@@ -0,0 +1,61 @@
1+{ stdenv, fetchurl, bash, coreutils, python3
2+, libcap_ng, policycoreutils, selinux-python, dbus
3+, xorgserver, openbox, xmodmap }:
4+
5+# this is python3 only as it depends on selinux-python
6+
7+with stdenv.lib;
8+with python3.pkgs;
9+
10+stdenv.mkDerivation rec {
11+ name = "selinux-sandbox-${version}";
12+ version = "2.7";
13+ se_release = "20170804";
14+
15+ src = fetchurl {
16+ url = "https://raw.githubusercontent.com/wiki/SELinuxProject/selinux/files/releases/${se_release}/selinux-sandbox-${version}.tar.gz";
17+ sha256 = "0hf5chm90iapb42njaps6p5460ys3ajh5446ja544vdbh01n544l";
18+ };
19+
20+ nativeBuildInputs = [ wrapPython ];
21+ buildInputs = [ bash coreutils libcap_ng policycoreutils python3 xorgserver openbox xmodmap dbus ];
22+ propagatedBuildInputs = [ pygobject3 selinux-python ];
23+
24+ postPatch = ''
25+ # Fix setuid install
26+ substituteInPlace Makefile --replace "-m 4755" "-m 755"
27+ substituteInPlace sandboxX.sh \
28+ --replace "#!/bin/sh" "#!${bash}/bin/sh" \
29+ --replace "/usr/share/sandbox/start" "${placeholder "out"}/share/sandbox/start" \
30+ --replace "/usr/bin/cut" "${coreutils}/bin/cut" \
31+ --replace "/usr/bin/Xephyr" "${xorgserver}/bin/Xepyhr" \
32+ --replace "secon" "${policycoreutils}/bin/secon"
33+ substituteInPlace sandbox \
34+ --replace "/usr/sbin/seunshare" "$out/bin/seunshare" \
35+ --replace "/usr/share/sandbox" "$out/share/sandbox" \
36+ --replace "/usr/share/locale" "${policycoreutils}/share/locale" \
37+ --replace "/usr/bin/openbox" "${openbox}/bin/openbox" \
38+ --replace "#!/bin/sh" "#!${bash}/bin/sh" \
39+ --replace "dbus-" "${dbus}/bin/dbus-" \
40+ --replace "/usr/bin/xmodmap" "${xmodmap}/bin/xmodmap" \
41+ --replace "/usr/bin/shred" "${coreutils}/bin/shred" \
42+ --replace "/usr/bin/test" "${coreutils}/bin/test" \
43+ '';
44+
45+ preBuild = ''
46+ makeFlagsArray+=("PREFIX=$out")
47+ makeFlagsArray+=("DESTDIR=$out")
48+ '';
49+
50+ postFixup = ''
51+ wrapPythonPrograms
52+ '';
53+
54+ meta = {
55+ description = "SELinux sandbox utility";
56+ license = licenses.gpl2;
57+ homepage = https://selinuxproject.org;
58+ platforms = platforms.linux;
59+ };
60+}
61+