NetBSD Problem Report #53813
From www@NetBSD.org Wed Dec 26 06:28:12 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 99F917A154
for <gnats-bugs@gnats.NetBSD.org>; Wed, 26 Dec 2018 06:28:12 +0000 (UTC)
Message-Id: <20181226062811.403BB7A1E3@mollari.NetBSD.org>
Date: Wed, 26 Dec 2018 06:28:11 +0000 (UTC)
From: edgar@pettijohn-web.com
Reply-To: edgar@pettijohn-web.com
To: gnats-bugs@NetBSD.org
Subject: ntpdate should print usage if not provided a server on commandline
X-Send-Pr-Version: www-1.0
>Number: 53813
>Category: bin
>Synopsis: ntpdate should print usage if not provided a server on commandline
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Dec 26 06:30:00 +0000 2018
>Closed-Date: Mon Apr 08 18:37:00 +0000 2019
>Last-Modified: Mon Apr 08 18:37:00 +0000 2019
>Originator: Edgar Pettijohn
>Release: 8.0 Wed Dec 26 00:21:57 CST 2018
>Organization:
>Environment:
NetBSD netbsd.my.domain 8.0 NetBSD 8.0 (GENERIC) #0: Tue Jul 17 14:59:51 UTC 2018 mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC amd64
>Description:
If you start ntpdate without any arguments you get this helpful text:
ntpdate[23355]: no servers can be used, exiting
If provided with the "usage" text it would be easier for the user to discover their mistake.
>How-To-Repeat:
# ntpdate
>Fix:
Print the usage text instead.
Index: ntpdate.c
===================================================================
RCS file: /cvsroot/src/external/bsd/ntp/dist/ntpdate/ntpdate.c,v
retrieving revision 1.11
diff -u -r1.11 ntpdate.c
--- ntpdate.c 13 Apr 2017 20:17:42 -0000 1.11
+++ ntpdate.c 26 Dec 2018 06:16:56 -0000
@@ -432,7 +432,7 @@
break;
}
- if (errflg) {
+ if (errflg || sys_numservers == 0) {
(void) fprintf(stderr,
"usage: %s [-46bBdqsuv] [-a key#] [-e delay] [-k file] [-p samples] [-o version#] [-t timeo] server ...\n",
progname);
@@ -499,11 +499,6 @@
}
#endif
- if (sys_numservers == 0) {
- msyslog(LOG_ERR, "no servers can be used, exiting");
- exit(1);
- }
-
/*
* Initialize the time of day routines and the I/O subsystem
*/
>Release-Note:
>Audit-Trail:
From: Manuel Bouyer <bouyer@antioche.eu.org>
To: gnats-bugs@NetBSD.org
Cc: gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: bin/53813: ntpdate should print usage if not provided a server
on commandline
Date: Wed, 26 Dec 2018 10:12:43 +0100
On Wed, Dec 26, 2018 at 06:30:00AM +0000, edgar@pettijohn-web.com wrote:
> If you start ntpdate without any arguments you get this helpful text:
>
> ntpdate[23355]: no servers can be used, exiting
>
> If provided with the "usage" text it would be easier for the user to discover their mistake.
You don't have to provide a server on command line, it can use the servers
from ntp.conf. The above message can be because of e.g. transient network
failure.
--
Manuel Bouyer <bouyer@antioche.eu.org>
NetBSD: 26 ans d'experience feront toujours la difference
--
From: edgar@pettijohn-web.com
To: gnats-bugs@NetBSD.org, netbsd-bugs@netbsd.org, bouyer@antioche.eu.org
Cc: gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: bin/53813: ntpdate should print usage if not provided a server
on commandline
Date: Wed, 26 Dec 2018 09:12:41 -0600
On Wed, Dec 26, 2018 at 09:15:00AM +0000, Manuel Bouyer wrote:
> The following reply was made to PR bin/53813; it has been noted by GNATS.
>
> From: Manuel Bouyer <bouyer@antioche.eu.org>
> To: gnats-bugs@NetBSD.org
> Cc: gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
> Subject: Re: bin/53813: ntpdate should print usage if not provided a server
> on commandline
> Date: Wed, 26 Dec 2018 10:12:43 +0100
>
> On Wed, Dec 26, 2018 at 06:30:00AM +0000, edgar@pettijohn-web.com wrote:
> > If you start ntpdate without any arguments you get this helpful text:
> >
> > ntpdate[23355]: no servers can be used, exiting
> >
> > If provided with the "usage" text it would be easier for the user to discover their mistake.
>
> You don't have to provide a server on command line, it can use the servers
> from ntp.conf. The above message can be because of e.g. transient network
> failure.
>
> --
> Manuel Bouyer <bouyer@antioche.eu.org>
> NetBSD: 26 ans d'experience feront toujours la difference
> --
>
I don't see anywhere that it opens ntp.conf. There is a loadservers() defined
in ntpdate.h, but doesn't appear to be used anywhere.
deathstar$ for i in 1 2 3 4 5 6 6 8 9
> do
> sleep 5 && sudo ntpdate
> done
26 Dec 09:07:46 ntpdate[21316]: no servers can be used, exiting
26 Dec 09:07:51 ntpdate[2749]: no servers can be used, exiting
26 Dec 09:07:56 ntpdate[19587]: no servers can be used, exiting
26 Dec 09:08:01 ntpdate[10166]: no servers can be used, exiting
26 Dec 09:08:06 ntpdate[26607]: no servers can be used, exiting
26 Dec 09:08:11 ntpdate[7338]: no servers can be used, exiting
26 Dec 09:08:16 ntpdate[2113]: no servers can be used, exiting
26 Dec 09:08:21 ntpdate[13595]: no servers can be used, exiting
26 Dec 09:08:26 ntpdate[2840]: no servers can be used, exiting
deathstar$ sudo ntpdate 0.netbsd.pool.ntp.org
26 Dec 09:09:03 ntpdate[7742]: adjust time server 104.238.179.228 offset 0.033862 sec
From: Manuel Bouyer <bouyer@antioche.eu.org>
To: edgar@pettijohn-web.com
Cc: gnats-bugs@NetBSD.org, netbsd-bugs@netbsd.org, gnats-admin@netbsd.org
Subject: Re: bin/53813: ntpdate should print usage if not provided a server
on commandline
Date: Wed, 26 Dec 2018 16:53:36 +0100
On Wed, Dec 26, 2018 at 09:12:41AM -0600, edgar@pettijohn-web.com wrote:
> On Wed, Dec 26, 2018 at 09:15:00AM +0000, Manuel Bouyer wrote:
> > The following reply was made to PR bin/53813; it has been noted by GNATS.
> >
> > From: Manuel Bouyer <bouyer@antioche.eu.org>
> > To: gnats-bugs@NetBSD.org
> > Cc: gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
> > Subject: Re: bin/53813: ntpdate should print usage if not provided a server
> > on commandline
> > Date: Wed, 26 Dec 2018 10:12:43 +0100
> >
> > On Wed, Dec 26, 2018 at 06:30:00AM +0000, edgar@pettijohn-web.com wrote:
> > > If you start ntpdate without any arguments you get this helpful text:
> > >
> > > ntpdate[23355]: no servers can be used, exiting
> > >
> > > If provided with the "usage" text it would be easier for the user to discover their mistake.
> >
> > You don't have to provide a server on command line, it can use the servers
> > from ntp.conf. The above message can be because of e.g. transient network
> > failure.
> >
> > --
> > Manuel Bouyer <bouyer@antioche.eu.org>
> > NetBSD: 26 ans d'experience feront toujours la difference
> > --
> >
>
> I don't see anywhere that it opens ntp.conf. There is a loadservers() defined
> in ntpdate.h, but doesn't appear to be used anywhere.
Yes, sorry. I now see that the man page mention this only works if netinfo
is compiled in. /etc/rc.d/netdate will fetch itself the servers from
ntp.conf if ntpdate_hosts is not defined. This is what confused me ...
--
Manuel Bouyer <bouyer@antioche.eu.org>
NetBSD: 26 ans d'experience feront toujours la difference
--
From: christos@zoulas.com (Christos Zoulas)
To: gnats-bugs@NetBSD.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Cc:
Subject: Re: bin/53813: ntpdate should print usage if not provided a server on commandline
Date: Wed, 26 Dec 2018 10:57:36 -0500
On Dec 26, 6:30am, edgar@pettijohn-web.com (edgar@pettijohn-web.com) wrote:
-- Subject: bin/53813: ntpdate should print usage if not provided a server on
Have you tested this? Moving the check before adding the servers will
always fail...
christos
From: edgar@pettijohn-web.com
To: gnats-bugs@NetBSD.org, netbsd-bugs@netbsd.org, christos@zoulas.com
Cc: gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: bin/53813: ntpdate should print usage if not provided a server
on commandline
Date: Wed, 26 Dec 2018 10:26:52 -0600
On Wed, Dec 26, 2018 at 04:00:02PM +0000, Christos Zoulas wrote:
> The following reply was made to PR bin/53813; it has been noted by GNATS.
>
> From: christos@zoulas.com (Christos Zoulas)
> To: gnats-bugs@NetBSD.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
> Cc:
> Subject: Re: bin/53813: ntpdate should print usage if not provided a server on commandline
> Date: Wed, 26 Dec 2018 10:57:36 -0500
>
> On Dec 26, 6:30am, edgar@pettijohn-web.com (edgar@pettijohn-web.com) wrote:
> -- Subject: bin/53813: ntpdate should print usage if not provided a server on
>
> Have you tested this? Moving the check before adding the servers will
> always fail...
>
> christos
>
sorry. Perhaps this or similar is better:
Index: ntpdate.c
===================================================================
RCS file: /cvsroot/src/external/bsd/ntp/dist/ntpdate/ntpdate.c,v
retrieving revision 1.11
diff -u -r1.11 ntpdate.c
--- ntpdate.c 13 Apr 2017 20:17:42 -0000 1.11
+++ ntpdate.c 26 Dec 2018 16:24:54 -0000
@@ -431,8 +431,7 @@
default:
break;
}
-
- if (errflg) {
+ if (errflg || argc == 1) {
(void) fprintf(stderr,
"usage: %s [-46bBdqsuv] [-a key#] [-e delay] [-k file] [-p samples] [-o version#] [-t timeo] server ...\n",
progname);
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/53813 CVS commit: src/external/bsd/ntp/dist/ntpdate
Date: Wed, 26 Dec 2018 13:31:29 -0500
Module Name: src
Committed By: christos
Date: Wed Dec 26 18:31:29 UTC 2018
Modified Files:
src/external/bsd/ntp/dist/ntpdate: ntpdate.c
Log Message:
PR/53813: Edgar Pettijohn: Print usage message if no servers are found.
To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/external/bsd/ntp/dist/ntpdate/ntpdate.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->closed
State-Changed-By: bsiegert@NetBSD.org
State-Changed-When: Mon, 08 Apr 2019 18:37:00 +0000
State-Changed-Why:
Fix committed.
>Unformatted:
(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.