libselinux/0016-libselinux-support-objname-in-compute_create.patch

51 lines
1.5 KiB
Diff
Raw Normal View History

From fa5b0504d861f569c6c97ab32719cc4a8dca0cd4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= <cgzones@googlemail.com>
Date: Tue, 30 Aug 2022 19:54:55 +0200
Subject: [PATCH] libselinux: support objname in compute_create
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Content-type: text/plain
Support passing an optional object name to compute_create for name
based type transitions.
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Acked-by: James Carter <jwcart2@gmail.com>
---
libselinux/utils/compute_create.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/libselinux/utils/compute_create.c b/libselinux/utils/compute_create.c
index c6481f4b01c1..5401fe967a53 100644
--- a/libselinux/utils/compute_create.c
+++ b/libselinux/utils/compute_create.c
@@ -10,10 +10,11 @@ int main(int argc, char **argv)
{
char *buf;
security_class_t tclass;
+ const char *objname;
int ret;
- if (argc != 4) {
- fprintf(stderr, "usage: %s scontext tcontext tclass\n",
+ if (argc != 4 && argc != 5) {
+ fprintf(stderr, "usage: %s scontext tcontext tclass [objname]\n",
argv[0]);
exit(1);
}
@@ -34,7 +35,9 @@ int main(int argc, char **argv)
exit(2);
}
- ret = security_compute_create(argv[1], argv[2], tclass, &buf);
+ objname = (argc == 5) ? argv[4] : NULL;
+
+ ret = security_compute_create_name(argv[1], argv[2], tclass, objname, &buf);
if (ret < 0) {
fprintf(stderr, "%s: security_compute_create failed: %s\n",
argv[0], strerror(errno));
--
2.38.1