Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* 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

* Re: vipw in perl, to help with "vipw: you mangled the temp file, /etc/passwd
  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 ` Jerry Leslie
  0 siblings, 0 replies; 2+ messages in thread
From: Jerry Leslie @ 2001-11-28 16:45 UTC (permalink / raw)


David Nicol (nicold@umkc.edu) wrote:
:
: I have written the following replacement for vipw.
: What other checks should it do on the password file?
:
Don't know, but try posting to the comp.unix.tru64 newsgroup.

The comp.unix.osf.misc and comp.unix.osf.osf1 newsgroups became 
obsolete on 29 May 2000.

--Jerry Leslie.


^ 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