From owner-svn-src-head@freebsd.org Tue Mar 31 13:43:21 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CEDEB2A6567; Tue, 31 Mar 2020 13:43:21 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48s9Wr2NLCz4GVM; Tue, 31 Mar 2020 13:43:20 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 541E9A69F; Tue, 31 Mar 2020 13:43:10 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 02VDhA7Y014708; Tue, 31 Mar 2020 13:43:10 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 02VDh9wb014706; Tue, 31 Mar 2020 13:43:09 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <202003311343.02VDh9wb014706@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Tue, 31 Mar 2020 13:43:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r359480 - head/usr.sbin/ctld X-SVN-Group: head X-SVN-Commit-Author: trasz X-SVN-Commit-Paths: head/usr.sbin/ctld X-SVN-Commit-Revision: 359480 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 Mar 2020 13:43:22 -0000 Author: trasz Date: Tue Mar 31 13:43:09 2020 New Revision: 359480 URL: https://svnweb.freebsd.org/changeset/base/359480 Log: 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 Modified: head/usr.sbin/ctld/ctld.8 head/usr.sbin/ctld/ctld.c Modified: head/usr.sbin/ctld/ctld.8 ============================================================================== --- head/usr.sbin/ctld/ctld.8 Tue Mar 31 06:25:43 2020 (r359479) +++ head/usr.sbin/ctld/ctld.8 Tue Mar 31 13:43:09 2020 (r359480) @@ -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 erro 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 Modified: head/usr.sbin/ctld/ctld.c ============================================================================== --- head/usr.sbin/ctld/ctld.c Tue Mar 31 06:25:43 2020 (r359479) +++ head/usr.sbin/ctld/ctld.c Tue Mar 31 13:43:09 2020 (r359480) @@ -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;