Commit | Line | Data |
---|---|---|
f269ad25 | 1 | ;;; GNU Guix --- Functional package management for GNU |
ca56021c | 2 | ;;; Copyright © 2016, 2017, 2018 Ricardo Wurmus <rekado@elephly.net> |
bb6c3d23 | 3 | ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr> |
f269ad25 RW |
4 | ;;; |
5 | ;;; This file is part of GNU Guix. | |
6 | ;;; | |
7 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | |
8 | ;;; under the terms of the GNU General Public License as published by | |
9 | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
10 | ;;; your option) any later version. | |
11 | ;;; | |
12 | ;;; GNU Guix is distributed in the hope that it will be useful, but | |
13 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | ;;; GNU General Public License for more details. | |
16 | ;;; | |
17 | ;;; You should have received a copy of the GNU General Public License | |
18 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | |
19 | ||
20 | (define-module (gnu packages selinux) | |
21 | #:use-module ((guix licenses) #:prefix license:) | |
22 | #:use-module (guix packages) | |
23 | #:use-module (guix download) | |
ca56021c | 24 | #:use-module (guix git-download) |
f269ad25 RW |
25 | #:use-module (guix utils) |
26 | #:use-module (guix build-system gnu) | |
4724d729 | 27 | #:use-module (guix build-system python) |
f269ad25 | 28 | #:use-module (gnu packages) |
32be6601 | 29 | #:use-module (gnu packages admin) |
66af08fb | 30 | #:use-module (gnu packages bison) |
c837027d | 31 | #:use-module (gnu packages docbook) |
4724d729 | 32 | #:use-module (gnu packages flex) |
6ef94ecb RW |
33 | #:use-module (gnu packages gettext) |
34 | #:use-module (gnu packages glib) | |
35 | #:use-module (gnu packages linux) | |
36 | #:use-module (gnu packages networking) | |
4724d729 RW |
37 | #:use-module (gnu packages pcre) |
38 | #:use-module (gnu packages pkg-config) | |
39 | #:use-module (gnu packages python) | |
32be6601 | 40 | #:use-module (gnu packages swig) |
c837027d RW |
41 | #:use-module (gnu packages textutils) |
42 | #:use-module (gnu packages xml)) | |
f269ad25 RW |
43 | |
44 | ;; Update the SELinux packages together! | |
45 | ||
46 | (define-public libsepol | |
47 | (package | |
48 | (name "libsepol") | |
ca56021c RW |
49 | (version "2.7") |
50 | (source (let ((release "20170804")) | |
f269ad25 | 51 | (origin |
ca56021c RW |
52 | (method git-fetch) |
53 | (uri (git-reference | |
54 | (url "https://github.com/SELinuxProject/selinux.git") | |
55 | (commit release))) | |
56 | (file-name (string-append "selinux-" release "-checkout")) | |
f269ad25 RW |
57 | (sha256 |
58 | (base32 | |
ca56021c | 59 | "1l1nn8bx08v4cxkw5kb0wgr61rfqj5ra9dh1dy5jslillj93vivq"))))) |
f269ad25 RW |
60 | (build-system gnu-build-system) |
61 | (arguments | |
62 | `(#:tests? #f ; tests require checkpolicy, which requires libsepol | |
63 | #:test-target "test" | |
64 | #:make-flags | |
65 | (let ((out (assoc-ref %outputs "out"))) | |
66 | (list (string-append "PREFIX=" out) | |
67 | (string-append "DESTDIR=" out) | |
68 | (string-append "MAN3DIR=" out "/share/man/man3") | |
69 | (string-append "MAN5DIR=" out "/share/man/man5") | |
70 | (string-append "MAN8DIR=" out "/share/man/man8") | |
71 | (string-append "LDFLAGS=-Wl,-rpath=" out "/lib") | |
72 | "CC=gcc")) | |
73 | #:phases | |
74 | (modify-phases %standard-phases | |
75 | (delete 'configure) | |
76 | (add-after 'unpack 'enter-dir | |
50e87903 RW |
77 | (lambda _ (chdir ,name) #t)) |
78 | (add-after 'enter-dir 'portability | |
79 | (lambda _ | |
80 | (substitute* "src/ibpkeys.c" | |
81 | (("#include \"ibpkey_internal.h\"" line) | |
82 | (string-append line "\n#include <inttypes.h>\n")) | |
83 | (("%#lx") "%#\" PRIx64 \"")) | |
84 | #t))))) | |
f269ad25 RW |
85 | (native-inputs |
86 | `(("flex" ,flex))) | |
87 | (home-page "https://selinuxproject.org/") | |
88 | (synopsis "Library for manipulating SELinux policies") | |
89 | (description | |
90 | "The libsepol library provides an API for the manipulation of SELinux | |
91 | binary policies. It is used by @code{checkpolicy} (the policy compiler) and | |
92 | similar tools, and programs such as @code{load_policy}, which must perform | |
93 | specific transformations on binary policies (for example, customizing policy | |
94 | boolean settings).") | |
95 | (license license:lgpl2.1+))) | |
66af08fb RW |
96 | |
97 | (define-public checkpolicy | |
98 | (package (inherit libsepol) | |
99 | (name "checkpolicy") | |
100 | (arguments | |
101 | `(#:tests? #f ; there is no check target | |
102 | #:make-flags | |
103 | (let ((out (assoc-ref %outputs "out"))) | |
104 | (list (string-append "PREFIX=" out) | |
ca56021c | 105 | (string-append "LIBSEPOLA=" |
66af08fb | 106 | (assoc-ref %build-inputs "libsepol") |
ca56021c | 107 | "/lib/libsepol.a") |
66af08fb RW |
108 | "CC=gcc")) |
109 | #:phases | |
110 | (modify-phases %standard-phases | |
111 | (delete 'configure) | |
50e87903 | 112 | (delete 'portability) |
66af08fb RW |
113 | (add-after 'unpack 'enter-dir |
114 | (lambda _ (chdir ,name) #t))))) | |
115 | (inputs | |
116 | `(("libsepol" ,libsepol))) | |
117 | (native-inputs | |
118 | `(("bison" ,bison) | |
119 | ("flex" ,flex))) | |
120 | (synopsis "Check SELinux security policy configurations and modules") | |
121 | (description | |
122 | "This package provides the tools \"checkpolicy\" and \"checkmodule\". | |
123 | Checkpolicy is a program that checks and compiles a SELinux security policy | |
124 | configuration into a binary representation that can be loaded into the kernel. | |
125 | Checkmodule is a program that checks and compiles a SELinux security policy | |
126 | module into a binary representation.") | |
127 | ;; GPLv2 only | |
128 | (license license:gpl2))) | |
4724d729 RW |
129 | |
130 | (define-public libselinux | |
131 | (package (inherit libsepol) | |
132 | (name "libselinux") | |
133 | (arguments | |
134 | (substitute-keyword-arguments (package-arguments libsepol) | |
135 | ((#:make-flags flags) | |
136 | `(cons* "PYTHON=python3" | |
ca56021c RW |
137 | (string-append "LIBSEPOLA=" |
138 | (assoc-ref %build-inputs "libsepol") | |
139 | "/lib/libsepol.a") | |
4724d729 RW |
140 | (string-append "PYSITEDIR=" |
141 | (assoc-ref %outputs "out") | |
142 | "/lib/python" | |
143 | ,(version-major+minor (package-version python)) | |
144 | "/site-packages/") | |
145 | ,flags)) | |
146 | ((#:phases phases) | |
147 | `(modify-phases ,phases | |
50e87903 | 148 | (delete 'portability) |
4724d729 RW |
149 | (replace 'enter-dir |
150 | (lambda _ (chdir ,name) #t)) | |
4724d729 RW |
151 | (add-after 'enter-dir 'remove-Werror |
152 | (lambda _ | |
153 | ;; GCC complains about the fact that the output does not (yet) | |
154 | ;; have an "include" directory, even though it is referenced. | |
155 | (substitute* '("src/Makefile" | |
156 | "utils/Makefile") | |
157 | (("-Werror ") "")) | |
158 | #t)) | |
159 | (add-after 'build 'pywrap | |
160 | (lambda* (#:key make-flags #:allow-other-keys) | |
927c52c4 | 161 | (apply invoke "make" "pywrap" make-flags))) |
4724d729 RW |
162 | (add-after 'install 'install-pywrap |
163 | (lambda* (#:key make-flags #:allow-other-keys) | |
927c52c4 | 164 | (apply invoke "make" "install-pywrap" make-flags))))))) |
9ffc1f0e KK |
165 | ;; These libraries are in "Requires.private" in libselinux.pc. |
166 | (propagated-inputs | |
4724d729 | 167 | `(("libsepol" ,libsepol) |
9ffc1f0e KK |
168 | ("pcre" ,pcre))) |
169 | ;; For pywrap phase | |
170 | (inputs | |
171 | `(("python" ,python-wrapper))) | |
4724d729 RW |
172 | ;; These inputs are only needed for the pywrap phase. |
173 | (native-inputs | |
174 | `(("swig" ,swig) | |
175 | ("pkg-config" ,pkg-config))) | |
176 | (synopsis "SELinux core libraries and utilities") | |
177 | (description | |
178 | "The libselinux library provides an API for SELinux applications to get | |
179 | and set process and file security contexts, and to obtain security policy | |
180 | decisions. It is required for any applications that use the SELinux API, and | |
181 | used by all applications that are SELinux-aware. This package also includes | |
182 | the core SELinux management utilities.") | |
183 | (license license:public-domain))) | |
32be6601 RW |
184 | |
185 | (define-public libsemanage | |
186 | (package (inherit libsepol) | |
187 | (name "libsemanage") | |
188 | (arguments | |
189 | (substitute-keyword-arguments (package-arguments libsepol) | |
190 | ((#:make-flags flags) | |
191 | `(cons* "PYTHON=python3" | |
192 | (string-append "PYSITEDIR=" | |
193 | (assoc-ref %outputs "out") | |
194 | "/lib/python" | |
195 | ,(version-major+minor (package-version python)) | |
196 | "/site-packages/") | |
197 | ,flags)) | |
198 | ((#:phases phases) | |
199 | `(modify-phases ,phases | |
50e87903 | 200 | (delete 'portability) |
32be6601 RW |
201 | (replace 'enter-dir |
202 | (lambda _ (chdir ,name) #t)) | |
203 | (add-after 'build 'pywrap | |
204 | (lambda* (#:key make-flags #:allow-other-keys) | |
bb6c3d23 | 205 | (apply invoke "make" "pywrap" make-flags))) |
32be6601 RW |
206 | (add-after 'install 'install-pywrap |
207 | (lambda* (#:key make-flags #:allow-other-keys) | |
bb6c3d23 | 208 | (apply invoke "make" "install-pywrap" make-flags))))))) |
32be6601 RW |
209 | (inputs |
210 | `(("libsepol" ,libsepol) | |
211 | ("libselinux" ,libselinux) | |
212 | ("audit" ,audit) | |
213 | ("ustr" ,ustr) | |
214 | ;; For pywrap phase | |
215 | ("python" ,python-wrapper))) | |
216 | (native-inputs | |
217 | `(("bison" ,bison) | |
218 | ("flex" ,flex) | |
219 | ;; For pywrap phase | |
220 | ("swig" ,swig) | |
221 | ("pkg-config" ,pkg-config))) | |
222 | (synopsis "SELinux policy management libraries") | |
223 | (description | |
224 | "The libsemanage library provides an API for the manipulation of SELinux | |
225 | binary policies.") | |
226 | (license license:lgpl2.1+))) | |
c837027d RW |
227 | |
228 | (define-public secilc | |
229 | (package (inherit libsepol) | |
230 | (name "secilc") | |
231 | (arguments | |
232 | (substitute-keyword-arguments (package-arguments libsepol) | |
233 | ((#:make-flags flags) | |
234 | `(let ((docbook (assoc-ref %build-inputs "docbook-xsl"))) | |
235 | (cons (string-append "XMLTO=xmlto --skip-validation -x " | |
236 | docbook "/xml/xsl/docbook-xsl-" | |
237 | ,(package-version docbook-xsl) | |
238 | "/manpages/docbook.xsl") | |
239 | ,flags))) | |
240 | ((#:phases phases) | |
241 | `(modify-phases ,phases | |
50e87903 | 242 | (delete 'portability) |
c837027d RW |
243 | (replace 'enter-dir |
244 | (lambda _ (chdir ,name) #t)))))) | |
245 | (inputs | |
246 | `(("libsepol" ,libsepol))) | |
247 | (native-inputs | |
248 | `(("xmlto" ,xmlto) | |
249 | ("docbook-xsl" ,docbook-xsl))) | |
250 | (synopsis "SELinux common intermediate language (CIL) compiler") | |
251 | (description "The SELinux CIL compiler is a compiler that converts the | |
252 | @dfn{common intermediate language} (CIL) into a kernel binary policy file.") | |
253 | (license license:bsd-2))) | |
d7e2d273 RW |
254 | |
255 | (define-public python-sepolgen | |
256 | (package (inherit libsepol) | |
257 | (name "python-sepolgen") | |
258 | (arguments | |
259 | `(#:modules ((srfi srfi-1) | |
260 | (guix build gnu-build-system) | |
261 | (guix build utils)) | |
262 | ,@(substitute-keyword-arguments (package-arguments libsepol) | |
263 | ((#:phases phases) | |
264 | `(modify-phases ,phases | |
50e87903 | 265 | (delete 'portability) |
d7e2d273 | 266 | (replace 'enter-dir |
ca56021c | 267 | (lambda _ (chdir "python/sepolgen") #t)) |
d7e2d273 RW |
268 | ;; By default all Python files would be installed to |
269 | ;; $out/gnu/store/...-python-.../, so we override the | |
270 | ;; PACKAGEDIR to fix this. | |
271 | (add-after 'enter-dir 'fix-target-path | |
272 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
273 | (let ((get-python-version | |
274 | ;; FIXME: copied from python-build-system | |
275 | (lambda (python) | |
276 | (let* ((version (last (string-split python #\-))) | |
277 | (components (string-split version #\.)) | |
278 | (major+minor (take components 2))) | |
279 | (string-join major+minor "."))))) | |
280 | (substitute* "src/sepolgen/Makefile" | |
281 | (("^PACKAGEDIR.*") | |
282 | (string-append "PACKAGEDIR=" | |
283 | (assoc-ref outputs "out") | |
284 | "/lib/python" | |
285 | (get-python-version | |
286 | (assoc-ref inputs "python")) | |
287 | "/site-packages/sepolgen"))) | |
288 | (substitute* "src/share/Makefile" | |
289 | (("\\$\\(DESTDIR\\)") (assoc-ref outputs "out")))) | |
290 | #t))))))) | |
291 | (inputs | |
292 | `(("python" ,python-wrapper))) | |
293 | (native-inputs '()) | |
294 | (synopsis "Python module for generating SELinux policies") | |
295 | (description | |
296 | "This package contains a Python module that forms the core of | |
297 | @code{audit2allow}, a part of the package @code{policycoreutils}. The | |
298 | sepolgen library contains: Reference Policy Representation, which are Objects | |
299 | for representing policies and the reference policy interfaces. It has objects | |
300 | and algorithms for representing access and sets of access in an abstract way | |
301 | and searching that access. It also has a parser for reference policy | |
302 | \"headers\". It contains infrastructure for parsing SELinux related messages | |
303 | as produced by the audit system. It has facilities for generating policy | |
304 | based on required access.") | |
305 | ;; GPLv2 only | |
306 | (license license:gpl2))) | |
41da8dbe | 307 | |
41da8dbe RW |
308 | (define-public python-setools |
309 | (package | |
310 | (name "python-setools") | |
ca56021c | 311 | (version "4.1.1") |
41da8dbe | 312 | (source (origin |
ca56021c RW |
313 | (method git-fetch) |
314 | (uri (git-reference | |
315 | (url "https://github.com/TresysTechnology/setools.git") | |
316 | (commit version))) | |
317 | (file-name (string-append name "-" version "-checkout")) | |
41da8dbe RW |
318 | (sha256 |
319 | (base32 | |
ca56021c | 320 | "0459xxly6zzqc5azcwk3rbbcxvj60dq08f8z6xr05y7dsbb16cg6")))) |
41da8dbe RW |
321 | (build-system python-build-system) |
322 | (arguments | |
323 | `(#:tests? #f ; the test target causes a rebuild | |
324 | #:phases | |
325 | (modify-phases %standard-phases | |
50e87903 | 326 | (delete 'portability) |
41da8dbe RW |
327 | (add-after 'unpack 'set-SEPOL-variable |
328 | (lambda* (#:key inputs #:allow-other-keys) | |
329 | (setenv "SEPOL" | |
330 | (string-append (assoc-ref inputs "libsepol") | |
331 | "/lib/libsepol.a")))) | |
332 | (add-after 'unpack 'remove-Werror | |
333 | (lambda _ | |
334 | (substitute* "setup.py" | |
335 | (("'-Werror',") "")) | |
336 | #t)) | |
337 | (add-after 'unpack 'fix-target-paths | |
338 | (lambda* (#:key outputs #:allow-other-keys) | |
339 | (substitute* "setup.py" | |
340 | (("join\\(sys.prefix") | |
341 | (string-append "join(\"" (assoc-ref outputs "out") "/\""))) | |
342 | #t))))) | |
343 | (propagated-inputs | |
344 | `(("python-networkx" ,python-networkx))) | |
345 | (inputs | |
346 | `(("libsepol" ,libsepol) | |
347 | ("libselinux" ,libselinux))) | |
348 | (native-inputs | |
349 | `(("bison" ,bison) | |
350 | ("flex" ,flex) | |
351 | ("swig" ,swig))) | |
352 | (home-page "https://github.com/TresysTechnology/setools") | |
353 | (synopsis "Tools for SELinux policy analysis") | |
354 | (description "SETools is a collection of graphical tools, command-line | |
355 | tools, and libraries designed to facilitate SELinux policy analysis.") | |
356 | ;; Some programs are under GPL, all libraries under LGPL. | |
357 | (license (list license:lgpl2.1+ | |
358 | license:gpl2+)))) | |
6ef94ecb RW |
359 | |
360 | (define-public policycoreutils | |
361 | (package (inherit libsepol) | |
362 | (name "policycoreutils") | |
6ef94ecb RW |
363 | (arguments |
364 | `(#:test-target "test" | |
365 | #:make-flags | |
366 | (let ((out (assoc-ref %outputs "out"))) | |
367 | (list "CC=gcc" | |
368 | (string-append "PREFIX=" out) | |
369 | (string-append "LOCALEDIR=" out "/share/locale") | |
370 | (string-append "BASHCOMPLETIONDIR=" out | |
371 | "/share/bash-completion/completions") | |
372 | "INSTALL=install -c -p" | |
373 | "INSTALL_DIR=install -d" | |
374 | ;; These ones are needed because some Makefiles define the | |
375 | ;; directories relative to DESTDIR, not relative to PREFIX. | |
376 | (string-append "SBINDIR=" out "/sbin") | |
377 | (string-append "ETCDIR=" out "/etc") | |
378 | (string-append "SYSCONFDIR=" out "/etc/sysconfig") | |
379 | (string-append "MAN5DIR=" out "/share/man/man5") | |
380 | (string-append "INSTALL_NLS_DIR=" out "/share/locale") | |
381 | (string-append "AUTOSTARTDIR=" out "/etc/xdg/autostart") | |
382 | (string-append "DBUSSERVICEDIR=" out "/share/dbus-1/services") | |
383 | (string-append "SYSTEMDDIR=" out "/lib/systemd") | |
384 | (string-append "INITDIR=" out "/etc/rc.d/init.d") | |
385 | (string-append "SELINUXDIR=" out "/etc/selinux"))) | |
386 | #:phases | |
387 | (modify-phases %standard-phases | |
388 | (delete 'configure) | |
50e87903 | 389 | (delete 'portability) |
6ef94ecb RW |
390 | (add-after 'unpack 'enter-dir |
391 | (lambda _ (chdir ,name) #t)) | |
392 | (add-after 'enter-dir 'ignore-/usr-tests | |
393 | (lambda* (#:key inputs #:allow-other-keys) | |
394 | ;; The Makefile decides to build restorecond only if it finds the | |
395 | ;; inotify header somewhere under /usr. | |
396 | (substitute* "Makefile" | |
397 | (("ifeq.*") "") | |
398 | (("endif.*") "")) | |
399 | ;; Rewrite lookup paths for header files. | |
400 | (substitute* '("newrole/Makefile" | |
401 | "setfiles/Makefile" | |
402 | "run_init/Makefile") | |
403 | (("/usr(/include/security/pam_appl.h)" _ file) | |
404 | (string-append (assoc-ref inputs "pam") file)) | |
405 | (("/usr(/include/libaudit.h)" _ file) | |
406 | (string-append (assoc-ref inputs "audit") file))) | |
6ef94ecb RW |
407 | #t))))) |
408 | (inputs | |
ca56021c | 409 | `(("audit" ,audit) |
6ef94ecb RW |
410 | ("pam" ,linux-pam) |
411 | ("libsepol" ,libsepol) | |
412 | ("libselinux" ,libselinux) | |
ca56021c | 413 | ("libsemanage" ,libsemanage))) |
6ef94ecb RW |
414 | (native-inputs |
415 | `(("gettext" ,gettext-minimal))) | |
416 | (synopsis "SELinux core utilities") | |
417 | (description "The policycoreutils package contains the core utilities that | |
418 | are required for the basic operation of an SELinux-enabled GNU system and its | |
419 | policies. These utilities include @code{load_policy} to load policies, | |
420 | @code{setfiles} to label file systems, @code{newrole} to switch roles, and | |
421 | @code{run_init} to run service scripts in their proper context.") | |
422 | (license license:gpl2+))) |