* vipw in perl, to help with "vipw: you mangled the temp file, /etc/passwd unchanged" errors
@ 2001-11-27 19:50 David Nicol
2001-11-28 16:45 ` vipw in perl, to help with "vipw: you mangled the temp file, /etc/passwd Jerry Leslie
0 siblings, 1 reply; 2+ messages in thread
From: David Nicol @ 2001-11-27 19:50 UTC (permalink / raw)
after reading
http://isisesc.supelec.fr/list-tru64/archive/August2000/0355.html
about
vipw: you mangled the temp file, /etc/passwd unchanged
errors,
I have written the following replacement for vipw.
What other checks should it do on the password file?
#!/usr/local/bin/perl
=pod
perl vipw
copyright 2002 UMKC (David Nicol)
released as public domain utility
=cut
$pid = $$;
system "cp /etc/passwd /etc/ptmp.$pid";
EDIT:
fork or exec "vi /etc/ptmp.$pid";
wait;
eval {
open CHECK, "</etc/ptmp.$pid";
while (<CHECK>){
/\S/ or next; # blank lines are okay
@F = split /:/;
$F[2] =~ /^\d+$/ or die "nonnumeric UID in line $. : [$_]\n";
$F[3] =~ /^\d+$/ or die "nonnumeric GID in line $. : [$_]\n";
-d $F[5] or die "home directory [$F[5]] does not exist in line $. : [$_]\n";
};
};
if ($@){
print $@;
print "enter q* or e* to quit/exit, anything else to edit again\n";
$_=<STDIN>;
/^[qeQE]/ or goto EDIT;
unlink "/etc/ptmp.$pid";
exit;
};
system "mv /etc/ptmp.$pid /etc/passwd";
exec q{/usr/sbin/mkpasswd /etc/passwd};
__END__
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2001-11-28 16:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-11-27 19:50 vipw in perl, to help with "vipw: you mangled the temp file, /etc/passwd unchanged" errors David Nicol
2001-11-28 16:45 ` vipw in perl, to help with "vipw: you mangled the temp file, /etc/passwd Jerry Leslie
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox