From patchwork Mon Jun 15 15:20:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 22723 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 C3A7C27BBE3; Mon, 15 Jun 2020 16:22:16 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id 1960127BBE1 for ; Mon, 15 Jun 2020 16:22:16 +0100 (BST) Received: from localhost ([::1]:56994 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jkqwB-0004lH-Lb for patchwork@mira.cbaines.net; Mon, 15 Jun 2020 11:22:15 -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 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" X-getmail-retrieved-from-mailbox: Patches * 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) From patchwork Mon Jun 15 15:20:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 22724 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 85C4327BBE3; Mon, 15 Jun 2020 16:22:32 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id 2E90727BBE1 for ; Mon, 15 Jun 2020 16:22:32 +0100 (BST) Received: from localhost ([::1]:57392 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jkqwR-0004wr-Mi for patchwork@mira.cbaines.net; Mon, 15 Jun 2020 11:22:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41154) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jkqvz-0004k4-0M for guix-patches@gnu.org; Mon, 15 Jun 2020 11:22:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:35649) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jkqvy-0001R9-NM 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-0007da-KF for guix-patches@gnu.org; Mon, 15 Jun 2020 11:22:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#41870] [PATCH 2/2] .guix-channel: Add primary URL. 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.159223446729283 (code B ref 41870); Mon, 15 Jun 2020 15:22:02 +0000 Received: (at 41870) by debbugs.gnu.org; 15 Jun 2020 15:21:07 +0000 Received: from localhost ([127.0.0.1]:47194 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jkqv5-0007cE-0b for submit@debbugs.gnu.org; Mon, 15 Jun 2020 11:21:07 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54548) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jkqv3-0007ai-Ln for 41870@debbugs.gnu.org; Mon, 15 Jun 2020 11:21:05 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:38478) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jkquy-0001Ff-Ej; Mon, 15 Jun 2020 11:21:00 -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 1jkqux-0004s4-Vr; Mon, 15 Jun 2020 11:21:00 -0400 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Mon, 15 Jun 2020 17:20:49 +0200 Message-Id: <20200615152049.1047-2-ludo@gnu.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200615152049.1047-1-ludo@gnu.org> References: <20200615152049.1047-1-ludo@gnu.org> 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" X-getmail-retrieved-from-mailbox: Patches * .guix-channel: Add 'url'. --- .guix-channel | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.guix-channel b/.guix-channel index f4459f1de1..b852180cf2 100644 --- a/.guix-channel +++ b/.guix-channel @@ -3,4 +3,5 @@ (channel (version 0) (news-file "etc/news.scm") - (keyring-reference "keyring")) + (keyring-reference "keyring") + (url "https://git.savannah.gnu.org/git/guix.git")) ;the primary URL