X-Git-Url: https://git.cameronkatri.com/pw-darwin.git/blobdiff_plain/ff4aa702015e5d6b3863c90eba93e78bb2e26a23..56c718c019f68b7adda30de4181d84b3be28e1f1:/adduser/rmuser.perl diff --git a/adduser/rmuser.perl b/adduser/rmuser.perl index ae8ce8a..1ffac08 100644 --- a/adduser/rmuser.perl +++ b/adduser/rmuser.perl @@ -32,6 +32,8 @@ # # $FreeBSD$ +use Fcntl; + sub LOCK_SH {0x01;} sub LOCK_EX {0x02;} sub LOCK_NB {0x04;} @@ -42,7 +44,7 @@ $ENV{"PATH"} = "/bin:/sbin:/usr/bin:/usr/sbin"; umask(022); $whoami = $0; $passwd_file = "/etc/master.passwd"; -$ptmp = "/etc/ptmp"; +$passwd_tmp = "/etc/ptmp"; $group_file = "/etc/group"; $new_group_file = "${group_file}.new.$$"; $mail_dir = "/var/mail"; @@ -311,8 +313,8 @@ sub update_passwd_file { print STDERR "Updating password file,"; seek(MASTER_PW, 0, 0); - sysopen(NEW_PW, $etc_ptmp, O_RDWR|O_CREAT|O_EXCL, 0600) || - die "\n${whoami}: Error: Couldn't open file ${etc_ptmp}:\n $!\n"; + sysopen(NEW_PW, $passwd_tmp, O_RDWR|O_CREAT|O_EXCL, 0600) || + die "\n${whoami}: Error: Couldn't open file ${passwd_tmp}:\n $!\n"; $skipped = 0; while () { @@ -339,8 +341,8 @@ sub update_passwd_file { if ($skipped == 0) { print STDERR "\n${whoami}: Whoops! Didn't find ${login_name}'s entry second time around!\n"; - unlink($etc_ptmp) || - print STDERR "\n${whoami}: Warning: couldn't unlink $etc_ptmp ($!)\n\tPlease investigate, as this file should not be left in the filesystem\n"; + unlink($passwd_tmp) || + print STDERR "\n${whoami}: Warning: couldn't unlink $passwd_tmp ($!)\n\tPlease investigate, as this file should not be left in the filesystem\n"; &unlockpw; exit 1; } @@ -349,7 +351,7 @@ sub update_passwd_file { # Run pwd_mkdb to install the updated password files and databases print STDERR " updating databases,"; - system('/usr/sbin/pwd_mkdb', '-p', ${passwd_file}); + system('/usr/sbin/pwd_mkdb', '-p', ${passwd_tmp}); print STDERR " done.\n"; close(MASTER_PW); # Not useful anymore @@ -378,7 +380,7 @@ sub update_group_file { chown($group_uid, $group_gid, $new_group_file) || print STDERR "\n${whoami}: Warning: could not set owner/group of new group file to ${group_uid}/${group_gid} ($!)\n\rContinuing, but please check ownership of $group_file!\n"; while ($i = ) { - if (!($i =~ /$login_name/)) { + if (!($i =~ /\Q$login_name\E/)) { # Line doesn't contain any references to the user, so just add it # to the new file print NEW_GROUP $i; @@ -494,7 +496,7 @@ sub invoke_atq { while(defined($_ = )) { chomp; - if (/^\d\d:\d\d:\d\d\s+\d\d\/\d\d\/\d\d\s+(\S+)\s+\S+\s+(\d+)$/) { + if (/^\d\d.\d\d.\d\d\s+\d\d.\d\d.\d\d\s+(\S+)\s+\S+\s+(\d+)$/) { push(@at, $2) if ($1 eq $user); } } @@ -531,10 +533,10 @@ sub remove_at_jobs { return 1 if ($user eq ""); - print STDERR "Removing user's at jobs:"; @at = invoke_atq($user); return 0 if ($#at == -1); + print STDERR "Removing user's at jobs:"; print STDERR " @at:"; $atrm = invoke_atrm($user, @at); if ($atrm ne "") { @@ -542,7 +544,7 @@ sub remove_at_jobs { return 1; } - print STDERR "done.\n"; + print STDERR " done.\n"; return 0; }