From 12d0092edb3a329ba03f5cba039b6c3523a90de3 Mon Sep 17 00:00:00 2001 From: Libor Peltan Date: Mon, 2 Aug 2021 18:30:21 +0200 Subject: [PATCH] keymgr: new -D param instead of deprecated -d --- doc/man/keymgr.8in | 2 +- doc/man_keymgr.rst | 2 +- src/utils/keymgr/functions.h | 3 ++- src/utils/keymgr/main.c | 11 +++++++---- tests-extra/tests/catalog/basic/test.py | 2 +- tests-extra/tests/catalog/groups/test.py | 2 +- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/doc/man/keymgr.8in b/doc/man/keymgr.8in index de786632fc..31ed7fcdc3 100644 --- a/doc/man/keymgr.8in +++ b/doc/man/keymgr.8in @@ -83,7 +83,7 @@ Use a binary configuration database directory (default is \fB@storage_dir@/confd The default configuration database, if exists, has a preference to the default configuration file. .TP -\fB\-d\fP, \fB\-\-dir\fP \fIpath\fP +\fB\-D\fP, \fB\-\-dir\fP \fIpath\fP Use specified KASP database path and default configuration. .UNINDENT .sp diff --git a/doc/man_keymgr.rst b/doc/man_keymgr.rst index 19844bc0d3..0c0dc11879 100644 --- a/doc/man_keymgr.rst +++ b/doc/man_keymgr.rst @@ -60,7 +60,7 @@ Config options The default configuration database, if exists, has a preference to the default configuration file. -**-d**, **--dir** *path* +**-D**, **--dir** *path* Use specified KASP database path and default configuration. .. NOTE:: diff --git a/src/utils/keymgr/functions.h b/src/utils/keymgr/functions.h index 398088543f..277cfc4486 100644 --- a/src/utils/keymgr/functions.h +++ b/src/utils/keymgr/functions.h @@ -20,7 +20,8 @@ #include "knot/dnssec/context.h" -#define ERROR(msg, ...) { fprintf(stderr, "Error: " msg, ##__VA_ARGS__); fflush(stderr); } +#define ERROR(msg, ...) { fprintf(stderr, "Error: " msg, ##__VA_ARGS__); fflush(stderr); } +#define WARNING(msg, ...) { fprintf(stderr, "Warning: " msg, ##__VA_ARGS__); fflush(stderr); } typedef struct { knot_time_print_t format; diff --git a/src/utils/keymgr/main.c b/src/utils/keymgr/main.c index 015603d738..bc24b787cc 100644 --- a/src/utils/keymgr/main.c +++ b/src/utils/keymgr/main.c @@ -47,7 +47,7 @@ static void print_help(void) " (default %s)\n" " -C, --confdb Use a binary configuration database directory.\n" " (default %s)\n" - " -d, --dir Use specified KASP database path and default configuration.\n" + " -D, --dir Use specified KASP database path and default configuration.\n" " -t, --tsig [alg] Generate a TSIG key.\n" " -l, --list List all zones that have at least one key in KASP database.\n" " -x, --mono Don't color the output.\n" @@ -369,7 +369,7 @@ int main(int argc, char *argv[]) struct option opts[] = { { "config", required_argument, NULL, 'c' }, { "confdb", required_argument, NULL, 'C' }, - { "dir", required_argument, NULL, 'd' }, + { "dir", required_argument, NULL, 'D' }, { "tsig", required_argument, NULL, 't' }, { "brief", no_argument, NULL, 'b' }, { "list", no_argument, NULL, 'l' }, @@ -389,7 +389,7 @@ int main(int argc, char *argv[]) list_params.color = isatty(STDOUT_FILENO); int opt = 0, parm = 0; - while ((opt = getopt_long(argc, argv, "hVd:c:C:t:lbxX", opts, NULL)) != -1) { + while ((opt = getopt_long(argc, argv, "hVd:D:c:C:t:lbxX", opts, NULL)) != -1) { switch (opt) { case 'h': print_help(); @@ -398,6 +398,9 @@ int main(int argc, char *argv[]) print_version(PROGRAM_NAME); return EXIT_SUCCESS; case 'd': + WARNING("keymgr -d is deprecated, use -D option instead\n"); + // FALLTHROUGH + case 'D': CHECK_CONF_UNINIT if (!init_conf(NULL) || !init_conf_blank(optarg)) { return EXIT_FAILURE; @@ -450,7 +453,7 @@ int main(int argc, char *argv[]) init_conf(NULL) && init_confile(CONF_DEFAULT_FILE)) { // initialized conf from default confile } else { - ERROR("couldn't initialize configuration, please provide -c, -C, or -d option\n"); + ERROR("couldn't initialize configuration, please provide -c, -C, or -D option\n"); return EXIT_FAILURE; } } diff --git a/tests-extra/tests/catalog/basic/test.py b/tests-extra/tests/catalog/basic/test.py index b4b1920a1b..80f6abbf31 100644 --- a/tests-extra/tests/catalog/basic/test.py +++ b/tests-extra/tests/catalog/basic/test.py @@ -14,7 +14,7 @@ import subprocess import random def check_keys(server, zone_name, expect_keys): - cmd = Popen([dnstest.params.keymgr_bin, "-d", server.dir + "/keys", zone_name, "list"], stdout=PIPE, stderr=PIPE, universal_newlines=True) + cmd = Popen([dnstest.params.keymgr_bin, "-D", server.dir + "/keys", zone_name, "list"], stdout=PIPE, stderr=PIPE, universal_newlines=True) (stdout, stderr) = cmd.communicate() lines = len(stdout.splitlines()) if lines != expect_keys: diff --git a/tests-extra/tests/catalog/groups/test.py b/tests-extra/tests/catalog/groups/test.py index 764e1d3a50..9ef9705b40 100644 --- a/tests-extra/tests/catalog/groups/test.py +++ b/tests-extra/tests/catalog/groups/test.py @@ -14,7 +14,7 @@ import subprocess import random def check_keys(server, zone_name, expect_keys): - cmd = Popen([dnstest.params.keymgr_bin, "-d", server.dir + "/keys", zone_name, "list"], \ + cmd = Popen([dnstest.params.keymgr_bin, "-D", server.dir + "/keys", zone_name, "list"], \ stdout=PIPE, stderr=PIPE, universal_newlines=True) (stdout, stderr) = cmd.communicate() lines = len(stdout.splitlines()) -- 2.47.3