Cover V06, I06
Article
Figure 1
Figure 2
Figure 3
Figure 4
Figure 5
Listing 1
Listing 2
Listing 3
Sidebar 1
Sidebar 2
Sidebar 3
Sidebar 4

jun97.tar


Listing 3: reset_user Reset locked account and assign a new random password

#!/usr/local/bin/perl # -------------------------------------------------------------------- # reset_user Reset any administrative lock or any other lockout # condition, assign and display a new randomly # generated password and set password to expire # on next use. # # usage: reset_user logonid # # args: # logonid : logonid to be reset (required) # -------------------------------------------------------------------- if ( ! $ARGV[0] ) { print STDERR "logonid argument required\n"; exit 1; } $logonid = $ARGV[0]; $rc = system("/usr/lbin/modprpw -k $logonid 2> /dev/null") / 256; if ( $rc != 0 ) { print "reset user: modprpw -k rc=$rc\n"; } if ( $rc == 3 ) { print "$logonid can not be found\n"; exit 1; } &_gc_; chop ( $host = `hostname` ); print "$logonid\'s new password on $host is: $pw\n"; $rc = system("/usr/lbin/modprpw -w \"$epw\" $logonid") / 256; $rc = system("/usr/lbin/modprpw -e $logonid") / 256; exit; sub _gc_ { srand(time|$$); $key1 = int(rand(26)) + 97; srand($$); $key2 = int(rand(26)) + 97; srand(time); $key3 = int(rand(26)) + 97; srand(time + $$); $key4 = int(rand(1) * 10000); $pw = pack("ccc", $key1, $key2, $key3) . $key4; srand(time|$$); $epw = crypt( $pw, $key1 ) } # -------------------------------------------------------------------- # Notes: The subroutine _gc_ uses four random # keys to generate a three alphabetic password # prefix that is followed by four digits. More # robust methods of password generation can # be substituted. However, the passwords # generated are only supposed to be temporary. # ------------------------------------------------------------------- # End of File