[dhcp] One more tweak of adding of user and group (#699713)

Jiří Popelka jpopelka at fedoraproject.org
Fri Sep 9 15:17:07 UTC 2011


commit 0f0b1e4ee5a1aa322e45b823fe23cc70ee9b5e57
Author: Jiri Popelka <jpopelka at redhat.com>
Date:   Fri Sep 9 17:16:12 2011 +0200

    One more tweak of adding of user and group (#699713)

 dhcp.spec |   21 +++++++++++++++------
 1 files changed, 15 insertions(+), 6 deletions(-)
---
diff --git a/dhcp.spec b/dhcp.spec
index d25e7ff..623ee6b 100644
--- a/dhcp.spec
+++ b/dhcp.spec
@@ -456,12 +456,20 @@ find ${RPM_BUILD_ROOT}/%{_libdir} -name '*.la' -exec '/bin/rm' '-f' '{}' ';';
 
 %pre
 # /usr/share/doc/setup/uidgid
-getent group dhcpd >/dev/null || groupadd --gid 177 --system dhcpd
-getent passwd dhcpd >/dev/null || \
-    useradd --system \
-            --uid 177 --gid dhcpd \
-            --home /var/lib/dhcpd --shell /sbin/nologin \
-            --comment "DHCP server" dhcpd
+if ! getent group dhcpd >/dev/null ; then
+  if ! getent group 177 >/dev/null ; then
+    groupadd --system --gid 177 dhcpd
+  else
+    groupadd --system dhcpd
+  fi
+fi
+if ! getent passwd dhcpd >/dev/null ; then
+    if ! getent passwd 177 >/dev/null ; then
+      useradd --system --uid 177 --gid dhcpd --home / --shell /sbin/nologin --comment "DHCP server" dhcpd
+    else
+      useradd --system --gid dhcpd --home / --shell /sbin/nologin --comment "DHCP server" dhcpd
+    fi
+fi
 exit 0
 
 %post
@@ -629,6 +637,7 @@ fi
 %changelog
 * Fri Sep 09 2011 Jiri Popelka <jpopelka at redhat.com> - 12:4.2.2-6
 - PIE-RELRO.patch is not needed anymore, defining _hardened_build does the same
+- One more tweak of adding of user and group (#699713)
 
 * Fri Sep 09 2011 Adam Tkac <atkac redhat com> - 12:4.2.2-5
 - rebuild against new bind


More information about the scm-commits mailing list