From patchwork Mon Aug 22 20:17:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: muradm X-Patchwork-Id: 41873 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 4A4F627BBEA; Mon, 22 Aug 2022 21:21:16 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 551D727BBE9 for ; Mon, 22 Aug 2022 21:21:15 +0100 (BST) Received: from localhost ([::1]:52244 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQDv8-0005G4-Er for patchwork@mira.cbaines.net; Mon, 22 Aug 2022 16:21:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44454) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQDuw-0005Fm-OZ for guix-patches@gnu.org; Mon, 22 Aug 2022 16:21:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:52125) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oQDuw-0003QY-GH for guix-patches@gnu.org; Mon, 22 Aug 2022 16:21:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oQDuw-0003Qw-1L for guix-patches@gnu.org; Mon, 22 Aug 2022 16:21:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#56690] [PATCH] gnu: seatd-service-type: Should use seat group. Resent-From: muradm Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 22 Aug 2022 20:21:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 56690 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Liliana Marie Prikler Cc: ludo@gnu.org, 56690@debbugs.gnu.org X-Debbugs-Original-Cc: Ludovic =?utf-8?q?Court=C3=A8s?= , 56690@debbugs.gnu.org, guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.166119961113092 (code B ref -1); Mon, 22 Aug 2022 20:21:01 +0000 Received: (at submit) by debbugs.gnu.org; 22 Aug 2022 20:20:11 +0000 Received: from localhost ([127.0.0.1]:41872 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oQDu6-0003Oy-AA for submit@debbugs.gnu.org; Mon, 22 Aug 2022 16:20:11 -0400 Received: from lists.gnu.org ([209.51.188.17]:33110) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oQDu1-0003Om-7j for submit@debbugs.gnu.org; Mon, 22 Aug 2022 16:20:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55396) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQDu0-00057Z-Tj for guix-patches@gnu.org; Mon, 22 Aug 2022 16:20:05 -0400 Received: from nomad-cl1.staging.muradm.net ([139.162.159.157]:49936 helo=nomad-cl1.muradm.net) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQDty-00030q-EU; Mon, 22 Aug 2022 16:20:04 -0400 Received: from localhost ([127.0.0.1]:58728) by nomad-cl1.muradm.net with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1oQDt5-0006Vx-1w; Mon, 22 Aug 2022 20:19:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=muradm.net; s=mail; h=Content-Type:MIME-Version:Message-ID:In-reply-to:Date:Subject:Cc:To :From:References:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=BuQsE5ohl2zPihK2U5/vfzw03hb8vWW2FxJS2iiQ7us=; b=DJS6V5QNKvI6UtVFZ3zmLXLPLC aGzxyhF/nmE6+Wv39S/82tKP0WUeQPMXYecRkMiMczDWqX23QcgodZsmyse+uSQn/JAglFOc2AoZx WOYNc+nFfTJTyYqOYtA08oefANP9WdnRmv/CaFAC2oj82gUbKIWiQUyvkrp1/HZ3jM3AKddfjGVou CF3cVrrJ0zf8IrOqK/7OnWPwCtfzlnEDE6atZYRcJzUV/h6mWlx5B02Qde3V4wwKGO0+1hlnmZfRL bDOBm45s9LD+pq1CsUY15fGmdyhhbkgv/A/XykhMUc0n5KzI9wsJEy/KMJxYnD4UrVKVLCDdBh8ra 3U0WxGKyFsrynVV+NZxPP+Lx/N8+9zteizodA6N2SsTTWECwHkDGsFLizSmHXUrmrEm0a8Ke2GsEy Y7cqzTk4d+YxF4LkmnV2br3wTxMyMxbIxoAkYL7LHc/+6lm1vFNgSTDKXWcK+iwryDZ4LLL4HguDT gMKIZZ+2sjpqHgE6TQ3lk8MP; Received: from muradm by localhost with local (Exim 4.96) (envelope-from ) id 1oQDts-0002mM-1R; Mon, 22 Aug 2022 23:19:56 +0300 References: <20220722042745.26745-1-mail@muradm.net> <87czdddrra.fsf@gnu.org> <87les00x51.fsf@muradm.net> <87h72n24ra.fsf@muradm.net> <55a3a3bf118f364b70cbd74d214998955d81eaa9.camel@ist.tugraz.at> <87mtcezhty.fsf@muradm.net> <063eee23b1ff1b0f288d5e465aa5bac1862c9bb8.camel@ist.tugraz.at> <87y1vxxjrt.fsf@muradm.net> User-agent: mu4e 1.8.7; emacs 29.0.50 From: muradm Date: Mon, 22 Aug 2022 23:17:59 +0300 In-reply-to: Message-ID: <8735doyqs4.fsf@muradm.net> MIME-Version: 1.0 Received-SPF: pass client-ip=139.162.159.157; envelope-from=mail@muradm.net; helo=nomad-cl1.muradm.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches Now accepts either string or user-group as group. Liliana Marie Prikler writes: > Am Dienstag, dem 09.08.2022 um 22:47 +0300 schrieb muradm: >> There is no such specification as login manager or what ever. >> User >> is any one/thing acquiring resources via seat management. It is >> perfectly fine to run mingetty, login into bash and from >> command line >> start sway that will use libseat to acquire video for instance. >> Who is >> user here? >> >> There is also no display manager as it was before. Please see >> my >> explanation to unmatched-paren: >> https://debbugs.gnu.org/cgi/bugreport.cgi?msg=46;bug=56690 >> What is sway in this usecase, it is not a user (like you or >> me), >> it is not a display manager (as gdm, sddm etc.). It is just >> application requiring video card (not only) resource, which >> it instead of having exclusive root access, uses libseat to >> acquire it in "seat managy" way. And greetd does/should not >> care about seatd/libseat until it is not required to acquire >> resources in "seat managy" way. Instead it is a greeter which >> is totatly customizable, could be even a bash script or small >> suckless-like application or else. >> >> This is the point of seatd I suppose, to do one thing only >> without enforcing on who should do what. >> >> Thus, none of your proposals are suitable, and I can't come up >> with something better than "seat management user" or "libseat >> user". However in my opinion, the one who commits into such >> setup, should be aware of what is seatd libseat and how, why to >> interact with it. > I think you're mixing user and application here, which makes > explaining > this to others difficult. For instance, GDM is both an > application > (display manager) and a user launching this application. > Likewise for > most other display managers. Thus, there is a 1:1 mapping > between > users and applications. > > With seatd, from what I understand, there is no such mapping. > However, > given your description, the following is unclear: Does alice > need to be > in the seat group to run bash? To run sway? To run sway *only > if not > having talked to greetd first*? > >> > > > > +  (group seatd-group (default "seat")) >> > > > > +  (existing-group? seatd-existing-group? (default #f)) >> > > > AFAIK this is not necessary.  accounts-service-type can >> > > > handle >> > > > multiple eq? groups, so as long as you're careful with >> > > > what >> > > > you put >> > > > into group, you shouldn't get an error. >> > > ok field removed >> > Note ‘eq?’ groups here.  In other words, you should be able >> > to >> > take a >> > group (not just a group name) for the group field, sanitize >> > the >> > field >> > so that it will always be a group, and then use that group in >> > seatd- >> > accounts (see the second option mentioned in >> > <79341a82bf9cd5fc6c2227255095f3fe2927dcbe.camel@ist.tugraz.at>). >> > If >> > for instance instead of seat, you wanted the video group, you >> > would >> > have to take the one from %base-groups, rather than creating >> > a >> > new one. >> Sorry, but I'm not so proficient in english as you. I can only >> speculate on what is written here. And that reference does not >> say anything to me, even duck duck go gives single result, it >> is >> your message. Could you please be more specific here, and/or >> provide more useful hyperlink style references. Thanks in >> advance. > I'll explain it in terms of lisp: > > (define seat1 (user-group (name "seat") (system #t)) > (define seat2 (user-group (name "seat") (system #t)) > (operating-system (groups (list seat1 seat1))) ; works, eq? > (operating-system (groups (list seat2 seat2))) ; works, eq? > (operating-system (groups (list seat1 seat2))) ; doesn't work > > For field sanitizers, see define-record-type*. > > Cheers From ad9323d5b3f774ee479cf16f41753dbbe2f90ff4 Mon Sep 17 00:00:00 2001 From: muradm Date: Fri, 22 Jul 2022 07:09:54 +0300 Subject: [PATCH v4] gnu: seatd-service-type: Should use seat group. To: 56690@debbugs.gnu.org * gnu/services/desktop.scm (seatd-service-type): Uses "seat" group. [extensions]: Added account-service-type with seatd-accounts. (seatd-accounts): Conditionally produces list with "seat" group. (): [user] Removed user field, since it is not going to be used. [group] Change default value to "seat" user-group. * doc/guix.texi: Mention that users may need to become members of "seat" group and update default value for group field. Add explanation on seatd.sock file. Remove dropped user field. --- doc/guix.texi | 29 +++++++++++++++++++++++++---- gnu/services/desktop.scm | 25 +++++++++++++++++++------ gnu/tests/desktop.scm | 9 +++++++++ 3 files changed, 53 insertions(+), 10 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 023b48ae35..40c6e66439 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -23189,6 +23189,30 @@ input), without requiring the applications needing access to be root. %base-services) @end lisp + +@code{seatd} operates over a UNIX domain socket, with @code{libseat} +providing the client-side of the protocol. Then applications dealing +with seat management (e.g. @code{sway}) connects to @code{seatd} via +mentioned socket. + +When seat management is provided by @code{seatd}, @code{libseat} users +that acquire resources provided by @code{seatd} should have permissions +to access its UNIX domain socket. By default, @code{seatd-service-type} +provides ``seat'' group. And @code{libseat} user should become its +member. + +@lisp +(user-account + (name "alice") + (group "users") + (supplementary-groups '("wheel" ;allow use of sudo, etc. + "seat" ;interact with seatd + "audio" ;sound card + "video" ;video devices such as webcams + "cdrom")) ;the good ol' CD-ROM + (comment "Bob's sister")) +@end lisp + @end defvr @deftp {Data Type} seatd-configuration @@ -23198,10 +23222,7 @@ Configuration record for the seatd daemon service. @item @code{seatd} (default: @code{seatd}) The seatd package to use. -@item @code{user} (default: @samp{"root"}) -User to own the seatd socket. - -@item @code{group} (default: @samp{"users"}) +@item @code{group} (default: @samp{"seat"}) Group to own the seatd socket. @item @code{socket} (default: @samp{"/run/seatd.sock"}) diff --git a/gnu/services/desktop.scm b/gnu/services/desktop.scm index f891d1b5cc..2e7b751c1a 100644 --- a/gnu/services/desktop.scm +++ b/gnu/services/desktop.scm @@ -13,7 +13,7 @@ ;;; Copyright © 2020 Tobias Geerinckx-Rice ;;; Copyright © 2020 Reza Alizadeh Majd ;;; Copyright © 2021 Brice Waegeneire -;;; Copyright © 2021 muradm +;;; Copyright © 2021, 2022 muradm ;;; ;;; This file is part of GNU Guix. ;;; @@ -69,6 +69,7 @@ (define-module (gnu services desktop) #:use-module (guix records) #:use-module (guix packages) #:use-module (guix store) + #:use-module (guix ui) #:use-module (guix utils) #:use-module (guix gexp) #:use-module (srfi srfi-1) @@ -1643,12 +1644,21 @@ (define polkit-wheel-service ;;; seatd-service-type -- minimal seat management daemon ;;; +(define (seatd-make-group g) + (user-group (name g) (system? #t))) + +(define (seatd-group-sanitizer g) + (cond ((user-group? g) g) + ((string? g) (seatd-make-group g)) + (#t (leave (G_ "seatd: '~a' is not a valid group-%") (object->string g))))) + (define-record-type* seatd-configuration make-seatd-configuration seatd-configuration? (seatd seatd-package (default seatd)) - (user seatd-user (default "root")) - (group seatd-group (default "users")) + (group seatd-group + (default (seatd-make-group "seat")) + (sanitize seatd-group-sanitizer)) (socket seatd-socket (default "/run/seatd.sock")) (logfile seatd-logfile (default "/var/log/seatd.log")) (loglevel seatd-loglevel (default "info"))) @@ -1662,8 +1672,7 @@ (define (seatd-shepherd-service config) (provision '(seatd elogind)) (start #~(make-forkexec-constructor (list #$(file-append (seatd-package config) "/bin/seatd") - "-u" #$(seatd-user config) - "-g" #$(seatd-group config)) + "-g" #$(user-group-name (seatd-group config))) #:environment-variables (list (string-append "SEATD_LOGLEVEL=" #$(seatd-loglevel config)) @@ -1672,9 +1681,12 @@ (define (seatd-shepherd-service config) #:log-file #$(seatd-logfile config))) (stop #~(make-kill-destructor))))) +(define seatd-accounts + (match-lambda (($ _ group) (list group)))) + (define seatd-environment (match-lambda - (($ _ _ _ socket) + (($ _ _ socket) `(("SEATD_SOCK" . ,socket))))) (define seatd-service-type @@ -1685,6 +1697,7 @@ (define seatd-service-type applications needing access to be root.") (extensions (list + (service-extension account-service-type seatd-accounts) (service-extension session-environment-service-type seatd-environment) ;; TODO: once cgroups is separate dependency we should not mount it here ;; for now it is mounted here, because elogind mounts it diff --git a/gnu/tests/desktop.scm b/gnu/tests/desktop.scm index 25971f9225..6fe6ec21be 100644 --- a/gnu/tests/desktop.scm +++ b/gnu/tests/desktop.scm @@ -255,6 +255,15 @@ (define (sock-var-sock var) (socks (map wait-for-unix-socket-m socks))) (and (= 2 (length socks)) (every identity socks))))) + (test-equal "seatd.sock ownership" + '("root" "seat") + `(,(marionette-eval + '(passwd:name (getpwuid (stat:uid (stat "/run/seatd.sock")))) + marionette) + ,(marionette-eval + '(group:name (getgrgid (stat:gid (stat "/run/seatd.sock")))) + marionette))) + (test-assert "greetd is ready" (begin (marionette-type "ps -C greetd -o pid,args --no-headers > ps-greetd\n" -- 2.37.1