Skip to content

Commit b5bc60b

Browse files
Tetsuo Handaxjamesmorris
authored andcommitted
TOMOYO: Cleanup part 2.
Update (or temporarily remove) comments. Remove or replace some of #define lines. Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Signed-off-by: James Morris <jmorris@namei.org>
1 parent 7c75964 commit b5bc60b

5 files changed

Lines changed: 204 additions & 359 deletions

File tree

‎security/tomoyo/common.c‎

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ static int tomoyo_update_manager_entry(const char *manager,
643643
static int tomoyo_write_manager(struct tomoyo_io_buffer *head)
644644
{
645645
char *data = head->write_buf;
646-
bool is_delete = tomoyo_str_starts(&data, TOMOYO_KEYWORD_DELETE);
646+
bool is_delete = tomoyo_str_starts(&data, "delete ");
647647

648648
if (!strcmp(data, "manage_by_non_root")) {
649649
tomoyo_manage_by_non_root = !is_delete;
@@ -830,7 +830,7 @@ static int tomoyo_delete_domain(char *domainname)
830830
static int tomoyo_write_domain2(char *data, struct tomoyo_domain_info *domain,
831831
const bool is_delete)
832832
{
833-
if (tomoyo_str_starts(&data, TOMOYO_KEYWORD_ALLOW_MOUNT))
833+
if (tomoyo_str_starts(&data, "allow_mount "))
834834
return tomoyo_write_mount(data, domain, is_delete);
835835
return tomoyo_write_file(data, domain, is_delete);
836836
}
@@ -852,9 +852,9 @@ static int tomoyo_write_domain(struct tomoyo_io_buffer *head)
852852
bool is_select = false;
853853
unsigned int profile;
854854

855-
if (tomoyo_str_starts(&data, TOMOYO_KEYWORD_DELETE))
855+
if (tomoyo_str_starts(&data, "delete "))
856856
is_delete = true;
857-
else if (tomoyo_str_starts(&data, TOMOYO_KEYWORD_SELECT))
857+
else if (tomoyo_str_starts(&data, "select "))
858858
is_select = true;
859859
if (is_select && tomoyo_select_one(head, data))
860860
return 0;
@@ -875,17 +875,17 @@ static int tomoyo_write_domain(struct tomoyo_io_buffer *head)
875875
if (!domain)
876876
return -EINVAL;
877877

878-
if (sscanf(data, TOMOYO_KEYWORD_USE_PROFILE "%u", &profile) == 1
878+
if (sscanf(data, "use_profile %u", &profile) == 1
879879
&& profile < TOMOYO_MAX_PROFILES) {
880880
if (tomoyo_profile_ptr[profile] || !tomoyo_policy_loaded)
881881
domain->profile = (u8) profile;
882882
return 0;
883883
}
884-
if (!strcmp(data, TOMOYO_KEYWORD_QUOTA_EXCEEDED)) {
884+
if (!strcmp(data, "quota_exceeded")) {
885885
domain->quota_warned = !is_delete;
886886
return 0;
887887
}
888-
if (!strcmp(data, TOMOYO_KEYWORD_TRANSITION_FAILED)) {
888+
if (!strcmp(data, "transition_failed")) {
889889
domain->transition_failed = !is_delete;
890890
return 0;
891891
}
@@ -1039,8 +1039,7 @@ static void tomoyo_read_domain(struct tomoyo_io_buffer *head)
10391039
/* Print domainname and flags. */
10401040
tomoyo_set_string(head, domain->domainname->name);
10411041
tomoyo_set_lf(head);
1042-
tomoyo_io_printf(head,
1043-
TOMOYO_KEYWORD_USE_PROFILE "%u\n",
1042+
tomoyo_io_printf(head, "use_profile %u\n",
10441043
domain->profile);
10451044
if (domain->quota_warned)
10461045
tomoyo_set_string(head, "quota_exceeded\n");
@@ -1192,17 +1191,15 @@ static void tomoyo_read_pid(struct tomoyo_io_buffer *head)
11921191
}
11931192

11941193
static const char *tomoyo_transition_type[TOMOYO_MAX_TRANSITION_TYPE] = {
1195-
[TOMOYO_TRANSITION_CONTROL_NO_INITIALIZE]
1196-
= TOMOYO_KEYWORD_NO_INITIALIZE_DOMAIN,
1197-
[TOMOYO_TRANSITION_CONTROL_INITIALIZE]
1198-
= TOMOYO_KEYWORD_INITIALIZE_DOMAIN,
1199-
[TOMOYO_TRANSITION_CONTROL_NO_KEEP] = TOMOYO_KEYWORD_NO_KEEP_DOMAIN,
1200-
[TOMOYO_TRANSITION_CONTROL_KEEP] = TOMOYO_KEYWORD_KEEP_DOMAIN
1194+
[TOMOYO_TRANSITION_CONTROL_NO_INITIALIZE] = "no_initialize_domain",
1195+
[TOMOYO_TRANSITION_CONTROL_INITIALIZE] = "initialize_domain",
1196+
[TOMOYO_TRANSITION_CONTROL_NO_KEEP] = "no_keep_domain",
1197+
[TOMOYO_TRANSITION_CONTROL_KEEP] = "keep_domain",
12011198
};
12021199

12031200
static const char *tomoyo_group_name[TOMOYO_MAX_GROUP] = {
1204-
[TOMOYO_PATH_GROUP] = TOMOYO_KEYWORD_PATH_GROUP,
1205-
[TOMOYO_NUMBER_GROUP] = TOMOYO_KEYWORD_NUMBER_GROUP
1201+
[TOMOYO_PATH_GROUP] = "path_group ",
1202+
[TOMOYO_NUMBER_GROUP] = "number_group ",
12061203
};
12071204

12081205
/**
@@ -1217,13 +1214,13 @@ static const char *tomoyo_group_name[TOMOYO_MAX_GROUP] = {
12171214
static int tomoyo_write_exception(struct tomoyo_io_buffer *head)
12181215
{
12191216
char *data = head->write_buf;
1220-
bool is_delete = tomoyo_str_starts(&data, TOMOYO_KEYWORD_DELETE);
1217+
bool is_delete = tomoyo_str_starts(&data, "delete ");
12211218
u8 i;
12221219
static const struct {
12231220
const char *keyword;
12241221
int (*write) (char *, const bool);
12251222
} tomoyo_callback[1] = {
1226-
{ TOMOYO_KEYWORD_AGGREGATOR, tomoyo_write_aggregator },
1223+
{ "aggregator ", tomoyo_write_aggregator },
12271224
};
12281225

12291226
for (i = 0; i < TOMOYO_MAX_TRANSITION_TYPE; i++)
@@ -1324,8 +1321,7 @@ static bool tomoyo_read_policy(struct tomoyo_io_buffer *head, const int idx)
13241321
{
13251322
struct tomoyo_aggregator *ptr =
13261323
container_of(acl, typeof(*ptr), head);
1327-
tomoyo_set_string(head,
1328-
TOMOYO_KEYWORD_AGGREGATOR);
1324+
tomoyo_set_string(head, "aggregator ");
13291325
tomoyo_set_string(head,
13301326
ptr->original_name->name);
13311327
tomoyo_set_space(head);

0 commit comments

Comments
 (0)