#
# $FreeBSD$
+use Fcntl;
+
sub LOCK_SH {0x01;}
sub LOCK_EX {0x02;}
sub LOCK_NB {0x04;}
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";
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 (<MASTER_PW>) {
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;
}
# 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
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 = <GROUP>) {
- 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;
while(defined($_ = <ATQ>)) {
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);
}
}
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 "") {
return 1;
}
- print STDERR "done.\n";
+ print STDERR " done.\n";
return 0;
}