13
13
*
14
14
* Author : Stephen Smalley, <[email protected] >
15
15
*/
16
+
16
17
#ifndef _SS_CONTEXT_H_
17
18
#define _SS_CONTEXT_H_
18
19
@@ -28,17 +29,18 @@ struct context {
28
29
u32 user ;
29
30
u32 role ;
30
31
u32 type ;
31
- u32 len ; /* length of string in bytes */
32
+ u32 len ; /* length of string in bytes */
32
33
struct mls_range range ;
33
- char * str ; /* string representation if context cannot be mapped. */
34
+ char * str ; /* string representation if context cannot be mapped. */
34
35
};
35
36
36
37
static inline void mls_context_init (struct context * c )
37
38
{
38
39
memset (& c -> range , 0 , sizeof (c -> range ));
39
40
}
40
41
41
- static inline int mls_context_cpy (struct context * dst , const struct context * src )
42
+ static inline int mls_context_cpy (struct context * dst ,
43
+ const struct context * src )
42
44
{
43
45
int rc ;
44
46
@@ -58,7 +60,8 @@ static inline int mls_context_cpy(struct context *dst, const struct context *src
58
60
/*
59
61
* Sets both levels in the MLS range of 'dst' to the low level of 'src'.
60
62
*/
61
- static inline int mls_context_cpy_low (struct context * dst , const struct context * src )
63
+ static inline int mls_context_cpy_low (struct context * dst ,
64
+ const struct context * src )
62
65
{
63
66
int rc ;
64
67
@@ -78,7 +81,8 @@ static inline int mls_context_cpy_low(struct context *dst, const struct context
78
81
/*
79
82
* Sets both levels in the MLS range of 'dst' to the high level of 'src'.
80
83
*/
81
- static inline int mls_context_cpy_high (struct context * dst , const struct context * src )
84
+ static inline int mls_context_cpy_high (struct context * dst ,
85
+ const struct context * src )
82
86
{
83
87
int rc ;
84
88
@@ -95,9 +99,9 @@ static inline int mls_context_cpy_high(struct context *dst, const struct context
95
99
return rc ;
96
100
}
97
101
98
-
99
102
static inline int mls_context_glblub (struct context * dst ,
100
- const struct context * c1 , const struct context * c2 )
103
+ const struct context * c1 ,
104
+ const struct context * c2 )
101
105
{
102
106
struct mls_range * dr = & dst -> range ;
103
107
const struct mls_range * r1 = & c1 -> range , * r2 = & c2 -> range ;
@@ -114,21 +118,22 @@ static inline int mls_context_glblub(struct context *dst,
114
118
/* Take the least of the high */
115
119
dr -> level [1 ].sens = min (r1 -> level [1 ].sens , r2 -> level [1 ].sens );
116
120
117
- rc = ebitmap_and (& dr -> level [0 ].cat ,
118
- & r1 -> level [ 0 ]. cat , & r2 -> level [0 ].cat );
121
+ rc = ebitmap_and (& dr -> level [0 ].cat , & r1 -> level [ 0 ]. cat ,
122
+ & r2 -> level [0 ].cat );
119
123
if (rc )
120
124
goto out ;
121
125
122
- rc = ebitmap_and (& dr -> level [1 ].cat ,
123
- & r1 -> level [ 1 ]. cat , & r2 -> level [1 ].cat );
126
+ rc = ebitmap_and (& dr -> level [1 ].cat , & r1 -> level [ 1 ]. cat ,
127
+ & r2 -> level [1 ].cat );
124
128
if (rc )
125
129
goto out ;
126
130
127
131
out :
128
132
return rc ;
129
133
}
130
134
131
- static inline int mls_context_cmp (const struct context * c1 , const struct context * c2 )
135
+ static inline int mls_context_cmp (const struct context * c1 ,
136
+ const struct context * c2 )
132
137
{
133
138
return ((c1 -> range .level [0 ].sens == c2 -> range .level [0 ].sens ) &&
134
139
ebitmap_cmp (& c1 -> range .level [0 ].cat , & c2 -> range .level [0 ].cat ) &&
@@ -183,19 +188,17 @@ static inline void context_destroy(struct context *c)
183
188
mls_context_destroy (c );
184
189
}
185
190
186
- static inline int context_cmp (const struct context * c1 , const struct context * c2 )
191
+ static inline int context_cmp (const struct context * c1 ,
192
+ const struct context * c2 )
187
193
{
188
194
if (c1 -> len && c2 -> len )
189
195
return (c1 -> len == c2 -> len && !strcmp (c1 -> str , c2 -> str ));
190
196
if (c1 -> len || c2 -> len )
191
197
return 0 ;
192
- return ((c1 -> user == c2 -> user ) &&
193
- (c1 -> role == c2 -> role ) &&
194
- (c1 -> type == c2 -> type ) &&
195
- mls_context_cmp (c1 , c2 ));
198
+ return ((c1 -> user == c2 -> user ) && (c1 -> role == c2 -> role ) &&
199
+ (c1 -> type == c2 -> type ) && mls_context_cmp (c1 , c2 ));
196
200
}
197
201
198
202
u32 context_compute_hash (const struct context * c );
199
203
200
- #endif /* _SS_CONTEXT_H_ */
201
-
204
+ #endif /* _SS_CONTEXT_H_ */
0 commit comments