| 1 |
.TH "get_ordered_context_list" "3" "1 January 2004" "[email protected]" "SELinux" |
| 2 |
.SH "NAME" |
| 3 |
get_ordered_context_list, get_ordered_context_list_with_level, get_default_context, get_default_context_with_level, get_default_context_with_role, get_default_context_with_rolelevel, query_user_context, manual_user_enter_context, get_default_role \- determine SELinux context(s) for user sessions |
| 4 |
. |
| 5 |
.SH "SYNOPSIS" |
| 6 |
.B #include <selinux/selinux.h> |
| 7 |
.br |
| 8 |
.B #include <selinux/get_context_list.h> |
| 9 |
.sp |
| 10 |
.BI "int get_ordered_context_list(const char *" user ", char *" fromcon ", char ***" list ); |
| 11 |
.sp |
| 12 |
.BI "int get_ordered_context_list_with_level(const char *" user ", const char *" level ", char *" fromcon ", char ***" list ); |
| 13 |
.sp |
| 14 |
.BI "int get_default_context(const char *" user ", char *" fromcon ", char **" newcon ); |
| 15 |
.sp |
| 16 |
.BI "int get_default_context_with_level(const char *" user ", const char *" level ", char *" fromcon ", char **" newcon ); |
| 17 |
.sp |
| 18 |
.BI "int get_default_context_with_role(const char *" user ", const char *" role ", char *" fromcon ", char **" newcon "); |
| 19 |
.sp |
| 20 |
.BI "int get_default_context_with_rolelevel(const char *" user ", const char *" role ", const char *" level ", char *" fromcon ", char **" newcon "); |
| 21 |
.sp |
| 22 |
.BI "int query_user_context(char **" list ", char **" newcon ); |
| 23 |
.sp |
| 24 |
.BI "int manual_user_enter_context(const char *" user ", char **" newcon ); |
| 25 |
.sp |
| 26 |
.BI "int get_default_type(const char *" role ", char **" type ); |
| 27 |
. |
| 28 |
.SH "DESCRIPTION" |
| 29 |
.BR get_ordered_context_list () |
| 30 |
invokes the |
| 31 |
.BR security_compute_user (3) |
| 32 |
function to obtain the list of contexts for the specified |
| 33 |
.I user |
| 34 |
that are reachable from the specified |
| 35 |
.I fromcon |
| 36 |
context. The function then orders the resulting list based on the global |
| 37 |
.I \%/etc/selinux/{SELINUXTYPE}/contexts/default_contexts |
| 38 |
file and the per-user |
| 39 |
.I \%/etc/selinux/{SELINUXTYPE}/contexts/users/<username> |
| 40 |
file if it exists. The |
| 41 |
.I fromcon |
| 42 |
parameter may be NULL to indicate that the current context should |
| 43 |
be used. The function returns the number of contexts in the |
| 44 |
list, or \-1 upon errors. The list must be freed using the |
| 45 |
.BR freeconary (3) |
| 46 |
function. |
| 47 |
|
| 48 |
.BR get_ordered_context_list_with_level () |
| 49 |
invokes the |
| 50 |
.BR \%get_ordered_context_list () |
| 51 |
function and applies the specified level. |
| 52 |
|
| 53 |
.BR get_default_context () |
| 54 |
is the same as |
| 55 |
.BR get_ordered_context_list () |
| 56 |
but only returns a single context |
| 57 |
which has to be freed with |
| 58 |
.BR freecon (3). |
| 59 |
|
| 60 |
.BR get_default_context_with_level () |
| 61 |
invokes the |
| 62 |
.BR get_default_context () |
| 63 |
function and applies the specified level. |
| 64 |
|
| 65 |
.BR get_default_context_with_role () |
| 66 |
is the same as |
| 67 |
.BR get_default_context () |
| 68 |
but only returns a context with the specified role, returning \-1 if no |
| 69 |
such context is reachable for the user. |
| 70 |
|
| 71 |
.BR get_default_context_with_rolelevel () |
| 72 |
invokes the |
| 73 |
.BR \%get_default_context_with_role () |
| 74 |
function and applies the specified level. |
| 75 |
|
| 76 |
.BR query_user_context () |
| 77 |
takes a list of contexts, queries the user via stdin/stdout as to which context |
| 78 |
they want, and returns a new context as selected by the user (which has to be |
| 79 |
freed with |
| 80 |
.BR freecon (3)). |
| 81 |
|
| 82 |
.BR manual_user_enter_context () |
| 83 |
allows the user to manually enter a context as a fallback if a list of |
| 84 |
authorized contexts could not be obtained. Caller must free via |
| 85 |
.BR freecon (3). |
| 86 |
|
| 87 |
.BR get_default_type () |
| 88 |
Get the default type (domain) for |
| 89 |
.I role |
| 90 |
and set |
| 91 |
.I type |
| 92 |
to refer to it, which has to be freed with free. |
| 93 |
. |
| 94 |
.SH "RETURN VALUE" |
| 95 |
.BR get_ordered_context_list () |
| 96 |
and |
| 97 |
.BR get_ordered_context_list_with_level () |
| 98 |
return the number of contexts in the list upon success or \-1 upon errors. |
| 99 |
The other functions return 0 for success or \-1 for errors. |
| 100 |
. |
| 101 |
.SH "SEE ALSO" |
| 102 |
.ad l |
| 103 |
.nh |
| 104 |
.BR selinux (8), |
| 105 |
.BR freeconary (3), |
| 106 |
.BR freecon (3), |
| 107 |
.BR security_compute_av (3), |
| 108 |
.BR getseuserbyname (3) |