git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #36978 from xeji/selinux-2-7

SELinux libs and tools: 2.4 -> 2.7

commit00a43001d44b48ca239aeb4292a8609cdc228118 authorJörg Thalheim <Mic92@users.noreply.github.com> dateTue 27 Mar 2018, 10:29 (9 years ago) parent4167600eb828c6
11 files changed+191−129
pkgs/os-specific/linux/checkpolicy/default.nix+2−11 pkgs/os-specific/linux/libselinux/default.nix+11−25 pkgs/os-specific/linux/libsemanage/default.nix+15−13 pkgs/os-specific/linux/libsepol/default.nix+5−4 pkgs/os-specific/linux/policycoreutils/default.nix+11−42 pkgs/os-specific/linux/policycoreutils/fix-printf-type.patch−12 pkgs/os-specific/linux/selinux-python/default.nix+49 pkgs/os-specific/linux/selinux-sandbox/default.nix+61 pkgs/os-specific/linux/setools/default.nix+28−21 pkgs/os-specific/linux/systemd/default.nix+2−1 pkgs/top-level/all-packages.nix+7
pkgs/os-specific/linux/checkpolicy/default.nix+2−11
@@ -2,27 +2,18 @@
22
33stdenv.mkDerivation rec {
44 name = "checkpolicy-${version}";
5− version = "2.4";
5+ version = "2.7";
66 inherit (libsepol) se_release se_url;
77
88 src = fetchurl {
99 url = "${se_url}/${se_release}/checkpolicy-${version}.tar.gz";
10− sha256 = "1m5wjm43lzp6bld8higsvdm2dkddydihhwv9qw2w9r4dm0largcv";
10+ sha256 = "009j9jc0hi4l7k8f21hn8fm25n0mqgzdpd4nk30nds6d3nglf4sl";
1111 };
1212
13− # Don't build tests
14− postPatch = ''
15− sed '/-C test/d' -i Makefile
16− sed '1i#include <ctype.h>' -i checkpolicy.c
17− '';
18−
1913 nativeBuildInputs = [ bison flex ];
2014 buildInputs = [ libsepol ];
2115
22− NIX_CFLAGS_COMPILE = "-fstack-protector-all";
23−
2416 preBuild = ''
25− makeFlagsArray+=("LEX=flex")
2617 makeFlagsArray+=("LIBDIR=${libsepol}/lib")
2718 makeFlagsArray+=("PREFIX=$out")
2819 '';
pkgs/os-specific/linux/libselinux/default.nix+11−25
@@ -1,4 +1,4 @@
1−{ stdenv, fetchurl, fetchpatch, pkgconfig, libsepol, pcre
1+{ stdenv, fetchurl, pcre, pkgconfig, libsepol
22, enablePython ? true, swig ? null, python ? null
33}:
44
@@ -8,48 +8,34 @@ with stdenv.lib;
88
99stdenv.mkDerivation rec {
1010 name = "libselinux-${version}";
11− version = "2.4";
11+ version = "2.7";
1212 inherit (libsepol) se_release se_url;
1313
1414 src = fetchurl {
1515 url = "${se_url}/${se_release}/libselinux-${version}.tar.gz";
16− sha256 = "0yqg73ns97jwjh1iyv0jr5qxb8k5sqq5ywfkx11lzfn5yj8k0126";
16+ sha256 = "0mwcq78v6ngbq06xmb9dvilpg0jnl2vs9fgrpakhmmiskdvc1znh";
1717 };
1818
1919 nativeBuildInputs = [ pkgconfig ];
2020 buildInputs = [ libsepol pcre ]
2121 ++ optionals enablePython [ swig python ];
2222
23− # Avoid this false warning:
24− # avc_internal.c: In function 'avc_netlink_receive':
25− # avc_internal.c:105:25: error: cast increases required alignment of target type [-Werror=cast-align]
26− # struct nlmsghdr *nlh = (struct nlmsghdr *)buf;
27− # ^
28−
29− NIX_CFLAGS_COMPILE = "-std=gnu89 -Wno-error=cast-align";
30−
31− # Unreleased upstream patch that fixes Python package issue arising
32− # from recent SWIG changes.
33− patches = optional enablePython (fetchpatch {
34− name = "fix-python-swig.patch";
35− url = "https://github.com/SELinuxProject/selinux/commit/a9604c30a5e2f71007d31aa6ba41cf7b95d94822.patch";
36− sha256 = "0mjrclh0sd8m7vq0wvl6pg29ss415j3kn0266v8ixy4fprafagfp";
37− stripLen = 1;
38− });
23+ # drop fortify here since package uses it by default, leading to compile error:
24+ # command-line>:0:0: error: "_FORTIFY_SOURCE" redefined [-Werror]
25+ hardeningDisable = [ "fortify" ];
3926
4027 postPatch = optionalString enablePython ''
4128 sed -i -e 's|\$(LIBDIR)/libsepol.a|${libsepol}/lib/libsepol.a|' src/Makefile
42− ''
43− + ''
44− sed '1i#include <sys/uio.h>' -i src/setrans_client.c
4529 '';
4630
31+ # fix install locations
4732 preBuild = ''
48− # Build fails without this precreated
49− mkdir -p $out/include
50−
5133 makeFlagsArray+=("PREFIX=$out")
5234 makeFlagsArray+=("DESTDIR=$out")
35+ makeFlagsArray+=("MAN3DIR=$out/share/man/man3")
36+ makeFlagsArray+=("MAN5DIR=$out/share/man/man5")
37+ makeFlagsArray+=("MAN8DIR=$out/share/man/man8")
38+ makeFlagsArray+=("PYSITEDIR=$out/lib/${python.libPrefix}/site-packages")
5339 '';
5440
5541 installTargets = [ "install" ] ++ optional enablePython "install-pywrap";
pkgs/os-specific/linux/libsemanage/default.nix+15−13
@@ -1,31 +1,33 @@
1−{ stdenv, fetchurl, bison, flex, libsepol, libselinux, ustr, bzip2, libaudit }:
1+{ stdenv, fetchurl, pkgconfig, bison, flex, libsepol, libselinux, bzip2, libaudit
2+, enablePython ? true, swig ? null, python ? null
3+}:
4+
5+with stdenv.lib;
26
37stdenv.mkDerivation rec {
48 name = "libsemanage-${version}";
5− version = "2.4";
9+ version = "2.7";
610 inherit (libsepol) se_release se_url;
711
812 src = fetchurl {
913 url = "${se_url}/${se_release}/libsemanage-${version}.tar.gz";
10− sha256 = "1134ka4mi4387ac5yv68bpp2y7ln5xxhwp07xhqnay0nxzjaqk0s";
14+ sha256 = "0xnlp1yg8b1aqc6kq3pss1i1nl06rfj4x4pyl5blasnf2ivlgs87";
1115 };
1216
13− nativeBuildInputs = [ bison flex ];
14− buildInputs = [ libsepol libselinux ustr bzip2 libaudit ];
15−
16− NIX_CFLAGS_COMPILE = [
17− "-fstack-protector-all"
18− "-std=gnu89"
19− # these were added to fix build with gcc7. review on update
20− "-Wno-error=format-truncation"
21− "-Wno-error=implicit-fallthrough"
22− ];
17+ nativeBuildInputs = [ bison flex pkgconfig ];
18+ buildInputs = [ libsepol libselinux bzip2 libaudit ]
19+ ++ optionals enablePython [ swig python ];
2320
2421 preBuild = ''
2522 makeFlagsArray+=("PREFIX=$out")
2623 makeFlagsArray+=("DESTDIR=$out")
24+ makeFlagsArray+=("MAN3DIR=$out/share/man/man3")
25+ makeFlagsArray+=("MAN5DIR=$out/share/man/man5")
26+ makeFlagsArray+=("PYSITEDIR=$out/lib/${python.libPrefix}/site-packages")
2727 '';
2828
29+ installTargets = [ "install" ] ++ optionals enablePython [ "install-pywrap" ];
30+
2931 meta = libsepol.meta // {
3032 description = "Policy management tools for SELinux";
3133 license = stdenv.lib.licenses.lgpl21;
pkgs/os-specific/linux/libsepol/default.nix+5−4
@@ -2,13 +2,13 @@
22
33stdenv.mkDerivation rec {
44 name = "libsepol-${version}";
5− version = "2.4";
6− se_release = "20150202";
5+ version = "2.7";
6+ se_release = "20170804";
77 se_url = "https://raw.githubusercontent.com/wiki/SELinuxProject/selinux/files/releases";
88
99 src = fetchurl {
1010 url = "${se_url}/${se_release}/libsepol-${version}.tar.gz";
11− sha256 = "0ncnwhpc1gx4hrrb822fqkwy5h75zzngsrfkd5mlqh1jk7aib419";
11+ sha256 = "1rzr90d3f1g5wy1b8sh6fgnqb9migys2zgpjmpakn6lhxkc3p7fn";
1212 };
1313
1414 nativeBuildInputs = [ flex ];
@@ -16,9 +16,10 @@ stdenv.mkDerivation rec {
1616 preBuild = ''
1717 makeFlagsArray+=("PREFIX=$out")
1818 makeFlagsArray+=("DESTDIR=$out")
19+ makeFlagsArray+=("MAN8DIR=$out/share/man/man8")
20+ makeFlagsArray+=("MAN3DIR=$out/share/man/man3")
1921 '';
2022
21− NIX_CFLAGS_COMPILE = [ "-Wno-error=implicit-fallthrough" ];
2223
2324 passthru = { inherit se_release se_url; };
2425
pkgs/os-specific/linux/policycoreutils/default.nix+11−42
@@ -1,64 +1,33 @@
1−{ stdenv, fetchurl, pythonPackages, gettext
2−, setools, libsepol, libselinux, libcap_ng, libsemanage, sepolgen
3−}:
1+{ stdenv, fetchurl, gettext, libsepol, libselinux, libsemanage }:
42
53stdenv.mkDerivation rec {
64 name = "policycoreutils-${version}";
7− version = "2.4";
5+ version = "2.7";
86 inherit (libsepol) se_release se_url;
97
108 src = fetchurl {
119 url = "${se_url}/${se_release}/policycoreutils-${version}.tar.gz";
12− sha256 = "0y9l9k60iy21hj0lcvfdfxs1fxydg6d3pxp9rhy7hwr4y5vgh6dq";
10+ sha256 = "1x742c7lkw30namhkw87yg7z384qzqjz0pvmqs0lk19v6958l6qa";
1311 };
1412
15− patches = [ ./fix-printf-type.patch ];
16−
1713 postPatch = ''
18− # Fix references to libsepol.a
19− find . -name Makefile -exec sed -i 's,[^ ]*/libsepol.a,${libsepol}/lib/libsepol.a,g' {} \;
20−
2114 # Fix install references
22− substituteInPlace po/Makefile --replace /usr/bin/install install
23−
24− # Fix references to /usr/share
25− grep -r '/usr/share' | awk -F: '{print $1}' | xargs sed -i "s,\(\$(DESTDIR)\)*/usr/share,$out/share,g"
26−
27− # Fix sepolicy install
28− sed -i "s,\(setup.py install\).*,\1 --prefix=$out,g" sepolicy/Makefile
29−
30− # Fix setuid install
31− sed -i 's|-m 4755|-m 755|' sandbox/Makefile
15+ substituteInPlace po/Makefile \
16+ --replace /usr/bin/install install --replace /usr/share /share
17+ substituteInPlace newrole/Makefile --replace /usr/share /share
3218 '';
3319
34− nativeBuildInputs = [ pythonPackages.python gettext ];
35− buildInputs = [ setools libsepol libselinux libcap_ng libsemanage ];
36− pythonPath = [ libselinux sepolgen ];
20+ nativeBuildInputs = [ gettext ];
21+ buildInputs = [ libsepol libselinux libsemanage ];
3722
3823 preBuild = ''
3924 makeFlagsArray+=("PREFIX=$out")
4025 makeFlagsArray+=("DESTDIR=$out")
26+ makeFlagsArray+=("BASHCOMPLETIONDIR=$out/share/bash-completion/completions")
27+ makeFlagsArray+=("LOCALEDIR=$out/share/locale")
28+ makeFlagsArray+=("MAN5DIR=$out/share/man/man5")
4129 '';
4230
43− # Creation of the system-config-selinux directory is broken
44− preInstall = ''
45− mkdir -p $out/share/system-config-selinux
46− '';
47−
48− # Fix the python scripts to include paths to libraries
49− # NOTE: We are not using wrapPythonPrograms or makeWrapper as these scripts
50− # purge the environment as a security measure
51− postInstall = ''
52− grep -r '#!.*python' $out/bin | awk -F: '{print $1}' | xargs sed -i "1a \
53− import sys; \
54− sys.path.append('$(toPythonPath "$out")'); \
55− ${stdenv.lib.flip stdenv.lib.concatMapStrings pythonPath (lib: ''
56− sys.path.append('$(toPythonPath "${lib}")'); \
57− '')}"
58− '';
59−
60− NIX_CFLAGS_COMPILE = "-fstack-protector-all";
61−
6231 meta = with stdenv.lib; {
6332 description = "SELinux policy core utilities";
6433 license = licenses.gpl2;
pkgs/os-specific/linux/policycoreutils/fix-printf-type.patchdeleted−12
@@ -1,12 +0,0 @@
1−diff -Nru policycoreutils-2.4/setfiles/restore.c policycoreutils-2.4.new/setfiles/restore.c
2−--- policycoreutils-2.4/setfiles/restore.c 2015-02-02 09:38:10.000000000 -0500
3−+++ policycoreutils-2.4.new/setfiles/restore.c 2015-08-29 20:44:13.693023222 -0400
4−@@ -118,7 +118,7 @@
5− r_opts->count++;
6− if (r_opts->count % STAR_COUNT == 0) {
7− if (r_opts->progress == 1) {
8−- fprintf(stdout, "\r%luk", (size_t) r_opts->count / STAR_COUNT );
9−+ fprintf(stdout, "\r%zuk", (size_t) r_opts->count / STAR_COUNT );
10− } else {
11− if (r_opts->nfile > 0) {
12− progress = (r_opts->count < r_opts->nfile) ? (100.0 * r_opts->count / r_opts->nfile) : 100;
pkgs/os-specific/linux/selinux-python/default.nixnew file+49
@@ -0,0 +1,49 @@
1+{ stdenv, fetchurl, python3
2+, libselinux, libsemanage, libsepol, setools }:
3+
4+# this is python3 only because setools only supports python3
5+
6+with stdenv.lib;
7+with python3.pkgs;
8+
9+stdenv.mkDerivation rec {
10+ name = "selinux-python-${version}";
11+ version = "2.7";
12+ se_release = "20170804";
13+ se_url = "https://raw.githubusercontent.com/wiki/SELinuxProject/selinux/files/releases";
14+
15+ src = fetchurl {
16+ url = "${se_url}/${se_release}/selinux-python-${version}.tar.gz";
17+ sha256 = "1va0y4b7cah7rprh04b3ylmwqgnivpkw5z2zw68nrafdbsbcn5s2";
18+ };
19+
20+ nativeBuildInputs = [ wrapPython ];
21+ buildInputs = [ libsepol python3 ];
22+ propagatedBuildInputs = [ libselinux libsemanage setools ipy ];
23+
24+ postPatch = ''
25+ substituteInPlace sepolicy/Makefile --replace "echo --root" "echo --prefix"
26+ '';
27+
28+ preBuild = ''
29+ makeFlagsArray+=("PREFIX=$out")
30+ makeFlagsArray+=("DESTDIR=$out")
31+ makeFlagsArray+=("LOCALEDIR=$out/share/locale")
32+ makeFlagsArray+=("LIBSEPOLA=${libsepol}/lib/libsepol.a")
33+ makeFlagsArray+=("BASHCOMPLETIONDIR=$out/share/bash-completion/completions")
34+ makeFlagsArray+=("PYTHON=${python3}/bin/python")
35+ makeFlagsArray+=("PYTHONLIBDIR=lib/${python3.libPrefix}/site-packages")
36+ '';
37+
38+ postFixup = ''
39+ wrapPythonPrograms
40+ '';
41+
42+ meta = {
43+ description = "SELinux policy core utilities written in Python";
44+ license = licenses.gpl2;
45+ homepage = https://selinuxproject.org;
46+ platforms = platforms.linux;
47+ };
48+}
49+
pkgs/os-specific/linux/selinux-sandbox/default.nixnew file+61
@@ -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+
pkgs/os-specific/linux/setools/default.nix+28−21
@@ -1,35 +1,42 @@
1−{ stdenv, fetchFromGitHub, autoreconfHook, pkgconfig, bison, flex
2−, python, swig2, tcl, libsepol, libselinux, libxml2, sqlite, bzip2 }:
1+{ stdenv, fetchFromGitHub, bison, flex, python3 , swig
2+, libsepol, libselinux, checkpolicy
3+, withGraphics ? false
4+}:
35
4−stdenv.mkDerivation rec {
5− name = "setools-2015-02-12";
6+with stdenv.lib;
7+with python3.pkgs;
8+
9+buildPythonApplication rec {
10+ pname = "setools";
11+ version = "2017-11-10";
612
713 src = fetchFromGitHub {
814 owner = "TresysTechnology";
9− repo = "setools3";
10− rev = "f1e5b208d507171968ca4d2eeefd7980f1004a3c";
11− sha256 = "02gzy2kpszhr13f0d9qfiwh2hj4201g2x366j53v5n5qz481aykd";
15+ repo = pname;
16+ rev = "a1aa0f33f5c428d3f9fe82960ed5de36f38047f7";
17+ sha256 = "0iyj35fff93cprjkzbkg9dn5xz8dg5h2kjx3476fl625nxxskndn";
1218 };
1319
14− configureFlags = [
15− "--disable-gui"
16− "--with-sepol-devel=${libsepol}"
17− "--with-selinux-devel=${libselinux}"
18− "--with-tcl=${tcl}/lib"
19− ];
20+ nativeBuildInputs = [ bison flex ];
21+ buildInputs = [ libsepol swig ];
22+ propagatedBuildInputs = [ enum34 libselinux networkx ]
23+ ++ optionals withGraphics [ pyqt5 ];
2024
21− hardeningDisable = [ "format" ];
25+ checkInputs = [ tox checkpolicy ];
26+ preCheck = ''
27+ export CHECKPOLICY=${checkpolicy}/bin/checkpolicy
28+ '';
2229
23− NIX_CFLAGS_COMPILE = "-fstack-protector-all";
24− NIX_LDFLAGS = "-L${libsepol}/lib -L${libselinux}/lib";
30+ setupPyBuildFlags = [ "-i" ];
2531
26− nativeBuildInputs = [ autoreconfHook pkgconfig python swig2 bison flex ];
27− buildInputs = [ tcl libxml2 sqlite bzip2 ];
32+ preBuild = ''
33+ export SEPOL="${libsepol}/lib/libsepol.a"
34+ '';
2835
2936 meta = {
3037 description = "SELinux Tools";
31− homepage = http://oss.tresys.com/projects/setools/;
32− license = stdenv.lib.licenses.gpl2;
33− platforms = stdenv.lib.platforms.linux;
38+ homepage = https://github.com/TresysTechnology/setools/wiki;
39+ license = licenses.gpl2;
40+ platforms = platforms.linux;
3441 };
3542}
pkgs/os-specific/linux/systemd/default.nix+2−1
@@ -10,6 +10,7 @@
1010, getent
1111, hostPlatform
1212, buildPackages
13+, withSelinux ? false, libselinux
1314}:
1415
1516assert stdenv.isLinux;
@@ -44,7 +45,7 @@ in stdenv.mkDerivation rec {
4445 iptables gnu-efi
4546 # This is actually native, but we already pull it from buildPackages
4647 pythonLxmlEnv
47− ];
48+ ] ++ stdenv.lib.optionals withSelinux [ libselinux ];
4849
4950 #dontAddPrefix = true;
5051
pkgs/top-level/all-packages.nix+7
@@ -11393,6 +11393,8 @@ with pkgs;
1139311393
1139411394 sblim-sfcc = callPackage ../development/libraries/sblim-sfcc {};
1139511395
11396+ selinux-sandbox = callPackage ../os-specific/linux/selinux-sandbox { };
11397+
1139611398 serd = callPackage ../development/libraries/serd {};
1139711399
1139811400 serf = callPackage ../development/libraries/serf {};
@@ -20704,6 +20706,11 @@ with pkgs;
2070420706 seafile-shared = callPackage ../misc/seafile-shared { };
2070520707
2070620708 serviio = callPackage ../servers/serviio {};
20709+ selinux-python = callPackage ../os-specific/linux/selinux-python {
20710+ # needs python3 bindings
20711+ libselinux = libselinux.override { python = python3; };
20712+ libsemanage = libsemanage.override { python = python3; };
20713+ };
2070720714
2070820715 slock = callPackage ../misc/screensavers/slock {
2070920716 conf = config.slock.conf or null;