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 / user.chk < prev    next >
Text File  |  1992-03-10  |  2KB  |  63 lines

  1. #!/bin/sh -- need to mention perl here to avoid recursion
  2. 'true' || eval 'exec perl -S $0 $argv:q';
  3. eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
  4. & eval 'exec /usr/local/bin/perl -S $0 $argv:q'
  5.         if 0;
  6.  
  7. #
  8. #  This combines user.chk and home.chk.  It searches for home directories
  9. # and various user startup files for world writability, as well as flagging
  10. # any .rhosts and .netrc files that are readable.  You can change the
  11. # files checked by changing @ftable and @readables, respectively.
  12.  
  13. #
  14. # check for writable files in all user's homes
  15. #
  16. require "pass.cache.pl";
  17. require "is_able.pl";
  18.  
  19. # files checked for:
  20. @ftable = ("rhosts", "profile", "login", "logout", "cshrc",
  21.        "bashrc", "bash_profile", "inputrc", "screenrc",
  22.        "kshrc", "tcshrc", "netrc", "forward", "dbxinit",
  23.        "distfile", "exrc", "emacsrc", "remote", "mh_profile",
  24.        "xinitrc", "xsession", "Xdefaults", "Xresources", "rninit");
  25.  
  26. @readables = ("netrc", "rhosts");
  27.  
  28. local(%done);
  29.  
  30. # what's the point of doing a keys and using $i ??
  31. # why not just do "for $dir (values %uname2dir) {" ????
  32. for $i (keys %uname2dir) {
  33.     $dir = $uname2dir{$i};
  34.     #   I don't want to hear about every file in their home dir, if 
  35.     # is WW, but still need to check the .netrc file for readability...
  36.     next unless $dir;
  37.     next if $done{$dir}++;
  38.     if (-e $dir) { 
  39.         if (&is_able($dir, "w", "w")) {
  40.             for $r (@readables) {
  41.                 if (-s "$dir/.$r") {
  42.                     &is_able("$dir/.$r", "w", "r");
  43.         }
  44.         }
  45.             next;
  46.     }
  47.         for $file (@ftable) {
  48.             $foo_file = $dir . "/.$file";
  49.             if (-e $foo_file) {
  50.                 &is_able($foo_file, "w", "w");
  51.                 for $r (@readables) {
  52.                     if ($file eq $r && -s $foo_file) {
  53.                         &is_able($foo_file, "w", "r");
  54.             }
  55.         }
  56.         }
  57.     }
  58.     }
  59. }
  60.  
  61. 1;
  62.