From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id WGT6OSM35GMhlAAAbAwnHQ (envelope-from ) for ; Thu, 09 Feb 2023 00:58:28 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id 6A40OSM35GO3HAAAG6o9tA (envelope-from ) for ; Thu, 09 Feb 2023 00:58:27 +0100 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 1EB46E6EE for ; Thu, 9 Feb 2023 00:58:27 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pPuKC-0005Nt-Ee; Wed, 08 Feb 2023 18:58:04 -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 1pPuKB-0005Nb-34 for guix-patches@gnu.org; Wed, 08 Feb 2023 18:58:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pPuKA-0004r7-Dg for guix-patches@gnu.org; Wed, 08 Feb 2023 18:58:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pPuK9-0000C0-PP for guix-patches@gnu.org; Wed, 08 Feb 2023 18:58:01 -0500 Subject: bug#60735: [PATCH 0/2] Implement etc-hosts-service-type Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-To: guix-patches@gnu.org Resent-Date: Wed, 08 Feb 2023 23:58:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 60735 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Bruno Victal Cc: 60735-done@debbugs.gnu.org Mail-Followup-To: 60735@debbugs.gnu.org, ludo@gnu.org, mirai@makinata.eu Received: via spool by 60735-done@debbugs.gnu.org id=D60735.1675900675723 (code D ref 60735); Wed, 08 Feb 2023 23:58:01 +0000 Received: (at 60735-done) by debbugs.gnu.org; 8 Feb 2023 23:57:55 +0000 Received: from localhost ([127.0.0.1]:56898 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pPuK2-0000BP-BC for submit@debbugs.gnu.org; Wed, 08 Feb 2023 18:57:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37462) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pPuJx-0000B8-8k for 60735-done@debbugs.gnu.org; Wed, 08 Feb 2023 18:57:53 -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 1pPuJr-0004le-D3; Wed, 08 Feb 2023 18:57:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=6uO+dyD0+WSQ518m2v5NVQRvfTvr97tI6CPWFY/2BhE=; b=X1QSvUNgG/RvGT0qVasb 45MDqjQCF87jm5kQCUObmmtvWlTcVvmcZpm7QeX4crtO38Fnf/C1fyce6RCTyE4wWcwNpv/QbtA6O bBUofQ/nVfNxjj/RztmHGL4VgSOCcNI4Jcucjps7vx2TSwOtdml4WCQl5WjkX16BeFVDrclLfzj4m bI53iQxsArXpDZ1hXU15ZU4o021NpWhGpQIuY+zu8TRcFIxbgVfAqss5qMt1v9yA7p0HU7DVSYbHP 7ZZJLTt3fE2+SOjtwMb6Oc0uDxZjo6mmUA46zKFrKbdq04ky2W3tYHccy98RGSmmj1pbXZaMlN5oK Mn6sC7M2ijmAMQ==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201] helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pPuJq-0008P2-Td; Wed, 08 Feb 2023 18:57:43 -0500 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <23c3ca682838a1722e619148bac0aee88124d212.1674853530.git.mirai@makinata.eu> <55ce2a77151a50d5e6e179ce53b437a3d0dc6d2b.1674853530.git.mirai@makinata.eu> Date: Thu, 09 Feb 2023 00:57:39 +0100 In-Reply-To: <55ce2a77151a50d5e6e179ce53b437a3d0dc6d2b.1674853530.git.mirai@makinata.eu> (Bruno Victal's message of "Fri, 27 Jan 2023 21:06:13 +0000") Message-ID: <87zg9nvhfw.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" 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+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Seal: i=1; s=key1; d=yhetil.org; t=1675900707; a=rsa-sha256; cv=none; b=PpBSlgyJYkJH/p6IhY4PKtFkCnSNNcaFtIp5VkyBb9vra+zDJd0+AgAUOaX436aFZWpt64 zdoaMpiUDY9hsiVkvW9/Ly+WZgc+pitbvSPZYYWAGnrIVW43eR+NwqgoFsuYjMn9K+l7D1 DHnAms1LwQYAfwmt4HOcecsDBIJ1PmxLLo6x//MgIITuiHLlHwMzmGgQEMy+g2I8CgBTbS l9PKWa9ajn18bHWvNpwuHurcUDjMboamKiVBlsKqy+2G+bxb/yHrQu25PVv4SUX4jeFWkL SCigaWHX00QloDvENErcAmyH6pRHikOhBAhHqDq/GwTdHs/ijVu/6Qu3up2tcg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=X1QSvUNg; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1675900707; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:resent-to:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=6uO+dyD0+WSQ518m2v5NVQRvfTvr97tI6CPWFY/2BhE=; b=doklFCUxHiaU1mRy1+lgSze5LUSqqAd4jDLFTsY+acEaAC5X7OJhAY0BS/2LU3MrSH1apj UAW522mvwy/x29mHHc8KMylcotKaoEARvTmD1ZSKDoAJAliMZxlB4g58bOvfICZbgV9oik 3VpaKqD6/57kU5h+4iDdlOM+TeSBQV9AvqePeJ9iRJ124OjJhb8blimI1ivQWyHP8OzjUy 43JsZUx2yyjRKBwVZL4NqvBBNUa9zvWAXsyAJpidprwuAXRf/oRX7fqYIT6xCfVZWpqnQs 47Csipq2FoRs+rd69jhkXPuNbyOmsGZamHPZ6p6X+korr90f7wwrxml+jaX/Cw== X-Migadu-Queue-Id: 1EB46E6EE X-Migadu-Scanner: scn1.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=X1QSvUNg; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org X-Migadu-Spam-Score: -3.00 X-Spam-Score: -3.00 X-TUID: b42dczfDVRC0 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Bruno, I=E2=80=99ve finally applied this v3 with the changes below: =E2=80=A2 spelling =E2=80=9Chost name=E2=80=9D as two words and tweaking = docstrings of public procedures; =E2=80=A2 keeping =E2=80=98local-host-aliases=E2=80=99 unchanged (returni= ng a string) as this is public and documented, and adding =E2=80=98local-host-entries=E2=80= =99 to return a list of records; =E2=80=A2 referencing to =E2=80=98%operating-system-hosts-file=E2=80=99 (= with leading percent sign) internally to avoid deprecation warnings. Thank you! Ludo=E2=80=99. --=-=-= Content-Type: text/x-patch Content-Disposition: inline diff --git a/doc/guix.texi b/doc/guix.texi index 5edc0d20cc..2b21e12b88 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -40246,10 +40246,7 @@ from being an alias of @code{localhost}. (operation-system-default-essential-services this-operating-system) (hosts-service-type config => (list (host "127.0.0.1" "localhost") - (host "::1" "localhost"))))) - - ;; @dots{} -) + (host "::1" "localhost")))))) @end lisp @end quotation diff --git a/gnu/services/base.scm b/gnu/services/base.scm index 53eda9ea1e..e9fdafd5d0 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -700,16 +700,16 @@ (define* (rngd-service #:key ;;; (define (valid-name? name) - "Return true if @var{name} is likely to be a valid hostname." + "Return true if @var{name} is likely to be a valid host name." (false-if-exception (not (string-any char-set:whitespace name)))) (define-compile-time-procedure (assert-valid-name (name valid-name?)) - "Ensure @var{name} is likely to be a valid hostname." + "Ensure @var{name} is likely to be a valid host name." ;; TODO: RFC compliant implementation. (unless (valid-name? name) (raise (make-compound-condition - (formatted-message (G_ "hostname '~a' contains invalid characters") + (formatted-message (G_ "host name '~a' contains invalid characters") name) (condition (&error-location (location @@ -728,7 +728,12 @@ (define-record-type* %host (sanitize (cut map assert-valid-name <>)))) (define* (host address canonical-name #:optional (aliases '())) - "Public constructor for records." + "Return a new record for the host at @var{address} with the given +@var{canonical-name} and possibly @var{aliases}. + +@var{address} must be a string denoting a valid IPv4 or IPv6 address, and +@var{canonical-name} and the strings listed in @var{aliases} must be valid +host names." (%host (address address) (canonical-name canonical-name) diff --git a/gnu/system.scm b/gnu/system.scm index e8904cfab7..df60fda53b 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -170,7 +170,8 @@ (define-module (gnu system) read-boot-parameters-file boot-parameters->menu-entry - local-host-aliases + local-host-aliases ;deprecated + local-host-entries %root-account %setuid-programs %sudoers-specification @@ -749,7 +750,7 @@ (define known-fs (swaps (swap-services os)) (procs (service user-processes-service-type)) (host-name (operating-system-host-name os)) - (hosts-file (operating-system-hosts-file os)) + (hosts-file (%operating-system-hosts-file os)) (entries (operating-system-directory-base-entries os))) (cons* (service system-service-type entries) (service linux-builder-service-type @@ -776,7 +777,7 @@ (define known-fs (simple-service 'deprecated-hosts-file etc-service-type (list `("hosts" ,hosts-file))) (service hosts-service-type - (local-host-aliases host-name))) + (local-host-entries host-name))) (service fstab-service-type (filter file-system-needed-for-boot? (operating-system-file-systems os))) @@ -798,7 +799,7 @@ (define known-fs (define (hurd-default-essential-services os) (let ((host-name (operating-system-host-name os)) - (hosts-file (operating-system-hosts-file os)) + (hosts-file (%operating-system-hosts-file os)) (entries (operating-system-directory-base-entries os))) (list (service system-service-type entries) %boot-service @@ -824,7 +825,7 @@ (define (hurd-default-essential-services os) (simple-service 'deprecated-hosts-file etc-service-type (list `("hosts" ,hosts-file))) (service hosts-service-type - (local-host-aliases host-name))) + (local-host-entries host-name))) (service setuid-program-service-type (operating-system-setuid-programs os)) (service profile-service-type (operating-system-packages os))))) @@ -943,8 +944,14 @@ (define %default-issue " This is the GNU system. Welcome.\n") -(define (local-host-aliases host-name) +(define-deprecated (local-host-aliases host-name) + local-host-entries "Return aliases for HOST-NAME, to be used in /etc/hosts." + (string-append "127.0.0.1 localhost " host-name "\n" + "::1 localhost " host-name "\n")) + +(define (local-host-entries host-name) + "Return records for @var{host-name}." (map (lambda (address) (host address "localhost" (list host-name))) '("127.0.0.1" "::1"))) --=-=-=--