Skip to content

Commit

Permalink
TOMOYO: Rename symbols.
Browse files Browse the repository at this point in the history
Use shorter name in order to make it easier to fit 80 columns limit.

Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: James Morris <jmorris@namei.org>
  • Loading branch information
Tetsuo Handa authored and James Morris committed Aug 2, 2010
1 parent 8e56868 commit e2bf690
Show file tree
Hide file tree
Showing 8 changed files with 199 additions and 240 deletions.
226 changes: 100 additions & 126 deletions security/tomoyo/common.c

Large diffs are not rendered by default.

54 changes: 25 additions & 29 deletions security/tomoyo/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,10 +310,10 @@ struct tomoyo_path_info {
};

/*
* tomoyo_name_entry is a structure which is used for linking
* tomoyo_name is a structure which is used for linking
* "struct tomoyo_path_info" into tomoyo_name_list .
*/
struct tomoyo_name_entry {
struct tomoyo_name {
struct list_head list;
atomic_t users;
struct tomoyo_path_info entry;
Expand Down Expand Up @@ -572,42 +572,42 @@ struct tomoyo_io_buffer {
};

/*
* tomoyo_globally_readable_file_entry is a structure which is used for holding
* tomoyo_readable_file is a structure which is used for holding
* "allow_read" entries.
* It has following fields.
*
* (1) "head" is "struct tomoyo_acl_head".
* (2) "filename" is a pathname which is allowed to open(O_RDONLY).
*/
struct tomoyo_globally_readable_file_entry {
struct tomoyo_readable_file {
struct tomoyo_acl_head head;
const struct tomoyo_path_info *filename;
};

/*
* tomoyo_pattern_entry is a structure which is used for holding
* tomoyo_no_pattern is a structure which is used for holding
* "file_pattern" entries.
* It has following fields.
*
* (1) "head" is "struct tomoyo_acl_head".
* (2) "pattern" is a pathname pattern which is used for converting pathnames
* to pathname patterns during learning mode.
*/
struct tomoyo_pattern_entry {
struct tomoyo_no_pattern {
struct tomoyo_acl_head head;
const struct tomoyo_path_info *pattern;
};

/*
* tomoyo_no_rewrite_entry is a structure which is used for holding
* tomoyo_no_rewrite is a structure which is used for holding
* "deny_rewrite" entries.
* It has following fields.
*
* (1) "head" is "struct tomoyo_acl_head".
* (2) "pattern" is a pathname which is by default not permitted to modify
* already existing content.
*/
struct tomoyo_no_rewrite_entry {
struct tomoyo_no_rewrite {
struct tomoyo_acl_head head;
const struct tomoyo_path_info *pattern;
};
Expand Down Expand Up @@ -636,22 +636,22 @@ struct tomoyo_transition_control {
};

/*
* tomoyo_aggregator_entry is a structure which is used for holding
* tomoyo_aggregator is a structure which is used for holding
* "aggregator" entries.
* It has following fields.
*
* (1) "head" is "struct tomoyo_acl_head".
* (2) "original_name" which is originally requested name.
* (3) "aggregated_name" which is name to rewrite.
*/
struct tomoyo_aggregator_entry {
struct tomoyo_aggregator {
struct tomoyo_acl_head head;
const struct tomoyo_path_info *original_name;
const struct tomoyo_path_info *aggregated_name;
};

/*
* tomoyo_policy_manager_entry is a structure which is used for holding list of
* tomoyo_manager is a structure which is used for holding list of
* domainnames or programs which are permitted to modify configuration via
* /sys/kernel/security/tomoyo/ interface.
* It has following fields.
Expand All @@ -661,7 +661,7 @@ struct tomoyo_aggregator_entry {
* otherwise.
* (3) "manager" is a domainname or a program's pathname.
*/
struct tomoyo_policy_manager_entry {
struct tomoyo_manager {
struct tomoyo_acl_head head;
bool is_domain; /* True if manager is a domainname. */
/* A path to program or a domainname. */
Expand Down Expand Up @@ -749,8 +749,6 @@ bool tomoyo_parse_number_union(char *data, struct tomoyo_number_union *num);
bool tomoyo_tokenize(char *buffer, char *w[], size_t size);
/* Write domain policy violation warning message to console? */
bool tomoyo_verbose_mode(const struct tomoyo_domain_info *domain);
/* Get the last component of the given domainname. */
const char *tomoyo_get_last_name(const struct tomoyo_domain_info *domain);
/* Fill "struct tomoyo_request_info". */
int tomoyo_init_request_info(struct tomoyo_request_info *r,
struct tomoyo_domain_info *domain,
Expand All @@ -759,7 +757,7 @@ int tomoyo_init_request_info(struct tomoyo_request_info *r,
int tomoyo_mount_permission(char *dev_name, struct path *path, char *type,
unsigned long flags, void *data_page);
/* Create "aggregator" entry in exception policy. */
int tomoyo_write_aggregator_policy(char *data, const bool is_delete);
int tomoyo_write_aggregator(char *data, const bool is_delete);
int tomoyo_write_transition_control(char *data, const bool is_delete,
const u8 type);
/*
Expand All @@ -769,27 +767,26 @@ int tomoyo_write_transition_control(char *data, const bool is_delete,
* "allow_truncate", "allow_symlink", "allow_rewrite", "allow_rename" and
* "allow_link" entry in domain policy.
*/
int tomoyo_write_file_policy(char *data, struct tomoyo_domain_info *domain,
const bool is_delete);
int tomoyo_write_file(char *data, struct tomoyo_domain_info *domain,
const bool is_delete);
/* Create "allow_read" entry in exception policy. */
int tomoyo_write_globally_readable_policy(char *data, const bool is_delete);
int tomoyo_write_globally_readable(char *data, const bool is_delete);
/* Create "allow_mount" entry in domain policy. */
int tomoyo_write_mount_policy(char *data, struct tomoyo_domain_info *domain,
const bool is_delete);
int tomoyo_write_mount(char *data, struct tomoyo_domain_info *domain,
const bool is_delete);
/* Create "deny_rewrite" entry in exception policy. */
int tomoyo_write_no_rewrite_policy(char *data, const bool is_delete);
int tomoyo_write_no_rewrite(char *data, const bool is_delete);
/* Create "file_pattern" entry in exception policy. */
int tomoyo_write_pattern_policy(char *data, const bool is_delete);
int tomoyo_write_pattern(char *data, const bool is_delete);
/* Create "path_group"/"number_group" entry in exception policy. */
int tomoyo_write_group(char *data, const bool is_delete, const u8 type);
int tomoyo_supervisor(struct tomoyo_request_info *r, const char *fmt, ...)
__attribute__ ((format(printf, 2, 3)));
/* Find a domain by the given name. */
struct tomoyo_domain_info *tomoyo_find_domain(const char *domainname);
/* Find or create a domain by the given name. */
struct tomoyo_domain_info *tomoyo_find_or_assign_new_domain(const char *
domainname,
const u8 profile);
struct tomoyo_domain_info *tomoyo_assign_domain(const char *domainname,
const u8 profile);
struct tomoyo_profile *tomoyo_profile(const u8 profile);
/*
* Allocate memory for "struct tomoyo_path_group"/"struct tomoyo_number_group".
Expand Down Expand Up @@ -820,7 +817,7 @@ char *tomoyo_realpath_nofollow(const char *pathname);
*/
char *tomoyo_realpath_from_path(struct path *path);
/* Get patterned pathname. */
const char *tomoyo_file_pattern(const struct tomoyo_path_info *filename);
const char *tomoyo_pattern(const struct tomoyo_path_info *filename);

/* Check memory quota. */
bool tomoyo_memory_ok(void *ptr);
Expand Down Expand Up @@ -882,7 +879,6 @@ int tomoyo_update_policy(struct tomoyo_acl_head *new_entry, const int size,
void tomoyo_check_acl(struct tomoyo_request_info *r,
bool (*check_entry) (const struct tomoyo_request_info *,
const struct tomoyo_acl_info *));
const char *tomoyo_last_word(const char *name);

/********** External variable definitions. **********/

Expand Down Expand Up @@ -959,8 +955,8 @@ static inline bool tomoyo_invalid(const unsigned char c)
static inline void tomoyo_put_name(const struct tomoyo_path_info *name)
{
if (name) {
struct tomoyo_name_entry *ptr =
container_of(name, struct tomoyo_name_entry, entry);
struct tomoyo_name *ptr =
container_of(name, typeof(*ptr), entry);
atomic_dec(&ptr->users);
}
}
Expand Down
60 changes: 25 additions & 35 deletions security/tomoyo/domain.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,26 +134,22 @@ struct list_head tomoyo_policy_list[TOMOYO_MAX_POLICY];
struct list_head tomoyo_group_list[TOMOYO_MAX_GROUP];

/**
* tomoyo_get_last_name - Get last component of a domainname.
* tomoyo_last_word - Get last component of a domainname.
*
* @domain: Pointer to "struct tomoyo_domain_info".
* @domainname: Domainname to check.
*
* Returns the last component of the domainname.
* Returns the last word of @domainname.
*/
const char *tomoyo_get_last_name(const struct tomoyo_domain_info *domain)
static const char *tomoyo_last_word(const char *name)
{
const char *cp0 = domain->domainname->name;
const char *cp1 = strrchr(cp0, ' ');

if (cp1)
return cp1 + 1;
return cp0;
const char *cp = strrchr(name, ' ');
if (cp)
return cp + 1;
return name;
}

static bool tomoyo_same_transition_control_entry(const struct tomoyo_acl_head *
a,
const struct tomoyo_acl_head *
b)
static bool tomoyo_same_transition_control(const struct tomoyo_acl_head *a,
const struct tomoyo_acl_head *b)
{
const struct tomoyo_transition_control *p1 = container_of(a,
typeof(*p1),
Expand Down Expand Up @@ -203,7 +199,7 @@ static int tomoyo_update_transition_control_entry(const char *domainname,
error = tomoyo_update_policy(&e.head, sizeof(e), is_delete,
&tomoyo_policy_list
[TOMOYO_ID_TRANSITION_CONTROL],
tomoyo_same_transition_control_entry);
tomoyo_same_transition_control);
out:
tomoyo_put_name(e.domainname);
tomoyo_put_name(e.program);
Expand Down Expand Up @@ -292,19 +288,17 @@ static u8 tomoyo_transition_type(const struct tomoyo_path_info *domainname,
return type;
}

static bool tomoyo_same_aggregator_entry(const struct tomoyo_acl_head *a,
const struct tomoyo_acl_head *b)
static bool tomoyo_same_aggregator(const struct tomoyo_acl_head *a,
const struct tomoyo_acl_head *b)
{
const struct tomoyo_aggregator_entry *p1 = container_of(a, typeof(*p1),
head);
const struct tomoyo_aggregator_entry *p2 = container_of(b, typeof(*p2),
head);
const struct tomoyo_aggregator *p1 = container_of(a, typeof(*p1), head);
const struct tomoyo_aggregator *p2 = container_of(b, typeof(*p2), head);
return p1->original_name == p2->original_name &&
p1->aggregated_name == p2->aggregated_name;
}

/**
* tomoyo_update_aggregator_entry - Update "struct tomoyo_aggregator_entry" list.
* tomoyo_update_aggregator_entry - Update "struct tomoyo_aggregator" list.
*
* @original_name: The original program's name.
* @aggregated_name: The program name to use.
Expand All @@ -318,7 +312,7 @@ static int tomoyo_update_aggregator_entry(const char *original_name,
const char *aggregated_name,
const bool is_delete)
{
struct tomoyo_aggregator_entry e = { };
struct tomoyo_aggregator e = { };
int error = is_delete ? -ENOENT : -ENOMEM;

if (!tomoyo_correct_path(original_name) ||
Expand All @@ -331,15 +325,15 @@ static int tomoyo_update_aggregator_entry(const char *original_name,
goto out;
error = tomoyo_update_policy(&e.head, sizeof(e), is_delete,
&tomoyo_policy_list[TOMOYO_ID_AGGREGATOR],
tomoyo_same_aggregator_entry);
tomoyo_same_aggregator);
out:
tomoyo_put_name(e.original_name);
tomoyo_put_name(e.aggregated_name);
return error;
}

/**
* tomoyo_write_aggregator_policy - Write "struct tomoyo_aggregator_entry" list.
* tomoyo_write_aggregator - Write "struct tomoyo_aggregator" list.
*
* @data: String to parse.
* @is_delete: True if it is a delete request.
Expand All @@ -348,7 +342,7 @@ static int tomoyo_update_aggregator_entry(const char *original_name,
*
* Caller holds tomoyo_read_lock().
*/
int tomoyo_write_aggregator_policy(char *data, const bool is_delete)
int tomoyo_write_aggregator(char *data, const bool is_delete)
{
char *cp = strchr(data, ' ');

Expand All @@ -359,7 +353,7 @@ int tomoyo_write_aggregator_policy(char *data, const bool is_delete)
}

/**
* tomoyo_find_or_assign_new_domain - Create a domain.
* tomoyo_assign_domain - Create a domain.
*
* @domainname: The name of domain.
* @profile: Profile number to assign if the domain was newly created.
Expand All @@ -368,9 +362,8 @@ int tomoyo_write_aggregator_policy(char *data, const bool is_delete)
*
* Caller holds tomoyo_read_lock().
*/
struct tomoyo_domain_info *tomoyo_find_or_assign_new_domain(const char *
domainname,
const u8 profile)
struct tomoyo_domain_info *tomoyo_assign_domain(const char *domainname,
const u8 profile)
{
struct tomoyo_domain_info *entry;
struct tomoyo_domain_info *domain = NULL;
Expand Down Expand Up @@ -430,10 +423,7 @@ int tomoyo_find_next_domain(struct linux_binprm *bprm)
int retval = -ENOMEM;
bool need_kfree = false;
struct tomoyo_path_info rn = { }; /* real name */
struct tomoyo_path_info ln; /* last name */

ln.name = tomoyo_get_last_name(old_domain);
tomoyo_fill_path_info(&ln);
mode = tomoyo_init_request_info(&r, NULL, TOMOYO_MAC_FILE_EXECUTE);
is_enforce = (mode == TOMOYO_CONFIG_ENFORCING);
if (!tmp)
Expand All @@ -454,7 +444,7 @@ int tomoyo_find_next_domain(struct linux_binprm *bprm)

/* Check 'aggregator' directive. */
{
struct tomoyo_aggregator_entry *ptr;
struct tomoyo_aggregator *ptr;
list_for_each_entry_rcu(ptr, &tomoyo_policy_list
[TOMOYO_ID_AGGREGATOR], head.list) {
if (ptr->head.is_deleted ||
Expand Down Expand Up @@ -517,7 +507,7 @@ int tomoyo_find_next_domain(struct linux_binprm *bprm)
if (error < 0)
goto done;
}
domain = tomoyo_find_or_assign_new_domain(tmp, old_domain->profile);
domain = tomoyo_assign_domain(tmp, old_domain->profile);
done:
if (domain)
goto out;
Expand Down
Loading

0 comments on commit e2bf690

Please sign in to comment.