summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Palimaka <kensington@gentoo.org>2016-01-12 22:51:31 +1100
committerMichael Palimaka <kensington@gentoo.org>2016-01-13 03:10:51 +1100
commit8748202605d13dd9f9d7111955cabd1cea1d1bde (patch)
treee57d5a97c5a34b8123d5bb297f1e1074b2caf1d9 /sys-apps/apparmor-utils
parentsys-apps/apparmor-utils: Bump to 2.10 (diff)
downloadgentoo-8748202605d13dd9f9d7111955cabd1cea1d1bde.tar.gz
gentoo-8748202605d13dd9f9d7111955cabd1cea1d1bde.tar.bz2
gentoo-8748202605d13dd9f9d7111955cabd1cea1d1bde.zip
sys-apps/apparmor-utils: fix python handling
Diffstat (limited to 'sys-apps/apparmor-utils')
-rw-r--r--sys-apps/apparmor-utils/apparmor-utils-2.10.ebuild14
-rw-r--r--sys-apps/apparmor-utils/files/apparmor-utils-2.10-python2.patch132
-rw-r--r--sys-apps/apparmor-utils/files/apparmor-utils-2.10-shebang.patch16
3 files changed, 158 insertions, 4 deletions
diff --git a/sys-apps/apparmor-utils/apparmor-utils-2.10.ebuild b/sys-apps/apparmor-utils/apparmor-utils-2.10.ebuild
index 4dbe8b1dac19..a034f035520a 100644
--- a/sys-apps/apparmor-utils/apparmor-utils-2.10.ebuild
+++ b/sys-apps/apparmor-utils/apparmor-utils-2.10.ebuild
@@ -2,9 +2,9 @@
# Distributed under the terms of the GNU General Public License v2
# $Id$
-EAPI=5
-PYTHON_COMPAT=( python2_7 )
+EAPI=6
+PYTHON_COMPAT=( python{2_7,3_4} )
inherit perl-module python-r1 versionator
DESCRIPTION="Additional userspace utils to assist with AppArmor profile management"
@@ -29,8 +29,13 @@ RDEPEND="${DEPEND}
S=${WORKDIR}/apparmor-${PV}/utils
+PATCHES=(
+ "${FILESDIR}/${PN}-2.10-python2.patch"
+ "${FILESDIR}/${PN}-2.10-shebang.patch"
+)
+
src_compile() {
- python_export_best
+ python_setup
# launches non-make subprocesses causing "make jobserver unavailable"
# error messages to appear in generated code
@@ -48,5 +53,6 @@ src_install() {
}
python_foreach_impl install_python
- python_replicate_script "${D}"/usr/bin/aa-easyprof
+ python_replicate_script "${D}"/usr/bin/aa-easyprof "${D}"/usr/sbin/apparmor_status \
+ "${D}"/usr/sbin/aa-{audit,autodep,cleanprof,complain,disable,enforce,genprof,logprof,mergeprof,status,unconfined}
}
diff --git a/sys-apps/apparmor-utils/files/apparmor-utils-2.10-python2.patch b/sys-apps/apparmor-utils/files/apparmor-utils-2.10-python2.patch
new file mode 100644
index 000000000000..412c13c2262f
--- /dev/null
+++ b/sys-apps/apparmor-utils/files/apparmor-utils-2.10-python2.patch
@@ -0,0 +1,132 @@
+Backport from upstream fixing runtime failure with python-2.
+
+https://bugs.launchpad.net/apparmor/+bug/1513880
+
+--- a/apparmor/common.py
++++ b/apparmor/common.py
+@@ -245,6 +245,15 @@
+ return False
+ return True
+
++def type_is_str(var):
++ ''' returns True if the given variable is a str (or unicode string when using python 2)'''
++ if type(var) == str:
++ return True
++ elif sys.version_info[0] < 3 and type(var) == unicode: # python 2 sometimes uses the 'unicode' type
++ return True
++ else:
++ return False
++
+ class DebugLogger(object):
+ def __init__(self, module_name=__name__):
+ self.debugging = False
+
+--- a/apparmor/rule/capability.py
++++ b/apparmor/rule/capability.py
+@@ -14,7 +14,7 @@
+ # ----------------------------------------------------------------------
+
+ from apparmor.regex import RE_PROFILE_CAP
+-from apparmor.common import AppArmorBug, AppArmorException
++from apparmor.common import AppArmorBug, AppArmorException, type_is_str
+ from apparmor.rule import BaseRule, BaseRuleset, parse_modifiers
+ import re
+
+@@ -47,7 +47,7 @@
+ self.all_caps = True
+ self.capability = set()
+ else:
+- if type(cap_list) == str:
++ if type_is_str(cap_list):
+ self.capability = {cap_list}
+ elif type(cap_list) == list and len(cap_list) > 0:
+ self.capability = set(cap_list)
+
+--- a/apparmor/rule/change_profile.py
++++ b/apparmor/rule/change_profile.py
+@@ -14,7 +14,7 @@
+ # ----------------------------------------------------------------------
+
+ from apparmor.regex import RE_PROFILE_CHANGE_PROFILE, strip_quotes
+-from apparmor.common import AppArmorBug, AppArmorException
++from apparmor.common import AppArmorBug, AppArmorException, type_is_str
+ from apparmor.rule import BaseRule, BaseRuleset, parse_modifiers, quote_if_needed
+
+ # setup module translations
+@@ -48,7 +48,7 @@
+ self.all_execconds = False
+ if execcond == ChangeProfileRule.ALL:
+ self.all_execconds = True
+- elif type(execcond) == str:
++ elif type_is_str(execcond):
+ if not execcond.strip():
+ raise AppArmorBug('Empty exec condition in change_profile rule')
+ elif execcond.startswith('/') or execcond.startswith('@'):
+@@ -62,7 +62,7 @@
+ self.all_targetprofiles = False
+ if targetprofile == ChangeProfileRule.ALL:
+ self.all_targetprofiles = True
+- elif type(targetprofile) == str:
++ elif type_is_str(targetprofile):
+ if targetprofile.strip():
+ self.targetprofile = targetprofile
+ else:
+
+--- a/apparmor/rule/network.py
++++ b/apparmor/rule/network.py
+@@ -16,7 +16,7 @@
+ import re
+
+ from apparmor.regex import RE_PROFILE_NETWORK
+-from apparmor.common import AppArmorBug, AppArmorException
++from apparmor.common import AppArmorBug, AppArmorException, type_is_str
+ from apparmor.rule import BaseRule, BaseRuleset, parse_modifiers
+
+ # setup module translations
+@@ -66,7 +66,7 @@
+ self.all_domains = False
+ if domain == NetworkRule.ALL:
+ self.all_domains = True
+- elif type(domain) == str:
++ elif type_is_str(domain):
+ if domain in network_domain_keywords:
+ self.domain = domain
+ else:
+@@ -78,7 +78,7 @@
+ self.all_type_or_protocols = False
+ if type_or_protocol == NetworkRule.ALL:
+ self.all_type_or_protocols = True
+- elif type(type_or_protocol) == str:
++ elif type_is_str(type_or_protocol):
+ if type_or_protocol in network_protocol_keywords:
+ self.type_or_protocol = type_or_protocol
+ elif type_or_protocol in network_type_keywords:
+
+--- a/apparmor/rule/rlimit.py
++++ b/apparmor/rule/rlimit.py
+@@ -16,7 +16,7 @@
+ import re
+
+ from apparmor.regex import RE_PROFILE_RLIMIT, strip_quotes
+-from apparmor.common import AppArmorBug, AppArmorException
++from apparmor.common import AppArmorBug, AppArmorException, type_is_str
+ from apparmor.rule import BaseRule, BaseRuleset, parse_comment, quote_if_needed
+
+ # setup module translations
+@@ -57,7 +57,7 @@
+ if audit or deny or allow_keyword:
+ raise AppArmorBug('The audit, allow or deny keywords are not allowed in rlimit rules.')
+
+- if type(rlimit) == str:
++ if type_is_str(rlimit):
+ if rlimit in rlimit_all:
+ self.rlimit = rlimit
+ else:
+@@ -70,7 +70,7 @@
+ self.all_values = False
+ if value == RlimitRule.ALL:
+ self.all_values = True
+- elif type(value) == str:
++ elif type_is_str(value):
+ if not value.strip():
+ raise AppArmorBug('Empty value in rlimit rule')
diff --git a/sys-apps/apparmor-utils/files/apparmor-utils-2.10-shebang.patch b/sys-apps/apparmor-utils/files/apparmor-utils-2.10-shebang.patch
new file mode 100644
index 000000000000..19b8892ee314
--- /dev/null
+++ b/sys-apps/apparmor-utils/files/apparmor-utils-2.10-shebang.patch
@@ -0,0 +1,16 @@
+Avoid rewriting the shebang.
+
+The ebuild will take care of this when replicating the script for each of the
+supported python implementations.
+
+--- a/python-tools-setup.py
++++ b/python-tools-setup.py
+@@ -43,7 +43,7 @@
+ f = prefix + s
+ # If we have a defined python version, use it instead of the system
+ # default
+- if 'PYTHON' in os.environ:
++ if False:
+ lines = open(os.path.basename(s)).readlines()
+ lines[0] = '#! /usr/bin/env %s\n' % os.environ['PYTHON']
+ open(f, 'w').write("".join(lines))