get_context_list.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #ifndef _SELINUX_GET_SID_LIST_H_
  2. #define _SELINUX_GET_SID_LIST_H_
  3. #include <selinux/selinux.h>
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. #define SELINUX_DEFAULTUSER "user_u"
  8. /* Get an ordered list of authorized security contexts for a user session
  9. for 'user' spawned by 'fromcon' and set *conary to refer to the
  10. NULL-terminated array of contexts. Every entry in the list will
  11. be authorized by the policy, but the ordering is subject to user
  12. customizable preferences. Returns number of entries in *conary.
  13. If 'fromcon' is NULL, defaults to current context.
  14. Caller must free via freeconary. */
  15. extern int get_ordered_context_list(const char *user,
  16. security_context_t fromcon,
  17. security_context_t ** list);
  18. /* As above, but use the provided MLS level rather than the
  19. default level for the user. */
  20. int get_ordered_context_list_with_level(const char *user,
  21. const char *level,
  22. security_context_t fromcon,
  23. security_context_t ** list);
  24. /* Get the default security context for a user session for 'user'
  25. spawned by 'fromcon' and set *newcon to refer to it. The context
  26. will be one of those authorized by the policy, but the selection
  27. of a default is subject to user customizable preferences.
  28. If 'fromcon' is NULL, defaults to current context.
  29. Returns 0 on success or -1 otherwise.
  30. Caller must free via freecon. */
  31. extern int get_default_context(const char *user,
  32. security_context_t fromcon,
  33. security_context_t * newcon);
  34. /* As above, but use the provided MLS level rather than the
  35. default level for the user. */
  36. int get_default_context_with_level(const char *user,
  37. const char *level,
  38. security_context_t fromcon,
  39. security_context_t * newcon);
  40. /* Same as get_default_context, but only return a context
  41. that has the specified role. If no reachable context exists
  42. for the user with that role, then return -1. */
  43. int get_default_context_with_role(const char *user,
  44. const char *role,
  45. security_context_t fromcon,
  46. security_context_t * newcon);
  47. /* Same as get_default_context, but only return a context
  48. that has the specified role and level. If no reachable context exists
  49. for the user with that role, then return -1. */
  50. int get_default_context_with_rolelevel(const char *user,
  51. const char *level,
  52. const char *role,
  53. security_context_t fromcon,
  54. security_context_t * newcon);
  55. /* Given a list of authorized security contexts for the user,
  56. query the user to select one and set *newcon to refer to it.
  57. Caller must free via freecon.
  58. Returns 0 on sucess or -1 otherwise. */
  59. extern int query_user_context(security_context_t * list,
  60. security_context_t * newcon);
  61. /* Allow the user to manually enter a context as a fallback
  62. if a list of authorized contexts could not be obtained.
  63. Caller must free via freecon.
  64. Returns 0 on success or -1 otherwise. */
  65. extern int manual_user_enter_context(const char *user,
  66. security_context_t * newcon);
  67. #ifdef __cplusplus
  68. }
  69. #endif
  70. #endif