1getfscreatecon(3) SELinux API documentation getfscreatecon(3)
2
3
4
6 getfscreatecon, setfscreatecon - get or set the SELinux security con‐
7 text used for creating a new file system object
8
10 #include <selinux/selinux.h>
11
12 int getfscreatecon(char **con);
13
14 int getfscreatecon_raw(char **con);
15
16 int setfscreatecon(char *context);
17
18 int setfscreatecon_raw(char *context);
19
21 getfscreatecon() retrieves the context used for creating a new file
22 system object. This returned context should be freed with freecon(3)
23 if non-NULL. getfscreatecon() sets *con to NULL if no fscreate context
24 has been explicitly set by the program (i.e. using the default policy
25 behavior).
26
27 setfscreatecon() sets the context used for creating a new file system
28 object. NULL can be passed to setfscreatecon() to reset to the default
29 policy behavior. The fscreate context is automatically reset after the
30 next execve(2), so a program doesn't need to explicitly sanitize it
31 upon startup.
32
33 setfscreatecon() can be applied prior to library functions that inter‐
34 nally perform an file creation, in order to set an file context on the
35 objects.
36
37 getfscreatecon_raw() and setfscreatecon_raw() behave identically to
38 their non-raw counterparts but do not perform context translation.
39
40 Note: Signal handlers that perform a setfscreatecon() must take care to
41 save, reset, and restore the fscreate context to avoid unexpected
42 behavior.
43
44 Note: Contexts are thread specific.
45
46
48 On error -1 is returned. On success 0 is returned.
49
51 selinux(8), freecon(3), getcon(3), getexeccon(3)
52
53
54
55russell@coker.com.au 1 January 2004 getfscreatecon(3)