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 ms0.migadu.com with LMTPS id LjJOJLh/EWGcDAAAgWs5BA (envelope-from ) for ; Mon, 09 Aug 2021 21:19:20 +0200 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 GGxXH7h/EWHGRgAAB5/wlQ (envelope-from ) for ; Mon, 09 Aug 2021 19:19:20 +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 B5CC09CC3 for ; Mon, 9 Aug 2021 21:19:19 +0200 (CEST) Received: from localhost ([::1]:60852 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mDAnu-0002md-Pv for larch@yhetil.org; Mon, 09 Aug 2021 15:19:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33788) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mDAnf-0002Ke-UJ for guix-patches@gnu.org; Mon, 09 Aug 2021 15:19:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:46304) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mDAnf-0000Sn-O7 for guix-patches@gnu.org; Mon, 09 Aug 2021 15:19:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mDAnf-0004XF-Jf for guix-patches@gnu.org; Mon, 09 Aug 2021 15:19:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49969] [PATCH 5/7] gnu: desktop: Add seatd-service-type Resent-From: muradm Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 09 Aug 2021 19:19:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49969 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 49969@debbugs.gnu.org Cc: muradm Received: via spool by 49969-submit@debbugs.gnu.org id=B49969.162853671317355 (code B ref 49969); Mon, 09 Aug 2021 19:19:03 +0000 Received: (at 49969) by debbugs.gnu.org; 9 Aug 2021 19:18:33 +0000 Received: from localhost ([127.0.0.1]:57842 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mDAn7-0004Vc-As for submit@debbugs.gnu.org; Mon, 09 Aug 2021 15:18:33 -0400 Received: from mail-ed1-f41.google.com ([209.85.208.41]:40514) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mDAn3-0004UY-ND for 49969@debbugs.gnu.org; Mon, 09 Aug 2021 15:18:26 -0400 Received: by mail-ed1-f41.google.com with SMTP id d6so26218167edt.7 for <49969@debbugs.gnu.org>; Mon, 09 Aug 2021 12:18:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=muradm-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/hDC3pxVXCM1gKMDEgcDzWDP1KxzgPUo45H2sFPeld4=; b=pIi8zMKTXub6yjxozBwIPWH72IxynXP9B29UPqUyy4gkHrimDecFIHaHe4qA7gX8r6 NyvE8aFV+EXJFEKrhbPnnY4jPTQhwCcxS7YbTFNdI2pPgbvf9FQXSmtE6TXTY6p1P7SU wubUdIfsIi6YSGWd9sT12FU8OTeoioYwIsBR1wPR+o8jbYNH7GoiFMsbKwTz7hMDF/9Z hS93W8uAScrXgc8QW5Q7kaPz/PWxTypV9BPOSYzyIpoMEVD02tXfPF4IgOCAn543cM1Z sRlCTdjUOjfrTd3hGqOockTMAvqFzcYNPbxvsE3eG4L3ApSZTClfyDQYvqeFzapitQd4 3hpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/hDC3pxVXCM1gKMDEgcDzWDP1KxzgPUo45H2sFPeld4=; b=ePwRgd5IQL9BayJP4NjXfFmgmdk9YLYHxM8c8LdSQ7WoxWf3uZ91SfropkOcG/wLZ6 tdjJ1FFzz2ocwRxAmYwmZIgB7y7TI4P8TLcgSks6jA1GaE4Hj0KHRDN7Z50PGBPG3vB/ R/P7jj7Zn3KuPdUJYaqqa0fiZJRPdppNdliKUigrmpbtsC2jMhpJB7ZQ0eQ4QchdiuSN A5rEK27+Ln77hKZrIbfpLnnUq4je/oIrPvkIxXeNN3SbCBmcns+I+T6v9S/x3zDJfN3C AjY8pvoMYRg0aSCOLxPJ5MX2WZ1fS9b3RaosdMRMEbRsXNgnzGIVRW21cYiKOMgSnXTw 5OjQ== X-Gm-Message-State: AOAM531tYvehWSfbmZ1w5R36mv3wgm8r30JOt+iaJaS0+YoZ1prUG0eH 8dz3pCYi3OR1btKyso2TCem7H5s+Ff82tw== X-Google-Smtp-Source: ABdhPJwcjF997nBvVfvp0vblaCO0S4iUhZWw55Bll2a/nHiFXB9pfN9G0EU6JnGZb17AD86bFwizyA== X-Received: by 2002:aa7:d757:: with SMTP id a23mr31743903eds.29.1628536699785; Mon, 09 Aug 2021 12:18:19 -0700 (PDT) Received: from localhost.localdomain ([31.142.122.131]) by smtp.gmail.com with ESMTPSA id gv7sm6167100ejc.5.2021.08.09.12.18.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Aug 2021 12:18:19 -0700 (PDT) From: muradm Date: Mon, 9 Aug 2021 22:18:01 +0300 Message-Id: <20210809191803.7833-5-mail@muradm.net> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210809190257.7280-1-mail@muradm.net> References: <20210809190257.7280-1-mail@muradm.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1628536759; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=jSUxKvawlD2NXs9n6UAgyFf4/HohE4WlQa+zIi1YLMg=; b=DJXaLcL8sVQFqQ+aHDMbzI+a8ECSPufG/vafcKdPqzxaxRC6qt+THVQTwc1sfSebYXHdxb deY3lDfpoh24YFau+Ut77KJ6DXiL5tl4hvpcgnYCcUxUNazROi45rZTiXHH9lWz7KCy9JT lH17BuAlYWTZRNzESBeikiPb8OA0v/MNUN48U1OLg/mJiWVUrke+600fp7fHM5MPIxVGhQ LM2MzX7Xt3083jTodQQhNSuOjyBmySKrrQQMqE3KJifnMlO0MRX3lvChr64OdfKO4zqa+/ FWCWfmmPYuFazyymfarCFetc4EAZqMwHxQ6VGnzTjloDWSorIrc/KP1Sy7oKtw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1628536759; a=rsa-sha256; cv=none; b=EG7t/JU7vegRaMhIAi5UUhQRJXl5bP0TVdKObRICEclEZrlzelSCnbNJ2KebvKgaOMQErg yJ2ihVWtw2sWftHcuLwLQ5+Hm4WedOAlaBGvCz92AkPplfLzDKzSndinF1SdAQgIiy/frb UaU8So/rrBrqYjhT8CwPSH/E2n+e7gz0mOvAyk5e3XBw24FHzt6GBb60Qfb5wKE7lExrqu JWiwJY2r+Vea+LmRobHRkFdxQ+zJIcwoptEnWAjw+09phTIPZFAaAk8YkzQWL6tAzAAgca N2x0XRGx4BUL567Gtu5Y4SyRlZPmmjR2ifgnnmDjoHi0qxIRAg43y+E7cJCoMA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=muradm-net.20150623.gappssmtp.com header.s=20150623 header.b=pIi8zMKT; 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-Migadu-Spam-Score: -0.41 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=muradm-net.20150623.gappssmtp.com header.s=20150623 header.b=pIi8zMKT; 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-Migadu-Queue-Id: B5CC09CC3 X-Spam-Score: -0.41 X-Migadu-Scanner: scn1.migadu.com X-TUID: hDTODh9mRaXP A seat management daemon, that does everything it needs to do. Nothing more, nothing less. Depends only on libc. * gnu/services/desktop.scm: Add seatd-service-type --- gnu/services/desktop.scm | 117 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 116 insertions(+), 1 deletion(-) diff --git a/gnu/services/desktop.scm b/gnu/services/desktop.scm index 64d0e85301..cc13859532 100644 --- a/gnu/services/desktop.scm +++ b/gnu/services/desktop.scm @@ -13,6 +13,7 @@ ;;; Copyright © 2020 Tobias Geerinckx-Rice ;;; Copyright © 2020 Reza Alizadeh Majd ;;; Copyright © 2021 Brice Waegeneire +;;; Copyright © 2021 muradm ;;; ;;; This file is part of GNU Guix. ;;; @@ -39,7 +40,9 @@ #:use-module (gnu services networking) #:use-module (gnu services sound) #:use-module ((gnu system file-systems) - #:select (%elogind-file-systems file-system)) + #:select (%elogind-file-systems + %control-groups + file-system)) #:use-module (gnu system) #:use-module (gnu system setuid) #:use-module (gnu system shadow) @@ -154,6 +157,9 @@ gnome-keyring-configuration? gnome-keyring-service-type + seatd-configuration + seatd-service-type + %desktop-services)) ;;; Commentary: @@ -1182,6 +1188,115 @@ or setting its password with passwd."))) (define polkit-wheel-service (simple-service 'polkit-wheel polkit-service-type (list polkit-wheel))) + +;;; +;;; seatd-service-type -- Seat management daemon +;;; + +;; TODO: separate service-type is needed for cgroups +(define %seatd-file-systems + (append + (list (file-system + (device "none") + (mount-point "/run/seatd/pam_mount") + (type "tmpfs") + (check? #f) + (flags '(no-suid no-dev no-exec)) + (options "mode=0755") + (create-mount-point? #t))) + %control-groups)) + +(define %seatd-pam-mount-rules + `((debug (@ (enable "0"))) + (volume (@ (sgrp "users") + (fstype "tmpfs") + (mountpoint "/run/user/%(USERUID)") + (options "noexec,nosuid,nodev,size=1g,mode=0700,uid=%(USERUID),gid=%(USERGID)"))) + (logout (@ (wait "0") + (hup "0") + (term "yes") + (kill "no"))) + (mkmountpoint (@ (enable "1") (remove "true"))))) + +(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")) + (socket seatd-socket (default "/run/seatd.sock"))) + +(define (make-seatd-pam-mount-configuration-file config) + (computed-file + "seatd_pam_mount.conf.xml" + #~(begin + (use-modules (sxml simple)) + (call-with-output-file #$output + (lambda (port) + (sxml->xml + '(*TOP* + (*PI* xml "version='1.0' encoding='utf-8'") + (pam_mount + #$@%seatd-pam-mount-rules + (pmvarrun + #$(file-append seatd-pam-mount + "/sbin/pmvarrun -u '%(USER)' -o '%(OPERATION)'")))) + port)))))) + +(define (seatd-pam-mount-etc-service config) + `(("security/seatd_pam_mount.conf.xml" + ,(make-seatd-pam-mount-configuration-file config)))) + +(define (seatd-pam-mount-pam-service config) + (define optional-pam-mount + (pam-entry + (control "optional") + (module #~(string-append #$seatd-pam-mount "/lib/security/pam_mount.so")))) + (list (lambda (pam) + (if (member (pam-service-name pam) + '("login" "su" "slim" "gdm-password")) + (pam-service + (inherit pam) + (auth (append (pam-service-auth pam) + (list optional-pam-mount))) + (session (append (pam-service-session pam) + (list optional-pam-mount)))) + pam)))) + +(define (seatd-shepherd-service config) + (list (shepherd-service + (requirement '()) + ;; TODO: once cgroups is separate dependency + ;; here we should depend on it rather than elogind + (provision '(seatd elogind)) + (start #~(make-forkexec-constructor + (list #$(file-append (seatd-package config) "/bin/seatd") + "-u" #$(seatd-user config) + "-g" #$(seatd-group config) + "-s" #$(seatd-socket config)))) + (stop #~(make-kill-destructor))))) + +(define seatd-environment + (match-lambda + (($ _ _ _ socket) + `(("SEATD_SOCK" . ,socket))))) + +(define seatd-service-type + (service-type (name 'seatd) + (extensions + (list + (service-extension session-environment-service-type + seatd-environment) + (service-extension file-system-service-type + (const %seatd-file-systems)) + (service-extension etc-service-type + seatd-pam-mount-etc-service) + (service-extension pam-root-service-type + seatd-pam-mount-pam-service) + (service-extension shepherd-root-service-type + seatd-shepherd-service))) + (default-value (seatd-configuration)))) + ;;; ;;; The default set of desktop services. -- 2.32.0