aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew G. Morgan <morgan@kernel.org>2021-08-25 19:48:12 -0700
committerAndrew G. Morgan <morgan@kernel.org>2021-08-25 19:48:12 -0700
commit935ab8f7cd332f958738c5c90d88dc2111187594 (patch)
treec9eee9b9e3539146ad4e11c568acd0e84324f250
parent04f903f9155b23a6a9f0dd972b448ada5bfc5f82 (diff)
downloadlibcap-935ab8f7cd332f958738c5c90d88dc2111187594.tar.gz
Support overriding choice of 'sudo'.
Use something like: make SUDO=my_sudo sudotest Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
-rw-r--r--Make.Rules1
-rw-r--r--go/Makefile8
-rw-r--r--pam_cap/Makefile14
-rw-r--r--progs/Makefile2
-rw-r--r--tests/Makefile10
5 files changed, 18 insertions, 17 deletions
diff --git a/Make.Rules b/Make.Rules
index dbf70ec..197a3df 100644
--- a/Make.Rules
+++ b/Make.Rules
@@ -65,6 +65,7 @@ DEFINES := -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
CC := $(CROSS_COMPILE)gcc
LD=$(CC) -Wl,-x -shared
+SUDO := sudo
COPTS ?= -O2
CFLAGS ?= $(COPTS) $(DEFINES)
LDFLAGS ?= #-g
diff --git a/go/Makefile b/go/Makefile
index 52e1f3e..2100eed 100644
--- a/go/Makefile
+++ b/go/Makefile
@@ -60,7 +60,7 @@ web: ../goapps/web/web.go CAPGOPACKAGE
CC="$(CC)" CGO_ENABLED="$(CGO_REQUIRED)" $(CGO_LDFLAGS_ALLOW) $(GO) build -mod=vendor -o $@ $<
ifeq ($(RAISE_GO_FILECAP),yes)
make -C ../progs setcap
- sudo ../progs/setcap cap_setpcap,cap_net_bind_service=p web
+ $(SUDO) ../progs/setcap cap_setpcap,cap_net_bind_service=p web
@echo "NOTE: RAISED cap_setpcap,cap_net_bind_service ON web binary"
endif
@@ -115,11 +115,11 @@ sudotest: test ../progs/tcapsh-static b210613
ifeq ($(CGO_REQUIRED),0)
./try-launching-cgo
endif
- sudo ./try-launching
+ $(SUDO) ./try-launching
ifeq ($(CGO_REQUIRED),0)
- sudo ./try-launching-cgo
+ $(SUDO) ./try-launching-cgo
endif
- sudo ../progs/tcapsh-static --cap-uid=$$(id -u) --caps="cap_setpcap=ep" --iab="^cap_setpcap" -- -c ./b210613
+ $(SUDO) ../progs/tcapsh-static --cap-uid=$$(id -u) --caps="cap_setpcap=ep" --iab="^cap_setpcap" -- -c ./b210613
install: all
rm -rf $(FAKEROOT)$(GOPKGDIR)/$(IMPORTDIR)/psx
diff --git a/pam_cap/Makefile b/pam_cap/Makefile
index d35bdb4..d5da6be 100644
--- a/pam_cap/Makefile
+++ b/pam_cap/Makefile
@@ -75,13 +75,13 @@ test: testlink test_pam_cap pam_cap.so
@echo "module can be run as an executable!"
sudotest: test test_pam_cap
- sudo ./test_pam_cap root 0x0 0x0 0x0 config=./capability.conf
- sudo ./test_pam_cap root 0x0 0x0 0x0 config=./sudotest.conf
- sudo ./test_pam_cap alpha 0x0 0x0 0x0 config=./capability.conf
- sudo ./test_pam_cap alpha 0x0 0x1 0x80 config=./sudotest.conf
- sudo ./test_pam_cap beta 0x0 0x1 0x0 config=./sudotest.conf
- sudo ./test_pam_cap gamma 0x0 0x0 0x81 config=./sudotest.conf
- sudo ./test_pam_cap delta 0x41 0x80 0x41 config=./sudotest.conf
+ $(SUDO) ./test_pam_cap root 0x0 0x0 0x0 config=./capability.conf
+ $(SUDO) ./test_pam_cap root 0x0 0x0 0x0 config=./sudotest.conf
+ $(SUDO) ./test_pam_cap alpha 0x0 0x0 0x0 config=./capability.conf
+ $(SUDO) ./test_pam_cap alpha 0x0 0x1 0x80 config=./sudotest.conf
+ $(SUDO) ./test_pam_cap beta 0x0 0x1 0x0 config=./sudotest.conf
+ $(SUDO) ./test_pam_cap gamma 0x0 0x0 0x81 config=./sudotest.conf
+ $(SUDO) ./test_pam_cap delta 0x41 0x80 0x41 config=./sudotest.conf
clean:
rm -f *.o *.so testlink lazylink.so test_pam_cap pam_cap_linkopts *~
diff --git a/progs/Makefile b/progs/Makefile
index c36ba9c..51e9a63 100644
--- a/progs/Makefile
+++ b/progs/Makefile
@@ -59,7 +59,7 @@ uns_test: ../tests/uns_test.c
cp ../tests/uns_test .
sudotest: test tcapsh-static uns_test
- sudo $(LDPATH) ./quicktest.sh
+ $(SUDO) $(LDPATH) ./quicktest.sh
clean:
$(LOCALCLEAN)
diff --git a/tests/Makefile b/tests/Makefile
index de890d0..d9ed248 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -79,13 +79,13 @@ uns_test: uns_test.c $(DEPS)
$(CC) $(CFLAGS) $(CPPFLAGS) $< -o $@ $(LINKEXTRA) $(LIBCAPLIB) $(LDFLAGS)
run_uns_test: uns_test
- echo exit | sudo ./uns_test
+ echo exit | $(SUDO) ./uns_test
run_libcap_launch_test: libcap_launch_test noop ../progs/tcapsh-static
- sudo ./libcap_launch_test
+ $(SUDO) ./libcap_launch_test
run_libcap_psx_launch_test: libcap_psx_launch_test ../progs/tcapsh-static
- sudo ./libcap_psx_launch_test
+ $(SUDO) ./libcap_psx_launch_test
libcap_launch_test: libcap_launch_test.c $(DEPS)
$(CC) $(CFLAGS) $(CPPFLAGS) $< -o $@ $(LINKEXTRA) $(LIBCAPLIB) $(LDFLAGS)
@@ -101,9 +101,9 @@ libcap_psx_launch_test: libcap_launch_test.c $(DEPS)
# programs that link against libcap.
run_exploit_test: exploit noexploit
@echo exploit should succeed
- sudo ./exploit ; if [ $$? -ne 0 ]; then exit 0; else exit 1 ; fi
+ $(SUDO) ./exploit ; if [ $$? -ne 0 ]; then exit 0; else exit 1 ; fi
@echo exploit should fail
- sudo ./noexploit ; if [ $$? -eq 0 ]; then exit 0; else exit 1 ; fi
+ $(SUDO) ./noexploit ; if [ $$? -eq 0 ]; then exit 0; else exit 1 ; fi
exploit.o: exploit.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c $<