From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id CDdmDzGcs19ycgAA0tVLHw (envelope-from ) for ; Tue, 17 Nov 2020 09:47:29 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id sMRNCzGcs1/KGAAA1q6Kng (envelope-from ) for ; Tue, 17 Nov 2020 09:47:29 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 75F2D940148 for ; Tue, 17 Nov 2020 09:47:28 +0000 (UTC) Received: from localhost ([::1]:48888 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kexa9-0003qK-F5 for larch@yhetil.org; Tue, 17 Nov 2020 04:47:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51244) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kexZm-0003ny-09 for guix-patches@gnu.org; Tue, 17 Nov 2020 04:47:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:46801) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kexZl-0007zm-L0 for guix-patches@gnu.org; Tue, 17 Nov 2020 04:47:01 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kexZl-0003l0-JB for guix-patches@gnu.org; Tue, 17 Nov 2020 04:47:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#44700] services: setuid: More configurable setuid support. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 17 Nov 2020 09:47:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 44700 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: To: Christopher Lemmer Webber Cc: 44700@debbugs.gnu.org Received: via spool by 44700-submit@debbugs.gnu.org id=B44700.160560637714390 (code B ref 44700); Tue, 17 Nov 2020 09:47:01 +0000 Received: (at 44700) by debbugs.gnu.org; 17 Nov 2020 09:46:17 +0000 Received: from localhost ([127.0.0.1]:58347 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kexZ3-0003k1-1F for submit@debbugs.gnu.org; Tue, 17 Nov 2020 04:46:17 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50908) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kexYy-0003jm-82 for 44700@debbugs.gnu.org; Tue, 17 Nov 2020 04:46:15 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:51433) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kexYs-0007iV-M8; Tue, 17 Nov 2020 04:46:06 -0500 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=54064 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kexYr-0002Y4-6U; Tue, 17 Nov 2020 04:46:05 -0500 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <874klog9tk.fsf@dustycloud.org> Date: Tue, 17 Nov 2020 10:46:03 +0100 In-Reply-To: <874klog9tk.fsf@dustycloud.org> (Christopher Lemmer Webber's message of "Mon, 16 Nov 2020 18:29:11 -0500") Message-ID: <87r1oss4dg.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -3.3 (---) X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Scanner: ns3122888.ip-94-23-21.eu Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Spam-Score: -1.51 X-TUID: mpl/7CaSB+I7 Hello! Christopher Lemmer Webber skribis: >>>From eadac673fb22132c555a4e1cee57a6308ecfdad4 Mon Sep 17 00:00:00 2001 > From: Christopher Lemmer Webber > Date: Sun, 15 Nov 2020 16:58:52 -0500 > Subject: [PATCH] services: setuid: More configurable setuid support. > > New record with fields for setting the specific user and > group, as well as specifically selecting the setuid and setgid bits, for a > program within the setuid-program-service. > > * gnu/services.scm (): New record type. > (setuid-program, make-setuid-program, setuid-program?) > (setuid-program-program, stuid-program-setuid?, setuid-program-setgid?) > (setuid-program-user, setuid-program-group): New variables, export them. > (setuid-program-entry): New variable, a procedure used for the > service-extension of activation-service-type as set up by > setuid-program-service-type. Unpacks the record, > handing off within the gexp to activate-setuid-programs. > (setuid-program-service-type): Make use of setuid-program-entry. > * gnu/build/activation.scm (activate-setuid-programs): Update to expect a > ftagged list for each program entry, pre-unpacked from the > record before being handed to this procedure. This looks like the right approach to me! > + (for-each (match-lambda > + [('setuid-program src-path setuid? setgid? user group) > + (let ((uid (match user > + [(? string?) (passwd:uid (getpwnam user))] > + [(? integer?) user])) > + (gid (match group > + [(? string?) (group:gid (getgrnam user))] > + [(? integer?) group]))) > + (catch 'system-error > + (lambda () > + (let ((target (string-append %setuid-directory > + "/" (basename src-path= ))) > + (mode (+ #o0555 ; base perm= issions > + (if setuid? #o4000 0) ; setuid bit > + (if setgid? #o2000 0)))) ; setgid bit > + (copy-file src-path target) > + (chown target uid gid) > + (chmod target mode))) Nitpick: I=E2=80=99d write =E2=80=9Cprogram=E2=80=9D or =E2=80=9Csource=E2= =80=9D instead of =E2=80=9Csrc-path=E2=80=9D and avoid square brackets for consistency with the rest of the code base (you spent time in Racket-land, didn=E2=80=99t you? ;-)). > +(define (setuid-program-entry programs) > + #~(activate-setuid-programs > + ;; convert into a tagged list structure as expected by > + ;; activate-setuid-programs > + (list #$@(map (match-lambda > + [(? setuid-program? sp) > + #~(list 'setuid-program > + #$(setuid-program-program sp) > + #$(setuid-program-setuid? sp) > + #$(setuid-program-setgid? sp) > + #$(setuid-program-user sp) > + #$(setuid-program-group sp))] > + ;; legacy, non- structure > + [program > + ;; TODO: Spit out a warning here? > + #~(list 'setuid-program > + #$program > + #t #t 0 0)]) > + programs)))) Maybe what we could do is rename =E2=80=98operating-system-setuid-programs= =E2=80=99 to =E2=80=99%operating-system-setuid-programs=E2=80=99, keep that internal, an= d add a new =E2=80=98operating-system-setuid-programs=E2=80=99 that calls the other one= and =E2=80=9Ccanonicalizes=E2=80=9D list entries so that they=E2=80=99re all records. It would call: (warning log (G_ "representing setuid programs with strings is \ deprecated; use 'setuid-program' instead~%")) WDYT? Could you also update the =E2=80=9CSetuid Programs=E2=80=9D section of the = manual? In a subsequent commit, we need to adjust all the services that extend =E2=80=98setuid-program-service-type=E2=80=99 so they pass a and not a string. Thanks! Ludo=E2=80=99.