From patchwork Sat Nov 11 11:06:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 56262 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 C31BA27BBE9; Sat, 11 Nov 2023 11:15:04 +0000 (GMT) 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 9B06C27BBE2 for ; Sat, 11 Nov 2023 11:15:03 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r1lwZ-0004Vb-6L; Sat, 11 Nov 2023 06:14:27 -0500 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 1r1lwX-0004Uk-JD for guix-patches@gnu.org; Sat, 11 Nov 2023 06:14:25 -0500 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 1r1lwX-0002Fa-9Q; Sat, 11 Nov 2023 06:14:25 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1r1lx8-0005og-NR; Sat, 11 Nov 2023 06:15:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#67072] [PATCH 4/4] weather: Report unauthorized substitute servers. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, rekado@elephly.net, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Sat, 11 Nov 2023 11:15:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67072 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 67072@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= , Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 67072-submit@debbugs.gnu.org id=B67072.169970127222280 (code B ref 67072); Sat, 11 Nov 2023 11:15:02 +0000 Received: (at 67072) by debbugs.gnu.org; 11 Nov 2023 11:14:32 +0000 Received: from localhost ([127.0.0.1]:52179 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r1lwd-0005nD-ND for submit@debbugs.gnu.org; Sat, 11 Nov 2023 06:14:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44198) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r1lwX-0005mV-Vl for 67072@debbugs.gnu.org; Sat, 11 Nov 2023 06:14:27 -0500 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 1r1lvo-00026c-Cp; Sat, 11 Nov 2023 06:13:40 -0500 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=zbPOgn0Gn1dj2q9Pg1kzalpGBjU4WdtZtoE0cpxLhMM=; b=CNTa7odlLznICJCLsvrE evMY4ShDWYsRBPHb0SSkLEaIRJfyYHotSLLVeIHjhsvyWs0crVhu6enwCTaMNgEdOkPp0ElTmXMVe 9Yap4x52EtAxVh38HiSWYl9PAkRe4ZqjWRRcWQKt7LTYt8H3rY7tXRFBwOW5NDiJfxI4aLR8K3ATn CO5WMD9Hdz7PhZzEmYTtHA8R2IcDGee8415gaeUOj0ndSvYv9cihHwI7XqPuZDBKTqrFsRj1bMwFx fj2H80oQpKCRyRedECchjVrazzKgheZUyvriK/cSsLbgr6o2ZFeoSgpXMhMk07sx0urMMwBJK3c/k y1WYO6BtqKg0tA==; From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Sat, 11 Nov 2023 12:06:26 +0100 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 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 The goal is to make it easier to diagnose substitute misconfiguration (where we’re passing a substitute URL whose corresponding key is not authorized). Suggested by Emmanuel Agullo. * guix/scripts/weather.scm (check-narinfo-authorization): New procedure. (report-server-coverage): Use it. * doc/guix.texi (Invoking guix weather): Document it. (Getting Substitutes from Other Servers): Add “Troubleshooting” frame. Change-Id: I0a049c39eefb10d6a06634c8b16aa86902769791 --- doc/guix.texi | 21 ++++++++++++++++++++- guix/scripts/weather.scm | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/doc/guix.texi b/doc/guix.texi index 028c4f3357..45c3b7344f 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -4058,6 +4058,7 @@ Substitute Server Authorization @node Getting Substitutes from Other Servers @subsection Getting Substitutes from Other Servers +@c Note: This section name appears in a hint printed by 'guix weather'. @cindex substitute servers, adding more Guix can look up and fetch substitutes from several servers. This is @@ -4157,6 +4158,21 @@ Getting Substitutes from Other Servers substitute lookup can be slowed down if too many servers need to be contacted. +@quotation Troubleshooting +To diagnose problems, you can run @command{guix weather}. For example, +running: + +@example +guix weather coreutils +@end example + +@noindent +not only tells you which of the currently-configured servers has +substitutes for the @code{coreutils} package, it also reports whether +one of these servers is unauthorized. @xref{Invoking guix weather}, for +more information. +@end quotation + Note that there are also situations where one may want to add the URL of a substitute server @emph{without} authorizing its key. @xref{Substitute Authentication}, to understand this fine point. @@ -16395,7 +16411,10 @@ Invoking guix weather specified servers so you can have an idea of whether you'll be grumpy today. It can sometimes be useful info as a user, but it is primarily useful to people running @command{guix publish} (@pxref{Invoking guix -publish}). +publish}). Sometimes substitutes @emph{are} available but they are not +authorized on your system; @command{guix weather} reports it so you can +authorize them if you want (@pxref{Getting Substitutes from Other +Servers}). @cindex statistics, for substitutes @cindex availability of substitutes diff --git a/guix/scripts/weather.scm b/guix/scripts/weather.scm index 7e302fcea7..e7e5a75811 100644 --- a/guix/scripts/weather.scm +++ b/guix/scripts/weather.scm @@ -35,6 +35,8 @@ (define-module (guix scripts weather) #:use-module ((guix build utils) #:select (every*)) #:use-module (guix substitutes) #:use-module (guix narinfo) + #:use-module (guix pki) + #:autoload (gcrypt pk-crypto) (canonical-sexp->string) #:use-module (guix http-client) #:use-module (guix ci) #:use-module (guix sets) @@ -185,6 +187,32 @@ (define (store-item-system store item) (() #f))) +(define (check-narinfo-authorization narinfo) + "Print a warning when NARINFO is not signed by an authorized key." + (unless (valid-narinfo? narinfo) + (warning (G_ "substitutes from '~a' are unauthorized~%") + (narinfo-uri-base narinfo)) + ;; The "all substitutes" below reflects the fact that, in reality, it *is* + ;; possible to download "unauthorized" substitutes, as long as they match + ;; authorized substitutes. + (display-hint (G_ "To authorize all substitutes from @uref{~a} to be +downloaded, the following command needs to be run as root: + +@example +guix archive --authorize <string + (signature-subject (narinfo-signature narinfo)))))) + (define* (report-server-coverage server items #:key display-missing?) "Report the subset of ITEMS available as substitutes on SERVER. @@ -204,6 +232,12 @@ (define* (report-server-coverage server items #:make-progress-reporter (lambda* (total #:key url #:allow-other-keys) (progress-reporter/bar total))))) + (match narinfos + (() #f) + ((narinfo . _) + ;; Help diagnose missing substitute authorizations. + (check-narinfo-authorization narinfo))) + (let ((obtained (length narinfos)) (requested (length items)) (missing (lset-difference string=?