NetBSD Problem Report #53458

From www@NetBSD.org  Wed Jul 18 06:09:59 2018
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id C405B7A182
	for <gnats-bugs@gnats.NetBSD.org>; Wed, 18 Jul 2018 06:09:59 +0000 (UTC)
Message-Id: <20180718060958.BF21C7A22E@mollari.NetBSD.org>
Date: Wed, 18 Jul 2018 06:09:58 +0000 (UTC)
From: triaxx@NetBSD.org
Reply-To: triaxx@NetBSD.org
To: gnats-bugs@NetBSD.org
Subject: usr.sbin/ypserv/ypinit: error while checking hostname
X-Send-Pr-Version: www-1.0

>Number:         53458
>Category:       bin
>Synopsis:       usr.sbin/ypserv/ypinit: error while checking hostname
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Jul 18 06:10:00 +0000 2018
>Closed-Date:    Fri Jul 27 14:27:50 +0000 2018
>Last-Modified:  Fri Jul 27 14:27:50 +0000 2018
>Originator:     Frédéric Fauberteau
>Release:        NetBSD-current
>Organization:
>Environment:
NetBSD defiler.triaxx.org 8.0_RC2 NetBSD 8.0_RC2 (XEN3_DOM0) #0: Tue Jul 10 12:50:33 UTC 2018  triaxx@defiler.triaxx.org:/usr/obj/sys/arch/amd64/compile/XEN3_DOM0 amd64
>Description:
When I intend to create a master NIS server, I get the following error:
defiler.triaxx.org: not found                                                                                                                                                                                                                                                   
ypinit: The local host's hostname has not been set.                                                                                                                                                                                                                             
        Please set it with the hostname(1) command.

But the hostname is correctly set:
# grep hostname /etc/rc.conf                                                                                                                                                                                                                                             
hostname=defiler.triaxx.org
# hostname                                                                                                                                                                                                                                                               
defiler.triaxx.org

After inspecting /usr/sbin/ypinit, the line 98 sounds strange to me:
 97 # Check if hostname is set, don't accept an empty hostname
 98 host=`${HOSTNAME}`
 99 if [ -z "${host}" ]; then

The fix seems obvious but I prefer send this PR for validation since I never touch ypserv before.
>How-To-Repeat:
# ypinit -m
>Fix:
cvs diff: Diffing usr.sbin/ypserv/ypinit
Index: usr.sbin/ypserv/ypinit/ypinit.sh
===================================================================
RCS file: /cvsroot/src/usr.sbin/ypserv/ypinit/ypinit.sh,v
retrieving revision 1.12
diff -u -r1.12 ypinit.sh
--- usr.sbin/ypserv/ypinit/ypinit.sh	5 Oct 2004 11:35:35 -0000	1.12
+++ usr.sbin/ypserv/ypinit/ypinit.sh	18 Jul 2018 05:54:41 -0000
@@ -95,7 +95,7 @@
 fi

 # Check if hostname is set, don't accept an empty hostname
-host=`${HOSTNAME}`
+host=`echo ${HOSTNAME}`
 if [ -z "${host}" ]; then
 	cat 1>&2 << __no_hostname
 $progname: The local host's hostname has not been set.

>Release-Note:

>Audit-Trail:
From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/53458: usr.sbin/ypserv/ypinit: error while checking hostname
Date: Wed, 18 Jul 2018 08:24:24 +0200

 On Wed, Jul 18, 2018 at 06:10:00AM +0000, triaxx@NetBSD.org wrote:
 > After inspecting /usr/sbin/ypinit, the line 98 sounds strange to me:
 >  97 # Check if hostname is set, don't accept an empty hostname
 >  98 host=`${HOSTNAME}`
 >  99 if [ -z "${host}" ]; then

 Earlier there is:

 HOSTNAME=/bin/hostname

 so this shold run /bin/hostname and store the output in "host".
 Looks perfectly fine to me. Can you run it with "sh -x /usr/sbin/ypinit"
 and see what goes wrong?

 Martin

From: christos@zoulas.com (Christos Zoulas)
To: gnats-bugs@NetBSD.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Cc: 
Subject: Re: bin/53458: usr.sbin/ypserv/ypinit: error while checking hostname
Date: Wed, 18 Jul 2018 07:00:12 -0400

 On Jul 18,  6:10am, triaxx@NetBSD.org (triaxx@NetBSD.org) wrote:
 -- Subject: bin/53458: usr.sbin/ypserv/ypinit: error while checking hostname

 | After inspecting /usr/sbin/ypinit, the line 98 sounds strange to me:

 [...]

 | -host=`${HOSTNAME}`
 | +host=`echo ${HOSTNAME}`

 HOSTNAME=/bin/hostname
 So after your patch host will contain /bin/hostname, which is not empty
 but not correct.

 christos

From: =?UTF-8?Q?Fr=C3=A9d=C3=A9ric_Fauberteau?= <triaxx@NetBSD.org>
To: gnats-bugs@NetBSD.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Cc: Martin Husemann <martin@duskware.de>, christos@zoulas.com
Subject: Re: bin/53458: usr.sbin/ypserv/ypinit: error while checking hostname
Date: Fri, 20 Jul 2018 12:53:41 +0200

 *Sorry for this from-scratch-mail, but I didn't subscribe the right ml*

 defiler# sh -x /usr/sbin/ypinit -m
 + '[' -f /etc/shrc ']'
 + . /etc/shrc
 + 
 PATH='/bin:/usr/sbin:/usr/bin:/sbin:/usr/sbin:/bin:/usr/bin:/usr/pkg/sbin:/usr/pkg/bin:/usr/X11R7/bin:/usr/local/sbin:/usr/local/bin'
 + DOMAINNAME=/bin/domainname
 + HOSTNAME=/bin/hostname
 + ID=/usr/bin/id
 + INSTALL=/usr/bin/install
 + MAKEDBM=/usr/sbin/makedbm
 + YPWHICH=/usr/bin/ypwhich
 + YPXFR=/usr/sbin/ypxfr
 + basename /usr/sbin/ypinit
 + progname=ypinit
 + yp_dir=/var/yp
 + mktemp /tmp/ypservers.XXXXXX
 + tmpfile=/tmp/ypservers.78GZ3v
 + trap 'rm -f /tmp/ypservers.78GZ3v ; exit 0' EXIT INT QUIT
 + umask 077
 + /usr/bin/id -u
 + '[' 0 '!=' 0 ']'
 + getopt 'cl:ms:' -m
 + args=' -m --'
 + '[' 0 -eq 0 ']'
 + set -- -m --
 + for i=-m
 + servertype=master
 + shift
 + for i=--
 + shift
 + break
 + '[' 0 -eq 1 ']'
 + /bin/domainname
 + domain=triaxx
 + '[' -z master ']'
 + '[' -z triaxx ']'
 + defiler.triaxx.org
 defiler.triaxx.org: not found
 + host=''
 + '[' -z '' ']'
 + cat >&2 <<...
 ypinit: The local host's hostname has not been set.
          Please set it with the hostname(1) command.
 + exit 1
 + rm -f /tmp/ypservers.78GZ3v
 + exit 0

 I don't really understand why the following script:
 #!/bin/sh
 HOSTNAME=foo
 echo ${HOSTNAME}

 produces the following output:
 defiler.triaxx.org

From: Robert Elz <kre@munnari.OZ.AU>
To: =?UTF-8?Q?Fr=C3=A9d=C3=A9ric_Fauberteau?= <triaxx@NetBSD.org>
Cc: gnats-bugs@NetBSD.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org,
        Martin Husemann <martin@duskware.de>, christos@zoulas.com
Subject: Re: bin/53458: usr.sbin/ypserv/ypinit: error while checking hostname
Date: Fri, 20 Jul 2018 19:41:27 +0700

     Date:        Fri, 20 Jul 2018 12:53:41 +0200
     From:        =?UTF-8?Q?Fr=C3=A9d=C3=A9ric_Fauberteau?= <triaxx@NetBSD.org>
     Message-ID:  <3a0d2be66f8647ce8f31645ae18e72b9@NetBSD.org>

   | I don't really understand why the following script:
   | #!/bin/sh
   | HOSTNAME=foo
   | echo ${HOSTNAME}
   |
   | produces the following output:
   | defiler.triaxx.org

 You are running into a feature of the NetBSD shell, ${HOSTNAME} is a built
 in variable, that always expands to (effectively the same as) $(/bin/hostname)
 (It doesn't matter what is assigned to it, that is ignored ... though I guess 
 there is some argument to change that).

 This is documented in sh(1) ...

      HOSTNAME   Set to the current hostname of the system, as returned by
                 gethostname(3).  This is obtained each time HOSTNAME is
                 expanded, so changes to the system's name are reflected
                 without further action.  If unset, it returns nothing.
                 Setting it does nothing except reverse the effect of an
                 earlier unset.

 It is intended (mostly) for use in PS1 (and similar places), often as 
 ${HOSTNAME%%.*}

 kre

From: "Robert Elz" <kre@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/53458 CVS commit: src/usr.sbin/ypserv/ypinit
Date: Fri, 20 Jul 2018 13:11:01 +0000

 Module Name:	src
 Committed By:	kre
 Date:		Fri Jul 20 13:11:01 UTC 2018

 Modified Files:
 	src/usr.sbin/ypserv/ypinit: ypinit.sh

 Log Message:
 PR bin/53458

 Bring this script a little up to date - make it work with modern /bin/sh
 (avoid HOSTNAME as a random variable) clean up trailing spaces on lines,
 use $( ) instead of `` ...


 To generate a diff of this commit:
 cvs rdiff -u -r1.12 -r1.13 src/usr.sbin/ypserv/ypinit/ypinit.sh

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->feedback
State-Changed-By: maya@NetBSD.org
State-Changed-When: Sat, 21 Jul 2018 21:28:52 +0000
State-Changed-Why:
Want a status other than 'open'. Does this work? we should pull it up, if so.


From: =?UTF-8?Q?Fr=C3=A9d=C3=A9ric_Fauberteau?= <triaxx@NetBSD.org>
To: gnats-bugs@netbsd.org
Cc: gnats-admin@netbsd.org, netbsd-bugs@netbsd.org, maya@netbsd.org
Subject: Re: bin/53458 (usr.sbin/ypserv/ypinit: error while checking hostname)
Date: Wed, 25 Jul 2018 11:20:17 +0200

 Le 2018-07-21 23:28, maya@NetBSD.org a écrit :
 > Synopsis: usr.sbin/ypserv/ypinit: error while checking hostname
 > 
 > State-Changed-From-To: open->feedback
 > State-Changed-By: maya@NetBSD.org
 > State-Changed-When: Sat, 21 Jul 2018 21:28:52 +0000
 > State-Changed-Why:
 > Want a status other than 'open'. Does this work? we should pull it up, 
 > if so.
 It works now for me and it can be pulled up.
 Thx!

State-Changed-From-To: feedback->needs-pullups
State-Changed-By: maya@NetBSD.org
State-Changed-When: Wed, 25 Jul 2018 09:27:15 +0000
State-Changed-Why:
works, thanks kre. Now we need to pull it up.


State-Changed-From-To: needs-pullups->pending-pullups
State-Changed-By: kre@NetBSD.org
State-Changed-When: Wed, 25 Jul 2018 14:26:25 +0000
State-Changed-Why:
pullup-8 #943 requested.


From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/53458 CVS commit: [netbsd-8] src/usr.sbin/ypserv/ypinit
Date: Fri, 27 Jul 2018 10:52:04 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Fri Jul 27 10:52:04 UTC 2018

 Modified Files:
 	src/usr.sbin/ypserv/ypinit [netbsd-8]: ypinit.sh

 Log Message:
 Pull up following revision(s) (requested by kre in ticket #943):

 	usr.sbin/ypserv/ypinit/ypinit.sh: revision 1.13

 PR bin/53458

 Bring this script a little up to date - make it work with modern /bin/sh
 (avoid HOSTNAME as a random variable) clean up trailing spaces on lines,
 use $( ) instead of `` ...


 To generate a diff of this commit:
 cvs rdiff -u -r1.12 -r1.12.82.1 src/usr.sbin/ypserv/ypinit/ypinit.sh

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: pending-pullups->closed
State-Changed-By: kre@NetBSD.org
State-Changed-When: Fri, 27 Jul 2018 14:27:50 +0000
State-Changed-Why:
Pullups completed


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.