aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew G. Morgan <morgan@kernel.org>2021-11-09 07:28:59 -0800
committerAndrew G. Morgan <morgan@kernel.org>2021-11-09 07:28:59 -0800
commit2e4335523e0a705b4ce6b49b1bfccfe519f559ce (patch)
tree582d4037086e4558bb5370deb62748de567ce867
parent95085598764ca6c874dc1ee48364dbd2921fc000 (diff)
downloadlibcap-2e4335523e0a705b4ce6b49b1bfccfe519f559ce.tar.gz
Include some helpful debugging for capso.so
This makes explaining how the program works more straightforward. That is: make CAPSO_DEBUG=-DCAPSO_DEBUG clean all builds a version that prints out some helpful info and pauses so the user can observe the capability state of the process tree at different stages of execution. Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
-rw-r--r--contrib/capso/Makefile2
-rw-r--r--contrib/capso/capso.c15
2 files changed, 16 insertions, 1 deletions
diff --git a/contrib/capso/Makefile b/contrib/capso/Makefile
index 87ed34b..70af7f9 100644
--- a/contrib/capso/Makefile
+++ b/contrib/capso/Makefile
@@ -2,7 +2,7 @@ topdir=$(shell pwd)/../..
include ../../Make.Rules
# Always build sources this way:
-CFLAGS += -fPIC
+CFLAGS += -fPIC $(CAPSO_DEBUG)
all: bind
diff --git a/contrib/capso/capso.c b/contrib/capso/capso.c
index 3f2f3ba..2a357c0 100644
--- a/contrib/capso/capso.c
+++ b/contrib/capso/capso.c
@@ -138,6 +138,11 @@ int bind80(const char *hostname)
return fd;
}
+#ifdef CAPSO_DEBUG
+ printf("application bind80(%s) attempt failed\n", hostname);
+ sleep(30);
+#endif
+
iov = calloc(1, sizeof(struct iovec));
if (iov == NULL) {
return -1;
@@ -226,6 +231,11 @@ SO_MAIN(int argc, char **argv)
char data[CMSG_SPACE(sizeof(fd))];
char junk[1];
+#ifdef CAPSO_DEBUG
+ printf("invoking %s standalone\n", argv[0]);
+ sleep(30);
+#endif
+
if (argv != NULL) {
cmd = argv[0];
}
@@ -280,5 +290,10 @@ SO_MAIN(int argc, char **argv)
perror("failed to write fd");
}
+#ifdef CAPSO_DEBUG
+ printf("exiting standalone %s\n", argv[0]);
+ sleep(30);
+#endif
+
exit(0);
}