mirror of
https://github.com/SELinuxProject/selinux
synced 2025-01-20 04:20:45 +00:00
libsepol/cil: Make invalid statement error messages consistent
Use a consistent style for the error messages when an invalid statement is found within tunableif, in-statement, block, macro, optional, and booleanif blocks. Signed-off-by: James Carter <jwcart2@gmail.com>
This commit is contained in:
parent
ea34dbf041
commit
ca339eb49d
@ -6095,8 +6095,7 @@ int __cil_build_ast_node_helper(struct cil_tree_node *parse_current, uint32_t *f
|
||||
if (tunif != NULL) {
|
||||
if (parse_current->data == CIL_KEY_TUNABLE) {
|
||||
rc = SEPOL_ERR;
|
||||
cil_tree_log(parse_current, CIL_ERR, "Found tunable");
|
||||
cil_log(CIL_ERR, "Tunables cannot be defined within tunableif statement\n");
|
||||
cil_tree_log(parse_current, CIL_ERR, "%s is not allowed in tunableif", (char *)parse_current->data);
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
@ -6105,8 +6104,7 @@ int __cil_build_ast_node_helper(struct cil_tree_node *parse_current, uint32_t *f
|
||||
if (parse_current->data == CIL_KEY_TUNABLE ||
|
||||
parse_current->data == CIL_KEY_IN) {
|
||||
rc = SEPOL_ERR;
|
||||
cil_tree_log(parse_current, CIL_ERR, "Found in-statement");
|
||||
cil_log(CIL_ERR, "in-statements cannot be defined within in-statements\n");
|
||||
cil_tree_log(parse_current, CIL_ERR, "%s is not allowed in in-statement", (char *)parse_current->data);
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
@ -6119,7 +6117,7 @@ int __cil_build_ast_node_helper(struct cil_tree_node *parse_current, uint32_t *f
|
||||
parse_current->data == CIL_KEY_BLOCKABSTRACT ||
|
||||
parse_current->data == CIL_KEY_MACRO) {
|
||||
rc = SEPOL_ERR;
|
||||
cil_tree_log(parse_current, CIL_ERR, "%s is not allowed in macros", (char *)parse_current->data);
|
||||
cil_tree_log(parse_current, CIL_ERR, "%s is not allowed in macro", (char *)parse_current->data);
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
@ -6131,7 +6129,7 @@ int __cil_build_ast_node_helper(struct cil_tree_node *parse_current, uint32_t *f
|
||||
parse_current->data == CIL_KEY_BLOCKABSTRACT ||
|
||||
parse_current->data == CIL_KEY_MACRO) {
|
||||
rc = SEPOL_ERR;
|
||||
cil_tree_log(parse_current, CIL_ERR, "%s is not allowed in optionals", (char *)parse_current->data);
|
||||
cil_tree_log(parse_current, CIL_ERR, "%s is not allowed in optional", (char *)parse_current->data);
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
@ -6148,13 +6146,10 @@ int __cil_build_ast_node_helper(struct cil_tree_node *parse_current, uint32_t *f
|
||||
parse_current->data != CIL_KEY_TYPECHANGE &&
|
||||
parse_current->data != CIL_KEY_TYPEMEMBER) {
|
||||
rc = SEPOL_ERR;
|
||||
cil_tree_log(parse_current, CIL_ERR, "Found %s", (char*)parse_current->data);
|
||||
if (((struct cil_booleanif*)boolif->data)->preserved_tunable) {
|
||||
cil_log(CIL_ERR, "%s cannot be defined within tunableif statement (treated as a booleanif due to preserve-tunables)\n",
|
||||
(char*)parse_current->data);
|
||||
cil_tree_log(parse_current, CIL_ERR, "%s is not allowed in tunableif being treated as a booleanif", (char *)parse_current->data);
|
||||
} else {
|
||||
cil_log(CIL_ERR, "%s cannot be defined within booleanif statement\n",
|
||||
(char*)parse_current->data);
|
||||
cil_tree_log(parse_current, CIL_ERR, "%s is not allowed in booleanif", (char *)parse_current->data);
|
||||
}
|
||||
goto exit;
|
||||
}
|
||||
|
@ -3789,7 +3789,7 @@ int __cil_resolve_ast_node_helper(struct cil_tree_node *node, uint32_t *finished
|
||||
if (block != NULL) {
|
||||
if (node->flavor == CIL_CAT ||
|
||||
node->flavor == CIL_SENS) {
|
||||
cil_tree_log(node, CIL_ERR, "%s statement is not allowed in blocks", cil_node_to_string(node));
|
||||
cil_tree_log(node, CIL_ERR, "%s is not allowed in block", cil_node_to_string(node));
|
||||
rc = SEPOL_ERR;
|
||||
goto exit;
|
||||
}
|
||||
@ -3802,7 +3802,7 @@ int __cil_resolve_ast_node_helper(struct cil_tree_node *node, uint32_t *finished
|
||||
node->flavor == CIL_BLOCKINHERIT ||
|
||||
node->flavor == CIL_BLOCKABSTRACT ||
|
||||
node->flavor == CIL_MACRO) {
|
||||
cil_tree_log(node, CIL_ERR, "%s statement is not allowed in macros", cil_node_to_string(node));
|
||||
cil_tree_log(node, CIL_ERR, "%s is not allowed in macro", cil_node_to_string(node));
|
||||
rc = SEPOL_ERR;
|
||||
goto exit;
|
||||
}
|
||||
@ -3814,7 +3814,7 @@ int __cil_resolve_ast_node_helper(struct cil_tree_node *node, uint32_t *finished
|
||||
node->flavor == CIL_BLOCK ||
|
||||
node->flavor == CIL_BLOCKABSTRACT ||
|
||||
node->flavor == CIL_MACRO) {
|
||||
cil_tree_log(node, CIL_ERR, "%s statement is not allowed in optionals", cil_node_to_string(node));
|
||||
cil_tree_log(node, CIL_ERR, "%s is not allowed in optional", cil_node_to_string(node));
|
||||
rc = SEPOL_ERR;
|
||||
goto exit;
|
||||
}
|
||||
@ -3836,9 +3836,9 @@ int __cil_resolve_ast_node_helper(struct cil_tree_node *node, uint32_t *finished
|
||||
}
|
||||
if (rc == SEPOL_ERR) {
|
||||
if (((struct cil_booleanif*)boolif->data)->preserved_tunable) {
|
||||
cil_tree_log(node, CIL_ERR, "%s statement is not allowed in booleanifs (tunableif treated as a booleanif)", cil_node_to_string(node));
|
||||
cil_tree_log(node, CIL_ERR, "%s is not allowed in tunableif being treated as a booleanif", cil_node_to_string(node));
|
||||
} else {
|
||||
cil_tree_log(node, CIL_ERR, "%s statement is not allowed in booleanifs", cil_node_to_string(node));
|
||||
cil_tree_log(node, CIL_ERR, "%s is not allowed in booleanif", cil_node_to_string(node));
|
||||
}
|
||||
goto exit;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user