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