Build system: Automatically set capabilities flag / set-UID bit when installing as...
authorFlorian Forster <octo@leeloo.lan.home.verplant.org>
Sun, 6 Mar 2011 08:34:22 +0000 (09:34 +0100)
committerFlorian Forster <octo@leeloo.lan.home.verplant.org>
Sun, 6 Mar 2011 08:34:22 +0000 (09:34 +0100)
src/Makefile.am

index bc35a78..29e7d92 100644 (file)
@@ -51,3 +51,16 @@ if BUILD_WITH_LIBRT
 noping_LDADD += -lrt
 endif
 endif # BUILD_WITH_LIBNCURSES
+
+install-exec-hook:
+       @if test "x0" = "x$$UID"; then \
+               if test "xLinux" = "x`uname -s`"; then \
+                       echo "Setting CAP_NET_RAW capability on binaries."; \
+                       setcap cap_net_raw=ep $(DESTDIR)$(bindir)/oping; \
+                       setcap cap_net_raw=ep $(DESTDIR)$(bindir)/noping; \
+               else \
+                       echo "Setting set-UID bit on binaries."; \
+                       chmod u+s $(DESTDIR)$(bindir)/oping; \
+                       chmod u+s $(DESTDIR)$(bindir)/noping; \
+               fi; \
+       fi