src/Makefile.am: Make setcap and chmod fault-tolerant.
[liboping.git] / src / Makefile.am
index bc35a78..1326783 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 || true; \
+                       setcap cap_net_raw=ep $(DESTDIR)$(bindir)/noping || true; \
+               else \
+                       echo "Setting set-UID bit on binaries."; \
+                       chmod u+s $(DESTDIR)$(bindir)/oping || true; \
+                       chmod u+s $(DESTDIR)$(bindir)/noping || true; \
+               fi; \
+       fi