| 1 |
.TH "getkeycreatecon" "3" "9 September 2008" "[email protected]" "SELinux API documentation" |
| 2 |
.SH "NAME" |
| 3 |
getkeycreatecon, setkeycreatecon \- get or set the SELinux security context used for creating a new kernel keyrings |
| 4 |
. |
| 5 |
.SH "SYNOPSIS" |
| 6 |
.B #include <selinux/selinux.h> |
| 7 |
.sp |
| 8 |
.BI "int getkeycreatecon(char **" con ); |
| 9 |
.sp |
| 10 |
.BI "int getkeycreatecon_raw(char **" con ); |
| 11 |
.sp |
| 12 |
.BI "int setkeycreatecon(char *" context ); |
| 13 |
.sp |
| 14 |
.BI "int setkeycreatecon_raw(char *" context ); |
| 15 |
. |
| 16 |
.SH "DESCRIPTION" |
| 17 |
.BR getkeycreatecon () |
| 18 |
retrieves the context used for creating a new kernel keyring. |
| 19 |
This returned context should be freed with |
| 20 |
.BR freecon (3) |
| 21 |
if non-NULL. |
| 22 |
.BR getkeycreatecon () |
| 23 |
sets *con to NULL if no keycreate context has been explicitly |
| 24 |
set by the program (i.e. using the default policy behavior). |
| 25 |
|
| 26 |
.BR setkeycreatecon () |
| 27 |
sets the context used for creating a new kernel keyring. |
| 28 |
NULL can be passed to |
| 29 |
.BR setkeycreatecon () |
| 30 |
to reset to the default policy behavior. |
| 31 |
The keycreate 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 setkeycreatecon () |
| 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 getkeycreatecon_raw () |
| 41 |
and |
| 42 |
.BR setkeycreatecon_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 setkeycreatecon () |
| 49 |
must take care to |
| 50 |
save, reset, and restore the keycreate context to avoid unexpected behavior. |
| 51 |
|
| 52 |
.br |
| 53 |
.B Note: |
| 54 |
Contexts are thread specific. |
| 55 |
. |
| 56 |
.SH "RETURN VALUE" |
| 57 |
On error \-1 is returned. |
| 58 |
On success 0 is returned. |
| 59 |
. |
| 60 |
.SH "SEE ALSO" |
| 61 |
.BR selinux "(8), " freecon "(3), " getcon "(3), " getexeccon "(3)" |