All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Carter <jwcart2@gmail.com>
To: selinux@vger.kernel.org
Cc: cgzones@googlemail.com, James Carter <jwcart2@gmail.com>
Subject: [PATCH 13/16] libsepol: Make return value clearer when reporting neverallowx errors
Date: Fri, 17 Dec 2021 13:19:10 -0500	[thread overview]
Message-ID: <20211217181913.336360-14-jwcart2@gmail.com> (raw)
In-Reply-To: <20211217181913.336360-1-jwcart2@gmail.com>

The value returned from report_assertion_extended_permissions() is
the nubmer of errors, so call it that instead of ret.

Signed-off-by: James Carter <jwcart2@gmail.com>
---
 libsepol/src/assertion.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/libsepol/src/assertion.c b/libsepol/src/assertion.c
index 0bd620a7..b8fe8b21 100644
--- a/libsepol/src/assertion.c
+++ b/libsepol/src/assertion.c
@@ -148,8 +148,8 @@ static int report_assertion_extended_permissions(sepol_handle_t *handle,
 	ebitmap_t *tattr = &p->type_attr_map[ttype];
 	ebitmap_node_t *snode, *tnode;
 	unsigned int i, j;
-	int rc = 1;
-	int ret = 0;
+	int rc;
+	int errors = 0;
 
 	memcpy(&tmp_key, k, sizeof(avtab_key_t));
 	tmp_key.specified = AVTAB_XPERMS_ALLOWED;
@@ -178,15 +178,14 @@ static int report_assertion_extended_permissions(sepol_handle_t *handle,
 							p->p_class_val_to_name[curperm->tclass - 1],
 							sepol_extended_perms_to_string(&error));
 
-					rc = 0;
-					ret++;
+					errors++;
 				}
 			}
 		}
 	}
 
 	/* failure on the regular permissions */
-	if (rc) {
+	if (!errors) {
 		ERR(handle, "neverallowxperm on line %lu of %s (or line %lu of policy.conf) violated by\n"
 				"allow %s %s:%s {%s };",
 				avrule->source_line, avrule->source_filename, avrule->line,
@@ -194,11 +193,11 @@ static int report_assertion_extended_permissions(sepol_handle_t *handle,
 				p->p_type_val_to_name[ttype],
 				p->p_class_val_to_name[curperm->tclass - 1],
 				sepol_av_to_string(p, curperm->tclass, perms));
-		ret++;
+		errors++;
 
 	}
 
-	return ret;
+	return errors;
 }
 
 static int report_assertion_avtab_matches(avtab_key_t *k, avtab_datum_t *d, void *args)
-- 
2.31.1


  parent reply	other threads:[~2021-12-17 18:19 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-17 18:18 [PATCH 00/16] Refactor and fix assertion checking James Carter
2021-12-17 18:18 ` [PATCH 01/16] libsepol: Return an error if check_assertion() returns an error James Carter
2021-12-17 18:18 ` [PATCH 02/16] libsepol: Change label in check_assertion_avtab_match() James Carter
2021-12-17 18:19 ` [PATCH 03/16] libsepol: Remove uneeded error messages in assertion checking James Carter
2021-12-17 18:19 ` [PATCH 04/16] libsepol: Check for error from check_assertion_extended_permissions() James Carter
2021-12-17 18:19 ` [PATCH 05/16] libsepol: Use consistent return checking style James Carter
2021-12-17 18:19 ` [PATCH 06/16] libsepol: Move check of target types to before check for self James Carter
2021-12-17 18:19 ` [PATCH 07/16] libsepol: Create function check_assertion_self_match() and use it James Carter
2021-12-17 18:19 ` [PATCH 08/16] libsepol: Use (rc < 0) instead of (rc) when calling ebitmap functions James Carter
2021-12-17 18:19 ` [PATCH 09/16] libsepol: Remove unnessesary check for matching class James Carter
2021-12-17 18:19 ` [PATCH 10/16] libsepol: Move assigning outer loop index out of inner loop James Carter
2021-12-17 18:19 ` [PATCH 11/16] libsepol: Make use of previously created ebitmap when checking self James Carter
2021-12-17 18:19 ` [PATCH 12/16] libsepol: Refactor match_any_class_permissions() to be clearer James Carter
2021-12-17 18:19 ` James Carter [this message]
2021-12-17 18:19 ` [PATCH 14/16] libsepol: The src and tgt must be the same if neverallow uses self James Carter
2021-12-17 18:19 ` [PATCH 15/16] libsepol: Set args avtab pointer when reporting assertion violations James Carter
2021-12-17 18:19 ` [PATCH 16/16] libsepol: Fix two problems with neverallowxperm reporting James Carter
2021-12-17 18:22 ` [PATCH 00/16] Refactor and fix assertion checking James Carter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211217181913.336360-14-jwcart2@gmail.com \
    --to=jwcart2@gmail.com \
    --cc=cgzones@googlemail.com \
    --cc=selinux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.