All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] libsemanage: add semanage_handle_create_with_path
@ 2025-04-11 18:59 Tristan Ross
  2025-04-11 18:59 ` [PATCH 2/2] semodule: add config argument Tristan Ross
  2025-04-15 14:34 ` [PATCH 1/2] libsemanage: add semanage_handle_create_with_path Christian Göttsche
  0 siblings, 2 replies; 17+ messages in thread
From: Tristan Ross @ 2025-04-11 18:59 UTC (permalink / raw)
  To: selinux; +Cc: Tristan Ross

---
 libsemanage/include/semanage/handle.h |  6 +++++-
 libsemanage/src/handle.c              | 26 +++++++++++++++++++-------
 libsemanage/src/libsemanage.map       |  1 +
 3 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/libsemanage/include/semanage/handle.h b/libsemanage/include/semanage/handle.h
index a5ea31de..601cd9ee 100644
--- a/libsemanage/include/semanage/handle.h
+++ b/libsemanage/include/semanage/handle.h
@@ -30,7 +30,11 @@
 struct semanage_handle;
 typedef struct semanage_handle semanage_handle_t;
 
-/* Create and return a semanage handle.
+/* Create and return a semanage handle with a specific config path.
+   The handle is initially in the disconnected state. */
+semanage_handle_t *semanage_handle_create_with_path(const char *conf_name);
+
+/* Create and return a semanage handle with the default config path.
    The handle is initially in the disconnected state. */
 extern semanage_handle_t *semanage_handle_create(void);
 
diff --git a/libsemanage/src/handle.c b/libsemanage/src/handle.c
index faea0606..ca57702a 100644
--- a/libsemanage/src/handle.c
+++ b/libsemanage/src/handle.c
@@ -59,19 +59,14 @@ const char * semanage_root(void)
 	return private_semanage_root;
 }
 
-
-semanage_handle_t *semanage_handle_create(void)
+semanage_handle_t *semanage_handle_create_with_path(const char *conf_name)
 {
 	semanage_handle_t *sh = NULL;
-	char *conf_name = NULL;
 
 	/* Allocate handle */
 	if ((sh = calloc(1, sizeof(semanage_handle_t))) == NULL)
 		goto err;
 
-	if ((conf_name = semanage_conf_path()) == NULL)
-		goto err;
-
 	if ((sh->conf = semanage_conf_parse(conf_name)) == NULL)
 		goto err;
 
@@ -106,13 +101,30 @@ semanage_handle_t *semanage_handle_create(void)
 	sh->msg_callback = semanage_msg_default_handler;
 	sh->msg_callback_arg = NULL;
 
+	return sh;
+
+      err:
+	semanage_handle_destroy(sh);
+	return NULL;
+}
+
+semanage_handle_t *semanage_handle_create(void)
+{
+	semanage_handle_t *sh = NULL;
+	char *conf_name = NULL;
+
+	if ((conf_name = semanage_conf_path()) == NULL)
+		goto err;
+
+	if ((sh = semanage_handle_create_with_path(conf_name)) == NULL)
+		goto err;
+
 	free(conf_name);
 
 	return sh;
 
       err:
 	free(conf_name);
-	semanage_handle_destroy(sh);
 	return NULL;
 }
 
diff --git a/libsemanage/src/libsemanage.map b/libsemanage/src/libsemanage.map
index c8214b26..02c615ac 100644
--- a/libsemanage/src/libsemanage.map
+++ b/libsemanage/src/libsemanage.map
@@ -347,6 +347,7 @@ LIBSEMANAGE_1.1 {
 } LIBSEMANAGE_1.0;
 
 LIBSEMANAGE_3.4 {
+    semanage_handle_create_with_path;
     semanage_module_compute_checksum;
     semanage_set_check_ext_changes;
 } LIBSEMANAGE_1.1;
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2025-05-06 19:33 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-11 18:59 [PATCH 1/2] libsemanage: add semanage_handle_create_with_path Tristan Ross
2025-04-11 18:59 ` [PATCH 2/2] semodule: add config argument Tristan Ross
2025-04-15 14:34 ` [PATCH 1/2] libsemanage: add semanage_handle_create_with_path Christian Göttsche
2025-04-16  4:50   ` Tristan Ross
2025-04-16 15:53     ` James Carter
2025-04-16 19:46     ` Petr Lautrbach
2025-04-17  2:16       ` Tristan Ross
2025-04-17  2:16         ` [PATCH 2/2] semodule: add config argument Tristan Ross
2025-04-18 18:12       ` [PATCH 1/2] libsemanage: add semanage_handle_create_with_path Tristan Ross
2025-04-18 18:12         ` [PATCH 2/2] semodule: add config argument Tristan Ross
2025-04-23 19:03           ` James Carter
2025-04-25 18:06             ` [PATCH 1/2] libsemanage: add semanage_handle_create_with_path Tristan Ross
2025-04-25 18:06               ` [PATCH 2/2] semodule: add config argument Tristan Ross
2025-04-25 18:09             ` [PATCH 1/2] libsemanage: add semanage_handle_create_with_path Tristan Ross
2025-04-25 18:09               ` [PATCH 2/2] semodule: add config argument Tristan Ross
2025-04-29 15:18               ` [PATCH 1/2] libsemanage: add semanage_handle_create_with_path James Carter
2025-05-06 19:33                 ` James Carter

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.