From ec149da51a7349cd747549c484a9019515922e72 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Sun, 6 Mar 2011 09:34:22 +0100 Subject: [PATCH] Build system: Automatically set capabilities flag / set-UID bit when installing as root. --- src/Makefile.am | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Makefile.am b/src/Makefile.am index bc35a78..29e7d92 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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 -- 2.11.0