Gentoo Archives: gentoo-commits

From: Sven Vermeulen <sven.vermeulen@××××××.be>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/hardened-dev:master commit in: sys-apps/policycoreutils/files/, sys-apps/policycoreutils/
Date: Wed, 13 Jul 2011 21:57:52
Message-Id: 1e5751d8b256df635ba6f1e489732f11cb729e12.SwifT@gentoo
1 commit: 1e5751d8b256df635ba6f1e489732f11cb729e12
2 Author: Sven Vermeulen <sven.vermeulen <AT> siphos <DOT> be>
3 AuthorDate: Wed Jul 13 21:50:06 2011 +0000
4 Commit: Sven Vermeulen <sven.vermeulen <AT> siphos <DOT> be>
5 CommitDate: Wed Jul 13 21:50:06 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/hardened-dev.git;a=commit;h=1e5751d8
7
8 Bump policycoreutils to 2.0.85
9
10 ---
11 sys-apps/policycoreutils/ChangeLog | 437 ++++++++
12 ...policycoreutils-2.0.85-fix-seunshare-vuln.patch | 1084 ++++++++++++++++++++
13 .../files/policycoreutils-2.0.85-python3.tar.gz | Bin 0 -> 19750 bytes
14 .../files/policycoreutils-2.0.85-sesandbox.patch | 387 +++++++
15 sys-apps/policycoreutils/metadata.xml | 17 +
16 .../policycoreutils/policycoreutils-2.0.85.ebuild | 116 +++
17 6 files changed, 2041 insertions(+), 0 deletions(-)
18
19 diff --git a/sys-apps/policycoreutils/ChangeLog b/sys-apps/policycoreutils/ChangeLog
20 new file mode 100644
21 index 0000000..7888b40
22 --- /dev/null
23 +++ b/sys-apps/policycoreutils/ChangeLog
24 @@ -0,0 +1,437 @@
25 +# ChangeLog for sys-apps/policycoreutils
26 +# Copyright 1999-2011 Gentoo Foundation; Distributed under the GPL v2
27 +# $Header: /var/cvsroot/gentoo-x86/sys-apps/policycoreutils/ChangeLog,v 1.86 2011/07/08 10:54:27 ssuominen Exp $
28 +
29 + 13 Jul 2011; <swift@g.o> +policycoreutils-2.0.85.ebuild,
30 + +files/policycoreutils-2.0.85-fix-seunshare-vuln.patch,
31 + +files/policycoreutils-2.0.85-python3.tar.gz,
32 + +files/policycoreutils-2.0.85-sesandbox.patch, +metadata.xml:
33 + Add fix for bug #374897 and initial support for python3
34 +
35 +*policycoreutils-2.0.85 (12 Jul 2011)
36 +
37 + 12 Jul 2011; <swift@g.o> +files/policycoreutils-2.0.69-setfiles.diff,
38 + +policycoreutils-2.0.85.ebuild, +metadata.xml:
39 + Bump to 2.0.85
40 +
41 + 08 Jul 2011; Samuli Suominen <ssuominen@g.o>
42 + policycoreutils-2.0.55.ebuild, policycoreutils-2.0.69.ebuild,
43 + policycoreutils-2.0.69-r1.ebuild, policycoreutils-2.0.69-r2.ebuild:
44 + Convert from "useq" to "use".
45 +
46 +*policycoreutils-2.0.82-r1 (30 Jun 2011)
47 +
48 + 30 Jun 2011; Anthony G. Basile <blueness@g.o>
49 + +policycoreutils-2.0.82-r1.ebuild:
50 + Overwrite invalid .po files with valid ones, fixes bug #372807
51 +
52 + 16 Jun 2011; Anthony G. Basile <blueness@g.o>
53 + policycoreutils-2.0.82.ebuild:
54 + Drop use_nls dependency on gettext. Its mandatory. See bug #299681.
55 + Also put gettext in COMMON_DEPS, it is more than a RDEPEND.
56 +
57 + 28 May 2011; Anthony G. Basile <blueness@g.o>
58 + policycoreutils-2.0.82.ebuild:
59 + Stable amd64 x86
60 +
61 + 16 Apr 2011; Anthony G. Basile <blueness@g.o> metadata.xml:
62 + Updated metadata info.
63 +
64 + 08 Feb 2011; Arfrever Frehtes Taifersar Arahesis <arfrever@g.o>
65 + policycoreutils-2.0.82.ebuild:
66 + Set SUPPORT_PYTHON_ABIS (bug #353762). Fix dependencies. Fix installation
67 + with FEATURES="multilib-strict".
68 +
69 +*policycoreutils-2.0.82 (05 Feb 2011)
70 +
71 + 05 Feb 2011; Anthony G. Basile <blueness@g.o>
72 + +policycoreutils-2.0.82.ebuild:
73 + New upstream release.
74 +
75 +*policycoreutils-2.0.69-r2 (05 Feb 2011)
76 +
77 + 05 Feb 2011; Anthony G. Basile <blueness@g.o>
78 + +policycoreutils-2.0.69-r2.ebuild,
79 + +files/policycoreutils-2.0.69-setfiles.diff:
80 + Fixed bug #300613
81 +
82 + 04 Apr 2010; Arfrever Frehtes Taifersar Arahesis <arfrever@g.o>
83 + policycoreutils-2.0.55.ebuild, policycoreutils-2.0.69.ebuild,
84 + policycoreutils-2.0.69-r1.ebuild:
85 + Delete calls to deprecated python_version().
86 +
87 +*policycoreutils-2.0.69-r1 (20 Sep 2009)
88 +
89 + 20 Sep 2009; Chris PeBenito <pebenito@g.o>
90 + +policycoreutils-2.0.69-r1.ebuild:
91 + Update rlpkg for ext4 and btrfs.
92 +
93 + 14 Sep 2009; Chris PeBenito <pebenito@g.o>
94 + policycoreutils-2.0.69.ebuild:
95 + Fix libsemanage DEP.
96 +
97 + 02 Aug 2009; Chris PeBenito <pebenito@g.o>
98 + policycoreutils-2.0.55.ebuild, policycoreutils-2.0.69.ebuild:
99 + Add python_need_rebuild.
100 +
101 +*policycoreutils-2.0.69 (02 Aug 2009)
102 +
103 + 02 Aug 2009; Chris PeBenito <pebenito@g.o>
104 + +policycoreutils-2.0.69.ebuild:
105 + New upstream release.
106 +
107 + 18 Jul 2009; Chris PeBenito <pebenito@g.o>
108 + -policycoreutils-1.34.15.ebuild, policycoreutils-2.0.55.ebuild:
109 + Mark stable. Remove old ebuilds.
110 +
111 +*policycoreutils-2.0.55 (03 Oct 2008)
112 +
113 + 03 Oct 2008; Chris PeBenito <pebenito@g.o>
114 + +policycoreutils-2.0.55.ebuild:
115 + Initial commit of policycoreutils 2.0.
116 +
117 + 29 May 2008; Ali Polatel <hawking@g.o>
118 + policycoreutils-1.34.15.ebuild:
119 + python_mod_optimize is ROOT aware. Fixed python_mod_cleanup.
120 +
121 + 26 May 2008; Chris PeBenito <pebenito@g.o>
122 + policycoreutils-1.34.15.ebuild:
123 + Fix libsemanage dependency.
124 +
125 + 13 May 2008; Chris PeBenito <pebenito@g.o>
126 + -files/policycoreutils-1.28-quietlp.diff,
127 + -files/policycoreutils-1.32-quietlp.diff,
128 + -files/policycoreutils-unsigned-char-ppc.diff,
129 + -policycoreutils-1.28.ebuild, -policycoreutils-1.30-r1.ebuild,
130 + -policycoreutils-1.34.1.ebuild, -policycoreutils-1.34.11.ebuild,
131 + policycoreutils-1.34.15.ebuild:
132 + Mark 1.34.15 stable, clear old ebuilds.
133 +
134 +*policycoreutils-1.34.15 (29 Jan 2008)
135 +
136 + 29 Jan 2008; Chris PeBenito <pebenito@g.o>
137 + +policycoreutils-1.34.15.ebuild:
138 + New upstream bugfix release.
139 +
140 + 19 Oct 2007; Chris PeBenito <pebenito@g.o>
141 + policycoreutils-1.34.11.ebuild:
142 + Fix quoting in unpack.
143 +
144 +*policycoreutils-1.34.11 (18 Oct 2007)
145 +
146 + 18 Oct 2007; Chris PeBenito <pebenito@g.o>
147 + +policycoreutils-1.34.11.ebuild:
148 + New upstream release.
149 +
150 + 04 Jun 2007; Chris PeBenito <pebenito@g.o>
151 + policycoreutils-1.34.1.ebuild:
152 + Mark stable.
153 +
154 +*policycoreutils-1.34.1 (15 Feb 2007)
155 +
156 + 15 Feb 2007; Chris PeBenito <pebenito@g.o>
157 + +policycoreutils-1.34.1.ebuild:
158 + New upstream release.
159 +
160 + 24 Oct 2006; Chris PeBenito <pebenito@g.o>
161 + policycoreutils-1.30.30.ebuild:
162 + Fix glibc handling.
163 +
164 + 09 Oct 2006; Chris PeBenito <pebenito@g.o>
165 + policycoreutils-1.30.30.ebuild:
166 + Stable to make repoman happy.
167 +
168 +*policycoreutils-1.30.30 (05 Oct 2006)
169 +
170 + 05 Oct 2006; Chris PeBenito <pebenito@g.o>
171 + +files/policycoreutils-1.32-quietlp.diff, +policycoreutils-1.30.30.ebuild:
172 + Add SVN snapshot and updated extras in preparation for reference policy.
173 +
174 + 31 Jul 2006; Chris PeBenito <pebenito@g.o>
175 + policycoreutils-1.30-r1.ebuild:
176 + Mark stable, long overdue.
177 +
178 +*policycoreutils-1.30-r1 (28 Mar 2006)
179 +
180 + 28 Mar 2006; Chris PeBenito <pebenito@g.o>
181 + -policycoreutils-1.30.ebuild, +policycoreutils-1.30-r1.ebuild:
182 + Fix install location of python site packages.
183 +
184 + 22 Feb 2006; Stephen Bennett <spb@g.o> policycoreutils-1.28.ebuild:
185 + Alpha stable
186 +
187 + 19 Feb 2006; Joshua Kinard <kumba@g.o> policycoreutils-1.28.ebuild:
188 + Marked stable on mips.
189 +
190 +*policycoreutils-1.30 (18 Mar 2006)
191 +
192 + 18 Mar 2006; Chris PeBenito <pebenito@g.o>
193 + +policycoreutils-1.30.ebuild:
194 + New upstream release.
195 +
196 + 05 Feb 2006; Chris PeBenito <pebenito@g.o>
197 + +files/policycoreutils-unsigned-char-ppc.diff,
198 + policycoreutils-1.28.ebuild:
199 + Add patch to fix #121689.
200 +
201 + 17 Jan 2006; Chris PeBenito <pebenito@g.o>
202 + policycoreutils-1.28.ebuild:
203 + Mark stable, x86, amd64, ppc, sparc.
204 +
205 + 14 Jan 2006; Stephen Bennett <spb@g.o> policycoreutils-1.28.ebuild:
206 + Added ~alpha
207 +
208 + 15 Dec 2005; Chris PeBenito <pebenito@g.o>
209 + policycoreutils-1.22.ebuild, policycoreutils-1.24-r2.ebuild,
210 + policycoreutils-1.28.ebuild:
211 + Tighten up versioning to try to prevent mismatch problems as seen in #112348.
212 +
213 +*policycoreutils-1.28 (09 Dec 2005)
214 +
215 + 09 Dec 2005; Chris PeBenito <pebenito@g.o>
216 + +files/policycoreutils-1.28-quietlp.diff, -policycoreutils-1.24-r1.ebuild,
217 + +policycoreutils-1.28.ebuild:
218 + New upstream release.
219 +
220 +*policycoreutils-1.24-r2 (08 Dec 2005)
221 +
222 + 08 Dec 2005; Chris PeBenito <pebenito@g.o>
223 + +policycoreutils-1.24-r2.ebuild:
224 + Add compatability symlink for genhomedircon.
225 +
226 +*policycoreutils-1.24-r1 (09 Sep 2005)
227 +
228 + 09 Sep 2005; Chris PeBenito <pebenito@g.o>
229 + +policycoreutils-1.24-r1.ebuild:
230 + Update for fixed selinuxconfig source policy path.
231 +
232 + 11 Jul 2005; Chris PeBenito <pebenito@g.o>
233 + policycoreutils-1.22.ebuild, policycoreutils-1.24.ebuild:
234 + Fix RDEPEND for building stages. Libsepol is required now.
235 +
236 +*policycoreutils-1.24 (25 Jun 2005)
237 +
238 + 25 Jun 2005; Chris PeBenito <pebenito@g.o>
239 + +files/policycoreutils-1.24-genhomedircon-quiet.diff,
240 + -policycoreutils-1.20-r1.ebuild, +policycoreutils-1.24.ebuild:
241 + New upstream release.
242 +
243 + 10 May 2005; Stephen Bennett <spb@g.o> policycoreutils-1.22.ebuild:
244 + mips stable
245 +
246 + 01 May 2005; Stephen Bennett <spb@g.o> policycoreutils-1.22.ebuild:
247 + Added ~mips.
248 +
249 + 01 May 2005; Chris PeBenito <pebenito@g.o>
250 + policycoreutils-1.22.ebuild:
251 + Mark stable.
252 +
253 +*policycoreutils-1.22 (13 Mar 2005)
254 +
255 + 13 Mar 2005; Chris PeBenito <pebenito@g.o>
256 + +files/policycoreutils-1.22-genhomedircon-quiet.diff,
257 + +policycoreutils-1.22.ebuild:
258 + New upstream release.
259 +
260 +*policycoreutils-1.20-r1 (13 Feb 2005)
261 +
262 + 13 Feb 2005; Chris PeBenito <pebenito@g.o>
263 + -policycoreutils-1.16.ebuild, +policycoreutils-1.20-r1.ebuild,
264 + -policycoreutils-1.20.ebuild:
265 + Add back some tools deleted from upstream libselinux.
266 +
267 +*policycoreutils-1.20 (07 Jan 2005)
268 +
269 + 07 Jan 2005; Chris PeBenito <pebenito@g.o>
270 + policycoreutils-1.18-r1.ebuild, +policycoreutils-1.20.ebuild:
271 + New upstream release. Mark 1.18-r1 stable.
272 +
273 +*policycoreutils-1.18-r1 (03 Jan 2005)
274 +
275 + 03 Jan 2005; Chris PeBenito <pebenito@g.o>
276 + +files/policycoreutils-nonls.diff, +policycoreutils-1.18-r1.ebuild:
277 + Make pam and nls optional for embedded systems use.
278 +
279 + 22 Nov 2004; Chris PeBenito <pebenito@g.o>
280 + policycoreutils-1.18.ebuild:
281 + Ensure a few dirs and perms during stage1 build.
282 +
283 + 15 Nov 2004; Chris PeBenito <pebenito@g.o>
284 + policycoreutils-1.18.ebuild:
285 + Fix libsepol dep.
286 +
287 +*policycoreutils-1.18 (14 Nov 2004)
288 +
289 + 14 Nov 2004; Chris PeBenito <pebenito@g.o>
290 + +policycoreutils-1.18.ebuild:
291 + New upstream release.
292 +
293 +*policycoreutils-1.16 (07 Sep 2004)
294 +
295 + 07 Sep 2004; Chris PeBenito <pebenito@g.o>
296 + +files/policycoreutils-1.16-genhomedircon-compat.diff,
297 + +policycoreutils-1.16.ebuild:
298 + New upstream release.
299 +
300 + 08 Aug 2004; Tom Martin <slarti@g.o> policycoreutils-1.12-r1.ebuild,
301 + policycoreutils-1.12-r2.ebuild, policycoreutils-1.14.ebuild,
302 + policycoreutils-1.4-r1.ebuild:
303 + Typo in DESCRIPTION: utilites -> utilities. Bug 59717.
304 +
305 + 06 Jul 2004; Chris PeBenito <pebenito@g.o>
306 + policycoreutils-1.14.ebuild:
307 + Bump extras to fix free() bug in runscript_selinux.so.
308 +
309 +*policycoreutils-1.12-r2 (06 Jul 2004)
310 +
311 + 06 Jul 2004; Chris PeBenito <pebenito@g.o>
312 + +files/runscript-selinux.diff, +policycoreutils-1.12-r2.ebuild:
313 + Fix free() error in runscript_selinux.so.
314 +
315 + 03 Jul 2004; Chris PeBenito <pebenito@g.o>
316 + policycoreutils-1.14.ebuild:
317 + Update extras.
318 +
319 +*policycoreutils-1.14 (02 Jul 2004)
320 +
321 + 02 Jul 2004; Chris PeBenito <pebenito@g.o>
322 + +files/policycoreutils-1.14-genhomedircon-compat.diff,
323 + +policycoreutils-1.14.ebuild:
324 + New upstream version.
325 +
326 +*policycoreutils-1.12-r1 (28 Jun 2004)
327 +
328 + 28 Jun 2004; Chris PeBenito <pebenito@g.o>
329 + +policycoreutils-1.12-r1.ebuild:
330 + Add toggle_bool to extras.
331 +
332 + 11 Jun 2004; Chris PeBenito <pebenito@g.o>
333 + -policycoreutils-1.10-r1.ebuild, policycoreutils-1.12.ebuild:
334 + Mark stable
335 +
336 +*policycoreutils-1.12 (14 May 2004)
337 +
338 + 14 May 2004; Chris PeBenito <pebenito@g.o>
339 + +policycoreutils-1.12.ebuild:
340 + New upstream release.
341 +
342 +*policycoreutils-1.10-r1 (28 Apr 2004)
343 +
344 + 28 Apr 2004; Chris PeBenito <pebenito@g.o>
345 + +policycoreutils-1.10-r1.ebuild, -policycoreutils-1.10.ebuild,
346 + -policycoreutils-1.8.ebuild:
347 + Update extras and mark stable.
348 +
349 +*policycoreutils-1.10 (20 Apr 2004)
350 +
351 + 08 Apr 2004; Chris PeBenito <pebenito@g.o>
352 + policycoreutils-1.4-r1.ebuild, policycoreutils-1.8.ebuild:
353 + More specific versioning for libselinux.
354 +
355 + 08 Apr 2004; Chris PeBenito <pebenito@g.o>
356 + policycoreutils-1.8.ebuild:
357 + Mark stable for 2004.1
358 +
359 + 15 Mar 2004; Chris PeBenito <pebenito@g.o>
360 + policycoreutils-1.8.ebuild:
361 + Update extras.
362 +
363 +*policycoreutils-1.8 (12 Mar 2004)
364 +
365 + 12 Mar 2004; Chris PeBenito <pebenito@g.o>
366 + policycoreutils-1.8.ebuild:
367 + New upstream release.
368 +
369 +*policycoreutils-1.6 (24 Feb 2004)
370 +
371 + 24 Feb 2004; Chris PeBenito <pebenito@g.o>
372 + policycoreutils-1.4-r1.ebuild, policycoreutils-1.6.ebuild:
373 + New upstream release. Mark 1.4-r1 stable.
374 +
375 +*policycoreutils-1.4-r1 (09 Feb 2004)
376 +
377 + 09 Feb 2004; Chris PeBenito <pebenito@g.o>
378 + policycoreutils-1.4-r1.ebuild:
379 + Move extras to mirrors, and add runscript_selinux.so.
380 +
381 + 31 Jan 2004; Chris PeBenito <pebenito@g.o> files/rlpkg:
382 + Switch to portageq from inline python. Add missing quotes for completeness.
383 +
384 + 16 Dec 2003; Chris PeBenito <pebenito@g.o>
385 + policycoreutils-1.4.ebuild:
386 + Mark stable.
387 +
388 +*policycoreutils-1.4 (06 Dec 2003)
389 +
390 + 06 Dec 2003; Chris PeBenito <pebenito@g.o>
391 + policycoreutils-1.4.ebuild:
392 + New upstream version.
393 +
394 +*policycoreutils-1.2-r2 (23 Nov 2003)
395 +
396 + 23 Nov 2003; Chris PeBenito <pebenito@g.o>
397 + policycoreutils-1.2-r2.ebuild:
398 + Bump to add /sbin/seinit.
399 +
400 + 29 Oct 2003; Joshua Brindle <method@g.o>
401 + policycoreutils-1.2-r1.ebuild:
402 + added sparc
403 +
404 +*policycoreutils-1.2-r1 (20 Oct 2003)
405 +
406 + 20 Oct 2003; Chris PeBenito <pebenito@g.o>
407 + policycoreutils-1.2-r1.ebuild:
408 + Remove unneeded -lattr linking from Makefiles.
409 +
410 + 07 Oct 2003; Chris PeBenito <pebenito@g.o>
411 + policycoreutils-1.2.ebuild:
412 + Mark stable.
413 +
414 +*policycoreutils-1.2 (03 Oct 2003)
415 +
416 + 03 Oct 2003; Chris PeBenito <pebenito@g.o>
417 + policycoreutils-1.2.ebuild, files/policycoreutils-1.2-gentoo.diff:
418 + New upstream version.
419 +
420 + 29 Sep 2003; Chris PeBenito <pebenito@g.o>
421 + policycoreutils-1.1-r1.ebuild:
422 + Add build USE flag; when asserted, only setfiles is built and merged.
423 +
424 + 22 Sep 2003; Chris PeBenito <pebenito@g.o>
425 + policycoreutils-1.1-r1.ebuild:
426 + Move selinux-base-policy RDEPEND to checkpolicy. No longer RDEPEND on
427 + checkpolicy.
428 +
429 + 22 Sep 2003; <paul@g.o> metadata.xml:
430 + Fix metadata.xml
431 +
432 + 24 Aug 2003; Chris PeBenito <pebenito@g.o>
433 + policycoreutils-1.1-r1.ebuild, policycoreutils-1.1.ebuild:
434 + Mark stable
435 +
436 +*policycoreutils-1.1-r1 (18 Aug 2003)
437 +
438 + 18 Aug 2003; Chris PeBenito <pebenito@g.o> metadata.xml,
439 + policycoreutils-1.0.ebuild, policycoreutils-1.1-r1.ebuild,
440 + files/avc_enforcing, files/avc_toggle,
441 + files/policycoreutils-1.1-setfiles.diff:
442 + Add setfiles patch for alternate root. Add avc_enforcing and avc_toggle
443 + scripts for ease of use for old API users. Use package description from RPM
444 + spec file in metadata.xml long description.
445 +
446 +*policycoreutils-1.1 (14 Aug 2003)
447 +
448 + 14 Aug 2003; Chris PeBenito <pebenito@g.o>
449 + policycoreutils-1.1.ebuild:
450 + New upstream version
451 +
452 + 10 Aug 2003; Chris PeBenito <pebenito@g.o>
453 + policycoreutils-1.0.ebuild, files/rlpkg:
454 + Add mkinitrd RDEP, add rlpkg.
455 +
456 +*policycoreutils-1.0 (03 Aug 2003)
457 +
458 + 03 Aug 2003; Chris PeBenito <pebenito@g.o> metadata.xml,
459 + policycoreutils-1.0.ebuild, files/policycoreutils-1.0-gentoo.diff:
460 + Initial commit
461 +
462
463 diff --git a/sys-apps/policycoreutils/files/policycoreutils-2.0.85-fix-seunshare-vuln.patch b/sys-apps/policycoreutils/files/policycoreutils-2.0.85-fix-seunshare-vuln.patch
464 new file mode 100644
465 index 0000000..ba00a0f
466 --- /dev/null
467 +++ b/sys-apps/policycoreutils/files/policycoreutils-2.0.85-fix-seunshare-vuln.patch
468 @@ -0,0 +1,1084 @@
469 +diff -uNr policycoreutils-2.0.85.orig/sandbox/sandbox policycoreutils-2.0.85/sandbox/sandbox
470 +--- policycoreutils-2.0.85.orig/sandbox/sandbox 2011-07-13 19:49:59.186002432 +0200
471 ++++ policycoreutils-2.0.85/sandbox/sandbox 2011-07-13 23:19:06.323002791 +0200
472 +@@ -19,16 +19,18 @@
473 + # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
474 + #
475 +
476 +-import os, sys, socket, random, fcntl, shutil, re, subprocess
477 ++import os, stat, sys, socket, random, fcntl, shutil, re, subprocess
478 + import selinux
479 + import signal
480 + from tempfile import mkdtemp
481 + import pwd
482 ++import commands
483 ++import gettext
484 +
485 + PROGNAME = "policycoreutils"
486 +-HOMEDIR=pwd.getpwuid(os.getuid()).pw_dir
487 ++SEUNSHARE = "/usr/sbin/seunshare"
488 ++SANDBOXSH = "/usr/share/sesandbox/sesandboxX.sh"
489 +
490 +-import gettext
491 + gettext.bindtextdomain(PROGNAME, "/usr/share/locale")
492 + gettext.textdomain(PROGNAME)
493 +
494 +@@ -41,6 +43,7 @@
495 + import __builtin__
496 + __builtin__.__dict__['_'] = unicode
497 +
498 ++DEFAULT_WINDOWSIZE = "1000x700"
499 + DEFAULT_TYPE = "sandbox_t"
500 + DEFAULT_X_TYPE = "sandbox_x_t"
501 + SAVE_FILES = {}
502 +@@ -63,15 +66,15 @@
503 + sys.stderr.flush()
504 + sys.exit(1)
505 +
506 +-def copyfile(file, dir, dest):
507 ++def copyfile(file, srcdir, dest):
508 + import re
509 +- if file.startswith(dir):
510 ++ if file.startswith(srcdir):
511 + dname = os.path.dirname(file)
512 + bname = os.path.basename(file)
513 +- if dname == dir:
514 ++ if dname == srcdir:
515 + dest = dest + "/" + bname
516 + else:
517 +- newdir = re.sub(dir, dest, dname)
518 ++ newdir = re.sub(srcdir, dest, dname)
519 + if not os.path.exists(newdir):
520 + os.makedirs(newdir)
521 + dest = newdir + "/" + bname
522 +@@ -81,9 +84,10 @@
523 + shutil.copytree(file, dest)
524 + else:
525 + shutil.copy2(file, dest)
526 ++
527 + except shutil.Error, elist:
528 +- for e in elist:
529 +- sys.stderr.write(e[1])
530 ++ for e in elist.message:
531 ++ sys.stderr.write(e[2])
532 +
533 + SAVE_FILES[file] = (dest, os.path.getmtime(dest))
534 +
535 +@@ -161,7 +165,7 @@
536 + if not self.__options.homedir or not self.__options.tmpdir:
537 + self.usage(_("Homedir and tempdir required for level mounts"))
538 +
539 +- if not os.path.exists("/usr/sbin/seunshare"):
540 ++ if not os.path.exists(SEUNSHARE):
541 + raise ValueError(_("""
542 + /usr/sbin/seunshare is required for the action you want to perform.
543 + """))
544 +@@ -194,6 +198,8 @@
545 + self.__include(option, opt, i[:-1], parser)
546 + except IOError, e:
547 + sys.stderr.write(str(e))
548 ++ except TypeError, e:
549 ++ sys.stderr.write(str(e))
550 + fd.close()
551 +
552 + def __copyfiles(self):
553 +@@ -212,7 +218,9 @@
554 + /etc/gdm/Xsession
555 + """)
556 + else:
557 +- command = " ".join(self.__paths)
558 ++ command = self.__paths[0] + " "
559 ++ for p in self.__paths[1:]:
560 ++ command += "'%s' " % p
561 + fd.write("""#! /bin/sh
562 + #TITLE: %s
563 + /usr/bin/test -r ~/.xmodmap && /usr/bin/xmodmap ~/.xmodmap
564 +@@ -230,9 +238,9 @@
565 + def __parse_options(self):
566 + from optparse import OptionParser
567 + usage = _("""
568 +-sesandbox [-h] [-[X|M] [-l level ] [-H homedir] [-T tempdir]] [-I includefile ] [-W windowmanager ] [[-i file ] ...] [ -t type ] command
569 ++sesandbox [-h] [-l level ] [-[X|M] [-H homedir] [-T tempdir]] [-I includefile ] [-W windowmanager ] [ -w windowsize ] [[-i file ] ...] [ -t type ] command
570 +
571 +-sesandbox [-h] [-[X|M] [-l level ] [-H homedir] [-T tempdir]] [-I includefile ] [-W windowmanager ] [[-i file ] ...] [ -t type ] -S
572 ++sesandbox [-h] [-l level ] [-[X|M] [-H homedir] [-T tempdir]] [-I includefile ] [-W windowmanager ] [ -w windowsize ] [[-i file ] ...] [ -t type ] -S
573 + """)
574 +
575 + parser = OptionParser(version=self.VERSION, usage=usage)
576 +@@ -268,6 +276,10 @@
577 + action="callback", callback=self.__validdir,
578 + help=_("alternate /tmp directory to use for mounting"))
579 +
580 ++ parser.add_option("-w", "--windowsize", dest="windowsize",
581 ++ type="string", default=DEFAULT_WINDOWSIZE,
582 ++ help="size of the sandbox window")
583 ++
584 + parser.add_option("-W", "--windowmanager", dest="wm",
585 + type="string",
586 + default="/usr/bin/matchbox-window-manager -use_titlebar no",
587 +@@ -276,12 +288,18 @@
588 + parser.add_option("-l", "--level", dest="level",
589 + help=_("MCS/MLS level for the sesandbox"))
590 +
591 ++ parser.add_option("-C", "--capabilities",
592 ++ action="store_true", dest="usecaps", default=False,
593 ++ help="Allow apps requiring capabilities to run within the sandbox.")
594 ++
595 ++
596 + self.__parser=parser
597 +
598 + self.__options, cmds = parser.parse_args()
599 +
600 + if self.__options.X_ind:
601 + self.setype = DEFAULT_X_TYPE
602 ++ self.dpi=commands.getoutput("xrdb -query | grep dpi | /bin/cut -f 2")
603 +
604 + if self.__options.setype:
605 + self.setype = self.__options.setype
606 +@@ -300,6 +318,10 @@
607 + self.__homedir = self.__options.homedir
608 + self.__tmpdir = self.__options.tmpdir
609 + else:
610 ++ if self.__options.level:
611 ++ self.__homedir = self.__options.homedir
612 ++ self.__tmpdir = self.__options.tmpdir
613 ++
614 + if len(cmds) == 0:
615 + self.usage(_("Command required"))
616 + cmds[0] = fullpath(cmds[0])
617 +@@ -329,44 +351,45 @@
618 + def __setup_dir(self):
619 + if self.__options.level or self.__options.session:
620 + return
621 +- sandboxdir = HOMEDIR + "/.sesandbox"
622 +- if not os.path.exists(sandboxdir):
623 +- os.mkdir(sandboxdir)
624 +
625 + if self.__options.homedir:
626 + selinux.chcon(self.__options.homedir, self.__filecon, recursive=True)
627 + self.__homedir = self.__options.homedir
628 + else:
629 + selinux.setfscreatecon(self.__filecon)
630 +- self.__homedir = mkdtemp(dir=sandboxdir, prefix=".sesandbox")
631 ++ self.__homedir = mkdtemp(dir="/tmp", prefix=".sesandbox_home_")
632 +
633 + if self.__options.tmpdir:
634 + selinux.chcon(self.__options.tmpdir, self.__filecon, recursive=True)
635 + self.__tmpdir = self.__options.tmpdir
636 + else:
637 + selinux.setfscreatecon(self.__filecon)
638 +- self.__tmpdir = mkdtemp(dir="/tmp", prefix=".sesandbox")
639 ++ self.__tmpdir = mkdtemp(dir="/tmp", prefix=".sesandbox_tmp_")
640 + selinux.setfscreatecon(None)
641 + self.__copyfiles()
642 +
643 + def __execute(self):
644 + try:
645 +- if self.__options.X_ind:
646 +- xmodmapfile = self.__homedir + "/.xmodmap"
647 +- xd = open(xmodmapfile,"w")
648 +- subprocess.Popen(["/usr/bin/xmodmap","-pke"],stdout=xd).wait()
649 +- xd.close()
650 +-
651 +- self.__setup_sandboxrc(self.__options.wm)
652 +-
653 +- cmds = [ '/usr/sbin/seunshare', "-t", self.__tmpdir, "-h", self.__homedir, "--", self.__execcon, "/usr/share/sesandbox/sesandboxX.sh" ]
654 +- rc = subprocess.Popen(cmds).wait()
655 +- return rc
656 +-
657 ++ cmds = [ SEUNSHARE, "-Z", self.__execcon ]
658 ++ if self.__options.usecaps:
659 ++ cmds.append('-C')
660 ++ if not self.__options.level:
661 ++ cmds.append('-k')
662 + if self.__mount:
663 +- cmds = [ '/usr/sbin/seunshare', "-t", self.__tmpdir, "-h", self.__homedir, "--", self.__execcon ] + self.__paths
664 +- rc = subprocess.Popen(cmds).wait()
665 +- return rc
666 ++ cmds += [ "-t", self.__tmpdir, "-h", self.__homedir ]
667 ++
668 ++ if self.__options.X_ind:
669 ++ xmodmapfile = self.__homedir + "/.xmodmap"
670 ++ xd = open(xmodmapfile,"w")
671 ++ subprocess.Popen(["/usr/bin/xmodmap","-pke"],stdout=xd).wait()
672 ++ xd.close()
673 ++
674 ++ self.__setup_sandboxrc(self.__options.wm)
675 ++
676 ++ cmds += [ "--", SANDBOXSH, self.__options.windowsize, self.dpi ]
677 ++ else:
678 ++ cmds += [ "--" ] + self.__paths
679 ++ return subprocess.Popen(cmds).wait()
680 +
681 + selinux.setexeccon(self.__execcon)
682 + rc = subprocess.Popen(self.__cmds).wait()
683 +@@ -404,7 +427,7 @@
684 + sandbox = Sandbox()
685 + rc = sandbox.main()
686 + except OSError, error:
687 +- error_exit(error.args[1])
688 ++ error_exit(error)
689 + except ValueError, error:
690 + error_exit(error.args[0])
691 + except KeyError, error:
692 +diff -uNr policycoreutils-2.0.85.orig/sandbox/seunshare.c policycoreutils-2.0.85/sandbox/seunshare.c
693 +--- policycoreutils-2.0.85.orig/sandbox/seunshare.c 2011-07-13 18:35:00.498002303 +0200
694 ++++ policycoreutils-2.0.85/sandbox/seunshare.c 2011-07-13 21:33:33.601002609 +0200
695 +@@ -1,10 +1,17 @@
696 ++/*
697 ++ * Authors: Dan Walsh <dwalsh@××××××.com>
698 ++ * Authors: Thomas Liu <tliu@×××××××××××××.org>
699 ++ *
700 ++ * Does not include cgroups support (as opposed to seunshare in fedora)
701 ++ */
702 ++
703 ++#define _GNU_SOURCE
704 + #include <signal.h>
705 + #include <sys/types.h>
706 + #include <sys/wait.h>
707 + #include <syslog.h>
708 + #include <sys/mount.h>
709 + #include <pwd.h>
710 +-#define _GNU_SOURCE
711 + #include <sched.h>
712 + #include <string.h>
713 + #include <stdio.h>
714 +@@ -15,6 +22,10 @@
715 + #include <limits.h>
716 + #include <stdlib.h>
717 + #include <errno.h>
718 ++#include <regex.h>
719 ++#include <sys/fsuid.h>
720 ++#include <fcntl.h>
721 ++#include <dirent.h>
722 +
723 + #include <selinux/selinux.h>
724 + #include <selinux/context.h> /* for context-mangling functions */
725 +@@ -22,6 +33,8 @@
726 + #include <sys/types.h>
727 + #include <sys/stat.h>
728 + #include <unistd.h>
729 ++#include <glob.h>
730 ++#include <regex.h>
731 +
732 + #ifdef USE_NLS
733 + #include <locale.h> /* for setlocale() */
734 +@@ -39,26 +52,44 @@
735 + #define MS_PRIVATE 1<<18
736 + #endif
737 +
738 ++static int verbose = 0;
739 ++static int child = 0;
740 ++
741 ++static capng_select_t cap_set = CAPNG_SELECT_BOTH;
742 ++
743 + /**
744 +- * This function will drop all capabilities
745 +- * Returns zero on success, non-zero otherwise
746 ++ * This function will drop all capabilities
747 + */
748 +-static int drop_capabilities(uid_t uid)
749 ++static int drop_caps()
750 + {
751 +- capng_clear(CAPNG_SELECT_BOTH);
752 +-
753 +- if (capng_lock() < 0)
754 ++ if (capng_have_capabilities(cap_set) == CAPNG_NONE)
755 ++ return 0;
756 ++ capng_clear(cap_set);
757 ++ if (capng_lock() == -1 || capng_apply(cap_set) == -1) {
758 ++ fprintf(stderr, _("Failed to drop all capabilities\n"));
759 + return -1;
760 +- /* Change uid */
761 +- if (setresuid(uid, uid, uid)) {
762 +- fprintf(stderr, _("Error changing uid, aborting.\n"));
763 ++ }
764 ++ return 0;
765 ++}
766 ++
767 ++/**
768 ++ * This function will drop all privileges.
769 ++ */
770 ++static int drop_privs(uid_t uid) {
771 ++ if (drop_caps() == -1 || setresuid(uid, uid, uid) == -1) {
772 ++ fprintf(stderr, _("Failed to drop privileges\n"));
773 + return -1;
774 + }
775 +- return capng_apply(CAPNG_SELECT_BOTH);
776 ++ return 0;
777 + }
778 +
779 +-#define DEFAULT_PATH "/usr/bin:/bin"
780 +-static int verbose = 0;
781 ++/**
782 ++ * If the user sends a siginto to seunshare, kill the child's session
783 ++ */
784 ++void handler(int sig) {
785 ++ if (child > 0)
786 ++ kill(-child, sig);
787 ++}
788 +
789 + /**
790 + * Take care of any signal setup
791 +@@ -81,24 +112,109 @@
792 + return -1;
793 + }
794 +
795 ++ if (signal(SIGINT, handler) == SIG_ERR) {
796 ++ perror("Unable to set SIGHUP handler");
797 ++ return -1;
798 ++ }
799 ++
800 + return 0;
801 + }
802 +
803 ++#define status_to_retval(status,retval) do { \
804 ++ if ((status) == -1) \
805 ++ retval = -1; \
806 ++ else if (WIFEXITED((status))) \
807 ++ retval = WEXITSTATUS((status)); \
808 ++ else if (WIFSIGNALED((status))) \
809 ++ retval = 128 + WTERMSIG((status)); \
810 ++ else \
811 ++ retval = -1; \
812 ++ } while(0)
813 ++
814 ++
815 ++/**
816 ++ * Spawn external command using system() with dropped privileges.
817 ++ * TODO: avoid system() and use exec*() instead.
818 ++ */
819 ++static int spawn_command(const char *cmd, uid_t uid) {
820 ++ int child;
821 ++ int status = -1;
822 ++
823 ++ if (verbose > 1)
824 ++ printf("spawn_command: %s\n", cmd);
825 ++
826 ++ child = fork();
827 ++ if (child == -1) {
828 ++ perror(_("Unable to fork"));
829 ++ return status;
830 ++ }
831 ++
832 ++ if (child == 0) {
833 ++ if (drop_privs(uid) != 0)
834 ++ exit(-1);
835 ++
836 ++ status = system(cmd);
837 ++ status_to_retval(status, status);
838 ++ exit(status);
839 ++ }
840 ++
841 ++ waitpid(child, &status, 0);
842 ++ status_to_retval(status, status);
843 ++ return status;
844 ++}
845 ++
846 + /**
847 +- * This function makes sure the mounted directory is owned by the user executing
848 +- * seunshare.
849 +- * If so, it returns 0. If it can not figure this out or they are different, it returns -1.
850 ++ * Check file/directory ownership, struct stat * must be passed to the functions.
851 + */
852 +-static int verify_mount(const char *mntdir, struct passwd *pwd) {
853 ++static int check_owner_uid(uid_t uid, const char *file, struct stat *st) {
854 ++ if (S_ISLNK(st->st_mode)) {
855 ++ fprintf(stderr, _("Error: %s must not be a symbolic link\n"), file);
856 ++ return -1;
857 ++ }
858 ++ if (st->st_uid != uid) {
859 ++ fprintf(stderr, _("Error: %s not owned by UID %d\n"), file, uid);
860 ++ return -1;
861 ++ }
862 ++ return 0;
863 ++}
864 ++
865 ++static int check_owner_gid(gid_t gid, const char *file, struct stat *st) {
866 ++ if (S_ISLNK(st->st_mode)) {
867 ++ fprintf(stderr, _("Error: %s must not be a symbolic link\n"), file);
868 ++ return -1;
869 ++ }
870 ++ if (st->st_gid != gid) {
871 ++ fprintf(stderr, _("Error: %s not owned by GID %d\n"), file, gid);
872 ++ return -1;
873 ++ }
874 ++ return 0;
875 ++}
876 ++
877 ++#define equal_stats(one,two) \
878 ++ ((one)->st_dev == (two)->st_dev && (one)->st_ino == (two)->st_ino && \
879 ++ (one)->st_uid == (two)->st_uid && (one)->st_gid == (two)->st_gid && \
880 ++ (one)->st_mode == (two)->st_mode)
881 ++
882 ++/**
883 ++ * Sanity check specified directory. Store stat info for future comparison, or compare
884 ++ * with previously saved info to detect replaced directories.
885 ++ * Note: this function does not perform owner checks.
886 ++ */
887 ++static int verify_directory(const char *dir, struct stat *st_in, struct stat *st_out) {
888 + struct stat sb;
889 +- if (stat(mntdir, &sb) == -1) {
890 +- fprintf(stderr, _("Invalid mount point %s: %s\n"), mntdir, strerror(errno));
891 ++
892 ++ if (st_out == NULL) st_out = &sb;
893 ++
894 ++ if (lstat(dir, st_out) == -1) {
895 ++ fprintf(stderr, _("Failed to stat %s: %s\n"), dir, strerror(errno));
896 + return -1;
897 + }
898 +- if (sb.st_uid != pwd->pw_uid) {
899 +- errno = EPERM;
900 +- syslog(LOG_AUTHPRIV | LOG_ALERT, "%s attempted to mount an invalid directory, %s", pwd->pw_name, mntdir);
901 +- perror(_("Invalid mount point, reporting to administrator"));
902 ++ if (! S_ISDIR(st_out->st_mode)) {
903 ++ fprintf(stderr, _("Error: %s is not a directory: %s\n"), dir, strerror(errno));
904 ++ return -1;
905 ++ }
906 ++ if (st_in && !equal_stats(st_in, st_out)) {
907 ++ fprintf(stderr, _("Error: %s was replaced by a different directory\n"), dir);
908 + return -1;
909 + }
910 + return 0;
911 +@@ -123,7 +239,7 @@
912 +
913 + /* check the shell skipping newline char */
914 + if (!strcmp(shell_name, buf)) {
915 +- rc = 1;
916 ++ rc = 0;
917 + break;
918 + }
919 + }
920 +@@ -131,45 +247,388 @@
921 + return rc;
922 + }
923 +
924 +-static int seunshare_mount(const char *src, const char *dst, struct passwd *pwd) {
925 ++/*
926 ++ * Mount directory and check that we mounted the right directory.
927 ++ */
928 ++static int seunshare_mount(const char *src, const char *dst, struct stat *src_st) {
929 ++ int flags = MS_REC;
930 ++ int is_tmp = 0;
931 ++
932 + if (verbose)
933 +- printf("Mount %s on %s\n", src, dst);
934 +- if (mount(dst, dst, NULL, MS_BIND | MS_REC, NULL) < 0) {
935 ++ printf(_("Mounting %s on %s\n"), src, dst);
936 ++
937 ++ if (strcmp("/tmp", dst) == 0) {
938 ++ flags = flags | MS_NODEV | MS_NOSUID | MS_NOEXEC;
939 ++ is_tmp = 1;
940 ++ }
941 ++
942 ++ /* mount directory */
943 ++ if (mount(dst, dst, NULL, MS_BIND | flags, NULL) < 0) {
944 + fprintf(stderr, _("Failed to mount %s on %s: %s\n"), dst, dst, strerror(errno));
945 + return -1;
946 + }
947 +
948 +- if (mount(dst, dst, NULL, MS_PRIVATE | MS_REC, NULL) < 0) {
949 ++ if (mount(dst, dst, NULL, MS_PRIVATE | flags, NULL) < 0) {
950 + fprintf(stderr, _("Failed to make %s private: %s\n"), dst, strerror(errno));
951 + return -1;
952 + }
953 +
954 +- if (mount(src, dst, NULL, MS_BIND | MS_REC, NULL) < 0) {
955 ++ if (mount(src, dst, NULL, MS_BIND | flags, NULL) < 0) {
956 + fprintf(stderr, _("Failed to mount %s on %s: %s\n"), src, dst, strerror(errno));
957 + return -1;
958 + }
959 +
960 +- if (verify_mount(dst, pwd) < 0)
961 ++ /* verify whether we mounted what we expected to mount */
962 ++ if (verify_directory(dst, src_st, NULL) < 0)
963 + return -1;
964 ++
965 ++ /* bind mount /tmp on /var/tmp too */
966 ++ if (is_tmp) {
967 ++ if (verbose)
968 ++ printf(_("Mounting /tmp on /var/tmp\n"));
969 ++
970 ++ if (mount("/var/tmp", "/var/tmp", NULL, MS_BIND | flags, NULL) < 0) {
971 ++ fprintf(stderr, _("Failed to mount /var/tmp on /var/tmp: %s\n"), strerror(errno));
972 ++ return -1;
973 ++ }
974 ++ if (mount("/var/tmp", "/var/tmp", NULL, MS_PRIVATE | flags, NULL) < 0) {
975 ++ fprintf(stderr, _("Failed to make /var/tmp private: %s\n"), strerror(errno));
976 ++ return -1;
977 ++ }
978 ++ if (mount("/tmp", "/var/tmp", NULL, MS_BIND | flags, NULL) < 0) {
979 ++ fprintf(stderr, _("Failed to mount /tmp on /var/tmp: %s\n"), strerror(errno));
980 ++ return -1;
981 ++ }
982 ++ }
983 ++
984 ++ return 0;
985 + }
986 +
987 +-#define USAGE_STRING _("USAGE: seunshare [ -v ] [ -t tmpdir ] [ -h homedir ] -- CONTEXT executable [args] ")
988 ++/*
989 ++ * If path is empty or ends with "/." or "/.." return -1 else return 0;
990 ++ */
991 ++static int bad_path(const char *path) {
992 ++ const char *ptr;
993 ++ ptr = path;
994 ++ while (*ptr) ptr++;
995 ++ if (ptr == path) return -1; // ptr null
996 ++ ptr--;
997 ++ if (ptr != path && *ptr == '.') {
998 ++ ptr--;
999 ++ if (*ptr == '/') return -1; // path ends in /.
1000 ++ if (*ptr == '.') {
1001 ++ if (ptr != path) {
1002 ++ ptr--;
1003 ++ if (*ptr == '/') return -1; // path ends in /..
1004 ++ }
1005 ++ }
1006 ++ }
1007 ++ return 0;
1008 ++}
1009 ++
1010 ++static int rsynccmd(const char *src, const char *dst, char **cmdbuf) {
1011 ++ char *buf = NULL;
1012 ++ char *newbuf = NULL;
1013 ++ glob_t fglob;
1014 ++ fglob.gl_offs = 0;
1015 ++ int flags = GLOB_PERIOD;
1016 ++ unsigned int i = 0;
1017 ++ int rc = -1;
1018 ++
1019 ++ /* match glob for all files in src dir */
1020 ++ if (asprintf(&buf, "%s/*", src) == -1) {
1021 ++ fprintf(stderr, "Out of memory\n");
1022 ++ return -1;
1023 ++ }
1024 ++
1025 ++ if (glob(buf, flags, NULL, &fglob) != 0) {
1026 ++ free(buf);
1027 ++ buf = NULL;
1028 ++ return -1;
1029 ++ }
1030 ++
1031 ++ free(buf);
1032 ++ buf = NULL;
1033 ++
1034 ++ for (i=0; i < fglob.gl_pathc; i++) {
1035 ++ const char * path = fglob.gl_pathv[i];
1036 ++
1037 ++ if (bad_path(path))
1038 ++ continue;
1039 ++
1040 ++ if (!buf) {
1041 ++ if (asprintf(&newbuf, "\'%s\'", path) == -1) {
1042 ++ fprintf(stderr, "Out of memory\n");
1043 ++ goto err;
1044 ++ }
1045 ++ } else {
1046 ++ if (asprintf(&newbuf, "%s \'%s\'", buf, path) == -1) {
1047 ++ fprintf(stderr, "Out of memory\n");
1048 ++ goto err;
1049 ++ }
1050 ++ }
1051 ++
1052 ++ free(buf); buf = newbuf;
1053 ++ newbuf = NULL;
1054 ++ }
1055 ++
1056 ++ if (buf) {
1057 ++ if (asprintf(&newbuf, "/usr/bin/rsync -trlHDq %s '%s'", buf, dst) == -1) {
1058 ++ fprintf(stderr, "Out of memory\n");
1059 ++ goto err;
1060 ++ }
1061 ++ *cmdbuf = newbuf;
1062 ++ } else {
1063 ++ *cmdbuf = NULL;
1064 ++ }
1065 ++ rc = 0;
1066 ++
1067 ++err:
1068 ++ free(buf);
1069 ++ buf = NULL;
1070 ++ globfree(&fglob);
1071 ++ return rc;
1072 ++}
1073 ++
1074 ++/**
1075 ++ * Clean up runtime temporary directory. Returns 0 if no problem was detected,
1076 ++ * >0 if some error was detected, but errors here are treated as non-fatal and
1077 ++ * left to tmpwatch to finish incomplete cleanup.
1078 ++ */
1079 ++static int cleanup_tmpdir(const char *tmpdir, const char *src, struct passwd *pwd, int copy_content) {
1080 ++ char *cmdbuf = NULL;
1081 ++ int rc = 0;
1082 ++
1083 ++ /* rsync files back */
1084 ++ if (copy_content) {
1085 ++ if (asprintf(&cmdbuf, "/usr/bin/rsync --exclude=.X11-unix -utrlHDq --delete '%s/' '%s/'", tmpdir, src) == -1) {
1086 ++ fprintf(stderr, _("Out of memory\n"));
1087 ++ cmdbuf = NULL;
1088 ++ rc++;
1089 ++ }
1090 ++ if (cmdbuf && spawn_command(cmdbuf, pwd->pw_uid) != 0) {
1091 ++ fprintf(stderr, _("Failed to copy files from the runtime temporary directory\n"));
1092 ++ rc++;
1093 ++ }
1094 ++ free(cmdbuf);
1095 ++ cmdbuf = NULL;
1096 ++ }
1097 ++
1098 ++ /* remove files from the runtime temporary directory */
1099 ++ if (asprintf(&cmdbuf, "/bin/rm -r '%s/' 2>/dev/null", tmpdir) == -1) {
1100 ++ fprintf(stderr, _("Out of memory\n"));
1101 ++ cmdbuf = NULL;
1102 ++ rc++;
1103 ++ }
1104 ++ /* this may fail if there's root-owned file left in the runtime tmpdir */
1105 ++ if (cmdbuf && spawn_command(cmdbuf, pwd->pw_uid) != 0)
1106 ++ rc++;
1107 ++ free(cmdbuf);
1108 ++ cmdbuf = NULL;
1109 ++
1110 ++ /* remove runtime temporary directory */
1111 ++ setfsuid(0);
1112 ++ if (rmdir(tmpdir) == -1)
1113 ++ fprintf(stderr, _("Failed to remove directory %s: %s\n"), tmpdir, strerror(errno));
1114 ++ setfsuid(pwd->pw_uid);
1115 ++
1116 ++ return 0;
1117 ++}
1118 ++
1119 ++/**
1120 ++ * seunshare will create a tmpdir in /tmp, with root ownership. The parent process
1121 ++ * waits for its child to exit to attempt to remove the directory. If it fails to remove
1122 ++ * the directory, we will need to rely on tmpreaper/tmpwatch to clean it up.
1123 ++ */
1124 ++static char *create_tmpdir(const char *src, struct stat *src_st, struct stat *out_st, struct passwd *pwd, security_context_t execcon) {
1125 ++ char *tmpdir = NULL;
1126 ++ char *cmdbuf = NULL;
1127 ++ int fd_t = -1, fd_s = -1;
1128 ++ struct stat tmp_st;
1129 ++ security_context_t con = NULL;
1130 ++
1131 ++ /* get selinux context */
1132 ++ if (execcon) {
1133 ++ setfsuid(pwd->pw_uid);
1134 ++ if ((fd_s = open(src, O_RDONLY)) < 0) {
1135 ++ fprintf(stderr, _("Failed to open directory %s: %s\n"), src, strerror(errno));
1136 ++ goto err;
1137 ++ }
1138 ++ if (fstat(fd_s, &tmp_st) == -1) {
1139 ++ fprintf(stderr, _("Failed to stat directory %s: %s\n"), src, strerror(errno));
1140 ++ goto err;
1141 ++ }
1142 ++ if (!equal_stats(src_st, &tmp_st)) {
1143 ++ fprintf(stderr, _("Error: %s was replaced by a different directory\n"), src);
1144 ++ goto err;
1145 ++ }
1146 ++
1147 ++ /* ok to not reach this if there is an error */
1148 ++ setfsuid(0);
1149 ++ }
1150 ++
1151 ++ if (asprintf(&tmpdir, "/tmp/.sandbox-%s-XXXXXX", pwd->pw_name) == -1) {
1152 ++ fprintf(stderr, _("Out of memory\n"));
1153 ++ tmpdir = NULL;
1154 ++ goto err;
1155 ++ }
1156 ++ if (mkdtemp(tmpdir) == NULL) {
1157 ++ fprintf(stderr, _("Failed to create temporary directory: %s\n"), strerror(errno));
1158 ++ goto err;
1159 ++ }
1160 ++
1161 ++ /* temporary directory must be owned by root:user */
1162 ++ if (verify_directory(tmpdir, NULL, out_st) < 0) {
1163 ++ goto err;
1164 ++ }
1165 ++ if (check_owner_uid(0, tmpdir, out_st) < 0) goto err;
1166 ++ if (check_owner_gid(getgid(), tmpdir, out_st) < 0) goto err;
1167 ++
1168 ++ /* change permission of the temporary directory */
1169 ++ if ((fd_t = open(tmpdir, O_RDONLY)) < 0) {
1170 ++ fprintf(stderr, _("Failed to open directory %s: %s\n"), tmpdir, strerror(errno));
1171 ++ goto err;
1172 ++ }
1173 ++ if (fstat(fd_t, &tmp_st) == -1) {
1174 ++ fprintf(stderr, _("Failed to stat directory %s: %s\n"), tmpdir, strerror(errno));
1175 ++ goto err;
1176 ++ }
1177 ++ if (!equal_stats(out_st, &tmp_st)) {
1178 ++ fprintf(stderr, _("Error: %s was replaced by a different directory\n"), tmpdir);
1179 ++ goto err;
1180 ++ }
1181 ++ if (fchmod(fd_t, 01770) == -1) {
1182 ++ fprintf(stderr, _("Unable to change mode on %s: %s\n"), tmpdir, strerror(errno));
1183 ++ goto err;
1184 ++ }
1185 ++ /* re-stat again to pick change mode */
1186 ++ if (fstat(fd_t, out_st) == -1) {
1187 ++ fprintf(stderr, _("Failed to stat directory %s: %s\n"), tmpdir, strerror(errno));
1188 ++ goto err;
1189 ++ }
1190 ++
1191 ++ /* copy selinux context */
1192 ++ if (execcon) {
1193 ++ if (fsetfilecon(fd_t, con) == -1) {
1194 ++ fprintf(stderr, _("Failed to set context of the directory %s: %s\n"), tmpdir, strerror(errno));
1195 ++ goto err;
1196 ++ }
1197 ++ }
1198 ++
1199 ++ setfsuid(pwd->pw_uid);
1200 ++
1201 ++ if (rsynccmd(src, tmpdir, &cmdbuf) < 0) {
1202 ++ goto err;
1203 ++ }
1204 ++
1205 ++ /* ok to not reach this if there is an error */
1206 ++ setfsuid(0);
1207 ++
1208 ++ if (cmdbuf && spawn_command(cmdbuf, pwd->pw_uid) != 0) {
1209 ++ fprintf(stderr, _("Failed to populate runtime temporary directory\n"));
1210 ++ cleanup_tmpdir(tmpdir, src, pwd, 0);
1211 ++ goto err;
1212 ++ }
1213 ++
1214 ++ goto good;
1215 ++err:
1216 ++ free(tmpdir);
1217 ++ tmpdir = NULL;
1218 ++good:
1219 ++ free(cmdbuf);
1220 ++ cmdbuf = NULL;
1221 ++ freecon(con);
1222 ++ con = NULL;
1223 ++ if (fd_t >= 0)
1224 ++ close(fd_t);
1225 ++ if (fd_s >= 0)
1226 ++ close(fd_s);
1227 ++ return tmpdir;
1228 ++}
1229 ++
1230 ++#define DEFAULT_PATH "/usr/bin:/bin"
1231 ++#define USAGE_STRING _("USAGE: seunshare [ -v ] -C -t tmpdir -h homedir [-Z context] -- executable [args]")
1232 ++#define PROC_BASE "/proc"
1233 ++
1234 ++static int killall (security_context_t execcon) {
1235 ++ DIR *dir;
1236 ++ security_context_t scon;
1237 ++ struct dirent *de;
1238 ++ pid_t *pid_table, pid, self;
1239 ++ int i;
1240 ++ int pids, max_pids;
1241 ++ int running = 0;
1242 ++ self = getpid();
1243 ++ if (!(dir = opendir(PROC_BASE))) {
1244 ++ return -1;
1245 ++ }
1246 ++ max_pids = 256;
1247 ++ pid_table = malloc(max_pids * sizeof(pid_t));
1248 ++ if (!pid_table) {
1249 ++ return -1;
1250 ++ }
1251 ++ pids = 0;
1252 ++ context_t con;
1253 ++ con = context_new(execcon);
1254 ++ const char *mcs = context_range_get(con);
1255 ++ printf("mcs=%s\n", mcs);
1256 ++ while ((de = readdir(dir)) != NULL) {
1257 ++ if (!(pid = (pid_t)atoi(de->d_name)) || pid == self)
1258 ++ continue;
1259 ++
1260 ++ if (pids == max_pids) {
1261 ++ if(!(pid_table = realloc(pid_table, 2*pids*sizeof(pid_t)))) {
1262 ++ return -1;
1263 ++ }
1264 ++ max_pids *= 2;
1265 ++ }
1266 ++ pid_table[pids++] = pid;
1267 ++ }
1268 ++
1269 ++ (void)closedir(dir);
1270 ++
1271 ++ for (i = 0; i < pids; i++) {
1272 ++ pid_t id = pid_table[i];
1273 ++
1274 ++ if (getpidcon(id, &scon) == 0) {
1275 ++ context_t pidcon = context_new(scon);
1276 ++ /* Attempt to kill remaining processes */
1277 ++ if (strcmp(context_range_get(pidcon), mcs) == 0)
1278 ++ kill(id, SIGKILL);
1279 ++
1280 ++ context_free(pidcon);
1281 ++ freecon(scon);
1282 ++ }
1283 ++ running++;
1284 ++ }
1285 ++
1286 ++ context_free(con);
1287 ++ free(pid_table);
1288 ++ return running;
1289 ++}
1290 +
1291 + int main(int argc, char **argv) {
1292 +- int rc;
1293 + int status = -1;
1294 ++ security_context_t execcon = NULL;
1295 +
1296 +- security_context_t scontext;
1297 +-
1298 +- int flag_index; /* flag index in argv[] */
1299 + int clflag; /* holds codes for command line flags */
1300 +- char *tmpdir_s = NULL; /* tmpdir spec'd by user in argv[] */
1301 ++ int kill_all = 0;
1302 ++
1303 + char *homedir_s = NULL; /* homedir spec'd by user in argv[] */
1304 ++ char *tmpdir_s = NULL; /* tmpdir spec'd by user in argv[] */
1305 ++ char * tmpdir_r = NULL; /* tmpdir created by seunshare */
1306 ++
1307 ++ struct stat st_homedir;
1308 ++ struct stat st_tmpdir_s;
1309 ++ struct stat st_tmpdir_r;
1310 +
1311 + const struct option long_options[] = {
1312 + {"homedir", 1, 0, 'h'},
1313 + {"tmpdir", 1, 0, 't'},
1314 ++ {"kill", 1, 0, 'k'},
1315 + {"verbose", 1, 0, 'v'},
1316 ++ {"context", 1, 0, 'Z'},
1317 ++ {"capabilities", 1, 0, 'C'},
1318 + {NULL, 0, 0, 0}
1319 + };
1320 +
1321 +@@ -187,34 +646,33 @@
1322 + }
1323 +
1324 + if (verify_shell(pwd->pw_shell) < 0) {
1325 +- fprintf(stderr, _("Error! Shell is not valid.\n"));
1326 ++ fprintf(stderr, _("Error: User shell is not valid.\n"));
1327 + return -1;
1328 + }
1329 +
1330 + while (1) {
1331 +- clflag = getopt_long(argc, argv, "h:t:", long_options,
1332 +- &flag_index);
1333 ++ clflag = getopt_long(argc, argv, "Cvh:t:Z", long_options, NULL);
1334 + if (clflag == -1)
1335 + break;
1336 +
1337 + switch (clflag) {
1338 + case 't':
1339 +- if (!(tmpdir_s = realpath(optarg, NULL))) {
1340 +- fprintf(stderr, _("Invalid mount point %s: %s\n"), optarg, strerror(errno));
1341 +- return -1;
1342 +- }
1343 +- if (verify_mount(tmpdir_s, pwd) < 0) return -1;
1344 ++ tmpdir_s = optarg;
1345 ++ break;
1346 ++ case 'k':
1347 ++ kill_all = 1;
1348 + break;
1349 + case 'h':
1350 +- if (!(homedir_s = realpath(optarg, NULL))) {
1351 +- fprintf(stderr, _("Invalid mount point %s: %s\n"), optarg, strerror(errno));
1352 +- return -1;
1353 +- }
1354 +- if (verify_mount(homedir_s, pwd) < 0) return -1;
1355 +- if (verify_mount(pwd->pw_dir, pwd) < 0) return -1;
1356 ++ homedir_s = optarg;
1357 + break;
1358 + case 'v':
1359 +- verbose = 1;
1360 ++ verbose++;
1361 ++ break;
1362 ++ case 'C':
1363 ++ cap_set = CAPNG_SELECT_CAPS;
1364 ++ break;
1365 ++ case 'Z':
1366 ++ execcon = optarg;
1367 + break;
1368 + default:
1369 + fprintf(stderr, "%s\n", USAGE_STRING);
1370 +@@ -223,74 +681,80 @@
1371 + }
1372 +
1373 + if (! homedir_s && ! tmpdir_s) {
1374 +- fprintf(stderr, _("Error: tmpdir and/or homedir required \n"),
1375 +- "%s\n", USAGE_STRING);
1376 ++ fprintf(stderr, _("Error: tmpdir and/or homedir required\n %s\n"), USAGE_STRING);
1377 + return -1;
1378 + }
1379 +
1380 +- if (argc - optind < 2) {
1381 +- fprintf(stderr, _("Error: context and executable required \n"),
1382 +- "%s\n", USAGE_STRING);
1383 ++ if (argc - optind < 1) {
1384 ++ fprintf(stderr, _("Error: executable required \n %s\n"), USAGE_STRING);
1385 + return -1;
1386 + }
1387 +
1388 +- scontext = argv[optind++];
1389 +-
1390 +- if (set_signal_handles())
1391 +- return -1;
1392 +-
1393 +- if (unshare(CLONE_NEWNS) < 0) {
1394 +- perror(_("Failed to unshare"));
1395 ++ if (execcon && is_selinux_enabled() != -1) {
1396 ++ fprintf(stderr, _("Error: execution context specified, but SELinux is not enabled\n"));
1397 + return -1;
1398 + }
1399 +
1400 +- if (homedir_s && tmpdir_s && (strncmp(pwd->pw_dir, tmpdir_s, strlen(pwd->pw_dir)) == 0)) {
1401 +- if (seunshare_mount(tmpdir_s, "/tmp", pwd) < 0)
1402 +- return -1;
1403 +- if (seunshare_mount(homedir_s, pwd->pw_dir, pwd) < 0)
1404 +- return -1;
1405 +- } else {
1406 +- if (homedir_s && seunshare_mount(homedir_s, pwd->pw_dir, pwd) < 0)
1407 +- return -1;
1408 +-
1409 +- if (tmpdir_s && seunshare_mount(tmpdir_s, "/tmp", pwd) < 0)
1410 +- return -1;
1411 +- }
1412 ++ if (set_signal_handles()) return -1;
1413 ++
1414 ++ /* set fsuid to ruid */
1415 ++ /* Changing fsuid is usually required when user-specified directory is
1416 ++ * on an NFS mount. It's also desired to avoid leaking info about
1417 ++ * existence of the files not accessible to the user.
1418 ++ */
1419 ++ setfsuid(uid);
1420 +
1421 +- if (drop_capabilities(uid)) {
1422 +- perror(_("Failed to drop all capabilities"));
1423 ++ /* verify homedir and tmpdir */
1424 ++ if (homedir_s && (
1425 ++ verify_directory(homedir_s, NULL, &st_homedir) < 0 ||
1426 ++ check_owner_uid(uid, homedir_s, &st_homedir))) return -1;
1427 ++ if (tmpdir_s && (
1428 ++ verify_directory(tmpdir_s, NULL, &st_tmpdir_s) < 0 ||
1429 ++ check_owner_uid(uid, tmpdir_s, &st_tmpdir_s))) return -1;
1430 ++ setfsuid(0);
1431 ++
1432 ++ /* create runtime tmpdir */
1433 ++ if (tmpdir_s && (tmpdir_r = create_tmpdir(tmpdir_s, &st_tmpdir_s, &st_tmpdir_r, pwd, execcon)) == NULL) {
1434 ++ fprintf(stderr, _("Failed to create runtime temporary directory\n"));
1435 + return -1;
1436 + }
1437 +
1438 +- int child = fork();
1439 ++ /* spawn child process */
1440 ++ child = fork();
1441 + if (child == -1) {
1442 + perror(_("Unable to fork"));
1443 +- return -1;
1444 ++ goto err;
1445 + }
1446 +
1447 +- if (!child) {
1448 +- char *display=NULL;
1449 +- /* Construct a new environment */
1450 +- char *d = getenv("DISPLAY");
1451 +- if (d) {
1452 +- display = strdup(d);
1453 +- if (!display) {
1454 +- perror(_("Out of memory"));
1455 +- exit(-1);
1456 +- }
1457 ++ if (child == 0) {
1458 ++ char *display = NULL;
1459 ++ int rc = -1;
1460 ++
1461 ++ if (unshare(CLONE_NEWNS) < 0) {
1462 ++ perror(_("Failed to unshare"));
1463 ++ goto childerr;
1464 + }
1465 +
1466 +- if ((rc = clearenv())) {
1467 +- perror(_("Unable to clear environment"));
1468 +- free(display);
1469 +- exit(-1);
1470 ++ /* assume fsuid == ruid after this point */
1471 ++ setfsuid(uid);
1472 ++
1473 ++ /* mount homedir and tmpdir, in this order */
1474 ++ if (homedir_s && seunshare_mount(homedir_s, pwd->pw_dir, &st_homedir) != 0) goto childerr;
1475 ++ if (tmpdir_s && seunshare_mount(tmpdir_r, "/tmp", &st_tmpdir_r) != 0) goto childerr;
1476 ++
1477 ++ if (drop_privs(uid) != 0) goto childerr;
1478 ++
1479 ++ /* construct a new environment */
1480 ++ if ((display = getenv("DISPLAY")) != NULL) {
1481 ++ if ((display = strdup(display)) == NULL) {
1482 ++ perror(_("Out of memory"));
1483 ++ goto childerr;
1484 ++ }
1485 + }
1486 +-
1487 +- if (setexeccon(scontext)) {
1488 +- fprintf(stderr, _("Could not set exec context to %s.\n"),
1489 +- scontext);
1490 +- free(display);
1491 +- exit(-1);
1492 ++
1493 ++ if ((rc = clearenv()) != 0) {
1494 ++ perror(_("Failed to clear environment"));
1495 ++ goto childerr;
1496 + }
1497 +
1498 + if (display)
1499 +@@ -300,22 +764,46 @@
1500 + rc |= setenv("USER", pwd->pw_name, 1);
1501 + rc |= setenv("LOGNAME", pwd->pw_name, 1);
1502 + rc |= setenv("PATH", DEFAULT_PATH, 1);
1503 +-
1504 ++
1505 ++ if (rc != 0) {
1506 ++ fprintf(stderr, _("Failed to construct environment\n"));
1507 ++ goto childerr;
1508 ++ }
1509 ++
1510 ++ /* selinux context */
1511 ++ if (execcon && setexeccon(execcon) != 0) {
1512 ++ fprintf(stderr, _("Could not set exec context to %s.\n"), execcon);
1513 ++ goto childerr;
1514 ++ }
1515 ++
1516 + if (chdir(pwd->pw_dir)) {
1517 + perror(_("Failed to change dir to homedir"));
1518 +- exit(-1);
1519 ++ goto childerr;
1520 + }
1521 ++
1522 + setsid();
1523 ++
1524 + execv(argv[optind], argv + optind);
1525 ++ fprintf(stderr, _("Failed to execute command %s: %s\n"), argv[optind], strerror(errno));
1526 ++childerr:
1527 + free(display);
1528 +- perror("execv");
1529 + exit(-1);
1530 +- } else {
1531 +- waitpid(child, &status, 0);
1532 + }
1533 +
1534 +- free(tmpdir_s);
1535 +- free(homedir_s);
1536 ++ drop_caps();
1537 +
1538 ++ /* parent waits for child exit to do the cleanup */
1539 ++ waitpid(child, &status, 0);
1540 ++ status_to_retval(status, status);
1541 ++
1542 ++ /* Make sure all child processes exit */
1543 ++ kill(-child, SIGTERM);
1544 ++
1545 ++ if (execcon && kill_all)
1546 ++ killall(execcon);
1547 ++
1548 ++ if (tmpdir_r) cleanup_tmpdir(tmpdir_r, tmpdir_s, pwd, 1);
1549 ++err:
1550 ++ free(tmpdir_r);
1551 + return status;
1552 + }
1553
1554 diff --git a/sys-apps/policycoreutils/files/policycoreutils-2.0.85-python3.tar.gz b/sys-apps/policycoreutils/files/policycoreutils-2.0.85-python3.tar.gz
1555 new file mode 100644
1556 index 0000000..49b3169
1557 Binary files /dev/null and b/sys-apps/policycoreutils/files/policycoreutils-2.0.85-python3.tar.gz differ
1558
1559 diff --git a/sys-apps/policycoreutils/files/policycoreutils-2.0.85-sesandbox.patch b/sys-apps/policycoreutils/files/policycoreutils-2.0.85-sesandbox.patch
1560 new file mode 100644
1561 index 0000000..42bd083
1562 --- /dev/null
1563 +++ b/sys-apps/policycoreutils/files/policycoreutils-2.0.85-sesandbox.patch
1564 @@ -0,0 +1,387 @@
1565 +diff -uNr policycoreutils-2.0.85.orig/sandbox/Makefile policycoreutils-2.0.85/sandbox/Makefile
1566 +--- policycoreutils-2.0.85.orig/sandbox/Makefile 2011-07-13 18:35:00.498002303 +0200
1567 ++++ policycoreutils-2.0.85/sandbox/Makefile 2011-07-13 19:32:10.337002401 +0200
1568 +@@ -6,28 +6,37 @@
1569 + SBINDIR ?= $(PREFIX)/sbin
1570 + MANDIR ?= $(PREFIX)/share/man
1571 + LOCALEDIR ?= /usr/share/locale
1572 +-SHAREDIR ?= $(PREFIX)/share/sandbox
1573 ++SHAREDIR ?= $(PREFIX)/share/sesandbox
1574 + override CFLAGS += $(LDFLAGS) -I$(PREFIX)/include -DPACKAGE="\"policycoreutils\""
1575 + LDLIBS += -lselinux -lcap-ng
1576 +
1577 +-all: sandbox seunshare sandboxX.sh
1578 ++all: sesandbox seunshare sesandboxX.sh
1579 ++
1580 ++sesandbox: sandbox
1581 ++ cp sandbox sesandbox
1582 ++ cp sandbox.8 sesandbox.8
1583 ++ cp sandbox.init sesandbox.init
1584 ++ cp sandbox.config sesandbox.config
1585 ++
1586 ++sesandboxX.sh: sandboxX.sh
1587 ++ cp sandboxX.sh sesandboxX.sh
1588 +
1589 + seunshare: seunshare.o $(EXTRA_OBJS)
1590 + $(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
1591 +
1592 + install: all
1593 + -mkdir -p $(BINDIR)
1594 +- install -m 755 sandbox $(BINDIR)
1595 ++ install -m 755 sesandbox $(BINDIR)
1596 + -mkdir -p $(MANDIR)/man8
1597 +- install -m 644 sandbox.8 $(MANDIR)/man8/
1598 ++ install -m 644 sesandbox.8 $(MANDIR)/man8/
1599 + -mkdir -p $(SBINDIR)
1600 + install -m 4755 seunshare $(SBINDIR)/
1601 + -mkdir -p $(SHAREDIR)
1602 +- install -m 755 sandboxX.sh $(SHAREDIR)
1603 ++ install -m 755 sesandboxX.sh $(SHAREDIR)
1604 + -mkdir -p $(INITDIR)
1605 +- install -m 755 sandbox.init $(INITDIR)/sandbox
1606 ++ install -m 755 sesandbox.init $(INITDIR)/sesandbox
1607 + -mkdir -p $(SYSCONFDIR)
1608 +- install -m 644 sandbox.config $(SYSCONFDIR)/sandbox
1609 ++ install -m 644 sesandbox.config $(SYSCONFDIR)/sesandbox
1610 +
1611 + test:
1612 + @python test_sandbox.py -v
1613 +diff -uNr policycoreutils-2.0.85.orig/sandbox/sandbox policycoreutils-2.0.85/sandbox/sandbox
1614 +--- policycoreutils-2.0.85.orig/sandbox/sandbox 2011-07-13 18:35:00.498002303 +0200
1615 ++++ policycoreutils-2.0.85/sandbox/sandbox 2011-07-13 18:39:07.068002310 +0200
1616 +@@ -142,7 +142,7 @@
1617 + return cmd
1618 +
1619 + class Sandbox:
1620 +- VERSION = "sandbox .1"
1621 ++ VERSION = "sesandbox .1"
1622 + SYSLOG = "/var/log/messages"
1623 +
1624 + def __init__(self):
1625 +@@ -204,7 +204,7 @@
1626 + copyfile(f, "/tmp", self.__tmpdir)
1627 +
1628 + def __setup_sandboxrc(self, wm = "/usr/bin/matchbox-window-manager -use_titlebar no"):
1629 +- execfile =self.__homedir + "/.sandboxrc"
1630 ++ execfile =self.__homedir + "/.sesandboxrc"
1631 + fd = open(execfile, "w+")
1632 + if self.__options.session:
1633 + fd.write("""#!/bin/sh
1634 +@@ -230,9 +230,9 @@
1635 + def __parse_options(self):
1636 + from optparse import OptionParser
1637 + usage = _("""
1638 +-sandbox [-h] [-[X|M] [-l level ] [-H homedir] [-T tempdir]] [-I includefile ] [-W windowmanager ] [[-i file ] ...] [ -t type ] command
1639 ++sesandbox [-h] [-[X|M] [-l level ] [-H homedir] [-T tempdir]] [-I includefile ] [-W windowmanager ] [[-i file ] ...] [ -t type ] command
1640 +
1641 +-sandbox [-h] [-[X|M] [-l level ] [-H homedir] [-T tempdir]] [-I includefile ] [-W windowmanager ] [[-i file ] ...] [ -t type ] -S
1642 ++sesandbox [-h] [-[X|M] [-l level ] [-H homedir] [-T tempdir]] [-I includefile ] [-W windowmanager ] [[-i file ] ...] [ -t type ] -S
1643 + """)
1644 +
1645 + parser = OptionParser(version=self.VERSION, usage=usage)
1646 +@@ -240,22 +240,22 @@
1647 + parser.add_option("-i", "--include",
1648 + action="callback", callback=self.__include,
1649 + type="string",
1650 +- help=_("include file in sandbox"))
1651 ++ help=_("include file in sesandbox"))
1652 + parser.add_option("-I", "--includefile", action="callback", callback=self.__includefile,
1653 + type="string",
1654 +- help=_("read list of files to include in sandbox from INCLUDEFILE"))
1655 ++ help=_("read list of files to include in sesandbox from INCLUDEFILE"))
1656 + parser.add_option("-t", "--type", dest="setype", action="store", default=None,
1657 +- help=_("run sandbox with SELinux type"))
1658 ++ help=_("run sesandbox with SELinux type"))
1659 + parser.add_option("-M", "--mount",
1660 + action="callback", callback=self.__mount_callback,
1661 + help=_("mount new home and/or tmp directory"))
1662 +
1663 + parser.add_option("-S", "--session", action="store_true", dest="session",
1664 +- default=False, help=_("run complete desktop session within sandbox"))
1665 ++ default=False, help=_("run complete desktop session within sesandbox"))
1666 +
1667 + parser.add_option("-X", dest="X_ind",
1668 + action="callback", callback=self.__x_callback,
1669 +- default=False, help=_("run X application within a sandbox"))
1670 ++ default=False, help=_("run X application within a sesandbox"))
1671 +
1672 + parser.add_option("-H", "--homedir",
1673 + action="callback", callback=self.__validdir,
1674 +@@ -274,7 +274,7 @@
1675 + help=_("alternate window manager"))
1676 +
1677 + parser.add_option("-l", "--level", dest="level",
1678 +- help=_("MCS/MLS level for the sandbox"))
1679 ++ help=_("MCS/MLS level for the sesandbox"))
1680 +
1681 + self.__parser=parser
1682 +
1683 +@@ -293,9 +293,9 @@
1684 + if not self.__options.setype:
1685 + self.setype = selinux.getcon()[1].split(":")[2]
1686 + if not self.__options.homedir or not self.__options.tmpdir:
1687 +- self.usage(_("You must specify a Homedir and tempdir when setting up a session sandbox"))
1688 ++ self.usage(_("You must specify a Homedir and tempdir when setting up a session sesandbox"))
1689 + if len(cmds) > 0:
1690 +- self.usage(_("Commands are not allowed in a session sandbox"))
1691 ++ self.usage(_("Commands are not allowed in a session sesandbox"))
1692 + self.__options.X_ind = True
1693 + self.__homedir = self.__options.homedir
1694 + self.__tmpdir = self.__options.tmpdir
1695 +@@ -329,7 +329,7 @@
1696 + def __setup_dir(self):
1697 + if self.__options.level or self.__options.session:
1698 + return
1699 +- sandboxdir = HOMEDIR + "/.sandbox"
1700 ++ sandboxdir = HOMEDIR + "/.sesandbox"
1701 + if not os.path.exists(sandboxdir):
1702 + os.mkdir(sandboxdir)
1703 +
1704 +@@ -338,14 +338,14 @@
1705 + self.__homedir = self.__options.homedir
1706 + else:
1707 + selinux.setfscreatecon(self.__filecon)
1708 +- self.__homedir = mkdtemp(dir=sandboxdir, prefix=".sandbox")
1709 ++ self.__homedir = mkdtemp(dir=sandboxdir, prefix=".sesandbox")
1710 +
1711 + if self.__options.tmpdir:
1712 + selinux.chcon(self.__options.tmpdir, self.__filecon, recursive=True)
1713 + self.__tmpdir = self.__options.tmpdir
1714 + else:
1715 + selinux.setfscreatecon(self.__filecon)
1716 +- self.__tmpdir = mkdtemp(dir="/tmp", prefix=".sandbox")
1717 ++ self.__tmpdir = mkdtemp(dir="/tmp", prefix=".sesandbox")
1718 + selinux.setfscreatecon(None)
1719 + self.__copyfiles()
1720 +
1721 +@@ -359,7 +359,7 @@
1722 +
1723 + self.__setup_sandboxrc(self.__options.wm)
1724 +
1725 +- cmds = [ '/usr/sbin/seunshare', "-t", self.__tmpdir, "-h", self.__homedir, "--", self.__execcon, "/usr/share/sandbox/sandboxX.sh" ]
1726 ++ cmds = [ '/usr/sbin/seunshare', "-t", self.__tmpdir, "-h", self.__homedir, "--", self.__execcon, "/usr/share/sesandbox/sesandboxX.sh" ]
1727 + rc = subprocess.Popen(cmds).wait()
1728 + return rc
1729 +
1730 +diff -uNr policycoreutils-2.0.85.orig/sandbox/sandbox.8 policycoreutils-2.0.85/sandbox/sandbox.8
1731 +--- policycoreutils-2.0.85.orig/sandbox/sandbox.8 2011-07-13 18:35:00.498002303 +0200
1732 ++++ policycoreutils-2.0.85/sandbox/sandbox.8 2011-07-13 18:40:09.803002312 +0200
1733 +@@ -1,8 +1,8 @@
1734 + .TH SANDBOX "8" "May 2009" "chcat" "User Commands"
1735 + .SH NAME
1736 +-sandbox \- Run cmd under an SELinux sandbox
1737 ++sesandbox \- Run cmd under an SELinux sandbox
1738 + .SH SYNOPSIS
1739 +-.B sandbox
1740 ++.B sesandbox
1741 + [-l level ] [[-M | -X] -H homedir -T tempdir ] [-I includefile ] [ -W windowmanager ] [[-i file ]...] [ -t type ] cmd
1742 + [-l level ] [[-M | -X] -H homedir -T tempdir ] [-I includefile ] [ -W windowmanager ] [[-i file ]...] [ -t type ] -S
1743 + .br
1744 +@@ -12,11 +12,8 @@
1745 + .I cmd
1746 + application within a tightly confined SELinux domain. The default sandbox domain only allows applications the ability to read and write stdin, stdout and any other file descriptors handed to it. It is not allowed to open any other files. The -M option will mount an alternate homedir and tmpdir to be used by the sandbox.
1747 +
1748 +-If you have the
1749 +-.I policycoreutils-sandbox
1750 +-package installed, you can use the -X option and the -M option.
1751 + .B sandbox -X
1752 +-allows you to run X applications within a sandbox. These applications will start up their own X Server and create a temporary home directory and /tmp. The default SELinux policy does not allow any capabilities or network access. It also prevents all access to the users other processes and files. Files specified on the command that are in the home directory or /tmp will be copied into the sandbox directories.
1753 ++allows you to run X applications within a sandbox. These applications will start up their own X Server and create a temporary home directory and /tmp. The default SELinux policy does not allow any capabilities or network access. It also prevents all access to the users other processes and files. Files specified on the command that are in the home directory or /tmp will be copied into the sesandbox directories.
1754 +
1755 + If directories are specified with -H or -T the directory will have its context modified with chcon(1) unless a level is specified with -l. If the MLS/MCS security level is specified, the user is responsible to set the correct labels.
1756 + .PP
1757 +@@ -25,10 +22,10 @@
1758 + Use alternate homedir to mount over your home directory. Defaults to temporary. Requires -X or -M.
1759 + .TP
1760 + \fB\-i file\fR
1761 +-Copy this file into the appropriate temporary sandbox directory. Command can be repeated.
1762 ++Copy this file into the appropriate temporary sesandbox directory. Command can be repeated.
1763 + .TP
1764 + \fB\-I inputfile\fR Copy all files listed in inputfile into the
1765 +-appropriate temporary sandbox directories.
1766 ++appropriate temporary sesandbox directories.
1767 + .TP
1768 + \fB\-l\fR
1769 + Specify the MLS/MCS Security Level to run the sandbox with. Defaults to random.
1770 +@@ -44,7 +41,7 @@
1771 + .TP
1772 + \fB\-W windowmanager\fR
1773 + Select alternative window manager to run within
1774 +-.B sandbox -X.
1775 ++.B sesandbox -X.
1776 + Default to /usr/bin/matchbox-window-manager.
1777 + .TP
1778 + \fB\-X\fR
1779 +diff -uNr policycoreutils-2.0.85.orig/sandbox/sandbox.init policycoreutils-2.0.85/sandbox/sandbox.init
1780 +--- policycoreutils-2.0.85.orig/sandbox/sandbox.init 2011-07-13 18:35:00.498002303 +0200
1781 ++++ policycoreutils-2.0.85/sandbox/sandbox.init 2011-07-13 18:38:08.850002308 +0200
1782 +@@ -1,22 +1,22 @@
1783 + #!/bin/bash
1784 + ## BEGIN INIT INFO
1785 +-# Provides: sandbox
1786 ++# Provides: sesandbox
1787 + # Default-Start: 3 4 5
1788 + # Default-Stop: 0 1 2 3 4 6
1789 + # Required-Start:
1790 + #
1791 + ## END INIT INFO
1792 +-# sandbox: Set up / mountpoint to be shared, /var/tmp, /tmp, /home/sandbox unshared
1793 ++# sesandbox: Set up / mountpoint to be shared, /var/tmp, /tmp, /home/sesandbox unshared
1794 + #
1795 + # chkconfig: 345 1 99
1796 + #
1797 +-# Description: sandbox and other apps that want to use pam_namespace
1798 ++# Description: sesandbox and other apps that want to use pam_namespace
1799 + # on /var/tmp, /tmp and home directories, requires this script
1800 + # to be run at boot time.
1801 + # This script sets up the / mount point and all of its
1802 + # subdirectories as shared. The script sets up
1803 + # /tmp, /var/tmp, /home and any homedirs listed in
1804 +-# /etc/sysconfig/sandbox and all of their subdirectories
1805 ++# /etc/sysconfig/sesandbox and all of their subdirectories
1806 + # as unshared.
1807 + # All processes that use pam_namespace will see
1808 + # modifications to the global mountspace, except for the
1809 +@@ -28,14 +28,14 @@
1810 +
1811 + HOMEDIRS="/home"
1812 +
1813 +-. /etc/sysconfig/sandbox
1814 ++. /etc/sysconfig/sesandbox
1815 +
1816 +-LOCKFILE=/var/lock/subsys/sandbox
1817 ++LOCKFILE=/var/lock/subsys/sesandbox
1818 +
1819 + base=${0##*/}
1820 +
1821 + start() {
1822 +- echo -n "Starting sandbox"
1823 ++ echo -n "Starting sesandbox"
1824 +
1825 + [ -f "$LOCKFILE" ] && return 1
1826 +
1827 +@@ -54,7 +54,7 @@
1828 + }
1829 +
1830 + stop() {
1831 +- echo -n "Stopping sandbox"
1832 ++ echo -n "Stopping sesandbox"
1833 +
1834 + [ -f "$LOCKFILE" ] || return 1
1835 + }
1836 +diff -uNr policycoreutils-2.0.85.orig/sandbox/sandboxX.sh policycoreutils-2.0.85/sandbox/sandboxX.sh
1837 +--- policycoreutils-2.0.85.orig/sandbox/sandboxX.sh 2011-07-13 18:35:00.498002303 +0200
1838 ++++ policycoreutils-2.0.85/sandbox/sandboxX.sh 2011-07-13 18:40:28.382002312 +0200
1839 +@@ -1,13 +1,13 @@
1840 + #!/bin/bash
1841 + context=`id -Z | secon -t -l -P`
1842 +-export TITLE="Sandbox $context -- `grep ^#TITLE: ~/.sandboxrc | /usr/bin/cut -b8-80`"
1843 ++export TITLE="Sandbox $context -- `grep ^#TITLE: ~/.sesandboxrc | /usr/bin/cut -b8-80`"
1844 + export SCREENSIZE="1000x700"
1845 + #export SCREENSIZE=`xdpyinfo | awk '/dimensions/ { print $2 }'`
1846 + trap "exit 0" HUP
1847 +
1848 + (/usr/bin/Xephyr -title "$TITLE" -terminate -screen $SCREENSIZE -displayfd 5 5>&1 2>/dev/null) | while read D; do
1849 + export DISPLAY=:$D
1850 +- python -c 'import gtk, os, commands; commands.getstatusoutput("%s/.sandboxrc" % os.environ["HOME"])'
1851 ++ python -c 'import gtk, os, commands; commands.getstatusoutput("%s/.sesandboxrc" % os.environ["HOME"])'
1852 + export EXITCODE=$?
1853 + kill -HUP 0
1854 + break
1855 +diff -uNr policycoreutils-2.0.85.orig/sandbox/test_sandbox.py policycoreutils-2.0.85/sandbox/test_sandbox.py
1856 +--- policycoreutils-2.0.85.orig/sandbox/test_sandbox.py 2011-07-13 18:35:00.498002303 +0200
1857 ++++ policycoreutils-2.0.85/sandbox/test_sandbox.py 2011-07-13 18:42:21.058002316 +0200
1858 +@@ -19,73 +19,73 @@
1859 + '"Sandbox should have succeeded for this test %r' % err)
1860 +
1861 + def test_simple_success(self):
1862 +- "Verify that we can read file descriptors handed to sandbox"
1863 ++ "Verify that we can read file descriptors handed to sesandbox"
1864 + p1 = Popen(['cat', '/etc/passwd'], stdout = PIPE)
1865 +- p2 = Popen(['sandbox', 'grep', 'root'], stdin = p1.stdout, stdout=PIPE)
1866 ++ p2 = Popen(['sesandbox', 'grep', 'root'], stdin = p1.stdout, stdout=PIPE)
1867 + out, err = p2.communicate()
1868 + self.assert_('root' in out)
1869 +
1870 + def test_cant_kill(self):
1871 +- "Verify that we cannot send kill signal in the sandbox"
1872 ++ "Verify that we cannot send kill signal in the sesandbox"
1873 + pid = os.getpid()
1874 +- p = Popen(['sandbox', 'kill', '-HUP', str(pid)], stdout=PIPE, stderr=PIPE)
1875 ++ p = Popen(['sesandbox', 'kill', '-HUP', str(pid)], stdout=PIPE, stderr=PIPE)
1876 + out, err = p.communicate()
1877 + self.assertDenied(err)
1878 +
1879 + def test_cant_ping(self):
1880 +- "Verify that we can't ping within the sandbox"
1881 +- p = Popen(['sandbox', 'ping', '-c 1 ', '127.0.0.1'], stdout=PIPE, stderr=PIPE)
1882 ++ "Verify that we can't ping within the sesandbox"
1883 ++ p = Popen(['sesandbox', 'ping', '-c 1 ', '127.0.0.1'], stdout=PIPE, stderr=PIPE)
1884 + out, err = p.communicate()
1885 + self.assertDenied(err)
1886 +
1887 + def test_cant_mkdir(self):
1888 +- "Verify that we can't mkdir within the sandbox"
1889 +- p = Popen(['sandbox', 'mkdir', '~/test'], stdout=PIPE, stderr=PIPE)
1890 ++ "Verify that we can't mkdir within the sesandbox"
1891 ++ p = Popen(['sesandbox', 'mkdir', '~/test'], stdout=PIPE, stderr=PIPE)
1892 + out, err = p.communicate()
1893 + self.assertFailure(p.returncode)
1894 +
1895 + def test_cant_list_homedir(self):
1896 +- "Verify that we can't list homedir within the sandbox"
1897 +- p = Popen(['sandbox', 'ls', '~'], stdout=PIPE, stderr=PIPE)
1898 ++ "Verify that we can't list homedir within the sesandbox"
1899 ++ p = Popen(['sesandbox', 'ls', '~'], stdout=PIPE, stderr=PIPE)
1900 + out, err = p.communicate()
1901 + self.assertFailure(p.returncode)
1902 +
1903 + def test_cant_send_mail(self):
1904 +- "Verify that we can't send mail within the sandbox"
1905 +- p = Popen(['sandbox', 'mail'], stdout=PIPE, stderr=PIPE)
1906 ++ "Verify that we can't send mail within the sesandbox"
1907 ++ p = Popen(['sesandbox', 'mail'], stdout=PIPE, stderr=PIPE)
1908 + out, err = p.communicate()
1909 + self.assertDenied(err)
1910 +
1911 + def test_cant_sudo(self):
1912 +- "Verify that we can't run sudo within the sandbox"
1913 +- p = Popen(['sandbox', 'sudo'], stdout=PIPE, stderr=PIPE)
1914 ++ "Verify that we can't run sudo within the sesandbox"
1915 ++ p = Popen(['sesandbox', 'sudo'], stdout=PIPE, stderr=PIPE)
1916 + out, err = p.communicate()
1917 + self.assertFailure(p.returncode)
1918 +
1919 + def test_mount(self):
1920 + "Verify that we mount a file system"
1921 +- p = Popen(['sandbox', '-M', 'id'], stdout=PIPE, stderr=PIPE)
1922 ++ p = Popen(['sesandbox', '-M', 'id'], stdout=PIPE, stderr=PIPE)
1923 + out, err = p.communicate()
1924 + self.assertSuccess(p.returncode, err)
1925 +
1926 + def test_set_level(self):
1927 + "Verify that we set level a file system"
1928 +- p = Popen(['sandbox', '-l', 's0', 'id'], stdout=PIPE, stderr=PIPE)
1929 ++ p = Popen(['sesandbox', '-l', 's0', 'id'], stdout=PIPE, stderr=PIPE)
1930 + out, err = p.communicate()
1931 + self.assertSuccess(p.returncode, err)
1932 +
1933 + def test_homedir(self):
1934 + "Verify that we set homedir a file system"
1935 +- homedir = mkdtemp(dir=".", prefix=".sandbox_test")
1936 +- p = Popen(['sandbox', '-H', homedir, '-M', 'id'], stdout=PIPE, stderr=PIPE)
1937 ++ homedir = mkdtemp(dir=".", prefix=".sesandbox_test")
1938 ++ p = Popen(['sesandbox', '-H', homedir, '-M', 'id'], stdout=PIPE, stderr=PIPE)
1939 + out, err = p.communicate()
1940 + shutil.rmtree(homedir)
1941 + self.assertSuccess(p.returncode, err)
1942 +
1943 + def test_tmpdir(self):
1944 + "Verify that we set tmpdir a file system"
1945 +- tmpdir = mkdtemp(dir="/tmp", prefix=".sandbox_test")
1946 +- p = Popen(['sandbox', '-T', tmpdir, '-M', 'id'], stdout=PIPE, stderr=PIPE)
1947 ++ tmpdir = mkdtemp(dir="/tmp", prefix=".sesandbox_test")
1948 ++ p = Popen(['sesandbox', '-T', tmpdir, '-M', 'id'], stdout=PIPE, stderr=PIPE)
1949 + out, err = p.communicate()
1950 + shutil.rmtree(tmpdir)
1951 + self.assertSuccess(p.returncode, err)
1952
1953 diff --git a/sys-apps/policycoreutils/metadata.xml b/sys-apps/policycoreutils/metadata.xml
1954 new file mode 100644
1955 index 0000000..87cddb0
1956 --- /dev/null
1957 +++ b/sys-apps/policycoreutils/metadata.xml
1958 @@ -0,0 +1,17 @@
1959 +<?xml version="1.0" encoding="UTF-8"?>
1960 +<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
1961 +<pkgmetadata>
1962 + <herd>selinux</herd>
1963 + <longdescription>
1964 + Policycoreutils contains the policy core utilities that are required
1965 + for basic operation of a SELinux system. These utilities include
1966 + load_policy to load policies, setfiles to label filesystems, newrole
1967 + to switch roles, and run_init to run /etc/init.d scripts in the proper
1968 + context.
1969 +
1970 + Gentoo-specific tools include rlpkg for relabeling packages by name,
1971 + avc_toggle to toggle between enforcing and permissive modes, and
1972 + avc_enforcing to query the current mode of the system, enforcing or
1973 + permissive.
1974 + </longdescription>
1975 +</pkgmetadata>
1976
1977 diff --git a/sys-apps/policycoreutils/policycoreutils-2.0.85.ebuild b/sys-apps/policycoreutils/policycoreutils-2.0.85.ebuild
1978 new file mode 100644
1979 index 0000000..cc8b09a
1980 --- /dev/null
1981 +++ b/sys-apps/policycoreutils/policycoreutils-2.0.85.ebuild
1982 @@ -0,0 +1,116 @@
1983 +# Copyright 1999-2011 Gentoo Foundation
1984 +# Distributed under the terms of the GNU General Public License v2
1985 +# $Header: /var/cvsroot/gentoo-x86/sys-apps/policycoreutils/policycoreutils-2.0.82.ebuild,v 1.4 2011/06/16 01:33:17 blueness Exp $
1986 +
1987 +EAPI="3"
1988 +PYTHON_DEPEND="*"
1989 +PYTHON_USE_WITH="xml"
1990 +SUPPORT_PYTHON_ABIS="1"
1991 +RESTRICT_PYTHON_ABIS="*-jython"
1992 +
1993 +inherit multilib python toolchain-funcs eutils
1994 +
1995 +EXTRAS_VER="1.20"
1996 +SEMNG_VER="2.0.46"
1997 +SELNX_VER="2.0.98"
1998 +SEPOL_VER="2.0.42"
1999 +
2000 +IUSE=""
2001 +
2002 +DESCRIPTION="SELinux core utilities"
2003 +HOMEPAGE="http://userspace.selinuxproject.org"
2004 +SRC_URI="http://userspace.selinuxproject.org/releases/20101221/devel/${P}.tar.gz
2005 + mirror://gentoo/policycoreutils-extra-${EXTRAS_VER}.tar.bz2
2006 + http://git.overlays.gentoo.org/gitweb/?p=proj/hardened-dev.git;a=blob_plain;f=sys-apps/policycoreutils/files/policycoreutils-2.0.85-python3.tar.gz"
2007 +
2008 +LICENSE="GPL-2"
2009 +SLOT="0"
2010 +KEYWORDS="~amd64 ~x86"
2011 +
2012 +COMMON_DEPS=">=sys-libs/libselinux-${SELNX_VER}[python]
2013 + >=sys-libs/glibc-2.4
2014 + >=sys-process/audit-1.5.1
2015 + >=sys-libs/libcap-1.10-r10
2016 + sys-libs/pam
2017 + >=sys-libs/libsemanage-${SEMNG_VER}[python]
2018 + sys-libs/libcap-ng
2019 + >=sys-libs/libsepol-${SEPOL_VER}
2020 + sys-devel/gettext"
2021 +
2022 +# pax-utils for scanelf used by rlpkg
2023 +RDEPEND="${COMMON_DEPS}
2024 + dev-python/sepolgen
2025 + app-misc/pax-utils"
2026 +
2027 +DEPEND="${COMMON_DEPS}"
2028 +
2029 +S2=${WORKDIR}/policycoreutils-extra
2030 +
2031 +src_prepare() {
2032 + # rlpkg is more useful than fixfiles
2033 + sed -i -e '/^all/s/fixfiles//' "${S}/scripts/Makefile" \
2034 + || die "fixfiles sed 1 failed"
2035 + sed -i -e '/fixfiles/d' "${S}/scripts/Makefile" \
2036 + || die "fixfiles sed 2 failed"
2037 + # We currently do not support MCS, so the sandbox code in policycoreutils
2038 + # is not usable yet. However, work for MCS is on the way and a reported
2039 + # vulnerability (bug #374897) might go by unnoticed if we ignore it now.
2040 + # As such, we will
2041 + # - prepare support for switching name from "sandbox" to "sesandbox"
2042 + epatch "${FILESDIR}/policycoreutils-2.0.85-sesandbox.patch"
2043 + # - patch the sandbox and seunshare code to fix the vulnerability
2044 + # (uses, with permission, extract from
2045 + # http://pkgs.fedoraproject.org/gitweb/?p=policycoreutils.git;a=blob_plain;f=policycoreutils-rhat.patch;hb=HEAD)
2046 + epatch "${FILESDIR}/policycoreutils-2.0.85-fix-seunshare-vuln.patch"
2047 + # But for now, disable building sandbox code
2048 + sed -i -e 's/sandbox //' "${S}/Makefile" || die "failed removing sandbox"
2049 + # Overwrite gl.po, id.po and et.po with valid PO file
2050 + cp "${S}/po/sq.po" "${S}/po/gl.po" || die "failed to copy ${S}/po/sq.po to gl.po"
2051 + cp "${S}/po/sq.po" "${S}/po/id.po" || die "failed to copy ${S}/po/sq.po to id.po"
2052 + cp "${S}/po/sq.po" "${S}/po/et.po" || die "failed to copy ${S}/po/sq.po to et.po"
2053 + # Fixed scripts for Python 3 support
2054 + cp "${WORKDIR}/seobject.py" "${S}/semanage/seobject.py" || die "failed to copy seobject.py"
2055 + cp "${WORKDIR}/semanage" "${S}/semanage/semanage" || die "failed to copy semanage"
2056 + cp "${WORKDIR}/chcat" "${S}/scripts/chcat" || die "failed to copy chcat"
2057 + cp "${WORKDIR}/audit2allow" "${S}/audit2allow/audit2allow" || die "failed to copy audit2allow"
2058 + cp "${WORKDIR}/rlpkg" "${S2}/scripts/rlpkg" || die "failed to copy rlpkg"
2059 +}
2060 +
2061 +src_compile() {
2062 + python_copy_sources semanage sandbox
2063 + building() {
2064 + einfo "Compiling policycoreutils"
2065 + emake -C "${S}" AUDIT_LOG_PRIVS="y" CC="$(tc-getCC)" PYLIBVER="python$(python_get_version)" || die
2066 + einfo "Compiling policycoreutils-extra"
2067 + emake -C "${S2}" AUDIT_LOG_PRIVS="y" CC="$(tc-getCC)" PYLIBVER="python$(python_get_version)" || die
2068 + }
2069 + python_execute_function -s --source-dir semanage building
2070 +}
2071 +
2072 +src_install() {
2073 + # Python scripts are present in many places. There are no extension modules.
2074 + installation() {
2075 + einfo "Installing policycoreutils"
2076 + emake -C "${S}" DESTDIR="${T}/images/${PYTHON_ABI}" AUDIT_LOG_PRIV="y" PYLIBVER="python$(python_get_version)" install || return 1
2077 +
2078 + einfo "Installing policycoreutils-extra"
2079 + emake -C "${S2}" DESTDIR="${T}/images/${PYTHON_ABI}" SHLIBDIR="${D}$(get_libdir)/rc" install || return 1
2080 + }
2081 + python_execute_function installation
2082 + python_merge_intermediate_installation_images "${T}/images"
2083 +
2084 + # remove redhat-style init script
2085 + rm -fR "${D}/etc/rc.d"
2086 +
2087 + # compatibility symlinks
2088 + dosym /sbin/setfiles /usr/sbin/setfiles
2089 + dosym /$(get_libdir)/rc/runscript_selinux.so /$(get_libdir)/rcscripts/runscript_selinux.so
2090 +}
2091 +
2092 +pkg_postinst() {
2093 + python_mod_optimize seobject.py
2094 +}
2095 +
2096 +pkg_postrm() {
2097 + python_mod_cleanup seobject.py
2098 +}