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