From 95ea3bf831aeac201108876e73750692aa1ba3f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20Kl=C3=B6cker?= Date: Tue, 24 Jan 2023 11:05:52 +0100 Subject: core: Support usage of gpgtar for decrypting an encrypted archive * src/gpgme.h.in (GPGME_DECRYPT_ARCHIVE): New decryption flag. * src/engine-gpg.c (gpg_decrypt): Set use_gpgtar engine flag if GPGME_DECRYPT_ARCHIVE flag is set. Check for new enough gpg and incompatible flags. Use add_gpg_arg_with_value for gpg-only options with a value and add_gpg_arg for gpg-only options without a value. Set extra options for gpgtar and pass input data to stdin when using gpgtar. * tests/run-decrypt.c (show_usage): New options --archive and --directory. (main): Parse new options. Decrypt with gpgtar if --archive is given. Set file name of output data to value of --directory option. -- GnuPG-bug-id: 6342 --- tests/run-decrypt.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'tests') diff --git a/tests/run-decrypt.c b/tests/run-decrypt.c index cf719925..ee49ead6 100644 --- a/tests/run-decrypt.c +++ b/tests/run-decrypt.c @@ -91,6 +91,8 @@ show_usage (int ex) " --unwrap remove only the encryption layer\n" " --large-buffers use large I/O buffer\n" " --sensitive mark data objects as sensitive\n" + " --archive extract files from an encrypted archive\n" + " --directory DIR extract the files into the directory DIR\n" " --diagnostics print diagnostics\n" , stderr); exit (ex); @@ -113,6 +115,7 @@ main (int argc, char **argv) int export_session_key = 0; const char *override_session_key = NULL; const char *request_origin = NULL; + const char *directory = NULL; int no_symkey_cache = 0; int ignore_mdc_error = 0; int raw_output = 0; @@ -205,6 +208,19 @@ main (int argc, char **argv) raw_output = 1; argc--; argv++; } + else if (!strcmp (*argv, "--archive")) + { + flags |= GPGME_DECRYPT_ARCHIVE; + argc--; argv++; + } + else if (!strcmp (*argv, "--directory")) + { + argc--; argv++; + if (!argc) + show_usage (1); + directory = *argv; + argc--; argv++; + } else if (!strncmp (*argv, "--", 2)) show_usage (1); @@ -302,6 +318,16 @@ main (int argc, char **argv) gpgme_strerror (err)); exit (1); } + if (directory && (flags & GPGME_DECRYPT_ARCHIVE)) + { + err = gpgme_data_set_file_name (out, directory); + if (err) + { + fprintf (stderr, PGM ": error setting file name (out): %s\n", + gpgme_strerror (err)); + exit (1); + } + } if (large_buffers) { err = gpgme_data_set_flag (out, "io-buffer-size", "1000000"); -- cgit v1.2.3