context.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #ifndef _SELINUX_CONTEXT_H_
  2. #define _SELINUX_CONTEXT_H_
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. /*
  7. * Functions to deal with security contexts in user space.
  8. */
  9. typedef struct {
  10. void *ptr;
  11. } context_s_t;
  12. typedef context_s_t *context_t;
  13. /* Return a new context initialized to a context string */
  14. extern context_t context_new(const char *);
  15. /*
  16. * Return a pointer to the string value of the context_t
  17. * Valid until the next call to context_str or context_free
  18. * for the same context_t*
  19. */
  20. extern char *context_str(context_t);
  21. /* Free the storage used by a context */
  22. extern void context_free(context_t);
  23. /* Get a pointer to the string value of a context component */
  24. extern const char *context_type_get(context_t);
  25. extern const char *context_range_get(context_t);
  26. extern const char *context_role_get(context_t);
  27. extern const char *context_user_get(context_t);
  28. /* Set a context component. Returns nonzero if unsuccessful */
  29. extern int context_type_set(context_t, const char *);
  30. extern int context_range_set(context_t, const char *);
  31. extern int context_role_set(context_t, const char *);
  32. extern int context_user_set(context_t, const char *);
  33. #ifdef __cplusplus
  34. }
  35. #endif
  36. #endif