diff options
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | Makefile.am | 7 | ||||
| -rw-r--r-- | configure.ac | 10 | ||||
| -rw-r--r-- | doc/guix.texi | 41 | ||||
| -rw-r--r-- | etc/apparmor.d/guix-daemon | 88 | ||||
| -rw-r--r-- | etc/apparmor.d/tunables/guix.in | 5 | ||||
| -rw-r--r-- | gnu/packages/package-management.scm | 4 |
7 files changed, 156 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore index 4f7308b295c..8779222df0c 100644 --- a/.gitignore +++ b/.gitignore | |||
| @@ -68,6 +68,7 @@ | |||
| 68 | /doc/stamp-vti | 68 | /doc/stamp-vti |
| 69 | /doc/version.texi | 69 | /doc/version.texi |
| 70 | /doc/version-*.texi | 70 | /doc/version-*.texi |
| 71 | /etc/apparmor.d/tunables/guix | ||
| 71 | /etc/committer.scm | 72 | /etc/committer.scm |
| 72 | /etc/gnu-store.mount | 73 | /etc/gnu-store.mount |
| 73 | /etc/guix-daemon.cil | 74 | /etc/guix-daemon.cil |
diff --git a/Makefile.am b/Makefile.am index 106849e89f0..bf7d1556f0e 100644 --- a/Makefile.am +++ b/Makefile.am | |||
| @@ -746,6 +746,13 @@ dist_fishcompletion_DATA = etc/completion/fish/guix.fish | |||
| 746 | # SELinux policy | 746 | # SELinux policy |
| 747 | nodist_selinux_policy_DATA = etc/guix-daemon.cil | 747 | nodist_selinux_policy_DATA = etc/guix-daemon.cil |
| 748 | 748 | ||
| 749 | # AppArmor profiles. | ||
| 750 | nodist_apparmor_profile_DATA = \ | ||
| 751 | etc/apparmor.d/guix-daemon | ||
| 752 | |||
| 753 | nodist_apparmor_profile_tunables_DATA = \ | ||
| 754 | etc/apparmor.d/tunables/guix | ||
| 755 | |||
| 749 | EXTRA_DIST += \ | 756 | EXTRA_DIST += \ |
| 750 | .dir-locals.el \ | 757 | .dir-locals.el \ |
| 751 | .guix-authorizations \ | 758 | .guix-authorizations \ |
diff --git a/configure.ac b/configure.ac index 82f12507745..6ad8e427736 100644 --- a/configure.ac +++ b/configure.ac | |||
| @@ -81,6 +81,15 @@ AC_ARG_WITH([selinux-policy-dir], | |||
| 81 | [selinux_policydir='${datadir}/selinux/']) | 81 | [selinux_policydir='${datadir}/selinux/']) |
| 82 | AC_SUBST([selinux_policydir]) | 82 | AC_SUBST([selinux_policydir]) |
| 83 | 83 | ||
| 84 | AC_ARG_WITH([apparmor-profile-dir], | ||
| 85 | AS_HELP_STRING([--with-apparmor-profile-dir=DIR], | ||
| 86 | [name of the AppArmor profile directory]), | ||
| 87 | [apparmor_profiledir="$withval"], | ||
| 88 | [apparmor_profiledir='${sysconfdir}/apparmor.d']) | ||
| 89 | AC_SUBST([apparmor_profiledir]) | ||
| 90 | apparmor_profile_tunablesdir='${apparmor_profiledir}/tunables' | ||
| 91 | AC_SUBST([apparmor_profile_tunablesdir]) | ||
| 92 | |||
| 84 | dnl Better be verbose. | 93 | dnl Better be verbose. |
| 85 | AC_MSG_CHECKING([for the store directory]) | 94 | AC_MSG_CHECKING([for the store directory]) |
| 86 | AC_MSG_RESULT([$storedir]) | 95 | AC_MSG_RESULT([$storedir]) |
| @@ -308,6 +317,7 @@ AC_CONFIG_FILES([Makefile | |||
| 308 | po/guix/Makefile.in | 317 | po/guix/Makefile.in |
| 309 | po/packages/Makefile.in | 318 | po/packages/Makefile.in |
| 310 | etc/guix-daemon.cil | 319 | etc/guix-daemon.cil |
| 320 | etc/apparmor.d/tunables/guix | ||
| 311 | guix/config.scm]) | 321 | guix/config.scm]) |
| 312 | 322 | ||
| 313 | AC_CONFIG_FILES([etc/committer.scm], [chmod +x etc/committer.scm]) | 323 | AC_CONFIG_FILES([etc/committer.scm], [chmod +x etc/committer.scm]) |
diff --git a/doc/guix.texi b/doc/guix.texi index d7d40ceb223..fc25b653f32 100644 --- a/doc/guix.texi +++ b/doc/guix.texi | |||
| @@ -146,6 +146,7 @@ Copyright @copyright{} 2025 Artur Wroblewski@* | |||
| 146 | Copyright @copyright{} 2025 Edouard Klein@* | 146 | Copyright @copyright{} 2025 Edouard Klein@* |
| 147 | Copyright @copyright{} 2025 Rodion Goritskov@* | 147 | Copyright @copyright{} 2025 Rodion Goritskov@* |
| 148 | Copyright @copyright{} 2025 dan@* | 148 | Copyright @copyright{} 2025 dan@* |
| 149 | Copyright @copyright{} 2025 NoƩ Lopez@* | ||
| 149 | 150 | ||
| 150 | Permission is granted to copy, distribute and/or modify this document | 151 | Permission is granted to copy, distribute and/or modify this document |
| 151 | under the terms of the GNU Free Documentation License, Version 1.3 or | 152 | under the terms of the GNU Free Documentation License, Version 1.3 or |
| @@ -919,6 +920,7 @@ pre-built binaries. | |||
| 919 | * Build Environment Setup:: Preparing the isolated build environment. | 920 | * Build Environment Setup:: Preparing the isolated build environment. |
| 920 | * Daemon Offload Setup:: Offloading builds to remote machines. | 921 | * Daemon Offload Setup:: Offloading builds to remote machines. |
| 921 | * SELinux Support:: Using an SELinux policy for the daemon. | 922 | * SELinux Support:: Using an SELinux policy for the daemon. |
| 923 | * AppArmor Support:: Using an AppArmor profile for the daemon. | ||
| 922 | @end menu | 924 | @end menu |
| 923 | 925 | ||
| 924 | @node Build Environment Setup | 926 | @node Build Environment Setup |
| @@ -1097,6 +1099,8 @@ systemctl daemon-reload | |||
| 1097 | systemctl start guix-daemon | 1099 | systemctl start guix-daemon |
| 1098 | @end example | 1100 | @end example |
| 1099 | 1101 | ||
| 1102 | If your system has AppArmor enabled, @pxref{AppArmor Support}. | ||
| 1103 | |||
| 1100 | @quotation Warning | 1104 | @quotation Warning |
| 1101 | The commands above assume that @command{guix pull} was run for the root | 1105 | The commands above assume that @command{guix pull} was run for the root |
| 1102 | user. You can check whether this is the case by running this command: | 1106 | user. You can check whether this is the case by running this command: |
| @@ -1526,6 +1530,43 @@ installation time whenever the Guix package that provides the | |||
| 1526 | effectively running @code{guix-daemon} executable is upgraded. | 1530 | effectively running @code{guix-daemon} executable is upgraded. |
| 1527 | @end enumerate | 1531 | @end enumerate |
| 1528 | 1532 | ||
| 1533 | @node AppArmor Support | ||
| 1534 | @subsection AppArmor Support | ||
| 1535 | |||
| 1536 | @cindex AppArmor | ||
| 1537 | |||
| 1538 | Guix includes an AppArmor profile for the build daemon in | ||
| 1539 | @file{etc/apparmor.d/guix-daemon} that can be installed on systems with | ||
| 1540 | strict AppArmor policies to allow it to run unprivileged | ||
| 1541 | (@pxref{Build Environment Setup}). Indeed, the unprivileged daemon makes | ||
| 1542 | use of Linux user namespaces but these are disallowed | ||
| 1543 | without an AppArmor policy on some systems like Ubuntu. | ||
| 1544 | |||
| 1545 | To know if this applies to you, check if the | ||
| 1546 | @code{kernel.apparmor_restrict_unprivileged_userns} kernel parameter is | ||
| 1547 | enabled. | ||
| 1548 | |||
| 1549 | @subsubsection Installing the AppArmor profile | ||
| 1550 | @cindex AppArmor, profile installation | ||
| 1551 | |||
| 1552 | @quotation Note | ||
| 1553 | The @code{guix-install.sh} binary installation script offers to perform | ||
| 1554 | the steps below for you (@pxref{Binary Installation}). | ||
| 1555 | @end quotation | ||
| 1556 | |||
| 1557 | Run these commands as root to install the profile: | ||
| 1558 | |||
| 1559 | @example | ||
| 1560 | export apparmor_sources=/var/guix/profiles/per-user/root/current-guix/etc/apparmor.d | ||
| 1561 | cp -f -t /etc/apparmor.d/tunables "$apparmor_sources/tunables/guix" | ||
| 1562 | cp -f -t /etc/apparmor.d "$apparmor_sources/guix-daemon" | ||
| 1563 | cp -f -t /etc/apparmor.d "$apparmor_sources/guix" | ||
| 1564 | apparmor_parser -r /etc/apparmor.d/guix-daemon | ||
| 1565 | apparmor_parser -r /etc/apparmor.d/guix | ||
| 1566 | @end example | ||
| 1567 | |||
| 1568 | After this, the build daemon will be able to function correctly. | ||
| 1569 | |||
| 1529 | @node Invoking guix-daemon | 1570 | @node Invoking guix-daemon |
| 1530 | @section Invoking @command{guix-daemon} | 1571 | @section Invoking @command{guix-daemon} |
| 1531 | @cindex @command{guix-daemon} | 1572 | @cindex @command{guix-daemon} |
diff --git a/etc/apparmor.d/guix-daemon b/etc/apparmor.d/guix-daemon new file mode 100644 index 00000000000..cb1ee92685c --- /dev/null +++ b/etc/apparmor.d/guix-daemon | |||
| @@ -0,0 +1,88 @@ | |||
| 1 | abi <abi/4.0>, | ||
| 2 | |||
| 3 | include <tunables/global> | ||
| 4 | include <tunables/guix> | ||
| 5 | |||
| 6 | profile guix-daemon @{guix_storedir}/*-{guix-daemon,guix}-*/bin/guix-daemon flags=(enforce,attach_disconnected.path=/disconnected) { | ||
| 7 | include <abstractions/base> | ||
| 8 | |||
| 9 | userns, | ||
| 10 | signal, | ||
| 11 | capability sys_admin, | ||
| 12 | capability net_admin, | ||
| 13 | capability sys_chroot, | ||
| 14 | capability setgid, | ||
| 15 | capability chown, | ||
| 16 | network dgram, | ||
| 17 | umount, | ||
| 18 | mount, | ||
| 19 | pivot_root, | ||
| 20 | # Paths inside build chroot | ||
| 21 | /real-root/ w, | ||
| 22 | / w, | ||
| 23 | |||
| 24 | @{guix_localstatedir}/guix/** rwk, | ||
| 25 | /var/log/guix/** w, | ||
| 26 | owner @{PROC}/@{pid}/{fd/,environ} r, | ||
| 27 | owner @{PROC}/@{pid}/oom_score_adj w, | ||
| 28 | owner @{PROC}/@{pid}/uid_map rw, | ||
| 29 | owner @{PROC}/@{pid}/gid_map rw, | ||
| 30 | owner @{PROC}/@{pid}/setgroups w, | ||
| 31 | @{guix_storedir}/ r, | ||
| 32 | @{guix_storedir}/** rwlmk, | ||
| 33 | @{guix_storedir}/*/bin/guile cx -> guix-builder, | ||
| 34 | @{guix_storedir}/*-guix-command cx -> guix-helper, | ||
| 35 | @{guix_storedir}/*-guix-*/bin/guix cx -> guix-helper, | ||
| 36 | @{etc_rw}/nsswitch.conf r, | ||
| 37 | @{etc_rw}/passwd r, | ||
| 38 | @{etc_rw}/group r, | ||
| 39 | owner /tmp/** rwl, | ||
| 40 | owner /var/tmp/** rwl, | ||
| 41 | |||
| 42 | /usr/bin/newgidmap Ux, | ||
| 43 | |||
| 44 | # Site-specific additions and overrides. See local/README for details. | ||
| 45 | include if exists <local/guix-daemon> | ||
| 46 | |||
| 47 | profile guix-builder flags=(enforce,attach_disconnected.path=/disconnected) { | ||
| 48 | include <abstractions/base> | ||
| 49 | |||
| 50 | signal (receive), | ||
| 51 | |||
| 52 | @{guix_storedir}/** rwlmkux, | ||
| 53 | |||
| 54 | owner /tmp/** rw, | ||
| 55 | |||
| 56 | @{PROC}/@{pid}/fd/ r, | ||
| 57 | |||
| 58 | /disconnected/** rw, | ||
| 59 | } | ||
| 60 | |||
| 61 | # This is for any time guix is called by the daemon as a helper: | ||
| 62 | # - guix download | ||
| 63 | # - guix discover | ||
| 64 | # - guix gc --list-busy | ||
| 65 | # - probably more? | ||
| 66 | profile guix-helper flags=(enforce,attach_disconnected.path=/disconnected) { | ||
| 67 | include <abstractions/base> | ||
| 68 | include <abstractions/nameservice> | ||
| 69 | |||
| 70 | signal (receive), | ||
| 71 | ptrace (read) peer=guix-daemon, | ||
| 72 | |||
| 73 | /disconnected/run/dbus/system_bus_socket rw, | ||
| 74 | dbus (send, receive), | ||
| 75 | @{guix_localstatedir}/guix/discover/ rw, | ||
| 76 | @{guix_localstatedir}/guix/discover/* rw, | ||
| 77 | |||
| 78 | @{guix_localstatedir}/guix/substitute/ rw, | ||
| 79 | @{guix_localstatedir}/guix/substitute/** rwk, | ||
| 80 | |||
| 81 | @{guix_sysconfdir}/guix/** r, | ||
| 82 | |||
| 83 | @{guix_storedir}/** rwlmix, | ||
| 84 | |||
| 85 | @{PROC}/ r, | ||
| 86 | owner @{PROC}/@{pid}/{fd/,environ} r, | ||
| 87 | } | ||
| 88 | } | ||
diff --git a/etc/apparmor.d/tunables/guix.in b/etc/apparmor.d/tunables/guix.in new file mode 100644 index 00000000000..e93f7caeb7d --- /dev/null +++ b/etc/apparmor.d/tunables/guix.in | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | @{guix_storedir} = @storedir@ | ||
| 2 | @{guix_sysconfdir} = @guix_sysconfdir@ | ||
| 3 | @{guix_localstatedir} = @guix_localstatedir@ | ||
| 4 | |||
| 5 | include if exists <tunables/guix.d> \ No newline at end of file | ||
diff --git a/gnu/packages/package-management.scm b/gnu/packages/package-management.scm index f04bd5efd9f..eadaea4967d 100644 --- a/gnu/packages/package-management.scm +++ b/gnu/packages/package-management.scm | |||
| @@ -234,6 +234,10 @@ | |||
| 234 | (string-append "--with-bash-completion-dir=" | 234 | (string-append "--with-bash-completion-dir=" |
| 235 | (assoc-ref %outputs "out") | 235 | (assoc-ref %outputs "out") |
| 236 | "/etc/bash_completion.d") | 236 | "/etc/bash_completion.d") |
| 237 | ;; TODO: Uncomment after guix is updated. | ||
| 238 | ;; (string-append "--with-apparmor-profile-dir=" | ||
| 239 | ;; (assoc-ref %outputs "out") | ||
| 240 | ;; "/etc/apparmor.d") | ||
| 237 | 241 | ||
| 238 | ;; Set 'DOT_USER_PROGRAM' to the empty string so | 242 | ;; Set 'DOT_USER_PROGRAM' to the empty string so |
| 239 | ;; we don't keep a reference to Graphviz, whose | 243 | ;; we don't keep a reference to Graphviz, whose |
