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