# procedure to check if the setuid bit is on sub checkSUID { return( -u $_[0] ); }
Some file test operators | |
---|---|
-r | readable |
-x | executable |
-e | exists |
-d | is a directory |
-t | is a tty |
-T | text file |
################################################################ # Check Security ################################################################ # Users who wish to use this program must # put the file ".allowmailform" in their home directory on the # machine running this script. We don't want people creating # forms that are abused to send "anonymous" mail. $homedir = (getpwnam($recipient))[7]; if (! -e "$homedir/.allowmailform") { # this user does not permit the server to send mail to him. Quit. &error("The recipient of the form has not enabled access for this form"); exit(0); }Note the interface to the system through
getpwnam
. One reason
perl is so widely used among the system administration community is that
it offers builtins to access things like password files (possibly through NIS
or similar) just as if it was C.
Note the clever subscripting of the list that getpwnam
returns.
getpwnam
returns all the information in the password file for
a user. We take that result in a list context and get the eighth element.
The National Center for Supercomputing Applications
University of Illinois at Urbana-Champaign
johnsonb@ncsa.uiuc.edu
Last modified: June 19, 1997