From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 4LXeNRPHImE39AAAgWs5BA (envelope-from ) for ; Sun, 22 Aug 2021 23:52:19 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id mP1vMRPHImHqJAAAB5/wlQ (envelope-from ) for ; Sun, 22 Aug 2021 21:52:19 +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 E700F1BB7E for ; Sun, 22 Aug 2021 23:52:18 +0200 (CEST) Received: from localhost ([::1]:49770 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mHvO5-0007yn-T3 for larch@yhetil.org; Sun, 22 Aug 2021 17:52:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54966) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mHvNs-0007ub-ON for guix-patches@gnu.org; Sun, 22 Aug 2021 17:52:06 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:56633) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mHvNs-0002x8-Gr for guix-patches@gnu.org; Sun, 22 Aug 2021 17:52:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mHvNs-0007eA-FO for guix-patches@gnu.org; Sun, 22 Aug 2021 17:52:04 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49969] [PATCH v5 06/10] gnu: desktop: Add greetd-service-type Resent-From: muradm Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 22 Aug 2021 21:52:04 +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 Received: via spool by 49969-submit@debbugs.gnu.org id=B49969.162966907929271 (code B ref 49969); Sun, 22 Aug 2021 21:52:04 +0000 Received: (at 49969) by debbugs.gnu.org; 22 Aug 2021 21:51:19 +0000 Received: from localhost ([127.0.0.1]:39932 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mHvN9-0007by-6b for submit@debbugs.gnu.org; Sun, 22 Aug 2021 17:51:19 -0400 Received: from mail-ed1-f50.google.com ([209.85.208.50]:46648) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mHvN1-0007aD-IO for 49969@debbugs.gnu.org; Sun, 22 Aug 2021 17:51:12 -0400 Received: by mail-ed1-f50.google.com with SMTP id r19so23084988eds.13 for <49969@debbugs.gnu.org>; Sun, 22 Aug 2021 14:51:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=muradm-net.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=4RvNuH2f0DUKJXveSm9L/j8vYPWQ0l8XsRGzPRTkteY=; b=lZiUMqXMPb2z+nuJxH8NQyAKawrW3DLiC7RNEjw8mmrlsyv18SK27mtP6H8HrYuYe0 Zqbdp6GoUwL+2Ln05iIzLIWFdtSXqC8aTkZ3fcK7q+IzmqFSD9yLYIvtOqSrTpuy80oc kzbOXqm6Q11JO7vjWmlKdV4MEHQEoYXXWqSliplVjpVktl27EdDuo95pUndMHM6PQ6zG B6yigbCxPLvj/ngsihhLShEYqDPVjnQLQQ5N1BNQ/ApLn8f6+QKD5ksLkSmFr2MZD3T9 pHADxl5b2EaDwnKCQJjmFYUBGZckc9nEzFu2rJRDXFljLHID8HlQO+LRYai5MYibQVzl mC+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4RvNuH2f0DUKJXveSm9L/j8vYPWQ0l8XsRGzPRTkteY=; b=lCboV54tV+2Z1j3Hgqkgh1ja79oHGHJdzVLi1fBNn+ekZAS9v/e2SgN/MfPMSjCWrp WKdgefjS7k9N7Fav0+vVKmz/Rf3i1l5VhU6jYTiRiQnphZpDmjp2m/6vmDe6bPS72RSB Gtyqb+bWspejI9JPWxwfFGGHdxLvaDN3L3OeMTTPmsGlOpLnfecP7O2Jf1NQOXkzA1Ma +K5fGUIIMBeC41uE0VZOM4XpqjMQuBoUhC/fOQh6XlCZcjgcPbohHGqKZrr/iIYHVuxH eXlHBpNJk54TXrGzTb75ZFIizX6h3/iC3yGo5oX0rgGEVYl1VpUu4sLSJ7DKNxF8IwP3 LWSA== X-Gm-Message-State: AOAM531YA2cqS1/nt/ZIs7YKUtuk3cqs9ltLQabr/mEIFci9xi28aDEx UP7SR9DUwyVcA8BBAZQjqNHzDhC5pg6Udg== X-Google-Smtp-Source: ABdhPJxczoEOPfK/1GaKnP8k0jYd7KDHFtw4a/uDHFyozJlEGWNlzCzSk98DsFKFtnlrgnbREw+QAg== X-Received: by 2002:a05:6402:1601:: with SMTP id f1mr33874946edv.388.1629669065514; Sun, 22 Aug 2021 14:51:05 -0700 (PDT) Received: from localhost.localdomain ([31.142.76.217]) by smtp.gmail.com with ESMTPSA id q5sm7959755edt.50.2021.08.22.14.51.04 for <49969@debbugs.gnu.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Aug 2021 14:51:05 -0700 (PDT) From: muradm Date: Mon, 23 Aug 2021 00:50:44 +0300 Message-Id: <20210822215048.20480-7-mail@muradm.net> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210822215048.20480-1-mail@muradm.net> References: <20210819143133.6398-1-mail@muradm.net> <20210822215048.20480-1-mail@muradm.net> MIME-Version: 1.0 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=1629669139; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: 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=VFr/dR6MrzSDpuwrNZlm0eZRhLDENHsCiM2lZNPsaNQ=; b=ZLOvm4l801Nxb5LZNGR+ii9G5UKBzqRgsMkW6h3NivkIjdeNHYOt4jB+eeBLvF8if1Kjkb ryeA17538yex95r4eltUXCC7ghBSe4Q8dBIVdimR6yvmbkt/3tCMjUxEHX8635WGpJ76+Z QjKW07oPPbDKB4QfBCBoPD6fdjehGC24bffvmKLhXH5vWPyDeJQtCTeElmot60Pti0s00G N+XUwSa2NoE+0WDnkodxa1VPv9VwbHLgk7DF4PpiUQc0430z63rsf7Y7QTJzPEZiFmIg6n d5rkhcgN6s5vjp1ZKMXK+t0uNSj1AWm9QaGzdOC3UByKR6D3+nY/x5g/MNzPiw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1629669139; a=rsa-sha256; cv=none; b=MnhOt7XJOpjMbQy0n+w3DwlcrtLbPDqOqIeh+7+GWTicv89N1Yl95CnZZZUj2fd4NK/wQO hN9fvWCLVI7q1iEfyVyAXR3t2EEi0+twxGuWBIrExjnTZI8MrXJxvX9J0nN+LsU1l+0o+n P6DDUh2ulna2M2DgZlz0k79SSvPN77KRVjuurbWvUeA5M65ZRJfsbzwpQ4YrbGvVjnYevr lPLMCRMjQajlFvx2FOCpgpcuQamS31QNGro2c53s0sc59d823hZyOLUFsIKNAN36IsX1kC wX7RhasQFUjeBmj2CkS06nYp7/KcrNj6+wNI5FFKIhgvWJO06fl55HPqFnrxaQ== 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=lZiUMqXM; 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: 3.57 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=muradm-net.20150623.gappssmtp.com header.s=20150623 header.b=lZiUMqXM; 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: E700F1BB7E X-Spam-Score: 3.57 X-Migadu-Scanner: scn0.migadu.com X-TUID: Fgkyz3G5qYQb Currently, only agreety configuration is provided. * gnu/services/desktop.scm: Add greetd-service-type --- gnu/services/desktop.scm | 229 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 229 insertions(+) diff --git a/gnu/services/desktop.scm b/gnu/services/desktop.scm index c42db5987e..1f4838d4d8 100644 --- a/gnu/services/desktop.scm +++ b/gnu/services/desktop.scm @@ -49,6 +49,7 @@ #:use-module (gnu system pam) #:use-module (gnu packages glib) #:use-module (gnu packages admin) + #:use-module (gnu packages bash) #:use-module (gnu packages cups) #:use-module (gnu packages freedesktop) #:use-module (gnu packages gnome) @@ -160,6 +161,12 @@ seatd-configuration seatd-service-type + greetd-configuration + greetd-terminal-configuration + greetd-service-type + greetd-agreety-tty-session + greetd-agreety-tty-xdg-session + %desktop-services)) ;;; Commentary: @@ -1240,6 +1247,228 @@ applications needing access to be root.") (service-extension shepherd-root-service-type seatd-shepherd-service))) (default-value (seatd-configuration)))) + +;;; +;;; greetd-service-type -- minimal and flexible login manager daemon +;;; + +(define-record-type* + greetd-agreety-session make-greetd-agreety-session + greetd-agreety-session? + (package greetd-agreety-command-package (default bash)) + (command-bin greetd-agreety-command-bin (default "/bin/bash")) + (command-args greetd-agreety-command-args (default '("-l"))) + (extra-env greetd-agreety-extra-env (default '())) + (command-generator greetd-agreety-command-generator)) + +(define greetd-agreety-tty-session-command + (match-lambda + (($ pkg command-bin command-args extra-env) + (program-file + "agreety-tty-session-command" + #~(begin + (use-modules (ice-9 match)) + (let* ((abs-cmd-bin #$(file-append pkg command-bin))) + (for-each + (match-lambda ((var . val) (setenv var val))) + (quote (#$@extra-env))) + (apply execl abs-cmd-bin abs-cmd-bin + (list #$@command-args)))))))) + +(define greetd-agreety-tty-xdg-session-command + (match-lambda + (($ package command-bin command-args extra-env) + (program-file + "agreety-tty-xdg-session-command" + #~(begin + (use-modules (ice-9 match)) + (let* + ((username (getenv "USER")) + (useruid (passwd:uid (getpwuid username))) + (useruid (number->string useruid)) + (abs-cmd-bin #$(file-append package command-bin))) + (setenv "XDG_SESSION_TYPE" "tty") + (setenv "XDG_RUNTIME_DIR" (string-append "/run/user/" useruid)) + (for-each + (match-lambda ((var . val) (setenv var val))) + (quote (#$@extra-env))) + (apply execl abs-cmd-bin abs-cmd-bin + (list #$@command-args)))))))) + +(define greetd-agreety-tty-session + (greetd-agreety-session + (command-generator greetd-agreety-tty-session-command))) + +(define greetd-agreety-tty-xdg-session + (greetd-agreety-session + (command-generator greetd-agreety-tty-xdg-session-command))) + +(define-record-type* + greetd-terminal-configuration make-greetd-terminal-configuration + greetd-terminal-configuration? + (greetd greetd-package (default greetd-next)) + (config-file-name greetd-config-file-name (thunked) + (default (default-config-file-name this-record))) + (terminal-vt greetd-terminal-vt (default "7")) + (terminal-switch greetd-terminal-switch (default #f)) + (default-session-user greetd-default-session-user (default "greeter")) + (default-session-command greetd-default-session-command + (default greetd-agreety-tty-xdg-session))) + +(define (default-config-file-name config) + (string-join (list "config-" (greetd-terminal-vt config) ".toml") "")) + +(define make-greetd-terminal-default-session-command + (match-lambda + (($ greetd _ _ _ _ default-session-command) + (cond ((greetd-agreety-session? default-session-command) + (let* + ((generator (greetd-agreety-command-generator + default-session-command)) + (command (apply generator (list default-session-command))) + (agreety-bin (file-append greetd "/bin/agreety"))) + (program-file + "agreety-command" + #~(execl #$agreety-bin #$agreety-bin "-c" #$command)))) + (else (program-file "agreety-command-exit" #~(exit #f))))))) + +(define (make-greetd-terminal-configuration-file config) + (let* + ((config-file-name (greetd-config-file-name config)) + (terminal-vt (greetd-terminal-vt config)) + (terminal-switch (greetd-terminal-switch config)) + (default-session-user (greetd-default-session-user config)) + (default-session-command (make-greetd-terminal-default-session-command config))) + (mixed-text-file + config-file-name + "[terminal]\n" + "vt = " terminal-vt "\n" + "switch = " (if terminal-switch "true" "false") "\n" + "[default_session]\n" + "user = " default-session-user "\n" + "command = " default-session-command "\n"))) + +(define %default-motd + (plain-file "motd" "This is the GNU operating system, welcome!\n\n")) + +(define %greetd-accounts + (list (user-account + (name "greeter") + (group "wheel") + (supplementary-groups '("users" "tty" "input" "video" "audio")) + (system? #t)))) + +(define %greetd-file-systems + (list (file-system + (device "none") + (mount-point "/run/greetd/pam_mount") + (type "tmpfs") + (check? #f) + (flags '(no-suid no-dev no-exec)) + (options "mode=0755") + (create-mount-point? #t)))) + +(define %greetd-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* + greetd-configuration make-greetd-configuration + greetd-configuration? + (motd greetd-motd (default %default-motd)) + (allow-empty-passwords? greetd-allow-empty-passwords? (default #t)) + (terminals greetd-terminals (default '()))) + +(define (make-greetd-pam-mount-conf-file config) + (computed-file + "greetd_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 + #$@%greetd-pam-mount-rules + (pmvarrun + #$(file-append greetd-pam-mount + "/sbin/pmvarrun -u '%(USER)' -o '%(OPERATION)'")))) + port)))))) + +(define (greetd-etc-service config) + `(("security/greetd_pam_mount.conf.xml" + ,(make-greetd-pam-mount-conf-file config)))) + +(define (greetd-pam-service config) + (define optional-pam-mount + (pam-entry + (control "optional") + (module #~(string-append #$greetd-pam-mount "/lib/security/pam_mount.so")) + (arguments '("disable_interactive")))) + + (list + (unix-pam-service "greetd" + #:login-uid? #t + #:allow-empty-passwords? + (greetd-allow-empty-passwords? config) + #:motd + (greetd-motd config)) + (lambda (pam) + (if (member (pam-service-name pam) + '("login" "greetd" "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 (greetd-shepherd-services config) + (map + (lambda (tc) + (let* + ((greetd-bin (file-append (greetd-package tc) "/sbin/greetd")) + (greetd-conf (make-greetd-terminal-configuration-file tc)) + (greetd-vt (greetd-terminal-vt tc))) + (shepherd-service + (documentation "Minimal and flexible login manager daemon") + (requirement '(user-processes host-name udev virtual-terminal)) + (provision (list (symbol-append + 'term-tty + (string->symbol (greetd-terminal-vt tc))))) + (start #~(make-forkexec-constructor + (list #$greetd-bin "-c" #$greetd-conf) + #:log-file + (string-append "/tmp/greetd." #$greetd-vt ".log"))) + (stop #~(make-kill-destructor))))) + (greetd-terminals config))) + +(define greetd-service-type + (service-type + (name 'greetd) + (description "Provides necessary infrastructure for logging into the +system including @code{greetd} PAM service, @code{pam-mount} module to +mount/unmount /run/user/ directory for user and @code{greetd} +login manager daemon.") + (extensions + (list + (service-extension account-service-type (const %greetd-accounts)) + (service-extension file-system-service-type (const %greetd-file-systems)) + (service-extension etc-service-type greetd-etc-service) + (service-extension pam-root-service-type greetd-pam-service) + (service-extension shepherd-root-service-type greetd-shepherd-services))) + (default-value (greetd-configuration)))) + ;;; ;;; The default set of desktop services. -- 2.32.0