255 |
ptr->learning_verbose = false; |
ptr->learning_verbose = false; |
256 |
ptr->learning_exec_realpath = true; |
ptr->learning_exec_realpath = true; |
257 |
ptr->learning_exec_argv0 = true; |
ptr->learning_exec_argv0 = true; |
258 |
|
ptr->learning_symlink_target = true; |
259 |
ptr->default_config = CCS_CONFIG_DISABLED | |
ptr->default_config = CCS_CONFIG_DISABLED | |
260 |
CCS_CONFIG_WANT_GRANT_LOG | CCS_CONFIG_WANT_REJECT_LOG; |
CCS_CONFIG_WANT_GRANT_LOG | CCS_CONFIG_WANT_REJECT_LOG; |
261 |
memset(ptr->config, CCS_CONFIG_USE_DEFAULT, |
memset(ptr->config, CCS_CONFIG_USE_DEFAULT, |
371 |
profile->learning_exec_argv0 = true; |
profile->learning_exec_argv0 = true; |
372 |
else if (strstr(cp, "exec.argv0=no")) |
else if (strstr(cp, "exec.argv0=no")) |
373 |
profile->learning_exec_argv0 = false; |
profile->learning_exec_argv0 = false; |
374 |
|
if (strstr(cp, "symlink.target=yes")) |
375 |
|
profile->learning_symlink_target = true; |
376 |
|
else if (strstr(cp, "symlink.target=no")) |
377 |
|
profile->learning_symlink_target = false; |
378 |
return 0; |
return 0; |
379 |
} |
} |
380 |
if (!strcmp(data, "CONFIG")) { |
if (!strcmp(data, "CONFIG")) { |
502 |
#endif |
#endif |
503 |
if (!ccs_io_printf(head, "%u-PREFERENCE::learning={ " |
if (!ccs_io_printf(head, "%u-PREFERENCE::learning={ " |
504 |
"verbose=%s max_entry=%u exec.realpath=%s " |
"verbose=%s max_entry=%u exec.realpath=%s " |
505 |
"exec.argv0=%s }\n", index, |
"exec.argv0=%s symlink.target=%s }\n", |
506 |
ccs_yesno(profile->learning_verbose), |
index, ccs_yesno(profile->learning_verbose), |
507 |
profile->learning_max_entry, |
profile->learning_max_entry, |
508 |
ccs_yesno(profile->learning_exec_realpath), |
ccs_yesno(profile->learning_exec_realpath), |
509 |
ccs_yesno(profile->learning_exec_argv0)) || |
ccs_yesno(profile->learning_exec_argv0), |
510 |
!ccs_io_printf(head, "%u-PREFERENCE::permissive={ " |
ccs_yesno(profile->learning_symlink_target)) |
511 |
"verbose=%s }\n", index, |
|| !ccs_io_printf(head, "%u-PREFERENCE::permissive={ " |
512 |
ccs_yesno(profile->permissive_verbose)) || |
"verbose=%s }\n", index, |
513 |
!ccs_io_printf(head, "%u-PREFERENCE::enforcing={ " |
ccs_yesno(profile->permissive_verbose)) |
514 |
"verbose=%s penalty=%u }\n", index, |
|| !ccs_io_printf(head, "%u-PREFERENCE::enforcing={ " |
515 |
ccs_yesno(profile->enforcing_verbose), |
"verbose=%s penalty=%u }\n", index, |
516 |
profile->enforcing_penalty)) |
ccs_yesno(profile->enforcing_verbose), |
517 |
|
profile->enforcing_penalty)) |
518 |
goto out; |
goto out; |
519 |
continue; |
continue; |
520 |
out: |
out: |
2017 |
return cond; |
return cond; |
2018 |
} |
} |
2019 |
|
|
2020 |
|
/** |
2021 |
|
* ccs_get_symlink_condition - Get condition part for symlink requests. |
2022 |
|
* |
2023 |
|
* @r: Pointer to "struct ccs_request_info". |
2024 |
|
* |
2025 |
|
* Returns pointer to "struct ccs_condition" on success, NULL otherwise. |
2026 |
|
*/ |
2027 |
|
static struct ccs_condition *ccs_get_symlink_condition(struct ccs_request_info |
2028 |
|
*r) |
2029 |
|
{ |
2030 |
|
struct ccs_condition *cond; |
2031 |
|
char *buf; |
2032 |
|
int len = 256; |
2033 |
|
const char *symlink = NULL; |
2034 |
|
const struct ccs_profile *profile = ccs_profile(r->profile); |
2035 |
|
if (profile->learning_symlink_target) { |
2036 |
|
symlink = r->obj->symlink_target->name; |
2037 |
|
len += strlen(symlink) + 18; |
2038 |
|
} |
2039 |
|
buf = kmalloc(len, GFP_KERNEL); |
2040 |
|
if (!buf) |
2041 |
|
return NULL; |
2042 |
|
snprintf(buf, len - 1, "if"); |
2043 |
|
if (current->ccs_flags & CCS_TASK_IS_EXECUTE_HANDLER) { |
2044 |
|
const int pos = strlen(buf); |
2045 |
|
snprintf(buf + pos, len - pos - 1, |
2046 |
|
" task.type=execute_handler"); |
2047 |
|
} |
2048 |
|
if (symlink) { |
2049 |
|
const int pos = strlen(buf); |
2050 |
|
snprintf(buf + pos, len - pos - 1, " symlink.target=\"%s\"", |
2051 |
|
symlink); |
2052 |
|
} |
2053 |
|
cond = ccs_get_condition(buf); |
2054 |
|
kfree(buf); |
2055 |
|
return cond; |
2056 |
|
} |
2057 |
|
|
2058 |
/* Wait queue for ccs_query_list. */ |
/* Wait queue for ccs_query_list. */ |
2059 |
static DECLARE_WAIT_QUEUE_HEAD(ccs_query_wait); |
static DECLARE_WAIT_QUEUE_HEAD(ccs_query_wait); |
2060 |
|
|
2118 |
ccs_normalize_line(buffer); |
ccs_normalize_line(buffer); |
2119 |
if (r->ee && !strncmp(buffer, "allow_execute ", 14)) |
if (r->ee && !strncmp(buffer, "allow_execute ", 14)) |
2120 |
cond = ccs_get_execute_condition(r->ee); |
cond = ccs_get_execute_condition(r->ee); |
2121 |
|
else if (r->obj && r->obj->symlink_target) |
2122 |
|
cond = ccs_get_symlink_condition(r); |
2123 |
else if ((current->ccs_flags & CCS_TASK_IS_EXECUTE_HANDLER)) { |
else if ((current->ccs_flags & CCS_TASK_IS_EXECUTE_HANDLER)) { |
2124 |
char str[] = "if task.type=execute_handler"; |
char str[] = "if task.type=execute_handler"; |
2125 |
cond = ccs_get_condition(str); |
cond = ccs_get_condition(str); |