summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorIngo Klöcker <dev@ingo-kloecker.de>2023-01-23 12:17:22 +0100
committerIngo Klöcker <dev@ingo-kloecker.de>2023-01-23 12:17:22 +0100
commit419adf41afa40e5b34f646f2cb16d8aebda20048 (patch)
tree36bc59215f41a551f6dfeecd3fe5b4c975969c35 /tests
parent4c872b674189d84d936d6c5cbe18b27c90c162e0 (diff)
downloadgpgme-419adf41afa40e5b34f646f2cb16d8aebda20048.tar.gz
core: Allow setting the base directory when creating an archive
* src/engine-gpg.c (gpg_encrypt, gpg_encrypt_sign, gpg_sign): Pass file name set in data with --directory option to gpgtar. * tests/run-encrypt.c (show_usage): New option --directory. (main): Parse new option. Set file name of input data to option value. * tests/run-sign.c (show_usage): New option --directory. (main): Parse new option. Set file name of input data to option value. -- GnuPG-bug-id: 6342
Diffstat (limited to 'tests')
-rw-r--r--tests/run-encrypt.c16
-rw-r--r--tests/run-sign.c16
2 files changed, 32 insertions, 0 deletions
diff --git a/tests/run-encrypt.c b/tests/run-encrypt.c
index 82a2cead..2d1c6e9d 100644
--- a/tests/run-encrypt.c
+++ b/tests/run-encrypt.c
@@ -134,6 +134,7 @@ show_usage (int ex)
" --wrap assume input is valid OpenPGP message\n"
" --symmetric encrypt symmetric (OpenPGP only)\n"
" --archive encrypt given file or directory into an archive\n"
+ " --directory DIR switch to directory DIR before encrypting into an archive\n"
" --diagnostics print diagnostics\n"
, stderr);
exit (ex);
@@ -157,6 +158,7 @@ main (int argc, char **argv)
gpgme_key_t keys[10+1];
int keycount = 0;
char *keystring = NULL;
+ const char *directory = NULL;
int i;
gpgme_encrypt_flags_t flags = GPGME_ENCRYPT_ALWAYS_TRUST;
gpgme_off_t offset;
@@ -266,6 +268,14 @@ main (int argc, char **argv)
flags |= GPGME_ENCRYPT_ARCHIVE;
argc--; argv++;
}
+ else if (!strcmp (*argv, "--directory"))
+ {
+ argc--; argv++;
+ if (!argc)
+ show_usage (1);
+ directory = *argv;
+ argc--; argv++;
+ }
else if (!strcmp (*argv, "--diagnostics"))
{
diagnostics = 1;
@@ -319,6 +329,12 @@ main (int argc, char **argv)
{
const char *path = *argv;
err = gpgme_data_new_from_mem (&in, path, strlen (path), 0);
+ fail_if_err (err);
+ if (directory)
+ {
+ err = gpgme_data_set_file_name (in, directory);
+ fail_if_err (err);
+ }
}
else
{
diff --git a/tests/run-sign.c b/tests/run-sign.c
index 73a970d0..84d7c070 100644
--- a/tests/run-sign.c
+++ b/tests/run-sign.c
@@ -88,6 +88,7 @@ show_usage (int ex)
" --include-key-block use this option with gpg\n"
" --clear create a clear text signature\n"
" --archive create a signed archive with the given file or directory\n"
+ " --directory DIR switch to directory DIR before creating the archive\n"
" --diagnostics print diagnostics\n"
, stderr);
exit (ex);
@@ -101,6 +102,7 @@ main (int argc, char **argv)
gpgme_error_t err;
gpgme_ctx_t ctx;
const char *key_string = NULL;
+ const char *directory = NULL;
gpgme_protocol_t protocol = GPGME_PROTOCOL_OpenPGP;
gpgme_sig_mode_t sigmode = GPGME_SIG_MODE_NORMAL;
gpgme_data_t in, out;
@@ -186,6 +188,14 @@ main (int argc, char **argv)
sigmode = GPGME_SIG_MODE_ARCHIVE;
argc--; argv++;
}
+ else if (!strcmp (*argv, "--directory"))
+ {
+ argc--; argv++;
+ if (!argc)
+ show_usage (1);
+ directory = *argv;
+ argc--; argv++;
+ }
else if (!strcmp (*argv, "--diagnostics"))
{
diagnostics = 1;
@@ -253,6 +263,12 @@ main (int argc, char **argv)
{
const char *path = *argv;
err = gpgme_data_new_from_mem (&in, path, strlen (path), 0);
+ fail_if_err (err);
+ if (directory)
+ {
+ err = gpgme_data_set_file_name (in, directory);
+ fail_if_err (err);
+ }
}
else
{