Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: David Nicol <nicold@umkc.edu>
Subject: vipw in perl, to help with "vipw: you mangled the temp file, /etc/passwd  unchanged" errors
Date: Tue, 27 Nov 2001 13:50:20 -0600	[thread overview]
Message-ID: <3C03EE7C.42C37CC6@umkc.edu> (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__


             reply	other threads:[~2001-11-27 19:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-11-27 19:50 David Nicol [this message]
2001-11-28 16:45 ` vipw in perl, to help with "vipw: you mangled the temp file, /etc/passwd Jerry Leslie
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox