From f4248636af4e0042bc0b74b034d047a3af0084e0 Mon Sep 17 00:00:00 2001
From: Daniel Salzman <daniel.salzman@nic.cz>
Date: Mon, 6 Sep 2021 11:01:28 +0200
Subject: [PATCH] Revert "keymgr: new -D param instead of deprecated -d"

This reverts commit 29decc3eb18804409e8c68f16be602bda7ef6e51.
---
 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, 9 insertions(+), 13 deletions(-)

diff --git a/doc/man/keymgr.8in b/doc/man/keymgr.8in
index 31ed7fcdc3..de786632fc 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 0c0dc11879..19844bc0d3 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 277cfc4486..398088543f 100644
--- a/src/utils/keymgr/functions.h
+++ b/src/utils/keymgr/functions.h
@@ -20,8 +20,7 @@
 
 #include "knot/dnssec/context.h"
 
-#define ERROR(msg, ...)   { fprintf(stderr, "Error: " msg, ##__VA_ARGS__); fflush(stderr); }
-#define WARNING(msg, ...) { fprintf(stderr, "Warning: " msg, ##__VA_ARGS__); fflush(stderr); }
+#define ERROR(msg, ...)	{ fprintf(stderr, "Error: " 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 bc24b787cc..015603d738 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 <dir>       Use a binary configuration database directory.\n"
 	       "                            (default %s)\n"
-	       "  -D, --dir <path>         Use specified KASP database path and default configuration.\n"
+	       "  -d, --dir <path>         Use specified KASP database path and default configuration.\n"
 	       "  -t, --tsig <name> [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:D:c:C:t:lbxX", opts, NULL)) != -1) {
+	while ((opt = getopt_long(argc, argv, "hVd:c:C:t:lbxX", opts, NULL)) != -1) {
 		switch (opt) {
 		case 'h':
 			print_help();
@@ -398,9 +398,6 @@ 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;
@@ -453,7 +450,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 80f6abbf31..b4b1920a1b 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 9ef9705b40..764e1d3a50 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())
-- 
GitLab