1get_ordered_context_list(3) SELinux get_ordered_context_list(3)
2
3
4
6 get_ordered_context_list, get_ordered_context_list_with_level,
7 get_default_context, get_default_context_with_level, get_default_con‐
8 text_with_role, get_default_context_with_rolelevel, query_user_context,
9 manual_user_enter_context, get_default_role - determine SELinux con‐
10 text(s) for user sessions
11
13 #include <selinux/selinux.h>
14 #include <selinux/get_context_list.h>
15
16 int get_ordered_context_list(const char *user, char *fromcon, char
17 ***list);
18
19 int get_ordered_context_list_with_level(const char *user, const char
20 *level, char *fromcon, char ***list);
21
22 int get_default_context(const char *user, char *fromcon, char **new‐
23 con);
24
25 int get_default_context_with_level(const char *user, const char *level,
26 char *fromcon, char **newcon);
27
28 int get_default_context_with_role(const char *user, const char *role,
29 char *fromcon, char **newcon);
30
31 int get_default_context_with_rolelevel(const char *user, const char
32 *role, const char *level, char *fromcon, char **newcon);
33
34 int query_user_context(char **list, char **newcon);
35
36 int manual_user_enter_context(const char *user, char **newcon);
37
38 int get_default_type(const char *role, char **type);
39
41 get_ordered_context_list() invokes the security_compute_user(3) func‐
42 tion to obtain the list of contexts for the specified user that are
43 reachable from the specified fromcon context. The function then orders
44 the resulting list based on the global
45 /etc/selinux/{SELINUXTYPE}/contexts/default_contexts file and the per-
46 user /etc/selinux/{SELINUXTYPE}/contexts/users/<username> file if it
47 exists. The fromcon parameter may be NULL to indicate that the current
48 context should be used. The function returns the number of contexts in
49 the list, or -1 upon errors. The list must be freed using the
50 freeconary(3) function.
51
52 get_ordered_context_list_with_level() invokes the
53 get_ordered_context_list() function and applies the specified level.
54
55 get_default_context() is the same as get_ordered_context_list() but
56 only returns a single context which has to be freed with freecon(3).
57
58 get_default_context_with_level() invokes the get_default_context()
59 function and applies the specified level.
60
61 get_default_context_with_role() is the same as get_default_context()
62 but only returns a context with the specified role, returning -1 if no
63 such context is reachable for the user.
64
65 get_default_context_with_rolelevel() invokes the
66 get_default_context_with_role() function and applies the specified
67 level.
68
69 query_user_context() takes a list of contexts, queries the user via
70 stdin/stdout as to which context they want, and returns a new context
71 as selected by the user (which has to be freed with freecon(3)).
72
73 manual_user_enter_context() allows the user to manually enter a context
74 as a fallback if a list of authorized contexts could not be obtained.
75 Caller must free via freecon(3).
76
77 get_default_type() Get the default type (domain) for role and set type
78 to refer to it, which has to be freed with free.
79
81 get_ordered_context_list() and get_ordered_context_list_with_level()
82 return the number of contexts in the list upon success or -1 upon
83 errors. The other functions return 0 for success or -1 for errors.
84
86 selinux(8), freeconary(3), freecon(3), security_compute_av(3),
87 getseuserbyname(3)
88
89
90
91russell@coker.com.au 1 January 2004 get_ordered_context_list(3)