* Recovering Lost passwd file @ 1999-03-04 5:00 Ellefson 1999-03-04 5:00 ` Erik Persson 1999-03-11 5:00 ` Ron Feral 0 siblings, 2 replies; 4+ messages in thread From: Ellefson @ 1999-03-04 5:00 UTC (permalink / raw) I need to know if there is a way to recover a what appears to be a zeroed out passwd file by manipulating the passwd.pag. There is no backup, all the users were created in one evening (600 or so) and a backup could not be taken although I realize a cp of the /etc/passwd to /etc/passwd.bak, would of save my butt. It is not know as of yet what actually happened to the passwd file. But I would like to know up front before we start recreating them over again if we have a fighting chance at salvaging the lost passwd file. Thanks for you help! Jason ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Recovering Lost passwd file 1999-03-04 5:00 Recovering Lost passwd file Ellefson @ 1999-03-04 5:00 ` Erik Persson 1999-03-08 5:00 ` Allan Hawdon 1999-03-11 5:00 ` Ron Feral 1 sibling, 1 reply; 4+ messages in thread From: Erik Persson @ 1999-03-04 5:00 UTC (permalink / raw) "Ellefson" <ellefson@visi.com> writes: > I need to know if there is a way to recover a what appears to be a zeroed > out passwd file by manipulating the passwd.pag. There is no backup, all the > users were created in one evening (600 or so) and a backup could not be > taken although I realize a cp of the /etc/passwd to /etc/passwd.bak, would > of save my butt. It is not know as of yet what actually happened to the > passwd file. But I would like to know up front before we start recreating > them over again if we have a fighting chance at salvaging the lost passwd > file. Thanks for you help! > > Jason You will probably need both the .dir and .pag files, but if you have these you could do it like this (if the names are passwd.pag and passwd.dir): makedbm -u passwd > passwd.restore This will create a listing with lines that looks like: <number> <regular passwd entry> so, som awk processing might be in place. makedbm -u passwd | awk '{print $2}' > passwd.restore /Erik -- Erik Persson, System Manager e-mail: erik@ikp.liu.se Dept. of Mech. Engineering Voice: +46 13 28 2464 University of Link�ping, Sweden Fax: +46 13 28 2717 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Recovering Lost passwd file 1999-03-04 5:00 ` Erik Persson @ 1999-03-08 5:00 ` Allan Hawdon 0 siblings, 0 replies; 4+ messages in thread From: Allan Hawdon @ 1999-03-08 5:00 UTC (permalink / raw) Erik Persson <erik@ikp.liu.se> wrote: : "Ellefson" <ellefson@visi.com> writes: :> I need to know if there is a way to recover a what appears to be a zeroed :> out passwd file by manipulating the passwd.pag. There is no backup, all the :> users were created in one evening (600 or so) and a backup could not be :> taken although I realize a cp of the /etc/passwd to /etc/passwd.bak, would :> of save my butt. It is not know as of yet what actually happened to the :> passwd file. But I would like to know up front before we start recreating :> them over again if we have a fighting chance at salvaging the lost passwd :> file. Thanks for you help! :> :> Jason : You will probably need both the .dir and .pag files, but if you have : these you could do it like this (if the names are passwd.pag and : passwd.dir): : makedbm -u passwd > passwd.restore This doesn't seem to work for the files in /etc, at least on my 4.0b box. The following perl script will do the trick. Use at your own risk, I haven't thoroughly tested it. You'll get duplicate records, so you'll want to pipe the output through sort & uniq. Allan ======================================================================= use strict; use NDBM_File; use Fcntl; use vars qw( $key $val %PASSWD ); use vars qw( $uname $pwd $uid $gid $gcos $dir $shell ); tie (%PASSWD, 'NDBM_File', '/etc/passwd', O_RDONLY, 0) or die "Can't open ($!)"; while ( ($key, $val) = each %PASSWD ) { ($uname,$pwd,$val) = split /\000/, $val, 3; ($uid, $gid) = unpack "LL", $val; $val = substr $val, 13; ($gcos,$dir,$shell) = split /\000/, $val; print "$uname:$pwd:$uid:$gid:$gcos:$dir:$shell\n"; } untie %PASSWD; ============================================================================= ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Recovering Lost passwd file 1999-03-04 5:00 Recovering Lost passwd file Ellefson 1999-03-04 5:00 ` Erik Persson @ 1999-03-11 5:00 ` Ron Feral 1 sibling, 0 replies; 4+ messages in thread From: Ron Feral @ 1999-03-11 5:00 UTC (permalink / raw) Assuming that your passwd.pag and passwd.dir as in good shape and still the default locations you can probably just whip up a PERL script to use getpwent() for each user's information. You can also use the equiv. C function if you prefer. Just loop through and write the stuff out in the passwd file format. This is simpler than bothering with the DBM stuff. In article <mvyD2.730$66.38680@ptah.visi.com>, ellefson@visi.com says... >I need to know if there is a way to recover a what appears to be a zeroed >out passwd file by manipulating the passwd.pag. ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~1999-03-11 5:00 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 1999-03-04 5:00 Recovering Lost passwd file Ellefson 1999-03-04 5:00 ` Erik Persson 1999-03-08 5:00 ` Allan Hawdon 1999-03-11 5:00 ` Ron Feral
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox