aboutsummaryrefslogtreecommitdiffstats
path: root/tools/gpgtar.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2023-04-18 06:04:05 +0000
committerWerner Koch <[email protected]>2023-04-18 06:04:48 +0000
commitba67fea5b9bb093f446dbd1ed2f88248d269d495 (patch)
tree89737c8ffd8a88c26ee95314039e3552a875fdb6 /tools/gpgtar.c
parentgpg: Allow overridden key import when stub exists. (diff)
downloadgnupg-ba67fea5b9bb093f446dbd1ed2f88248d269d495.tar.gz
gnupg-ba67fea5b9bb093f446dbd1ed2f88248d269d495.zip
gpgtar: Read common.conf for the log-file option.
* common/util.h (GNUPG_MODULE_NAME_GPGTAR): New. * common/homedir.c (gnupg_module_name): Add it. * tools/gpgtar.c: Include comopt.h. (enum cmd_and_opt_values): Add oDebug. (opts): Add --debug. (any_debug): New. (main): Parse common.conf. -- Having a way to see the output of gpgtar is often useful for debugging. The only effect of the debug option is to show whether common.conf was read.
Diffstat (limited to 'tools/gpgtar.c')
-rw-r--r--tools/gpgtar.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/tools/gpgtar.c b/tools/gpgtar.c
index 64e5306b2..b2ccc9f8a 100644
--- a/tools/gpgtar.c
+++ b/tools/gpgtar.c
@@ -42,6 +42,7 @@
#include "../common/openpgpdefs.h"
#include "../common/init.h"
#include "../common/strlist.h"
+#include "../common/comopt.h"
#include "gpgtar.h"
@@ -89,6 +90,7 @@ enum cmd_and_opt_values
oTarProgram,
/* Debugging. */
+ oDebug,
oDryRun
};
@@ -145,6 +147,8 @@ static gpgrt_opt_t opts[] = {
ARGPARSE_s_s (oTarArgs, "tar-args", "@"),
ARGPARSE_s_s (oTarProgram, "tar", "@"),
+ ARGPARSE_s_s (oDebug, "debug", "@"),
+
ARGPARSE_end ()
};
@@ -166,7 +170,7 @@ static enum cmd_and_opt_values cmd = 0;
static int skip_crypto = 0;
static const char *files_from = NULL;
static int null_names = 0;
-
+static int any_debug;
@@ -438,6 +442,10 @@ parse_arguments (gpgrt_argparse_t *pargs, gpgrt_opt_t *popts)
}
break;
+ case oDebug:
+ any_debug = 1;
+ break;
+
case oDryRun:
opt.dry_run = 1;
break;
@@ -471,6 +479,10 @@ main (int argc, char **argv)
/* Set default options */
opt.status_fd = -1;
+ /* The configuraton directories for use by gpgrt_argparser. */
+ gpgrt_set_confdir (GPGRT_CONFDIR_SYS, gnupg_sysconfdir ());
+ gpgrt_set_confdir (GPGRT_CONFDIR_USER, gnupg_homedir ());
+
/* Parse the command line. */
pargs.argc = &argc;
pargs.argv = &argv;
@@ -481,6 +493,10 @@ main (int argc, char **argv)
if (log_get_errorcount (0))
exit (2);
+ /* Get a log file from common.conf. */
+ if (!parse_comopt (GNUPG_MODULE_NAME_GPGTAR, any_debug) && comopt.logfile)
+ log_set_file (comopt.logfile);
+
/* Print a warning if an argument looks like an option. */
if (!opt.quiet && !(pargs.flags & ARGPARSE_FLAG_STOP_SEEN))
{