GNU bug report logs -
#60735
[PATCH 0/2] Implement etc-hosts-service-type
Previous Next
Reported by: Bruno Victal <mirai <at> makinata.eu>
Date: Wed, 11 Jan 2023 17:27:02 UTC
Severity: normal
Tags: patch
Done: Ludovic Courtès <ludo <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Your message dated Thu, 09 Feb 2023 00:57:39 +0100
with message-id <87zg9nvhfw.fsf_-_ <at> gnu.org>
and subject line Re: bug#60735: [PATCH 0/2] Implement etc-hosts-service-type
has caused the debbugs.gnu.org bug report #60735,
regarding [PATCH 0/2] Implement etc-hosts-service-type
to be marked as done.
(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)
--
60735: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=60735
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
This patch-set introduces etc-hosts-service-type which allows for /etc/hosts to be
extended with service-extensions.
As an example of such a service, %facebook-host-aliases was used as a base for
the new block-facebook-hosts-service-type.
Indirectly solves #59700.
Bruno Victal (2):
services: Add etc-hosts-service-type.
services: Add block-facebook-hosts-service-type.
doc/guix.texi | 42 ++++++++++++-------------
gnu/services.scm | 18 +++++++++++
gnu/services/networking.scm | 61 ++++++++++++++++++-------------------
gnu/system.scm | 55 ++++++++++++++++++++++++---------
4 files changed, 107 insertions(+), 69 deletions(-)
base-commit: c42ae60a84f0e7c30126f726a0057781b81f5074
--
2.38.1
[Message part 3 (message/rfc822, inline)]
[Message part 4 (text/plain, inline)]
Hi Bruno,
I’ve finally applied this v3 with the changes below:
• spelling “host name” as two words and tweaking docstrings of public
procedures;
• keeping ‘local-host-aliases’ unchanged (returning a string) as this
is public and documented, and adding ‘local-host-entries’ to return
a list of <host> records;
• referencing to ‘%operating-system-hosts-file’ (with leading percent
sign) internally to avoid deprecation warnings.
Thank you!
Ludo’.
[Message part 5 (text/x-patch, 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> %host
(sanitize (cut map assert-valid-name <>))))
(define* (host address canonical-name #:optional (aliases '()))
- "Public constructor for <host> 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 <host> records for @var{host-name}."
(map (lambda (address)
(host address "localhost" (list host-name)))
'("127.0.0.1" "::1")))
This bug report was last modified 2 years and 99 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.