Reverse makemap command

Gerald Combs gerald at ethereal.com
Fri Apr 18 15:58:45 CDT 2003


On 18 Apr 2003, Brad Crotchett wrote:

> I am running db3 and makemap does not have a -u option.  I copied the db
> file over to a system running db4 and tried from there but it complained
> that it was from an older version of Berkeley and need to be recreated. 
> Any other ideas on reversing it?

Write a quick perl script/C program to open the db file and dump out its
hash keys and contents?  It's been a while, but I think the perl would
look something like:

use DB_File;
tie %dbhash, "DB_File", "access.db", O_RDONLY, 0600, $DB_HASH ;
while ( ($key, $val) = each %dbhash ) {
    print "$key: $valn";
}

The first Unix system I administered ran Ultrix.  /etc/passwd (there was
no shadow) was stored as plain text and as DBM files.  One day I
accidentally deleted /etc/passwd.  I got to spend the afternoon writing a
C program to read the db files and regenerate /etc/passwd.  Luckily my
boss and coworker were patient people.




More information about the Kclug mailing list