From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id wLucFAyQ515BKAAA0tVLHw (envelope-from ) for ; Mon, 15 Jun 2020 15:13:16 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id YEt2EAyQ515WbQAAB5/wlQ (envelope-from ) for ; Mon, 15 Jun 2020 15:13:16 +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 E7FED94053F for ; Mon, 15 Jun 2020 15:13:15 +0000 (UTC) Received: from localhost ([::1]:34746 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jkqnS-0003cj-SW for larch@yhetil.org; Mon, 15 Jun 2020 11:13:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37900) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jkqnG-0003Yn-PS for guix-patches@gnu.org; Mon, 15 Jun 2020 11:13:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:35631) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jkqnG-00081N-GZ for guix-patches@gnu.org; Mon, 15 Jun 2020 11:13:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jkqnG-0007OP-CK for guix-patches@gnu.org; Mon, 15 Jun 2020 11:13:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#41763] services: opensmtpd: Fix the setgid problem for the smtpctl utility. Resent-From: Brice Waegeneire Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 15 Jun 2020 15:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41763 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: To: maxim.cournoyer@gmail.com Cc: Christopher Baines , 41763@debbugs.gnu.org Received: via spool by 41763-submit@debbugs.gnu.org id=B41763.159223397628391 (code B ref 41763); Mon, 15 Jun 2020 15:13:02 +0000 Received: (at 41763) by debbugs.gnu.org; 15 Jun 2020 15:12:56 +0000 Received: from localhost ([127.0.0.1]:47175 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jkqn9-0007Nq-TZ for submit@debbugs.gnu.org; Mon, 15 Jun 2020 11:12:56 -0400 Received: from relay2-d.mail.gandi.net ([217.70.183.194]:65471) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jkqn8-0007Nc-63 for 41763@debbugs.gnu.org; Mon, 15 Jun 2020 11:12:55 -0400 X-Originating-IP: 78.237.113.178 Received: from localhost (luy13-1-78-237-113-178.fbx.proxad.net [78.237.113.178]) (Authenticated sender: brice@waegenei.re) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id E9EA140008; Mon, 15 Jun 2020 15:12:46 +0000 (UTC) From: Brice Waegeneire In-Reply-To: <87eeqpih6q.fsf@hurd.i-did-not-set--mail-host-address--so-tickle-me> (maxim cournoyer's message of "Mon, 08 Jun 2020 13:46:37 -0400") References: <87eeqpih6q.fsf@hurd.i-did-not-set--mail-host-address--so-tickle-me> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.91 (gnu/linux) Date: Mon, 15 Jun 2020 17:12:40 +0200 Message-ID: <87d060747r.fsf@waegenei.re> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -1.7 (-) 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: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; 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.01 X-TUID: KC74Ut7DbLSW Hello Maxim, Thank you for the patchset! maxim.cournoyer@gmail.com writes: > The following patches provide a mean to specify a user and group for a > setuid program, and uses that to fix a setgid permission issue in the > context of the opensmtpd service. I applied it to try to use wireshark as non-root[0]: --8<---------------cut here---------------start------------->8--- (simple-service 'wireshark-group account-service-type (list (user-group (name "wireshark") (system? #t)))) (simple-service 'wireshark-dumpcap setuid-program-service-type (list (list (file-append wireshark "/bin/dumpcap") "root" "wireshark"))) --8<---------------cut here---------------end--------------->8--- And unfortunately the first run of =E2=80=9Cguix reconfigure=E2=80=9C faile= d to make =E2=80=9Cdumpcap=E2=80=9C as a setuid, but subsequent run succeeded: --8<---------------cut here---------------start------------->8--- [=E2=80=A6] setting up setuid programs in '/run/setuid-programs'... warning: failed to make '/gnu/store/vdlk9rli5k5svy8p7bhf90ln03ybnxgj-wiresh= ark-3.2.4/bin/dumpcap' setuid (root:wireshark): Success populating /etc from /gnu/store/hxjyvg80zjaxfynjyk3jgqsn9249azmx-etc... [=E2=80=A6] --8<---------------cut here---------------end--------------->8--- I guess it's because at first there wasn't a wireshark group on my system, adding the group and the setuid program was done in the same run, but =E2=80=9Csetting up setuid programs=E2=80=9D is done before =E2=80= =9Cpopulating /etc=E2=80=9D (comprising /etc/passwd) which in effect ended up trying to setuid =E2=80=9Cdumpcap=E2=80=9C before the =E2=80=9Cwireshark=E2=80=9C group exis= ts. And subsequent runs succeeded creating a setuid =E2=80=9Cdumpcap=E2=80=9D because the new group= was already on the system, it was created during the first run. Populating /etc before setting up /run/setuid-programs should fix that issue but maybe there is reason behind the current order of execution. > Christopher, you should be able to leverage this new facility to > configure the uid/gid of the sendmail program to that of the smtpq user, > like this: > > (operating-system) > [...] > (setuid-programs (cons (list (file-append sendmail "/usr/sbin/sendmail"= ) "smtpq") > %setuid-programs)) > Aside from that I wonder if specifying user and group in a list is future proof, maybe using a record would be more Guixy. In particular I would like to be able to set capabilities (as with =E2=80=9Csetcap=E2=80=9C= ) on binaries since the store don't support it[1]; if that's even possible but it's an other issue. [0]: https://wiki.wireshark.org/CaptureSetup/CapturePrivileges#Most_UNIXes [1]: https://lists.gnu.org/archive/html/help-guix/2016-11/msg00046.html - Brice