[RFC] BLFS profile group/user creation

Thomas Pegg thomasp at linuxfromscratch.org
Sat Oct 23 14:22:08 PDT 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Kevin P. Fleming wrote:
| Throughout the profile, we use some common idioms for creating users and
| groups needed for packages. However, the current methods have some
| problems...
|
| -- Users --
|
| Currently, we use
|
| {execute command="grep -q ^username /etc/passwd || useradd"}
|   ...
|   {param}username{/param}
| {/execute}
|
| However, this fails if the system is using any alternative methods of
| providing usernames (NIS, winbind, etc.), and it also doesn't take into
| account that there may be multiple usernames that start with the same
| string.
|
| A better solution is:
|
| {execute command="getent passwd username > /dev/null || useradd"}
|   ...
|   {param}username{/param}
| {/execute}
|
| This will search for the username using whatever means the system is
| configured to do, and won't find a similar (but longer) username.
|
| -- Groups --
|
| Currently, we use
|
| {execute command="groupadd"}
|   {param}-f{/param}
|   {param}groupname{/param}
| {/execute}
|
| This fails if the group already exists, because groupadd returns a
| failure. It also fails if the system is using an alternative source of
| groupnames.
|
| A better solution is:
|
| {execute command="getent group groupname > /dev/null || groupadd"}
|   {param}groupname{/param}
| {/execute}
|
| If there is agreement that this is the right way to go, anyone want to
| tackle converting the profile over to these methods?

Sounds pretty good, never even knew that existed till now.

I'll probably integrate it into some updates I got to do for the BLFS
profile.

- --
Thomas
LFS User : 4729
Linux User : 298329
warpcore -  16:20:08 up 18:46,  2 users,  load average: 0.18, 0.13, 0.09
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFBesuAs/fpwCov90QRAo/CAKDuRsZ+iHfJbyXYG51P+Ybc7U7VAQCeIevU
sOmyjw4oD4yGysgI7t0g4FU=
=VeFm
-----END PGP SIGNATURE-----



More information about the alfs-discuss mailing list