Skip to content

Commit 2f0808b

Browse files
committed
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.
1 parent f523f10 commit 2f0808b

File tree

6 files changed

+46
-42
lines changed

6 files changed

+46
-42
lines changed

Makefile.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ strace_SOURCES = \
3333
block.c \
3434
cacheflush.c \
3535
capability.c \
36+
caps0.h \
37+
caps1.h \
3638
chdir.c \
3739
chmod.c \
3840
clone.c \

capability.c

Lines changed: 6 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,53 +2,17 @@
22

33
/* these constants are the same as in <linux/capability.h> */
44
enum {
5-
CAP_CHOWN,
6-
CAP_DAC_OVERRIDE,
7-
CAP_DAC_READ_SEARCH,
8-
CAP_FOWNER,
9-
CAP_FSETID,
10-
CAP_KILL,
11-
CAP_SETGID,
12-
CAP_SETUID,
13-
CAP_SETPCAP,
14-
CAP_LINUX_IMMUTABLE,
15-
CAP_NET_BIND_SERVICE,
16-
CAP_NET_BROADCAST,
17-
CAP_NET_ADMIN,
18-
CAP_NET_RAW,
19-
CAP_IPC_LOCK,
20-
CAP_IPC_OWNER,
21-
CAP_SYS_MODULE,
22-
CAP_SYS_RAWIO,
23-
CAP_SYS_CHROOT,
24-
CAP_SYS_PTRACE,
25-
CAP_SYS_PACCT,
26-
CAP_SYS_ADMIN,
27-
CAP_SYS_BOOT,
28-
CAP_SYS_NICE,
29-
CAP_SYS_RESOURCE,
30-
CAP_SYS_TIME,
31-
CAP_SYS_TTY_CONFIG,
32-
CAP_MKNOD,
33-
CAP_LEASE,
34-
CAP_AUDIT_WRITE,
35-
CAP_AUDIT_CONTROL,
36-
CAP_SETFCAP
5+
#include "caps0.h"
376
};
387

39-
#include "xlat/capabilities.h"
8+
#include "xlat/cap_mask0.h"
409

4110
/* these constants are CAP_TO_INDEX'ed constants from <linux/capability.h> */
4211
enum {
43-
CAP_MAC_OVERRIDE,
44-
CAP_MAC_ADMIN,
45-
CAP_SYSLOG,
46-
CAP_WAKE_ALARM,
47-
CAP_BLOCK_SUSPEND,
48-
CAP_AUDIT_READ
12+
#include "caps1.h"
4913
};
5014

51-
#include "xlat/capabilities1.h"
15+
#include "xlat/cap_mask1.h"
5216

5317
/* these constants are the same as in <linux/capability.h> */
5418
enum {
@@ -107,12 +71,12 @@ static void
10771
print_cap_bits(const uint32_t lo, const uint32_t hi)
10872
{
10973
if (lo || !hi)
110-
printflags(capabilities, lo, "CAP_???");
74+
printflags(cap_mask0, lo, "CAP_???");
11175

11276
if (hi) {
11377
if (lo)
11478
tprints("|");
115-
printflags(capabilities1, hi, "CAP_???");
79+
printflags(cap_mask1, hi, "CAP_???");
11680
}
11781
}
11882

caps0.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
CAP_CHOWN,
2+
CAP_DAC_OVERRIDE,
3+
CAP_DAC_READ_SEARCH,
4+
CAP_FOWNER,
5+
CAP_FSETID,
6+
CAP_KILL,
7+
CAP_SETGID,
8+
CAP_SETUID,
9+
CAP_SETPCAP,
10+
CAP_LINUX_IMMUTABLE,
11+
CAP_NET_BIND_SERVICE,
12+
CAP_NET_BROADCAST,
13+
CAP_NET_ADMIN,
14+
CAP_NET_RAW,
15+
CAP_IPC_LOCK,
16+
CAP_IPC_OWNER,
17+
CAP_SYS_MODULE,
18+
CAP_SYS_RAWIO,
19+
CAP_SYS_CHROOT,
20+
CAP_SYS_PTRACE,
21+
CAP_SYS_PACCT,
22+
CAP_SYS_ADMIN,
23+
CAP_SYS_BOOT,
24+
CAP_SYS_NICE,
25+
CAP_SYS_RESOURCE,
26+
CAP_SYS_TIME,
27+
CAP_SYS_TTY_CONFIG,
28+
CAP_MKNOD,
29+
CAP_LEASE,
30+
CAP_AUDIT_WRITE,
31+
CAP_AUDIT_CONTROL,
32+
CAP_SETFCAP,

caps1.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CAP_MAC_OVERRIDE,
2+
CAP_MAC_ADMIN,
3+
CAP_SYSLOG,
4+
CAP_WAKE_ALARM,
5+
CAP_BLOCK_SUSPEND,
6+
CAP_AUDIT_READ,
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)