]> sourceware.org Git - systemtap.git/commitdiff
Simplify creation of groups during installation
authorDavid Ward <david.ward@ll.mit.edu>
Wed, 30 Jan 2019 05:37:55 +0000 (00:37 -0500)
committerFrank Ch. Eigler <fche@redhat.com>
Mon, 4 Feb 2019 17:01:37 +0000 (12:01 -0500)
Use the "-f" option of "groupadd", rather than calling it a second
time if the desired GID is already in use.

Do not call "getent" twice. We know that a group exists if the first
call to "getent" returned successfully, or otherwise if "groupadd"
returned successfully.

stapbpf/Makefile.am
stapbpf/Makefile.in
staprun/Makefile.am
staprun/Makefile.in
systemtap.spec

index fa2035dabd4f83f20915c7354f40fa5fbaabc783..1626e4a33ea78e76332125a8087e698f521283ed 100644 (file)
@@ -43,8 +43,7 @@ git_version.stamp ../git_version.h:
 # make install, and have "sudo stap ...." or "sudo stapbpf ...." work later.
 install-exec-hook:
        if [ `id -u` -eq 0 ]; then \
-               getent group stapusr >/dev/null || groupadd -g 156 -r stapusr 2>/dev/null || groupadd -r stapusr; \
-               getent group stapusr >/dev/null \
+               (getent group stapusr >/dev/null || groupadd -f -g 156 -r stapusr) \
                && chgrp stapusr "$(DESTDIR)$(bindir)/stapbpf" \
                && chmod 04110 "$(DESTDIR)$(bindir)/stapbpf"; \
        fi
index f7f20b6ee264d5ac703f1578021023ab92b2d6f5..487da04d725144cbcb8737856528b051dfbac3d6 100644 (file)
@@ -849,8 +849,7 @@ uninstall-man: uninstall-man8
 # make install, and have "sudo stap ...." or "sudo stapbpf ...." work later.
 @HAVE_BPF_DECLS_TRUE@install-exec-hook:
 @HAVE_BPF_DECLS_TRUE@  if [ `id -u` -eq 0 ]; then \
-@HAVE_BPF_DECLS_TRUE@          getent group stapusr >/dev/null || groupadd -g 156 -r stapusr 2>/dev/null || groupadd -r stapusr; \
-@HAVE_BPF_DECLS_TRUE@          getent group stapusr >/dev/null \
+@HAVE_BPF_DECLS_TRUE@          (getent group stapusr >/dev/null || groupadd -f -g 156 -r stapusr) \
 @HAVE_BPF_DECLS_TRUE@          && chgrp stapusr "$(DESTDIR)$(bindir)/stapbpf" \
 @HAVE_BPF_DECLS_TRUE@          && chmod 04110 "$(DESTDIR)$(bindir)/stapbpf"; \
 @HAVE_BPF_DECLS_TRUE@  fi
index 73ddc41ff7bfecb5f1636e3b299783e86658a1f6..f1a7a696f5ba3869a026b9c4f0e36c3e95bbcceb 100644 (file)
@@ -78,7 +78,7 @@ git_version.stamp ../git_version.h:
 # make install, and have "sudo stap ...." or "sudo staprun ...." work later.
 install-exec-hook:
        if [ `id -u` -eq 0 ]; then \
-               getent group stapusr >/dev/null || groupadd -g 156 -r stapusr 2>/dev/null || groupadd -r stapusr; \
-               getent group stapusr >/dev/null && chgrp stapusr "$(DESTDIR)$(bindir)/staprun"; \
-               chmod 04110 "$(DESTDIR)$(bindir)/staprun"; \
+               (getent group stapusr >/dev/null || groupadd -f -g 156 -r stapusr) \
+               && chgrp stapusr "$(DESTDIR)$(bindir)/staprun" \
+               && chmod 04110 "$(DESTDIR)$(bindir)/staprun"; \
        fi
index 6cb3966a58efb68fb01d4207acde27718d784e27..c518c7dbd18c4d7901c3d6110fffad23466e0a26 100644 (file)
@@ -1162,9 +1162,9 @@ git_version.stamp ../git_version.h:
 # make install, and have "sudo stap ...." or "sudo staprun ...." work later.
 install-exec-hook:
        if [ `id -u` -eq 0 ]; then \
-               getent group stapusr >/dev/null || groupadd -g 156 -r stapusr 2>/dev/null || groupadd -r stapusr; \
-               getent group stapusr >/dev/null && chgrp stapusr "$(DESTDIR)$(bindir)/staprun"; \
-               chmod 04110 "$(DESTDIR)$(bindir)/staprun"; \
+               (getent group stapusr >/dev/null || groupadd -f -g 156 -r stapusr) \
+               && chgrp stapusr "$(DESTDIR)$(bindir)/staprun" \
+               && chmod 04110 "$(DESTDIR)$(bindir)/staprun"; \
        fi
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
index c3a9a32e942c88784c9b436529de536500f63fdf..26bfad0a3b7edc3386d46672cf4a99d4c3a7e46e 100644 (file)
@@ -767,13 +767,13 @@ done
 %endif
 
 %pre runtime
-getent group stapusr >/dev/null || groupadd -g 156 -r stapusr 2>/dev/null || groupadd -r stapusr
-getent group stapsys >/dev/null || groupadd -g 157 -r stapsys 2>/dev/null || groupadd -r stapsys
-getent group stapdev >/dev/null || groupadd -g 158 -r stapdev 2>/dev/null || groupadd -r stapdev
+getent group stapusr >/dev/null || groupadd -f -g 156 -r stapusr
+getent group stapsys >/dev/null || groupadd -f -g 157 -r stapsys
+getent group stapdev >/dev/null || groupadd -f -g 158 -r stapdev
 exit 0
 
 %pre server
-getent group stap-server >/dev/null || groupadd -g 155 -r stap-server 2>/dev/null || groupadd -r stap-server
+getent group stap-server >/dev/null || groupadd -f -g 155 -r stap-server
 getent passwd stap-server >/dev/null || \
   useradd -c "Systemtap Compile Server" -u 155 -g stap-server -d %{_localstatedir}/lib/stap-server -r -s /sbin/nologin stap-server 2>/dev/null || \
   useradd -c "Systemtap Compile Server" -g stap-server -d %{_localstatedir}/lib/stap-server -r -s /sbin/nologin stap-server
This page took 0.035088 seconds and 5 git commands to generate.