blob: 18a5691caef02d7d9331e9637bdaca6fc07d83c6 [file] [log] [blame]
Dmitry V. Levin5e7987b2014-12-03 20:30:15 +00001#include "defs.h"
2
3#define _LINUX_SOCKET_H
4#define _LINUX_FS_H
5
6#include <sys/socket.h>
7#include <netinet/in.h>
8#include <arpa/inet.h>
9#ifdef HAVE_LINUX_CAPABILITY_H
10# include <linux/capability.h>
11#endif
12
13#ifdef SYS_capget
14
15#include "xlat/capabilities.h"
16
17#ifndef _LINUX_CAPABILITY_VERSION_1
18# define _LINUX_CAPABILITY_VERSION_1 0x19980330
19#endif
20#ifndef _LINUX_CAPABILITY_VERSION_2
21# define _LINUX_CAPABILITY_VERSION_2 0x20071026
22#endif
23#ifndef _LINUX_CAPABILITY_VERSION_3
24# define _LINUX_CAPABILITY_VERSION_3 0x20080522
25#endif
26
27#include "xlat/cap_version.h"
28
29static void
30print_cap_header(struct tcb *tcp, unsigned long addr)
31{
32 union { cap_user_header_t p; long *a; char *c; } arg;
33 long a[sizeof(*arg.p) / sizeof(long) + 1];
34 arg.a = a;
35
36 if (!addr)
37 tprints("NULL");
38 else if (!verbose(tcp) ||
39 umoven(tcp, addr, sizeof(*arg.p), arg.c) < 0)
40 tprintf("%#lx", addr);
41 else {
42 tprints("{");
43 printxval(cap_version, arg.p->version,
44 "_LINUX_CAPABILITY_VERSION_???");
45 tprintf(", %d}", arg.p->pid);
46 }
47}
48
49static void
50print_cap_data(struct tcb *tcp, unsigned long addr)
51{
52 union { cap_user_data_t p; long *a; char *c; } arg;
53 long a[sizeof(*arg.p) / sizeof(long) + 1];
54 arg.a = a;
55
56 if (!addr)
57 tprints("NULL");
58 else if (!verbose(tcp) ||
59 (exiting(tcp) && syserror(tcp)) ||
60 umoven(tcp, addr, sizeof(*arg.p), arg.c) < 0)
61 tprintf("%#lx", addr);
62 else {
63 tprints("{");
64 printflags(capabilities, arg.p->effective, "CAP_???");
65 tprints(", ");
66 printflags(capabilities, arg.p->permitted, "CAP_???");
67 tprints(", ");
68 printflags(capabilities, arg.p->inheritable, "CAP_???");
69 tprints("}");
70 }
71}
72
73int
74sys_capget(struct tcb *tcp)
75{
76 if (entering(tcp)) {
77 print_cap_header(tcp, tcp->u_arg[0]);
78 tprints(", ");
79 } else {
80 print_cap_data(tcp, tcp->u_arg[1]);
81 }
82 return 0;
83}
84
85int
86sys_capset(struct tcb *tcp)
87{
88 if (entering(tcp)) {
89 print_cap_header(tcp, tcp->u_arg[0]);
90 tprints(", ");
91 print_cap_data(tcp, tcp->u_arg[1]);
92 }
93 return 0;
94}
95
96#else
97
98int sys_capget(struct tcb *tcp)
99{
100 return printargs(tcp);
101}
102
103int sys_capset(struct tcb *tcp)
104{
105 return printargs(tcp);
106}
107
108#endif