1getexeccon(3) SE Linux API documentation getexeccon(3)
2
3
4
6 getexeccon, setexeccon - get or set the SELinux security context used
7 for executing a new process.
8
9 rpm_execcon - run a helper for rpm in an appropriate security context
10
11
13 #include <selinux/selinux.h>
14
15 int getexeccon(security_context_t *context);
16
17 int setexeccon(security_context_t context);
18
19 int rpm_execcon(unsigned int verified, const char *filename, char
20 *const argv[] , char *const envp[]);
21
22
24 getexeccon retrieves the context used for executing a new process.
25 This returned context should be freed with freecon if non-NULL. getex‐
26 eccon sets *con to NULL if no exec context has been explicitly set by
27 the program (i.e. using the default policy behavior).
28
29 setexeccon sets the context used for the next execve call. NULL can be
30 passed to setexeccon to reset to the default policy behavior. The exec
31 context is automatically reset after the next execve, so a program
32 doesn't need to explicitly sanitize it upon startup.
33
34
35 setexeccon can be applied prior to library functions that internally
36 perform an execve, e.g. execl*, execv*, popen, in order to set an exec
37 context for that operation.
38
39
40 Note: Signal handlers that perform an execve must take care to save,
41 reset, and restore the exec context to avoid unexpected behaviors.
42
43
44 rpm_execcon runs a helper for rpm in an appropriate security context.
45 The verified parameter should contain the return code from the signa‐
46 ture verification (0 == ok, 1 == notfound, 2 == verifyfail, 3 == not‐
47 trusted, 4 == nokey), although this information is not yet used by the
48 function. The function determines the proper security context for the
49 helper based on policy, sets the exec context accordingly, and then
50 executes the specified filename with the provided argument and environ‐
51 ment arrays.
52
53
54
56 On error -1 is returned.
57
58 On success getexeccon and setexeccon returns 0. rpm_execcon only
59 returns upon errors, as it calls execve(2).
60
61
63 selinux(8), freecon(3), getcon(3)
64
65
66
67
68
69russell@coker.com.au 1 January 2004 getexeccon(3)