Home | History | Annotate | Download | only in sepol
      1 #ifndef _SEPOL_USER_RECORD_H_
      2 #define _SEPOL_USER_RECORD_H_
      3 
      4 #include <stddef.h>
      5 #include <sepol/handle.h>
      6 
      7 #ifdef __cplusplus
      8 extern "C" {
      9 #endif
     10 
     11 struct sepol_user;
     12 struct sepol_user_key;
     13 typedef struct sepol_user sepol_user_t;
     14 typedef struct sepol_user_key sepol_user_key_t;
     15 
     16 /* Key */
     17 extern int sepol_user_key_create(sepol_handle_t * handle,
     18 				 const char *name, sepol_user_key_t ** key);
     19 
     20 extern void sepol_user_key_unpack(const sepol_user_key_t * key,
     21 				  const char **name);
     22 
     23 extern int sepol_user_key_extract(sepol_handle_t * handle,
     24 				  const sepol_user_t * user,
     25 				  sepol_user_key_t ** key_ptr);
     26 
     27 extern void sepol_user_key_free(sepol_user_key_t * key);
     28 
     29 extern int sepol_user_compare(const sepol_user_t * user,
     30 			      const sepol_user_key_t * key);
     31 
     32 extern int sepol_user_compare2(const sepol_user_t * user,
     33 			       const sepol_user_t * user2);
     34 
     35 /* Name */
     36 extern const char *sepol_user_get_name(const sepol_user_t * user);
     37 
     38 extern int sepol_user_set_name(sepol_handle_t * handle,
     39 			       sepol_user_t * user, const char *name);
     40 
     41 /* MLS */
     42 extern const char *sepol_user_get_mlslevel(const sepol_user_t * user);
     43 
     44 extern int sepol_user_set_mlslevel(sepol_handle_t * handle,
     45 				   sepol_user_t * user, const char *mls_level);
     46 
     47 extern const char *sepol_user_get_mlsrange(const sepol_user_t * user);
     48 
     49 extern int sepol_user_set_mlsrange(sepol_handle_t * handle,
     50 				   sepol_user_t * user, const char *mls_range);
     51 
     52 /* Role management */
     53 extern int sepol_user_get_num_roles(const sepol_user_t * user);
     54 
     55 extern int sepol_user_add_role(sepol_handle_t * handle,
     56 			       sepol_user_t * user, const char *role);
     57 
     58 extern void sepol_user_del_role(sepol_user_t * user, const char *role);
     59 
     60 extern int sepol_user_has_role(const sepol_user_t * user, const char *role);
     61 
     62 extern int sepol_user_get_roles(sepol_handle_t * handle,
     63 				const sepol_user_t * user,
     64 				const char ***roles_arr,
     65 				unsigned int *num_roles);
     66 
     67 extern int sepol_user_set_roles(sepol_handle_t * handle,
     68 				sepol_user_t * user,
     69 				const char **roles_arr, unsigned int num_roles);
     70 
     71 /* Create/Clone/Destroy */
     72 extern int sepol_user_create(sepol_handle_t * handle, sepol_user_t ** user_ptr);
     73 
     74 extern int sepol_user_clone(sepol_handle_t * handle,
     75 			    const sepol_user_t * user,
     76 			    sepol_user_t ** user_ptr);
     77 
     78 extern void sepol_user_free(sepol_user_t * user);
     79 
     80 #ifdef __cplusplus
     81 }
     82 #endif
     83 
     84 #endif
     85