system("clear"); print "CREATE ACCOUNT:\n\n"; $username = &ask("Enter the login id of the new user: "); # # Read the local passwd file. # open (PWD,"$LOCAL_PASSWD")|| die "can't open $LOCAL_PASSWD\n"; while () { push(@local_passwd,$_); } close (PWD); # # Figure out what uids have been used # for ($i=0 ; $i<=$#local_passwd && ($_ = $local_passwd[$i]); $i++) { ($uname,$pwd,$uid) = split(/:/); push(@user_ids,$uid); } foreach $i (200..2000) { foreach $uid (@user_ids) { $uid_ok=1; if ($i eq $uid) { $uid_ok=0; last; } } if ($uid_ok) { $g_user_id = $i; last; } } undef @user_ids; # # Read the local password # open(PWD,"$LOCAL_PASSWD")|| die "can't open the $LOCAL_PASSWD\n"; while () { push(@local_passwd,$_); } close (PWD); # # Check for duplicate names # for ($i=0 ; $i<=$#local_passwd && ($_ = $local_passwd[$i]); $i++) { ($uname) = split(/:/); if ($uname eq $username) { print "DUPLICATE NAME: $username: can't continue\n"; exit(1); } } undef @local_passwd;