mirror of
git://git.gnupg.org/gnupg.git
synced 2025-03-26 22:29:58 +01:00
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 <justus@g10code.com>
This commit is contained in:
parent
a81aca6e1c
commit
0c0dafd8e8
@ -142,9 +142,8 @@ gpgtar_SOURCES = \
|
|||||||
gpgtar-extract.c \
|
gpgtar-extract.c \
|
||||||
gpgtar-list.c \
|
gpgtar-list.c \
|
||||||
no-libgcrypt.c
|
no-libgcrypt.c
|
||||||
gpgtar_CFLAGS = $(GPG_ERROR_CFLAGS) $(NPTH_CFLAGS) $(LIBASSUAN_CFLAGS)
|
gpgtar_CFLAGS = $(GPG_ERROR_CFLAGS)
|
||||||
gpgtar_LDADD = $(libcommonpth) $(GPG_ERROR_LIBS) \
|
gpgtar_LDADD = $(libcommon) $(GPG_ERROR_LIBS) \
|
||||||
$(NPTH_LIBS) $(LIBASSUAN_LIBS) \
|
|
||||||
$(LIBINTL) $(NETLIBS) $(LIBICONV) $(W32SOCKLIBS)
|
$(LIBINTL) $(NETLIBS) $(LIBICONV) $(W32SOCKLIBS)
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include "i18n.h"
|
#include "i18n.h"
|
||||||
#include "../common/call-gpg.h"
|
#include "../common/sh-exectool.h"
|
||||||
#include "../common/sysutils.h"
|
#include "../common/sysutils.h"
|
||||||
#include "gpgtar.h"
|
#include "gpgtar.h"
|
||||||
|
|
||||||
@ -888,16 +888,40 @@ gpgtar_create (char **inpattern, int encrypt)
|
|||||||
|
|
||||||
if (encrypt)
|
if (encrypt)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
strlist_t arg;
|
||||||
|
const char **argv;
|
||||||
|
|
||||||
err = es_fseek (outstream, 0, SEEK_SET);
|
err = es_fseek (outstream, 0, SEEK_SET);
|
||||||
if (err)
|
if (err)
|
||||||
goto leave;
|
goto leave;
|
||||||
|
|
||||||
err = gpg_encrypt_stream (NULL,
|
argv = xtrycalloc (strlist_length (opt.gpg_arguments)
|
||||||
opt.gpg_program,
|
+ 2 * strlist_length (opt.recipients)
|
||||||
opt.gpg_arguments,
|
+ 2,
|
||||||
outstream,
|
sizeof *argv);
|
||||||
opt.recipients,
|
if (argv == NULL)
|
||||||
cipher_stream);
|
{
|
||||||
|
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)
|
if (err)
|
||||||
goto leave;
|
goto leave;
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include "i18n.h"
|
#include "i18n.h"
|
||||||
#include "../common/call-gpg.h"
|
#include "../common/sh-exectool.h"
|
||||||
#include "../common/sysutils.h"
|
#include "../common/sysutils.h"
|
||||||
#include "gpgtar.h"
|
#include "gpgtar.h"
|
||||||
|
|
||||||
@ -299,6 +299,10 @@ gpgtar_extract (const char *filename, int decrypt)
|
|||||||
|
|
||||||
if (decrypt)
|
if (decrypt)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
strlist_t arg;
|
||||||
|
const char **argv;
|
||||||
|
|
||||||
cipher_stream = stream;
|
cipher_stream = stream;
|
||||||
stream = es_fopenmem (0, "rwb");
|
stream = es_fopenmem (0, "rwb");
|
||||||
if (! stream)
|
if (! stream)
|
||||||
@ -306,8 +310,24 @@ gpgtar_extract (const char *filename, int decrypt)
|
|||||||
err = gpg_error_from_syserror ();
|
err = gpg_error_from_syserror ();
|
||||||
goto leave;
|
goto leave;
|
||||||
}
|
}
|
||||||
err = gpg_decrypt_stream (NULL, opt.gpg_program, opt.gpg_arguments,
|
|
||||||
cipher_stream, stream);
|
argv = xtrycalloc (strlist_length (opt.gpg_arguments) + 2,
|
||||||
|
sizeof *argv);
|
||||||
|
if (argv == NULL)
|
||||||
|
{
|
||||||
|
err = gpg_error_from_syserror ();
|
||||||
|
goto leave;
|
||||||
|
}
|
||||||
|
i = 0;
|
||||||
|
argv[i++] = "--decrypt";
|
||||||
|
for (arg = opt.gpg_arguments; arg; arg = arg->next)
|
||||||
|
argv[i++] = arg->d;
|
||||||
|
argv[i++] = NULL;
|
||||||
|
assert (i == strlist_length (opt.gpg_arguments) + 2);
|
||||||
|
|
||||||
|
err = sh_exec_tool_stream (opt.gpg_program, argv,
|
||||||
|
cipher_stream, stream);
|
||||||
|
xfree (argv);
|
||||||
if (err)
|
if (err)
|
||||||
goto leave;
|
goto leave;
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
#include "i18n.h"
|
#include "i18n.h"
|
||||||
#include "gpgtar.h"
|
#include "gpgtar.h"
|
||||||
#include "../common/call-gpg.h"
|
#include "../common/sh-exectool.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -299,6 +299,10 @@ gpgtar_list (const char *filename, int decrypt)
|
|||||||
|
|
||||||
if (decrypt)
|
if (decrypt)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
strlist_t arg;
|
||||||
|
const char **argv;
|
||||||
|
|
||||||
cipher_stream = stream;
|
cipher_stream = stream;
|
||||||
stream = es_fopenmem (0, "rwb");
|
stream = es_fopenmem (0, "rwb");
|
||||||
if (! stream)
|
if (! stream)
|
||||||
@ -306,8 +310,24 @@ gpgtar_list (const char *filename, int decrypt)
|
|||||||
err = gpg_error_from_syserror ();
|
err = gpg_error_from_syserror ();
|
||||||
goto leave;
|
goto leave;
|
||||||
}
|
}
|
||||||
err = gpg_decrypt_stream (NULL, opt.gpg_program, opt.gpg_arguments,
|
|
||||||
cipher_stream, stream);
|
argv = xtrycalloc (strlist_length (opt.gpg_arguments) + 2,
|
||||||
|
sizeof *argv);
|
||||||
|
if (argv == NULL)
|
||||||
|
{
|
||||||
|
err = gpg_error_from_syserror ();
|
||||||
|
goto leave;
|
||||||
|
}
|
||||||
|
i = 0;
|
||||||
|
argv[i++] = "--decrypt";
|
||||||
|
for (arg = opt.gpg_arguments; arg; arg = arg->next)
|
||||||
|
argv[i++] = arg->d;
|
||||||
|
argv[i++] = NULL;
|
||||||
|
assert (i == strlist_length (opt.gpg_arguments) + 2);
|
||||||
|
|
||||||
|
err = sh_exec_tool_stream (opt.gpg_program, argv,
|
||||||
|
cipher_stream, stream);
|
||||||
|
xfree (argv);
|
||||||
if (err)
|
if (err)
|
||||||
goto leave;
|
goto leave;
|
||||||
|
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
gpg. So here we go. */
|
gpg. So here we go. */
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <assuan.h>
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <npth.h>
|
#include <npth.h>
|
||||||
@ -39,7 +38,6 @@
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "i18n.h"
|
#include "i18n.h"
|
||||||
#include "sysutils.h"
|
#include "sysutils.h"
|
||||||
#include "../common/asshelp.h"
|
|
||||||
#include "../common/openpgpdefs.h"
|
#include "../common/openpgpdefs.h"
|
||||||
#include "../common/init.h"
|
#include "../common/init.h"
|
||||||
#include "../common/strlist.h"
|
#include "../common/strlist.h"
|
||||||
@ -281,11 +279,6 @@ shell_parse_argv (const char *s, int *r_argc, char ***r_argv)
|
|||||||
(*r_argv)[i] = list->d, list = list->next;
|
(*r_argv)[i] = list->d, list = list->next;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Define Assuan hooks for NPTH. */
|
|
||||||
|
|
||||||
ASSUAN_SYSTEM_NPTH_IMPL;
|
|
||||||
|
|
||||||
|
|
||||||
/* Global flags. */
|
/* Global flags. */
|
||||||
enum cmd_and_opt_values cmd = 0;
|
enum cmd_and_opt_values cmd = 0;
|
||||||
@ -412,11 +405,6 @@ main (int argc, char **argv)
|
|||||||
/* Make sure that our subsystems are ready. */
|
/* Make sure that our subsystems are ready. */
|
||||||
i18n_init();
|
i18n_init();
|
||||||
init_common_subsystems (&argc, &argv);
|
init_common_subsystems (&argc, &argv);
|
||||||
npth_init ();
|
|
||||||
assuan_set_assuan_log_prefix (log_get_prefix (NULL));
|
|
||||||
assuan_set_gpg_err_source (GPG_ERR_SOURCE_DEFAULT);
|
|
||||||
assuan_set_system_hooks (ASSUAN_SYSTEM_NPTH);
|
|
||||||
assuan_sock_init ();
|
|
||||||
|
|
||||||
/* Parse the command line. */
|
/* Parse the command line. */
|
||||||
pargs.argc = &argc;
|
pargs.argc = &argc;
|
||||||
@ -442,9 +430,11 @@ main (int argc, char **argv)
|
|||||||
log_info (_("NOTE: '%s' is not considered an option\n"), argv[i]);
|
log_info (_("NOTE: '%s' is not considered an option\n"), argv[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! opt.gpg_program)
|
||||||
|
opt.gpg_program = gnupg_module_name (GNUPG_MODULE_NAME_GPG);
|
||||||
|
|
||||||
if (opt.verbose > 1)
|
if (opt.verbose > 1)
|
||||||
opt.debug_level = 1024;
|
opt.debug_level = 1024;
|
||||||
setup_libassuan_logging (&opt.debug_level);
|
|
||||||
|
|
||||||
switch (cmd)
|
switch (cmd)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user