From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:306:2d92::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id ODSdHqe/6GSq5gAA9RJhRA:P1 (envelope-from ) for ; Fri, 25 Aug 2023 16:50:15 +0200 Received: from aspmx1.migadu.com ([2001:41d0:306:2d92::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id ODSdHqe/6GSq5gAA9RJhRA (envelope-from ) for ; Fri, 25 Aug 2023 16:50:15 +0200 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 C94773865A for ; Fri, 25 Aug 2023 16:50:14 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=wurtshell.com header.s=mail header.b=jNVJcDZ0; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1692975015; h=from:from:sender:sender:reply-to: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=nFSaqyHbq+v97VW66PeWAQYFPyFecokhIUG03brQWBE=; b=F6qmPpenrJ2EjLW7ImVXDB3EsuKz9c5TnSV4U6getZbQUyl6xvuUC93MKkHt9cXEd8MdH+ QkP5kzLQDt+rni8zrOX62SqkFTxfpdzh9vX+5Z9eVGV446ONN/AEj4j3znbsfffDr2yrkZ aGrUXBt+BPRZ7cnMfzL7cn4Kt0WF/ItPGhEm6MeToH2MAWWheBMdQ1jatcdwg9FuxYOgGf uznkbTcXqbGMCsTSLxLyk+MQVSbERUvzqV9qPDgJQIeZN6xTZ6oj4+xB9UsQWpEhSr0KPZ cB+st+Ww5SmuDNfseyq8berktyagaBoV0BLi8i53asgtZUW5ODojf41P3WSV3Q== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=wurtshell.com header.s=mail header.b=jNVJcDZ0; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Seal: i=1; s=key1; d=yhetil.org; t=1692975015; a=rsa-sha256; cv=none; b=nCERXSt9lI8vSUNecuZrNRcqIfExUhS9lEBivTDrQTBEepuL0PoD2edocgMKPDy0rU5zWr bQ2ojPQGl1fnvJm/GAWlFbJBqEbGBG1eAZ7l5NBIjFAPpgqVkYGIk+G6TzaVlK+zAfNs7Q /xKt7tf0h2AX2riyTS98MLgrAeNkWgC8wElXUzJlVes7OlJuByohld9kakeVxK8Q62Hyfy qcrKCvRaG7E62RvswCSDwzaqXWKYizelNlyiRell41Us1CIjKh72ICtajRDEUeozpuHYgw puxiU8ClmAD7gFN1e/0LsVLiuqZFXHETVgx9oHkuIcrLImfrVXvmXNnKxhILLw== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qZY8O-0006bi-Et; Fri, 25 Aug 2023 10:50:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qZY8M-0006bY-Ac for guix-patches@gnu.org; Fri, 25 Aug 2023 10:49:58 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qZY8M-0000sv-2b for guix-patches@gnu.org; Fri, 25 Aug 2023 10:49:58 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qZY8Q-00067T-GG for guix-patches@gnu.org; Fri, 25 Aug 2023 10:50:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#65538] [PATCH v2] services: greetd: Add pam-gnupg support. Resent-From: Carlos =?UTF-8?Q?Dur=C3=A1n_?= =?UTF-8?Q?Dom=C3=ADnguez?= Original-Sender: "Debbugs-submit" Resent-CC: , guix-patches@gnu.org Resent-Date: Fri, 25 Aug 2023 14:50:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 65538 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 65538@debbugs.gnu.org Cc: Carlos =?UTF-8?Q?Dur=C3=A1n_?= =?UTF-8?Q?Dom=C3=ADnguez?= , ( , Christopher Baines , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Mathieu Othacehe , Raghav Gururajan , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice , jgart X-Debbugs-Original-To: guix-patches@gnu.org X-Debbugs-Original-Xcc: ( , Christopher Baines , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Mathieu Othacehe , Raghav Gururajan , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice , jgart Received: via spool by submit@debbugs.gnu.org id=B.169297495923462 (code B ref -1); Fri, 25 Aug 2023 14:50:02 +0000 Received: (at submit) by debbugs.gnu.org; 25 Aug 2023 14:49:19 +0000 Received: from localhost ([127.0.0.1]:41039 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qZY7i-00066L-D1 for submit@debbugs.gnu.org; Fri, 25 Aug 2023 10:49:19 -0400 Received: from lists.gnu.org ([2001:470:142::17]:47544) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qZY7e-000667-PH for submit@debbugs.gnu.org; Fri, 25 Aug 2023 10:49:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qZY7U-0006WN-OX for guix-patches@gnu.org; Fri, 25 Aug 2023 10:49:04 -0400 Received: from mail.wurtshell.com ([2001:41d0:304:200::95da] helo=wurtshell.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qZY7R-0000pf-Dw for guix-patches@gnu.org; Fri, 25 Aug 2023 10:49:04 -0400 Received: from localhost.localdomain (unknown [IPv6:2a0c:5a80:8003:4600:e206:e6ff:fe9a:ab42]) by wurtshell.com (Postfix) with ESMTPSA id 51DD367173; Fri, 25 Aug 2023 14:48:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wurtshell.com; s=mail; t=1692974936; bh=9D0TlmMB/uWlTC1UsxbcRuyAWXb74PG+HchLl55b6f8=; h=From:To:Cc:Subject:Date:From; b=jNVJcDZ0WORHupiG7VQsuGBTVvJaSLJ/i9DJ3P+D+EWkJGut4AZFIMLIeaBa94OAf 5hCTkjIQSGCbEjYIYfVfYUMRGOgveDilz16I2/N92jcnSVBCtMPPYf4VhYTaoNO6wI M8di8Hxr84TZwgpBN2d7RdHWMNWzTHnNJs5XjfoEkFmgqmL4wrU6ZDA1fXv1kgI6ai 1vnukYcXFUPHJznvdVSJLnjYbv61ZqyyUDRTdYVMHlRM5qvNVGi83P4Vk3vZq/nq38 ithdmieYgokOhpCZy/qrqvrqrOuwutCX1EE7REPyvB3s9XFgJg3job0KAXxaVM1q9t nCxDgBxTOe3Dg== Date: Fri, 25 Aug 2023 16:48:03 +0200 Message-ID: <20230825144806.6315-1-wurt@wurtshell.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2001:41d0:304:200::95da; envelope-from=wurt@wurtshell.com; helo=wurtshell.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: , Reply-to: Carlos =?UTF-8?Q?Dur=C3=A1n_?= =?UTF-8?Q?Dom=C3=ADnguez?= X-ACL-Warn: , =?utf-8?q?Carlos_Dur=C3=A1n_Dom=C3=ADnguez_via_Guix-patches?= From: guix-patches--- via Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Scanner: mx2.migadu.com X-Migadu-Spam-Score: -3.71 X-Spam-Score: -3.71 X-Migadu-Queue-Id: C94773865A X-TUID: T0Qc9rDdZk5F I retry to implement the pam-gnupg module for the greetd system service. It is A PAM module that hands over your login password to gpg-agent. I added de documentation and the insert-before procedure (maybe it needs a better name), to ensure that the pam-gnupg module will be loaded at the end. * doc/guix.texi: documentation about #:gnupg? option on (greetd-configuration). * gnu/services.scm (insert-before): new procedure. * gnu/services/base.scm (greetd-configuration): new option #:gnupg?. * gnu/services/pam-mount.scm: ensure that pam mount module goes before pam gnupg module. * gnu/system/pam.scm (pam-gnupg-module?): new procedure and ensure that pam gnupg module is at the end of (unix-pam-service). --- doc/guix.texi | 9 +++++++++ gnu/services.scm | 11 ++++++++++- gnu/services/base.scm | 28 ++++++++++++++++++---------- gnu/services/pam-mount.scm | 14 +++++++++----- gnu/system/pam.scm | 13 ++++++++++--- 5 files changed, 56 insertions(+), 19 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index e8c67b0cd8..1fe38bd971 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -119,6 +119,7 @@ Copyright @copyright{} 2023 Tanguy Le Carrour@* Copyright @copyright{} 2023 Zheng Junjie@* Copyright @copyright{} 2023 Brian Cully@* Copyright @copyright{} 2023 Felix Lechner@* +Copyright @copyright{} 2023 Carlos Durán Domínguez@* Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or @@ -19666,6 +19667,14 @@ A file-like object containing the ``message of the day''. Allow empty passwords by default so that first-time users can log in when the 'root' account has just been created. +@item @code{gnupg?} (default: @code{#f}) +If enabled, @code{pam-gnupg} will attempt to automatically unlock the +user's GPG keys with the login password via @code{gpg-agent}. The +keygrips of all keys to be unlocked should be written to +@file{~/.pam-gnupg}, and can be queried with @code{gpg -K +--with-keygrip}. Presetting passphrases must be enabled by adding +@code{allow-preset-passphrase} in @file{~/.gnupg/gpg-agent.conf}. + @item @code{terminals} (default: @code{'()}) List of @code{greetd-terminal-configuration} per terminal for which @code{greetd} should be started. diff --git a/gnu/services.scm b/gnu/services.scm index eb9258977e..118b8973ff 100644 --- a/gnu/services.scm +++ b/gnu/services.scm @@ -129,7 +129,8 @@ (define-module (gnu services) %boot-service %activation-service - etc-service) ; deprecated + etc-service ; deprecated + insert-before) #:re-export (;; Note: Re-export 'delete' to allow for proper syntax matching ;; in 'modify-services' forms. See ;; . @@ -1248,4 +1249,12 @@ (define-syntax-rule (for-home exp ...) (syntax-parameterize ((for-home? (identifier-syntax #t))) exp ...)) +(define (insert-before pred lst1 lst2) + "Return a list appending LST2 just before the first element on LST1 that + satisfy the predicate PRED." + (cond + ((null? lst1) lst2) + ((pred (car lst1)) (append lst2 lst1)) + (else (cons (car lst1) (insert-before pred (cdr lst1) lst2))))) + ;;; services.scm ends here. diff --git a/gnu/services/base.scm b/gnu/services/base.scm index b3f2d2e8b8..34aeb4f7d2 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -21,6 +21,7 @@ ;;; Copyright © 2022 Justin Veilleux ;;; Copyright © 2022 ( ;;; Copyright © 2023 Bruno Victal +;;; Copyright © 2023 Carlos Durán Domínguez ;;; ;;; This file is part of GNU Guix. ;;; @@ -3227,6 +3228,7 @@ (define-record-type* greetd-configuration? (motd greetd-motd (default %default-motd)) (allow-empty-passwords? greetd-allow-empty-passwords? (default #t)) + (gnupg? greetd-gnupg? (default #f)) (terminals greetd-terminals (default '())) (greeter-supplementary-groups greetd-greeter-supplementary-groups (default '()))) @@ -3266,25 +3268,31 @@ (define optional-pam-mount (module (file-append greetd-pam-mount "/lib/security/pam_mount.so")) (arguments '("disable_interactive")))) + (define (optional-pam-mount-transformer pam) + (if (member (pam-service-name pam) + '("login" "greetd" "su" "slim" "gdm-password")) + (pam-service + (inherit pam) + ;; SLiM could have pam-gnupg module, and pam-mount must be before it. + (auth (insert-before pam-gnupg-module? + (pam-service-auth pam) + (list optional-pam-mount))) + (session (insert-before pam-gnupg-module? + (pam-service-session pam) + (list optional-pam-mount)))) + pam)) (list (unix-pam-service "greetd" #:login-uid? #t #:allow-empty-passwords? (greetd-allow-empty-passwords? config) + #:gnupg? + (greetd-gnupg? config) #:motd (greetd-motd config)) (pam-extension (transformer - (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)))))) + optional-pam-mount-transformer)))) (define (greetd-shepherd-services config) (map diff --git a/gnu/services/pam-mount.scm b/gnu/services/pam-mount.scm index b3a02e82e9..a7470e1fcb 100644 --- a/gnu/services/pam-mount.scm +++ b/gnu/services/pam-mount.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2019 Guillaume Le Vaillant ;;; Copyright © 2023 Brian Cully +;;; Copyright © 2023 Carlos Durán Domínguez ;;; ;;; This file is part of GNU Guix. ;;; @@ -94,7 +95,8 @@ (define (pam-mount-pam-service config) (define optional-pam-mount (pam-entry (control "optional") - (module (file-append pam-mount "/lib/security/pam_mount.so")))) + (module #~(string-append #$pam-mount "/lib/security/pam_mount.so")))) + (list (pam-extension (transformer @@ -103,10 +105,12 @@ (module (file-append pam-mount "/lib/security/pam_mount.so")))) '("login" "greetd" "su" "slim" "gdm-password" "sddm")) (pam-service (inherit pam) - (auth (append (pam-service-auth pam) - (list optional-pam-mount))) - (session (append (pam-service-session pam) - (list optional-pam-mount)))) + (auth (insert-before pam-gnupg-module? + (pam-service-auth pam) + (list optional-pam-mount))) + (session (insert-before pam-gnupg-module? + (pam-service-session pam) + (list optional-pam-mount)))) pam)))))) (define (extend-pam-mount-configuration initial extensions) diff --git a/gnu/system/pam.scm b/gnu/system/pam.scm index a035a92e25..445e45c5ef 100644 --- a/gnu/system/pam.scm +++ b/gnu/system/pam.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2013-2017, 2019-2021 Ludovic Courtès ;;; Copyright © 2023 Josselin Poiret +;;; Copyright © 2023 Carlos Durán Domínguez ;;; ;;; This file is part of GNU Guix. ;;; @@ -64,7 +65,9 @@ (define-module (gnu system pam) pam-extension-shepherd-requirements pam-root-service-type - pam-root-service)) + pam-root-service + + pam-gnupg-module?)) ;;; Commentary: ;;; @@ -264,12 +267,12 @@ (module "pam_motd.so") (control "required") (module "pam_loginuid.so"))) '()) + ,env ,unix ,@(if gnupg? (list (pam-entry (control "required") (module (file-append pam-gnupg "/lib/security/pam_gnupg.so")))) - '()) - ,env ,unix)))))) + '()))))))) (define (rootok-pam-service command) "Return a PAM service for COMMAND such that 'root' does not need to @@ -454,4 +457,8 @@ (define* (pam-root-service base #:key (transformers '()) (shepherd-requirements (transformers transformers) (shepherd-requirements shepherd-requirements)))) +(define (pam-gnupg-module? name) + "Return `#t' if NAME is the path to the pam-gnupg module, `#f' otherwise." + (equal? (pam-entry-module name) + (file-append pam-gnupg "/lib/security/pam_gnupg.so"))) -- 2.41.0