ntpd(8): Make -n quieter

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

ntpd(8): Make -n quieter

Michael Reed
Hi all,

If ntpd is run with the -n flag, and /etc/ntpd.conf is parsed without
error, then "Configuration OK" is printed.  I don't think this is
particularly useful, as both a lack of an error message and an exit
value of 0 already indicate success in this case.  This seems to be the
case for most (many?) programs in the base system, such as doas(1).

Given that, I've removed the message

Regards,
Michael



Index: ntpd.c
===================================================================
RCS file: /cvs/src/usr.sbin/ntpd/ntpd.c,v
retrieving revision 1.94
diff -u -p -r1.94 ntpd.c
--- ntpd.c 18 Jul 2015 00:53:44 -0000 1.94
+++ ntpd.c 30 Aug 2015 18:42:06 -0000
@@ -159,7 +159,6 @@ main(int argc, char *argv[])
  exit(1);
 
  if (lconf.noaction) {
- fprintf(stderr, "configuration OK\n");
  exit(0);
  }
 

Reply | Threaded
Open this post in threaded view
|

Re: ntpd(8): Make -n quieter

Michael Reed
On 08/30/15 14:58, Michael Reed wrote:

> Hi all,
>
> If ntpd is run with the -n flag, and /etc/ntpd.conf is parsed without
> error, then "Configuration OK" is printed.  I don't think this is
> particularly useful, as both a lack of an error message and an exit
> value of 0 already indicate success in this case.  This seems to be the
> case for most (many?) programs in the base system, such as doas(1).
>
> Given that, I've removed the message
>
> Regards,
> Michael
>
>
>
> Index: ntpd.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/ntpd/ntpd.c,v
> retrieving revision 1.94
> diff -u -p -r1.94 ntpd.c
> --- ntpd.c 18 Jul 2015 00:53:44 -0000 1.94
> +++ ntpd.c 30 Aug 2015 18:42:06 -0000
> @@ -159,7 +159,6 @@ main(int argc, char *argv[])
>   exit(1);
>  
>   if (lconf.noaction) {
> - fprintf(stderr, "configuration OK\n");
>   exit(0);
>   }
>  
>

In case this idea is accepted, here's an updated patch which does
the same for radiusd(8).


Index: src/usr.sbin/ntpd/ntpd.c
===================================================================
RCS file: /cvs/src/usr.sbin/ntpd/ntpd.c,v
retrieving revision 1.94
diff -u -p -r1.94 ntpd.c
--- src/usr.sbin/ntpd/ntpd.c 18 Jul 2015 00:53:44 -0000 1.94
+++ src/usr.sbin/ntpd/ntpd.c 30 Aug 2015 21:57:53 -0000
@@ -159,7 +159,6 @@ main(int argc, char *argv[])
  exit(1);
 
  if (lconf.noaction) {
- fprintf(stderr, "configuration OK\n");
  exit(0);
  }
 
Index: src/usr.sbin/radiusd/radiusd.c
===================================================================
RCS file: /cvs/src/usr.sbin/radiusd/radiusd.c,v
retrieving revision 1.7
diff -u -p -r1.7 radiusd.c
--- src/usr.sbin/radiusd/radiusd.c 25 Aug 2015 01:12:59 -0000 1.7
+++ src/usr.sbin/radiusd/radiusd.c 30 Aug 2015 21:57:53 -0000
@@ -142,7 +142,6 @@ main(int argc, char *argv[])
  if (parse_config(conffile, radiusd) != 0)
  errx(EX_DATAERR, "config error");
  if (noaction) {
- fprintf(stderr, "configuration OK\n");
  exit(EXIT_SUCCESS);
  }
 

Reply | Threaded
Open this post in threaded view
|

Re: ntpd(8): Make -n quieter

Sebastian Benoit-3
In reply to this post by Michael Reed
Michael Reed([hidden email]) on 2015.08.30 14:58:35 -0400:
> Hi all,
>
> If ntpd is run with the -n flag, and /etc/ntpd.conf is parsed without
> error, then "Configuration OK" is printed.  I don't think this is
> particularly useful, as both a lack of an error message and an exit
> value of 0 already indicate success in this case.  This seems to be the
> case for most (many?) programs in the base system, such as doas(1).

I like the message. Why is it a problem?

/Benno

Reply | Threaded
Open this post in threaded view
|

Re: ntpd(8): Make -n quieter

Michael Reed
On 08/31/15 07:36, Sebastian Benoit wrote:

> Michael Reed([hidden email]) on 2015.08.30 14:58:35 -0400:
>> Hi all,
>>
>> If ntpd is run with the -n flag, and /etc/ntpd.conf is parsed without
>> error, then "Configuration OK" is printed.  I don't think this is
>> particularly useful, as both a lack of an error message and an exit
>> value of 0 already indicate success in this case.  This seems to be the
>> case for most (many?) programs in the base system, such as doas(1).
>
> I like the message. Why is it a problem?
>
> /Benno
>

It's admittedly not much of a problem, more just to follow the Unix
principle of saying nothing if there's nothing wrong.

Regards,
Michael

Reply | Threaded
Open this post in threaded view
|

Re: ntpd(8): Make -n quieter

phessler
On 2015 Aug 31 (Mon) at 14:28:11 -0400 (-0400), Michael Reed wrote:
:On 08/31/15 07:36, Sebastian Benoit wrote:
:> Michael Reed([hidden email]) on 2015.08.30 14:58:35 -0400:
:>> Hi all,
:>>
:>> If ntpd is run with the -n flag, and /etc/ntpd.conf is parsed without
:>> error, then "Configuration OK" is printed.  I don't think this is
:>> particularly useful, as both a lack of an error message and an exit
:>> value of 0 already indicate success in this case.  This seems to be the
:>> case for most (many?) programs in the base system, such as doas(1).
:>
:> I like the message. Why is it a problem?
:>
:> /Benno
:>
:
:It's admittedly not much of a problem, more just to follow the Unix
:principle of saying nothing if there's nothing wrong.
:
:Regards,
:Michael
:

In my mind, -n is explicitly asking for a configuration check, so
explicitly telling me it's OK is a good thing.

I prefer keeping the message.


--
Jone's Motto:
        Friends come and go, but enemies accumulate.

Reply | Threaded
Open this post in threaded view
|

Re: ntpd(8): Make -n quieter

Gleydson Soares-3
On Tue, Sep 01, 2015 at 09:21:03AM +0200, Peter Hessler wrote:

> On 2015 Aug 31 (Mon) at 14:28:11 -0400 (-0400), Michael Reed wrote:
> :On 08/31/15 07:36, Sebastian Benoit wrote:
> :> Michael Reed([hidden email]) on 2015.08.30 14:58:35 -0400:
> :>> Hi all,
> :>>
> :>> If ntpd is run with the -n flag, and /etc/ntpd.conf is parsed without
> :>> error, then "Configuration OK" is printed.  I don't think this is
> :>> particularly useful, as both a lack of an error message and an exit
> :>> value of 0 already indicate success in this case.  This seems to be the
> :>> case for most (many?) programs in the base system, such as doas(1).
> :>
> :> I like the message. Why is it a problem?
> :>
> :> /Benno
> :>
> :
> :It's admittedly not much of a problem, more just to follow the Unix
> :principle of saying nothing if there's nothing wrong.
> :
> :Regards,
> :Michael
> :
>
> In my mind, -n is explicitly asking for a configuration check, so
> explicitly telling me it's OK is a good thing.

sure,
and if anyone wants less bother, just redirect the stderr like
$ ntpd -n -f /etc/ntpd.conf  2>/dev/null ; echo $?
0

//gsoares