aboutsummaryrefslogtreecommitdiffstats
path: root/tools/gpgtar-create.c
diff options
context:
space:
mode:
authorJustus Winter <[email protected]>2015-11-30 15:21:22 +0000
committerJustus Winter <[email protected]>2015-12-04 11:52:40 +0000
commit0c0dafd8e89bb702e856c661c1561e10cdcaf37f (patch)
treec5873a51c9a8ba8edf13d49c21d416a8d1011697 /tools/gpgtar-create.c
parentcommon: Add a stream interface to 'sh-exectool'. (diff)
downloadgnupg-0c0dafd8e89bb702e856c661c1561e10cdcaf37f.tar.gz
gnupg-0c0dafd8e89bb702e856c661c1561e10cdcaf37f.zip
tools/gpgtar: Use the new exectool helper.
* tools/Makefile.am: gpgtar now requires neither npth nor libassuan. * tools/gpgtar-create.c (gpgtar_create): Use the new 'sh-exectool' helper. * tools/gpgtar-extract.c (gpgtar_extract): Likewise. * tools/gpgtar-list.c (gpgtar_list): Likewise. * tools/gpgtar.c (main): Set default gpg program. Drop the initialization of npth and libassuan. Signed-off-by: Justus Winter <[email protected]>
Diffstat (limited to 'tools/gpgtar-create.c')
-rw-r--r--tools/gpgtar-create.c38
1 files changed, 31 insertions, 7 deletions
diff --git a/tools/gpgtar-create.c b/tools/gpgtar-create.c
index cc82889ab..8975fc6ba 100644
--- a/tools/gpgtar-create.c
+++ b/tools/gpgtar-create.c
@@ -36,7 +36,7 @@
#include <assert.h>
#include "i18n.h"
-#include "../common/call-gpg.h"
+#include "../common/sh-exectool.h"
#include "../common/sysutils.h"
#include "gpgtar.h"
@@ -888,16 +888,40 @@ gpgtar_create (char **inpattern, int encrypt)
if (encrypt)
{
+ int i;
+ strlist_t arg;
+ const char **argv;
+
err = es_fseek (outstream, 0, SEEK_SET);
if (err)
goto leave;
- err = gpg_encrypt_stream (NULL,
- opt.gpg_program,
- opt.gpg_arguments,
- outstream,
- opt.recipients,
- cipher_stream);
+ argv = xtrycalloc (strlist_length (opt.gpg_arguments)
+ + 2 * strlist_length (opt.recipients)
+ + 2,
+ sizeof *argv);
+ if (argv == NULL)
+ {
+ err = gpg_error_from_syserror ();
+ goto leave;
+ }
+ i = 0;
+ argv[i++] = "--encrypt";
+ for (arg = opt.recipients; arg; arg = arg->next)
+ {
+ argv[i++] = "--recipient";
+ argv[i++] = arg->d;
+ }
+ for (arg = opt.gpg_arguments; arg; arg = arg->next)
+ argv[i++] = arg->d;
+ argv[i++] = NULL;
+ assert (i == strlist_length (opt.gpg_arguments)
+ + 2 * strlist_length (opt.recipients)
+ + 2);
+
+ err = sh_exec_tool_stream (opt.gpg_program, argv,
+ outstream, cipher_stream);
+ xfree (argv);
if (err)
goto leave;
}