#!/usr/bin/perl # # mailall # # sends mail to all users on this host. verifies that the user is really # a user by checking uid, shell, and login name. allows us to send mail # to, for example, "allusers@mother.cs.colorado.edu" and delievers that # mail to all the "real" people on that machine. # # requires a line in /usr/lib/aliases like: # allusers: "|/usr/local/bin/mailall" # # By: davewood@cs.colorado.edu # October 15, 1992 # $MIN_ID = 1000; # # first we get a list of legal shells # open(SHELLS,"/etc/shells"); @shells = ; close SHELLS; # # now look at all the passwd entries and make a list of "real" usernames # open(PASSWD,"/etc/passwd"); foreach () { undef $login,$passwd,$uid,$gid,$gcos,$home,$shell; ($login,$passwd,$uid,$gid,$gcos,$home,$shell) = split(/:/); push(@mailto,$login) if ($uid >= $MIN_ID && $login ne "nobody" && (grep(/^$shell$/,@shells) || $shell =~ /^$/) && length($passwd) == 13); } close PASSWD; # # now shove stdin into a mail message to all these users # open (MAIL,"|/usr/lib/sendmail @mailto"); foreach () { print MAIL; } close MAIL;