* [bug#61462] Add support for file capabilities(7) @ 2023-02-12 20:37 Tobias Geerinckx-Rice via Guix-patches via 2023-02-05 0:00 ` [bug#61462] [PATCH 01/10] system: Disallow file-like setuid-programs Tobias Geerinckx-Rice via Guix-patches via ` (3 more replies) 0 siblings, 4 replies; 35+ messages in thread From: Tobias Geerinckx-Rice via Guix-patches via @ 2023-02-12 20:37 UTC (permalink / raw) To: 61462 [-- Attachment #1: Type: text/plain, Size: 1190 bytes --] Hi Guix, I need to offload some of my eternally rebased local patches. Here's one that makes it easy to assign capabilities(7) — currently through setcap(8) — to programmes like we can set{u,g}id. There are many packages that benefit from this. Mine are: (privileged-programs (cons* (privileged-program (file-append mtr "/sbin/mtr") (capabilities "cap_net_raw+ep")) (privileged-program (file-append nethogs "/sbin/nethogs") (capabilities "cap_net_admin,cap_new_raw+ep")) (privileged-program (file-append light "/bin/light") (setuid? #t)) %default-privileged-programs)) The set's over a year old and needs a bit of love. Some details might have bitrot, I probably forgot a to-do or two in that year, and there's something unguixy about calling setcap(8) instead of writing a completely new Guile binding/module :-) I'm quite opinionated about the setuid-programs unification: there should not be multiple confusing and masking layers of privilege, and it should be possible to setgid a capable executable. Kind regards, T G-R [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 247 bytes --] ^ permalink raw reply [flat|nested] 35+ messages in thread
* [bug#61462] [PATCH 01/10] system: Disallow file-like setuid-programs. 2023-02-12 20:37 [bug#61462] Add support for file capabilities(7) Tobias Geerinckx-Rice via Guix-patches via @ 2023-02-05 0:00 ` Tobias Geerinckx-Rice via Guix-patches via 2023-02-05 0:00 ` [bug#61462] [PATCH 02/10] services: setuid-program: Populate /run/privileged/bin Tobias Geerinckx-Rice via Guix-patches via ` (8 more replies) 2023-02-12 21:05 ` [bug#61462] Add support for file capabilities(7) Tobias Geerinckx-Rice via Guix-patches via ` (2 subsequent siblings) 3 siblings, 9 replies; 35+ messages in thread From: Tobias Geerinckx-Rice via Guix-patches via @ 2023-02-05 0:00 UTC (permalink / raw) To: 61462 It has been a warning for well over a year now. Now, with privileged-programs coming, don't let's support nested deprecation hacks. * gnu/system.scm (<operating-system>): Don't ‘sanitize’ the setuid-programs field. (ensure-setuid-program-list): Delete syntax. (%ensure-setuid-program-list): Delete variable. --- gnu/system.scm | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/gnu/system.scm b/gnu/system.scm index df60fda53b..85380136e2 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -297,8 +297,7 @@ (define-record-type* <operating-system> operating-system (pam-services operating-system-pam-services ; list of PAM services (default (base-pam-services))) (setuid-programs operating-system-setuid-programs - (default %setuid-programs) ; list of <setuid-program> - (sanitize ensure-setuid-program-list)) + (default %setuid-programs)) ; list of <setuid-program> (sudoers-file operating-system-sudoers-file ; file-like (default %sudoers-specification)) @@ -1214,31 +1213,6 @@ (define (operating-system-environment-variables os) ;; TODO: Remove when glibc@2.23 is long gone. ("GUIX_LOCPATH" . "/run/current-system/locale"))) -;; Ensure LST is a list of <setuid-program> records and warn otherwise. -(define-with-syntax-properties (ensure-setuid-program-list (lst properties)) - (%ensure-setuid-program-list lst properties)) - -;; We want to be able to use defines, so define a procedure. -(define (%ensure-setuid-program-list lst properties) - (define warned? #f) - - (define (warn-once) - (unless warned? - (warning (source-properties->location properties) - (G_ "representing setuid programs with file-like objects is \ -deprecated; use 'setuid-program' instead~%")) - (set! warned? #t))) - - (map (match-lambda - ((? setuid-program? program) - program) - (program - ;; PROGRAM is a file-like or a gexp like #~(string-append #$foo - ;; "/bin/bar"). - (warn-once) - (setuid-program (program program)))) - lst)) - (define %setuid-programs ;; Default set of setuid-root programs. (let ((shadow (@ (gnu packages admin) shadow))) base-commit: 2b1383c0a2f79117103b142440c64f6a751d545d prerequisite-patch-id: 886fb4af654b597857d992a7c1e9c4bcc8bf5ab6 prerequisite-patch-id: 159d9e2558e5fb2dfc1d7442440e154dba14e500 prerequisite-patch-id: 2a1dffe5206b8a67cc544267d4ce4ddd23f3f290 prerequisite-patch-id: 992a4004d5fc0c427696da0b142942008c987083 prerequisite-patch-id: ee47c54ab1f9c72ee6974eca16aa311c80601048 prerequisite-patch-id: b50c71d9cc8fb39d18f448d9db6d61eca9f0f25b prerequisite-patch-id: 15aab9bfe126cf392055f82d0831ad2bd8622ad4 prerequisite-patch-id: 83928f7dc391bf556c5d4405ca966c60bfdfff4b prerequisite-patch-id: 4370270b5f1db400fe91d922da17390ef76d7962 prerequisite-patch-id: 1bf3ab2da9cb51156f6b28aac26b1c9e46f58f3c prerequisite-patch-id: e082433b46efa579b4026c24466af3bb375c66a9 prerequisite-patch-id: 37587dd99ea94d6fd06e5a85600364a9b9e30257 prerequisite-patch-id: 48b2c23df7636eb66789649d5465c5aba5551c6d prerequisite-patch-id: ee83168a69856ce6aacac6399af1e0f6b6126001 prerequisite-patch-id: 313f790e410773ccec61a27665d372b1f45b7236 prerequisite-patch-id: e82c8b9f3dd1b945f7cb937cf34f308b74759ca8 prerequisite-patch-id: ebd98ed22463fdb02fcfc5108a39bda89020cddd prerequisite-patch-id: aa023f744b32055ca87a6131b0791d7524f03749 prerequisite-patch-id: 780a9840ba83b219743a5d4847dcec3e6bd4eb4c prerequisite-patch-id: d337437b304428933fd187c3d38669f1ab6810f5 prerequisite-patch-id: 088d2163c05a955c2dc69c32cfd07a2c9bbb38fe prerequisite-patch-id: f49f51dfc2e47144c8c9b27534f4d041d4c0abce -- 2.39.1 ^ permalink raw reply related [flat|nested] 35+ messages in thread
* [bug#61462] [PATCH 02/10] services: setuid-program: Populate /run/privileged/bin. 2023-02-05 0:00 ` [bug#61462] [PATCH 01/10] system: Disallow file-like setuid-programs Tobias Geerinckx-Rice via Guix-patches via @ 2023-02-05 0:00 ` Tobias Geerinckx-Rice via Guix-patches via 2023-02-05 0:00 ` [bug#61462] [PATCH 03/10] system: Use /run/privileged/bin in search paths Tobias Geerinckx-Rice via Guix-patches via ` (7 subsequent siblings) 8 siblings, 0 replies; 35+ messages in thread From: Tobias Geerinckx-Rice via Guix-patches via @ 2023-02-05 0:00 UTC (permalink / raw) To: 61462 Create /run/setuid-programs compatibility symlinks so that we can migrate all users (both package and human) piecemeal at our leisure. Apart from being symlinks, this should be a user-invisible change. * gnu/build/activation.scm (%privileged-program-directory): New variable. [activate-setuid-programs]: Put privileged copies in %PRIVILEGED-PROGRAM-DIRECTORY, with compatibility symlinks to each in %SETUID-DIRECTORY. * gnu/services.scm (setuid-program-service-type): Update docstring. * doc/guix.texi (Setuid Programs): Update @file{} name accordingly. --- doc/guix.texi | 2 +- gnu/build/activation.scm | 54 ++++++++++++++++++++++++++-------------- gnu/services.scm | 9 +++++-- 3 files changed, 44 insertions(+), 21 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 44e2165a82..009bcf5d40 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -38219,7 +38219,7 @@ The list includes commands such as @command{passwd}, @command{ping}, @end defvar Under the hood, the actual setuid programs are created in the -@file{/run/setuid-programs} directory at system activation time. The +@file{/run/privileged/bin} directory at system activation time. The files in this directory refer to the ``real'' binaries, which are in the store. diff --git a/gnu/build/activation.scm b/gnu/build/activation.scm index eea2233563..af947a39fa 100644 --- a/gnu/build/activation.scm +++ b/gnu/build/activation.scm @@ -8,6 +8,7 @@ ;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be> ;;; Copyright © 2020 Christine Lemmer-Webber <cwebber@dustycloud.org> ;;; Copyright © 2021 Brice Waegeneire <brice@waegenei.re> +;;; Copyright © 2022 Tobias Geerinckx-Rice <me@tobias.gr> ;;; ;;; This file is part of GNU Guix. ;;; @@ -278,14 +279,29 @@ (define (rm-f file) string<?))) (define %setuid-directory - ;; Place where setuid programs are stored. + ;; Place where setuid programs used to be stored. It exists for backwards + ;; compatibility & will be removed. Use %PRIVILEGED-PROGRAM-DIRECTORY instead. "/run/setuid-programs") +(define %privileged-program-directory + ;; Place where privileged copies of programs are stored. + "/run/privileged/bin") + (define (activate-setuid-programs programs) - "Turn PROGRAMS, a list of file setuid-programs record, into setuid programs -stored under %SETUID-DIRECTORY." - (define (make-setuid-program program setuid? setgid? uid gid) - (let ((target (string-append %setuid-directory + "Turn PROGRAMS, a list of file setuid-programs records, into privileged +copies stored under %PRIVILEGED-PROGRAM-DIRECTORY." + (define (ensure-empty-directory directory) + (if (file-exists? directory) + (for-each (compose delete-file + (cut string-append directory "/" <>)) + (scandir directory + (lambda (file) + (not (member file '("." "..")))) + string<?)) + (mkdir-p directory)) ) + + (define (make-privileged-program program setuid? setgid? uid gid) + (let ((target (string-append %privileged-program-directory "/" (basename program))) (mode (+ #o0555 ; base permissions (if setuid? #o4000 0) ; setuid bit @@ -294,16 +310,17 @@ (define (make-setuid-program program setuid? setgid? uid gid) (chown target uid gid) (chmod target mode))) - (format #t "setting up setuid programs in '~a'...~%" - %setuid-directory) - (if (file-exists? %setuid-directory) - (for-each (compose delete-file - (cut string-append %setuid-directory "/" <>)) - (scandir %setuid-directory - (lambda (file) - (not (member file '("." "..")))) - string<?)) - (mkdir-p %setuid-directory)) + (define (make-deprecated-wrapper program) + ;; This will eventually become a script that warns on usage, then vanish. + (symlink (string-append %privileged-program-directory + "/" (basename program)) + (string-append %setuid-directory + "/" (basename program)))) + + (format #t "setting up privileged program in '~a'...~%" + %privileged-program-directory) + (ensure-empty-directory %privileged-program-directory) + (ensure-empty-directory %setuid-directory) (for-each (lambda (program) (catch 'system-error @@ -319,11 +336,12 @@ (define (make-setuid-program program setuid? setgid? uid gid) (gid (match group ((? string?) (group:gid (getgrnam group))) ((? integer?) group)))) - (make-setuid-program program-name setuid? setgid? uid gid))) + (make-privileged-program program-name setuid? setgid? uid gid) + (make-deprecated-wrapper program-name))) (lambda args ;; If we fail to create a setuid program, better keep going - ;; so that we don't leave %SETUID-DIRECTORY empty or - ;; half-populated. This can happen if PROGRAMS contains + ;; so that we don't leave %PRIVILEGED-PROGRAM-DIRECTORY empty + ;; or half-populated. This can happen if PROGRAMS contains ;; incorrect file names: <https://bugs.gnu.org/38800>. (format (current-error-port) "warning: failed to make ~s setuid/setgid: ~a~%" diff --git a/gnu/services.scm b/gnu/services.scm index 2abef557d4..26546e1369 100644 --- a/gnu/services.scm +++ b/gnu/services.scm @@ -6,6 +6,7 @@ ;;; Copyright © 2021 raid5atemyhomework <raid5atemyhomework@protonmail.com> ;;; Copyright © 2020 Christine Lemmer-Webber <cwebber@dustycloud.org> ;;; Copyright © 2020, 2021 Brice Waegeneire <brice@waegenei.re> +;;; Copyright © 2022 Tobias Geerinckx-Rice <me@tobias.gr> ;;; ;;; This file is part of GNU Guix. ;;; @@ -842,8 +843,12 @@ (define setuid-program-service-type (extend (lambda (config extensions) (append config extensions))) (description - "Populate @file{/run/setuid-programs} with the specified -executables, making them setuid and/or setgid."))) + "Copy the specified executables to @file{/run/privileged/bin} +and apply special privileges like setuid and/or setgid. + +The deprecated @file{/run/setuid-programs} directory is also populated with +symbolic links to their @file{/run/privileged/bin} counterpart. It will be +removed in a future Guix release."))) (define (packages->profile-entry packages) "Return a system entry for the profile containing PACKAGES." -- 2.39.1 ^ permalink raw reply related [flat|nested] 35+ messages in thread
* [bug#61462] [PATCH 03/10] system: Use /run/privileged/bin in search paths. 2023-02-05 0:00 ` [bug#61462] [PATCH 01/10] system: Disallow file-like setuid-programs Tobias Geerinckx-Rice via Guix-patches via 2023-02-05 0:00 ` [bug#61462] [PATCH 02/10] services: setuid-program: Populate /run/privileged/bin Tobias Geerinckx-Rice via Guix-patches via @ 2023-02-05 0:00 ` Tobias Geerinckx-Rice via Guix-patches via 2023-02-05 0:00 ` [bug#61462] [PATCH 04/10] gnu: Replace (almost) all uses of /run/setuid-programs Tobias Geerinckx-Rice via Guix-patches via ` (6 subsequent siblings) 8 siblings, 0 replies; 35+ messages in thread From: Tobias Geerinckx-Rice via Guix-patches via @ 2023-02-05 0:00 UTC (permalink / raw) To: 61462 * gnu/system.scm (operating-system-etc-service): Substitute /run/privileged/bin for deprecated /run/setuid-programs. --- gnu/system.scm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gnu/system.scm b/gnu/system.scm index 85380136e2..446439bcac 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -987,10 +987,10 @@ (define* (operating-system-etc-service os) (plain-file "login.defs" (string-append "# Default paths for non-login shells started by su(1).\n" - "ENV_PATH /run/setuid-programs:" + "ENV_PATH /run/privileged/bin:" "/run/current-system/profile/bin:" "/run/current-system/profile/sbin\n" - "ENV_SUPATH /run/setuid-programs:" + "ENV_SUPATH /run/privileged/bin:" "/run/current-system/profile/bin:" "/run/current-system/profile/sbin\n" @@ -1054,8 +1054,8 @@ (define* (operating-system-etc-service os) fi done -# Prepend setuid programs. -export PATH=/run/setuid-programs:$PATH +# Prepend privileged programs. +export PATH=/run/privileged/bin:$PATH # Arrange so that ~/.config/guix/current/share/info comes first. export INFOPATH=\"$HOME/.config/guix/current/share/info:$INFOPATH\" -- 2.39.1 ^ permalink raw reply related [flat|nested] 35+ messages in thread
* [bug#61462] [PATCH 04/10] gnu: Replace (almost) all uses of /run/setuid-programs. 2023-02-05 0:00 ` [bug#61462] [PATCH 01/10] system: Disallow file-like setuid-programs Tobias Geerinckx-Rice via Guix-patches via 2023-02-05 0:00 ` [bug#61462] [PATCH 02/10] services: setuid-program: Populate /run/privileged/bin Tobias Geerinckx-Rice via Guix-patches via 2023-02-05 0:00 ` [bug#61462] [PATCH 03/10] system: Use /run/privileged/bin in search paths Tobias Geerinckx-Rice via Guix-patches via @ 2023-02-05 0:00 ` Tobias Geerinckx-Rice via Guix-patches via 2023-02-05 0:00 ` [bug#61462] [PATCH 05/10] system: Add (gnu system privilege) Tobias Geerinckx-Rice via Guix-patches via ` (5 subsequent siblings) 8 siblings, 0 replies; 35+ messages in thread From: Tobias Geerinckx-Rice via Guix-patches via @ 2023-02-05 0:00 UTC (permalink / raw) To: 61462 …those good for master, anyway. * gnu/packages/admin.scm (ktsuss, opendoas, hosts) [arguments]: Replace /run/setuid-programs with /run/privileged/bin. * gnu/packages/containers.scm (slirp4netns)[arguments]: Likewise. * gnu/packages/debian.scm (pbuilder)[arguments]: Likewise. * gnu/packages/disk.scm (udevil)[arguments]: Likewise. * gnu/packages/enlightenment.scm (efl, enlightenment) [arguments]: Likewise. * gnu/packages/gnome.scm (gdm, gnome-control-center) [arguments]: Likewise. * gnu/packages/linux.scm (singularity)[arguments]: Likewise. * gnu/packages/lxde.scm (spacefm)[arguments]: Likewise. * gnu/packages/monitoring.scm (zabbix-agentd)[arguments]: Likewise. * gnu/packages/virtualization.scm (ganeti)[arguments]: Likewise. * gnu/packages/xdisorg.scm (xsecurelock)[arguments]: Likewise. * gnu/services/dbus.scm (dbus-configuration-directory): Likewise. * gnu/services/ganeti.scm (%default-ganeti-environment-variables): Likewise. * gnu/services/monitoring.scm (zabbix-agent-shepherd-service): Likewise. * gnu/tests/ldap.scm (marionette): Likewise. * gnu/tests/monitoring.scm (os): Likewise. --- gnu/machine/ssh.scm | 2 ++ gnu/packages/admin.scm | 6 +++--- gnu/packages/containers.scm | 2 +- gnu/packages/debian.scm | 4 ++-- gnu/packages/disk.scm | 14 +++++++------- gnu/packages/enlightenment.scm | 10 +++++----- gnu/packages/gnome.scm | 4 ++-- gnu/packages/linux.scm | 2 +- gnu/packages/lxde.scm | 19 ++++++++----------- gnu/packages/monitoring.scm | 2 +- gnu/packages/virtualization.scm | 2 +- gnu/packages/xdisorg.scm | 2 +- gnu/services/dbus.scm | 2 +- gnu/services/ganeti.scm | 2 +- gnu/services/monitoring.scm | 2 +- gnu/tests/ldap.scm | 2 +- gnu/tests/monitoring.scm | 4 ++-- 17 files changed, 40 insertions(+), 41 deletions(-) diff --git a/gnu/machine/ssh.scm b/gnu/machine/ssh.scm index 343cf74748..26ea787e29 100644 --- a/gnu/machine/ssh.scm +++ b/gnu/machine/ssh.scm @@ -177,6 +177,8 @@ (define (machine-become-command machine) (if (string= "root" (machine-ssh-configuration-user (machine-configuration machine))) '() + ;; Use the old setuid-programs location until the remote is likely to + ;; have the new /run/privileged one in place. '("/run/setuid-programs/sudo" "-n" "--"))) (define (managed-host-remote-eval machine exp) diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm index 3d0886aba8..c022e9224c 100644 --- a/gnu/packages/admin.scm +++ b/gnu/packages/admin.scm @@ -199,7 +199,7 @@ (define-public ktsuss (lambda _ (substitute* "configure.ac" (("supath=`which su 2>/dev/null`") - "supath=/run/setuid-programs/su")) + "supath=/run/privileged/bin/su")) #t))))) (native-inputs (list autoconf automake libtool pkg-config)) @@ -2086,7 +2086,7 @@ (define-public opendoas (substitute* "doas.c" (("safepath =" match) (string-append match " \"" - "/run/setuid-programs:" + "/run/privileged/bin:" "/run/current-system/profile/bin:" "/run/current-system/profile/sbin:" "\" "))))) @@ -4863,7 +4863,7 @@ (define-public hosts ":" (assoc-ref %build-inputs "grep") "/bin" ":" (assoc-ref %build-inputs "ncurses") "/bin" ":" (assoc-ref %build-inputs "sed") "/bin" - ":" "/run/setuid-programs" + ":" "/run/privileged/bin" ":" (getenv "PATH"))) (substitute* "hosts" (("#!/usr/bin/env bash") diff --git a/gnu/packages/containers.scm b/gnu/packages/containers.scm index 3982f4f059..8976ca3b20 100644 --- a/gnu/packages/containers.scm +++ b/gnu/packages/containers.scm @@ -236,7 +236,7 @@ (define-public slirp4netns (add-after 'unpack 'fix-hardcoded-paths (lambda _ (substitute* (find-files "tests" "\\.sh") - (("ping") "/run/setuid-programs/ping"))))))) + (("ping") "/run/privileged/bin/ping"))))))) (inputs (list glib libcap diff --git a/gnu/packages/debian.scm b/gnu/packages/debian.scm index 4319d3a518..308f2bc286 100644 --- a/gnu/packages/debian.scm +++ b/gnu/packages/debian.scm @@ -493,8 +493,8 @@ (define-public pbuilder (lambda () (format #t "# A couple of presets to make this work more smoothly.~@ MIRRORSITE=\"http://deb.debian.org/debian\"~@ - if [ -r /run/setuid-programs/sudo ]; then~@ - PBUILDERROOTCMD=\"/run/setuid-programs/sudo -E\"~@ + if [ -r /run/privileged/bin/sudo ]; then~@ + PBUILDERROOTCMD=\"/run/privileged/bin/sudo -E\"~@ fi~@ PBUILDERSATISFYDEPENDSCMD=\"~a/lib/pbuilder/pbuilder-satisfydepends-apt\"~%" #$output))))) diff --git a/gnu/packages/disk.scm b/gnu/packages/disk.scm index f9fe9c5989..4f78a3aa9e 100644 --- a/gnu/packages/disk.scm +++ b/gnu/packages/disk.scm @@ -198,10 +198,10 @@ (define-public udevil ;; udevil expects these programs to be run with uid set as root. ;; user has to manually add these programs to setuid-programs. ;; mount and umount are default setuid-programs in guix system. - "--with-mount-prog=/run/setuid-programs/mount" - "--with-umount-prog=/run/setuid-programs/umount" - "--with-losetup-prog=/run/setuid-programs/losetup" - "--with-setfacl-prog=/run/setuid-programs/setfacl") + "--with-mount-prog=/run/privileged/bin/mount" + "--with-umount-prog=/run/privileged/bin/umount" + "--with-losetup-prog=/run/privileged/bin/losetup" + "--with-setfacl-prog=/run/privileged/bin/setfacl") #:phases (modify-phases %standard-phases (add-after 'unpack 'remove-root-reference @@ -212,12 +212,12 @@ (define-public udevil (add-after 'unpack 'patch-udevil-reference ;; udevil expects itself to be run with uid set as root. ;; devmon also expects udevil to be run with uid set as root. - ;; user has to manually add udevil to setuid-programs. + ;; user has to manually add udevil to privileged-programs. (lambda _ (substitute* "src/udevil.c" - (("/usr/bin/udevil") "/run/setuid-programs/udevil")) + (("/usr/bin/udevil") "/run/privileged/bin/udevil")) (substitute* "src/devmon" - (("`which udevil 2>/dev/null`") "/run/setuid-programs/udevil")) + (("`which udevil 2>/dev/null`") "/run/privileged/bin/udevil")) #t))))) (native-inputs (list intltool pkg-config)) diff --git a/gnu/packages/enlightenment.scm b/gnu/packages/enlightenment.scm index a08ad05143..0bb6bf3bcc 100644 --- a/gnu/packages/enlightenment.scm +++ b/gnu/packages/enlightenment.scm @@ -150,8 +150,8 @@ (define-public efl "-Dbuild-examples=false" "-Decore-imf-loaders-disabler=scim" "-Dglib=true" - "-Dmount-path=/run/setuid-programs/mount" - "-Dunmount-path=/run/setuid-programs/umount" + "-Dmount-path=/run/privileged/bin/mount" + "-Dunmount-path=/run/privileged/bin/umount" "-Dnetwork-backend=connman" ,,@(if (member (%current-system) (package-transitive-supported-systems luajit)) @@ -339,7 +339,7 @@ (define-public enlightenment (substitute* '("src/bin/e_sys_main.c" "src/bin/e_util_suid.h") (("PATH=/bin:/usr/bin:/sbin:/usr/sbin") - (string-append "PATH=/run/setuid-programs:" + (string-append "PATH=/run/privileged/bin:" "/run/current-system/profile/bin:" "/run/current-system/profile/sbin"))) (substitute* "src/modules/everything/evry_plug_calc.c" @@ -348,8 +348,8 @@ (define-public enlightenment (("libddcutil\\.so\\.?" libddcutil) (string-append ddcutil "/lib/" libddcutil))) (substitute* "data/etc/meson.build" - (("/bin/mount") "/run/setuid-programs/mount") - (("/bin/umount") "/run/setuid-programs/umount") + (("/bin/mount") "/run/privileged/bin/mount") + (("/bin/umount") "/run/privileged/bin/umount") (("/usr/bin/eject") "/run/current-system/profile/bin/eject")) (substitute* "src/bin/system/e_system_power.c" (("systemctl") "loginctl")))))))) diff --git a/gnu/packages/gnome.scm b/gnu/packages/gnome.scm index 19a96ef9f4..1891e9bf11 100644 --- a/gnu/packages/gnome.scm +++ b/gnu/packages/gnome.scm @@ -9013,7 +9013,7 @@ (define-public gdm "--localstatedir=/var" (string-append "-Ddefault-path=" - (string-join '("/run/setuid-programs" + (string-join '("/run/privileged/bin" "/run/current-system/profile/bin" "/run/current-system/profile/sbin") ":")) @@ -9290,7 +9290,7 @@ (define-public gnome-control-center inputs "bin/nm-connection-editor")))) (substitute* "panels/user-accounts/run-passwd.c" (("/usr/bin/passwd") - "/run/setuid-programs/passwd")) + "/run/privileged/bin/passwd")) (substitute* "panels/info-overview/cc-info-overview-panel.c" (("DATADIR \"/gnome/gnome-version.xml\"") (format #f "~s" (search-input-file diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm index 13e2ca9493..19c68cc429 100644 --- a/gnu/packages/linux.scm +++ b/gnu/packages/linux.scm @@ -5027,7 +5027,7 @@ (define-public singularity (substitute* (find-files "libexec/cli" "\\.exec$") (("\\$SINGULARITY_libexecdir/singularity/bin/([a-z]+)-suid" _ program) - (string-append "/run/setuid-programs/singularity-" + (string-append "/run/privileged/bin/singularity-" program "-helper"))) ;; These squashfs mount options are apparently no longer diff --git a/gnu/packages/lxde.scm b/gnu/packages/lxde.scm index 0657db6eb8..9b380ede0e 100644 --- a/gnu/packages/lxde.scm +++ b/gnu/packages/lxde.scm @@ -372,26 +372,23 @@ (define-public spacefm (substitute* '("mime-type/mime-type.c" "ptk/ptk-file-menu.c") (("/usr(/local)?/share/mime") mime))) #t))) - (add-after 'patch-mime-dirs 'patch-setuid-progs + (add-after 'patch-mime-dirs 'patch-privileged-programs (lambda _ - (let* ((su "/run/setuid-programs/su") - (mount "/run/setuid-programs/mount") - (umount "/run/setuid-programs/umount") - (udevil "/run/setuid-programs/udevil")) + (let ((privileged (lambda (command) + (string-append "/run/privileged/bin/" + command)))) (with-directory-excursion "src" (substitute* '("settings.c" "settings.h" "vfs/vfs-file-task.c" "vfs/vfs-volume-hal.c" "../data/ui/prefdlg.ui" "../data/ui/prefdlg2.ui") - (("(/usr)?/bin/su") su) - (("/(bin|sbin)/mount") mount) - (("/(bin|sbin)/umount") umount) - (("/usr/bin/udevil") udevil))) + (("(/usr)?/s?bin/(mount|umount|su|udevil)" _ _ command) + (privileged command)))) #t))) - (add-after 'patch-setuid-progs 'patch-spacefm-conf + (add-after 'patch-privileged-programs 'patch-spacefm.conf (lambda* (#:key inputs #:allow-other-keys) (substitute* "etc/spacefm.conf" (("#terminal_su=/bin/su") - "terminal_su=/run/setuid-programs/su") + "terminal_su=/run/privileged/bin/su") (("#graphical_su=/usr/bin/gksu") (string-append "graphical_su=" (search-input-file inputs "/bin/ktsuss"))))))) diff --git a/gnu/packages/monitoring.scm b/gnu/packages/monitoring.scm index 74ec7b6cdf..2571994624 100644 --- a/gnu/packages/monitoring.scm +++ b/gnu/packages/monitoring.scm @@ -187,7 +187,7 @@ (define-public zabbix-agentd "src/zabbix_server/server.c") ;; 'fping' must be setuid, so look for it in the usual location. (("/usr/sbin/fping6?") - "/run/setuid-programs/fping"))))) + "/run/privileged/bin/fping"))))) (build-system gnu-build-system) (arguments (list #:configure-flags diff --git a/gnu/packages/virtualization.scm b/gnu/packages/virtualization.scm index 64a26edb02..ac1d0f3cd3 100644 --- a/gnu/packages/virtualization.scm +++ b/gnu/packages/virtualization.scm @@ -761,7 +761,7 @@ (define-public ganeti ;; hard coded PATH. Patch so it works on Guix System. (substitute* "src/Ganeti/Constants.hs" (("/sbin:/bin:/usr/sbin:/usr/bin") - "/run/setuid-programs:/run/current-system/profile/sbin:\ + "/run/privileged/bin:/run/current-system/profile/sbin:\ /run/current-system/profile/bin")))) (add-after 'bootstrap 'patch-sphinx-version-detection (lambda _ diff --git a/gnu/packages/xdisorg.scm b/gnu/packages/xdisorg.scm index 2ebeb4e013..d53329b243 100644 --- a/gnu/packages/xdisorg.scm +++ b/gnu/packages/xdisorg.scm @@ -2434,7 +2434,7 @@ (define-public xsecurelock '(#:configure-flags '("--with-pam-service-name=login" "--with-xkb" - "--with-default-authproto-module=/run/setuid-programs/authproto_pam"))) + "--with-default-authproto-module=/run/privileged/bin/authproto_pam"))) (native-inputs (list pandoc pkg-config)) (inputs diff --git a/gnu/services/dbus.scm b/gnu/services/dbus.scm index 5efd6bdadf..cb1c94a607 100644 --- a/gnu/services/dbus.scm +++ b/gnu/services/dbus.scm @@ -114,7 +114,7 @@ (define (services->sxml services) ;; failures such as <https://issues.guix.gnu.org/52051> on slow ;; computers with slow I/O. (limit (@ (name "auth_timeout")) "300000") - (servicehelper "/run/setuid-programs/dbus-daemon-launch-helper") + (servicehelper "/run/privileged/bin/dbus-daemon-launch-helper") ;; First, the '.service' files of services subject to activation. ;; We use a fixed location under /etc because the setuid helper diff --git a/gnu/services/ganeti.scm b/gnu/services/ganeti.scm index f4fec3833e..ee72946c88 100644 --- a/gnu/services/ganeti.scm +++ b/gnu/services/ganeti.scm @@ -182,7 +182,7 @@ (define-module (gnu services ganeti) ;; Ceph, Gluster, etc, without having to add absolute references to everything. (define %default-ganeti-environment-variables (list (string-append "PATH=" - (string-join '("/run/setuid-programs" + (string-join '("/run/privileged/bin" "/run/current-system/profile/sbin" "/run/current-system/profile/bin") ":")))) diff --git a/gnu/services/monitoring.scm b/gnu/services/monitoring.scm index 44e2e8886c..b86b0ab87d 100644 --- a/gnu/services/monitoring.scm +++ b/gnu/services/monitoring.scm @@ -544,7 +544,7 @@ (define (zabbix-agent-shepherd-service config) /etc/ssl/certs" "SSL_CERT_FILE=/run/current-system/profile\ /etc/ssl/certs/ca-certificates.crt" - "PATH=/run/setuid-programs:\ + "PATH=/run/privileged/bin:\ /run/current-system/profile/bin:/run/current-system/profile/sbin"))) (stop #~(make-kill-destructor))))) diff --git a/gnu/tests/ldap.scm b/gnu/tests/ldap.scm index 47e77c0c53..d5ab6899cf 100644 --- a/gnu/tests/ldap.scm +++ b/gnu/tests/ldap.scm @@ -144,7 +144,7 @@ (define marionette (test-assert "Can become LDAP user" (marionette-eval - '(zero? (system* "/run/setuid-programs/su" "eva" "-c" + '(zero? (system* "/run/privileged/bin/su" "eva" "-c" #$(file-append coreutils "/bin/true"))) marionette)) diff --git a/gnu/tests/monitoring.scm b/gnu/tests/monitoring.scm index ae0a8e0845..f5e3f591a7 100644 --- a/gnu/tests/monitoring.scm +++ b/gnu/tests/monitoring.scm @@ -189,11 +189,11 @@ (define marionette (start-service 'postgres)) marionette)) - ;; Add /run/setuid-programs to $PATH so that the scripts passed to + ;; Add privileged programs to $PATH so that the scripts passed to ;; 'system' can find 'sudo'. (marionette-eval '(setenv "PATH" - "/run/setuid-programs:/run/current-system/profile/bin") + "/run/privileged/bin:/run/current-system/profile/bin") marionette) (test-eq "postgres create zabbix user" -- 2.39.1 ^ permalink raw reply related [flat|nested] 35+ messages in thread
* [bug#61462] [PATCH 05/10] system: Add (gnu system privilege). 2023-02-05 0:00 ` [bug#61462] [PATCH 01/10] system: Disallow file-like setuid-programs Tobias Geerinckx-Rice via Guix-patches via ` (2 preceding siblings ...) 2023-02-05 0:00 ` [bug#61462] [PATCH 04/10] gnu: Replace (almost) all uses of /run/setuid-programs Tobias Geerinckx-Rice via Guix-patches via @ 2023-02-05 0:00 ` Tobias Geerinckx-Rice via Guix-patches via 2023-02-05 0:00 ` [bug#61462] [PATCH 06/10] system: (gnu system setuid) wraps " Tobias Geerinckx-Rice via Guix-patches via ` (4 subsequent siblings) 8 siblings, 0 replies; 35+ messages in thread From: Tobias Geerinckx-Rice via Guix-patches via @ 2023-02-05 0:00 UTC (permalink / raw) To: 61462 * gnu/system/privilege.scm: New file. * gnu/local.mk (GNU_SYSTEM_MODULES): Add it. --- gnu/local.mk | 1 + gnu/system/privilege.scm | 58 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 gnu/system/privilege.scm diff --git a/gnu/local.mk b/gnu/local.mk index cdb99813d0..acf74cd9ae 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -723,6 +723,7 @@ GNU_SYSTEM_MODULES = \ %D%/system/mapped-devices.scm \ %D%/system/nss.scm \ %D%/system/pam.scm \ + %D%/system/privilege.scm \ %D%/system/setuid.scm \ %D%/system/shadow.scm \ %D%/system/uuid.scm \ diff --git a/gnu/system/privilege.scm b/gnu/system/privilege.scm new file mode 100644 index 0000000000..d89d5d5d1c --- /dev/null +++ b/gnu/system/privilege.scm @@ -0,0 +1,58 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2021 Brice Waegeneire <brice@waegenei.re> +;;; Copyright © 2022 Tobias Geerinckx-Rice <me@tobias.gr> +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. + +(define-module (gnu system privilege) + #:use-module (guix records) + #:export (privileged-program + privileged-program? + privileged-program-program + privileged-program-setuid? + privileged-program-setgid? + privileged-program-user + privileged-program-group + privileged-program-capabilities)) + +;;; Commentary: +;;; +;;; Data structures representing privileged programs: binaries with additional +;;; permissions such as setuid/setgid, or POSIX capabilities. This is meant to +;;; be used both on the host side and at run time--e.g., in activation snippets. +;;; +;;; Code: + +(define-record-type* <privileged-program> + privileged-program make-privileged-program + privileged-program? + ;; File name of the program to assign elevated privileges. + (program privileged-program-program) ;file-like + ;; Whether to set the setuid (‘set user ID’) bit. + (setuid? privileged-program-setuid? ;boolean + (default #f)) + ;; Whether to set the setgid (‘set group ID’) bit. + (setgid? privileged-program-setgid? ;boolean + (default #f)) + ;; The user name or ID this should be set to (defaults to root's). + (user privileged-program-user ;integer or string + (default 0)) + ;; The group name or ID we want to set this to (defaults to root's). + (group privileged-program-group ;integer or string + (default 0)) + ;; POSIX capabilities in cap_from_text(3) form (defaults to #f: none). + (capabilities privileged-program-capabilities ;string or #f + (default #f))) -- 2.39.1 ^ permalink raw reply related [flat|nested] 35+ messages in thread
* [bug#61462] [PATCH 06/10] system: (gnu system setuid) wraps (gnu system privilege). 2023-02-05 0:00 ` [bug#61462] [PATCH 01/10] system: Disallow file-like setuid-programs Tobias Geerinckx-Rice via Guix-patches via ` (3 preceding siblings ...) 2023-02-05 0:00 ` [bug#61462] [PATCH 05/10] system: Add (gnu system privilege) Tobias Geerinckx-Rice via Guix-patches via @ 2023-02-05 0:00 ` Tobias Geerinckx-Rice via Guix-patches via 2023-02-05 0:00 ` [bug#61462] [PATCH 07/10] build: Rename activate-setuid-programs Tobias Geerinckx-Rice via Guix-patches via ` (3 subsequent siblings) 8 siblings, 0 replies; 35+ messages in thread From: Tobias Geerinckx-Rice via Guix-patches via @ 2023-02-05 0:00 UTC (permalink / raw) To: 61462 * gnu/system/setuid.scm (setuid-program): Rewrite as syntax to create a <privileged-program> record that is setuid by default. (setuid-program?, setuid-program-program, setuid-program-setuid?) (setuid-program-setgid?, setuid-program-user, setuid-program-group): Alias their privileged-program equivalent. --- gnu/system/setuid.scm | 44 +++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/gnu/system/setuid.scm b/gnu/system/setuid.scm index 83111d932c..4dd0cc8962 100644 --- a/gnu/system/setuid.scm +++ b/gnu/system/setuid.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2021 Brice Waegeneire <brice@waegenei.re> +;;; Copyright © 2022 Tobias Geerinckx-Rice <me@tobias.gr> ;;; ;;; This file is part of GNU Guix. ;;; @@ -17,7 +18,9 @@ ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. (define-module (gnu system setuid) - #:use-module (guix records) + #:use-module (gnu system privilege) + #:use-module (ice-9 match) + #:use-module (srfi srfi-1) #:export (setuid-program setuid-program? setuid-program-program @@ -30,28 +33,29 @@ (define-module (gnu system setuid) ;;; Commentary: ;;; -;;; Data structures representing setuid/setgid programs. This is meant to be -;;; used both on the host side and at run time--e.g., in activation snippets. +;;; Do not use this module in new code. It used to define data structures +;;; representing setuid/setgid programs, but is now a mere compatibility shim +;;; wrapping a subset of (gnu system privilege). ;;; ;;; Code: -(define-record-type* <setuid-program> - setuid-program make-setuid-program - setuid-program? - ;; Path to program to link with setuid permissions - (program setuid-program-program) ;file-like - ;; Whether to set user setuid bit - (setuid? setuid-program-setuid? ;boolean - (default #t)) - ;; Whether to set group setgid bit - (setgid? setuid-program-setgid? ;boolean - (default #f)) - ;; The user this should be set to (defaults to root) - (user setuid-program-user ;integer or string - (default 0)) - ;; Group we want to set this to (defaults to root) - (group setuid-program-group ;integer or string - (default 0))) +(define-syntax setuid-program + (lambda (fields) + (syntax-case fields () + ((_ (field value) ...) + #`(privileged-program + (setuid? (match (assoc-ref '((field value) ...) 'setuid?) + ((#f) #f) + (_ #t))) + #,@(remove (match-lambda ((f _) (eq? (syntax->datum f) 'setuid?))) + #'((field value) ...))))))) + +(define setuid-program? privileged-program?) +(define setuid-program-program privileged-program-program) +(define setuid-program-setuid? privileged-program-setuid?) +(define setuid-program-setgid? privileged-program-setgid?) +(define setuid-program-user privileged-program-user) +(define setuid-program-group privileged-program-group) (define (file-like->setuid-program program) (setuid-program (program program))) -- 2.39.1 ^ permalink raw reply related [flat|nested] 35+ messages in thread
* [bug#61462] [PATCH 07/10] build: Rename activate-setuid-programs. 2023-02-05 0:00 ` [bug#61462] [PATCH 01/10] system: Disallow file-like setuid-programs Tobias Geerinckx-Rice via Guix-patches via ` (4 preceding siblings ...) 2023-02-05 0:00 ` [bug#61462] [PATCH 06/10] system: (gnu system setuid) wraps " Tobias Geerinckx-Rice via Guix-patches via @ 2023-02-05 0:00 ` Tobias Geerinckx-Rice via Guix-patches via 2023-02-05 0:00 ` [bug#61462] [PATCH 08/10] services: Rename setuid-program-service-type Tobias Geerinckx-Rice via Guix-patches via ` (2 subsequent siblings) 8 siblings, 0 replies; 35+ messages in thread From: Tobias Geerinckx-Rice via Guix-patches via @ 2023-02-05 0:00 UTC (permalink / raw) To: 61462 * gnu/build/activation.scm (activate-setuid-programs): Rename this… (activate-privileged-programs): …to this. Operate on a list of <privileged-program> records. * gnu/services.scm (setuid-program->activation-gexp): Adjust caller. --- gnu/build/activation.scm | 24 ++++++++++++------------ gnu/services.scm | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/gnu/build/activation.scm b/gnu/build/activation.scm index af947a39fa..b5004a292c 100644 --- a/gnu/build/activation.scm +++ b/gnu/build/activation.scm @@ -27,7 +27,7 @@ (define-module (gnu build activation) #:use-module (gnu system accounts) - #:use-module (gnu system setuid) + #:use-module (gnu system privilege) #:use-module (gnu build accounts) #:use-module (gnu build linux-boot) #:use-module (guix build utils) @@ -41,7 +41,7 @@ (define-module (gnu build activation) #:export (activate-users+groups activate-user-home activate-etc - activate-setuid-programs + activate-privileged-programs activate-special-files activate-modprobe activate-firmware @@ -287,8 +287,8 @@ (define %privileged-program-directory ;; Place where privileged copies of programs are stored. "/run/privileged/bin") -(define (activate-setuid-programs programs) - "Turn PROGRAMS, a list of file setuid-programs records, into privileged +(define (activate-privileged-programs programs) + "Turn PROGRAMS, a list of file privileged-programs records, into privileged copies stored under %PRIVILEGED-PROGRAM-DIRECTORY." (define (ensure-empty-directory directory) (if (file-exists? directory) @@ -325,11 +325,11 @@ (define (make-deprecated-wrapper program) (for-each (lambda (program) (catch 'system-error (lambda () - (let* ((program-name (setuid-program-program program)) - (setuid? (setuid-program-setuid? program)) - (setgid? (setuid-program-setgid? program)) - (user (setuid-program-user program)) - (group (setuid-program-group program)) + (let* ((program-name (privileged-program-program program)) + (setuid? (privileged-program-setuid? program)) + (setgid? (privileged-program-setgid? program)) + (user (privileged-program-user program)) + (group (privileged-program-group program)) (uid (match user ((? string?) (passwd:uid (getpwnam user))) ((? integer?) user))) @@ -339,13 +339,13 @@ (define (make-deprecated-wrapper program) (make-privileged-program program-name setuid? setgid? uid gid) (make-deprecated-wrapper program-name))) (lambda args - ;; If we fail to create a setuid program, better keep going + ;; If we fail to create a privileged program, better keep going ;; so that we don't leave %PRIVILEGED-PROGRAM-DIRECTORY empty ;; or half-populated. This can happen if PROGRAMS contains ;; incorrect file names: <https://bugs.gnu.org/38800>. (format (current-error-port) - "warning: failed to make ~s setuid/setgid: ~a~%" - (setuid-program-program program) + "warning: failed to privilege ~s: ~a~%" + (privileged-program-program program) (strerror (system-error-errno args)))))) programs)) diff --git a/gnu/services.scm b/gnu/services.scm index 26546e1369..af9f4e1db6 100644 --- a/gnu/services.scm +++ b/gnu/services.scm @@ -832,7 +832,7 @@ (define (setuid-program->activation-gexp programs) #~(begin (use-modules (gnu system setuid)) - (activate-setuid-programs (list #$@programs)))))) + (activate-privileged-programs (list #$@programs)))))) (define setuid-program-service-type (service-type (name 'setuid-program) -- 2.39.1 ^ permalink raw reply related [flat|nested] 35+ messages in thread
* [bug#61462] [PATCH 08/10] services: Rename setuid-program-service-type. 2023-02-05 0:00 ` [bug#61462] [PATCH 01/10] system: Disallow file-like setuid-programs Tobias Geerinckx-Rice via Guix-patches via ` (5 preceding siblings ...) 2023-02-05 0:00 ` [bug#61462] [PATCH 07/10] build: Rename activate-setuid-programs Tobias Geerinckx-Rice via Guix-patches via @ 2023-02-05 0:00 ` Tobias Geerinckx-Rice via Guix-patches via 2023-02-05 0:00 ` [bug#61462] [PATCH 09/10] system: Use privileged-program-service-type by default Tobias Geerinckx-Rice via Guix-patches via 2023-02-05 0:00 ` [bug#61462] [PATCH 10/10] system: Add privileged-programs to <operating-system> Tobias Geerinckx-Rice via Guix-patches via 8 siblings, 0 replies; 35+ messages in thread From: Tobias Geerinckx-Rice via Guix-patches via @ 2023-02-05 0:00 UTC (permalink / raw) To: 61462 * gnu/services.scm (setuid-program->activation-gexp): Rename this… (privileged-program->activation-gexp): …to this. Operate on a list of <privileged-program> records. (privileged-program-service-type): New variable, renamed from setuid-program-service-type. Rename the service-type accordingly. (setuid-program-service-type): Redefine as an alias for the above. --- gnu/services.scm | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/gnu/services.scm b/gnu/services.scm index af9f4e1db6..09ff58dcd1 100644 --- a/gnu/services.scm +++ b/gnu/services.scm @@ -43,6 +43,7 @@ (define-module (gnu services) #:use-module (gnu packages base) #:use-module (gnu packages bash) #:use-module (gnu packages hurd) + #:use-module (gnu system privilege) #:use-module (gnu system setuid) #:use-module (srfi srfi-1) #:use-module (srfi srfi-9) @@ -110,7 +111,8 @@ (define-module (gnu services) extra-special-file etc-service-type etc-directory - setuid-program-service-type + privileged-program-service-type + setuid-program-service-type ; deprecated profile-service-type firmware-service-type gc-root-service-type @@ -810,17 +812,17 @@ (define (etc-service files) FILES must be a list of name/file-like object pairs." (service etc-service-type files)) -(define (setuid-program->activation-gexp programs) - "Return an activation gexp for setuid-program from PROGRAMS." +(define (privileged-program->activation-gexp programs) + "Return an activation gexp for privileged-program from PROGRAMS." (let ((programs (map (lambda (program) ;; FIXME This is really ugly, I didn't managed to use ;; "inherit" - (let ((program-name (setuid-program-program program)) - (setuid? (setuid-program-setuid? program)) - (setgid? (setuid-program-setgid? program)) - (user (setuid-program-user program)) - (group (setuid-program-group program)) ) - #~(setuid-program + (let ((program-name (privileged-program-program program)) + (setuid? (privileged-program-setuid? program)) + (setgid? (privileged-program-setgid? program)) + (user (privileged-program-user program)) + (group (privileged-program-group program)) ) + #~(privileged-program (setuid? #$setuid?) (setgid? #$setgid?) (user #$user) @@ -828,17 +830,17 @@ (define (setuid-program->activation-gexp programs) (program #$program-name)))) programs))) (with-imported-modules (source-module-closure - '((gnu system setuid))) + '((gnu system privilege))) #~(begin - (use-modules (gnu system setuid)) + (use-modules (gnu system privilege)) (activate-privileged-programs (list #$@programs)))))) -(define setuid-program-service-type - (service-type (name 'setuid-program) +(define privileged-program-service-type + (service-type (name 'privileged-program) (extensions (list (service-extension activation-service-type - setuid-program->activation-gexp))) + privileged-program->activation-gexp))) (compose concatenate) (extend (lambda (config extensions) (append config extensions))) @@ -850,6 +852,10 @@ (define setuid-program-service-type symbolic links to their @file{/run/privileged/bin} counterpart. It will be removed in a future Guix release."))) +(define setuid-program-service-type + ;; Deprecated alias to ease transition. Will be removed! + privileged-program-service-type) + (define (packages->profile-entry packages) "Return a system entry for the profile containing PACKAGES." ;; XXX: 'mlet' is needed here for one reason: to get the proper -- 2.39.1 ^ permalink raw reply related [flat|nested] 35+ messages in thread
* [bug#61462] [PATCH 09/10] system: Use privileged-program-service-type by default. 2023-02-05 0:00 ` [bug#61462] [PATCH 01/10] system: Disallow file-like setuid-programs Tobias Geerinckx-Rice via Guix-patches via ` (6 preceding siblings ...) 2023-02-05 0:00 ` [bug#61462] [PATCH 08/10] services: Rename setuid-program-service-type Tobias Geerinckx-Rice via Guix-patches via @ 2023-02-05 0:00 ` Tobias Geerinckx-Rice via Guix-patches via 2023-02-05 0:00 ` [bug#61462] [PATCH 10/10] system: Add privileged-programs to <operating-system> Tobias Geerinckx-Rice via Guix-patches via 8 siblings, 0 replies; 35+ messages in thread From: Tobias Geerinckx-Rice via Guix-patches via @ 2023-02-05 0:00 UTC (permalink / raw) To: 61462 * gnu/system.scm (operating-system-default-essential-services) (hurd-default-essential-services): Substitute privileged-program-service-type for setuid-program-service-type. --- gnu/system.scm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gnu/system.scm b/gnu/system.scm index 446439bcac..3b66847b4f 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -784,7 +784,7 @@ (define known-fs (operating-system-environment-variables os)) (host-name-service host-name) procs root-fs - (service setuid-program-service-type + (service privileged-program-service-type (operating-system-setuid-programs os)) (service profile-service-type (operating-system-packages os)) @@ -825,7 +825,7 @@ (define (hurd-default-essential-services os) (list `("hosts" ,hosts-file))) (service hosts-service-type (local-host-entries host-name))) - (service setuid-program-service-type + (service privileged-program-service-type (operating-system-setuid-programs os)) (service profile-service-type (operating-system-packages os))))) -- 2.39.1 ^ permalink raw reply related [flat|nested] 35+ messages in thread
* [bug#61462] [PATCH 10/10] system: Add privileged-programs to <operating-system>. 2023-02-05 0:00 ` [bug#61462] [PATCH 01/10] system: Disallow file-like setuid-programs Tobias Geerinckx-Rice via Guix-patches via ` (7 preceding siblings ...) 2023-02-05 0:00 ` [bug#61462] [PATCH 09/10] system: Use privileged-program-service-type by default Tobias Geerinckx-Rice via Guix-patches via @ 2023-02-05 0:00 ` Tobias Geerinckx-Rice via Guix-patches via 8 siblings, 0 replies; 35+ messages in thread From: Tobias Geerinckx-Rice via Guix-patches via @ 2023-02-05 0:00 UTC (permalink / raw) To: 61462 * gnu/system.scm (<operating-system>): Add new privileged-programs field, that defaults to… (%default-privileged-programs): …this new variable, renamed from… (%setuid-programs): …this, which is now defined as the empty list. * doc/guix.texi (Setuid Programs): Rename this… (Privileged Programs): …to this. Adjust all refs. Update all mentions of ‘setuid’ (whether in prose, variable names, or code samples) to use the new ‘privilege[d]’ terminology instead. (operating-system Reference, X Window, Desktop Services, Invoking guix system, Service Reference): Adjust likewise. --- doc/guix.texi | 89 ++++++++++++++++++++++------------------- gnu/packages/crypto.scm | 2 +- gnu/services.scm | 1 - gnu/system.scm | 21 ++++++++-- 4 files changed, 65 insertions(+), 48 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 009bcf5d40..7e54abcffb 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -358,7 +358,7 @@ System Configuration * Keyboard Layout:: How the system interprets key strokes. * Locales:: Language and cultural convention settings. * Services:: Specifying system services. -* Setuid Programs:: Programs running with elevated privileges. +* Privileged Programs:: Programs running with elevated privileges. * X.509 Certificates:: Authenticating HTTPS servers. * Name Service Switch:: Configuring libc's name service switch. * Initial RAM Disk:: Linux-Libre bootstrapping. @@ -16146,7 +16146,7 @@ instance to support new system services. * Keyboard Layout:: How the system interprets key strokes. * Locales:: Language and cultural convention settings. * Services:: Specifying system services. -* Setuid Programs:: Programs running with elevated privileges. +* Privileged Programs:: Programs running with elevated privileges. * X.509 Certificates:: Authenticating HTTPS servers. * Name Service Switch:: Configuring libc's name service switch. * Initial RAM Disk:: Linux-Libre bootstrapping. @@ -16591,9 +16591,9 @@ As a user you should @emph{never} need to touch this field. Linux @dfn{pluggable authentication module} (PAM) services. @c FIXME: Add xref to PAM services section. -@item @code{setuid-programs} (default: @code{%setuid-programs}) -List of @code{<setuid-program>}. @xref{Setuid Programs}, for more -information. +@item @code{privileged-programs} (default: @code{%default-privileged-programs}) +List of @code{<privileged-program>}. @xref{Privileged Programs}, for +more information. @item @code{sudoers-file} (default: @code{%sudoers-specification}) @cindex sudoers file @@ -22047,8 +22047,8 @@ Usually the X server is started by a login manager. @deffn {Scheme Procedure} screen-locker-service @var{package} [@var{program}] Add @var{package}, a package for a screen locker or screen saver whose -command is @var{program}, to the set of setuid programs and add a PAM entry -for it. For example: +command is @var{program}, to the set of privileged programs and add a PAM +entry for it. For example: @lisp (screen-locker-service xlockmore "xlock") @@ -22965,9 +22965,9 @@ to operate with elevated privileges on a limited number of special-purpose system interfaces. Additionally, adding a service of type @code{mate-desktop-service-type} adds the MATE metapackage to the system profile. ``Adding Enlightenment'' means that @code{dbus} is extended -appropriately, and several of Enlightenment's binaries are set as setuid, -allowing Enlightenment's screen locker and other functionality to work as -expected. +appropriately, and several of Enlightenment's binaries are set as privileged +programs, allowing Enlightenment's screen locker and other functionality to +work as expected. The desktop environments in Guix use the Xorg display server by default. If you'd like to use the newer display server protocol @@ -25905,7 +25905,7 @@ remote servers. Run @command{man smtpd.conf} for more information. Make the following commands setgid to @code{smtpq} so they can be executed: @command{smtpctl}, @command{sendmail}, @command{send-mail}, @command{makemap}, @command{mailq}, and @command{newaliases}. -@xref{Setuid Programs}, for more information on setgid programs. +@xref{Privileged Programs}, for more information on setgid programs. @end table @end deftp @@ -37704,8 +37704,8 @@ create and run application bundles (aka. ``containers''). The value for this service is the Singularity package to use. The service does not install a daemon; instead, it installs helper programs as -setuid-root (@pxref{Setuid Programs}) such that unprivileged users can invoke -@command{singularity run} and similar commands. +setuid-root (@pxref{Privileged Programs}) such that unprivileged users can +invoke @command{singularity run} and similar commands. @end defvar @cindex Audit @@ -38136,11 +38136,14 @@ Mode for filter. @c End of auto-generated fail2ban documentation. -@node Setuid Programs -@section Setuid Programs +@node Privileged Programs +@section Privileged Programs +@cindex privileged programs @cindex setuid programs @cindex setgid programs +@cindex capabilities, POSIX +@cindex setcap Some programs need to run with elevated privileges, even when they are launched by unprivileged users. A notorious example is the @command{passwd} program, which users can run to change their @@ -38151,46 +38154,48 @@ obvious security reasons. To address that, @command{passwd} should be (@pxref{How Change Persona,,, libc, The GNU C Library Reference Manual}, for more info about the setuid mechanism). -The store itself @emph{cannot} contain setuid programs: that would be a -security issue since any user on the system can write derivations that +The store itself @emph{cannot} contain privileged programs: that would be +a security issue since any user on the system can write derivations that populate the store (@pxref{The Store}). Thus, a different mechanism is -used: instead of changing the setuid or setgid bits directly on files that -are in the store, we let the system administrator @emph{declare} which +used: instead of directly granting permissions to files that are in +the store, we let the system administrator @emph{declare} which programs should be entrusted with these additional privileges. -The @code{setuid-programs} field of an @code{operating-system} -declaration contains a list of @code{<setuid-program>} denoting the +The @code{privileged-programs} field of an @code{operating-system} +declaration contains a list of @code{<privileged-program>} denoting the names of programs to have a setuid or setgid bit set (@pxref{Using the Configuration System}). For instance, the @command{mount.nfs} program, which is part of the nfs-utils package, with a setuid root can be designated like this: @lisp -(setuid-program - (program (file-append nfs-utils "/sbin/mount.nfs"))) +(privileged-program + (program (file-append nfs-utils "/sbin/mount.nfs")) + (setuid? #t)) @end lisp And then, to make @command{mount.nfs} setuid on your system, add the previous example to your operating system declaration by appending it to -@code{%setuid-programs} like this: +@code{%default-privileged-programs} like this: @lisp (operating-system ;; Some fields omitted... - (setuid-programs - (append (list (setuid-program - (program (file-append nfs-utils "/sbin/mount.nfs")))) - %setuid-programs))) + (privileged-programs + (append (list (privileged-program + (program (file-append nfs-utils "/sbin/mount.nfs")) + (setuid? #t)) + %default-privileged-programs))) @end lisp -@deftp {Data Type} setuid-program -This data type represents a program with a setuid or setgid bit set. +@deftp {Data Type} privileged-program +This data type represents a program with special privileges, such as setuid @table @asis @item @code{program} -A file-like object having its setuid and/or setgid bit set. +A file-like object to which all given privileges should apply. -@item @code{setuid?} (default: @code{#t}) +@item @code{setuid?} (default: @code{#f}) Whether to set user setuid bit. @item @code{setgid?} (default: @code{#f}) @@ -38207,18 +38212,18 @@ defaults to root. @end table @end deftp -A default set of setuid programs is defined by the -@code{%setuid-programs} variable of the @code{(gnu system)} module. +A default set of privileged programs is defined by the +@code{%default-privileged-programs} variable of the @code{(gnu system)} module. -@defvar %setuid-programs -A list of @code{<setuid-program>} denoting common programs that are -setuid-root. +@defvar {Scheme Variable} %default-privileged-programs +A list of @code{<privileged-program>} denoting common programs with +elevated privileges. The list includes commands such as @command{passwd}, @command{ping}, @command{su}, and @command{sudo}. @end defvar -Under the hood, the actual setuid programs are created in the +Under the hood, the actual privileged programs are created in the @file{/run/privileged/bin} directory at system activation time. The files in this directory refer to the ``real'' binaries, which are in the store. @@ -39089,7 +39094,7 @@ once @command{reconfigure} has completed. @end quotation This effects all the configuration specified in @var{file}: user -accounts, system services, global package list, setuid programs, etc. +accounts, system services, global package list, privileged programs, etc. The command starts system services specified in @var{file} that are not currently running; if a service is currently running this command will arrange for it to be upgraded the next time it is stopped (e.g.@: by @@ -40535,10 +40540,10 @@ tiresome to create multiple records with it so in practice the procedure @end quotation @end defvar -@defvar setuid-program-service-type -Type for the ``setuid-program service''. This service collects lists of +@defvar privileged-program-service-type +Type for the ``privileged-program service''. This service collects lists of executable file names, passed as gexps, and adds them to the set of -setuid and setgid programs on the system (@pxref{Setuid Programs}). +privileged programs on the system (@pxref{Privileged Programs}). @end defvar @defvar profile-service-type diff --git a/gnu/packages/crypto.scm b/gnu/packages/crypto.scm index 57a42a6a84..87c26f10ad 100644 --- a/gnu/packages/crypto.scm +++ b/gnu/packages/crypto.scm @@ -499,7 +499,7 @@ (define-public tomb `(#:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out"))) ;; The "sudo" input is needed only to satisfy dependency checks in the ;; 'check' phase. The "sudo" used at runtime should come from the - ;; system's setuid-programs, so ensure no reference is kept. + ;; system's privileged-programs, so ensure no reference is kept. #:disallowed-references (,sudo) ;; TODO: Build and install gtk and qt trays #:phases diff --git a/gnu/services.scm b/gnu/services.scm index 09ff58dcd1..9825f4a4a5 100644 --- a/gnu/services.scm +++ b/gnu/services.scm @@ -44,7 +44,6 @@ (define-module (gnu services) #:use-module (gnu packages bash) #:use-module (gnu packages hurd) #:use-module (gnu system privilege) - #:use-module (gnu system setuid) #:use-module (srfi srfi-1) #:use-module (srfi srfi-9) #:use-module (srfi srfi-9 gnu) diff --git a/gnu/system.scm b/gnu/system.scm index 3b66847b4f..1a22dc65f5 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -75,6 +75,7 @@ (define-module (gnu system) #:use-module (gnu system locale) #:use-module (gnu system pam) #:use-module (gnu system linux-initrd) + #:use-module (gnu system privilege) #:use-module (gnu system setuid) #:use-module (gnu system uuid) #:use-module (gnu system file-systems) @@ -128,6 +129,7 @@ (define-module (gnu system) operating-system-keyboard-layout operating-system-name-service-switch operating-system-pam-services + operating-system-privileged-programs operating-system-setuid-programs operating-system-skeletons operating-system-sudoers-file @@ -173,6 +175,7 @@ (define-module (gnu system) local-host-aliases ;deprecated local-host-entries %root-account + %default-privileged-programs %setuid-programs %sudoers-specification %base-packages @@ -296,7 +299,10 @@ (define-record-type* <operating-system> operating-system (pam-services operating-system-pam-services ; list of PAM services (default (base-pam-services))) + (privileged-programs operating-system-privileged-programs ; list of <privileged-program> + (default %default-privileged-programs)) (setuid-programs operating-system-setuid-programs + ;; For backwards compatibility; will be removed. (default %setuid-programs)) ; list of <setuid-program> (sudoers-file operating-system-sudoers-file ; file-like @@ -785,7 +791,8 @@ (define known-fs (host-name-service host-name) procs root-fs (service privileged-program-service-type - (operating-system-setuid-programs os)) + (append (operating-system-privileged-programs os) + (operating-system-setuid-programs os))) (service profile-service-type (operating-system-packages os)) boot-fs non-boot-fs @@ -826,7 +833,8 @@ (define (hurd-default-essential-services os) (service hosts-service-type (local-host-entries host-name))) (service privileged-program-service-type - (operating-system-setuid-programs os)) + (append (operating-system-privileged-programs os) + (operating-system-setuid-programs os))) (service profile-service-type (operating-system-packages os))))) (define* (operating-system-services os) @@ -1213,8 +1221,7 @@ (define (operating-system-environment-variables os) ;; TODO: Remove when glibc@2.23 is long gone. ("GUIX_LOCPATH" . "/run/current-system/locale"))) -(define %setuid-programs - ;; Default set of setuid-root programs. +(define %default-privileged-programs (let ((shadow (@ (gnu packages admin) shadow))) (map file-like->setuid-program (list (file-append shadow "/bin/passwd") @@ -1236,6 +1243,12 @@ (define %setuid-programs (file-append util-linux "/bin/mount") (file-append util-linux "/bin/umount"))))) +(define %setuid-programs + ;; Do not add to this list or use it in new code! It's defined only to ease + ;; transition to %default-privileged-programs and will be removed. Some rare + ;; use cases already break, such as the obvious (remove … %setuid-programs). + '()) + (define %sudoers-specification ;; Default /etc/sudoers contents: 'root' and all members of the 'wheel' ;; group can do anything. See -- 2.39.1 ^ permalink raw reply related [flat|nested] 35+ messages in thread
* [bug#61462] Add support for file capabilities(7) 2023-02-12 20:37 [bug#61462] Add support for file capabilities(7) Tobias Geerinckx-Rice via Guix-patches via 2023-02-05 0:00 ` [bug#61462] [PATCH 01/10] system: Disallow file-like setuid-programs Tobias Geerinckx-Rice via Guix-patches via @ 2023-02-12 21:05 ` Tobias Geerinckx-Rice via Guix-patches via 2023-03-04 16:55 ` Ludovic Courtès 2023-07-15 23:59 ` [bug#61462] [PATCH v2 01/10] system: Disallow file-like setuid-programs Tobias Geerinckx-Rice via Guix-patches via 3 siblings, 0 replies; 35+ messages in thread From: Tobias Geerinckx-Rice via Guix-patches via @ 2023-02-12 21:05 UTC (permalink / raw) Cc: 61462 [-- Attachment #1: Type: text/plain, Size: 289 bytes --] Tobias Geerinckx-Rice via Guix-patches via 写道: > The set's over a year old and needs a bit of love. I noticed some merge conflicts after sending this cover letter, and, as I'm too tired for love right now, will fix them and send the rest tomorrow. Kind regards, T G-R [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 247 bytes --] ^ permalink raw reply [flat|nested] 35+ messages in thread
* [bug#61462] Add support for file capabilities(7) 2023-02-12 20:37 [bug#61462] Add support for file capabilities(7) Tobias Geerinckx-Rice via Guix-patches via 2023-02-05 0:00 ` [bug#61462] [PATCH 01/10] system: Disallow file-like setuid-programs Tobias Geerinckx-Rice via Guix-patches via 2023-02-12 21:05 ` [bug#61462] Add support for file capabilities(7) Tobias Geerinckx-Rice via Guix-patches via @ 2023-03-04 16:55 ` Ludovic Courtès 2023-03-24 4:31 ` Vagrant Cascadian via Guix-patches 2023-07-15 23:59 ` [bug#61462] [PATCH v2 01/10] system: Disallow file-like setuid-programs Tobias Geerinckx-Rice via Guix-patches via 3 siblings, 1 reply; 35+ messages in thread From: Ludovic Courtès @ 2023-03-04 16:55 UTC (permalink / raw) To: Tobias Geerinckx-Rice; +Cc: 61462 Hi! Tobias Geerinckx-Rice <me@tobias.gr> skribis: > I need to offload some of my eternally rebased local patches. Here's > one that makes it easy to assign capabilities(7) — currently through > setcap(8) — to programmes like we can set{u,g}id. > > There are many packages that benefit from this. Mine are: > > (privileged-programs > (cons* (privileged-program > (file-append mtr "/sbin/mtr") > (capabilities "cap_net_raw+ep")) > (privileged-program > (file-append nethogs "/sbin/nethogs") > (capabilities "cap_net_admin,cap_new_raw+ep")) > (privileged-program > (file-append light "/bin/light") > (setuid? #t)) > %default-privileged-programs)) Neat! > The set's over a year old and needs a bit of love. Some details might > have bitrot, I probably forgot a to-do or two in that year, and > there's something unguixy about calling setcap(8) instead of writing a > completely new Guile binding/module :-) > > I'm quite opinionated about the setuid-programs unification: there > should not be multiple confusing and masking layers of privilege, and > it should be possible to setgid a capable executable. So you mean that ‘privileged-programs’ should entirely replace ‘setuid-programs’, right? I’m a bit unsure about using file capabilities: 1. File capabilities are persistent and less visible than setuid bits (you won’t see them with “ls -l”), so easily overlooked. Could there be a risk of lingering file capabilities when reconfiguring a system? 2. How ’bout portability to different file systems and to GNU/Hurd? 3. What’s the complexity/benefit ratio? :-) Then there’s the compatibility story with moving from /run/setuid-programs to /run/privileged-programs etc. that’ll have to be handled with care. I’m very much sold to the principle of least authority, but I feel like POSIX capabilities (not to be confused with “actual” capabilities) are a bit of a hack. Thoughts? Ludo’. ^ permalink raw reply [flat|nested] 35+ messages in thread
* [bug#61462] Add support for file capabilities(7) 2023-03-04 16:55 ` Ludovic Courtès @ 2023-03-24 4:31 ` Vagrant Cascadian via Guix-patches 2023-04-18 13:14 ` Ludovic Courtès 0 siblings, 1 reply; 35+ messages in thread From: Vagrant Cascadian via Guix-patches @ 2023-03-24 4:31 UTC (permalink / raw) To: Ludovic Courtès, Tobias Geerinckx-Rice; +Cc: 61462 [-- Attachment #1: Type: text/plain, Size: 4435 bytes --] On 2023-03-04, Ludovic Courtès wrote: > Tobias Geerinckx-Rice <me@tobias.gr> skribis: > >> I need to offload some of my eternally rebased local patches. Here's >> one that makes it easy to assign capabilities(7) — currently through >> setcap(8) — to programmes like we can set{u,g}id. >> >> There are many packages that benefit from this. Mine are: >> >> (privileged-programs >> (cons* (privileged-program >> (file-append mtr "/sbin/mtr") >> (capabilities "cap_net_raw+ep")) >> (privileged-program >> (file-append nethogs "/sbin/nethogs") >> (capabilities "cap_net_admin,cap_new_raw+ep")) >> (privileged-program >> (file-append light "/bin/light") >> (setuid? #t)) >> %default-privileged-programs)) > > Neat! Agreed! Thanks! >> I'm quite opinionated about the setuid-programs unification: there >> should not be multiple confusing and masking layers of privilege, and >> it should be possible to setgid a capable executable. > > So you mean that ‘privileged-programs’ should entirely replace > ‘setuid-programs’, right? > > I’m a bit unsure about using file capabilities: > > 1. File capabilities are persistent and less visible than setuid bits > (you won’t see them with “ls -l”), so easily overlooked. Could > there be a risk of lingering file capabilities when reconfiguring a > system? Does reconfigure leave old setuid binaries laying around in /run/setuid-programs currently? That sounds like leaking state from previous generations into the current generation, and should be fixed if it is indeed the case. Seems like with setuid/setgid and the proposed priviledged binaries, the setuid/setgid bits and capabilties should be explicitly set on any defined binaries, and any that are left over in the /run/*-programs directories should be... forcibly removed! Otherwise your current system is vulnerable to previous potentially bad choices indefinitely... Basically, guix system reconfigure should be fastidious and ideally deterministic with generating and updating /run/*-programs ... > 2. How ’bout portability to different file systems and to GNU/Hurd? Currently I *think* /run/setuid-programs is tmpfs (at least on systems I have used running a linux-libre kernel) ... I do not think this attempts to change that...; we probably do not need broad filesystem compatibility, just whatever filesystem /run/*-programs is implemented on. And since they are not compatibly with GNU/Hurd, then let us drop support for x86_64-linux, riscv64-linux, ppc64el-linux, arm64-linux, etc. ... to make sure things are compatible! :P In all seriousness though, while I appreciate thinking about broad compatibility across different types of systems, I am a bit nervous about an approach that would require features to behave compatibly across all systems... ...though I suspect you were more getting at "What are the consequences of implementing this for some other system types?" > 3. What’s the complexity/benefit ratio? :-) > > Then there’s the compatibility story with moving from > /run/setuid-programs to /run/privileged-programs etc. that’ll have to be > handled with care. I am less opinionated about adding yet another directory to PATH, although obivously then you get into the weird issues with old $PATH values laying around (e.g. not getting the new directory added until logging out or re-loading the running profile) > I’m very much sold to the principle of least authority, but I feel like > POSIX capabilities (not to be confused with “actual” capabilities) are a > bit of a hack. And setuid/setgid is not a hack? It seems like essentially the same thing, just with no granularity... > Thoughts? There are some things that are just not possible without capabilities, and setuid/setgid is a dangerous hammer that should be used very sparingly, if at all, and capabilities are no *worse* that setuid/setgid, allowing a finer grained set of problems :) The need for this functionality has come up more than a few times: https://issues.guix.gnu.org/27415 https://issues.guix.gnu.org/39136 https://issues.guix.gnu.org/55683 And possibly a few others: https://issues.guix.gnu.org/search?query=setcap live well, vagrant [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 227 bytes --] ^ permalink raw reply [flat|nested] 35+ messages in thread
* [bug#61462] Add support for file capabilities(7) 2023-03-24 4:31 ` Vagrant Cascadian via Guix-patches @ 2023-04-18 13:14 ` Ludovic Courtès 2023-04-18 19:38 ` Vagrant Cascadian 0 siblings, 1 reply; 35+ messages in thread From: Ludovic Courtès @ 2023-04-18 13:14 UTC (permalink / raw) To: Vagrant Cascadian; +Cc: Tobias Geerinckx-Rice, 61462 Hi Vagrant & Tobias, Sorry for the late reply! Vagrant Cascadian <vagrant@debian.org> skribis: >>> I'm quite opinionated about the setuid-programs unification: there >>> should not be multiple confusing and masking layers of privilege, and >>> it should be possible to setgid a capable executable. >> >> So you mean that ‘privileged-programs’ should entirely replace >> ‘setuid-programs’, right? >> >> I’m a bit unsure about using file capabilities: >> >> 1. File capabilities are persistent and less visible than setuid bits >> (you won’t see them with “ls -l”), so easily overlooked. Could >> there be a risk of lingering file capabilities when reconfiguring a >> system? > > Does reconfigure leave old setuid binaries laying around in > /run/setuid-programs currently? No: ‘activate-setuid-programs’ first deletes /run/setuid-programs/*, then populates it. > Seems like with setuid/setgid and the proposed priviledged binaries, the > setuid/setgid bits and capabilties should be explicitly set on any > defined binaries, and any that are left over in the /run/*-programs > directories should be... forcibly removed! Otherwise your current system > is vulnerable to previous potentially bad choices indefinitely... Right, so in that sense it’s no different from setuid binaries, other than the fact that “ls -l” won’t show it. >> 2. How ’bout portability to different file systems and to GNU/Hurd? > > Currently I *think* /run/setuid-programs is tmpfs It’s not by default. [...] > In all seriousness though, while I appreciate thinking about broad > compatibility across different types of systems, I am a bit nervous > about an approach that would require features to behave compatibly > across all systems... I guess All I’m saying is that we should keep this in mind. Perhaps the hypothetical ‘activate-privileged-programs’ procedure would fall back to setuid-root on GNU/Hurd or do some other Hurd-specific thing. We don’t need to go too far, but we do need to give it some thought IMO. >> I’m very much sold to the principle of least authority, but I feel like >> POSIX capabilities (not to be confused with “actual” capabilities) are a >> bit of a hack. > > And setuid/setgid is not a hack? It seems like essentially the same > thing, just with no granularity... That’s right! > There are some things that are just not possible without capabilities, > and setuid/setgid is a dangerous hammer that should be used very > sparingly, if at all, and capabilities are no *worse* that > setuid/setgid, allowing a finer grained set of problems :) > > The need for this functionality has come up more than a few times: > > https://issues.guix.gnu.org/27415 > https://issues.guix.gnu.org/39136 > https://issues.guix.gnu.org/55683 Right; thanks for digging the references. I wouldn’t want to block this change. Tobias, if you’re around, let’s look more closely how we can address Hurd suppot and backward compatibility. Thanks, Ludo’. ^ permalink raw reply [flat|nested] 35+ messages in thread
* [bug#61462] Add support for file capabilities(7) 2023-04-18 13:14 ` Ludovic Courtès @ 2023-04-18 19:38 ` Vagrant Cascadian 2023-04-20 10:33 ` Ludovic Courtès 0 siblings, 1 reply; 35+ messages in thread From: Vagrant Cascadian @ 2023-04-18 19:38 UTC (permalink / raw) To: Ludovic Courtès; +Cc: Tobias Geerinckx-Rice, 61462 [-- Attachment #1: Type: text/plain, Size: 3505 bytes --] On 2023-04-18, Ludovic Courtès wrote: > Vagrant Cascadian <vagrant@debian.org> skribis: > >>>> I'm quite opinionated about the setuid-programs unification: there >>>> should not be multiple confusing and masking layers of privilege, and >>>> it should be possible to setgid a capable executable. >>> >>> So you mean that ‘privileged-programs’ should entirely replace >>> ‘setuid-programs’, right? >>> >>> I’m a bit unsure about using file capabilities: >>> >>> 1. File capabilities are persistent and less visible than setuid bits >>> (you won’t see them with “ls -l”), so easily overlooked. Could >>> there be a risk of lingering file capabilities when reconfiguring a >>> system? >> >> Does reconfigure leave old setuid binaries laying around in >> /run/setuid-programs currently? > > No: ‘activate-setuid-programs’ first deletes /run/setuid-programs/*, > then populates it. Good! >> Seems like with setuid/setgid and the proposed priviledged binaries, the >> setuid/setgid bits and capabilties should be explicitly set on any >> defined binaries, and any that are left over in the /run/*-programs >> directories should be... forcibly removed! Otherwise your current system >> is vulnerable to previous potentially bad choices indefinitely... > > Right, so in that sense it’s no different from setuid binaries, other > than the fact that “ls -l” won’t show it. That aspect seems fixable with documentation in the simplest case of how to show that /run/*-programs contains the correct permissions, e.g a brief mention of "getcap" to show the capabilities. The most fancy case I quickly think of might be "guix system list-privledged-programs" or some such that would display all the various privledges (setuid, setgid, capabilities, etc.) on each of the binaries in /run/*-programs? But probably overkill... >>> 2. How ’bout portability to different file systems and to GNU/Hurd? >> >> Currently I *think* /run/setuid-programs is tmpfs > > It’s not by default. Huh, could have sworn on all my guix systems that /run was on tmpfs by default, and I did not knowingly do anything special to change that... >> In all seriousness though, while I appreciate thinking about broad >> compatibility across different types of systems, I am a bit nervous >> about an approach that would require features to behave compatibly >> across all systems... > > I guess All I’m saying is that we should keep this in mind. > > Perhaps the hypothetical ‘activate-privileged-programs’ procedure would > fall back to setuid-root on GNU/Hurd or do some other Hurd-specific > thing. We don’t need to go too far, but we do need to give it some > thought IMO. If it cannot properly set the capabilities, then it should not assume setuid-root is an ok fallback; it should instead most definitely just fail! At least the case I am most familiar with, lcsync, it really should not run as setuid-root, as that effectively allows anyone to modify or copy any file as root. Although, likely Hurd limits the impacts of setuid root in ways I do not understand? Even then, I still think if you ask for something in your guix system configuration, and it cannot deliver what you asked for, it should not give you something else as an approximation of what you wanted. Maybe that is a strict interpretation of an ideal, and reality is much harder than that. :) live well, vagrant [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 227 bytes --] ^ permalink raw reply [flat|nested] 35+ messages in thread
* [bug#61462] Add support for file capabilities(7) 2023-04-18 19:38 ` Vagrant Cascadian @ 2023-04-20 10:33 ` Ludovic Courtès 0 siblings, 0 replies; 35+ messages in thread From: Ludovic Courtès @ 2023-04-20 10:33 UTC (permalink / raw) To: Vagrant Cascadian; +Cc: Tobias Geerinckx-Rice, 61462 Hi, Vagrant Cascadian <vagrant@debian.org> skribis: > At least the case I am most familiar with, lcsync, it really should not > run as setuid-root, as that effectively allows anyone to modify or copy > any file as root. Although, likely Hurd limits the impacts of setuid > root in ways I do not understand? There are many more things that can be done on the Hurd without being root. So I don’t know, maybe we can ignore the issue for now and simply make sure that the defaults work for the Hurd. > Even then, I still think if you ask for something in your guix system > configuration, and it cannot deliver what you asked for, it should not > give you something else as an approximation of what you wanted. Yeah, you’re right that an approximation could be risky… Thanks, Ludo’. ^ permalink raw reply [flat|nested] 35+ messages in thread
* [bug#61462] [PATCH v2 01/10] system: Disallow file-like setuid-programs. 2023-02-12 20:37 [bug#61462] Add support for file capabilities(7) Tobias Geerinckx-Rice via Guix-patches via ` (2 preceding siblings ...) 2023-03-04 16:55 ` Ludovic Courtès @ 2023-07-15 23:59 ` Tobias Geerinckx-Rice via Guix-patches via 2023-07-15 23:59 ` [bug#61462] [PATCH v2 02/10] services: setuid-program: Populate /run/privileged/bin Tobias Geerinckx-Rice via Guix-patches via ` (9 more replies) 3 siblings, 10 replies; 35+ messages in thread From: Tobias Geerinckx-Rice via Guix-patches via @ 2023-07-15 23:59 UTC (permalink / raw) To: 61462 It has been a warning for well over a year now. Now, with privileged-programs coming, don't let's support nested deprecation hacks. * gnu/system.scm (<operating-system>): Don't ‘sanitize’ the setuid-programs field. (ensure-setuid-program-list): Delete syntax. (%ensure-setuid-program-list): Delete variable. --- This is a quick snapshot of my rebased tree at the request of vagrantc. There shouldn't be any functional changes. If there are, that's cool too. gnu/system.scm | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/gnu/system.scm b/gnu/system.scm index 23addf41e9..e32879b240 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -296,8 +296,7 @@ (define-record-type* <operating-system> operating-system (pam-services operating-system-pam-services ; list of PAM services (default (base-pam-services))) (setuid-programs operating-system-setuid-programs - (default %setuid-programs) ; list of <setuid-program> - (sanitize ensure-setuid-program-list)) + (default %setuid-programs)) ; list of <setuid-program> (sudoers-file operating-system-sudoers-file ; file-like (default %sudoers-specification)) @@ -1203,31 +1202,6 @@ (define (operating-system-environment-variables os) ;; when /etc/machine-id is missing. Make sure these warnings are non-fatal. ("DBUS_FATAL_WARNINGS" . "0"))) -;; Ensure LST is a list of <setuid-program> records and warn otherwise. -(define-with-syntax-properties (ensure-setuid-program-list (lst properties)) - (%ensure-setuid-program-list lst properties)) - -;; We want to be able to use defines, so define a procedure. -(define (%ensure-setuid-program-list lst properties) - (define warned? #f) - - (define (warn-once) - (unless warned? - (warning (source-properties->location properties) - (G_ "representing setuid programs with file-like objects is \ -deprecated; use 'setuid-program' instead~%")) - (set! warned? #t))) - - (map (match-lambda - ((? setuid-program? program) - program) - (program - ;; PROGRAM is a file-like or a gexp like #~(string-append #$foo - ;; "/bin/bar"). - (warn-once) - (setuid-program (program program)))) - lst)) - (define %setuid-programs ;; Default set of setuid-root programs. (let ((shadow (@ (gnu packages admin) shadow))) base-commit: 21b718f4d6c3ded8ef50d12f6e9ae6474f74620f prerequisite-patch-id: efc79914a4e3e994a8786e02774237de36f6b105 prerequisite-patch-id: 1986dc849c15ae6c1502df25f9c17b53a02df83d prerequisite-patch-id: bb189cbd1346b0d00e9b79189155c9916731788b prerequisite-patch-id: 062a02ed88acf0f11c5895b67065faa55d71fae8 prerequisite-patch-id: 2eea585e7940a16c24baeed3b65a123b1b10fd6b prerequisite-patch-id: 31a3407b0c583d01cc2664168ec6cf499f10cb53 prerequisite-patch-id: a0566799f4aef296a3efcd228c3a223202662f86 prerequisite-patch-id: cd50cb9494a47433c7fd167729e239178c78d7f1 prerequisite-patch-id: e86e94b9a40613e3ce534ce778d027210b93b05a prerequisite-patch-id: c7068d2079b3d2f0f172cc4cf9e0791ff5e84da3 prerequisite-patch-id: b52b35693094914ea1962ac2f186a52617d38c8a prerequisite-patch-id: b2bdf5541825c9cd57d2fe3e3e9a90e5fc8ffbe6 prerequisite-patch-id: f085c8ee7c7f1d0250b0ed8a548a72d397d96056 prerequisite-patch-id: 49c8f3f912d24147362a3a874c2b2c0b4b182d5d prerequisite-patch-id: 1f0fc1ca1a40444f4831beaf3183d7d4f866fd6d prerequisite-patch-id: 8c69acfe3cb01ff3c0a46a2efe04b53ad063002d prerequisite-patch-id: 10f972ac75020ce096d83b53a68a3b2f1eba1c8c prerequisite-patch-id: 74586b82a25b775527adc7e8cf09b15bdb4850f7 prerequisite-patch-id: 7388ac8d395ef16830105026230e47d903026335 prerequisite-patch-id: 2c7df330bf50663218016e01b9c0922a6b3a001f prerequisite-patch-id: f45ec5e6d6023fc5538e1578bbb4e270d7b23baf prerequisite-patch-id: 0083d0b8d60fd0e526449cd192f153d0bd1bde0b prerequisite-patch-id: 7e6e4ab87b52996e9bb6cd8595889f21ba87e9fe -- 2.41.0 ^ permalink raw reply related [flat|nested] 35+ messages in thread
* [bug#61462] [PATCH v2 02/10] services: setuid-program: Populate /run/privileged/bin. 2023-07-15 23:59 ` [bug#61462] [PATCH v2 01/10] system: Disallow file-like setuid-programs Tobias Geerinckx-Rice via Guix-patches via @ 2023-07-15 23:59 ` Tobias Geerinckx-Rice via Guix-patches via 2023-07-15 23:59 ` [bug#61462] [PATCH v2 03/10] system: Use /run/privileged/bin in search paths Tobias Geerinckx-Rice via Guix-patches via ` (8 subsequent siblings) 9 siblings, 0 replies; 35+ messages in thread From: Tobias Geerinckx-Rice via Guix-patches via @ 2023-07-15 23:59 UTC (permalink / raw) To: 61462 Create /run/setuid-programs compatibility symlinks so that we can migrate all users (both package and human) piecemeal at our leisure. Apart from being symlinks, this should be a user-invisible change. * gnu/build/activation.scm (%privileged-program-directory): New variable. [activate-setuid-programs]: Put privileged copies in %PRIVILEGED-PROGRAM-DIRECTORY, with compatibility symlinks to each in %SETUID-DIRECTORY. * gnu/services.scm (setuid-program-service-type): Update docstring. * doc/guix.texi (Setuid Programs): Update @file{} name accordingly. --- doc/guix.texi | 2 +- gnu/build/activation.scm | 54 ++++++++++++++++++++++++++-------------- gnu/services.scm | 9 +++++-- 3 files changed, 44 insertions(+), 21 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 1d8ebcd72f..9426c72e1e 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -39383,7 +39383,7 @@ Setuid Programs @end defvar Under the hood, the actual setuid programs are created in the -@file{/run/setuid-programs} directory at system activation time. The +@file{/run/privileged/bin} directory at system activation time. The files in this directory refer to the ``real'' binaries, which are in the store. diff --git a/gnu/build/activation.scm b/gnu/build/activation.scm index eea2233563..7f4800bba1 100644 --- a/gnu/build/activation.scm +++ b/gnu/build/activation.scm @@ -8,6 +8,7 @@ ;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be> ;;; Copyright © 2020 Christine Lemmer-Webber <cwebber@dustycloud.org> ;;; Copyright © 2021 Brice Waegeneire <brice@waegenei.re> +;;; Copyright © 2022 Tobias Geerinckx-Rice <me@tobias.gr> ;;; ;;; This file is part of GNU Guix. ;;; @@ -278,14 +279,29 @@ (define (activate-etc etc) string<?))) (define %setuid-directory - ;; Place where setuid programs are stored. + ;; Place where setuid programs used to be stored. It exists for backwards + ;; compatibility & will be removed. Use %PRIVILEGED-PROGRAM-DIRECTORY instead. "/run/setuid-programs") +(define %privileged-program-directory + ;; Place where privileged copies of programs are stored. + "/run/privileged/bin") + (define (activate-setuid-programs programs) - "Turn PROGRAMS, a list of file setuid-programs record, into setuid programs -stored under %SETUID-DIRECTORY." - (define (make-setuid-program program setuid? setgid? uid gid) - (let ((target (string-append %setuid-directory + "Turn PROGRAMS, a list of file setuid-programs records, into privileged +copies stored under %PRIVILEGED-PROGRAM-DIRECTORY." + (define (ensure-empty-directory directory) + (if (file-exists? directory) + (for-each (compose delete-file + (cut string-append directory "/" <>)) + (scandir directory + (lambda (file) + (not (member file '("." "..")))) + string<?)) + (mkdir-p directory)) ) + + (define (make-privileged-program program setuid? setgid? uid gid) + (let ((target (string-append %privileged-program-directory "/" (basename program))) (mode (+ #o0555 ; base permissions (if setuid? #o4000 0) ; setuid bit @@ -294,16 +310,17 @@ (define (activate-setuid-programs programs) (chown target uid gid) (chmod target mode))) - (format #t "setting up setuid programs in '~a'...~%" - %setuid-directory) - (if (file-exists? %setuid-directory) - (for-each (compose delete-file - (cut string-append %setuid-directory "/" <>)) - (scandir %setuid-directory - (lambda (file) - (not (member file '("." "..")))) - string<?)) - (mkdir-p %setuid-directory)) + (define (make-deprecated-wrapper program) + ;; This will eventually become a script that warns on usage, then vanish. + (symlink (string-append %privileged-program-directory + "/" (basename program)) + (string-append %setuid-directory + "/" (basename program)))) + + (format #t "setting up privileged programs in '~a'...~%" + %privileged-program-directory) + (ensure-empty-directory %privileged-program-directory) + (ensure-empty-directory %setuid-directory) (for-each (lambda (program) (catch 'system-error @@ -319,11 +336,12 @@ (define (activate-setuid-programs programs) (gid (match group ((? string?) (group:gid (getgrnam group))) ((? integer?) group)))) - (make-setuid-program program-name setuid? setgid? uid gid))) + (make-privileged-program program-name setuid? setgid? uid gid) + (make-deprecated-wrapper program-name))) (lambda args ;; If we fail to create a setuid program, better keep going - ;; so that we don't leave %SETUID-DIRECTORY empty or - ;; half-populated. This can happen if PROGRAMS contains + ;; so that we don't leave %PRIVILEGED-PROGRAM-DIRECTORY empty + ;; or half-populated. This can happen if PROGRAMS contains ;; incorrect file names: <https://bugs.gnu.org/38800>. (format (current-error-port) "warning: failed to make ~s setuid/setgid: ~a~%" diff --git a/gnu/services.scm b/gnu/services.scm index 109e050a23..eefe58b336 100644 --- a/gnu/services.scm +++ b/gnu/services.scm @@ -6,6 +6,7 @@ ;;; Copyright © 2021 raid5atemyhomework <raid5atemyhomework@protonmail.com> ;;; Copyright © 2020 Christine Lemmer-Webber <cwebber@dustycloud.org> ;;; Copyright © 2020, 2021 Brice Waegeneire <brice@waegenei.re> +;;; Copyright © 2022 Tobias Geerinckx-Rice <me@tobias.gr> ;;; Copyright © 2023 Brian Cully <bjc@spork.org> ;;; ;;; This file is part of GNU Guix. @@ -892,8 +893,12 @@ (define setuid-program-service-type (extend (lambda (config extensions) (append config extensions))) (description - "Populate @file{/run/setuid-programs} with the specified -executables, making them setuid and/or setgid."))) + "Copy the specified executables to @file{/run/privileged/bin} +and apply special privileges like setuid and/or setgid. + +The deprecated @file{/run/setuid-programs} directory is also populated with +symbolic links to their @file{/run/privileged/bin} counterpart. It will be +removed in a future Guix release."))) (define (packages->profile-entry packages) "Return a system entry for the profile containing PACKAGES." -- 2.41.0 ^ permalink raw reply related [flat|nested] 35+ messages in thread
* [bug#61462] [PATCH v2 03/10] system: Use /run/privileged/bin in search paths. 2023-07-15 23:59 ` [bug#61462] [PATCH v2 01/10] system: Disallow file-like setuid-programs Tobias Geerinckx-Rice via Guix-patches via 2023-07-15 23:59 ` [bug#61462] [PATCH v2 02/10] services: setuid-program: Populate /run/privileged/bin Tobias Geerinckx-Rice via Guix-patches via @ 2023-07-15 23:59 ` Tobias Geerinckx-Rice via Guix-patches via 2023-07-15 23:59 ` [bug#61462] [PATCH v2 04/10] gnu: Replace (almost) all uses of /run/setuid-programs Tobias Geerinckx-Rice via Guix-patches via ` (7 subsequent siblings) 9 siblings, 0 replies; 35+ messages in thread From: Tobias Geerinckx-Rice via Guix-patches via @ 2023-07-15 23:59 UTC (permalink / raw) To: 61462 * gnu/system.scm (operating-system-etc-service): Substitute /run/privileged/bin for deprecated /run/setuid-programs. --- gnu/system.scm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gnu/system.scm b/gnu/system.scm index e32879b240..b68c4d272b 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -985,10 +985,10 @@ (define* (operating-system-etc-service os) (plain-file "login.defs" (string-append "# Default paths for non-login shells started by su(1).\n" - "ENV_PATH /run/setuid-programs:" + "ENV_PATH /run/privileged/bin:" "/run/current-system/profile/bin:" "/run/current-system/profile/sbin\n" - "ENV_SUPATH /run/setuid-programs:" + "ENV_SUPATH /run/privileged/bin:" "/run/current-system/profile/bin:" "/run/current-system/profile/sbin\n" @@ -1051,8 +1051,8 @@ (define* (operating-system-etc-service os) fi done -# Prepend setuid programs. -export PATH=/run/setuid-programs:$PATH +# Prepend privileged programs. +export PATH=/run/privileged/bin:$PATH # Arrange so that ~/.config/guix/current/share/info comes first. export INFOPATH=\"$HOME/.config/guix/current/share/info:$INFOPATH\" -- 2.41.0 ^ permalink raw reply related [flat|nested] 35+ messages in thread
* [bug#61462] [PATCH v2 04/10] gnu: Replace (almost) all uses of /run/setuid-programs. 2023-07-15 23:59 ` [bug#61462] [PATCH v2 01/10] system: Disallow file-like setuid-programs Tobias Geerinckx-Rice via Guix-patches via 2023-07-15 23:59 ` [bug#61462] [PATCH v2 02/10] services: setuid-program: Populate /run/privileged/bin Tobias Geerinckx-Rice via Guix-patches via 2023-07-15 23:59 ` [bug#61462] [PATCH v2 03/10] system: Use /run/privileged/bin in search paths Tobias Geerinckx-Rice via Guix-patches via @ 2023-07-15 23:59 ` Tobias Geerinckx-Rice via Guix-patches via 2023-07-15 23:59 ` [bug#61462] [PATCH v2 05/10] system: Add (gnu system privilege) Tobias Geerinckx-Rice via Guix-patches via ` (6 subsequent siblings) 9 siblings, 0 replies; 35+ messages in thread From: Tobias Geerinckx-Rice via Guix-patches via @ 2023-07-15 23:59 UTC (permalink / raw) To: 61462 Cc: Leo Famulari, Liliana Marie Prikler, Maxim Cournoyer, Raghav Gururajan, Tobias Geerinckx-Rice …those good for master, anyway. * gnu/packages/admin.scm (ktsuss, opendoas, hosts) [arguments]: Replace /run/setuid-programs with /run/privileged/bin. * gnu/packages/containers.scm (slirp4netns)[arguments]: Likewise. * gnu/packages/debian.scm (pbuilder)[arguments]: Likewise. * gnu/packages/disk.scm (udevil)[arguments]: Likewise. * gnu/packages/enlightenment.scm (efl, enlightenment) [arguments]: Likewise. * gnu/packages/gnome.scm (gdm, gnome-control-center) [arguments]: Likewise. * gnu/packages/linux.scm (singularity)[arguments]: Likewise. * gnu/packages/lxde.scm (spacefm)[arguments]: Likewise. * gnu/packages/monitoring.scm (zabbix-agentd)[arguments]: Likewise. * gnu/packages/virtualization.scm (ganeti)[arguments]: Likewise. * gnu/packages/xdisorg.scm (xsecurelock)[arguments]: Likewise. * gnu/services/dbus.scm (dbus-configuration-directory): Likewise. * gnu/services/ganeti.scm (%default-ganeti-environment-variables): Likewise. * gnu/services/monitoring.scm (zabbix-agent-shepherd-service): Likewise. * gnu/tests/ldap.scm (marionette): Likewise. * gnu/tests/monitoring.scm (os): Likewise. --- gnu/machine/ssh.scm | 2 ++ gnu/packages/admin.scm | 6 +++--- gnu/packages/containers.scm | 2 +- gnu/packages/debian.scm | 4 ++-- gnu/packages/disk.scm | 14 +++++++------- gnu/packages/enlightenment.scm | 10 +++++----- gnu/packages/gnome.scm | 4 ++-- gnu/packages/linux.scm | 2 +- gnu/packages/lxde.scm | 19 ++++++++----------- gnu/packages/monitoring.scm | 2 +- gnu/packages/virtualization.scm | 2 +- gnu/packages/xdisorg.scm | 2 +- gnu/services/dbus.scm | 2 +- gnu/services/ganeti.scm | 2 +- gnu/services/monitoring.scm | 2 +- gnu/tests/ldap.scm | 2 +- gnu/tests/monitoring.scm | 4 ++-- 17 files changed, 40 insertions(+), 41 deletions(-) diff --git a/gnu/machine/ssh.scm b/gnu/machine/ssh.scm index 343cf74748..26ea787e29 100644 --- a/gnu/machine/ssh.scm +++ b/gnu/machine/ssh.scm @@ -177,6 +177,8 @@ (define (machine-become-command machine) (if (string= "root" (machine-ssh-configuration-user (machine-configuration machine))) '() + ;; Use the old setuid-programs location until the remote is likely to + ;; have the new /run/privileged one in place. '("/run/setuid-programs/sudo" "-n" "--"))) (define (managed-host-remote-eval machine exp) diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm index ec32041055..c42f23f437 100644 --- a/gnu/packages/admin.scm +++ b/gnu/packages/admin.scm @@ -205,7 +205,7 @@ (define-public ktsuss (lambda _ (substitute* "configure.ac" (("supath=`which su 2>/dev/null`") - "supath=/run/setuid-programs/su")) + "supath=/run/privileged/bin/su")) #t))))) (native-inputs (list autoconf automake libtool pkg-config)) @@ -2077,7 +2077,7 @@ (define-public opendoas (substitute* "doas.c" (("safepath =" match) (string-append match " \"" - "/run/setuid-programs:" + "/run/privileged/bin:" "/run/current-system/profile/bin:" "/run/current-system/profile/sbin:" "\" "))))) @@ -4918,7 +4918,7 @@ (define-public hosts ":" (assoc-ref %build-inputs "grep") "/bin" ":" (assoc-ref %build-inputs "ncurses") "/bin" ":" (assoc-ref %build-inputs "sed") "/bin" - ":" "/run/setuid-programs" + ":" "/run/privileged/bin" ":" (getenv "PATH"))) (substitute* "hosts" (("#!/usr/bin/env bash") diff --git a/gnu/packages/containers.scm b/gnu/packages/containers.scm index 232d994fe3..92573f211d 100644 --- a/gnu/packages/containers.scm +++ b/gnu/packages/containers.scm @@ -237,7 +237,7 @@ (define-public slirp4netns (add-after 'unpack 'fix-hardcoded-paths (lambda _ (substitute* (find-files "tests" "\\.sh") - (("ping") "/run/setuid-programs/ping"))))))) + (("ping") "/run/privileged/bin/ping"))))))) (inputs (list glib libcap diff --git a/gnu/packages/debian.scm b/gnu/packages/debian.scm index c5cfda9f80..c18de1403c 100644 --- a/gnu/packages/debian.scm +++ b/gnu/packages/debian.scm @@ -494,8 +494,8 @@ (define-public pbuilder (lambda () (format #t "# A couple of presets to make this work more smoothly.~@ MIRRORSITE=\"http://deb.debian.org/debian\"~@ - if [ -r /run/setuid-programs/sudo ]; then~@ - PBUILDERROOTCMD=\"/run/setuid-programs/sudo -E\"~@ + if [ -r /run/privileged/bin/sudo ]; then~@ + PBUILDERROOTCMD=\"/run/privileged/bin/sudo -E\"~@ fi~@ PBUILDERSATISFYDEPENDSCMD=\"~a/lib/pbuilder/pbuilder-satisfydepends-apt\"~%" #$output))))) diff --git a/gnu/packages/disk.scm b/gnu/packages/disk.scm index 35ffcf173e..95688ad422 100644 --- a/gnu/packages/disk.scm +++ b/gnu/packages/disk.scm @@ -204,10 +204,10 @@ (define-public udevil ;; udevil expects these programs to be run with uid set as root. ;; user has to manually add these programs to setuid-programs. ;; mount and umount are default setuid-programs in guix system. - "--with-mount-prog=/run/setuid-programs/mount" - "--with-umount-prog=/run/setuid-programs/umount" - "--with-losetup-prog=/run/setuid-programs/losetup" - "--with-setfacl-prog=/run/setuid-programs/setfacl") + "--with-mount-prog=/run/privileged/bin/mount" + "--with-umount-prog=/run/privileged/bin/umount" + "--with-losetup-prog=/run/privileged/bin/losetup" + "--with-setfacl-prog=/run/privileged/bin/setfacl") #:phases (modify-phases %standard-phases (add-after 'unpack 'remove-root-reference @@ -218,12 +218,12 @@ (define-public udevil (add-after 'unpack 'patch-udevil-reference ;; udevil expects itself to be run with uid set as root. ;; devmon also expects udevil to be run with uid set as root. - ;; user has to manually add udevil to setuid-programs. + ;; user has to manually add udevil to privileged-programs. (lambda _ (substitute* "src/udevil.c" - (("/usr/bin/udevil") "/run/setuid-programs/udevil")) + (("/usr/bin/udevil") "/run/privileged/bin/udevil")) (substitute* "src/devmon" - (("`which udevil 2>/dev/null`") "/run/setuid-programs/udevil")) + (("`which udevil 2>/dev/null`") "/run/privileged/bin/udevil")) #t))))) (native-inputs (list intltool pkg-config)) diff --git a/gnu/packages/enlightenment.scm b/gnu/packages/enlightenment.scm index 64d8945f8e..a6ee9dcb8a 100644 --- a/gnu/packages/enlightenment.scm +++ b/gnu/packages/enlightenment.scm @@ -149,8 +149,8 @@ (define-public efl "-Dbuild-examples=false" "-Decore-imf-loaders-disabler=scim" "-Dglib=true" - "-Dmount-path=/run/setuid-programs/mount" - "-Dunmount-path=/run/setuid-programs/umount" + "-Dmount-path=/run/privileged/bin/mount" + "-Dunmount-path=/run/privileged/bin/umount" "-Dnetwork-backend=connman" ,,@(if (member (%current-system) (package-transitive-supported-systems luajit)) @@ -338,7 +338,7 @@ (define-public enlightenment (substitute* '("src/bin/e_sys_main.c" "src/bin/e_util_suid.h") (("PATH=/bin:/usr/bin:/sbin:/usr/sbin") - (string-append "PATH=/run/setuid-programs:" + (string-append "PATH=/run/privileged/bin:" "/run/current-system/profile/bin:" "/run/current-system/profile/sbin"))) (substitute* "src/modules/everything/evry_plug_calc.c" @@ -347,8 +347,8 @@ (define-public enlightenment (("libddcutil\\.so\\.?" libddcutil) (string-append ddcutil "/lib/" libddcutil))) (substitute* "data/etc/meson.build" - (("/bin/mount") "/run/setuid-programs/mount") - (("/bin/umount") "/run/setuid-programs/umount") + (("/bin/mount") "/run/privileged/bin/mount") + (("/bin/umount") "/run/privileged/bin/umount") (("/usr/bin/eject") "/run/current-system/profile/bin/eject")) (substitute* "src/bin/system/e_system_power.c" (("systemctl") "loginctl")))))))) diff --git a/gnu/packages/gnome.scm b/gnu/packages/gnome.scm index 11085ecc80..485b8a16ba 100644 --- a/gnu/packages/gnome.scm +++ b/gnu/packages/gnome.scm @@ -8813,7 +8813,7 @@ (define-public gdm "--localstatedir=/var" (string-append "-Ddefault-path=" - (string-join '("/run/setuid-programs" + (string-join '("/run/privileged/bin" "/run/current-system/profile/bin" "/run/current-system/profile/sbin") ":")) @@ -9088,7 +9088,7 @@ (define-public gnome-control-center inputs "bin/nm-connection-editor")))) (substitute* "panels/user-accounts/run-passwd.c" (("/usr/bin/passwd") - "/run/setuid-programs/passwd")) + "/run/privileged/bin/passwd")) (substitute* "panels/info-overview/cc-info-overview-panel.c" (("DATADIR \"/gnome/gnome-version.xml\"") (format #f "~s" (search-input-file diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm index 67128524ff..cc8d3be791 100644 --- a/gnu/packages/linux.scm +++ b/gnu/packages/linux.scm @@ -5114,7 +5114,7 @@ (define-public singularity (substitute* (find-files "libexec/cli" "\\.exec$") (("\\$SINGULARITY_libexecdir/singularity/bin/([a-z]+)-suid" _ program) - (string-append "/run/setuid-programs/singularity-" + (string-append "/run/privileged/bin/singularity-" program "-helper"))) ;; These squashfs mount options are apparently no longer diff --git a/gnu/packages/lxde.scm b/gnu/packages/lxde.scm index 0291f50302..1a969eb4b5 100644 --- a/gnu/packages/lxde.scm +++ b/gnu/packages/lxde.scm @@ -372,26 +372,23 @@ (define-public spacefm (substitute* '("mime-type/mime-type.c" "ptk/ptk-file-menu.c") (("/usr(/local)?/share/mime") mime))) #t))) - (add-after 'patch-mime-dirs 'patch-setuid-progs + (add-after 'patch-mime-dirs 'patch-privileged-programs (lambda _ - (let* ((su "/run/setuid-programs/su") - (mount "/run/setuid-programs/mount") - (umount "/run/setuid-programs/umount") - (udevil "/run/setuid-programs/udevil")) + (let ((privileged (lambda (command) + (string-append "/run/privileged/bin/" + command)))) (with-directory-excursion "src" (substitute* '("settings.c" "settings.h" "vfs/vfs-file-task.c" "vfs/vfs-volume-hal.c" "../data/ui/prefdlg.ui" "../data/ui/prefdlg2.ui") - (("(/usr)?/bin/su") su) - (("/(bin|sbin)/mount") mount) - (("/(bin|sbin)/umount") umount) - (("/usr/bin/udevil") udevil))) + (("(/usr)?/s?bin/(mount|umount|su|udevil)" _ _ command) + (privileged command)))) #t))) - (add-after 'patch-setuid-progs 'patch-spacefm-conf + (add-after 'patch-privileged-programs 'patch-spacefm.conf (lambda* (#:key inputs #:allow-other-keys) (substitute* "etc/spacefm.conf" (("#terminal_su=/bin/su") - "terminal_su=/run/setuid-programs/su") + "terminal_su=/run/privileged/bin/su") (("#graphical_su=/usr/bin/gksu") (string-append "graphical_su=" (search-input-file inputs "/bin/ktsuss"))))))) diff --git a/gnu/packages/monitoring.scm b/gnu/packages/monitoring.scm index 3238f11fb4..f935c015a4 100644 --- a/gnu/packages/monitoring.scm +++ b/gnu/packages/monitoring.scm @@ -186,7 +186,7 @@ (define-public zabbix-agentd "src/zabbix_server/server.c") ;; 'fping' must be setuid, so look for it in the usual location. (("/usr/sbin/fping6?") - "/run/setuid-programs/fping"))))) + "/run/privileged/bin/fping"))))) (build-system gnu-build-system) (arguments (list #:configure-flags diff --git a/gnu/packages/virtualization.scm b/gnu/packages/virtualization.scm index 9b1bdeb5e4..26e4ecff14 100644 --- a/gnu/packages/virtualization.scm +++ b/gnu/packages/virtualization.scm @@ -764,7 +764,7 @@ (define-public ganeti ;; hard coded PATH. Patch so it works on Guix System. (substitute* "src/Ganeti/Constants.hs" (("/sbin:/bin:/usr/sbin:/usr/bin") - "/run/setuid-programs:/run/current-system/profile/sbin:\ + "/run/privileged/bin:/run/current-system/profile/sbin:\ /run/current-system/profile/bin")))) (add-after 'bootstrap 'patch-sphinx-version-detection (lambda _ diff --git a/gnu/packages/xdisorg.scm b/gnu/packages/xdisorg.scm index da5ca76e10..e7ede8de3e 100644 --- a/gnu/packages/xdisorg.scm +++ b/gnu/packages/xdisorg.scm @@ -2507,7 +2507,7 @@ (define-public xsecurelock '(#:configure-flags '("--with-pam-service-name=login" "--with-xkb" - "--with-default-authproto-module=/run/setuid-programs/authproto_pam"))) + "--with-default-authproto-module=/run/privileged/bin/authproto_pam"))) (native-inputs (list pandoc pkg-config)) (inputs diff --git a/gnu/services/dbus.scm b/gnu/services/dbus.scm index 5a0c634393..bb9efb1c56 100644 --- a/gnu/services/dbus.scm +++ b/gnu/services/dbus.scm @@ -115,7 +115,7 @@ (define (dbus-configuration-directory services) ;; failures such as <https://issues.guix.gnu.org/52051> on slow ;; computers with slow I/O. (limit (@ (name "auth_timeout")) "300000") - (servicehelper "/run/setuid-programs/dbus-daemon-launch-helper") + (servicehelper "/run/privileged/bin/dbus-daemon-launch-helper") ;; First, the '.service' files of services subject to activation. ;; We use a fixed location under /etc because the setuid helper diff --git a/gnu/services/ganeti.scm b/gnu/services/ganeti.scm index f4fec3833e..ee72946c88 100644 --- a/gnu/services/ganeti.scm +++ b/gnu/services/ganeti.scm @@ -182,7 +182,7 @@ (define-module (gnu services ganeti) ;; Ceph, Gluster, etc, without having to add absolute references to everything. (define %default-ganeti-environment-variables (list (string-append "PATH=" - (string-join '("/run/setuid-programs" + (string-join '("/run/privileged/bin" "/run/current-system/profile/sbin" "/run/current-system/profile/bin") ":")))) diff --git a/gnu/services/monitoring.scm b/gnu/services/monitoring.scm index e698040078..c3fc8dafc8 100644 --- a/gnu/services/monitoring.scm +++ b/gnu/services/monitoring.scm @@ -1016,7 +1016,7 @@ (define (zabbix-agent-shepherd-service config) /etc/ssl/certs" "SSL_CERT_FILE=/run/current-system/profile\ /etc/ssl/certs/ca-certificates.crt" - "PATH=/run/setuid-programs:\ + "PATH=/run/privileged/bin:\ /run/current-system/profile/bin:/run/current-system/profile/sbin"))) (stop #~(make-kill-destructor))))) diff --git a/gnu/tests/ldap.scm b/gnu/tests/ldap.scm index 47e77c0c53..d5ab6899cf 100644 --- a/gnu/tests/ldap.scm +++ b/gnu/tests/ldap.scm @@ -144,7 +144,7 @@ (define (run-ldap-test) (test-assert "Can become LDAP user" (marionette-eval - '(zero? (system* "/run/setuid-programs/su" "eva" "-c" + '(zero? (system* "/run/privileged/bin/su" "eva" "-c" #$(file-append coreutils "/bin/true"))) marionette)) diff --git a/gnu/tests/monitoring.scm b/gnu/tests/monitoring.scm index bbab1d8acf..a0c8c929b1 100644 --- a/gnu/tests/monitoring.scm +++ b/gnu/tests/monitoring.scm @@ -189,11 +189,11 @@ (define* (run-zabbix-server-test name test-os) (start-service 'postgres)) marionette)) - ;; Add /run/setuid-programs to $PATH so that the scripts passed to + ;; Add privileged programs to $PATH so that the scripts passed to ;; 'system' can find 'sudo'. (marionette-eval '(setenv "PATH" - "/run/setuid-programs:/run/current-system/profile/bin") + "/run/privileged/bin:/run/current-system/profile/bin") marionette) (test-eq "postgres create zabbix user" -- 2.41.0 ^ permalink raw reply related [flat|nested] 35+ messages in thread
* [bug#61462] [PATCH v2 05/10] system: Add (gnu system privilege). 2023-07-15 23:59 ` [bug#61462] [PATCH v2 01/10] system: Disallow file-like setuid-programs Tobias Geerinckx-Rice via Guix-patches via ` (2 preceding siblings ...) 2023-07-15 23:59 ` [bug#61462] [PATCH v2 04/10] gnu: Replace (almost) all uses of /run/setuid-programs Tobias Geerinckx-Rice via Guix-patches via @ 2023-07-15 23:59 ` Tobias Geerinckx-Rice via Guix-patches via 2023-07-15 23:59 ` [bug#61462] [PATCH v2 06/10] system: (gnu system setuid) wraps " Tobias Geerinckx-Rice via Guix-patches via ` (5 subsequent siblings) 9 siblings, 0 replies; 35+ messages in thread From: Tobias Geerinckx-Rice via Guix-patches via @ 2023-07-15 23:59 UTC (permalink / raw) To: 61462 * gnu/system/privilege.scm: New file. * gnu/local.mk (GNU_SYSTEM_MODULES): Add it. --- gnu/local.mk | 1 + gnu/system/privilege.scm | 58 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 gnu/system/privilege.scm diff --git a/gnu/local.mk b/gnu/local.mk index f10713f126..49298ff0ad 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -733,6 +733,7 @@ GNU_SYSTEM_MODULES = \ %D%/system/mapped-devices.scm \ %D%/system/nss.scm \ %D%/system/pam.scm \ + %D%/system/privilege.scm \ %D%/system/setuid.scm \ %D%/system/shadow.scm \ %D%/system/uuid.scm \ diff --git a/gnu/system/privilege.scm b/gnu/system/privilege.scm new file mode 100644 index 0000000000..d89d5d5d1c --- /dev/null +++ b/gnu/system/privilege.scm @@ -0,0 +1,58 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2021 Brice Waegeneire <brice@waegenei.re> +;;; Copyright © 2022 Tobias Geerinckx-Rice <me@tobias.gr> +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. + +(define-module (gnu system privilege) + #:use-module (guix records) + #:export (privileged-program + privileged-program? + privileged-program-program + privileged-program-setuid? + privileged-program-setgid? + privileged-program-user + privileged-program-group + privileged-program-capabilities)) + +;;; Commentary: +;;; +;;; Data structures representing privileged programs: binaries with additional +;;; permissions such as setuid/setgid, or POSIX capabilities. This is meant to +;;; be used both on the host side and at run time--e.g., in activation snippets. +;;; +;;; Code: + +(define-record-type* <privileged-program> + privileged-program make-privileged-program + privileged-program? + ;; File name of the program to assign elevated privileges. + (program privileged-program-program) ;file-like + ;; Whether to set the setuid (‘set user ID’) bit. + (setuid? privileged-program-setuid? ;boolean + (default #f)) + ;; Whether to set the setgid (‘set group ID’) bit. + (setgid? privileged-program-setgid? ;boolean + (default #f)) + ;; The user name or ID this should be set to (defaults to root's). + (user privileged-program-user ;integer or string + (default 0)) + ;; The group name or ID we want to set this to (defaults to root's). + (group privileged-program-group ;integer or string + (default 0)) + ;; POSIX capabilities in cap_from_text(3) form (defaults to #f: none). + (capabilities privileged-program-capabilities ;string or #f + (default #f))) -- 2.41.0 ^ permalink raw reply related [flat|nested] 35+ messages in thread
* [bug#61462] [PATCH v2 06/10] system: (gnu system setuid) wraps (gnu system privilege). 2023-07-15 23:59 ` [bug#61462] [PATCH v2 01/10] system: Disallow file-like setuid-programs Tobias Geerinckx-Rice via Guix-patches via ` (3 preceding siblings ...) 2023-07-15 23:59 ` [bug#61462] [PATCH v2 05/10] system: Add (gnu system privilege) Tobias Geerinckx-Rice via Guix-patches via @ 2023-07-15 23:59 ` Tobias Geerinckx-Rice via Guix-patches via 2023-07-15 23:59 ` [bug#61462] [PATCH v2 07/10] build: Rename activate-setuid-programs Tobias Geerinckx-Rice via Guix-patches via ` (4 subsequent siblings) 9 siblings, 0 replies; 35+ messages in thread From: Tobias Geerinckx-Rice via Guix-patches via @ 2023-07-15 23:59 UTC (permalink / raw) To: 61462 * gnu/system/setuid.scm (setuid-program): Rewrite as syntax to create a <privileged-program> record that is setuid by default. (setuid-program?, setuid-program-program, setuid-program-setuid?) (setuid-program-setgid?, setuid-program-user, setuid-program-group): Alias their privileged-program equivalent. --- gnu/system/setuid.scm | 44 +++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/gnu/system/setuid.scm b/gnu/system/setuid.scm index 83111d932c..4dd0cc8962 100644 --- a/gnu/system/setuid.scm +++ b/gnu/system/setuid.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2021 Brice Waegeneire <brice@waegenei.re> +;;; Copyright © 2022 Tobias Geerinckx-Rice <me@tobias.gr> ;;; ;;; This file is part of GNU Guix. ;;; @@ -17,7 +18,9 @@ ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. (define-module (gnu system setuid) - #:use-module (guix records) + #:use-module (gnu system privilege) + #:use-module (ice-9 match) + #:use-module (srfi srfi-1) #:export (setuid-program setuid-program? setuid-program-program @@ -30,28 +33,29 @@ (define-module (gnu system setuid) ;;; Commentary: ;;; -;;; Data structures representing setuid/setgid programs. This is meant to be -;;; used both on the host side and at run time--e.g., in activation snippets. +;;; Do not use this module in new code. It used to define data structures +;;; representing setuid/setgid programs, but is now a mere compatibility shim +;;; wrapping a subset of (gnu system privilege). ;;; ;;; Code: -(define-record-type* <setuid-program> - setuid-program make-setuid-program - setuid-program? - ;; Path to program to link with setuid permissions - (program setuid-program-program) ;file-like - ;; Whether to set user setuid bit - (setuid? setuid-program-setuid? ;boolean - (default #t)) - ;; Whether to set group setgid bit - (setgid? setuid-program-setgid? ;boolean - (default #f)) - ;; The user this should be set to (defaults to root) - (user setuid-program-user ;integer or string - (default 0)) - ;; Group we want to set this to (defaults to root) - (group setuid-program-group ;integer or string - (default 0))) +(define-syntax setuid-program + (lambda (fields) + (syntax-case fields () + ((_ (field value) ...) + #`(privileged-program + (setuid? (match (assoc-ref '((field value) ...) 'setuid?) + ((#f) #f) + (_ #t))) + #,@(remove (match-lambda ((f _) (eq? (syntax->datum f) 'setuid?))) + #'((field value) ...))))))) + +(define setuid-program? privileged-program?) +(define setuid-program-program privileged-program-program) +(define setuid-program-setuid? privileged-program-setuid?) +(define setuid-program-setgid? privileged-program-setgid?) +(define setuid-program-user privileged-program-user) +(define setuid-program-group privileged-program-group) (define (file-like->setuid-program program) (setuid-program (program program))) -- 2.41.0 ^ permalink raw reply related [flat|nested] 35+ messages in thread
* [bug#61462] [PATCH v2 07/10] build: Rename activate-setuid-programs. 2023-07-15 23:59 ` [bug#61462] [PATCH v2 01/10] system: Disallow file-like setuid-programs Tobias Geerinckx-Rice via Guix-patches via ` (4 preceding siblings ...) 2023-07-15 23:59 ` [bug#61462] [PATCH v2 06/10] system: (gnu system setuid) wraps " Tobias Geerinckx-Rice via Guix-patches via @ 2023-07-15 23:59 ` Tobias Geerinckx-Rice via Guix-patches via 2023-07-15 23:59 ` [bug#61462] [PATCH v2 08/10] services: Rename setuid-program-service-type Tobias Geerinckx-Rice via Guix-patches via ` (3 subsequent siblings) 9 siblings, 0 replies; 35+ messages in thread From: Tobias Geerinckx-Rice via Guix-patches via @ 2023-07-15 23:59 UTC (permalink / raw) To: 61462 * gnu/build/activation.scm (activate-setuid-programs): Rename this… (activate-privileged-programs): …to this. Operate on a list of <privileged-program> records. * gnu/services.scm (setuid-program->activation-gexp): Adjust caller. --- gnu/build/activation.scm | 24 ++++++++++++------------ gnu/services.scm | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/gnu/build/activation.scm b/gnu/build/activation.scm index 7f4800bba1..84fbeda162 100644 --- a/gnu/build/activation.scm +++ b/gnu/build/activation.scm @@ -27,7 +27,7 @@ (define-module (gnu build activation) #:use-module (gnu system accounts) - #:use-module (gnu system setuid) + #:use-module (gnu system privilege) #:use-module (gnu build accounts) #:use-module (gnu build linux-boot) #:use-module (guix build utils) @@ -41,7 +41,7 @@ (define-module (gnu build activation) #:export (activate-users+groups activate-user-home activate-etc - activate-setuid-programs + activate-privileged-programs activate-special-files activate-modprobe activate-firmware @@ -287,8 +287,8 @@ (define %privileged-program-directory ;; Place where privileged copies of programs are stored. "/run/privileged/bin") -(define (activate-setuid-programs programs) - "Turn PROGRAMS, a list of file setuid-programs records, into privileged +(define (activate-privileged-programs programs) + "Turn PROGRAMS, a list of file privileged-programs records, into privileged copies stored under %PRIVILEGED-PROGRAM-DIRECTORY." (define (ensure-empty-directory directory) (if (file-exists? directory) @@ -325,11 +325,11 @@ (define (activate-setuid-programs programs) (for-each (lambda (program) (catch 'system-error (lambda () - (let* ((program-name (setuid-program-program program)) - (setuid? (setuid-program-setuid? program)) - (setgid? (setuid-program-setgid? program)) - (user (setuid-program-user program)) - (group (setuid-program-group program)) + (let* ((program-name (privileged-program-program program)) + (setuid? (privileged-program-setuid? program)) + (setgid? (privileged-program-setgid? program)) + (user (privileged-program-user program)) + (group (privileged-program-group program)) (uid (match user ((? string?) (passwd:uid (getpwnam user))) ((? integer?) user))) @@ -339,13 +339,13 @@ (define (activate-setuid-programs programs) (make-privileged-program program-name setuid? setgid? uid gid) (make-deprecated-wrapper program-name))) (lambda args - ;; If we fail to create a setuid program, better keep going + ;; If we fail to create a privileged program, better keep going ;; so that we don't leave %PRIVILEGED-PROGRAM-DIRECTORY empty ;; or half-populated. This can happen if PROGRAMS contains ;; incorrect file names: <https://bugs.gnu.org/38800>. (format (current-error-port) - "warning: failed to make ~s setuid/setgid: ~a~%" - (setuid-program-program program) + "warning: failed to privilege ~s: ~a~%" + (privileged-program-program program) (strerror (system-error-errno args)))))) programs)) diff --git a/gnu/services.scm b/gnu/services.scm index eefe58b336..91584e64ca 100644 --- a/gnu/services.scm +++ b/gnu/services.scm @@ -882,7 +882,7 @@ (define (setuid-program->activation-gexp programs) #~(begin (use-modules (gnu system setuid)) - (activate-setuid-programs (list #$@programs)))))) + (activate-privileged-programs (list #$@programs)))))) (define setuid-program-service-type (service-type (name 'setuid-program) -- 2.41.0 ^ permalink raw reply related [flat|nested] 35+ messages in thread
* [bug#61462] [PATCH v2 08/10] services: Rename setuid-program-service-type. 2023-07-15 23:59 ` [bug#61462] [PATCH v2 01/10] system: Disallow file-like setuid-programs Tobias Geerinckx-Rice via Guix-patches via ` (5 preceding siblings ...) 2023-07-15 23:59 ` [bug#61462] [PATCH v2 07/10] build: Rename activate-setuid-programs Tobias Geerinckx-Rice via Guix-patches via @ 2023-07-15 23:59 ` Tobias Geerinckx-Rice via Guix-patches via 2023-07-15 23:59 ` [bug#61462] [PATCH v2 09/10] system: Use privileged-program-service-type by default Tobias Geerinckx-Rice via Guix-patches via ` (2 subsequent siblings) 9 siblings, 0 replies; 35+ messages in thread From: Tobias Geerinckx-Rice via Guix-patches via @ 2023-07-15 23:59 UTC (permalink / raw) To: 61462 * gnu/services.scm (setuid-program->activation-gexp): Rename this… (privileged-program->activation-gexp): …to this. Operate on a list of <privileged-program> records. (privileged-program-service-type): New variable, renamed from setuid-program-service-type. Rename the service-type accordingly. (setuid-program-service-type): Redefine as an alias for the above. --- gnu/services.scm | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/gnu/services.scm b/gnu/services.scm index 91584e64ca..5cb7f37c06 100644 --- a/gnu/services.scm +++ b/gnu/services.scm @@ -45,6 +45,7 @@ (define-module (gnu services) #:use-module (gnu packages base) #:use-module (gnu packages bash) #:use-module (gnu packages hurd) + #:use-module (gnu system privilege) #:use-module (gnu system setuid) #:use-module (srfi srfi-1) #:use-module (srfi srfi-9) @@ -113,7 +114,8 @@ (define-module (gnu services) extra-special-file etc-service-type etc-directory - setuid-program-service-type + privileged-program-service-type + setuid-program-service-type ; deprecated profile-service-type firmware-service-type gc-root-service-type @@ -860,17 +862,17 @@ (define-deprecated (etc-service files) FILES must be a list of name/file-like object pairs." (service etc-service-type files)) -(define (setuid-program->activation-gexp programs) - "Return an activation gexp for setuid-program from PROGRAMS." +(define (privileged-program->activation-gexp programs) + "Return an activation gexp for privileged-program from PROGRAMS." (let ((programs (map (lambda (program) ;; FIXME This is really ugly, I didn't managed to use ;; "inherit" - (let ((program-name (setuid-program-program program)) - (setuid? (setuid-program-setuid? program)) - (setgid? (setuid-program-setgid? program)) - (user (setuid-program-user program)) - (group (setuid-program-group program)) ) - #~(setuid-program + (let ((program-name (privileged-program-program program)) + (setuid? (privileged-program-setuid? program)) + (setgid? (privileged-program-setgid? program)) + (user (privileged-program-user program)) + (group (privileged-program-group program)) ) + #~(privileged-program (setuid? #$setuid?) (setgid? #$setgid?) (user #$user) @@ -878,17 +880,17 @@ (define (setuid-program->activation-gexp programs) (program #$program-name)))) programs))) (with-imported-modules (source-module-closure - '((gnu system setuid))) + '((gnu system privilege))) #~(begin - (use-modules (gnu system setuid)) + (use-modules (gnu system privilege)) (activate-privileged-programs (list #$@programs)))))) -(define setuid-program-service-type - (service-type (name 'setuid-program) +(define privileged-program-service-type + (service-type (name 'privileged-program) (extensions (list (service-extension activation-service-type - setuid-program->activation-gexp))) + privileged-program->activation-gexp))) (compose concatenate) (extend (lambda (config extensions) (append config extensions))) @@ -900,6 +902,10 @@ (define setuid-program-service-type symbolic links to their @file{/run/privileged/bin} counterpart. It will be removed in a future Guix release."))) +(define setuid-program-service-type + ;; Deprecated alias to ease transition. Will be removed! + privileged-program-service-type) + (define (packages->profile-entry packages) "Return a system entry for the profile containing PACKAGES." ;; XXX: 'mlet' is needed here for one reason: to get the proper -- 2.41.0 ^ permalink raw reply related [flat|nested] 35+ messages in thread
* [bug#61462] [PATCH v2 09/10] system: Use privileged-program-service-type by default. 2023-07-15 23:59 ` [bug#61462] [PATCH v2 01/10] system: Disallow file-like setuid-programs Tobias Geerinckx-Rice via Guix-patches via ` (6 preceding siblings ...) 2023-07-15 23:59 ` [bug#61462] [PATCH v2 08/10] services: Rename setuid-program-service-type Tobias Geerinckx-Rice via Guix-patches via @ 2023-07-15 23:59 ` Tobias Geerinckx-Rice via Guix-patches via 2023-07-16 0:00 ` [bug#61462] [PATCH v2 10/10] system: Add privileged-programs to <operating-system> Tobias Geerinckx-Rice via Guix-patches via 2023-07-21 18:53 ` [bug#61462] Add support for file capabilities(7) Vagrant Cascadian 9 siblings, 0 replies; 35+ messages in thread From: Tobias Geerinckx-Rice via Guix-patches via @ 2023-07-15 23:59 UTC (permalink / raw) To: 61462 * gnu/system.scm (operating-system-default-essential-services) (hurd-default-essential-services): Substitute privileged-program-service-type for setuid-program-service-type. --- gnu/system.scm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gnu/system.scm b/gnu/system.scm index b68c4d272b..39c10dddcb 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -783,7 +783,7 @@ (define (operating-system-default-essential-services os) (operating-system-environment-variables os)) (service host-name-service-type host-name) procs root-fs - (service setuid-program-service-type + (service privileged-program-service-type (operating-system-setuid-programs os)) (service profile-service-type (operating-system-packages os)) @@ -824,7 +824,7 @@ (define (hurd-default-essential-services os) (list `("hosts" ,hosts-file))) (service hosts-service-type (local-host-entries host-name))) - (service setuid-program-service-type + (service privileged-program-service-type (operating-system-setuid-programs os)) (service profile-service-type (operating-system-packages os))))) -- 2.41.0 ^ permalink raw reply related [flat|nested] 35+ messages in thread
* [bug#61462] [PATCH v2 10/10] system: Add privileged-programs to <operating-system>. 2023-07-15 23:59 ` [bug#61462] [PATCH v2 01/10] system: Disallow file-like setuid-programs Tobias Geerinckx-Rice via Guix-patches via ` (7 preceding siblings ...) 2023-07-15 23:59 ` [bug#61462] [PATCH v2 09/10] system: Use privileged-program-service-type by default Tobias Geerinckx-Rice via Guix-patches via @ 2023-07-16 0:00 ` Tobias Geerinckx-Rice via Guix-patches via 2023-07-21 18:53 ` [bug#61462] Add support for file capabilities(7) Vagrant Cascadian 9 siblings, 0 replies; 35+ messages in thread From: Tobias Geerinckx-Rice via Guix-patches via @ 2023-07-16 0:00 UTC (permalink / raw) To: 61462 * gnu/system.scm (<operating-system>): Add new privileged-programs field, that defaults to… (%default-privileged-programs): …this new variable, renamed from… (%setuid-programs): …this, which is now defined as the empty list. * doc/guix.texi (Setuid Programs): Rename this… (Privileged Programs): …to this. Adjust all refs. Update all mentions of ‘setuid’ (whether in prose, variable names, or code samples) to use the new ‘privilege[d]’ terminology instead. (operating-system Reference, X Window, Desktop Services, Invoking guix system, Service Reference): Adjust likewise. --- doc/guix.texi | 89 ++++++++++++++++++++++------------------- gnu/packages/crypto.scm | 2 +- gnu/services.scm | 1 - gnu/system.scm | 21 ++++++++-- 4 files changed, 65 insertions(+), 48 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 9426c72e1e..0be8a2f4b5 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -362,7 +362,7 @@ Top * Keyboard Layout:: How the system interprets key strokes. * Locales:: Language and cultural convention settings. * Services:: Specifying system services. -* Setuid Programs:: Programs running with elevated privileges. +* Privileged Programs:: Programs running with elevated privileges. * X.509 Certificates:: Authenticating HTTPS servers. * Name Service Switch:: Configuring libc's name service switch. * Initial RAM Disk:: Linux-Libre bootstrapping. @@ -16712,7 +16712,7 @@ System Configuration * Keyboard Layout:: How the system interprets key strokes. * Locales:: Language and cultural convention settings. * Services:: Specifying system services. -* Setuid Programs:: Programs running with elevated privileges. +* Privileged Programs:: Programs running with elevated privileges. * X.509 Certificates:: Authenticating HTTPS servers. * Name Service Switch:: Configuring libc's name service switch. * Initial RAM Disk:: Linux-Libre bootstrapping. @@ -17159,9 +17159,9 @@ operating-system Reference Linux @dfn{pluggable authentication module} (PAM) services. @c FIXME: Add xref to PAM services section. -@item @code{setuid-programs} (default: @code{%setuid-programs}) -List of @code{<setuid-program>}. @xref{Setuid Programs}, for more -information. +@item @code{privileged-programs} (default: @code{%default-privileged-programs}) +List of @code{<privileged-program>}. @xref{Privileged Programs}, for +more information. @item @code{sudoers-file} (default: @code{%sudoers-specification}) @cindex sudoers file @@ -22760,10 +22760,10 @@ X Window @defvar screen-locker-service-type Type for a service that adds a package for a screen locker or screen -saver to the set of setuid programs and/or add a PAM entry for it. The +saver to the set of privileged programs and/or add a PAM entry for it. The value for this service is a @code{<screen-locker-configuration>} object. -While the default behavior is to setup both a setuid program and PAM +While the default behavior is to setup both a privileged program and PAM entry, these two methods are redundant. Screen locker programs may not execute when PAM is configured and @code{setuid} is set on their executable. In this case, @code{using-setuid?} can be set to @code{#f}. @@ -23689,9 +23689,9 @@ Desktop Services system interfaces. Additionally, adding a service of type @code{mate-desktop-service-type} adds the MATE metapackage to the system profile. ``Adding Enlightenment'' means that @code{dbus} is extended -appropriately, and several of Enlightenment's binaries are set as setuid, -allowing Enlightenment's screen locker and other functionality to work as -expected. +appropriately, and several of Enlightenment's binaries are set as privileged +programs, allowing Enlightenment's screen locker and other functionality to +work as expected. The desktop environments in Guix use the Xorg display server by default. If you'd like to use the newer display server protocol @@ -26727,7 +26727,7 @@ Mail Services Make the following commands setgid to @code{smtpq} so they can be executed: @command{smtpctl}, @command{sendmail}, @command{send-mail}, @command{makemap}, @command{mailq}, and @command{newaliases}. -@xref{Setuid Programs}, for more information on setgid programs. +@xref{Privileged Programs}, for more information on setgid programs. @end table @end deftp @@ -38868,8 +38868,8 @@ Miscellaneous Services service is the Singularity package to use. The service does not install a daemon; instead, it installs helper programs as -setuid-root (@pxref{Setuid Programs}) such that unprivileged users can invoke -@command{singularity run} and similar commands. +setuid-root (@pxref{Privileged Programs}) such that unprivileged users can +invoke @command{singularity run} and similar commands. @end defvar @cindex Audit @@ -39300,11 +39300,14 @@ Miscellaneous Services @c End of auto-generated fail2ban documentation. -@node Setuid Programs -@section Setuid Programs +@node Privileged Programs +@section Privileged Programs +@cindex privileged programs @cindex setuid programs @cindex setgid programs +@cindex capabilities, POSIX +@cindex setcap Some programs need to run with elevated privileges, even when they are launched by unprivileged users. A notorious example is the @command{passwd} program, which users can run to change their @@ -39315,46 +39318,48 @@ Setuid Programs (@pxref{How Change Persona,,, libc, The GNU C Library Reference Manual}, for more info about the setuid mechanism). -The store itself @emph{cannot} contain setuid programs: that would be a -security issue since any user on the system can write derivations that +The store itself @emph{cannot} contain privileged programs: that would be +a security issue since any user on the system can write derivations that populate the store (@pxref{The Store}). Thus, a different mechanism is -used: instead of changing the setuid or setgid bits directly on files that -are in the store, we let the system administrator @emph{declare} which +used: instead of directly granting permissions to files that are in +the store, we let the system administrator @emph{declare} which programs should be entrusted with these additional privileges. -The @code{setuid-programs} field of an @code{operating-system} -declaration contains a list of @code{<setuid-program>} denoting the +The @code{privileged-programs} field of an @code{operating-system} +declaration contains a list of @code{<privileged-program>} denoting the names of programs to have a setuid or setgid bit set (@pxref{Using the Configuration System}). For instance, the @command{mount.nfs} program, which is part of the nfs-utils package, with a setuid root can be designated like this: @lisp -(setuid-program - (program (file-append nfs-utils "/sbin/mount.nfs"))) +(privileged-program + (program (file-append nfs-utils "/sbin/mount.nfs")) + (setuid? #t)) @end lisp And then, to make @command{mount.nfs} setuid on your system, add the previous example to your operating system declaration by appending it to -@code{%setuid-programs} like this: +@code{%default-privileged-programs} like this: @lisp (operating-system ;; Some fields omitted... - (setuid-programs - (append (list (setuid-program - (program (file-append nfs-utils "/sbin/mount.nfs")))) - %setuid-programs))) + (privileged-programs + (append (list (privileged-program + (program (file-append nfs-utils "/sbin/mount.nfs")) + (setuid? #t)) + %default-privileged-programs))) @end lisp -@deftp {Data Type} setuid-program -This data type represents a program with a setuid or setgid bit set. +@deftp {Data Type} privileged-program +This data type represents a program with special privileges, such as setuid @table @asis @item @code{program} -A file-like object having its setuid and/or setgid bit set. +A file-like object to which all given privileges should apply. -@item @code{setuid?} (default: @code{#t}) +@item @code{setuid?} (default: @code{#f}) Whether to set user setuid bit. @item @code{setgid?} (default: @code{#f}) @@ -39371,18 +39376,18 @@ Setuid Programs @end table @end deftp -A default set of setuid programs is defined by the -@code{%setuid-programs} variable of the @code{(gnu system)} module. +A default set of privileged programs is defined by the +@code{%default-privileged-programs} variable of the @code{(gnu system)} module. -@defvar %setuid-programs -A list of @code{<setuid-program>} denoting common programs that are -setuid-root. +@defvar {Scheme Variable} %default-privileged-programs +A list of @code{<privileged-program>} denoting common programs with +elevated privileges. The list includes commands such as @command{passwd}, @command{ping}, @command{su}, and @command{sudo}. @end defvar -Under the hood, the actual setuid programs are created in the +Under the hood, the actual privileged programs are created in the @file{/run/privileged/bin} directory at system activation time. The files in this directory refer to the ``real'' binaries, which are in the store. @@ -40276,7 +40281,7 @@ Invoking guix system @end quotation This effects all the configuration specified in @var{file}: user -accounts, system services, global package list, setuid programs, etc. +accounts, system services, global package list, privileged programs, etc. The command starts system services specified in @var{file} that are not currently running; if a service is currently running this command will arrange for it to be upgraded the next time it is stopped (e.g.@: by @@ -41649,10 +41654,10 @@ Service Reference pointing to the given file. @end defvar -@defvar setuid-program-service-type -Type for the ``setuid-program service''. This service collects lists of +@defvar privileged-program-service-type +Type for the ``privileged-program service''. This service collects lists of executable file names, passed as gexps, and adds them to the set of -setuid and setgid programs on the system (@pxref{Setuid Programs}). +privileged programs on the system (@pxref{Privileged Programs}). @end defvar @defvar profile-service-type diff --git a/gnu/packages/crypto.scm b/gnu/packages/crypto.scm index 91acedbc97..5c711e0cc6 100644 --- a/gnu/packages/crypto.scm +++ b/gnu/packages/crypto.scm @@ -501,7 +501,7 @@ (define-public tomb `(#:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out"))) ;; The "sudo" input is needed only to satisfy dependency checks in the ;; 'check' phase. The "sudo" used at runtime should come from the - ;; system's setuid-programs, so ensure no reference is kept. + ;; system's privileged-programs, so ensure no reference is kept. #:disallowed-references (,sudo) ;; TODO: Build and install gtk and qt trays #:phases diff --git a/gnu/services.scm b/gnu/services.scm index 5cb7f37c06..a96d42099f 100644 --- a/gnu/services.scm +++ b/gnu/services.scm @@ -46,7 +46,6 @@ (define-module (gnu services) #:use-module (gnu packages bash) #:use-module (gnu packages hurd) #:use-module (gnu system privilege) - #:use-module (gnu system setuid) #:use-module (srfi srfi-1) #:use-module (srfi srfi-9) #:use-module (srfi srfi-9 gnu) diff --git a/gnu/system.scm b/gnu/system.scm index 39c10dddcb..572a0c19df 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -75,6 +75,7 @@ (define-module (gnu system) #:use-module (gnu system locale) #:use-module (gnu system pam) #:use-module (gnu system linux-initrd) + #:use-module (gnu system privilege) #:use-module (gnu system setuid) #:use-module (gnu system uuid) #:use-module (gnu system file-systems) @@ -128,6 +129,7 @@ (define-module (gnu system) operating-system-keyboard-layout operating-system-name-service-switch operating-system-pam-services + operating-system-privileged-programs operating-system-setuid-programs operating-system-skeletons operating-system-sudoers-file @@ -172,6 +174,7 @@ (define-module (gnu system) local-host-aliases ;deprecated %root-account + %default-privileged-programs %setuid-programs %sudoers-specification %base-packages @@ -295,7 +298,10 @@ (define-record-type* <operating-system> operating-system (pam-services operating-system-pam-services ; list of PAM services (default (base-pam-services))) + (privileged-programs operating-system-privileged-programs ; list of <privileged-program> + (default %default-privileged-programs)) (setuid-programs operating-system-setuid-programs + ;; For backwards compatibility; will be removed. (default %setuid-programs)) ; list of <setuid-program> (sudoers-file operating-system-sudoers-file ; file-like @@ -784,7 +790,8 @@ (define (operating-system-default-essential-services os) (service host-name-service-type host-name) procs root-fs (service privileged-program-service-type - (operating-system-setuid-programs os)) + (append (operating-system-privileged-programs os) + (operating-system-setuid-programs os))) (service profile-service-type (operating-system-packages os)) boot-fs non-boot-fs @@ -825,7 +832,8 @@ (define (hurd-default-essential-services os) (service hosts-service-type (local-host-entries host-name))) (service privileged-program-service-type - (operating-system-setuid-programs os)) + (append (operating-system-privileged-programs os) + (operating-system-setuid-programs os))) (service profile-service-type (operating-system-packages os))))) (define* (operating-system-services os) @@ -1202,8 +1210,7 @@ (define (operating-system-environment-variables os) ;; when /etc/machine-id is missing. Make sure these warnings are non-fatal. ("DBUS_FATAL_WARNINGS" . "0"))) -(define %setuid-programs - ;; Default set of setuid-root programs. +(define %default-privileged-programs (let ((shadow (@ (gnu packages admin) shadow))) (map file-like->setuid-program (list (file-append shadow "/bin/passwd") @@ -1225,6 +1232,12 @@ (define %setuid-programs (file-append util-linux "/bin/mount") (file-append util-linux "/bin/umount"))))) +(define %setuid-programs + ;; Do not add to this list or use it in new code! It's defined only to ease + ;; transition to %default-privileged-programs and will be removed. Some rare + ;; use cases already break, such as the obvious (remove … %setuid-programs). + '()) + (define %sudoers-specification ;; Default /etc/sudoers contents: 'root' and all members of the 'wheel' ;; group can do anything. See -- 2.41.0 ^ permalink raw reply related [flat|nested] 35+ messages in thread
* [bug#61462] Add support for file capabilities(7) 2023-07-15 23:59 ` [bug#61462] [PATCH v2 01/10] system: Disallow file-like setuid-programs Tobias Geerinckx-Rice via Guix-patches via ` (8 preceding siblings ...) 2023-07-16 0:00 ` [bug#61462] [PATCH v2 10/10] system: Add privileged-programs to <operating-system> Tobias Geerinckx-Rice via Guix-patches via @ 2023-07-21 18:53 ` Vagrant Cascadian 2023-07-21 19:11 ` Vagrant Cascadian 2023-11-15 21:37 ` [bug#61462] Add support for file capabilities(7) Vagrant Cascadian 9 siblings, 2 replies; 35+ messages in thread From: Vagrant Cascadian @ 2023-07-21 18:53 UTC (permalink / raw) To: Tobias Geerinckx-Rice, 61462 [-- Attachment #1: Type: text/plain, Size: 679 bytes --] Thanks for the refreshed v2 patches! I gave them a quick spin... As noted on IRC, apparently it lacks actual calls to setcap, so that part still needs another patch at least! Otherwise, it did seem to more-or-less work... There are compatibility symlinks from /run/setuid-programs to /run/privledged/bin and it sets setuid on requested files. I was a little curious about why /run/privlidged/bin as opposed to without /bin ... keeping the door open for other privlidged things? What about things that come from /gnu/store/*/sbin ? are those handled any differently? My only concern is... wow is it hard, even for a native speaker, to spell privileged! live well, vagrant [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 227 bytes --] ^ permalink raw reply [flat|nested] 35+ messages in thread
* [bug#61462] Add support for file capabilities(7) 2023-07-21 18:53 ` [bug#61462] Add support for file capabilities(7) Vagrant Cascadian @ 2023-07-21 19:11 ` Vagrant Cascadian 2023-08-08 15:40 ` Ludovic Courtès 2023-11-15 21:37 ` [bug#61462] Add support for file capabilities(7) Vagrant Cascadian 1 sibling, 1 reply; 35+ messages in thread From: Vagrant Cascadian @ 2023-07-21 19:11 UTC (permalink / raw) To: Tobias Geerinckx-Rice, 61462 [-- Attachment #1: Type: text/plain, Size: 904 bytes --] On 2023-07-21, Vagrant Cascadian wrote: > Thanks for the refreshed v2 patches! I gave them a quick spin... > > As noted on IRC, apparently it lacks actual calls to setcap, so that > part still needs another patch at least! > > Otherwise, it did seem to more-or-less work... > > There are compatibility symlinks from /run/setuid-programs to > /run/privledged/bin and it sets setuid on requested files. Oh, I noticed on reconfiguring back to a system without the patches to support /run/privileged configurations ... the /run/privileged directory is still present, with all those files sitting there in their previous state. This is why I think at least by default, many other distros implement /run as a tmpfs or similar, so that it at least gets thrown out at reboot. Though this is obviously a deeper problem than just this patch series... I will file a separate bug about that. live well, vagrant [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 227 bytes --] ^ permalink raw reply [flat|nested] 35+ messages in thread
* [bug#61462] Add support for file capabilities(7) 2023-07-21 19:11 ` Vagrant Cascadian @ 2023-08-08 15:40 ` Ludovic Courtès 2023-08-29 20:29 ` [bug#61462] /run should be cleaned on boot Vagrant Cascadian 0 siblings, 1 reply; 35+ messages in thread From: Ludovic Courtès @ 2023-08-08 15:40 UTC (permalink / raw) To: Vagrant Cascadian; +Cc: Tobias Geerinckx-Rice, 61462 Hey! Vagrant Cascadian <vagrant@debian.org> skribis: > Oh, I noticed on reconfiguring back to a system without the patches to > support /run/privileged configurations ... the /run/privileged directory > is still present, with all those files sitting there in their previous > state. > > This is why I think at least by default, many other distros implement > /run as a tmpfs or similar, so that it at least gets thrown out at > reboot. Though this is obviously a deeper problem than just this patch > series... I will file a separate bug about that. We could try to make that change: /run as tmpfs, or wiped by ‘cleanup-service-type’. Ludo’. ^ permalink raw reply [flat|nested] 35+ messages in thread
* [bug#61462] /run should be cleaned on boot 2023-08-08 15:40 ` Ludovic Courtès @ 2023-08-29 20:29 ` Vagrant Cascadian 0 siblings, 0 replies; 35+ messages in thread From: Vagrant Cascadian @ 2023-08-29 20:29 UTC (permalink / raw) To: Ludovic Courtès; +Cc: 64775, 61462 [-- Attachment #1: Type: text/plain, Size: 798 bytes --] On 2023-08-08, Ludovic Courtès wrote: > Vagrant Cascadian <vagrant@debian.org> skribis: >> Oh, I noticed on reconfiguring back to a system without the patches to >> support /run/privileged configurations ... the /run/privileged directory >> is still present, with all those files sitting there in their previous >> state. >> >> This is why I think at least by default, many other distros implement >> /run as a tmpfs or similar, so that it at least gets thrown out at >> reboot. Though this is obviously a deeper problem than just this patch >> series... I will file a separate bug about that. > > We could try to make that change: /run as tmpfs, or wiped by > ‘cleanup-service-type’. Or both, really! Filed: https://issues.guix.gnu.org/64775 live well, vagrant [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 227 bytes --] ^ permalink raw reply [flat|nested] 35+ messages in thread
* [bug#61462] Add support for file capabilities(7) 2023-07-21 18:53 ` [bug#61462] Add support for file capabilities(7) Vagrant Cascadian 2023-07-21 19:11 ` Vagrant Cascadian @ 2023-11-15 21:37 ` Vagrant Cascadian 2023-12-24 0:34 ` Vagrant Cascadian 1 sibling, 1 reply; 35+ messages in thread From: Vagrant Cascadian @ 2023-11-15 21:37 UTC (permalink / raw) To: Tobias Geerinckx-Rice, 61462 [-- Attachment #1: Type: text/plain, Size: 959 bytes --] On 2023-07-21, Vagrant Cascadian wrote: > Thanks for the refreshed v2 patches! I gave them a quick spin... > > As noted on IRC, apparently it lacks actual calls to setcap, so that > part still needs another patch at least! > > Otherwise, it did seem to more-or-less work... I did eventually get some updated patches that even followed through on the promise of calling out to setcap, and from what I recall they even worked! I liked them a lot. > There are compatibility symlinks from /run/setuid-programs to > /run/privledged/bin and it sets setuid on requested files. > > I was a little curious about why /run/privlidged/bin as opposed to > without /bin ... keeping the door open for other privlidged things? What > about things that come from /gnu/store/*/sbin ? are those handled any > differently? Working patches aside, that is my only outstanding question, and I would hate to see that be a blocker. :) In short, "ping" :) live well, vagrant [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 227 bytes --] ^ permalink raw reply [flat|nested] 35+ messages in thread
* [bug#61462] Add support for file capabilities(7) 2023-11-15 21:37 ` [bug#61462] Add support for file capabilities(7) Vagrant Cascadian @ 2023-12-24 0:34 ` Vagrant Cascadian 2024-01-08 16:45 ` Ludovic Courtès 0 siblings, 1 reply; 35+ messages in thread From: Vagrant Cascadian @ 2023-12-24 0:34 UTC (permalink / raw) To: Tobias Geerinckx-Rice, 61462; +Cc: Ludovic Courtès, brian [-- Attachment #1: Type: text/plain, Size: 1848 bytes --] On 2023-11-15, Vagrant Cascadian wrote: > On 2023-07-21, Vagrant Cascadian wrote: >> Thanks for the refreshed v2 patches! I gave them a quick spin... >> >> As noted on IRC, apparently it lacks actual calls to setcap, so that >> part still needs another patch at least! >> >> Otherwise, it did seem to more-or-less work... > > I did eventually get some updated patches that even followed through on > the promise of calling out to setcap, and from what I recall they even > worked! I liked them a lot. > > >> There are compatibility symlinks from /run/setuid-programs to >> /run/privledged/bin and it sets setuid on requested files. >> >> I was a little curious about why /run/privlidged/bin as opposed to >> without /bin ... keeping the door open for other privlidged things? What >> about things that come from /gnu/store/*/sbin ? are those handled any >> differently? > > Working patches aside, that is my only outstanding question, and I would > hate to see that be a blocker. :) I just noticed I pushed a branch with the working patches to a public branch last month: https://salsa.debian.org/debian/guix/-/tree/capabilities-61462-20231115?ref_type=heads They are even still cherry-pickable from current master! Yay! These patches were started over a year ago(well, probably before that, even), and had a working implementation about 6 months ago... My guess is the main blocker is nervousness about renaming setuid-programs to privilidged-programs (I know I am a bit nervous to do so!)? This would make it possible to properly fix several bugs: https://issues.guix.gnu.org/27415 https://issues.guix.gnu.org/39136 https://issues.guix.gnu.org/39136 https://issues.guix.gnu.org/55683 And have been mentioned indirectly in several others over the years: https://issues.guix.gnu.org/search?query=setcap live well, vagrant [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 227 bytes --] ^ permalink raw reply [flat|nested] 35+ messages in thread
* [bug#61462] Add support for file capabilities(7) 2023-12-24 0:34 ` Vagrant Cascadian @ 2024-01-08 16:45 ` Ludovic Courtès 2024-08-19 14:55 ` Ludovic Courtès 0 siblings, 1 reply; 35+ messages in thread From: Ludovic Courtès @ 2024-01-08 16:45 UTC (permalink / raw) To: Vagrant Cascadian; +Cc: Tobias Geerinckx-Rice, 61462, brian Hello! Vagrant Cascadian <vagrant@debian.org> skribis: > I just noticed I pushed a branch with the working patches to a public > branch last month: > > https://salsa.debian.org/debian/guix/-/tree/capabilities-61462-20231115?ref_type=heads > > They are even still cherry-pickable from current master! Yay! Wo0t! > These patches were started over a year ago(well, probably before that, > even), and had a working implementation about 6 months ago... > > My guess is the main blocker is nervousness about renaming > setuid-programs to privilidged-programs (I know I am a bit nervous to do > so!)? It shouldn’t be an issue as /run/setuid-programs is populated with symlinks for backward compatibility. AIUI, we can still use good’ol setuid programs on the Hurd until a better solution is found, so we should be fine (meaning “make check-system TESTS=childhurd” should pass). We could emit a deprecation warning when someone uses the ‘setuid-programs’ field of <operating-system>. Not a blocker though. Tobias, ready to push? :-) Cheers, Ludo’. ^ permalink raw reply [flat|nested] 35+ messages in thread
* [bug#61462] Add support for file capabilities(7) 2024-01-08 16:45 ` Ludovic Courtès @ 2024-08-19 14:55 ` Ludovic Courtès 0 siblings, 0 replies; 35+ messages in thread From: Ludovic Courtès @ 2024-08-19 14:55 UTC (permalink / raw) To: Tobias Geerinckx-Rice; +Cc: Vagrant Cascadian, 61462, brian Hey Tobias & all, Thanks for pushing this series!! I followed up with these commits: ce40b1c655 install: Set ‘privileged-programs’ rather than ‘setuid-programs’. b51990057c system: hurd: Empty default ‘privileged-programs’ list. 2cccf2f11c services: Truly mark ‘setuid-program-service-type’ as deprecated. 52ac2db924 services: privileged-program: No libcap when cross-compiling to the Hurd. They restore support for Guix System cross-compilation to GNU/Hurd, as tested with: make check-system TESTS=childhurd Let me know if I got anything wrong! Note that there’s a number of internal uses of ‘setuid-program-service-type’ that we should update at some point (no rush, though). Thanks, Ludo’. ^ permalink raw reply [flat|nested] 35+ messages in thread
end of thread, other threads:[~2024-08-19 14:56 UTC | newest] Thread overview: 35+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-02-12 20:37 [bug#61462] Add support for file capabilities(7) Tobias Geerinckx-Rice via Guix-patches via 2023-02-05 0:00 ` [bug#61462] [PATCH 01/10] system: Disallow file-like setuid-programs Tobias Geerinckx-Rice via Guix-patches via 2023-02-05 0:00 ` [bug#61462] [PATCH 02/10] services: setuid-program: Populate /run/privileged/bin Tobias Geerinckx-Rice via Guix-patches via 2023-02-05 0:00 ` [bug#61462] [PATCH 03/10] system: Use /run/privileged/bin in search paths Tobias Geerinckx-Rice via Guix-patches via 2023-02-05 0:00 ` [bug#61462] [PATCH 04/10] gnu: Replace (almost) all uses of /run/setuid-programs Tobias Geerinckx-Rice via Guix-patches via 2023-02-05 0:00 ` [bug#61462] [PATCH 05/10] system: Add (gnu system privilege) Tobias Geerinckx-Rice via Guix-patches via 2023-02-05 0:00 ` [bug#61462] [PATCH 06/10] system: (gnu system setuid) wraps " Tobias Geerinckx-Rice via Guix-patches via 2023-02-05 0:00 ` [bug#61462] [PATCH 07/10] build: Rename activate-setuid-programs Tobias Geerinckx-Rice via Guix-patches via 2023-02-05 0:00 ` [bug#61462] [PATCH 08/10] services: Rename setuid-program-service-type Tobias Geerinckx-Rice via Guix-patches via 2023-02-05 0:00 ` [bug#61462] [PATCH 09/10] system: Use privileged-program-service-type by default Tobias Geerinckx-Rice via Guix-patches via 2023-02-05 0:00 ` [bug#61462] [PATCH 10/10] system: Add privileged-programs to <operating-system> Tobias Geerinckx-Rice via Guix-patches via 2023-02-12 21:05 ` [bug#61462] Add support for file capabilities(7) Tobias Geerinckx-Rice via Guix-patches via 2023-03-04 16:55 ` Ludovic Courtès 2023-03-24 4:31 ` Vagrant Cascadian via Guix-patches 2023-04-18 13:14 ` Ludovic Courtès 2023-04-18 19:38 ` Vagrant Cascadian 2023-04-20 10:33 ` Ludovic Courtès 2023-07-15 23:59 ` [bug#61462] [PATCH v2 01/10] system: Disallow file-like setuid-programs Tobias Geerinckx-Rice via Guix-patches via 2023-07-15 23:59 ` [bug#61462] [PATCH v2 02/10] services: setuid-program: Populate /run/privileged/bin Tobias Geerinckx-Rice via Guix-patches via 2023-07-15 23:59 ` [bug#61462] [PATCH v2 03/10] system: Use /run/privileged/bin in search paths Tobias Geerinckx-Rice via Guix-patches via 2023-07-15 23:59 ` [bug#61462] [PATCH v2 04/10] gnu: Replace (almost) all uses of /run/setuid-programs Tobias Geerinckx-Rice via Guix-patches via 2023-07-15 23:59 ` [bug#61462] [PATCH v2 05/10] system: Add (gnu system privilege) Tobias Geerinckx-Rice via Guix-patches via 2023-07-15 23:59 ` [bug#61462] [PATCH v2 06/10] system: (gnu system setuid) wraps " Tobias Geerinckx-Rice via Guix-patches via 2023-07-15 23:59 ` [bug#61462] [PATCH v2 07/10] build: Rename activate-setuid-programs Tobias Geerinckx-Rice via Guix-patches via 2023-07-15 23:59 ` [bug#61462] [PATCH v2 08/10] services: Rename setuid-program-service-type Tobias Geerinckx-Rice via Guix-patches via 2023-07-15 23:59 ` [bug#61462] [PATCH v2 09/10] system: Use privileged-program-service-type by default Tobias Geerinckx-Rice via Guix-patches via 2023-07-16 0:00 ` [bug#61462] [PATCH v2 10/10] system: Add privileged-programs to <operating-system> Tobias Geerinckx-Rice via Guix-patches via 2023-07-21 18:53 ` [bug#61462] Add support for file capabilities(7) Vagrant Cascadian 2023-07-21 19:11 ` Vagrant Cascadian 2023-08-08 15:40 ` Ludovic Courtès 2023-08-29 20:29 ` [bug#61462] /run should be cleaned on boot Vagrant Cascadian 2023-11-15 21:37 ` [bug#61462] Add support for file capabilities(7) Vagrant Cascadian 2023-12-24 0:34 ` Vagrant Cascadian 2024-01-08 16:45 ` Ludovic Courtès 2024-08-19 14:55 ` Ludovic Courtès
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/guix.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).