#!/usr/local/bin/perl -s # htmlUserList.pl -- A tool for creating and HTML list of system users # Ed Golden # Doke Scott # # # Version 0.99, 12/9/94 # Version 0.991, 17/12/94 # Added docs, index, homepage redirects, and userstatus # This is getting ugly. # Version 0.992 2 Feb 1996 Michael W. Gilbode # Removed finger information because it is now useless # Only display users with links now # Diplay using tables instead of separated by commas $ypcat = "/usr/bin/ypcat"; $cgiBin = "/cgi-bin"; $publicHTML = "public_html"; $redirect_file = ".homepage_redirect"; $doc_url = "userListDoc.html"; $url_pattern = '^http://[\w\.-]{1,33}(:\d{1,5})?(/[^\">]*)?$'; $userstatus_file = ".userstatus"; # Filter is a list of users which are not supposed to appear in the list $filter = 'root,daemon,staff,ftp,gnu,fax,faxadm,games,netgod,netwatch,'. 'securema,security,uucp,uucptest,infocon,theboss,account'; # for individual users to test their ~/public_html/.homepage_redirect files &testurl if ( $testurl ); $filter =~ s/,/\\b|\\b/g; $filter = "\\b$filter\\b"; # get the userstatus data from the yp map if ( open( ush, "$ypcat -k userstatus.byname |" ) ) { while ( ) { chop; s/&/&/g; s//>/g; s/"/"/g; ( $userName, $status ) = split( /\s+/, $_, 2 ); $userStatus{ $userName } = $status; $debug2 && print stderr "\$userStatus{ $userName } = $status\n"; } close ush; } # get the user's password data from the yp password system, or file open (pwdFD, "$ypcat passwd |") || open (pwdFD, ") { ($userName,$uid,$fullName,$homeDir) = m/([^:]+):[^:]*:([^:]*):[^:]*:([^:,]+)[^:]*:([^:]+)/; $debug && $userName !~ m/^scott|golden|scoggin|kok|sandler/o && next; $userName =~ m/$filter/o && next; $fullName =~ s/^(.*)<\/b>/\1/g; # sandler had bolds in his already $fullName =~ s/&/&/g; $fullName =~ s//>/g; $fullName =~ s/"/"/g; $fullNames{$userName} = $fullName; # vvvvvvvvvv $userHomes{$userName} = "/home/www/$homeDir"; # ^^^^^^^^^^ $userUid{$userName} = $uid; # we don't want to generate pointers to letters for # which we don't have users. if ( -r "$userHomes{$userName}/$publicHTML" ) { $letters{ substr( "$userName", 0, 1 ) } = 1; } } close pwdFD; $date=`date`; print " EE/CIS User Links

EE/CIS User Links

automaticly generated $date

"; foreach $letter (sort keys %letters ) { print "$comma$letter"; $comma = ", \n"; } print "

\n"; $current_letter = '`'; foreach $userName (sort keys %fullNames) { if ( -r "$userHomes{$userName}/$publicHTML" ) { # point their username at finger if ( ( $letter = substr( "$userName", 0, 1 ) ) ne $current_letter ) { print "

\n"; $current_letter = $letter; } printf(""); # point their full name at their home page $fullName = "$fullNames{$userName}"; $redirected = 0; if ( open( rdf, "<$userHomes{$userName}/$publicHTML/$redirect_file" ) ){ while( ) { chop; s/\s+$//; if ( m!$url_pattern! ) { printf ("",$fullName); $redirected = 1; last; } } } if ( ! $redirected ) { printf("",$fullName); } # their user status $status = ''; if ( open( ush, "<$userHomes{$userName}/$userstatus_file" ) ) { $debug && print stderr "taking ${userName}'s status from ". "/home/www/$userHomes{$userName}/$userstatus_file\n"; $status = ; chop; $status =~ s/&/&/g; $status =~ s//>/g; $status =~ s/"/"/g; close ush; } if ( $status eq '' && defined( $userStatus{ $userName } ) ) { $debug && print stderr "taking ${userName}'s status from ". "userstatus.byname\n"; $status = $userStatus{ $userName }; } if ( $status eq '' ) { $debug && print stderr "taking ${userName}'s status from ". "figure_status_string( $userUid{ $userName } )\n"; $status = &figure_status_string( $userUid{ $userName } ); } print "\n"; } } print "
home page user status
\n

$letter

\t%30s\t%30s\t $status
\n"; print "
staff\@eecis.udel.edu
"; sub figure_status_string { local( $uid ) = @_; return "System Account" if ( $uid < 900 ); return "Alien (Neither EE nor CIS)" if ( $uid < 1000 ); return "EE Faculty" if ( $uid < 2000 ); return "EE Graduate Student/Staff" if ( $uid < 3000 ); return "EE Undergraduate Student" if ( $uid < 4000 ); return "CIS Faculty" if ( $uid < 5000 ); return "CIS Graduate Student/Staff" if ( $uid < 6000 ); return "CIS Undergraduate Student" if ( $uid < 7000 ); return "UDel Computing Center Staff" if ( $uid < 8000 ); return "Semester Class Account" if ( $uid < 9000 ); return "Alien (Neither EE nor CIS)"; }; # for individual users to test their ~/public_html/.homepage_redirect files sub testurl { $rdf = "$ENV{'HOME'}/$publicHTML/$redirect_file"; $valid = ''; open( rdf, "<$rdf" ) || die "can't open $rdf: $!\n"; while( ) { chop; s/\s+$//; if ( m!$url_pattern! ) { print ":-) '$_'\n"; if ( $valid eq '' ) { $valid = $_; $validline = $.; } } else { print "yuck '$_'\n" } } print ( ( $valid eq '' ) ? "\nno valid urls were found in $rdf\n" : "\n$0 will use first valid url, from line $validline\n '$valid'\n"); exit 0; }