Hello,

I had a look through the glibc history. Roland McGrath's ChangeLog
entry for 1998-07-20 records the addition of the Hurd getdomain.c
and setdomain.c. It doesn't say why that particular name was chosen.

One detail that may help is that on the Hurd, getdomainname() reads
/etc/nisdomain directly, and setdomainname() writes it. On Debian
GNU/Linux, /etc/defaultdomain supplies the NIS domain to set at boot.
That explains the different roles of the files, though I couldn't
find a record of why the Hurd implementation chose /etc/nisdomain.

Best regards,
Alperen

[1] https://git.zx2c4.com/glibc/tree/ChangeLog.old/ChangeLog.8
    (Roland McGrath's entry for 1998-07-20)

On Tue, Dec 1, 2026 at 3:03 AM Samuel Thibault <[email protected]>
wrote:

> [email protected], le lun. 30 nov. 2026 14:41:00 +0100, a ecrit:
> > See attached patch. I also expanded the comment with a note that there
> needs to be space for a trailing NUL to explain the asymmetry between the
> setter and getter.
>
> Appied, thanks!
>
> > For the domainname/hostname setters they work with potentially not
> nul-terminated strings and for the getters the caller has to provide a
> buffer that "will be big enough" to fit the value + NUL.By design the
> hostid has a fixed length so this would be never a problem here.
> > Tangentially related do you know why the NIS domain gets stored in
> /etc/nisdomain while debian uses /etc/defaultdomain for this (the
> nis.debian.howto mentions this is a convention inherited from
> sunos/solaris)?
>
> I don't know.
>
> Samuel
>
> >  Y.
> > Nov 29, 2026, 20:27 by [email protected]:
> >
> > > yelninei--- via Bug reports for the GNU Hurd, le dim. 29 nov. 2026
> 21:25:14 +0100, a ecrit:
> > >
> > >> I have rebuilt my libc with a patch to just increase the buffer size
> from 8 to 9 to have space for the NUL and can confirm that it is enough to
> fix the issue.
> > >>
> > >> As Alperen Erkan was faster to send a diff should they make that a
> proper patch you can apply or should I do that?
> > >>
> > >
> > > Whichever does it first is fine :) there is no authorship on such a
> > > small modification.
> > >
> > > Samuel
> > >
> > >> Thanks,
> > >> Y.
> > >>
> > >> Nov 29, 2026, 14:25 by [email protected]:
> > >>
> > >> > Hello,
> > >> >
> > >> > yelninei--- via Bug reports for the GNU Hurd, le sam. 28 nov. 2026
> 21:28:33 +0100, a ecrit:
> > >> >
> > >> >> - After a successfull sethostid () /etc/hostid has the id in hex.
> > >> >> - gethostid fails to read it back. _hurd_get_host_config fails
> with ENAMETOOLONG causing gethostid to return -1.
> > >> >>
> > >> >> The reason is that _hurd_get_host_config always tries to
> null-terminate the given buffer however gethostid passes a buffer that is
> just large enough to contain the contents as the id has a fixed size and a
> trailing null is not really neccessary.
> > >> >>
> > >> >> Should that just use a bigger buffer?
> > >> >>
> > >> >
> > >> > That should be fine yes.
> > >> >
> > >> >> I dont know if this ever worked or if the hostid was a casualty of
> making sure the return is null-terminated which seems reasonable for the
> hostname as the hostid is not really used much.
> > >> >>
> > >> >
> > >> > _hurd_get_host_config probably got modified at some point without
> > >> > checking whether gethostid is still working.
> > >> >
> > >> > Samuel
> > >> >
> > >>
> > >
> > > --
> > > Samuel
> > > Fatal Error: Found [MS-Windows] System -> Repartitioning Disk for
> Linux...
> > > (By [email protected], Christopher Browne)
> > >
> >
>
> > From ebd2f0113c55372604e544af2943f5e362dadf65 Mon Sep 17 00:00:00 2001
> > From: Yelninei <[email protected]>
> > Date: Mon, 30 Nov 2026 12:57:49 +0000
> > Subject: [PATCH] hurd: gethostid: Fix reading /etc/hostid.
> >
> > Provide a big enough buffer for _hurd_get_host_config to NUL-terminate
> > the contents.
> > ---
> >  sysdeps/mach/hurd/gethostid.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/sysdeps/mach/hurd/gethostid.c
> b/sysdeps/mach/hurd/gethostid.c
> > index c4f8a102f9..fa2508208d 100644
> > --- a/sysdeps/mach/hurd/gethostid.c
> > +++ b/sysdeps/mach/hurd/gethostid.c
> > @@ -24,9 +24,10 @@ long int
> >  gethostid (void)
> >  {
> >    /* The hostid is just the contents of the file /etc/hostid,
> > -     kept as text of hexadecimal digits.  */
> > +     kept as text of eight hexadecimal digits,
> > +     including space for a NUL-terminator.  */
> >    /* XXX this is supposed to come from the hardware serial number */
> > -  char buf[8];
> > +  char buf[9];
> >    ssize_t n = _hurd_get_host_config ("/etc/hostid", buf, sizeof buf);
> >    if (n < 0)
> >      return -1;
> > --
> > 2.55.0
> >
>
>
> --
> Samuel
> "...Deep Hack Mode--that mysterious and frightening state of
> consciousness where Mortal Users fear to tread."
> (By Matt Welsh)
>
>

Reply via email to