Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 25 May 1998 03:44:23 +0800 (SGT)
From:      chas <panda@peace.com.my>
To:        Alex <garbanzo@hooked.net>, questions@FreeBSD.ORG
Subject:   Re: Generating a master.passwd from pwd.db?
Message-ID:  <3.0.32.19980525040629.00a02410@peace.com.my>

next in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3.0.32.19980525040629.00a02410>