home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / c / cops_104.zip / cops_104 / perl / shadow.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  1992-03-10  |  849b  |  32 lines

  1. #!/bin/sh
  2. #
  3. #  Usage: shadow.stuff
  4. #
  5. #   Extracts the correct info from shadow pass to use for processing with
  6. # the rest of the perl stuff
  7. #
  8. #   The way you use this is just to type "shadow.stuff > tempfile";
  9. # this will create a file, "tempfile" (or whatever), that *should*
  10. # be the equivalent to a normal password file.  Of course, you'll have
  11. # to run this as root so that you can read the shadow password file.
  12.  
  13. shadow=/etc/shadow
  14. passwd=/etc/passwd
  15. foo_pass=./shadow.tmp.$$
  16.  
  17. # foo_pass=shadow.pass
  18.  
  19. cat $passwd $shadow | sort > $foo_pass
  20.  
  21. awk -F: '{parray[$1] = $0":"parray[$1]} END { \
  22.     for (line in parray) { \
  23.         nf=split(parray[line], pline, ":"); \
  24.         if (pline[9] != "LOCKED" && nf == 13) {
  25.             print pline[1]":"pline[9]":"pline[3]":"pline[4]":" \
  26.             pline[5]":"pline[6]":"pline[7]; \
  27.                   } \
  28.               } \
  29.         }' $foo_pass
  30. rm $foo_pass
  31.  
  32.