From 2f0808b88ee90d364ff34d84dbe8853c527d0d38 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Wed, 18 Feb 2015 23:59:50 +0000 Subject: [PATCH] Move CAP_* definitions out to header files * Makefile.am (strace_SOURCES): Add caps0.h and caps1.h. * caps0.h: New file. * caps1.h: New file. * capability.c: Remove CAP_* definitions, include "caps0.h" and "caps1.h" instead. Include "xlat/cap_mask0.h" instead of "xlat/capabilities.h". Include "xlat/cap_mask1.h" instead of "xlat/capabilities1.h". (print_cap_bits): Update callers. * xlat/capabilities.in: Rename to xlat/cap_mask0.in. * xlat/capabilities1.in: Rename to xlat/cap_mask1.in. --- Makefile.am | 2 ++ capability.c | 48 ++++--------------------- caps0.h | 32 +++++++++++++++++ caps1.h | 6 ++++ xlat/{capabilities.in => cap_mask0.in} | 0 xlat/{capabilities1.in => cap_mask1.in} | 0 6 files changed, 46 insertions(+), 42 deletions(-) create mode 100644 caps0.h create mode 100644 caps1.h rename xlat/{capabilities.in => cap_mask0.in} (100%) rename xlat/{capabilities1.in => cap_mask1.in} (100%) diff --git a/Makefile.am b/Makefile.am index ac6df197..07719408 100644 --- a/Makefile.am +++ b/Makefile.am @@ -33,6 +33,8 @@ strace_SOURCES = \ block.c \ cacheflush.c \ capability.c \ + caps0.h \ + caps1.h \ chdir.c \ chmod.c \ clone.c \ diff --git a/capability.c b/capability.c index af4dffeb..bbd5544a 100644 --- a/capability.c +++ b/capability.c @@ -2,53 +2,17 @@ /* these constants are the same as in */ enum { - CAP_CHOWN, - CAP_DAC_OVERRIDE, - CAP_DAC_READ_SEARCH, - CAP_FOWNER, - CAP_FSETID, - CAP_KILL, - CAP_SETGID, - CAP_SETUID, - CAP_SETPCAP, - CAP_LINUX_IMMUTABLE, - CAP_NET_BIND_SERVICE, - CAP_NET_BROADCAST, - CAP_NET_ADMIN, - CAP_NET_RAW, - CAP_IPC_LOCK, - CAP_IPC_OWNER, - CAP_SYS_MODULE, - CAP_SYS_RAWIO, - CAP_SYS_CHROOT, - CAP_SYS_PTRACE, - CAP_SYS_PACCT, - CAP_SYS_ADMIN, - CAP_SYS_BOOT, - CAP_SYS_NICE, - CAP_SYS_RESOURCE, - CAP_SYS_TIME, - CAP_SYS_TTY_CONFIG, - CAP_MKNOD, - CAP_LEASE, - CAP_AUDIT_WRITE, - CAP_AUDIT_CONTROL, - CAP_SETFCAP +#include "caps0.h" }; -#include "xlat/capabilities.h" +#include "xlat/cap_mask0.h" /* these constants are CAP_TO_INDEX'ed constants from */ enum { - CAP_MAC_OVERRIDE, - CAP_MAC_ADMIN, - CAP_SYSLOG, - CAP_WAKE_ALARM, - CAP_BLOCK_SUSPEND, - CAP_AUDIT_READ +#include "caps1.h" }; -#include "xlat/capabilities1.h" +#include "xlat/cap_mask1.h" /* these constants are the same as in */ enum { @@ -107,12 +71,12 @@ static void print_cap_bits(const uint32_t lo, const uint32_t hi) { if (lo || !hi) - printflags(capabilities, lo, "CAP_???"); + printflags(cap_mask0, lo, "CAP_???"); if (hi) { if (lo) tprints("|"); - printflags(capabilities1, hi, "CAP_???"); + printflags(cap_mask1, hi, "CAP_???"); } } diff --git a/caps0.h b/caps0.h new file mode 100644 index 00000000..ad206ffa --- /dev/null +++ b/caps0.h @@ -0,0 +1,32 @@ +CAP_CHOWN, +CAP_DAC_OVERRIDE, +CAP_DAC_READ_SEARCH, +CAP_FOWNER, +CAP_FSETID, +CAP_KILL, +CAP_SETGID, +CAP_SETUID, +CAP_SETPCAP, +CAP_LINUX_IMMUTABLE, +CAP_NET_BIND_SERVICE, +CAP_NET_BROADCAST, +CAP_NET_ADMIN, +CAP_NET_RAW, +CAP_IPC_LOCK, +CAP_IPC_OWNER, +CAP_SYS_MODULE, +CAP_SYS_RAWIO, +CAP_SYS_CHROOT, +CAP_SYS_PTRACE, +CAP_SYS_PACCT, +CAP_SYS_ADMIN, +CAP_SYS_BOOT, +CAP_SYS_NICE, +CAP_SYS_RESOURCE, +CAP_SYS_TIME, +CAP_SYS_TTY_CONFIG, +CAP_MKNOD, +CAP_LEASE, +CAP_AUDIT_WRITE, +CAP_AUDIT_CONTROL, +CAP_SETFCAP, diff --git a/caps1.h b/caps1.h new file mode 100644 index 00000000..d8fa6f47 --- /dev/null +++ b/caps1.h @@ -0,0 +1,6 @@ +CAP_MAC_OVERRIDE, +CAP_MAC_ADMIN, +CAP_SYSLOG, +CAP_WAKE_ALARM, +CAP_BLOCK_SUSPEND, +CAP_AUDIT_READ, diff --git a/xlat/capabilities.in b/xlat/cap_mask0.in similarity index 100% rename from xlat/capabilities.in rename to xlat/cap_mask0.in diff --git a/xlat/capabilities1.in b/xlat/cap_mask1.in similarity index 100% rename from xlat/capabilities1.in rename to xlat/cap_mask1.in