#!/usr/local/bin/perl # # user_links --- User Home Page Links # # Search all the users home directories for a wide world web public # directory and output the ``User Supplied Home Pages'' document to be # directly sent to the caller. # # Example Usage: CIT, Griffith University, Australia # http://www.cit.gu.edu.au/cgi-bin/user-links # # This program currently knows about and looks for the following html # document files in users WWW public directory. ( "public_html"? ) # # index.html The mail home page of the user, if not present # the user is not presented in the list thus allowing # hidden homepages to exist. # comment.html A short comment about this users WWW home to be # included. # personal.html personal information about this user specifically. # # NOTE: this program ignores all input arguments making it very secure. # # Programmer: Anthony Thyssen 29 May 94 # http://www.cit.gu.edu.au/~anthony/ # # --------------------------------------------------------------------------- # The following constants is used to determine the directories and files # the might supply. Only the user's WWW directory must exist and be # readable by the httpd user `nobody'. The other files is optional. # # For best effect the user should also supply a summery file ``comment.html'' # and an initial index (home page) file ``index.html''. $USER_DIR="www"; # Name of directory to look for in users homes # default "public_html", set in httpd configs @USER_INDEX= ( "index.html", # list of valid index files "index.htm", # user home pages (must be present) "index.shtml" ); # $USER_SUMMERY="comment.html"; # the short summery to include in the output. $USER_PERSONAL="personal.html"; # the users personal details page $USER_PUBS="publications.html"; # publications by the user (not used) $MIN_UID=100; # the smallest USER_ID a user can have $HELP_DOC=' Installing a WWW Homepage '; $WEBMASTER=' webmaster@cit.gu.edu.au'; # --------------------------------------------------------------------------- # Print the top part of the user links document print <<"EOF"; Content-type: text/html User Home Pages

User Home Pages

The following is a list of local users who have provided public information maintained by that individual. I can not make any guarantee as to the quality, accuracy and/or the working status of this information.

This list is automatically collected whenever a request is made by the server. Staff members who wish to create a personal home page or information area can read $HELP_DOC (please read it) which explains how to do this. For more information or if you are experiencing problems contact $WEBMASTER

EOF # For each user on this machine determine if they provide a WWW directory open(PASSWD, "/etc/passwd") || die "Can't open passwd file: $!\n"; while( $userrec = ) { ($login,$pass,$uid,$gid,$gcos,$home,$shell) = split(/:/, $userrec); $fullname = $gcos; $fullname =~ s/^[^,]*-(.*)\(.*/$1/ || $fullname =~ s/,.*//; if ( $fullname =~ /&/) { # you don't want to know. $name = $login; substr($name,0,1) =~ tr/a-z/A-Z/; $fullname =~ s/&/$name/; } # remove system, disabled and demo accounts next if $uid < $MIN_UID # Ignore the system accounts || $home eq "" # no home directory given || $home eq "/" # home is root || $shell eq "" # no shell || $shell =~ "NOSHELL" # DISABLED account || $shell =~ "SECURE" # SECURED account ; # add user if they have WWW dir which is accessable (read is not needed) for $index ( @USER_INDEX ) { if( -f "$home/$USER_DIR/$index" && -r _ ) { $links_found++; print "
$fullname,\n"; print " <$login\@cit.gu.edu.au>\n"; # if the user has some personal details provide a link to this too if ( -f "$home/$USER_DIR/$USER_PERSONAL" && -r _ ) { print " Personal Details\n"; } # add user summery if present (presumably it is only about two lines) if ( -f "$home/$USER_DIR/$USER_SUMMERY" && -r _ ) { open( COMMENT, "$home/$USER_DIR/$USER_SUMMERY" ) || next; print "
"; while( $line = ) { print $line; } close COMMENT; } last; # finished with this user } # if index file has been found } # for each index file type } print <<"EOF" if ! $links_found; Sorry no staff member has made any information publicly available at this time. EOF print <<"EOF";

Program: ``user_links'' -- User Home Page Linker
Created: 26th November 1993
Modified: 7th August 1997
Written: Anthony Thyssen, < anthony\@cit.gu.edu.au>
Send comments, errors and suggestions to $WEBMASTER
EOF