#!/usr/local/bin/perl # # auth_user # # Checks a username and password against unix yellow pages to see if they are valid # # Arguments: # $username A username for which yellow pages is to be searched # $password The unencrypted password entered by this user # # Return Values: # 0 - user found & authorized # 1 - user not found # 2 - user found but not authorized # # Modification History: # 9/20/96 - tnd - Original Code # 10/30/96 - tjo - check in sc.sec (MACCS) authorization file, too # # # # sub auth_user { local( $username, $password ) = @_; local( @ypcat, $entry, $found, $ypname, $yppass ) = ( "", "", 0, "", "" ); @ypcat = `ypcat passwd`; # issue unix command & capture output foreach $entry (@ypcat) { ($ypname,$yppass) = split(/:/,$entry); if ($ypname eq $username) { $found += 1; last; } } # check MACCS authorization file, too if (`/usr/bin/grep -i "^$username " sc.sec`) { $found += 1; } if ($found == 2) { if (crypt($password, $yppass) eq $yppass) { 0; } # AUTHORIZED else { 2; } # NOT AUTHORIZED } else { 1; } # USER NOT FOUND } 1;