From owner-freebsd-questions Sun May 24 13:03:41 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id NAA03884 for freebsd-questions-outgoing; Sun, 24 May 1998 13:03:41 -0700 (PDT) (envelope-from owner-freebsd-questions@FreeBSD.ORG) Received: from dove.peace.com.my (peace.com.my [202.184.153.15]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id NAA03847 for ; Sun, 24 May 1998 13:03:19 -0700 (PDT) (envelope-from panda@peace.com.my) Received: from lovebox (love.com.my [202.184.153.17]) by dove.peace.com.my (8.8.5/8.8.5) with SMTP id DAA11759; Mon, 25 May 1998 03:44:23 +0800 (SGT) Date: Mon, 25 May 1998 03:44:23 +0800 (SGT) Message-Id: <3.0.32.19980525040629.00a02410@peace.com.my> X-Sender: panda@peace.com.my X-Mailer: Windows Eudora Pro Version 3.0 (32) To: Alex , questions@FreeBSD.ORG From: chas Subject: Re: Generating a master.passwd from pwd.db? Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG The difficult way I think : take a look at "man getpwent" and write a script. I'm sure perl must have a module to access this. Using python, it's rather easy : >>> import pwd >>> x = pwd.getpwall() Now x contains info like : [('root', '$1$3KagL$aHK65kVdt9gQLJqIx9HUU1', 0, 0, 'Charlie &', '/root', '/bin/csh'), ('toor', '*', 0, 0, 'Bourne-again Superuser', '/root', ''), ('daemon', '*', 1, 1, 'Owner of many system processes', '/root', '/nonexistent'), .... etc simply join the fields with ":" But note that you still have to add ":0:0" for 2 of the fields (6th and 7th fields... every entry seems to have these) though I don't know what they do. ie. using only getpwall()'s results would produce : gary:$1$s5oclFll$3244G/:1001:1000::gary:/home/gary:/bin/sh when the real entry should be : gary:$1$s5oclFll$3244G/:1001:1000::0:0:gary:/home/gary:/bin/sh hth, chas >As the subject alluded to, I'm curious if there's some way to (easily) >generate passwd and master.passwd files from their respective databases. >I've trashed the master.passwd accidentally, and while I have a backup, >I'd like to know if there's some way to fix this if sometime I >accidentally zap the backup file too. > >- alex > >| "Contrary to popular belief, penguins are not the salvation of modern | >| technology. Neither do they throw parties for the urban proletariat." | >| Powered by FreeBSD http://www.freebsd.org/ | > > >To Unsubscribe: send mail to majordomo@FreeBSD.org >with "unsubscribe freebsd-questions" in the body of the message > > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message