From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fa528,e4ce2f02460124d3 X-Google-Attributes: gidfa528,public X-Google-ArrivalTime: 2002-07-23 07:11:06 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!nntp.cs.ubc.ca!newsflash.concordia.ca!not-for-mail From: syl@alcor.concordia.ca (Sylvain Robitaille) Newsgroups: comp.unix.tru64 Subject: Re: corrupt /etc/passwd Date: 23 Jul 2002 14:11:06 GMT Organization: Concordia University, Montreal, Canada Message-ID: References: <3d3d52b5$1@eumel.hag.hilti.com> NNTP-Posting-Host: alcor.concordia.ca NNTP-Posting-User: syl User-Agent: slrn/0.9.5.7 (UNIX) Xref: archiver1.google.com comp.unix.tru64:8200 On Tue, 23 Jul 2002 14:57:22 +0200, Skaghk wrote: > I got a box running Tru64 V. 4.0 which got a blown up /etc/passwd. The > file currently consitst of 4096 characters of ASCII 0. Surprisingly > users still can log in and su to root also works well. Changing > passwords ist the only thing, that does not work. Appended below my signature is the start of a Perl script which will convert the /etc/passwd.dir and /etc/passwd.pag files into a not quite complete /etc/passwd.txt. You're going to need to either work on the script to complete it (It was really written for .htpasswd files with less information), or you'll need to go through the resulting passwd.txt file and fix up userids, groupids, and take ':' characters out of the GCOS field. Whether you want to add to the script or fix up the output manually probably depends on how many users you have... When you're done, rename /etc/passwd.txt to /etc/passwd. I'm sorry I don't have a more complete solution, but I hope this at least helps get you started in the right direction. Reloading from backup *would* be a *lot* easier, of course... ;-) -- ---------------------------------------------------------------------- Sylvain Robitaille syl@alcor.concordia.ca Systems analyst Concordia University Instructional & Information Technology Montreal, Quebec, Canada ---------------------------------------------------------------------- #!/local/paths/perl -wT # # file: dbm2txt.pl # # 2000/08/30 Sylvain Robitaille: Quick hack to extract text password # file from DBM file. my ($key, $value); my ($db_file) = @ARGV; if(!defined $db_file) { die "Usage:\n $0 \n"; } # Untaint input: if( $db_file =~ m%^([^`\\<>|]+)$% ) { $db_file = $1; } else { die "$db_file tainted\n"; } dbmopen %PW, "$db_file", 0666 or die "can't dbmopen $db_file: $!\n"; open TXTPW, "> $db_file.txt" or die "can't open $db_file.txt: $!\n"; # Make sure we'll be writing to the output file: my $oldfh = select TXTPW; # translate the input: while (($key,$value) = each %PW) { $value =~ s/[\0\s]+/:/g; $value =~ s/:$//g; print "$value\n"; } # Reset our stdout: select $oldfh; close TXTPW; dbmclose %PW;