users.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #ifndef _SEPOL_USERS_H_
  2. #define _SEPOL_USERS_H_
  3. #include <sepol/policydb.h>
  4. #include <sepol/user_record.h>
  5. #include <sepol/handle.h>
  6. #include <stddef.h>
  7. /*---------compatibility------------*/
  8. /* Given an existing binary policy (starting at 'data with length 'len')
  9. and user configurations living in 'usersdir', generate a new binary
  10. policy for the new user configurations. Sets '*newdata' and '*newlen'
  11. to refer to the new binary policy image. */
  12. extern int sepol_genusers(void *data, size_t len,
  13. const char *usersdir,
  14. void **newdata, size_t * newlen);
  15. /* Enable or disable deletion of users by sepol_genusers(3) when
  16. a user in original binary policy image is not defined by the
  17. new user configurations. Defaults to disabled. */
  18. extern void sepol_set_delusers(int on);
  19. /*--------end compatibility----------*/
  20. /* Modify the user, or add it, if the key is not found */
  21. extern int sepol_user_modify(sepol_handle_t * handle,
  22. sepol_policydb_t * policydb,
  23. const sepol_user_key_t * key,
  24. const sepol_user_t * data);
  25. /* Return the number of users */
  26. extern int sepol_user_count(sepol_handle_t * handle,
  27. const sepol_policydb_t * p, unsigned int *response);
  28. /* Check if the specified user exists */
  29. extern int sepol_user_exists(sepol_handle_t * handle,
  30. const sepol_policydb_t * policydb,
  31. const sepol_user_key_t * key, int *response);
  32. /* Query a user - returns the user or NULL if not found */
  33. extern int sepol_user_query(sepol_handle_t * handle,
  34. const sepol_policydb_t * p,
  35. const sepol_user_key_t * key,
  36. sepol_user_t ** response);
  37. /* Iterate the users
  38. * The handler may return:
  39. * -1 to signal an error condition,
  40. * 1 to signal successful exit
  41. * 0 to signal continue */
  42. extern int sepol_user_iterate(sepol_handle_t * handle,
  43. const sepol_policydb_t * policydb,
  44. int (*fn) (const sepol_user_t * user,
  45. void *fn_arg), void *arg);
  46. #endif