From patchwork Mon Jul 24 19:03:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Efraim Flashner X-Patchwork-Id: 52167 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 D456127BBE2; Mon, 24 Jul 2023 20:04:21 +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 006A427BBE9 for ; Mon, 24 Jul 2023 20:04:19 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qO0qk-0000sz-4P; Mon, 24 Jul 2023 15:04:06 -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 1qO0qh-0000rP-0h for guix-patches@gnu.org; Mon, 24 Jul 2023 15:04:03 -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 1qO0qg-0003FP-OT for guix-patches@gnu.org; Mon, 24 Jul 2023 15:04:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qO0qg-0002ti-2Z for guix-patches@gnu.org; Mon, 24 Jul 2023 15:04:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#64838] [PATCH] home: Add parcimonie service. Resent-From: Efraim Flashner Original-Sender: "Debbugs-submit" Resent-CC: , guix-patches@gnu.org Resent-Date: Mon, 24 Jul 2023 19:04:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 64838 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 64838@debbugs.gnu.org Cc: Efraim Flashner , ( , Andrew Tropin , Ludovic =?utf-8?q?Court=C3=A8s?= X-Debbugs-Original-To: guix-patches@gnu.org X-Debbugs-Original-Xcc: ( , Andrew Tropin , Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by submit@debbugs.gnu.org id=B.169022543511123 (code B ref -1); Mon, 24 Jul 2023 19:04:01 +0000 Received: (at submit) by debbugs.gnu.org; 24 Jul 2023 19:03:55 +0000 Received: from localhost ([127.0.0.1]:44034 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qO0qY-0002tK-KW for submit@debbugs.gnu.org; Mon, 24 Jul 2023 15:03:55 -0400 Received: from lists.gnu.org ([2001:470:142::17]:39766) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qO0qV-0002t4-N7 for submit@debbugs.gnu.org; Mon, 24 Jul 2023 15:03:53 -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 1qO0qP-0000qC-Pc for guix-patches@gnu.org; Mon, 24 Jul 2023 15:03:45 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qO0qN-0003Cz-95 for guix-patches@gnu.org; Mon, 24 Jul 2023 15:03:45 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-3fbea147034so36961485e9.0 for ; Mon, 24 Jul 2023 12:03:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690225420; x=1690830220; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:from:to:cc:subject:date:message-id:reply-to; bh=Gpo9vTRoxcLM1C9iH3rPatkiLyNS7HPgFN7z6PsfNjs=; b=lAoK6Tm4ICysZS/EHuxabMCGVKv1GTsHApLZgeU0XP+5igQvJLKGEpgCWyFDXIaplS KKm+IwIDgb2GLCJrWS/x4n3x3rHNjwcKY6LBetG2eMOFAVQDDrClMhcz6h//TwjR0FlY acni8GRv/bhJui37xzj7FLLtb/2nVmT3JSnYUfHt/JCUzqSWRSbIsR/vc9w+FwEYGcPD VL5IEiNuLBU8CqU01eFkiSdV2yxtil7FapRFQbiJzn/9x6gTi9Sr4TyfcjVn8g7pg/4Z Flr8luEFWEENezgda6u2y2hqykBtp1YsZlNXhqWmXutamJZQHD73zZuGcoLScPwjBq6V ZU0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690225420; x=1690830220; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Gpo9vTRoxcLM1C9iH3rPatkiLyNS7HPgFN7z6PsfNjs=; b=h+QSFedbZ2AC/9itcRhxIDDCaHfpr44wwTq3L+f9f14T+MYHBf/OyaJJ5x0RpI2T/8 jyCZ4gkNPp9Qeaw5vkIaKIwGku69nLsUE36AeZ71DiQxy7SMu9yxzhqsaIK6rPg0/0CH cSB/vQYKFA3sLewRZUtokfNaf1pYe6eimraqi73VtUv/b7BS/YyM9l9HIfGX+PKxrEj3 WLF6iUf1bWSX5BzGMR8LhSVWLhb4fIaGKlAYY3mC7vSG9uqxC2YHIyoguS/UQ0E4Fl8R TcGUgGzG940oamIkuO6Nw2W9LKFc6bl5CVWbnYGraVktqndZJw7SPdFM6OmOKNWtRvI8 VVYQ== X-Gm-Message-State: ABy/qLZ0XA3uvPbmmdvJstBUSHgQGgzJ3DC3kfQPqR/Wl9Q+xP8kgqj1 AgwVMjhTs48zLZPMOacsIy6Fji2tH2RB+Q== X-Google-Smtp-Source: APBJJlF2vPWlxjIluZxFh2Eyvhyv4jgQ0UTfdzWeojCW2xa9sHZlqVIZMfTrovP0IXSx34wg8M2x1w== X-Received: by 2002:a7b:cc93:0:b0:3fd:3049:9496 with SMTP id p19-20020a7bcc93000000b003fd30499496mr3764050wma.33.1690225420262; Mon, 24 Jul 2023 12:03:40 -0700 (PDT) Received: from localhost ([141.226.14.192]) by smtp.gmail.com with ESMTPSA id j19-20020a5d4533000000b0031763fd36c4sm2478248wra.104.2023.07.24.12.03.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jul 2023 12:03:39 -0700 (PDT) From: Efraim Flashner Date: Mon, 24 Jul 2023 22:03:30 +0300 Message-ID: X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=efraim.flashner@gmail.com; helo=mail-wm1-x332.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * gnu/home/services/gnupg.scm (home-parcimonie-service-type, home-parcimonie-configuration): New variables. * doc/guix.texi (GNU Privacy Guard): Document it. --- doc/guix.texi | 55 ++++++++++++++++++++++++ gnu/home/services/gnupg.scm | 86 ++++++++++++++++++++++++++++++++++++- 2 files changed, 139 insertions(+), 2 deletions(-) base-commit: 3adde30af52d4be347d610c0bdd543e0fdd6d64d diff --git a/doc/guix.texi b/doc/guix.texi index 585baf358f..bc86c58cdb 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -43679,6 +43679,61 @@ GNU Privacy Guard @end deftp +@cindex Parcimonie, Home service +The @code{parcimonie} service runs a daemon that slowly refreshes a GnuPG +public key from a keyserver. Its refreshes one key at a time; between every +key update parcimonie sleeps a random amount of time, long enough for the +previously used Tor circuit to expire. This process is meant to make it hard +for an attacker to correlate the multiple performed key update operations. + +As an example, here is how you would configure @code{parcimonie} to refresh the +keys in your GnuPG keyring, as well as those keyrings created by Guix, such as +when running @code{guix import}: + +@lisp +(service home-parcimonie-service-type + (home-parcimonie-configuration + (refresh-guix-keyrings? #t))) +@end lisp + +The service reference is given below. + +@defvar parcimonie-service-type +This is the service type for @command{parcimonie} +(@uref{https://salsa.debian.org/intrigeri/parcimonie, Parcimonie's web site}). +Its value must be a @code{home-parcimonie-configuration}, as shown below. +@end defvar + +@c %start of fragment + +@deftp {Data Table} home-parcimonie-configuration +Available @code{home-parcimonie-configuration} fields are: + +@table @asis +@item @code{parcimonie} (default: @code{parcimonie}) (type: file-like) +The parcimonie package to use. + +@item @code{verbose?} (default: @code{#f}) (type: boolean) +Whether to have more verbose logging from the service. + +@item @code{gnupg-already-torified?} (default: @code{#f}) (type: boolean) +Whether GnuPG is already configured to pass all traffic through +@uref{https://torproject.org, Tor}. + +@item @code{dbus?} (default: @code{#f}) (type: boolean) +Whether to send activity updates through D-Bus. + +@item @code{refresh-guix-keyrings?} (default: @code{#f}) (type: boolean) +Guix creates a few keyrings in the @var{$XDG_CONFIG_DIR}, such as when running +@code{guix import} (@pxref{Invoking guix import}). Setting this to @code{#t} +will also refresh any keyrings which Guix has created. + +@item @code{extra-content} (default: @code{#f}) (type: raw-configuration-string) +Raw content to add to the parcimonie command. + +@end table + +@end deftp @c %end of fragment diff --git a/gnu/home/services/gnupg.scm b/gnu/home/services/gnupg.scm index 7e9e02a3cc..9b66f7b1cf 100644 --- a/gnu/home/services/gnupg.scm +++ b/gnu/home/services/gnupg.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2023 Ludovic Courtès +;;; Copyright © 2023 Efraim Flashner ;;; ;;; This file is part of GNU Guix. ;;; @@ -23,7 +24,7 @@ (define-module (gnu home services gnupg) #:use-module (gnu services configuration) #:use-module (gnu home services) #:use-module (gnu home services shepherd) - #:autoload (gnu packages gnupg) (gnupg pinentry) + #:autoload (gnu packages gnupg) (gnupg pinentry parcimonie) #:export (home-gpg-agent-configuration home-gpg-agent-configuration? home-gpg-agent-configuration-gnupg @@ -34,7 +35,17 @@ (define-module (gnu home services gnupg) home-gpg-agent-configuration-max-cache-ttl-ssh home-gpg-agent-configuration-extra-content - home-gpg-agent-service-type)) + home-gpg-agent-service-type + + home-parcimonie-configuration + home-parcimonie-configuration? + home-parcimonie-configuration-parcimonie + home-parcimonie-configuration-gnupg-already-torified? + home-parcimonie-configuration-with-dbus? + home-parcimonie-configuration-refresh-guix-keyrings? + home-parcimonie-configuration-extra-content + + home-parcimonie-service-type)) (define raw-configuration-string? string?) @@ -148,3 +159,74 @@ (define home-gpg-agent-service-type managing OpenPGP and optionally SSH private keys. When SSH support is enabled, @command{gpg-agent} acts as a drop-in replacement for OpenSSH's @command{ssh-agent}."))) + +(define-configuration/no-serialization home-parcimonie-configuration + (parcimonie + (file-like parcimonie) + "The parcimonie package to use.") + (verbose? + (boolean #f) + "Provide extra output to the log file.") + (gnupg-aleady-torified? + (boolean #f) + "GnuPG is already configured to use tor and parcimonie won't attempt to use +tor directly.") + (dbus? + (boolean #f) + "Send activity updates on the org.parcimonie.daemon D-Bus service.") + (refresh-guix-keyrings? + (boolean #f) + "Also refresh any Guix keyrings found in the XDG_CONFIG_DIR.") + (extra-content + (raw-configuration-string "") + "Raw content to add to the parcimonie service.")) + +(define (home-parcimonie-shepherd-service config) + "Return a user service to run parcimonie." + (match-record config + (parcimonie verbose? gnupg-aleady-torified? dbus? + refresh-guix-keyrings? extra-content) + (let ((log-file #~(string-append %user-log-dir "/parcimonie.log"))) + (list (shepherd-service + (provision '(parcimonie)) + (modules '((shepherd support) ;for '%user-log-dir' + (guix build utils) + (srfi srfi-1))) + (start #~(make-forkexec-constructor + (cons* + #$(file-append parcimonie "/bin/parcimonie") + #$@(if verbose? + '("--verbose") + '()) + #$@(if gnupg-aleady-torified? + '("--gnupg_already_torified") + '()) + #$@(if dbus? + '("--with_dbus") + '()) + #$@(if (not (string=? extra-content "")) + (list extra-content) + '()) + #$@(if refresh-guix-keyrings? + '((append-map + (lambda (item) + (list (string-append "--gnupg_extra_options=" + "--keyring=" item))) + (find-files + (string-append (getenv "XDG_CONFIG_HOME") "/guix") + "^trustedkeys\\.kbx$"))) + '((list)))) + #:log-file #$log-file)) + (stop #~(make-kill-destructor)) + (respawn? #t) + (documentation "Incrementally refresh gnupg keyring over Tor")))))) + +(define home-parcimonie-service-type + (service-type + (name 'home-parcimonie) + (extensions + (list (service-extension home-shepherd-service-type + home-parcimonie-shepherd-service))) + (default-value (home-parcimonie-configuration)) + (description + "Incrementally refresh GnuPG keyrings over Tor.")))