Browse Source

Provide the -n switch like in the other imsg daemons for testing

the configuration file.
"yes please, ok" henning@
OPENBSD_4_3
pyr 17 years ago
parent
commit
90f5650e4c
3 changed files with 18 additions and 6 deletions
  1. +6
    -3
      src/usr.sbin/ntpd/ntpd.8
  2. +10
    -2
      src/usr.sbin/ntpd/ntpd.c
  3. +2
    -1
      src/usr.sbin/ntpd/ntpd.h

+ 6
- 3
src/usr.sbin/ntpd/ntpd.8 View File

@ -1,4 +1,4 @@
.\" $OpenBSD: ntpd.8,v 1.19 2007/08/22 21:04:30 ckuethe Exp $
.\" $OpenBSD: ntpd.8,v 1.20 2007/09/13 14:34:36 pyr Exp $
.\" .\"
.\" Copyright (c) 2003, 2004, 2006 Henning Brauer <henning@openbsd.org> .\" Copyright (c) 2003, 2004, 2006 Henning Brauer <henning@openbsd.org>
.\" .\"
@ -14,7 +14,7 @@
.\" AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT .\" AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
.\" OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\" .\"
.Dd $Mdocdate: August 22 2007 $
.Dd $Mdocdate: September 13 2007 $
.Dt NTPD 8 .Dt NTPD 8
.Os .Os
.Sh NAME .Sh NAME
@ -23,7 +23,7 @@
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm ntpd .Nm ntpd
.Bk -words .Bk -words
.Op Fl dSsv
.Op Fl dnSsv
.Op Fl f Ar file .Op Fl f Ar file
.Ek .Ek
.Sh DESCRIPTION .Sh DESCRIPTION
@ -89,6 +89,9 @@ Use
as the configuration file, as the configuration file,
instead of the default instead of the default
.Pa /etc/ntpd.conf . .Pa /etc/ntpd.conf .
.It Fl n
Configtest mode.
Only check the configuration file for validity.
.It Fl S .It Fl S
Do not set the time immediately at startup. Do not set the time immediately at startup.
This is the default. This is the default.


+ 10
- 2
src/usr.sbin/ntpd/ntpd.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: ntpd.c,v 1.50 2007/08/22 21:04:30 ckuethe Exp $ */
/* $OpenBSD: ntpd.c,v 1.51 2007/09/13 14:34:36 pyr Exp $ */
/* /*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -96,7 +96,7 @@ main(int argc, char *argv[])
log_init(1); /* log to stderr until daemonized */ log_init(1); /* log to stderr until daemonized */
res_init(); /* XXX */ res_init(); /* XXX */
while ((ch = getopt(argc, argv, "df:sSv")) != -1) {
while ((ch = getopt(argc, argv, "df:nsSv")) != -1) {
switch (ch) { switch (ch) {
case 'd': case 'd':
lconf.debug = 1; lconf.debug = 1;
@ -104,6 +104,9 @@ main(int argc, char *argv[])
case 'f': case 'f':
conffile = optarg; conffile = optarg;
break; break;
case 'n':
lconf.noaction = 1;
break;
case 's': case 's':
lconf.settime = 1; lconf.settime = 1;
break; break;
@ -122,6 +125,11 @@ main(int argc, char *argv[])
if (parse_config(conffile, &lconf)) if (parse_config(conffile, &lconf))
exit(1); exit(1);
if (lconf.noaction) {
fprintf(stderr, "configuration OK\n");
exit(0);
}
if (geteuid()) { if (geteuid()) {
fprintf(stderr, "ntpd: need root privileges\n"); fprintf(stderr, "ntpd: need root privileges\n");
exit(1); exit(1);


+ 2
- 1
src/usr.sbin/ntpd/ntpd.h View File

@ -1,4 +1,4 @@
/* $OpenBSD: ntpd.h,v 1.86 2007/09/12 21:08:46 ckuethe Exp $ */
/* $OpenBSD: ntpd.h,v 1.87 2007/09/13 14:34:36 pyr Exp $ */
/* /*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -172,6 +172,7 @@ struct ntpd_conf {
u_int8_t settime; u_int8_t settime;
u_int8_t debug; u_int8_t debug;
u_int32_t scale; u_int32_t scale;
u_int8_t noaction;
}; };
struct buf { struct buf {


Loading…
Cancel
Save