- Create a system user, not a regular user

- Check if user/group already exists and are in system range
- Do not ignore return values from user/group creation

OBS-URL: https://build.opensuse.org/package/show/server:dns/nsd?expand=0&rev=36
This commit is contained in:
Adam Majer 2018-02-12 09:05:22 +00:00 committed by Git OBS Bridge
parent 1e575e0155
commit 15a8757c21
2 changed files with 15 additions and 4 deletions

View File

@ -1,3 +1,10 @@
-------------------------------------------------------------------
Mon Feb 12 08:54:46 UTC 2018 - adam.majer@suse.de
- Create a system user, not a regular user
- Check if user/group already exists and are in system range
- Do not ignore return values from user/group creation
-------------------------------------------------------------------
Mon Feb 5 10:26:02 UTC 2018 - adam.majer@suse.de

View File

@ -54,10 +54,11 @@ BuildRequires: pwdutils
BuildRequires: tcpd-devel
Requires: %fillup_prereq
Requires: pwdutils
Requires(pre): coreutils
Requires(post): coreutils
Requires(post): findutils
Requires(post): shadow
Requires(pre): shadow
Requires(post): shadow
%if %{with systemd}
BuildRequires: systemd-devel
%{?systemd_requires}
@ -114,10 +115,13 @@ ln -s -f %{_sysconfdir}/init.d/%{name} %{buildroot}%{_sbindir}/rc%{name}
%pre
#
# e.g. adding user
# adding user and group, if it doesn't exist yet
#
%{_sbindir}/groupadd -r _nsd &>/dev/null ||:
%{_sbindir}/useradd -g _nsd -s /bin/false -r -c "user for %{name}" -d %{home} _nsd &>/dev/null ||:
if ! ${_bindir}/id _nsd > /dev/null 2> /dev/null; then
echo "Creating _nsd:_nsd" && \
%{_sbindir}/groupadd -r _nsd && \
%{_sbindir}/useradd -r -g _nsd -s /bin/false -r -c "user for %{name}" -d %{home} _nsd
fi
%if %{with systemd}
%service_add_pre %{name}.service
%endif