GNU bug report logs - #60735
[PATCH 0/2] Implement etc-hosts-service-type

Previous Next

Package: guix-patches;

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


Message #35 received at 60735 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Bruno Victal <mirai <at> makinata.eu>
Cc: 60735 <at> debbugs.gnu.org
Subject: Re: [PATCH v2 1/3] services: Add etc-hosts-service-type.
Date: Mon, 23 Jan 2023 23:47:35 +0100
Bruno Victal <mirai <at> makinata.eu> skribis:

> * gnu/services.scm (etc-hosts-service-type): New variable.
> * doc/guix.texi: Document it.

Other things that crossed my mind; sorry for not noticing earlier!

> +++ b/gnu/services.scm

Should this be in (gnu services base) instead?

> +     (make-compound-condition
> +      (formatted-message (G_ "hostname '~a' contains invalid characters.")

No period please.

> +(define-record-type* <host-entry> host-entry
> +  make-host-entry host-entry?
> +  (address        host-entry-address)
> +  (canonical-name host-entry-canonical-name
> +                  (sanitize assert-valid-name))
> +  (aliases        host-entry-aliases
> +                  (default '())
> +                  (sanitize (cut map assert-valid-name <>))))
> +
> +(define* (host address canonical-name #:optional (aliases '()))
> +  "More compact way of creating <host> records"
> +  (make-host-entry address canonical-name aliases))

I just realized that ‘make-host-entry’ won’t run any sanitizer, oops!
So you have to use ‘host-entry’:

--8<---------------cut here---------------start------------->8---
scheme@(guile-user)> (define-record-type* <host-entry> host-entry
  make-host-entry host-entry?
  (address        host-entry-address)
  (canonical-name host-entry-canonical-name
                  (sanitize assert-valid-name))
  (aliases        host-entry-aliases
                  (default '())
                  (sanitize (cut map assert-valid-name <>))))

scheme@(guile-user)> ,optimize (make-host-entry 1 2 3)
$12 = (make-struct/simple #{% <host-entry> rtd}# 1 2 3)
scheme@(guile-user)> ,optimize (host-entry (address 1) (canonical-name 2))
$13 = (let ((canonical-name (assert-valid-name 2)))
  (if (eq? #{% <host-entry> abi-cookie}#
           796283273607885551)
    (if #f #f)
    (throw 'record-abi-mismatch-error
           'abi-check
           "~a: record ABI mismatch; recompilation needed"
           (list #{% <host-entry> rtd}#)
           '()))
  (let ((aliases ((cut map assert-valid-name <>) '())))
    (make-struct/simple
      #{% <host-entry> rtd}#
      1
      canonical-name
      aliases)))
--8<---------------cut here---------------end--------------->8---

Also, there’s a naming confusion between ‘host’ and ‘host-entry’; you
should choose one or the other IMO.

Thanks,
Ludo’.




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.