Skip to content

Commit 34a3e4e

Browse files
committed
cap-list: return lower-case capability names, similar to libcap's cap_to_name(), for compat reasons
1 parent 98cd265 commit 34a3e4e

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1252,7 +1252,7 @@ src/shared/cap-list.txt:
12521252
$(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 >$@
12531253

12541254
src/shared/cap-to-name.h: src/shared/cap-list.txt
1255-
$(AM_V_GEN)$(AWK) 'BEGIN{ print "static const char* const capability_names[] = { "} { printf "[%s] = \"%s\",\n", $$1, $$1 } END{print "};"}' <$< >$@
1255+
$(AM_V_GEN)$(AWK) 'BEGIN{ print "static const char* const capability_names[] = { "} { printf "[%s] = \"%s\",\n", $$1, tolower($$1) } END{print "};"}' <$< >$@
12561256

12571257
src/shared/cap-from-name.gperf: src/shared/cap-list.txt
12581258
$(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/test/test-cap-list.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ int main(int argc, char *argv[]) {
3939

4040
assert_se(capability_from_name("asdfbsd") == -EINVAL);
4141
assert_se(capability_from_name("CAP_AUDIT_READ") == CAP_AUDIT_READ);
42+
assert_se(capability_from_name("cap_audit_read") == CAP_AUDIT_READ);
43+
assert_se(capability_from_name("cAp_aUdIt_rEAd") == CAP_AUDIT_READ);
4244
assert_se(capability_from_name("0") == 0);
4345
assert_se(capability_from_name("15") == 15);
4446
assert_se(capability_from_name("-1") == -EINVAL);

0 commit comments

Comments
 (0)