summaryrefslogtreecommitdiff
path: root/libcap/Makefile
diff options
context:
space:
mode:
authorAndrew G. Morgan <morgan@kernel.org>2020-07-05 10:20:17 -0700
committerAndrew G. Morgan <morgan@kernel.org>2020-07-05 10:20:17 -0700
commit5457efd92c533259eecde426d9e6bb6abb270d89 (patch)
treef33cdf736c39f5ad610d4a321e8a66fefbfcb15a /libcap/Makefile
parent264f8dcb14d811b7b1a0a9abbe82a946cff3d955 (diff)
downloadlibcap2-5457efd92c533259eecde426d9e6bb6abb270d89.tar.gz
Fix capability list generation and legacy go package install.
Fixes Hussam Al-Tayeb bug report: https://bugzilla.kernel.org/show_bug.cgi?id=208439 The list generation has been intended to be fully self-defined since 2.23, but I didn't complete the job back then because of a lack of a way to runtime-determine the capabilities actually supported by the running kernel. This last bit was fixed with 2.30 and I should have caught the need for this final clean up then. The go install was broken in 2.37 as a oversight as I refactored to support go modules. I did a write up about how this Go support is expected to work here: https://sites.google.com/site/fullycapable/building-go-programs-that-manipulate-capabilities Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
Diffstat (limited to 'libcap/Makefile')
-rw-r--r--libcap/Makefile11
1 files changed, 8 insertions, 3 deletions
diff --git a/libcap/Makefile b/libcap/Makefile
index 1ef9086..4321c2f 100644
--- a/libcap/Makefile
+++ b/libcap/Makefile
@@ -57,9 +57,14 @@ $(GPERF_OUTPUT): cap_names.list.h
perl -e 'print "struct __cap_token_s { const char *name; int index; };\n%{\nconst struct __cap_token_s *__cap_lookup_name(const char *, size_t);\n%}\n%%\n"; while ($$l = <>) { $$l =~ s/[\{\"]//g; $$l =~ s/\}.*// ; print $$l; }' < $< | gperf --ignore-case --language=ANSI-C --readonly --null-strings --global-table --hash-function-name=__cap_hash_name --lookup-function-name="__cap_lookup_name" -c -t -m20 $(INDENT) > $@
sed -e 's/unsigned int len/size_t len/' -i $@
-cap_names.list.h: Makefile $(KERNEL_HEADERS)/linux/capability.h
- @echo "=> making $@ from $(KERNEL_HEADERS)/linux/capability.h"
- perl -e 'while ($$l=<>) { if ($$l =~ /^\#define[ \t](CAP[_A-Z]+)[ \t]+([0-9]+)\s+$$/) { $$tok=$$1; $$val=$$2; $$tok =~ tr/A-Z/a-z/; print "{\"$$tok\",$$val},\n"; } }' $(KERNEL_HEADERS)/linux/capability.h | fgrep -v 0x > $@
+# Intention is that libcap keeps up with torvalds' tree, as reflected
+# by this maintained version of the kernel header. libcap dynamically
+# trims the meaning of "all" capabilities down to that of the running
+# kernel as of 2.30.
+UAPI_HEADER := $(topdir)/libcap/include/uapi/linux/capability.h
+cap_names.list.h: Makefile $(UAPI_HEADER)
+ @echo "=> making $@ from $(UAPI_HEADER)"
+ perl -e 'while ($$l=<>) { if ($$l =~ /^\#define[ \t](CAP[_A-Z]+)[ \t]+([0-9]+)\s+$$/) { $$tok=$$1; $$val=$$2; $$tok =~ tr/A-Z/a-z/; print "{\"$$tok\",$$val},\n"; } }' $(UAPI_HEADER) | fgrep -v 0x > $@
$(STACAPLIBNAME): $(CAPOBJS)
$(AR) rcs $@ $^