Mailinglist Archive: opensuse-packaging (134 mails)
| < Previous | Next > |
[opensuse-packaging] To getent or not to getent
- From: Jan Engelhardt <jengelh@xxxxxxxxxx>
- Date: Fri, 1 Jul 2011 18:08:45 +0200 (CEST)
- Message-id: <alpine.LNX.2.01.1107011759120.8308@frira.zrqbmnf.qr>
Heya,
some packages in the openSUSE distribution do this (or equivalent) in
their %post section:
%post
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
some packages in the openSUSE distribution do this (or equivalent) in
their %post section:
%post
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 > |