| 1 |
.TH "context_new" "3" "20 December 2011" "[email protected]" "SELinux API documentation" |
| 2 |
.SH "NAME" |
| 3 |
context_new, context_str, context_free, context_type_get, context_type_set, context_range_get, context_range_set,context_role_get, context_role_set, context_user_get, context_user_set \- Routines to manipulate SELinux security contexts |
| 4 |
. |
| 5 |
.SH "SYNOPSIS" |
| 6 |
.B #include <selinux/context.h> |
| 7 |
.sp |
| 8 |
.BI "context_t context_new(const char *" context_str ); |
| 9 |
.sp |
| 10 |
.BI "const char * context_str(context_t " con ); |
| 11 |
.sp |
| 12 |
.BI "void context_free(context_t " con ); |
| 13 |
.sp |
| 14 |
.BI "const char * context_type_get(context_t " con ); |
| 15 |
.sp |
| 16 |
.BI "const char * context_range_get(context_t " con ); |
| 17 |
.sp |
| 18 |
.BI "const char * context_role_get(context_t " con ); |
| 19 |
.sp |
| 20 |
.BI "const char * context_user_get(context_t " con ); |
| 21 |
.sp |
| 22 |
.BI "int context_type_set(context_t " con ", const char *" type ); |
| 23 |
.sp |
| 24 |
.BI "int context_range_set(context_t " con ", const char *" range ); |
| 25 |
.sp |
| 26 |
.BI "int context_role_set(context_t " con ", const char *" role ); |
| 27 |
.sp |
| 28 |
.BI "int context_user_set(context_t " con ", const char *" user ); |
| 29 |
. |
| 30 |
.SH "DESCRIPTION" |
| 31 |
These functions allow an application to manipulate the fields of a |
| 32 |
security context string without requiring it to know the format of the |
| 33 |
string. |
| 34 |
|
| 35 |
.BR context_new () |
| 36 |
returns a new context initialized to a context string. |
| 37 |
|
| 38 |
.BR context_str () |
| 39 |
returns a pointer to the string value of the |
| 40 |
.BR context_t , |
| 41 |
valid until the next call to |
| 42 |
.BR context_str () |
| 43 |
or |
| 44 |
.BR context_free () |
| 45 |
for the same |
| 46 |
.BR context_t* . |
| 47 |
|
| 48 |
.BR context_free () |
| 49 |
frees the storage used by a context. |
| 50 |
|
| 51 |
.BR context_type_get (), |
| 52 |
.BR context_range_get (), |
| 53 |
.BR context_role_get (), |
| 54 |
.BR \%context_user_get () |
| 55 |
get a pointer to the string value of a context component. |
| 56 |
|
| 57 |
.B Note: |
| 58 |
Values returned by the get functions are only valid until the next call |
| 59 |
to a set function or |
| 60 |
.BR context_free () |
| 61 |
for the same |
| 62 |
.B context_t |
| 63 |
structure. |
| 64 |
|
| 65 |
.BR context_type_set (), |
| 66 |
.BR context_range_set (), |
| 67 |
.BR context_role_set (), |
| 68 |
.BR \%context_user_set () |
| 69 |
set a context component. |
| 70 |
. |
| 71 |
.SH "RETURN VALUE" |
| 72 |
On failure |
| 73 |
.BR context_*_set () |
| 74 |
functions return non-zero and 0 on success. |
| 75 |
|
| 76 |
The other functions return NULL on failure and non-NULL on success. |
| 77 |
|
| 78 |
On failure |
| 79 |
.I errno |
| 80 |
is set appropriately. |
| 81 |
. |
| 82 |
.SH "SEE ALSO" |
| 83 |
.BR selinux "(8)" |