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