summaryrefslogtreecommitdiff
path: root/usr.sbin/ctld
diff options
context:
space:
mode:
authorEdward Tomasz Napierala <trasz@FreeBSD.org>2020-03-31 13:43:09 +0000
committerEdward Tomasz Napierala <trasz@FreeBSD.org>2020-03-31 13:43:09 +0000
commit7fcbecd004fccb6cfc507d7fa4115508305f3acb (patch)
tree5012b182ab51f5464cb8701223dfc11d19fc461c /usr.sbin/ctld
parentc30797873f663df5fc45ba0db943393f611bd24e (diff)
downloadsrc-test2-7fcbecd004fccb6cfc507d7fa4115508305f3acb.tar.gz
src-test2-7fcbecd004fccb6cfc507d7fa4115508305f3acb.zip
Add 'ctld -t', to test configuration file validity.
Reviewed by: mav, allanjude, bcr (man pages) MFC after: 2 weeks Sponsored by: Klara Inc. Differential Revision: https://reviews.freebsd.org/D23792
Notes
Notes: svn path=/head/; revision=359480
Diffstat (limited to 'usr.sbin/ctld')
-rw-r--r--usr.sbin/ctld/ctld.88
-rw-r--r--usr.sbin/ctld/ctld.c11
2 files changed, 17 insertions, 2 deletions
diff --git a/usr.sbin/ctld/ctld.8 b/usr.sbin/ctld/ctld.8
index e63a6cd2dfef..ad510b28d575 100644
--- a/usr.sbin/ctld/ctld.8
+++ b/usr.sbin/ctld/ctld.8
@@ -27,7 +27,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd March 23, 2018
+.Dd March 31, 2020
.Dt CTLD 8
.Os
.Sh NAME
@@ -38,6 +38,10 @@
.Op Fl d
.Op Fl f Ar config-file
.Op Fl u
+.Nm
+.Fl t
+.Op Fl f Ar config-file
+.Op Fl u
.Sh DESCRIPTION
The
.Nm
@@ -90,6 +94,8 @@ The daemon sends verbose debug output to standard error, and does not
put itself in the background.
The daemon will also not fork and will exit after processing one connection.
This option is only intended for debugging the target.
+.It Fl t
+Test the configuration file for validity and exit.
.It Fl u
Use UCL configuration file format instead of the traditional non-UCL format.
.El
diff --git a/usr.sbin/ctld/ctld.c b/usr.sbin/ctld/ctld.c
index c1dbac6f7956..dc7a789fcb19 100644
--- a/usr.sbin/ctld/ctld.c
+++ b/usr.sbin/ctld/ctld.c
@@ -69,6 +69,7 @@ usage(void)
{
fprintf(stderr, "usage: ctld [-d][-u][-f config-file]\n");
+ fprintf(stderr, " ctld -t [-u][-f config-file]\n");
exit(1);
}
@@ -2663,14 +2664,18 @@ main(int argc, char **argv)
const char *config_path = DEFAULT_CONFIG_PATH;
int debug = 0, ch, error;
bool dont_daemonize = false;
+ bool test_config = false;
bool use_ucl = false;
- while ((ch = getopt(argc, argv, "duf:R")) != -1) {
+ while ((ch = getopt(argc, argv, "dtuf:R")) != -1) {
switch (ch) {
case 'd':
dont_daemonize = true;
debug++;
break;
+ case 't':
+ test_config = true;
+ break;
case 'u':
use_ucl = true;
break;
@@ -2701,6 +2706,10 @@ main(int argc, char **argv)
if (newconf == NULL)
log_errx(1, "configuration error; exiting");
+
+ if (test_config)
+ return (0);
+
if (debug > 0) {
oldconf->conf_debug = debug;
newconf->conf_debug = debug;