mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-25 18:30:06 +00:00
TOMOYO: Simplify policy reader.
We can directly assign the result of tomoyo_io_printf() to done flag. Signed-off-by: Kentaro Takeda <takedakn@nttdata.co.jp> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Signed-off-by: Toshiharu Harada <haradats@nttdata.co.jp> Signed-off-by: James Morris <jmorris@namei.org>
This commit is contained in:
parent
ab588ccadc
commit
7d2948b124
3 changed files with 41 additions and 52 deletions
|
@ -1113,11 +1113,10 @@ static int tomoyo_read_manager_policy(struct tomoyo_io_buffer *head)
|
||||||
list);
|
list);
|
||||||
if (ptr->is_deleted)
|
if (ptr->is_deleted)
|
||||||
continue;
|
continue;
|
||||||
if (!tomoyo_io_printf(head, "%s\n", ptr->manager->name)) {
|
done = tomoyo_io_printf(head, "%s\n", ptr->manager->name);
|
||||||
done = false;
|
if (!done)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
up_read(&tomoyo_policy_manager_list_lock);
|
up_read(&tomoyo_policy_manager_list_lock);
|
||||||
head->read_eof = done;
|
head->read_eof = done;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1441,15 +1440,14 @@ static int tomoyo_read_domain_policy(struct tomoyo_io_buffer *head)
|
||||||
TOMOYO_DOMAIN_FLAGS_IGNORE_GLOBAL_ALLOW_READ)
|
TOMOYO_DOMAIN_FLAGS_IGNORE_GLOBAL_ALLOW_READ)
|
||||||
ignore_global_allow_read
|
ignore_global_allow_read
|
||||||
= TOMOYO_KEYWORD_IGNORE_GLOBAL_ALLOW_READ "\n";
|
= TOMOYO_KEYWORD_IGNORE_GLOBAL_ALLOW_READ "\n";
|
||||||
if (!tomoyo_io_printf(head,
|
done = tomoyo_io_printf(head, "%s\n" TOMOYO_KEYWORD_USE_PROFILE
|
||||||
"%s\n" TOMOYO_KEYWORD_USE_PROFILE "%u\n"
|
"%u\n%s%s%s\n",
|
||||||
"%s%s%s\n", domain->domainname->name,
|
domain->domainname->name,
|
||||||
domain->profile, quota_exceeded,
|
domain->profile, quota_exceeded,
|
||||||
transition_failed,
|
transition_failed,
|
||||||
ignore_global_allow_read)) {
|
ignore_global_allow_read);
|
||||||
done = false;
|
if (!done)
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
head->read_step = 2;
|
head->read_step = 2;
|
||||||
acl_loop:
|
acl_loop:
|
||||||
if (head->read_step == 3)
|
if (head->read_step == 3)
|
||||||
|
@ -1461,20 +1459,18 @@ static int tomoyo_read_domain_policy(struct tomoyo_io_buffer *head)
|
||||||
struct tomoyo_acl_info *ptr
|
struct tomoyo_acl_info *ptr
|
||||||
= list_entry(apos, struct tomoyo_acl_info,
|
= list_entry(apos, struct tomoyo_acl_info,
|
||||||
list);
|
list);
|
||||||
if (!tomoyo_print_entry(head, ptr)) {
|
done = tomoyo_print_entry(head, ptr);
|
||||||
done = false;
|
if (!done)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
up_read(&tomoyo_domain_acl_info_list_lock);
|
up_read(&tomoyo_domain_acl_info_list_lock);
|
||||||
if (!done)
|
if (!done)
|
||||||
break;
|
break;
|
||||||
head->read_step = 3;
|
head->read_step = 3;
|
||||||
tail_mark:
|
tail_mark:
|
||||||
if (!tomoyo_io_printf(head, "\n")) {
|
done = tomoyo_io_printf(head, "\n");
|
||||||
done = false;
|
if (!done)
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
head->read_step = 1;
|
head->read_step = 1;
|
||||||
if (head->read_single_domain)
|
if (head->read_single_domain)
|
||||||
break;
|
break;
|
||||||
|
@ -1544,12 +1540,11 @@ static int tomoyo_read_domain_profile(struct tomoyo_io_buffer *head)
|
||||||
domain = list_entry(pos, struct tomoyo_domain_info, list);
|
domain = list_entry(pos, struct tomoyo_domain_info, list);
|
||||||
if (domain->is_deleted)
|
if (domain->is_deleted)
|
||||||
continue;
|
continue;
|
||||||
if (!tomoyo_io_printf(head, "%u %s\n", domain->profile,
|
done = tomoyo_io_printf(head, "%u %s\n", domain->profile,
|
||||||
domain->domainname->name)) {
|
domain->domainname->name);
|
||||||
done = false;
|
if (!done)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
up_read(&tomoyo_domain_list_lock);
|
up_read(&tomoyo_domain_list_lock);
|
||||||
head->read_eof = done;
|
head->read_eof = done;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -189,14 +189,13 @@ bool tomoyo_read_domain_initializer_policy(struct tomoyo_io_buffer *head)
|
||||||
from = " from ";
|
from = " from ";
|
||||||
domain = ptr->domainname->name;
|
domain = ptr->domainname->name;
|
||||||
}
|
}
|
||||||
if (!tomoyo_io_printf(head,
|
done = tomoyo_io_printf(head,
|
||||||
"%s" TOMOYO_KEYWORD_INITIALIZE_DOMAIN
|
"%s" TOMOYO_KEYWORD_INITIALIZE_DOMAIN
|
||||||
"%s%s%s\n", no, ptr->program->name, from,
|
"%s%s%s\n", no, ptr->program->name,
|
||||||
domain)) {
|
from, domain);
|
||||||
done = false;
|
if (!done)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
up_read(&tomoyo_domain_initializer_list_lock);
|
up_read(&tomoyo_domain_initializer_list_lock);
|
||||||
return done;
|
return done;
|
||||||
}
|
}
|
||||||
|
@ -387,14 +386,13 @@ bool tomoyo_read_domain_keeper_policy(struct tomoyo_io_buffer *head)
|
||||||
from = " from ";
|
from = " from ";
|
||||||
program = ptr->program->name;
|
program = ptr->program->name;
|
||||||
}
|
}
|
||||||
if (!tomoyo_io_printf(head,
|
done = tomoyo_io_printf(head,
|
||||||
"%s" TOMOYO_KEYWORD_KEEP_DOMAIN
|
"%s" TOMOYO_KEYWORD_KEEP_DOMAIN
|
||||||
"%s%s%s\n", no, program, from,
|
"%s%s%s\n", no, program, from,
|
||||||
ptr->domainname->name)) {
|
ptr->domainname->name);
|
||||||
done = false;
|
if (!done)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
up_read(&tomoyo_domain_keeper_list_lock);
|
up_read(&tomoyo_domain_keeper_list_lock);
|
||||||
return done;
|
return done;
|
||||||
}
|
}
|
||||||
|
@ -513,13 +511,12 @@ bool tomoyo_read_alias_policy(struct tomoyo_io_buffer *head)
|
||||||
ptr = list_entry(pos, struct tomoyo_alias_entry, list);
|
ptr = list_entry(pos, struct tomoyo_alias_entry, list);
|
||||||
if (ptr->is_deleted)
|
if (ptr->is_deleted)
|
||||||
continue;
|
continue;
|
||||||
if (!tomoyo_io_printf(head, TOMOYO_KEYWORD_ALIAS "%s %s\n",
|
done = tomoyo_io_printf(head, TOMOYO_KEYWORD_ALIAS "%s %s\n",
|
||||||
ptr->original_name->name,
|
ptr->original_name->name,
|
||||||
ptr->aliased_name->name)) {
|
ptr->aliased_name->name);
|
||||||
done = false;
|
if (!done)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
up_read(&tomoyo_alias_list_lock);
|
up_read(&tomoyo_alias_list_lock);
|
||||||
return done;
|
return done;
|
||||||
}
|
}
|
||||||
|
|
|
@ -247,12 +247,11 @@ bool tomoyo_read_globally_readable_policy(struct tomoyo_io_buffer *head)
|
||||||
list);
|
list);
|
||||||
if (ptr->is_deleted)
|
if (ptr->is_deleted)
|
||||||
continue;
|
continue;
|
||||||
if (!tomoyo_io_printf(head, TOMOYO_KEYWORD_ALLOW_READ "%s\n",
|
done = tomoyo_io_printf(head, TOMOYO_KEYWORD_ALLOW_READ "%s\n",
|
||||||
ptr->filename->name)) {
|
ptr->filename->name);
|
||||||
done = false;
|
if (!done)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
up_read(&tomoyo_globally_readable_list_lock);
|
up_read(&tomoyo_globally_readable_list_lock);
|
||||||
return done;
|
return done;
|
||||||
}
|
}
|
||||||
|
@ -369,12 +368,11 @@ bool tomoyo_read_file_pattern(struct tomoyo_io_buffer *head)
|
||||||
ptr = list_entry(pos, struct tomoyo_pattern_entry, list);
|
ptr = list_entry(pos, struct tomoyo_pattern_entry, list);
|
||||||
if (ptr->is_deleted)
|
if (ptr->is_deleted)
|
||||||
continue;
|
continue;
|
||||||
if (!tomoyo_io_printf(head, TOMOYO_KEYWORD_FILE_PATTERN "%s\n",
|
done = tomoyo_io_printf(head, TOMOYO_KEYWORD_FILE_PATTERN
|
||||||
ptr->pattern->name)) {
|
"%s\n", ptr->pattern->name);
|
||||||
done = false;
|
if (!done)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
up_read(&tomoyo_pattern_list_lock);
|
up_read(&tomoyo_pattern_list_lock);
|
||||||
return done;
|
return done;
|
||||||
}
|
}
|
||||||
|
@ -483,12 +481,11 @@ bool tomoyo_read_no_rewrite_policy(struct tomoyo_io_buffer *head)
|
||||||
ptr = list_entry(pos, struct tomoyo_no_rewrite_entry, list);
|
ptr = list_entry(pos, struct tomoyo_no_rewrite_entry, list);
|
||||||
if (ptr->is_deleted)
|
if (ptr->is_deleted)
|
||||||
continue;
|
continue;
|
||||||
if (!tomoyo_io_printf(head, TOMOYO_KEYWORD_DENY_REWRITE "%s\n",
|
done = tomoyo_io_printf(head, TOMOYO_KEYWORD_DENY_REWRITE
|
||||||
ptr->pattern->name)) {
|
"%s\n", ptr->pattern->name);
|
||||||
done = false;
|
if (!done)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
up_read(&tomoyo_no_rewrite_list_lock);
|
up_read(&tomoyo_no_rewrite_list_lock);
|
||||||
return done;
|
return done;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue