[Reproducible-commits] [dpkg] 14/40: dpkg: Simplify sehandle handling

Jérémy Bobbio lunar at moszumanska.debian.org
Sat May 30 09:52:47 UTC 2015


This is an automated email from the git hooks/post-receive script.

lunar pushed a commit to branch pu/reproducible_builds
in repository dpkg.

commit b24e5502d6963a1efe0940b31ae6ffc0c9ac6584
Author: Guillem Jover <guillem at debian.org>
Date:   Wed May 27 20:56:56 2015 +0200

    dpkg: Simplify sehandle handling
    
    Remove pointless dpkg_selabel_get_handle() function, rename
    dpkg_sehandle to sehandle, and change dpkg_selabel_set_context() to
    access the variable directly.
---
 src/selinux.c | 22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)

diff --git a/src/selinux.c b/src/selinux.c
index b582b14..4d020b1 100644
--- a/src/selinux.c
+++ b/src/selinux.c
@@ -40,13 +40,7 @@
 #include "main.h"
 
 #ifdef WITH_SELINUX
-static struct selabel_handle *dpkg_sehandle;
-
-static struct selabel_handle *
-dpkg_selabel_get_handle(void)
-{
-	return dpkg_sehandle;
-}
+static struct selabel_handle *sehandle;
 #endif
 
 void
@@ -75,14 +69,14 @@ dpkg_selabel_load(void)
 	} else if (selinux_enabled && selinux_status_updated()) {
 		/* The SELinux policy got updated in the kernel, usually after
 		 * upgrading the package shipping it, we need to reload. */
-		selabel_close(dpkg_sehandle);
+		selabel_close(sehandle);
 	} else {
 		/* SELinux is either disabled or it does not need a reload. */
 		return;
 	}
 
-	dpkg_sehandle = selabel_open(SELABEL_CTX_FILE, NULL, 0);
-	if (dpkg_sehandle == NULL)
+	sehandle = selabel_open(SELABEL_CTX_FILE, NULL, 0);
+	if (sehandle == NULL)
 		ohshite(_("cannot get security labeling handle"));
 #endif
 }
@@ -91,12 +85,10 @@ void
 dpkg_selabel_set_context(const char *matchpath, const char *path, mode_t mode)
 {
 #ifdef WITH_SELINUX
-	struct selabel_handle *sehandle;
 	security_context_t scontext = NULL;
 	int ret;
 
 	/* If SELinux is not enabled just do nothing. */
-	sehandle = dpkg_selabel_get_handle();
 	if (sehandle == NULL)
 		return;
 
@@ -125,11 +117,11 @@ void
 dpkg_selabel_close(void)
 {
 #ifdef WITH_SELINUX
-	if (dpkg_sehandle == NULL)
+	if (sehandle == NULL)
 		return;
 
 	selinux_status_close();
-	selabel_close(dpkg_sehandle);
-	dpkg_sehandle = NULL;
+	selabel_close(sehandle);
+	sehandle = NULL;
 #endif
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/dpkg.git



More information about the Reproducible-commits mailing list