From fdc974f5da4dd94dce7df1408b8cb4d62256e10f Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sat, 27 May 2006 04:53:11 +0000 Subject: Remove dependence on a patched version of libselinux for bug #122517. svn path=/main/trunk/; revision=3430 --- pym/portage.py | 8 ++++---- pym/portage_selinux.py | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 pym/portage_selinux.py diff --git a/pym/portage.py b/pym/portage.py index e6834be43..c930816d9 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -115,7 +115,7 @@ except ImportError, e: try: - import selinux + import portage_selinux as selinux except OSError, e: writemsg("!!! SELinux not loaded: %s\n" % str(e), noiselevel=-1) del e @@ -1811,10 +1811,10 @@ class config: self._selinux_enabled = 0 if "selinux" in self["USE"].split(): if "selinux" in globals(): - if hasattr(selinux, "enabled"): - self._selinux_enabled = selinux.enabled - else: + if selinux.is_selinux_enabled() == 1: self._selinux_enabled = 1 + else: + self._selinux_enabled = 0 else: writemsg("!!! SELinux module not found. Please verify that it was installed.\n", noiselevel=-1) diff --git a/pym/portage_selinux.py b/pym/portage_selinux.py new file mode 100644 index 000000000..4cc265a52 --- /dev/null +++ b/pym/portage_selinux.py @@ -0,0 +1,17 @@ +# Copyright 1999-2006 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +import selinux +from selinux import is_selinux_enabled +from selinux_aux import setexec, secure_symlink, secure_rename, \ + secure_copy, secure_mkdir + +def getcontext(): + return selinux.getcon()[1] + +def get_sid(filename): + return selinux.getfilecon(filename)[1] + +def get_lsid(filename): + return selinux.lgetfilecon(filename)[1] -- cgit v1.2.3-1-g7c22