From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id MPHFNiSS515CRgAA0tVLHw (envelope-from ) for ; Mon, 15 Jun 2020 15:22:12 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id YPmHMiSS517/OAAAbx9fmQ (envelope-from ) for ; Mon, 15 Jun 2020 15:22:12 +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 70361940900 for ; Mon, 15 Jun 2020 15:22:12 +0000 (UTC) Received: from localhost ([::1]:56994 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jkqw7-0004lH-8d for larch@yhetil.org; Mon, 15 Jun 2020 11:22:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41152) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jkqvy-0004je-M3 for guix-patches@gnu.org; Mon, 15 Jun 2020 11:22:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:35648) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jkqvy-0001R3-C8 for guix-patches@gnu.org; Mon, 15 Jun 2020 11:22:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jkqvy-0007dT-8a for guix-patches@gnu.org; Mon, 15 Jun 2020 11:22:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#41870] [PATCH 1/2] channels: Warn when pulling from a mirror. References: <20200615151201.533-1-ludo@gnu.org> In-Reply-To: <20200615151201.533-1-ludo@gnu.org> Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 15 Jun 2020 15:22:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41870 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 41870@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 41870-submit@debbugs.gnu.org id=B41870.159223446529266 (code B ref 41870); Mon, 15 Jun 2020 15:22:02 +0000 Received: (at 41870) by debbugs.gnu.org; 15 Jun 2020 15:21:05 +0000 Received: from localhost ([127.0.0.1]:47191 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jkqv2-0007bx-Lk for submit@debbugs.gnu.org; Mon, 15 Jun 2020 11:21:04 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54530) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jkqv1-0007af-9b for 41870@debbugs.gnu.org; Mon, 15 Jun 2020 11:21:03 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:38475) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jkquv-0001FE-Nl; Mon, 15 Jun 2020 11:20:57 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=39854 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jkquv-0004s4-7k; Mon, 15 Jun 2020 11:20:57 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Mon, 15 Jun 2020 17:20:48 +0200 Message-Id: <20200615152049.1047-1-ludo@gnu.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -3.3 (---) 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-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; 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-Spam-Score: 3.99 X-TUID: zyFGSR9F2ef5 * guix/channels.scm ()[url]: New field. (read-channel-metadata): Initialize it. (read-channel-metadata-from-source): Likewise. (channel-instance-primary-url): New procedure. (latest-channel-instances): Compare CHANNEL's URL against it. * doc/guix.texi (Channels)[Primary URL]: New subsection. --- doc/guix.texi | 22 ++++++++++++++++++++++ guix/channels.scm | 29 +++++++++++++++++++++++++---- 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 81a11c6756..16ef5bf42e 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -4153,6 +4153,28 @@ add a meta-data file @file{.guix-channel} that contains: (directory "guix")) @end lisp +@cindex primary URL, channels +@subsection Primary URL + +Channel authors can indicate the primary URL of their channel's Git +repository in the @file{.guix-channel} file, like so: + +@lisp +(channel + (version 0) + (url "https://example.org/guix.git")) +@end lisp + +This allows @command{guix pull} to determine whether it is pulling code +from a mirror of the channel; when that is the case, it warns the user +that the mirror might be stale and displays the primary URL. That way, +users cannot be tricked into fetching code from a stale mirror that does +not receive security updates. + +This feature only makes sense for authenticated repositories, such as +the official @code{guix} channel, for which @command{guix pull} ensures +the code it fetches is authentic. + @cindex news, for channels @subsection Writing Channel News diff --git a/guix/channels.scm b/guix/channels.scm index 38ec68fec1..7e4d6e4c84 100644 --- a/guix/channels.scm +++ b/guix/channels.scm @@ -182,12 +182,13 @@ introduction, add it." (checkout channel-instance-checkout)) (define-record-type - (channel-metadata directory dependencies news-file keyring-reference) + (channel-metadata directory dependencies news-file keyring-reference url) channel-metadata? (directory channel-metadata-directory) ;string with leading slash (dependencies channel-metadata-dependencies) ;list of (news-file channel-metadata-news-file) ;string | #f - (keyring-reference channel-metadata-keyring-reference)) ;string + (keyring-reference channel-metadata-keyring-reference) ;string + (url channel-metadata-url)) ;string | #f (define %default-keyring-reference ;; Default value of the 'keyring-reference' field. @@ -209,6 +210,7 @@ if valid metadata could not be read from PORT." (let ((directory (and=> (assoc-ref properties 'directory) first)) (dependencies (or (assoc-ref properties 'dependencies) '())) (news-file (and=> (assoc-ref properties 'news-file) first)) + (url (and=> (assoc-ref properties 'url) first)) (keyring-reference (or (and=> (assoc-ref properties 'keyring-reference) first) %default-keyring-reference))) @@ -229,7 +231,8 @@ if valid metadata could not be read from PORT." (commit (get 'commit)))))) dependencies) news-file - keyring-reference))) + keyring-reference + url))) ((and ('channel ('version version) _ ...) sexp) (raise (condition (&message (message "unsupported '.guix-channel' version")) @@ -253,7 +256,7 @@ doesn't exist." read-channel-metadata)) (lambda args (if (= ENOENT (system-error-errno args)) - (channel-metadata "/" '() #f %default-keyring-reference) + (channel-metadata "/" '() #f %default-keyring-reference #f) (apply throw args))))) (define (channel-instance-metadata instance) @@ -463,6 +466,11 @@ been tampered with and is trying to force a roll-back, preventing you from getting the latest updates. If you think this is not the case, explicitly allow non-forward updates.")))))))))) +(define (channel-instance-primary-url instance) + "Return the primary URL advertised for INSTANCE, or #f if there is no such +information." + (channel-metadata-url (channel-instance-metadata instance))) + (define* (latest-channel-instances store channels #:key (current-channels '()) @@ -518,6 +526,19 @@ depending on the policy it implements." validate-pull #:starting-commit current))) + (when authenticate? + ;; CHANNEL is authenticated so we can trust the + ;; primary URL advertised in its metadata and warn + ;; about possibly stale mirrors. + (let ((primary-url (channel-instance-primary-url + instance))) + (unless (or (not primary-url) + (channel-commit channel) + (string=? primary-url (channel-url channel))) + (warning (G_ "pulled channel '~a' from a mirror \ +of ~a, which might be stale~%") + (channel-name channel) + primary-url)))) (let-values (((new-instances new-channels) (loop (channel-instance-dependencies instance) -- 2.26.2