1 |
commit: 91ebad34fdd2900c65166dc14fd583fd6b75cc3a |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Sep 19 06:17:09 2021 +0000 |
4 |
Commit: Sam James <sam <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Sep 19 06:30:29 2021 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=91ebad34 |
7 |
|
8 |
sys-apps/selinux-python: don't import all of setools |
9 |
|
10 |
Bug: https://bugs.gentoo.org/809038 |
11 |
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org> |
12 |
Signed-off-by: Sam James <sam <AT> gentoo.org> |
13 |
|
14 |
.../selinux-python-3.2-optional-networkx.patch | 271 +++++++++++++++++++++ |
15 |
...hon-3.2.ebuild => selinux-python-3.2-r1.ebuild} | 4 + |
16 |
2 files changed, 275 insertions(+) |
17 |
|
18 |
diff --git a/sys-apps/selinux-python/files/selinux-python-3.2-optional-networkx.patch b/sys-apps/selinux-python/files/selinux-python-3.2-optional-networkx.patch |
19 |
new file mode 100644 |
20 |
index 00000000000..a9525ddda93 |
21 |
--- /dev/null |
22 |
+++ b/sys-apps/selinux-python/files/selinux-python-3.2-optional-networkx.patch |
23 |
@@ -0,0 +1,271 @@ |
24 |
+Avoid importing networkx which ends up having a Fortran (and other large) |
25 |
+dependencies. |
26 |
+ |
27 |
+https://bugs.gentoo.org/809038 |
28 |
+https://github.com/SELinuxProject/selinux/commit/ba23ba068364ab11ff51f52bd1e20e3c63798a62 |
29 |
+ |
30 |
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@g.o> |
31 |
+Date: Wed, 25 Aug 2021 11:19:40 +0200 |
32 |
+Subject: [PATCH] python: Import specific modules from setools for less deps |
33 |
+MIME-Version: 1.0 |
34 |
+Content-Type: text/plain; charset=UTF-8 |
35 |
+Content-Transfer-Encoding: 8bit |
36 |
+ |
37 |
+Import the setools classes needed for Python bindings from specific |
38 |
+setools modules in order to reduce the dependency footprint |
39 |
+of the Python bindings. Importing the top-level module causes all |
40 |
+setools modules to be loaded which includes the modules that require |
41 |
+networkx. |
42 |
+ |
43 |
+SELinux packages belong to the group of core system packages on Gentoo |
44 |
+Linux. It is desirable to keep the system set as small as possible, |
45 |
+and the dependency between setools and networkx seems to be the easiest |
46 |
+link to break without major loss of functionality. |
47 |
+ |
48 |
+Signed-off-by: Michał Górny <mgorny@g.o> |
49 |
+--- a/semanage/seobject.py |
50 |
++++ b/semanage/seobject.py |
51 |
+@@ -31,7 +31,8 @@ |
52 |
+ from semanage import * |
53 |
+ PROGNAME = "policycoreutils" |
54 |
+ import sepolicy |
55 |
+-import setools |
56 |
++from setools.policyrep import SELinuxPolicy |
57 |
++from setools.typequery import TypeQuery |
58 |
+ import ipaddress |
59 |
+ |
60 |
+ try: |
61 |
+@@ -1339,7 +1340,7 @@ class ibpkeyRecords(semanageRecords): |
62 |
+ def __init__(self, args = None): |
63 |
+ semanageRecords.__init__(self, args) |
64 |
+ try: |
65 |
+- q = setools.TypeQuery(setools.SELinuxPolicy(sepolicy.get_store_policy(self.store)), attrs=["ibpkey_type"]) |
66 |
++ q = TypeQuery(SELinuxPolicy(sepolicy.get_store_policy(self.store)), attrs=["ibpkey_type"]) |
67 |
+ self.valid_types = sorted(str(t) for t in q.results()) |
68 |
+ except: |
69 |
+ pass |
70 |
+@@ -1599,7 +1600,7 @@ class ibendportRecords(semanageRecords): |
71 |
+ def __init__(self, args = None): |
72 |
+ semanageRecords.__init__(self, args) |
73 |
+ try: |
74 |
+- q = setools.TypeQuery(setools.SELinuxPolicy(sepolicy.get_store_policy(self.store)), attrs=["ibendport_type"]) |
75 |
++ q = TypeQuery(SELinuxPolicy(sepolicy.get_store_policy(self.store)), attrs=["ibendport_type"]) |
76 |
+ self.valid_types = set(str(t) for t in q.results()) |
77 |
+ except: |
78 |
+ pass |
79 |
+--- a/sepolicy/sepolicy/__init__.py |
80 |
++++ b/sepolicy/sepolicy/__init__.py |
81 |
+@@ -4,7 +4,6 @@ |
82 |
+ |
83 |
+ import errno |
84 |
+ import selinux |
85 |
+-import setools |
86 |
+ import glob |
87 |
+ import sepolgen.defaults as defaults |
88 |
+ import sepolgen.interfaces as interfaces |
89 |
+@@ -13,6 +12,17 @@ |
90 |
+ import re |
91 |
+ import gzip |
92 |
+ |
93 |
++from setools.boolquery import BoolQuery |
94 |
++from setools.portconquery import PortconQuery |
95 |
++from setools.policyrep import SELinuxPolicy |
96 |
++from setools.objclassquery import ObjClassQuery |
97 |
++from setools.rbacrulequery import RBACRuleQuery |
98 |
++from setools.rolequery import RoleQuery |
99 |
++from setools.terulequery import TERuleQuery |
100 |
++from setools.typeattrquery import TypeAttributeQuery |
101 |
++from setools.typequery import TypeQuery |
102 |
++from setools.userquery import UserQuery |
103 |
++ |
104 |
+ PROGNAME = "policycoreutils" |
105 |
+ try: |
106 |
+ import gettext |
107 |
+@@ -168,7 +178,7 @@ def policy(policy_file): |
108 |
+ global _pol |
109 |
+ |
110 |
+ try: |
111 |
+- _pol = setools.SELinuxPolicy(policy_file) |
112 |
++ _pol = SELinuxPolicy(policy_file) |
113 |
+ except: |
114 |
+ raise ValueError(_("Failed to read %s policy file") % policy_file) |
115 |
+ |
116 |
+@@ -188,7 +198,7 @@ def info(setype, name=None): |
117 |
+ init_policy() |
118 |
+ |
119 |
+ if setype == TYPE: |
120 |
+- q = setools.TypeQuery(_pol) |
121 |
++ q = TypeQuery(_pol) |
122 |
+ q.name = name |
123 |
+ results = list(q.results()) |
124 |
+ |
125 |
+@@ -206,7 +216,7 @@ def info(setype, name=None): |
126 |
+ } for x in results) |
127 |
+ |
128 |
+ elif setype == ROLE: |
129 |
+- q = setools.RoleQuery(_pol) |
130 |
++ q = RoleQuery(_pol) |
131 |
+ if name: |
132 |
+ q.name = name |
133 |
+ |
134 |
+@@ -217,7 +227,7 @@ def info(setype, name=None): |
135 |
+ } for x in q.results()) |
136 |
+ |
137 |
+ elif setype == ATTRIBUTE: |
138 |
+- q = setools.TypeAttributeQuery(_pol) |
139 |
++ q = TypeAttributeQuery(_pol) |
140 |
+ if name: |
141 |
+ q.name = name |
142 |
+ |
143 |
+@@ -227,7 +237,7 @@ def info(setype, name=None): |
144 |
+ } for x in q.results()) |
145 |
+ |
146 |
+ elif setype == PORT: |
147 |
+- q = setools.PortconQuery(_pol) |
148 |
++ q = PortconQuery(_pol) |
149 |
+ if name: |
150 |
+ ports = [int(i) for i in name.split("-")] |
151 |
+ if len(ports) == 2: |
152 |
+@@ -251,7 +261,7 @@ def info(setype, name=None): |
153 |
+ } for x in q.results()) |
154 |
+ |
155 |
+ elif setype == USER: |
156 |
+- q = setools.UserQuery(_pol) |
157 |
++ q = UserQuery(_pol) |
158 |
+ if name: |
159 |
+ q.name = name |
160 |
+ |
161 |
+@@ -268,7 +278,7 @@ def info(setype, name=None): |
162 |
+ } for x in q.results()) |
163 |
+ |
164 |
+ elif setype == BOOLEAN: |
165 |
+- q = setools.BoolQuery(_pol) |
166 |
++ q = BoolQuery(_pol) |
167 |
+ if name: |
168 |
+ q.name = name |
169 |
+ |
170 |
+@@ -278,7 +288,7 @@ def info(setype, name=None): |
171 |
+ } for x in q.results()) |
172 |
+ |
173 |
+ elif setype == TCLASS: |
174 |
+- q = setools.ObjClassQuery(_pol) |
175 |
++ q = ObjClassQuery(_pol) |
176 |
+ if name: |
177 |
+ q.name = name |
178 |
+ |
179 |
+@@ -372,11 +382,11 @@ def search(types, seinfo=None): |
180 |
+ tertypes.append(DONTAUDIT) |
181 |
+ |
182 |
+ if len(tertypes) > 0: |
183 |
+- q = setools.TERuleQuery(_pol, |
184 |
+- ruletype=tertypes, |
185 |
+- source=source, |
186 |
+- target=target, |
187 |
+- tclass=tclass) |
188 |
++ q = TERuleQuery(_pol, |
189 |
++ ruletype=tertypes, |
190 |
++ source=source, |
191 |
++ target=target, |
192 |
++ tclass=tclass) |
193 |
+ |
194 |
+ if PERMS in seinfo: |
195 |
+ q.perms = seinfo[PERMS] |
196 |
+@@ -385,11 +395,11 @@ def search(types, seinfo=None): |
197 |
+ |
198 |
+ if TRANSITION in types: |
199 |
+ rtypes = ['type_transition', 'type_change', 'type_member'] |
200 |
+- q = setools.TERuleQuery(_pol, |
201 |
+- ruletype=rtypes, |
202 |
+- source=source, |
203 |
+- target=target, |
204 |
+- tclass=tclass) |
205 |
++ q = TERuleQuery(_pol, |
206 |
++ ruletype=rtypes, |
207 |
++ source=source, |
208 |
++ target=target, |
209 |
++ tclass=tclass) |
210 |
+ |
211 |
+ if PERMS in seinfo: |
212 |
+ q.perms = seinfo[PERMS] |
213 |
+@@ -398,11 +408,11 @@ def search(types, seinfo=None): |
214 |
+ |
215 |
+ if ROLE_ALLOW in types: |
216 |
+ ratypes = ['allow'] |
217 |
+- q = setools.RBACRuleQuery(_pol, |
218 |
+- ruletype=ratypes, |
219 |
+- source=source, |
220 |
+- target=target, |
221 |
+- tclass=tclass) |
222 |
++ q = RBACRuleQuery(_pol, |
223 |
++ ruletype=ratypes, |
224 |
++ source=source, |
225 |
++ target=target, |
226 |
++ tclass=tclass) |
227 |
+ |
228 |
+ for r in q.results(): |
229 |
+ toret.append({'source': str(r.source), |
230 |
+@@ -720,11 +730,11 @@ def get_all_entrypoints(): |
231 |
+ |
232 |
+ |
233 |
+ def get_entrypoint_types(setype): |
234 |
+- q = setools.TERuleQuery(_pol, |
235 |
+- ruletype=[ALLOW], |
236 |
+- source=setype, |
237 |
+- tclass=["file"], |
238 |
+- perms=["entrypoint"]) |
239 |
++ q = TERuleQuery(_pol, |
240 |
++ ruletype=[ALLOW], |
241 |
++ source=setype, |
242 |
++ tclass=["file"], |
243 |
++ perms=["entrypoint"]) |
244 |
+ return [str(x.target) for x in q.results() if x.source == setype] |
245 |
+ |
246 |
+ |
247 |
+@@ -739,10 +749,10 @@ def get_init_transtype(path): |
248 |
+ |
249 |
+ |
250 |
+ def get_init_entrypoint(transtype): |
251 |
+- q = setools.TERuleQuery(_pol, |
252 |
+- ruletype=["type_transition"], |
253 |
+- source="init_t", |
254 |
+- tclass=["process"]) |
255 |
++ q = TERuleQuery(_pol, |
256 |
++ ruletype=["type_transition"], |
257 |
++ source="init_t", |
258 |
++ tclass=["process"]) |
259 |
+ entrypoints = [] |
260 |
+ for i in q.results(): |
261 |
+ try: |
262 |
+@@ -754,10 +764,10 @@ def get_init_entrypoint(transtype): |
263 |
+ return entrypoints |
264 |
+ |
265 |
+ def get_init_entrypoints_str(): |
266 |
+- q = setools.TERuleQuery(_pol, |
267 |
+- ruletype=["type_transition"], |
268 |
+- source="init_t", |
269 |
+- tclass=["process"]) |
270 |
++ q = TERuleQuery(_pol, |
271 |
++ ruletype=["type_transition"], |
272 |
++ source="init_t", |
273 |
++ tclass=["process"]) |
274 |
+ entrypoints = {} |
275 |
+ for i in q.results(): |
276 |
+ try: |
277 |
+@@ -837,7 +847,7 @@ def get_all_role_allows(): |
278 |
+ return role_allows |
279 |
+ role_allows = {} |
280 |
+ |
281 |
+- q = setools.RBACRuleQuery(_pol, ruletype=[ALLOW]) |
282 |
++ q = RBACRuleQuery(_pol, ruletype=[ALLOW]) |
283 |
+ for r in q.results(): |
284 |
+ src = str(r.source) |
285 |
+ tgt = str(r.target) |
286 |
+@@ -923,7 +933,7 @@ def get_all_roles(): |
287 |
+ if not _pol: |
288 |
+ init_policy() |
289 |
+ |
290 |
+- q = setools.RoleQuery(_pol) |
291 |
++ q = RoleQuery(_pol) |
292 |
+ roles = [str(x) for x in q.results() if str(x) != "object_r"] |
293 |
+ return roles |
294 |
+ |
295 |
|
296 |
diff --git a/sys-apps/selinux-python/selinux-python-3.2.ebuild b/sys-apps/selinux-python/selinux-python-3.2-r1.ebuild |
297 |
similarity index 98% |
298 |
rename from sys-apps/selinux-python/selinux-python-3.2.ebuild |
299 |
rename to sys-apps/selinux-python/selinux-python-3.2-r1.ebuild |
300 |
index affdd90050d..15b87bbd725 100644 |
301 |
--- a/sys-apps/selinux-python/selinux-python-3.2.ebuild |
302 |
+++ b/sys-apps/selinux-python/selinux-python-3.2-r1.ebuild |
303 |
@@ -39,6 +39,10 @@ BDEPEND=" |
304 |
>=sys-apps/secilc-${PV} |
305 |
)" |
306 |
|
307 |
+PATCHES=( |
308 |
+ "${FILESDIR}"/${PN}-3.2-optional-networkx.patch |
309 |
+) |
310 |
+ |
311 |
src_prepare() { |
312 |
default |
313 |
sed -i 's/-Werror//g' "${S}"/*/Makefile || die "Failed to remove Werror" |