summaryrefslogtreecommitdiffstats
path: root/tools/gpgtar.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2023-01-26 11:39:19 +0100
committerWerner Koch <wk@gnupg.org>2023-01-26 11:40:10 +0100
commit1ab21c82c342618051319c93125945c62142ec03 (patch)
tree5536b29cedf6e8f03d1b0701a6c03004f37b9955 /tools/gpgtar.c
parentpo: Update Japanese Translation. (diff)
downloadgnupg2-1ab21c82c342618051319c93125945c62142ec03.tar.xz
gnupg2-1ab21c82c342618051319c93125945c62142ec03.zip
gpgtar: Allow decryption from stdin.
* tools/gpgtar.c (main): Revamp switch and fix usage test for aDecrypt and aList. -- GnuPG-bug-id: 6355
Diffstat (limited to '')
-rw-r--r--tools/gpgtar.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/tools/gpgtar.c b/tools/gpgtar.c
index 8461666b9..b412f3ffb 100644
--- a/tools/gpgtar.c
+++ b/tools/gpgtar.c
@@ -499,17 +499,27 @@ main (int argc, char **argv)
switch (cmd)
{
+ case aDecrypt:
case aList:
if (argc > 1)
gpgrt_usage (1);
- fname = argc ? *argv : NULL;
+ fname = (argc && strcmp (*argv, "-"))? *argv : NULL;
if (opt.filename)
log_info ("note: ignoring option --set-filename\n");
if (files_from)
log_info ("note: ignoring option --files-from\n");
- err = gpgtar_list (fname, !skip_crypto);
- if (err && log_get_errorcount (0) == 0)
- log_error ("listing archive failed: %s\n", gpg_strerror (err));
+ if (cmd == aDecrypt)
+ {
+ err = gpgtar_extract (fname, !skip_crypto);
+ if (err && !log_get_errorcount (0))
+ log_error ("extracting archive failed: %s\n", gpg_strerror (err));
+ }
+ else
+ {
+ err = gpgtar_list (fname, !skip_crypto);
+ if (err && !log_get_errorcount (0))
+ log_error ("listing archive failed: %s\n", gpg_strerror (err));
+ }
break;
case aEncrypt:
@@ -530,19 +540,6 @@ main (int argc, char **argv)
log_error ("creating archive failed: %s\n", gpg_strerror (err));
break;
- case aDecrypt:
- if (argc != 1)
- gpgrt_usage (1);
- if (opt.outfile)
- log_info ("note: ignoring option --output\n");
- if (files_from)
- log_info ("note: ignoring option --files-from\n");
- fname = argc ? *argv : NULL;
- err = gpgtar_extract (fname, !skip_crypto);
- if (err && log_get_errorcount (0) == 0)
- log_error ("extracting archive failed: %s\n", gpg_strerror (err));
- break;
-
default:
log_error (_("invalid command (there is no implicit command)\n"));
break;