Rebase on upstream commit 32611aea6543 See $ cd SELinuxProject/selinux $ git log --pretty=oneline libsepol-3.2..32611aea6543 -- libsepol
121 lines
5.7 KiB
Diff
121 lines
5.7 KiB
Diff
From ca339eb49da6fe5b191de5c3ee7196453fa14e23 Mon Sep 17 00:00:00 2001
|
|
From: James Carter <jwcart2@gmail.com>
|
|
Date: Tue, 30 Mar 2021 13:40:01 -0400
|
|
Subject: [PATCH] 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>
|
|
---
|
|
libsepol/cil/src/cil_build_ast.c | 17 ++++++-----------
|
|
libsepol/cil/src/cil_resolve_ast.c | 10 +++++-----
|
|
2 files changed, 11 insertions(+), 16 deletions(-)
|
|
|
|
diff --git a/libsepol/cil/src/cil_build_ast.c b/libsepol/cil/src/cil_build_ast.c
|
|
index 3f83c228fec1..5b1e28246b2e 100644
|
|
--- a/libsepol/cil/src/cil_build_ast.c
|
|
+++ b/libsepol/cil/src/cil_build_ast.c
|
|
@@ -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;
|
|
}
|
|
diff --git a/libsepol/cil/src/cil_resolve_ast.c b/libsepol/cil/src/cil_resolve_ast.c
|
|
index 7229a3b4e990..872b6799b0bf 100644
|
|
--- a/libsepol/cil/src/cil_resolve_ast.c
|
|
+++ b/libsepol/cil/src/cil_resolve_ast.c
|
|
@@ -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;
|
|
}
|
|
--
|
|
2.32.0
|
|
|