unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: 42030@debbugs.gnu.org
Cc: "Ludovic Courtès" <ludo@gnu.org>
Subject: [bug#42030] [PATCH] channels: Error out when the 'guix' channel lacks an introduction.
Date: Wed, 24 Jun 2020 14:57:49 +0200	[thread overview]
Message-ID: <20200624125749.10908-1-ludo@gnu.org> (raw)

* guix/channels.scm (latest-channel-instance): Raise an error instead of
warning when 'guix is unauthenticated.
* tests/channels.scm ("latest-channel-instances, missing introduction for 'guix'"):
New test.
---
 guix/channels.scm  | 13 ++++++++++---
 tests/channels.scm | 21 +++++++++++++++++++++
 2 files changed, 31 insertions(+), 3 deletions(-)

Hi!

This patch makes it an error to have a 'guix' channel without an
introduction.  Before that, it was just a warning, which is easily
overlooked.  (Similarly, wget or your browser stop if they cannot
authenticate the host you're connecting to over HTTPS.)

Note that when using the "official" 'guix' channel, (guix channels)
automatically adds the introduction (see commit
c3f6f564e909ebefe752d24b325871a4e3a02d40).  It will work similarly
for people who maintain forks.

Thanks,
Ludo'.

diff --git a/guix/channels.scm b/guix/channels.scm
index 3eec5df883..1016b95045 100644
--- a/guix/channels.scm
+++ b/guix/channels.scm
@@ -406,9 +406,16 @@ their relation.  When AUTHENTICATE? is false, CHANNEL is not authenticated."
             ;; TODO: Warn for all the channels once the authentication interface
             ;; is public.
             (when (guix-channel? channel)
-              (warning (G_ "channel '~a' lacks an introduction and \
-cannot be authenticated~%")
-                       (channel-name channel))))
+              (raise (condition
+                      (&message
+                       (message (format #f (G_ "channel '~a' lacks an \
+introduction and cannot be authenticated~%")
+                                        (channel-name channel))))
+                      (&fix-hint
+                       (hint (G_ "Add the missing introduction to your
+channels file to address the issue.  Alternatively, you can pass
+@option{--disable-authentication}, at the risk of running unauthenticated and
+thus potentially malicious code.")))))))
         (warning (G_ "channel authentication disabled~%")))
 
     (when (guix-channel? channel)
diff --git a/tests/channels.scm b/tests/channels.scm
index 3a2c1d429b..d7202f8cbf 100644
--- a/tests/channels.scm
+++ b/tests/channels.scm
@@ -402,6 +402,27 @@
                          (channel-news-for-commit channel commit5 commit1))
                     '(#f "tag-for-first-news-entry")))))))
 
+(unless (which (git-command)) (test-skip 1))
+(test-assert "latest-channel-instances, missing introduction for 'guix'"
+  (with-temporary-git-repository directory
+      '((add "a.txt" "A")
+        (commit "first commit")
+        (add "b.scm" "#t")
+        (commit "second commit"))
+    (with-repository directory repository
+      (let* ((commit1 (find-commit repository "first"))
+             (commit2 (find-commit repository "second"))
+             (channel (channel (url (string-append "file://" directory))
+                               (name 'guix))))
+
+        (guard (c ((message-condition? c)
+                   (->bool (string-contains (condition-message c)
+                                            "introduction"))))
+          (with-store store
+            ;; Attempt a downgrade from NEW to OLD.
+            (latest-channel-instances store (list channel))
+            #f))))))
+
 (unless (gpg+git-available?) (test-skip 1))
 (test-equal "authenticate-channel, wrong first commit signer"
   #t
-- 
2.26.2





             reply	other threads:[~2020-06-24 12:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-24 12:57 Ludovic Courtès [this message]
2020-06-24 21:13 ` [bug#42030] [PATCH] channels: Error out when the 'guix' channel lacks an introduction Marius Bakke
2020-06-25  9:29   ` Ludovic Courtès
2020-06-29 11:47     ` Marius Bakke
2020-06-29 15:14       ` Ludovic Courtès
2020-07-25 15:05         ` Marius Bakke
2020-06-28 21:31 ` bug#42030: " Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200624125749.10908-1-ludo@gnu.org \
    --to=ludo@gnu.org \
    --cc=42030@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).