From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms1.migadu.com with LMTPS id aO6aJ7PET2YWHAAAqHPOHw:P1 (envelope-from ) for ; Fri, 24 May 2024 00:35:31 +0200 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id aO6aJ7PET2YWHAAAqHPOHw (envelope-from ) for ; Fri, 24 May 2024 00:35:31 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=antr.me header.s=MBO0001 header.b=angDBtgc; dmarc=fail reason="SPF not aligned (relaxed)" header.from=antr.me (policy=none); spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1716503731; a=rsa-sha256; cv=none; b=YVLEcyzihCczEzHn1YGQn14WrjlcPDdP266cjPiaX7fwu2ea/kRqIbM6lMCP0ehN8VqIze xc7u36HDvdmVByf3+oMZuX1iRvedfTPb0EDrQ6bNR91mGEt6fVP5BnhbP2ele3imXnrvT+ vgm5CcjKOVjdgCt8ES1vExtOrQHfnsUz5JBh4B5xU4QiittFtRSSoFppYt584LCLCsY042 agKkNUsnvT1XVShDzUl9rRCLEY3MkxG9r9ocLOk1ItNAqOrmMsaE5qo4bPozBLROjoyyg6 +nIBBQDuiZtPmQ0wQm/AlZv1JAN/rP7Gy5Q/ucirrKcbOgP9efNVSRyy3Mr3Yg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=antr.me header.s=MBO0001 header.b=angDBtgc; dmarc=fail reason="SPF not aligned (relaxed)" header.from=antr.me (policy=none); spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1716503731; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:list-id:list-help:list-unsubscribe:list-subscribe: list-post:dkim-signature; bh=j1j3ix4ZZcH72BaAmYiEoXN5k9eL/aIK+58emn44tZU=; b=bhDNWDvLEMcMipEh3HipFCMefkipmibq30mvEde7qN/k4h92i5uOitW14e8LNVXkRaMXgP 2x1nrXh9SZ/ibblibgHUO4cdjczrO9bD70s2SYi194FT/aI6Uwc1ZGn1w/TPGOuaAtD3nK RmeHp17C3PU8sL+VSKPfyUh/nj2uUAGMrzaigag6gETXuJp/V1N8kr58BhscngxFxdExdI IN7aXwxL4hXuXDGVwkz6+CBF7be7QPGjsA0b7NdgHNyAIPDSvjsfIvA/WjdIkegNnq4gk4 RWOZyuptM4jeRyA154pU7iWHJTLI8blQxFoCAPzaJBc+2knEhAq7gNGfxHGa+A== 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 6935C202DC for ; Fri, 24 May 2024 00:35:31 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sAH1b-0002X3-5w; Thu, 23 May 2024 18:35:03 -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 1sAH1U-0002WQ-VO for bug-guix@gnu.org; Thu, 23 May 2024 18:34:56 -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 1sAH1U-0007mT-7F for bug-guix@gnu.org; Thu, 23 May 2024 18:34:56 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sAH1a-0008In-JD for bug-guix@gnu.org; Thu, 23 May 2024 18:35:02 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#71153: [PATCH] gnu: Validate substitute URLs for guix service. Resent-From: Antero Mejr Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Thu, 23 May 2024 22:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 71153 X-GNU-PR-Package: guix X-GNU-PR-Keywords: patch To: 71153@debbugs.gnu.org X-Debbugs-Original-To: bug-guix@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.171650365631885 (code B ref -1); Thu, 23 May 2024 22:35:02 +0000 Received: (at submit) by debbugs.gnu.org; 23 May 2024 22:34:16 +0000 Received: from localhost ([127.0.0.1]:33117 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sAH0p-0008ID-PS for submit@debbugs.gnu.org; Thu, 23 May 2024 18:34:16 -0400 Received: from lists.gnu.org ([209.51.188.17]:53392) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sAH0m-0008I7-UQ for submit@debbugs.gnu.org; Thu, 23 May 2024 18:34:14 -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 1sAH0f-0002Gj-Mk for bug-guix@gnu.org; Thu, 23 May 2024 18:34:05 -0400 Received: from mout-p-103.mailbox.org ([2001:67c:2050:0:465::103]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim 4.90_1) (envelope-from ) id 1sAH0d-0007hi-Rc for bug-guix@gnu.org; Thu, 23 May 2024 18:34:05 -0400 Received: from smtp2.mailbox.org (smtp2.mailbox.org [10.196.197.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-103.mailbox.org (Postfix) with ESMTPS id 4VljdG6hgYz9sQb for ; Fri, 24 May 2024 00:33:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antr.me; s=MBO0001; t=1716503634; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=j1j3ix4ZZcH72BaAmYiEoXN5k9eL/aIK+58emn44tZU=; b=angDBtgcd/5WUSLVB09GDnTODZ4HM5pUvHcH4izsbYw35/umkaCjRGpsbq1LVi3R6lPtqu 5B5Fa55CjOqK5vM8wkuK43qFAyGJ50gSGgwVvzVcR6aJ15KOqJ+IcUrkVagaLjHWOiXQ2B hsRNctbXZ725RTizgZuwZ4WBDrc//te7epwuDOJvwtxaXEalWwrZ8m1icSOmdXd7XCzF5F 1s/crobiAkEexMqgOy5Z/ycSUgXgoA3lCOu750MX8YHRYgsTRLafVUkyHJo8zJHXs4X8VK iWRimsLQd2aVYfAstIqhc1jwXvvKPLLoW8wRRzyncrcgBQ9YmhpsMHceTawK5Q== From: Antero Mejr Date: Thu, 23 May 2024 22:33:42 +0000 Message-ID: <87cypcrwe1.fsf@antr.me> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2001:67c:2050:0:465::103; envelope-from=mail@antr.me; helo=mout-p-103.mailbox.org X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: bug-guix-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Queue-Id: 6935C202DC X-Migadu-Scanner: mx12.migadu.com X-Migadu-Spam-Score: 3.85 X-Spam-Score: 3.85 X-TUID: 9E2zn65kSAod * gnu/services/base.scm (guix-service-type): Validate `substitute-urls' field. Change-Id: I11ed74304ab02ae550db5479be9f02601857f294 --- If you forget to write "https://" when specifying a substitute URL in guix-configuration, the system will end up in a bad state where any `guix pull` or `guix reconfigure` operation immediately fail. It's difficult to fix, so validate the field to avoid the problem. gnu/services/base.scm | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/gnu/services/base.scm b/gnu/services/base.scm index 85160bd3ab..da26b86c83 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -99,6 +99,7 @@ (define-module (gnu services base) #:use-module (srfi srfi-35) #:use-module (ice-9 match) #:use-module (ice-9 format) + #:use-module (web uri) #:re-export (user-processes-service-type ;backwards compatibility %default-substitute-urls) #:export (fstab-service-type @@ -2075,6 +2076,11 @@ (define (guix-extension-merge a b) (chroot-directories (append (guix-extension-chroot-directories a) (guix-extension-chroot-directories b))))) +(define (validate-substitute-url url-str) + (if (string->uri url-str) + url-str + (error "Not a valid substitute URL: " url-str))) + (define guix-service-type (service-type (name 'guix) @@ -2093,8 +2099,10 @@ (define guix-service-type (inherit config) (authorized-keys (append (guix-extension-authorized-keys extension) (guix-configuration-authorized-keys config))) - (substitute-urls (append (guix-extension-substitute-urls extension) - (guix-configuration-substitute-urls config))) + (substitute-urls + (map validate-substitute-url + (append (guix-extension-substitute-urls extension) + (guix-configuration-substitute-urls config)))) (build-machines (and (or (guix-configuration-build-machines config) (pair? (guix-extension-build-machines extension))) base-commit: 9901416233867233192b63fde7f616751127b189 -- 2.41.0