summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Salzman <daniel.salzman@nic.cz>2023-10-23 13:17:55 +0200
committerDaniel Salzman <daniel.salzman@nic.cz>2023-10-25 19:41:53 +0200
commita5f5c33bd5a00529af128bbbea8e2edddd87da25 (patch)
tree09db8f11dfa5f374631d101ce8e746dc30e84701
parentconfigure: remove server version from the summary and add configure parameters (diff)
downloadknot-a5f5c33bd5a00529af128bbbea8e2edddd87da25.tar.xz
knot-a5f5c33bd5a00529af128bbbea8e2edddd87da25.zip
utils: add the "-VV" option for listing compile time configuration summary
-rw-r--r--doc/man/kcatalogprint.8in3
-rw-r--r--doc/man/kdig.1in3
-rw-r--r--doc/man/keymgr.8in3
-rw-r--r--doc/man/khost.1in3
-rw-r--r--doc/man/kjournalprint.8in3
-rw-r--r--doc/man/knotc.8in3
-rw-r--r--doc/man/knotd.8in3
-rw-r--r--doc/man/knsec3hash.1in12
-rw-r--r--doc/man/knsupdate.1in3
-rw-r--r--doc/man/kxdpgun.8in3
-rw-r--r--doc/man/kzonecheck.1in3
-rw-r--r--doc/man/kzonesign.1in3
-rw-r--r--doc/man_kcatalogprint.rst3
-rw-r--r--doc/man_kdig.rst3
-rw-r--r--doc/man_keymgr.rst3
-rw-r--r--doc/man_khost.rst3
-rw-r--r--doc/man_kjournalprint.rst3
-rw-r--r--doc/man_knotc.rst3
-rw-r--r--doc/man_knotd.rst3
-rw-r--r--doc/man_knsec3hash.rst12
-rw-r--r--doc/man_knsupdate.rst3
-rw-r--r--doc/man_kxdpgun.rst3
-rw-r--r--doc/man_kzonecheck.rst3
-rw-r--r--doc/man_kzonesign.rst3
-rw-r--r--src/contrib/string.c4
-rw-r--r--src/contrib/string.h4
-rw-r--r--src/knot/ctl/commands.c2
-rw-r--r--src/utils/common/params.h11
-rw-r--r--src/utils/kcatalogprint/main.c6
-rw-r--r--src/utils/kdig/kdig_params.c11
-rw-r--r--src/utils/keymgr/main.c6
-rw-r--r--src/utils/khost/khost_params.c10
-rw-r--r--src/utils/kjournalprint/main.c6
-rw-r--r--src/utils/knotc/main.c6
-rw-r--r--src/utils/knotd/main.c12
-rw-r--r--src/utils/knsec3hash/knsec3hash.c10
-rw-r--r--src/utils/knsupdate/knsupdate_params.c10
-rw-r--r--src/utils/kxdpgun/main.c6
-rw-r--r--src/utils/kzonecheck/main.c6
-rw-r--r--src/utils/kzonesign/main.c6
40 files changed, 127 insertions, 79 deletions
diff --git a/doc/man/kcatalogprint.8in b/doc/man/kcatalogprint.8in
index fe8fd29da..b4e2f494d 100644
--- a/doc/man/kcatalogprint.8in
+++ b/doc/man/kcatalogprint.8in
@@ -63,7 +63,8 @@ Filter the output by member zone name.
Print the program help.
.TP
\fB\-V\fP, \fB\-\-version\fP
-Print the program version.
+Print the program version. The option \fB\-VV\fP makes the program
+print the compile time configuration summary.
.UNINDENT
.SH EXIT VALUES
.sp
diff --git a/doc/man/kdig.1in b/doc/man/kdig.1in
index 12d874e6e..952bb26fc 100644
--- a/doc/man/kdig.1in
+++ b/doc/man/kdig.1in
@@ -132,7 +132,8 @@ is provided, empty question section is set.
An explicit \fIquery_type\fP specification. See possible values above.
.TP
\fB\-V\fP, \fB\-\-version\fP
-Print the program version.
+Print the program version. The option \fB\-VV\fP makes the program
+print the compile time configuration summary.
.TP
\fB\-x\fP \fIaddress\fP
Send a reverse (PTR) query for IPv4 or IPv6 \fIaddress\fP\&. The correct name, class
diff --git a/doc/man/keymgr.8in b/doc/man/keymgr.8in
index e32a5d914..fbe234265 100644
--- a/doc/man/keymgr.8in
+++ b/doc/man/keymgr.8in
@@ -96,7 +96,8 @@ Force colorized output in the normal mode.
Print the program help.
.TP
\fB\-V\fP, \fB\-\-version\fP
-Print the program version.
+Print the program version. The option \fB\-VV\fP makes the program
+print the compile time configuration summary.
.UNINDENT
.sp
\fBNOTE:\fP
diff --git a/doc/man/khost.1in b/doc/man/khost.1in
index d0f0e7c6c..d82d522d2 100644
--- a/doc/man/khost.1in
+++ b/doc/man/khost.1in
@@ -80,7 +80,8 @@ Use the TCP protocol.
Enable verbose output.
.TP
\fB\-V\fP, \fB\-\-version\fP
-Print the program version.
+Print the program version. The option \fB\-VV\fP makes the program
+print the compile time configuration summary.
.TP
\fB\-w\fP
Wait forever for the reply.
diff --git a/doc/man/kjournalprint.8in b/doc/man/kjournalprint.8in
index 506ffbec8..4924e2afa 100644
--- a/doc/man/kjournalprint.8in
+++ b/doc/man/kjournalprint.8in
@@ -90,7 +90,8 @@ Force colorized output.
Print the program help.
.TP
\fB\-V\fP, \fB\-\-version\fP
-Print the program version.
+Print the program version. The option \fB\-VV\fP makes the program
+print the compile time configuration summary.
.UNINDENT
.SH EXIT VALUES
.sp
diff --git a/doc/man/knotc.8in b/doc/man/knotc.8in
index db0bb7443..dfeabf25b 100644
--- a/doc/man/knotc.8in
+++ b/doc/man/knotc.8in
@@ -88,7 +88,8 @@ Enable debug output.
Print the program help.
.TP
\fB\-V\fP, \fB\-\-version\fP
-Print the program version.
+Print the program version. The option \fB\-VV\fP makes the program
+print the compile time configuration summary.
.UNINDENT
.SS Actions
.INDENT 0.0
diff --git a/doc/man/knotd.8in b/doc/man/knotd.8in
index 13cee3439..234fb8eea 100644
--- a/doc/man/knotd.8in
+++ b/doc/man/knotd.8in
@@ -69,7 +69,8 @@ Enable debug output.
Print the program help.
.TP
\fB\-V\fP, \fB\-\-version\fP
-Print the program version.
+Print the program version. The option \fB\-VV\fP makes the program
+print the compile time configuration summary.
.UNINDENT
.SS Signals
.sp
diff --git a/doc/man/knsec3hash.1in b/doc/man/knsec3hash.1in
index fc1dc5a17..aba77d4be 100644
--- a/doc/man/knsec3hash.1in
+++ b/doc/man/knsec3hash.1in
@@ -35,6 +35,8 @@ knsec3hash \- Simple utility to compute NSEC3 hash
\fBknsec3hash\fP \fIsalt\fP \fIalgorithm\fP \fIiterations\fP \fIname\fP
.sp
\fBknsec3hash\fP \fIalgorithm\fP \fIflags\fP \fIiterations\fP \fIsalt\fP \fIname\fP
+.sp
+\fBknsec3hash\fP [\fI\-h\fP] [\fI\-V\fP]
.SH DESCRIPTION
.sp
This utility generates a NSEC3 hash for a given domain name and parameters of NSEC3 hash.
@@ -56,6 +58,16 @@ Specifies the domain name to be hashed.
\fIflags\fP
Specifies NSEC3 flags as an unsigned integer.
.UNINDENT
+.SS Options
+.INDENT 0.0
+.TP
+\fB\-h\fP, \fB\-\-help\fP
+Print the program help.
+.TP
+\fB\-V\fP, \fB\-\-version\fP
+Print the program version. The option \fB\-VV\fP makes the program
+print the compile time configuration summary.
+.UNINDENT
.SH EXIT VALUES
.sp
Exit status of 0 means successful operation. Any other exit status indicates
diff --git a/doc/man/knsupdate.1in b/doc/man/knsupdate.1in
index 91a9394e2..2849a277a 100644
--- a/doc/man/knsupdate.1in
+++ b/doc/man/knsupdate.1in
@@ -77,7 +77,8 @@ The default is 12. If set to zero, the timeout is infinite.
Use a TCP connection.
.TP
\fB\-V\fP, \fB\-\-version\fP
-Print the program version.
+Print the program version. The option \fB\-VV\fP makes the program
+print the compile time configuration summary.
.TP
\fB\-y\fP [\fIalg\fP:]\fIname\fP:\fIkey\fP
Use the TSIG key with a name \fIname\fP to authenticate the request. The \fIalg\fP
diff --git a/doc/man/kxdpgun.8in b/doc/man/kxdpgun.8in
index e5e9a8889..ef8ad618e 100644
--- a/doc/man/kxdpgun.8in
+++ b/doc/man/kxdpgun.8in
@@ -136,7 +136,8 @@ with \fB\-\-quic=R\fP or with low QPS. Otherwise, too many files are generated.
Print the program help.
.TP
\fB\-V\fP, \fB\-\-version\fP
-Print the program version.
+Print the program version. The option \fB\-VV\fP makes the program
+print the compile time configuration summary.
.UNINDENT
.SS Queries file format
.sp
diff --git a/doc/man/kzonecheck.1in b/doc/man/kzonecheck.1in
index a10c64f6d..e9c907c58 100644
--- a/doc/man/kzonecheck.1in
+++ b/doc/man/kzonecheck.1in
@@ -74,7 +74,8 @@ Enable debug output.
Print the program help.
.TP
\fB\-V\fP, \fB\-\-version\fP
-Print the program version.
+Print the program version. The option \fB\-VV\fP makes the program
+print the compile time configuration summary.
.UNINDENT
.SH EXIT VALUES
.sp
diff --git a/doc/man/kzonesign.1in b/doc/man/kzonesign.1in
index 170fd107d..135840b92 100644
--- a/doc/man/kzonesign.1in
+++ b/doc/man/kzonesign.1in
@@ -78,7 +78,8 @@ specified by timestamp.
Print the program help.
.TP
\fB\-V\fP, \fB\-\-version\fP
-Print the program version.
+Print the program version. The option \fB\-VV\fP makes the program
+print the compile time configuration summary.
.UNINDENT
.SH EXIT VALUES
.sp
diff --git a/doc/man_kcatalogprint.rst b/doc/man_kcatalogprint.rst
index 31af77049..9e62a9da1 100644
--- a/doc/man_kcatalogprint.rst
+++ b/doc/man_kcatalogprint.rst
@@ -40,7 +40,8 @@ Options
Print the program help.
**-V**, **--version**
- Print the program version.
+ Print the program version. The option **-VV** makes the program
+ print the compile time configuration summary.
Exit values
-----------
diff --git a/doc/man_kdig.rst b/doc/man_kdig.rst
index d40efe8e1..b77caa9ab 100644
--- a/doc/man_kdig.rst
+++ b/doc/man_kdig.rst
@@ -111,7 +111,8 @@ Options
An explicit *query_type* specification. See possible values above.
**-V**, **--version**
- Print the program version.
+ Print the program version. The option **-VV** makes the program
+ print the compile time configuration summary.
**-x** *address*
Send a reverse (PTR) query for IPv4 or IPv6 *address*. The correct name, class
diff --git a/doc/man_keymgr.rst b/doc/man_keymgr.rst
index 481292d1b..503cac504 100644
--- a/doc/man_keymgr.rst
+++ b/doc/man_keymgr.rst
@@ -73,7 +73,8 @@ Options
Print the program help.
**-V**, **--version**
- Print the program version.
+ Print the program version. The option **-VV** makes the program
+ print the compile time configuration summary.
.. NOTE::
Keymgr runs with the same user privileges as configured for :doc:`knotd<man_knotd>`.
diff --git a/doc/man_khost.rst b/doc/man_khost.rst
index 76fa9c81d..69c66d96f 100644
--- a/doc/man_khost.rst
+++ b/doc/man_khost.rst
@@ -57,7 +57,8 @@ Options
Enable verbose output.
**-V**, **--version**
- Print the program version.
+ Print the program version. The option **-VV** makes the program
+ print the compile time configuration summary.
**-w**
Wait forever for the reply.
diff --git a/doc/man_kjournalprint.rst b/doc/man_kjournalprint.rst
index fc7431280..33cdde7bb 100644
--- a/doc/man_kjournalprint.rst
+++ b/doc/man_kjournalprint.rst
@@ -67,7 +67,8 @@ Options
Print the program help.
**-V**, **--version**
- Print the program version.
+ Print the program version. The option **-VV** makes the program
+ print the compile time configuration summary.
Exit values
-----------
diff --git a/doc/man_knotc.rst b/doc/man_knotc.rst
index 5c16b522c..6fad8f3a8 100644
--- a/doc/man_knotc.rst
+++ b/doc/man_knotc.rst
@@ -65,7 +65,8 @@ Options
Print the program help.
**-V**, **--version**
- Print the program version.
+ Print the program version. The option **-VV** makes the program
+ print the compile time configuration summary.
Actions
.......
diff --git a/doc/man_knotd.rst b/doc/man_knotd.rst
index beb12a907..d467f4fbb 100644
--- a/doc/man_knotd.rst
+++ b/doc/man_knotd.rst
@@ -46,7 +46,8 @@ Options
Print the program help.
**-V**, **--version**
- Print the program version.
+ Print the program version. The option **-VV** makes the program
+ print the compile time configuration summary.
Signals
.......
diff --git a/doc/man_knsec3hash.rst b/doc/man_knsec3hash.rst
index 946cad9f5..157f9471c 100644
--- a/doc/man_knsec3hash.rst
+++ b/doc/man_knsec3hash.rst
@@ -10,6 +10,8 @@ Synopsis
:program:`knsec3hash` *algorithm* *flags* *iterations* *salt* *name*
+:program:`knsec3hash` [*-h*] [*-V*]
+
Description
-----------
@@ -33,6 +35,16 @@ Parameters
*flags*
Specifies NSEC3 flags as an unsigned integer.
+Options
+.......
+
+**-h**, **--help**
+ Print the program help.
+
+**-V**, **--version**
+ Print the program version. The option **-VV** makes the program
+ print the compile time configuration summary.
+
Exit values
-----------
diff --git a/doc/man_knsupdate.rst b/doc/man_knsupdate.rst
index 38feb96e6..996dc49c5 100644
--- a/doc/man_knsupdate.rst
+++ b/doc/man_knsupdate.rst
@@ -54,7 +54,8 @@ Options
Use a TCP connection.
**-V**, **--version**
- Print the program version.
+ Print the program version. The option **-VV** makes the program
+ print the compile time configuration summary.
**-y** [*alg*:]\ *name*:*key*
Use the TSIG key with a name *name* to authenticate the request. The *alg*
diff --git a/doc/man_kxdpgun.rst b/doc/man_kxdpgun.rst
index c98fb04b1..5bd886346 100644
--- a/doc/man_kxdpgun.rst
+++ b/doc/man_kxdpgun.rst
@@ -111,7 +111,8 @@ Options
Print the program help.
**-V**, **--version**
- Print the program version.
+ Print the program version. The option **-VV** makes the program
+ print the compile time configuration summary.
Queries file format
...................
diff --git a/doc/man_kzonecheck.rst b/doc/man_kzonecheck.rst
index 44fd0b9e3..d251742d8 100644
--- a/doc/man_kzonecheck.rst
+++ b/doc/man_kzonecheck.rst
@@ -51,7 +51,8 @@ Options
Print the program help.
**-V**, **--version**
- Print the program version.
+ Print the program version. The option **-VV** makes the program
+ print the compile time configuration summary.
Exit values
-----------
diff --git a/doc/man_kzonesign.rst b/doc/man_kzonesign.rst
index 9552afac8..e87a0592f 100644
--- a/doc/man_kzonesign.rst
+++ b/doc/man_kzonesign.rst
@@ -55,7 +55,8 @@ Options
Print the program help.
**-V**, **--version**
- Print the program version.
+ Print the program version. The option **-VV** makes the program
+ print the compile time configuration summary.
Exit values
-----------
diff --git a/src/contrib/string.c b/src/contrib/string.c
index 272116e72..9c8817f32 100644
--- a/src/contrib/string.c
+++ b/src/contrib/string.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2021 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
+/* Copyright (C) 2023 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -36,6 +36,8 @@
#include "contrib/ctype.h"
#include "contrib/tolower.h"
+const char *configure_summary = CONFIGURE_SUMMARY;
+
uint8_t *memdup(const uint8_t *data, size_t data_size)
{
uint8_t *result = (uint8_t *)malloc(data_size);
diff --git a/src/contrib/string.h b/src/contrib/string.h
index ad3c990ba..3e113b151 100644
--- a/src/contrib/string.h
+++ b/src/contrib/string.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2022 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
+/* Copyright (C) 2023 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -24,6 +24,8 @@
#include <stddef.h>
#include <stdint.h>
+extern const char *configure_summary;
+
/*!
* \brief Create a copy of a binary buffer.
*
diff --git a/src/knot/ctl/commands.c b/src/knot/ctl/commands.c
index 135b2967d..b1d5ea6d7 100644
--- a/src/knot/ctl/commands.c
+++ b/src/knot/ctl/commands.c
@@ -1900,7 +1900,7 @@ static int server_status(ctl_args_t *args)
conf()->cache.srv_xdp_threads, conf()->cache.srv_bg_threads,
running_bkg_wrk, wrk_queue);
} else if (strcasecmp(type, "configure") == 0) {
- ret = snprintf(buff, sizeof(buff), "%s", CONFIGURE_SUMMARY);
+ ret = snprintf(buff, sizeof(buff), "%s", configure_summary);
} else if (strcasecmp(type, "cert-key") == 0) {
uint8_t pin[128];
size_t pin_len = server_cert_pin(args->server, pin, sizeof(pin));
diff --git a/src/utils/common/params.h b/src/utils/common/params.h
index 8b7565e98..be5f54c04 100644
--- a/src/utils/common/params.h
+++ b/src/utils/common/params.h
@@ -22,6 +22,7 @@
#include <stdio.h>
#include "libknot/libknot.h"
+#include "contrib/string.h"
#include "contrib/ucw/lists.h"
#define DEFAULT_IPV4_NAME "127.0.0.1"
@@ -118,9 +119,15 @@ typedef struct {
param_handle_f handler;
} param_t;
-inline static void print_version(const char *program_name)
+inline static void print_version(const char *prog_name, bool verbose)
{
- printf("%s (Knot DNS), version %s\n", program_name, PACKAGE_VERSION);
+ if (prog_name != NULL) {
+ printf("%s, ", prog_name);
+ }
+ printf("Knot DNS %s\n", PACKAGE_VERSION);
+ if (verbose) {
+ printf("\n%s\n", configure_summary);
+ }
}
/*!
diff --git a/src/utils/kcatalogprint/main.c b/src/utils/kcatalogprint/main.c
index 0172347ad..28175aeb0 100644
--- a/src/utils/kcatalogprint/main.c
+++ b/src/utils/kcatalogprint/main.c
@@ -108,7 +108,7 @@ int main(int argc, char *argv[])
{ "catalog", required_argument, NULL, 'a' },
{ "member", required_argument, NULL, 'm' },
{ "help", no_argument, NULL, 'h' },
- { "version", no_argument, NULL, 'V' },
+ { "version", optional_argument, NULL, 'V' },
{ NULL }
};
@@ -116,7 +116,7 @@ int main(int argc, char *argv[])
signal_init_std();
int opt = 0;
- while ((opt = getopt_long(argc, argv, "c:C:D:a:m:hV", opts, NULL)) != -1) {
+ while ((opt = getopt_long(argc, argv, "c:C:D:a:m:hV::", opts, NULL)) != -1) {
switch (opt) {
case 'c':
if (util_conf_init_file(optarg) != KNOT_EOK) {
@@ -147,7 +147,7 @@ int main(int argc, char *argv[])
print_help();
goto success;
case 'V':
- print_version(PROGRAM_NAME);
+ print_version(PROGRAM_NAME, optarg != NULL);
goto success;
default:
print_help();
diff --git a/src/utils/kdig/kdig_params.c b/src/utils/kdig/kdig_params.c
index f72fbd2b5..471132cd6 100644
--- a/src/utils/kdig/kdig_params.c
+++ b/src/utils/kdig/kdig_params.c
@@ -2516,12 +2516,7 @@ static int parse_opt1(const char *opt, const char *value, kdig_params_t *params,
*index += add;
break;
case 'V':
- if (len > 1) {
- ERR("invalid option -%s", opt);
- return KNOT_ENOTSUP;
- }
-
- print_version(PROGRAM_NAME);
+ print_version(PROGRAM_NAME, len > 1);
params->stop = true;
break;
case 'x':
@@ -2597,8 +2592,8 @@ static int parse_opt1(const char *opt, const char *value, kdig_params_t *params,
if (strcmp(opt, "-help") == 0) {
print_help();
params->stop = true;
- } else if (strcmp(opt, "-version") == 0) {
- print_version(PROGRAM_NAME);
+ } else if (strncmp(opt, "-version", 8) == 0) {
+ print_version(PROGRAM_NAME, strlen(opt) > 9);
params->stop = true;
} else {
ERR("invalid option: -%s", opt);
diff --git a/src/utils/keymgr/main.c b/src/utils/keymgr/main.c
index 355fd3a62..8d36e0040 100644
--- a/src/utils/keymgr/main.c
+++ b/src/utils/keymgr/main.c
@@ -310,7 +310,7 @@ int main(int argc, char *argv[])
{ "mono", no_argument, NULL, 'x' },
{ "color", no_argument, NULL, 'X' },
{ "help", no_argument, NULL, 'h' },
- { "version", no_argument, NULL, 'V' },
+ { "version", optional_argument, NULL, 'V' },
{ "json", no_argument, NULL, 'j' },
{ NULL }
};
@@ -327,7 +327,7 @@ int main(int argc, char *argv[])
list_params.color = isatty(STDOUT_FILENO);
int opt = 0, parm = 0;
- while ((opt = getopt_long(argc, argv, "c:C:D:t:ejlbxXhV", opts, NULL)) != -1) {
+ while ((opt = getopt_long(argc, argv, "c:C:D:t:ejlbxXhV::", opts, NULL)) != -1) {
switch (opt) {
case 'c':
if (util_conf_init_file(optarg) != KNOT_EOK) {
@@ -376,7 +376,7 @@ int main(int argc, char *argv[])
print_help();
goto success;
case 'V':
- print_version(PROGRAM_NAME);
+ print_version(PROGRAM_NAME, optarg != NULL);
goto success;
default:
print_help();
diff --git a/src/utils/khost/khost_params.c b/src/utils/khost/khost_params.c
index 1423e0996..de95d9b63 100644
--- a/src/utils/khost/khost_params.c
+++ b/src/utils/khost/khost_params.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2022 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
+/* Copyright (C) 2023 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -251,14 +251,14 @@ int khost_parse(kdig_params_t *params, int argc, char *argv[])
// Long options.
struct option opts[] = {
- { "help", no_argument, NULL, 'h' },
- { "version", no_argument, NULL, 'V' },
+ { "help", no_argument, NULL, 'h' },
+ { "version", optional_argument, NULL, 'V' },
{ NULL }
};
// Command line options processing.
int opt = 0;
- while ((opt = getopt_long(argc, argv, "46adhrsTvVwc:t:R:W:", opts, NULL))
+ while ((opt = getopt_long(argc, argv, "46adhrsTvV::wc:t:R:W:", opts, NULL))
!= -1) {
switch (opt) {
case '4':
@@ -294,7 +294,7 @@ int khost_parse(kdig_params_t *params, int argc, char *argv[])
conf->style.show_footer = true;
break;
case 'V':
- print_version(PROGRAM_NAME);
+ print_version(PROGRAM_NAME, optarg != NULL);
params->stop = false;
return KNOT_EOK;
case 'w':
diff --git a/src/utils/kjournalprint/main.c b/src/utils/kjournalprint/main.c
index 3ba001959..a5c935b69 100644
--- a/src/utils/kjournalprint/main.c
+++ b/src/utils/kjournalprint/main.c
@@ -346,7 +346,7 @@ int main(int argc, char *argv[])
{ "mono", no_argument, NULL, 'x' },
{ "color", no_argument, NULL, 'X' },
{ "help", no_argument, NULL, 'h' },
- { "version", no_argument, NULL, 'V' },
+ { "version", optional_argument, NULL, 'V' },
{ NULL }
};
@@ -354,7 +354,7 @@ int main(int argc, char *argv[])
signal_init_std();
int opt = 0;
- while ((opt = getopt_long(argc, argv, "c:C:D:l:s:zHdnxXhV", opts, NULL)) != -1) {
+ while ((opt = getopt_long(argc, argv, "c:C:D:l:s:zHdnxXhV::", opts, NULL)) != -1) {
switch (opt) {
case 'c':
if (util_conf_init_file(optarg) != KNOT_EOK) {
@@ -404,7 +404,7 @@ int main(int argc, char *argv[])
print_help();
goto success;
case 'V':
- print_version(PROGRAM_NAME);
+ print_version(PROGRAM_NAME, optarg != NULL);
goto success;
default:
print_help();
diff --git a/src/utils/knotc/main.c b/src/utils/knotc/main.c
index dad3671e5..274ab6dad 100644
--- a/src/utils/knotc/main.c
+++ b/src/utils/knotc/main.c
@@ -82,7 +82,7 @@ int main(int argc, char **argv)
{ "color", no_argument, NULL, 'X' },
{ "verbose", no_argument, NULL, 'v' },
{ "help", no_argument, NULL, 'h' },
- { "version", no_argument, NULL, 'V' },
+ { "version", optional_argument, NULL, 'V' },
{ NULL }
};
@@ -97,7 +97,7 @@ int main(int argc, char **argv)
/* Parse command line arguments */
int opt = 0;
- while ((opt = getopt_long(argc, argv, "+c:C:m:s:t:befxXvhV", opts, NULL)) != -1) {
+ while ((opt = getopt_long(argc, argv, "+c:C:m:s:t:befxXvhV::", opts, NULL)) != -1) {
switch (opt) {
case 'c':
params.orig_config = optarg;
@@ -147,7 +147,7 @@ int main(int argc, char **argv)
print_help();
return EXIT_SUCCESS;
case 'V':
- print_version(PROGRAM_NAME);
+ print_version(PROGRAM_NAME, optarg != NULL);
return EXIT_SUCCESS;
default:
print_help();
diff --git a/src/utils/knotd/main.c b/src/utils/knotd/main.c
index 2e4ac02da..1bf7c4540 100644
--- a/src/utils/knotd/main.c
+++ b/src/utils/knotd/main.c
@@ -44,6 +44,7 @@
#include "knot/common/systemd.h"
#include "knot/server/server.h"
#include "knot/server/tcp-handler.h"
+#include "utils/common/params.h"
#define PROGRAM_NAME "knotd"
@@ -362,11 +363,6 @@ static void print_help(void)
CONF_MAPSIZE, RUN_DIR "/knot.sock");
}
-static void print_version(void)
-{
- printf("%s (Knot DNS), version %s\n", PROGRAM_NAME, PACKAGE_VERSION);
-}
-
static int set_config(const char *confdb, const char *config, size_t max_conf_size)
{
if (config != NULL && confdb != NULL) {
@@ -439,7 +435,7 @@ int main(int argc, char **argv)
{ "daemonize", optional_argument, NULL, 'd' },
{ "verbose", no_argument, NULL, 'v' },
{ "help", no_argument, NULL, 'h' },
- { "version", no_argument, NULL, 'V' },
+ { "version", optional_argument, NULL, 'V' },
{ NULL }
};
@@ -448,7 +444,7 @@ int main(int argc, char **argv)
/* Parse command line arguments. */
int opt = 0;
- while ((opt = getopt_long(argc, argv, "c:C:m:s:dvhV", opts, NULL)) != -1) {
+ while ((opt = getopt_long(argc, argv, "c:C:m:s:dvhV::", opts, NULL)) != -1) {
switch (opt) {
case 'c':
config = optarg;
@@ -480,7 +476,7 @@ int main(int argc, char **argv)
print_help();
return EXIT_SUCCESS;
case 'V':
- print_version();
+ print_version(PROGRAM_NAME, optarg != NULL);
return EXIT_SUCCESS;
default:
print_help();
diff --git a/src/utils/knsec3hash/knsec3hash.c b/src/utils/knsec3hash/knsec3hash.c
index a7bac978d..08d420316 100644
--- a/src/utils/knsec3hash/knsec3hash.c
+++ b/src/utils/knsec3hash/knsec3hash.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2022 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
+/* Copyright (C) 2023 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -103,19 +103,19 @@ static bool parse_nsec3_params(dnssec_nsec3_params_t *params, const char *salt_s
int main(int argc, char *argv[])
{
struct option options[] = {
- { "help", no_argument, NULL, 'h' },
- { "version", no_argument, NULL, 'V' },
+ { "help", no_argument, NULL, 'h' },
+ { "version", optional_argument, NULL, 'V' },
{ NULL }
};
int opt = 0;
- while ((opt = getopt_long(argc, argv, "hV", options, NULL)) != -1) {
+ while ((opt = getopt_long(argc, argv, "hV::", options, NULL)) != -1) {
switch(opt) {
case 'h':
print_help();
return EXIT_SUCCESS;
case 'V':
- print_version(PROGRAM_NAME);
+ print_version(PROGRAM_NAME, optarg != NULL);
return EXIT_SUCCESS;
default:
print_help();
diff --git a/src/utils/knsupdate/knsupdate_params.c b/src/utils/knsupdate/knsupdate_params.c
index f9fa41fb9..44ac9f3c9 100644
--- a/src/utils/knsupdate/knsupdate_params.c
+++ b/src/utils/knsupdate/knsupdate_params.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2022 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
+/* Copyright (C) 2023 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -190,14 +190,14 @@ int knsupdate_parse(knsupdate_params_t *params, int argc, char *argv[])
// Long options.
struct option opts[] = {
- { "help", no_argument, NULL, 'h' },
- { "version", no_argument, NULL, 'V' },
+ { "help", no_argument, NULL, 'h' },
+ { "version", optional_argument, NULL, 'V' },
{ NULL }
};
/* Command line options processing. */
int opt = 0;
- while ((opt = getopt_long(argc, argv, "dhDvVp:t:r:y:k:", opts, NULL))
+ while ((opt = getopt_long(argc, argv, "dhDvV::p:t:r:y:k:", opts, NULL))
!= -1) {
switch (opt) {
case 'd':
@@ -212,7 +212,7 @@ int knsupdate_parse(knsupdate_params_t *params, int argc, char *argv[])
params->protocol = PROTO_TCP;
break;
case 'V':
- print_version(PROGRAM_NAME);
+ print_version(PROGRAM_NAME, optarg != NULL);
params->stop = true;
return KNOT_EOK;
case 'p':
diff --git a/src/utils/kxdpgun/main.c b/src/utils/kxdpgun/main.c
index 3a0dabe2e..5a5e94c46 100644
--- a/src/utils/kxdpgun/main.c
+++ b/src/utils/kxdpgun/main.c
@@ -1213,7 +1213,7 @@ static bool get_opts(int argc, char *argv[], xdp_gun_ctx_t *ctx)
{
struct option opts[] = {
{ "help", no_argument, NULL, 'h' },
- { "version", no_argument, NULL, 'V' },
+ { "version", optional_argument, NULL, 'V' },
{ "duration", required_argument, NULL, 't' },
{ "qps", required_argument, NULL, 'Q' },
{ "batch", required_argument, NULL, 'b' },
@@ -1237,13 +1237,13 @@ static bool get_opts(int argc, char *argv[], xdp_gun_ctx_t *ctx)
bool default_at_once = true;
double argf;
char *argcp, *local_ip = NULL, *filename = NULL;
- while ((opt = getopt_long(argc, argv, "hVt:Q:b:rp:T::U::F:I:l:i:L:R:v:m:G:", opts, NULL)) != -1) {
+ while ((opt = getopt_long(argc, argv, "hV::t:Q:b:rp:T::U::F:I:l:i:L:R:v:m:G:", opts, NULL)) != -1) {
switch (opt) {
case 'h':
print_help();
exit(EXIT_SUCCESS);
case 'V':
- print_version(PROGRAM_NAME);
+ print_version(PROGRAM_NAME, optarg != NULL);
exit(EXIT_SUCCESS);
case 't':
assert(optarg);
diff --git a/src/utils/kzonecheck/main.c b/src/utils/kzonecheck/main.c
index 3a2b620ad..521ae8817 100644
--- a/src/utils/kzonecheck/main.c
+++ b/src/utils/kzonecheck/main.c
@@ -78,7 +78,7 @@ int main(int argc, char *argv[])
{ "print", no_argument, NULL, 'p' },
{ "verbose", no_argument, NULL, 'v' },
{ "help", no_argument, NULL, 'h' },
- { "version", no_argument, NULL, 'V' },
+ { "version", optional_argument, NULL, 'V' },
{ NULL }
};
@@ -87,7 +87,7 @@ int main(int argc, char *argv[])
/* Parse command line arguments */
int opt = 0;
- while ((opt = getopt_long(argc, argv, "o:t:d:pvVh", opts, NULL)) != -1) {
+ while ((opt = getopt_long(argc, argv, "o:t:d:pvV::h", opts, NULL)) != -1) {
switch (opt) {
case 'o':
origin = optarg;
@@ -102,7 +102,7 @@ int main(int argc, char *argv[])
print_help();
return EXIT_SUCCESS;
case 'V':
- print_version(PROGRAM_NAME);
+ print_version(PROGRAM_NAME, optarg != NULL);
return EXIT_SUCCESS;
case 'd':
optional = str2bool(optarg) ? SEMCHECK_DNSSEC_ON : SEMCHECK_DNSSEC_OFF;
diff --git a/src/utils/kzonesign/main.c b/src/utils/kzonesign/main.c
index e70abb64c..fd43bdbc7 100644
--- a/src/utils/kzonesign/main.c
+++ b/src/utils/kzonesign/main.c
@@ -204,7 +204,7 @@ int main(int argc, char *argv[])
{ "verify" , no_argument, NULL, 'v' },
{ "time", required_argument, NULL, 't' },
{ "help", no_argument, NULL, 'h' },
- { "version", no_argument, NULL, 'V' },
+ { "version", optional_argument, NULL, 'V' },
{ NULL }
};
@@ -212,7 +212,7 @@ int main(int argc, char *argv[])
signal_init_std();
int opt = 0;
- while ((opt = getopt_long(argc, argv, "c:C:o:rvt:hV", opts, NULL)) != -1) {
+ while ((opt = getopt_long(argc, argv, "c:C:o:rvt:hV::", opts, NULL)) != -1) {
switch (opt) {
case 'c':
if (util_conf_init_file(optarg) != KNOT_EOK) {
@@ -245,7 +245,7 @@ int main(int argc, char *argv[])
print_help();
goto success;
case 'V':
- print_version(PROGRAM_NAME);
+ print_version(PROGRAM_NAME, optarg != NULL);
goto success;
default:
print_help();