From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:403:4789::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id CCK/IPaODWVkYQEA9RJhRA:P1 (envelope-from ) for ; Fri, 22 Sep 2023 14:56:22 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:4789::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id CCK/IPaODWVkYQEA9RJhRA (envelope-from ) for ; Fri, 22 Sep 2023 14:56:22 +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 725F95E7C8 for ; Fri, 22 Sep 2023 14:56:22 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=Sq+6AsE2; 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=1695387382; 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=F8/ITNybdKENRcRhPNVo7d37tSrUe4l7QUIGWPatBPc=; b=bYk2jA9NvPuSq23+4FSm+zi/I/+ob95krB9tPpzVvuOZIB9vzVPoO+hdJSeKeRYXZtGt1M zMyVRFFXqxRRYCyt5JdCxtmpIYWtgL4/e8r8q3JrO4hLVTlJ5DHly4ugkglEj/0U8RvNOA awmeUU6FykHoSR2B5ruJvfYY2P4j8n5UX51TxgneUUqiC62QpwfGP5Iv330I+RU7hKt8SY BgLsHComZDPbH+cGybYiqqzZiB3fBoTqXEoVmlf6y5kJPrwvVbciYnqJhOHyaCNYP7iAtQ 3FyAH7GIFCpbuo6rWRMNxYs1eq6VMLIvqSXbSJGe8iY4L4NE8/SqsNcSHjWKdw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1695387382; a=rsa-sha256; cv=none; b=G1Wvt1egaKhXE6KBep2qMJHrkqmzABfRPhgMNCMSkaIdy8a13IxrijWCW4gNu+hsPWayxU eBbLKEwA+CZ5EXFtLbhjmA9YgQilcDEG+eHn9FAY6ycBLQrpcn9fFet6Ls7xeFAoE0gDYj n59p1pcaugQGxJeqlRM0vTrBoHA1O/BpmxCEPPIPpNwVjs3Au2T414FKDqaL2ugFgr7Buw iywX1KSs7ugLTHkFlkHdzCeA7/tRnM+n3h2u6Jk6ir2E93WNaXMkoK7+FBaBqkbvaBZcp9 nj+o+JApU8MNIl40dZZcfhvOMkiFdPP3PRnBArkaybEpYcQ3RGUGXq+QkrzHYg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=Sq+6AsE2; 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 Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qjfhJ-0001Nx-CO; Fri, 22 Sep 2023 08:55: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 1qjfhI-0001NW-9U for guix-patches@gnu.org; Fri, 22 Sep 2023 08:55:52 -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 1qjfhI-0008B1-1I for guix-patches@gnu.org; Fri, 22 Sep 2023 08:55:52 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qjfhS-0005j1-Ji for guix-patches@gnu.org; Fri, 22 Sep 2023 08:56:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#66156] [PATCH 07/12] services: childhurd: Authorize the =?UTF-8?Q?childhurd=E2=80=99s?= key on the host. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 22 Sep 2023 12:56:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66156 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 66156@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 66156-submit@debbugs.gnu.org id=B66156.169538731221901 (code B ref 66156); Fri, 22 Sep 2023 12:56:02 +0000 Received: (at 66156) by debbugs.gnu.org; 22 Sep 2023 12:55:12 +0000 Received: from localhost ([127.0.0.1]:35591 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qjfgd-0005h3-L4 for submit@debbugs.gnu.org; Fri, 22 Sep 2023 08:55:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41108) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qjfgM-0005eI-5A for 66156@debbugs.gnu.org; Fri, 22 Sep 2023 08:54:54 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qjfg6-0007nH-8U; Fri, 22 Sep 2023 08:54:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=F8/ITNybdKENRcRhPNVo7d37tSrUe4l7QUIGWPatBPc=; b=Sq+6AsE2Lj+i33o1BBfm m0l5bSfMIeDGm5U0veBnWCoNljRyxFDvK18vGExQqd2Ii44Ui1C/uXlvKyuq3Pn2sIjSrivJmLiWd jOZIdj8K46Ro3RHtF4Aj6hoxI2tadvDrbO2wARkP2nd/aJIJB9YmAVriO+RhRvDDVCZ/lNSFJtJyF sTzm+uaKCWW8mIyvvEPbe5aNaeFM21XM0HFSxXJTGEJ9pruWYYF90RBitr/WWHLxAxFPIFEMTEB/J h9qD1z7UxcPrtaofgyXdskpRvxABg8Jn3CaVAF4DM1qnDEnW9ldDm3dAX3hM6lmkgNPLPFgvf43Yt +99g+tux90P8rg==; From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Fri, 22 Sep 2023 14:54:08 +0200 Message-ID: <0f2ebabd36558e2f660e4f1037a3c0a7f77f53d5.1695386493.git.ludo@gnu.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: 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-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Spam-Score: -5.98 X-Migadu-Spam-Score: -5.98 X-Migadu-Scanner: mx1.migadu.com X-Migadu-Queue-Id: 725F95E7C8 X-TUID: uEmoa2twgI4q This partly automates setting up a childhurd for offloading purposes. * gnu/services/virtualization.scm (authorize-guest-substitutes-on-host): New procedure. (hurd-vm-activation): Use it. --- gnu/services/virtualization.scm | 51 ++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/gnu/services/virtualization.scm b/gnu/services/virtualization.scm index fd153dd051..ca000f5d28 100644 --- a/gnu/services/virtualization.scm +++ b/gnu/services/virtualization.scm @@ -28,6 +28,7 @@ (define-module (gnu services virtualization) #:use-module (gnu image) #:use-module (gnu packages admin) #:use-module (gnu packages gdb) + #:autoload (gnu packages gnupg) (guile-gcrypt) #:use-module (gnu packages package-management) #:use-module (gnu packages ssh) #:use-module (gnu packages virtualization) @@ -50,6 +51,7 @@ (define-module (gnu services virtualization) #:use-module (guix records) #:use-module (guix store) #:use-module (guix utils) + #:autoload (guix self) (make-config.scm) #:use-module (srfi srfi-9) #:use-module (srfi srfi-26) @@ -1271,6 +1273,50 @@ (define (initialize-hurd-vm-substitutes) (program-file "initialize-hurd-vm-substitutes" run)) +(define (authorize-guest-substitutes-on-host) + "Return a program that authorizes the guest's archive signing key (passed as +an argument) on the host." + (define not-config? + (match-lambda + ('(guix config) #f) + (('guix _ ...) #t) + (('gnu _ ...) #t) + (_ #f))) + + (define run + (with-extensions (list guile-gcrypt) + (with-imported-modules `(((guix config) => ,(make-config.scm)) + ,@(source-module-closure + '((guix pki) + (guix build utils)) + #:select? not-config?)) + #~(begin + (use-modules (ice-9 match) + (ice-9 textual-ports) + (gcrypt pk-crypto) + (guix pki) + (guix build utils)) + + (match (command-line) + ((_ guest-config-directory) + (let ((guest-key (string-append guest-config-directory + "/signing-key.pub"))) + (if (file-exists? guest-key) + ;; Add guest key to the host's ACL. + (let* ((key (string->canonical-sexp + (call-with-input-file guest-key + get-string-all))) + (acl (public-keys->acl + (cons key (acl->public-keys (current-acl)))))) + (with-atomic-file-replacement %acl-file + (lambda (_ port) + (write-acl acl port)))) + (format (current-error-port) + "warning: guest key missing from '~a'~%" + guest-key))))))))) + + (program-file "authorize-guest-substitutes-on-host" run)) + (define (hurd-vm-activation config) "Return a gexp to activate the Hurd VM according to CONFIG." (with-imported-modules '((guix build utils)) @@ -1294,7 +1340,10 @@ (define (hurd-vm-activation config) (unless (file-exists? guix-directory) (invoke #$(initialize-hurd-vm-substitutes) - guix-directory))))) + guix-directory)) + + ;; Authorize the archive signing key from GUIX-DIRECTORY in the host. + (invoke #$(authorize-guest-substitutes-on-host) guix-directory)))) (define hurd-vm-service-type (service-type -- 2.41.0