1 /* Copyright (C) 2005 Red Hat, Inc. */
2
3 #include <sepol/context_record.h>
4 #include "handle.h"
5
6 typedef sepol_context_t semanage_context_t;
7
8 #define _SEMANAGE_CONTEXT_DEFINED_
9 #include "context_internal.h"
10
11 /* User */
semanage_context_get_user(const semanage_context_t * con)12 const char *semanage_context_get_user(const semanage_context_t * con)
13 {
14
15 return sepol_context_get_user(con);
16 }
17
semanage_context_set_user(semanage_handle_t * handle,semanage_context_t * con,const char * user)18 int semanage_context_set_user(semanage_handle_t * handle,
19 semanage_context_t * con, const char *user)
20 {
21
22 return sepol_context_set_user(handle->sepolh, con, user);
23 }
24
25 /* Role */
semanage_context_get_role(const semanage_context_t * con)26 const char *semanage_context_get_role(const semanage_context_t * con)
27 {
28
29 return sepol_context_get_role(con);
30 }
31
semanage_context_set_role(semanage_handle_t * handle,semanage_context_t * con,const char * role)32 int semanage_context_set_role(semanage_handle_t * handle,
33 semanage_context_t * con, const char *role)
34 {
35
36 return sepol_context_set_role(handle->sepolh, con, role);
37 }
38
39 /* Type */
semanage_context_get_type(const semanage_context_t * con)40 const char *semanage_context_get_type(const semanage_context_t * con)
41 {
42
43 return sepol_context_get_type(con);
44 }
45
semanage_context_set_type(semanage_handle_t * handle,semanage_context_t * con,const char * type)46 int semanage_context_set_type(semanage_handle_t * handle,
47 semanage_context_t * con, const char *type)
48 {
49
50 return sepol_context_set_type(handle->sepolh, con, type);
51 }
52
53 /* MLS */
semanage_context_get_mls(const semanage_context_t * con)54 const char *semanage_context_get_mls(const semanage_context_t * con)
55 {
56
57 return sepol_context_get_mls(con);
58 }
59
semanage_context_set_mls(semanage_handle_t * handle,semanage_context_t * con,const char * mls_range)60 int semanage_context_set_mls(semanage_handle_t * handle,
61 semanage_context_t * con, const char *mls_range)
62 {
63
64 return sepol_context_set_mls(handle->sepolh, con, mls_range);
65 }
66
67 /* Create/Clone/Destroy */
semanage_context_create(semanage_handle_t * handle,semanage_context_t ** con_ptr)68 int semanage_context_create(semanage_handle_t * handle,
69 semanage_context_t ** con_ptr)
70 {
71
72 return sepol_context_create(handle->sepolh, con_ptr);
73 }
74
semanage_context_clone(semanage_handle_t * handle,const semanage_context_t * con,semanage_context_t ** con_ptr)75 int semanage_context_clone(semanage_handle_t * handle,
76 const semanage_context_t * con,
77 semanage_context_t ** con_ptr)
78 {
79
80 return sepol_context_clone(handle->sepolh, con, con_ptr);
81 }
82
hidden_def(semanage_context_clone)83 hidden_def(semanage_context_clone)
84
85 void semanage_context_free(semanage_context_t * con)
86 {
87
88 sepol_context_free(con);
89 }
90
hidden_def(semanage_context_free)91 hidden_def(semanage_context_free)
92
93 /* Parse to/from string */
94 int semanage_context_from_string(semanage_handle_t * handle,
95 const char *str, semanage_context_t ** con)
96 {
97
98 return sepol_context_from_string(handle->sepolh, str, con);
99 }
100
hidden_def(semanage_context_from_string)101 hidden_def(semanage_context_from_string)
102
103 int semanage_context_to_string(semanage_handle_t * handle,
104 const semanage_context_t * con, char **str_ptr)
105 {
106
107 return sepol_context_to_string(handle->sepolh, con, str_ptr);
108 }
109
110 hidden_def(semanage_context_to_string)
111