summaryrefslogtreecommitdiff
path: root/usr.sbin/ntpd
diff options
context:
space:
mode:
authorPierre-Yves Ritschard <pyr@cvs.openbsd.org>2007-09-13 14:34:37 +0000
committerPierre-Yves Ritschard <pyr@cvs.openbsd.org>2007-09-13 14:34:37 +0000
commitd53cf41bbd3cfe9bddc257c76275bd404ecc43aa (patch)
tree8772e94f34fef2f136125d38ef350fef490afe3d /usr.sbin/ntpd
parente149a4581854b359e674cd5b1a129eb8549b09b1 (diff)
Provide the -n switch like in the other imsg daemons for testing
the configuration file. "yes please, ok" henning@
Diffstat (limited to 'usr.sbin/ntpd')
-rw-r--r--usr.sbin/ntpd/ntpd.89
-rw-r--r--usr.sbin/ntpd/ntpd.c12
-rw-r--r--usr.sbin/ntpd/ntpd.h3
3 files changed, 18 insertions, 6 deletions
diff --git a/usr.sbin/ntpd/ntpd.8 b/usr.sbin/ntpd/ntpd.8
index 60fffd13687..1bcc6821ee6 100644
--- a/usr.sbin/ntpd/ntpd.8
+++ b/usr.sbin/ntpd/ntpd.8
@@ -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>
.\"
@@ -14,7 +14,7 @@
.\" AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
.\" 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
.Os
.Sh NAME
@@ -23,7 +23,7 @@
.Sh SYNOPSIS
.Nm ntpd
.Bk -words
-.Op Fl dSsv
+.Op Fl dnSsv
.Op Fl f Ar file
.Ek
.Sh DESCRIPTION
@@ -89,6 +89,9 @@ Use
as the configuration file,
instead of the default
.Pa /etc/ntpd.conf .
+.It Fl n
+Configtest mode.
+Only check the configuration file for validity.
.It Fl S
Do not set the time immediately at startup.
This is the default.
diff --git a/usr.sbin/ntpd/ntpd.c b/usr.sbin/ntpd/ntpd.c
index cae33baade4..d90f7eb3078 100644
--- a/usr.sbin/ntpd/ntpd.c
+++ b/usr.sbin/ntpd/ntpd.c
@@ -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>
@@ -96,7 +96,7 @@ main(int argc, char *argv[])
log_init(1); /* log to stderr until daemonized */
res_init(); /* XXX */
- while ((ch = getopt(argc, argv, "df:sSv")) != -1) {
+ while ((ch = getopt(argc, argv, "df:nsSv")) != -1) {
switch (ch) {
case 'd':
lconf.debug = 1;
@@ -104,6 +104,9 @@ main(int argc, char *argv[])
case 'f':
conffile = optarg;
break;
+ case 'n':
+ lconf.noaction = 1;
+ break;
case 's':
lconf.settime = 1;
break;
@@ -122,6 +125,11 @@ main(int argc, char *argv[])
if (parse_config(conffile, &lconf))
exit(1);
+ if (lconf.noaction) {
+ fprintf(stderr, "configuration OK\n");
+ exit(0);
+ }
+
if (geteuid()) {
fprintf(stderr, "ntpd: need root privileges\n");
exit(1);
diff --git a/usr.sbin/ntpd/ntpd.h b/usr.sbin/ntpd/ntpd.h
index 9b841d79d81..1ab2ffa3ed1 100644
--- a/usr.sbin/ntpd/ntpd.h
+++ b/usr.sbin/ntpd/ntpd.h
@@ -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>
@@ -172,6 +172,7 @@ struct ntpd_conf {
u_int8_t settime;
u_int8_t debug;
u_int32_t scale;
+ u_int8_t noaction;
};
struct buf {