Mailinglist Archive: opensuse-packaging (134 mails)

< Previous Next >
[opensuse-packaging] To getent or not to getent

some packages in the openSUSE distribution do this (or equivalent) in
their %post section:

getent passwd user >/dev/null || useradd user || :

darix says this is against policy (what a killer argument), but closely
looking at what is happening, getent is just what is desired.

If getent were not used, useradd would throw a warning whenever the user
already exists, which would be the case on all upgrade attempts of such
packages. So people slap in

useradd user 2>/dev/null || :

instead, but that hides real errors that do not stem from a preexisting
user. So, with getent, one can check whether the user already exists and
not call useradd if so; otherwise do create the user, and NOT drop any
stderr messages.
To unsubscribe, e-mail: opensuse-packaging+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse-packaging+help@xxxxxxxxxxxx

< Previous Next >