57 lines
1.6 KiB
Diff
57 lines
1.6 KiB
Diff
From 3459dfd92e466f72442dbeb34d1f235bbbe52cc0 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= <cgzones@googlemail.com>
|
|
Date: Thu, 3 Aug 2023 17:59:43 +0200
|
|
Subject: [PATCH] libselinux/utils: update selabel_partial_match
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
Print usage information and exit if required path option is not given
|
|
or superfluous arguments are given.
|
|
|
|
Constify read-only variables assigned command line arguments.
|
|
|
|
Simplify bool evaluation.
|
|
|
|
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
|
|
Acked-by: James Carter <jwcart2@gmail.com>
|
|
---
|
|
libselinux/utils/selabel_partial_match.c | 7 +++++--
|
|
1 file changed, 5 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/utils/selabel_partial_match.c b/utils/selabel_partial_match.c
|
|
index 7bbd5777..0df2627a 100644
|
|
--- a/utils/selabel_partial_match.c
|
|
+++ b/utils/selabel_partial_match.c
|
|
@@ -28,7 +28,7 @@ int main(int argc, char **argv)
|
|
{
|
|
int opt;
|
|
bool partial_match;
|
|
- char *validate = NULL, *path = NULL, *file = NULL;
|
|
+ const char *validate = NULL, *path = NULL, *file = NULL;
|
|
|
|
struct selabel_handle *hnd;
|
|
struct selinux_opt selabel_option[] = {
|
|
@@ -55,6 +55,9 @@ int main(int argc, char **argv)
|
|
}
|
|
}
|
|
|
|
+ if (!path || optind != argc)
|
|
+ usage(argv[0]);
|
|
+
|
|
selabel_option[0].value = file;
|
|
selabel_option[1].value = validate;
|
|
|
|
@@ -69,7 +72,7 @@ int main(int argc, char **argv)
|
|
partial_match = selabel_partial_match(hnd, path);
|
|
|
|
printf("Match or Partial match: %s\n",
|
|
- partial_match == 1 ? "TRUE" : "FALSE");
|
|
+ partial_match ? "TRUE" : "FALSE");
|
|
|
|
selabel_close(hnd);
|
|
return partial_match;
|
|
--
|
|
2.27.0
|
|
|