This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
[PATCH] Fix "make install" in certain fakeroot environments
- From: David Ward <david dot ward at ll dot mit dot edu>
- To: systemtap at sourceware dot org
- Date: Sat, 26 Jan 2019 22:25:27 -0500
- Subject: [PATCH] Fix "make install" in certain fakeroot environments
Do not abort "make install" if the stapusr group cannot be found or
created, or it cannot be set as the owner of installed executables,
even when the effective user ID is 0.
These operations may not be possible in some fakeroot environments
that are used to build distribution binary packages. (I discovered
this issue on Arch Linux using "makechrootpkg".) The package build
files often specify these operations directly: see systemtap.spec.
Otherwise, use fewer commands to achieve the same result as before.
---
stapbpf/Makefile.am | 13 +++++--------
stapbpf/Makefile.in | 13 +++++--------
staprun/Makefile.am | 12 +++++-------
staprun/Makefile.in | 12 +++++-------
4 files changed, 20 insertions(+), 30 deletions(-)
diff --git a/stapbpf/Makefile.am b/stapbpf/Makefile.am
index fa2035dab..7f3511806 100644
--- a/stapbpf/Makefile.am
+++ b/stapbpf/Makefile.am
@@ -39,13 +39,10 @@ BUILT_SOURCES += git_version.stamp
git_version.stamp ../git_version.h:
$(MAKE) -C .. $(notdir $@)
-# Why the "id -u" condition? This way, an unprivileged user can run
-# make install, and have "sudo stap ...." or "sudo stapbpf ...." work later.
+# Why the "-" at the start of the line? This way, an unprivileged user can run
+# "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 \
- && chgrp stapusr "$(DESTDIR)$(bindir)/stapbpf" \
- && chmod 04110 "$(DESTDIR)$(bindir)/stapbpf"; \
- fi
+ -(getent group stapusr >/dev/null || groupadd -f -g 156 -r stapusr) \
+ && chgrp stapusr "$(DESTDIR)$(bindir)/stapbpf" \
+ && chmod 04110 "$(DESTDIR)$(bindir)/stapbpf"
endif
diff --git a/stapbpf/Makefile.in b/stapbpf/Makefile.in
index f7f20b6ee..1e1b334e3 100644
--- a/stapbpf/Makefile.in
+++ b/stapbpf/Makefile.in
@@ -845,15 +845,12 @@ uninstall-man: uninstall-man8
@HAVE_BPF_DECLS_TRUE@git_version.stamp ../git_version.h:
@HAVE_BPF_DECLS_TRUE@ $(MAKE) -C .. $(notdir $@)
-# Why the "id -u" condition? This way, an unprivileged user can run
-# make install, and have "sudo stap ...." or "sudo stapbpf ...." work later.
+# Why the "-" at the start of the line? This way, an unprivileged user can run
+# "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@ && chgrp stapusr "$(DESTDIR)$(bindir)/stapbpf" \
-@HAVE_BPF_DECLS_TRUE@ && chmod 04110 "$(DESTDIR)$(bindir)/stapbpf"; \
-@HAVE_BPF_DECLS_TRUE@ fi
+@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"
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/staprun/Makefile.am b/staprun/Makefile.am
index 73ddc41ff..288911f57 100644
--- a/staprun/Makefile.am
+++ b/staprun/Makefile.am
@@ -74,11 +74,9 @@ git_version.stamp ../git_version.h:
$(MAKE) -C .. $(notdir $@)
-# Why the "id -u" condition? This way, an unprivileged user can run
-# make install, and have "sudo stap ...." or "sudo staprun ...." work later.
+# Why the "-" at the start of the line? This way, an unprivileged user can run
+# "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 && chgrp stapusr "$(DESTDIR)$(bindir)/staprun"; \
- chmod 04110 "$(DESTDIR)$(bindir)/staprun"; \
- fi
+ -(getent group stapusr >/dev/null || groupadd -f -g 156 -r stapusr) \
+ && chgrp stapusr "$(DESTDIR)$(bindir)/staprun" \
+ && chmod 04110 "$(DESTDIR)$(bindir)/staprun"
diff --git a/staprun/Makefile.in b/staprun/Makefile.in
index 6cb3966a5..4c00a7df8 100644
--- a/staprun/Makefile.in
+++ b/staprun/Makefile.in
@@ -1158,14 +1158,12 @@ uninstall-man: uninstall-man8
git_version.stamp ../git_version.h:
$(MAKE) -C .. $(notdir $@)
-# Why the "id -u" condition? This way, an unprivileged user can run
-# make install, and have "sudo stap ...." or "sudo staprun ...." work later.
+# Why the "-" at the start of the line? This way, an unprivileged user can run
+# "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 && chgrp stapusr "$(DESTDIR)$(bindir)/staprun"; \
- chmod 04110 "$(DESTDIR)$(bindir)/staprun"; \
- fi
+ -(getent group stapusr >/dev/null || groupadd -f -g 156 -r stapusr) \
+ && chgrp stapusr "$(DESTDIR)$(bindir)/staprun" \
+ && chmod 04110 "$(DESTDIR)$(bindir)/staprun"
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
--
2.20.1