Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions | Variables
util.c File Reference
#include <linux/slab.h>
#include "common.h"

Go to the source code of this file.

Functions

 DEFINE_MUTEX (tomoyo_policy_lock)
 
void tomoyo_convert_time (time_t time, struct tomoyo_time *stamp)
 
bool tomoyo_permstr (const char *string, const char *keyword)
 
chartomoyo_read_token (struct tomoyo_acl_param *param)
 
struct tomoyo_path_infotomoyo_get_domainname (struct tomoyo_acl_param *param)
 
u8 tomoyo_parse_ulong (unsigned long *result, char **str)
 
void tomoyo_print_ulong (char *buffer, const int buffer_len, const unsigned long value, const u8 type)
 
bool tomoyo_parse_name_union (struct tomoyo_acl_param *param, struct tomoyo_name_union *ptr)
 
bool tomoyo_parse_number_union (struct tomoyo_acl_param *param, struct tomoyo_number_union *ptr)
 
bool tomoyo_str_starts (char **src, const char *find)
 
void tomoyo_normalize_line (unsigned char *buffer)
 
bool tomoyo_correct_word (const char *string)
 
bool tomoyo_correct_path (const char *filename)
 
bool tomoyo_correct_domain (const unsigned char *domainname)
 
bool tomoyo_domain_def (const unsigned char *buffer)
 
struct tomoyo_domain_infotomoyo_find_domain (const char *domainname)
 
void tomoyo_fill_path_info (struct tomoyo_path_info *ptr)
 
bool tomoyo_path_matches_pattern (const struct tomoyo_path_info *filename, const struct tomoyo_path_info *pattern)
 
const chartomoyo_get_exe (void)
 
int tomoyo_get_mode (const struct tomoyo_policy_namespace *ns, const u8 profile, const u8 index)
 
int tomoyo_init_request_info (struct tomoyo_request_info *r, struct tomoyo_domain_info *domain, const u8 index)
 
bool tomoyo_domain_quota_is_ok (struct tomoyo_request_info *r)
 

Variables

bool tomoyo_policy_loaded
 
const u8 tomoyo_index2category [TOMOYO_MAX_MAC_INDEX]
 

Function Documentation

DEFINE_MUTEX ( tomoyo_policy_lock  )
void tomoyo_convert_time ( time_t  time,
struct tomoyo_time stamp 
)

tomoyo_convert_time - Convert time_t to YYYY/MM/DD hh/mm/ss.

: Seconds since 1970/01/01 00:00:00. : Pointer to "struct tomoyo_time".

Returns nothing.

This function does not handle Y2038 problem.

Definition at line 90 of file util.c.

bool tomoyo_correct_domain ( const unsigned char domainname)

tomoyo_correct_domain - Check whether the given domainname follows the naming rules.

: The domainname to check.

Returns true if follows the naming rules, false otherwise.

Definition at line 545 of file util.c.

bool tomoyo_correct_path ( const char filename)

tomoyo_correct_path - Validate a pathname.

: The pathname to check.

Check whether the given pathname follows the naming rules. Returns true if follows the naming rules, false otherwise.

Definition at line 533 of file util.c.

bool tomoyo_correct_word ( const char string)

tomoyo_correct_word - Validate a string.

: The string to check.

Check whether the given string follows the naming rules. Returns true if follows the naming rules, false otherwise.

Definition at line 520 of file util.c.

bool tomoyo_domain_def ( const unsigned char buffer)

tomoyo_domain_def - Check whether the given token can be a domainname.

: The token to check.

Returns true if possibly be a domainname, false otherwise.

Definition at line 571 of file util.c.

bool tomoyo_domain_quota_is_ok ( struct tomoyo_request_info r)

tomoyo_domain_quota_is_ok - Check for domain's quota.

: Pointer to "struct tomoyo_request_info".

Returns true if the domain is not exceeded quota, false otherwise.

Caller holds tomoyo_read_lock().

Definition at line 1023 of file util.c.

void tomoyo_fill_path_info ( struct tomoyo_path_info ptr)

tomoyo_fill_path_info - Fill in "struct tomoyo_path_info" members.

: Pointer to "struct tomoyo_path_info" to fill in.

The caller sets "struct tomoyo_path_info"->name.

Definition at line 661 of file util.c.

struct tomoyo_domain_info* tomoyo_find_domain ( const char domainname)
read

tomoyo_find_domain - Find a domain by the given name.

: The domainname to find.

Returns pointer to "struct tomoyo_domain_info" if found, NULL otherwise.

Caller holds tomoyo_read_lock().

Definition at line 597 of file util.c.

struct tomoyo_path_info* tomoyo_get_domainname ( struct tomoyo_acl_param param)
read

tomoyo_get_domainname - Read a domainname from a line.

Parameters
Pointer to "struct tomoyo_acl_param".

Returns a domainname on success, NULL otherwise.

Definition at line 169 of file util.c.

const char* tomoyo_get_exe ( void  )

tomoyo_get_exe - Get tomoyo_realpath() of current process.

Returns the tomoyo_realpath() of current process on success, NULL otherwise.

This function uses kzalloc(), so the caller must call kfree() if this function didn't return NULL.

Definition at line 949 of file util.c.

int tomoyo_get_mode ( const struct tomoyo_policy_namespace ns,
const u8  profile,
const u8  index 
)

tomoyo_get_mode - Get MAC mode.

: Pointer to "struct tomoyo_policy_namespace". : Profile number. : Index number of functionality.

Returns mode.

Definition at line 972 of file util.c.

int tomoyo_init_request_info ( struct tomoyo_request_info r,
struct tomoyo_domain_info domain,
const u8  index 
)

tomoyo_init_request_info - Initialize "struct tomoyo_request_info" members.

: Pointer to "struct tomoyo_request_info" to initialize. : Pointer to "struct tomoyo_domain_info". NULL for tomoyo_domain(). : Index number of functionality.

Returns mode.

Definition at line 999 of file util.c.

void tomoyo_normalize_line ( unsigned char buffer)

tomoyo_normalize_line - Format string.

: The line to normalize.

Leading and trailing whitespaces are removed. Multiple whitespaces are packed into single space.

Returns nothing.

Definition at line 414 of file util.c.

bool tomoyo_parse_name_union ( struct tomoyo_acl_param param,
struct tomoyo_name_union ptr 
)

tomoyo_parse_name_union - Parse a tomoyo_name_union.

Parameters
Pointer to "struct tomoyo_acl_param". : Pointer to "struct tomoyo_name_union".

Returns true on success, false otherwise.

Definition at line 257 of file util.c.

bool tomoyo_parse_number_union ( struct tomoyo_acl_param param,
struct tomoyo_number_union ptr 
)

tomoyo_parse_number_union - Parse a tomoyo_number_union.

Parameters
Pointer to "struct tomoyo_acl_param". : Pointer to "struct tomoyo_number_union".

Returns true on success, false otherwise.

Definition at line 281 of file util.c.

u8 tomoyo_parse_ulong ( unsigned long result,
char **  str 
)

tomoyo_parse_ulong - Parse an "unsigned long" value.

Returns
: Pointer to "unsigned long". : Pointer to string to parse.

Returns one of values in "enum tomoyo_value_type".

The is updated to point the first character after the value on success.

Definition at line 197 of file util.c.

bool tomoyo_path_matches_pattern ( const struct tomoyo_path_info filename,
const struct tomoyo_path_info pattern 
)

/ '/' + 'One or more repetitions of dir/' (e.g. /dir/ /dir/dir/ /dir/dir/dir/ ).

Definition at line 920 of file util.c.

bool tomoyo_permstr ( const char string,
const char keyword 
)

tomoyo_permstr - Find permission keywords.

: String representation for permissions in foo/bar/buz format. : Keyword to find from /

Returns ture if was found in , false otherwise.

This function assumes that strncmp(w1, w2, strlen(w1)) != 0 if w1 != w2.

Definition at line 131 of file util.c.

void tomoyo_print_ulong ( char buffer,
const int  buffer_len,
const unsigned long  value,
const u8  type 
)

tomoyo_print_ulong - Print an "unsigned long" value.

: Pointer to buffer. : Size of . : An "unsigned long" value. : Type of .

Returns nothing.

Definition at line 236 of file util.c.

char* tomoyo_read_token ( struct tomoyo_acl_param param)

tomoyo_read_token - Read a word from a line.

Parameters
Pointer to "struct tomoyo_acl_param".

Returns a word on success, "" otherwise.

To allow the caller to skip NULL check, this function returns "" rather than NULL if there is no more words to read.

Definition at line 149 of file util.c.

bool tomoyo_str_starts ( char **  src,
const char find 
)

tomoyo_str_starts - Check whether the given string starts with the given keyword.

: Pointer to pointer to the string. : Pointer to the keyword.

Returns true if starts with , false otherwise.

The is updated to point the first character after the if starts with .

Definition at line 392 of file util.c.

Variable Documentation

const u8 tomoyo_index2category[TOMOYO_MAX_MAC_INDEX]

Definition at line 20 of file util.c.

bool tomoyo_policy_loaded

Definition at line 14 of file util.c.