summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Harris <jgh146exb@wizmail.org>2022-04-19 21:44:17 +0100
committerJeremy Harris <jgh146exb@wizmail.org>2022-04-19 21:44:17 +0100
commit97c83a31f1269ac154408a571b9207c6f3552fc9 (patch)
tree911dcdc32cb91e6ff7c088ff1c62a43afb38ee39
parentec2a355fdc961aba7ace27c624c01accd58dc1ed (diff)
exim_dumpdb: keys-only output option
-rw-r--r--doc/doc-docbook/spec.xfpt3
-rw-r--r--src/src/exim_dbutil.c30
-rw-r--r--test/scripts/5892-Resume-OpenSSL/58925
-rw-r--r--test/stdout/58922
4 files changed, 25 insertions, 15 deletions
diff --git a/doc/doc-docbook/spec.xfpt b/doc/doc-docbook/spec.xfpt
index 89f762436..2b445e328 100644
--- a/doc/doc-docbook/spec.xfpt
+++ b/doc/doc-docbook/spec.xfpt
@@ -39954,8 +39954,9 @@ The entire contents of a database are written to the standard output by the
&'exim_dumpdb'& program,
.new
taking as arguments the spool and database names.
-An option &'-z'& may be given to regest times in UTC;
+An option &'-z'& may be given to request times in UTC;
otherwise times are in the local timezone.
+An option &'-k'& may be given to dump only the record keys.
.wen
For example, to dump the retry database:
.code
diff --git a/src/src/exim_dbutil.c b/src/src/exim_dbutil.c
index 2cee43b85..3a38c8df2 100644
--- a/src/src/exim_dbutil.c
+++ b/src/src/exim_dbutil.c
@@ -47,6 +47,7 @@ whose inclusion is controlled by -D on the compilation command. */
uschar *spool_directory;
+BOOL keyonly = FALSE;
BOOL utc = FALSE;
@@ -125,13 +126,13 @@ check_args(int argc, uschar **argv, uschar *name, uschar *options)
uschar * aname = argv[optind + 1];
if (argc - optind == 2)
{
- if (Ustrcmp(aname, "retry") == 0) return type_retry;
- if (Ustrcmp(aname, "misc") == 0) return type_misc;
+ if (Ustrcmp(aname, "retry") == 0) return type_retry;
+ if (Ustrcmp(aname, "misc") == 0) return type_misc;
if (Ustrncmp(aname, "wait-", 5) == 0) return type_wait;
- if (Ustrcmp(aname, "callout") == 0) return type_callout;
+ if (Ustrcmp(aname, "callout") == 0) return type_callout;
if (Ustrcmp(aname, "ratelimit") == 0) return type_ratelimit;
- if (Ustrcmp(aname, "tls") == 0) return type_tls;
- if (Ustrcmp(aname, "seen") == 0) return type_seen;
+ if (Ustrcmp(aname, "tls") == 0) return type_tls;
+ if (Ustrcmp(aname, "seen") == 0) return type_seen;
}
usage(name, options);
return -1; /* Never obeyed */
@@ -140,16 +141,17 @@ return -1; /* Never obeyed */
FUNC_MAYBE_UNUSED
static void
-options(int argc, uschar * argv[], uschar * name)
+options(int argc, uschar * argv[], uschar * name, const uschar * opts)
{
int opt;
opterr = 0;
-while ((opt = getopt(argc, (char * const *)argv, "z")) != -1)
+while ((opt = getopt(argc, (char * const *)argv, CCS opts)) != -1)
switch (opt)
{
+ case 'k': keyonly = TRUE; break;
case 'z': utc = TRUE; break;
- default: usage(name, US" [-z]");
+ default: usage(name, US" [-z] [-k]");
}
}
@@ -558,11 +560,11 @@ uschar **argv = USS cargv;
uschar keybuffer[1024];
store_init();
-options(argc, argv, US"dumpdb");
+options(argc, argv, US"dumpdb", US"kz");
/* Check the arguments, and open the database */
-dbdata_type = check_args(argc, argv, US"dumpdb", US" [-z]");
+dbdata_type = check_args(argc, argv, US"dumpdb", US" [-z] [-k]");
argc -= optind; argv += optind;
spool_directory = argv[0];
@@ -601,12 +603,13 @@ for (uschar * key = dbfn_scan(dbm, TRUE, &cursor);
}
Ustrcpy(keybuffer, key);
- if (!(value = dbfn_read_with_length(dbm, keybuffer, &length)))
+ if (keyonly)
+ printf(" %s\n", keybuffer);
+ else if (!(value = dbfn_read_with_length(dbm, keybuffer, &length)))
fprintf(stderr, "**** Entry \"%s\" was in the key scan, but the record "
"was not found in the file - something is wrong!\n",
CS keybuffer);
else
- {
/* Note: don't use print_time more than once in one statement, since
it uses a single buffer. */
@@ -729,7 +732,6 @@ for (uschar * key = dbfn_scan(dbm, TRUE, &cursor);
printf("%s\t%s\n", keybuffer, print_time(seen->time_stamp));
break;
}
- }
store_reset(reset_point);
}
@@ -785,7 +787,7 @@ rmark reset_point;
uschar * aname;
store_init();
-options(argc, argv, US"fixdb");
+options(argc, argv, US"fixdb", US"z");
name[0] = 0; /* No name set */
/* Sort out the database type, verify what we are working on and then process
diff --git a/test/scripts/5892-Resume-OpenSSL/5892 b/test/scripts/5892-Resume-OpenSSL/5892
index 814a27b6b..e09fc6398 100644
--- a/test/scripts/5892-Resume-OpenSSL/5892
+++ b/test/scripts/5892-Resume-OpenSSL/5892
@@ -46,5 +46,10 @@ exim -DVALUE=resume -DHELO_MSG=differenthost -odf resume@test.ex
exim -DVALUE=resume -odf resume@test.ex
****
#
+# Check the -k (key only) option on dumpdb
+perl
+system 'DIR/eximdir/exim_dumpdb -k DIR/spool tls';
+****
+#
killdaemon
no_msglog_check
diff --git a/test/stdout/5892 b/test/stdout/5892
index 6f9aa1388..23a7bcf3e 100644
--- a/test/stdout/5892
+++ b/test/stdout/5892
@@ -1,4 +1,6 @@
### TLS1.2
+ 4686560d7a1d9becb8fd0c62406eaaf169b2ea1b889244342653024281bca106
+ b90422e57483069e0b7dbcebbdf1be3504bae64df49ea1f699cc773acc8a76d5
******** SERVER ********
### TLS1.2