diff options
author | Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> | 2011-06-26 10:16:36 -0400 |
---|---|---|
committer | James Morris <jmorris@namei.org> | 2011-06-28 19:31:19 -0400 |
commit | 0df7e8b8f1c25c10820bdc679555f2fbfb897ca0 (patch) | |
tree | 626a0304fceec0bbee93e43a24bc0f813fe230b7 /security/tomoyo/util.c | |
parent | b5bc60b4ce313b6dbb42e7d32915dcf0a07c2a68 (diff) |
TOMOYO: Cleanup part 3.
Use common structure for ACL with "struct list_head" + "atomic_t".
Use array/struct where possible.
Remove is_group from "struct tomoyo_name_union"/"struct tomoyo_number_union".
Pass "struct file"->private_data rather than "struct file".
Update some of comments.
Bring tomoyo_same_acl_head() from common.h to domain.c .
Bring tomoyo_invalid()/tomoyo_valid() from common.h to util.c .
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'security/tomoyo/util.c')
-rw-r--r-- | security/tomoyo/util.c | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/security/tomoyo/util.c b/security/tomoyo/util.c index 7fb9bbf7021a..abb177c2d7c2 100644 --- a/security/tomoyo/util.c +++ b/security/tomoyo/util.c | |||
@@ -21,7 +21,7 @@ bool tomoyo_policy_loaded; | |||
21 | * @result: Pointer to "unsigned long". | 21 | * @result: Pointer to "unsigned long". |
22 | * @str: Pointer to string to parse. | 22 | * @str: Pointer to string to parse. |
23 | * | 23 | * |
24 | * Returns value type on success, 0 otherwise. | 24 | * Returns one of values in "enum tomoyo_value_type". |
25 | * | 25 | * |
26 | * The @src is updated to point the first character after the value | 26 | * The @src is updated to point the first character after the value |
27 | * on success. | 27 | * on success. |
@@ -43,7 +43,7 @@ static u8 tomoyo_parse_ulong(unsigned long *result, char **str) | |||
43 | } | 43 | } |
44 | *result = simple_strtoul(cp, &ep, base); | 44 | *result = simple_strtoul(cp, &ep, base); |
45 | if (cp == ep) | 45 | if (cp == ep) |
46 | return 0; | 46 | return TOMOYO_VALUE_TYPE_INVALID; |
47 | *str = ep; | 47 | *str = ep; |
48 | switch (base) { | 48 | switch (base) { |
49 | case 16: | 49 | case 16: |
@@ -93,11 +93,9 @@ bool tomoyo_parse_name_union(const char *filename, | |||
93 | return false; | 93 | return false; |
94 | if (filename[0] == '@') { | 94 | if (filename[0] == '@') { |
95 | ptr->group = tomoyo_get_group(filename + 1, TOMOYO_PATH_GROUP); | 95 | ptr->group = tomoyo_get_group(filename + 1, TOMOYO_PATH_GROUP); |
96 | ptr->is_group = true; | ||
97 | return ptr->group != NULL; | 96 | return ptr->group != NULL; |
98 | } | 97 | } |
99 | ptr->filename = tomoyo_get_name(filename); | 98 | ptr->filename = tomoyo_get_name(filename); |
100 | ptr->is_group = false; | ||
101 | return ptr->filename != NULL; | 99 | return ptr->filename != NULL; |
102 | } | 100 | } |
103 | 101 | ||
@@ -118,17 +116,16 @@ bool tomoyo_parse_number_union(char *data, struct tomoyo_number_union *num) | |||
118 | if (!tomoyo_correct_word(data)) | 116 | if (!tomoyo_correct_word(data)) |
119 | return false; | 117 | return false; |
120 | num->group = tomoyo_get_group(data + 1, TOMOYO_NUMBER_GROUP); | 118 | num->group = tomoyo_get_group(data + 1, TOMOYO_NUMBER_GROUP); |
121 | num->is_group = true; | ||
122 | return num->group != NULL; | 119 | return num->group != NULL; |
123 | } | 120 | } |
124 | type = tomoyo_parse_ulong(&v, &data); | 121 | type = tomoyo_parse_ulong(&v, &data); |
125 | if (!type) | 122 | if (!type) |
126 | return false; | 123 | return false; |
127 | num->values[0] = v; | 124 | num->values[0] = v; |
128 | num->min_type = type; | 125 | num->value_type[0] = type; |
129 | if (!*data) { | 126 | if (!*data) { |
130 | num->values[1] = v; | 127 | num->values[1] = v; |
131 | num->max_type = type; | 128 | num->value_type[1] = type; |
132 | return true; | 129 | return true; |
133 | } | 130 | } |
134 | if (*data++ != '-') | 131 | if (*data++ != '-') |
@@ -137,7 +134,7 @@ bool tomoyo_parse_number_union(char *data, struct tomoyo_number_union *num) | |||
137 | if (!type || *data) | 134 | if (!type || *data) |
138 | return false; | 135 | return false; |
139 | num->values[1] = v; | 136 | num->values[1] = v; |
140 | num->max_type = type; | 137 | num->value_type[1] = type; |
141 | return true; | 138 | return true; |
142 | } | 139 | } |
143 | 140 | ||
@@ -185,6 +182,30 @@ static inline u8 tomoyo_make_byte(const u8 c1, const u8 c2, const u8 c3) | |||
185 | } | 182 | } |
186 | 183 | ||
187 | /** | 184 | /** |
185 | * tomoyo_valid - Check whether the character is a valid char. | ||
186 | * | ||
187 | * @c: The character to check. | ||
188 | * | ||
189 | * Returns true if @c is a valid character, false otherwise. | ||
190 | */ | ||
191 | static inline bool tomoyo_valid(const unsigned char c) | ||
192 | { | ||
193 | return c > ' ' && c < 127; | ||
194 | } | ||
195 | |||
196 | /** | ||
197 | * tomoyo_invalid - Check whether the character is an invalid char. | ||
198 | * | ||
199 | * @c: The character to check. | ||
200 | * | ||
201 | * Returns true if @c is an invalid character, false otherwise. | ||
202 | */ | ||
203 | static inline bool tomoyo_invalid(const unsigned char c) | ||
204 | { | ||
205 | return c && (c <= ' ' || c >= 127); | ||
206 | } | ||
207 | |||
208 | /** | ||
188 | * tomoyo_str_starts - Check whether the given string starts with the given keyword. | 209 | * tomoyo_str_starts - Check whether the given string starts with the given keyword. |
189 | * | 210 | * |
190 | * @src: Pointer to pointer to the string. | 211 | * @src: Pointer to pointer to the string. |