chiark / gitweb /
cap-list: return lower-case capability names, similar to libcap's cap_to_name(),...
authorLennart Poettering <lennart@poettering.net>
Fri, 12 Dec 2014 17:37:25 +0000 (18:37 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 12 Dec 2014 17:37:25 +0000 (18:37 +0100)
Makefile.am
src/test/test-cap-list.c

index 417074945ff862b35c3bce63144fa47f2c0f25c6..4545cfebebe2cd856deef7a39d7585480e279652 100644 (file)
@@ -1252,7 +1252,7 @@ src/shared/cap-list.txt:
        $(AM_V_GEN)$(CPP) $(CFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) -dM -include linux/capability.h -include missing.h - </dev/null | $(AWK) '/^#define[ \t]+CAP_[A-Z_]+[ \t]+/ { print $$2; }' | grep -v CAP_LAST_CAP >$@
 
 src/shared/cap-to-name.h: src/shared/cap-list.txt
        $(AM_V_GEN)$(CPP) $(CFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) -dM -include linux/capability.h -include missing.h - </dev/null | $(AWK) '/^#define[ \t]+CAP_[A-Z_]+[ \t]+/ { print $$2; }' | grep -v CAP_LAST_CAP >$@
 
 src/shared/cap-to-name.h: src/shared/cap-list.txt
-       $(AM_V_GEN)$(AWK) 'BEGIN{ print "static const char* const capability_names[] = { "} { printf "[%s] = \"%s\",\n", $$1, $$1 } END{print "};"}' <$< >$@
+       $(AM_V_GEN)$(AWK) 'BEGIN{ print "static const char* const capability_names[] = { "} { printf "[%s] = \"%s\",\n", $$1, tolower($$1) } END{print "};"}' <$< >$@
 
 src/shared/cap-from-name.gperf: src/shared/cap-list.txt
        $(AM_V_GEN)$(AWK) 'BEGIN{ print "struct capability_name { const char* name; int id; };"; print "%null-strings"; print "%%";} { printf "%s, %s\n", $$1, $$1 }' <$< >$@
 
 src/shared/cap-from-name.gperf: src/shared/cap-list.txt
        $(AM_V_GEN)$(AWK) 'BEGIN{ print "struct capability_name { const char* name; int id; };"; print "%null-strings"; print "%%";} { printf "%s, %s\n", $$1, $$1 }' <$< >$@
index dfa9a063c2069199574cecbf63e5b85209c9febc..a536522646ad78a59f30f584c374618dcdb9131c 100644 (file)
@@ -39,6 +39,8 @@ int main(int argc, char *argv[]) {
 
         assert_se(capability_from_name("asdfbsd") == -EINVAL);
         assert_se(capability_from_name("CAP_AUDIT_READ") == CAP_AUDIT_READ);
 
         assert_se(capability_from_name("asdfbsd") == -EINVAL);
         assert_se(capability_from_name("CAP_AUDIT_READ") == CAP_AUDIT_READ);
+        assert_se(capability_from_name("cap_audit_read") == CAP_AUDIT_READ);
+        assert_se(capability_from_name("cAp_aUdIt_rEAd") == CAP_AUDIT_READ);
         assert_se(capability_from_name("0") == 0);
         assert_se(capability_from_name("15") == 15);
         assert_se(capability_from_name("-1") == -EINVAL);
         assert_se(capability_from_name("0") == 0);
         assert_se(capability_from_name("15") == 15);
         assert_se(capability_from_name("-1") == -EINVAL);