mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
Use gpgrt_process_spawn API from libgpg-error.
* agent/genkey.c (do_check_passphrase_pattern): Use the gpgrt API. * common/asshelp.c (start_new_service): Ditto. * common/exechelp.h: Remove gnupg_process_spawn API. * common/exechelp-posix.c: Remove gnupg_process_spawn implementation. * common/exechelp-w32.c: Likewise. * common/exectool.c (gnupg_exec_tool_stream): Use the gpgrt API. * common/t-exechelp.c (test_pipe_stream): Remove. * dirmngr/ldap-wrapper.c (destroy_wrapper, ldap_reaper_thread): Use the gpgrt API. (ldap_wrapper_connection_cleanup, ldap_wrapper): Ditto. * dirmngr/ldap.c, g10/call-keyboxd.c: No need to include exechelp.h. * g10/photoid.c (run_with_pipe, show_photo): Use the gpgrt API. * g13/be-encfs.c (run_umount_helper, run_encfs_tool): Ditto. * g13/g13.c, g13/mount.c, g13/runner.c: No need to include exechelp.h. * scd/apdu.c: No need to include exechelp.h. * scd/app.c (report_change): Use the gpgrt API. * sm/export.c, sm/import.c: No need to include exechelp.h. * tests/gpgscm/ffi.c (proc_object_finalize, proc_wrap) (do_process_spawn_io, do_process_spawn_fd, do_process_wait): Use the gpgrt API. * tools/gpg-auth.c: No need to include exechelp.h. * tools/gpg-card.c (cmd_gpg): Use the gpgrt API. * tools/gpg-connect-agent.c: No need to include exechelp.h. * tools/gpg-mail-tube.c (mail_tube_encrypt, prepare_for_appimage) (start_gpg_encrypt): Use the gpgrt API. * tools/gpgconf-comp.c (gpg_agent_runtime_change) (scdaemon_runtime_change, tpm2daemon_runtime_change) (dirmngr_runtime_change, keyboxd_runtime_change) (gc_component_launch, gc_component_check_options) (retrieve_options_from_program): Ditto. * tools/gpgconf.c (show_versions_via_dirmngr): Ditto. * tools/gpgtar-create.c (gpgtar_create): Ditto. * tools/gpgtar-extract.c (gpgtar_extract): Ditto. * tools/gpgtar-list.c (gpgtar_list): Ditto. -- GnuPG-bug-id: 7192 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
parent
c333e9dad6
commit
953dd67368
29 changed files with 204 additions and 2092 deletions
|
@ -46,7 +46,6 @@
|
|||
|
||||
#include "../common/util.h"
|
||||
#include "../common/i18n.h"
|
||||
#include "../common/exechelp.h"
|
||||
#include "../common/sysutils.h"
|
||||
#include "../common/status.h"
|
||||
|
||||
|
@ -747,7 +746,7 @@ gpg_agent_runtime_change (int killflag)
|
|||
gpg_error_t err = 0;
|
||||
const char *pgmname;
|
||||
const char *argv[5];
|
||||
gnupg_process_t proc = NULL;
|
||||
gpgrt_process_t proc = NULL;
|
||||
int i = 0;
|
||||
int cmdidx;
|
||||
|
||||
|
@ -764,13 +763,13 @@ gpg_agent_runtime_change (int killflag)
|
|||
log_assert (i < DIM(argv));
|
||||
|
||||
if (!err)
|
||||
err = gnupg_process_spawn (pgmname, argv, 0, NULL, &proc);
|
||||
err = gpgrt_process_spawn (pgmname, argv, 0, NULL, &proc);
|
||||
if (!err)
|
||||
err = gnupg_process_wait (proc, 1);
|
||||
err = gpgrt_process_wait (proc, 1);
|
||||
if (err)
|
||||
gc_error (0, 0, "error running '%s %s': %s",
|
||||
pgmname, argv[cmdidx], gpg_strerror (err));
|
||||
gnupg_process_release (proc);
|
||||
gpgrt_process_release (proc);
|
||||
}
|
||||
|
||||
|
||||
|
@ -780,7 +779,7 @@ scdaemon_runtime_change (int killflag)
|
|||
gpg_error_t err = 0;
|
||||
const char *pgmname;
|
||||
const char *argv[9];
|
||||
gnupg_process_t proc = NULL;
|
||||
gpgrt_process_t proc = NULL;
|
||||
int i = 0;
|
||||
int cmdidx;
|
||||
|
||||
|
@ -808,13 +807,13 @@ scdaemon_runtime_change (int killflag)
|
|||
log_assert (i < DIM(argv));
|
||||
|
||||
if (!err)
|
||||
err = gnupg_process_spawn (pgmname, argv, 0, NULL, &proc);
|
||||
err = gpgrt_process_spawn (pgmname, argv, 0, NULL, &proc);
|
||||
if (!err)
|
||||
err = gnupg_process_wait (proc, 1);
|
||||
err = gpgrt_process_wait (proc, 1);
|
||||
if (err)
|
||||
gc_error (0, 0, "error running '%s %s': %s",
|
||||
pgmname, argv[cmdidx], gpg_strerror (err));
|
||||
gnupg_process_release (proc);
|
||||
gpgrt_process_release (proc);
|
||||
}
|
||||
|
||||
|
||||
|
@ -825,7 +824,7 @@ tpm2daemon_runtime_change (int killflag)
|
|||
gpg_error_t err = 0;
|
||||
const char *pgmname;
|
||||
const char *argv[9];
|
||||
gnupg_process_t proc = NULL;
|
||||
gpgrt_process_t proc = NULL;
|
||||
int i = 0;
|
||||
int cmdidx;
|
||||
|
||||
|
@ -853,13 +852,13 @@ tpm2daemon_runtime_change (int killflag)
|
|||
log_assert (i < DIM(argv));
|
||||
|
||||
if (!err)
|
||||
err = gnupg_process_spawn (pgmname, argv, 0, NULL, &proc);
|
||||
err = gpgrt_process_spawn (pgmname, argv, 0, NULL, &proc);
|
||||
if (!err)
|
||||
err = gnupg_process_wait (proc, 1);
|
||||
err = gpgrt_process_wait (proc, 1);
|
||||
if (err)
|
||||
gc_error (0, 0, "error running '%s %s': %s",
|
||||
pgmname, argv[cmdidx], gpg_strerror (err));
|
||||
gnupg_process_release (proc);
|
||||
gpgrt_process_release (proc);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -870,7 +869,7 @@ dirmngr_runtime_change (int killflag)
|
|||
gpg_error_t err = 0;
|
||||
const char *pgmname;
|
||||
const char *argv[6];
|
||||
gnupg_process_t proc = NULL;
|
||||
gpgrt_process_t proc = NULL;
|
||||
int i = 0;
|
||||
int cmdidx;
|
||||
|
||||
|
@ -888,13 +887,13 @@ dirmngr_runtime_change (int killflag)
|
|||
log_assert (i < DIM(argv));
|
||||
|
||||
if (!err)
|
||||
err = gnupg_process_spawn (pgmname, argv, 0, NULL, &proc);
|
||||
err = gpgrt_process_spawn (pgmname, argv, 0, NULL, &proc);
|
||||
if (!err)
|
||||
err = gnupg_process_wait (proc, 1);
|
||||
err = gpgrt_process_wait (proc, 1);
|
||||
if (err)
|
||||
gc_error (0, 0, "error running '%s %s': %s",
|
||||
pgmname, argv[cmdidx], gpg_strerror (err));
|
||||
gnupg_process_release (proc);
|
||||
gpgrt_process_release (proc);
|
||||
}
|
||||
|
||||
|
||||
|
@ -904,7 +903,7 @@ keyboxd_runtime_change (int killflag)
|
|||
gpg_error_t err = 0;
|
||||
const char *pgmname;
|
||||
const char *argv[6];
|
||||
gnupg_process_t proc = NULL;
|
||||
gpgrt_process_t proc = NULL;
|
||||
int i = 0;
|
||||
int cmdidx;
|
||||
|
||||
|
@ -922,13 +921,13 @@ keyboxd_runtime_change (int killflag)
|
|||
log_assert (i < DIM(argv));
|
||||
|
||||
if (!err)
|
||||
err = gnupg_process_spawn (pgmname, argv, 0, NULL, &proc);
|
||||
err = gpgrt_process_spawn (pgmname, argv, 0, NULL, &proc);
|
||||
if (!err)
|
||||
err = gnupg_process_wait (proc, 1);
|
||||
err = gpgrt_process_wait (proc, 1);
|
||||
if (err)
|
||||
gc_error (0, 0, "error running '%s %s': %s",
|
||||
pgmname, argv[cmdidx], gpg_strerror (err));
|
||||
gnupg_process_release (proc);
|
||||
gpgrt_process_release (proc);
|
||||
}
|
||||
|
||||
|
||||
|
@ -940,7 +939,7 @@ gc_component_launch (int component)
|
|||
const char *pgmname;
|
||||
const char *argv[6];
|
||||
int i;
|
||||
gnupg_process_t proc = NULL;
|
||||
gpgrt_process_t proc = NULL;
|
||||
|
||||
if (component < 0)
|
||||
{
|
||||
|
@ -988,9 +987,9 @@ gc_component_launch (int component)
|
|||
argv[i] = NULL;
|
||||
log_assert (i < DIM(argv));
|
||||
|
||||
err = gnupg_process_spawn (pgmname, argv, 0, NULL, &proc);
|
||||
err = gpgrt_process_spawn (pgmname, argv, 0, NULL, &proc);
|
||||
if (!err)
|
||||
err = gnupg_process_wait (proc, 1);
|
||||
err = gpgrt_process_wait (proc, 1);
|
||||
if (err)
|
||||
gc_error (0, 0, "error running '%s%s%s': %s",
|
||||
pgmname,
|
||||
|
@ -998,7 +997,7 @@ gc_component_launch (int component)
|
|||
: component == GC_COMPONENT_KEYBOXD? " --keyboxd":"",
|
||||
" NOP",
|
||||
gpg_strerror (err));
|
||||
gnupg_process_release (proc);
|
||||
gpgrt_process_release (proc);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -1339,7 +1338,7 @@ gc_component_check_options (int component, estream_t out, const char *conf_file)
|
|||
const char *pgmname;
|
||||
const char *argv[6];
|
||||
int i;
|
||||
gnupg_process_t proc;
|
||||
gpgrt_process_t proc;
|
||||
estream_t errfp;
|
||||
error_line_t errlines;
|
||||
|
||||
|
@ -1372,27 +1371,27 @@ gc_component_check_options (int component, estream_t out, const char *conf_file)
|
|||
|
||||
result = 0;
|
||||
errlines = NULL;
|
||||
err = gnupg_process_spawn (pgmname, argv, GNUPG_PROCESS_STDERR_PIPE,
|
||||
err = gpgrt_process_spawn (pgmname, argv, GPGRT_PROCESS_STDERR_PIPE,
|
||||
NULL, &proc);
|
||||
if (err)
|
||||
result |= 1; /* Program could not be run. */
|
||||
else
|
||||
{
|
||||
gnupg_process_get_streams (proc, 0, NULL, NULL, &errfp);
|
||||
gpgrt_process_get_streams (proc, 0, NULL, NULL, &errfp);
|
||||
errlines = collect_error_output (errfp,
|
||||
gc_component[component].name);
|
||||
if (!gnupg_process_wait (proc, 1))
|
||||
if (!gpgrt_process_wait (proc, 1))
|
||||
{
|
||||
int exitcode;
|
||||
|
||||
gnupg_process_ctl (proc, GNUPG_PROCESS_GET_EXIT_ID, &exitcode);
|
||||
gpgrt_process_ctl (proc, GPGRT_PROCESS_GET_EXIT_ID, &exitcode);
|
||||
if (exitcode == -1)
|
||||
result |= 1; /* Program could not be run or it
|
||||
terminated abnormally. */
|
||||
else if (exitcode)
|
||||
result |= 2; /* Program returned an error. */
|
||||
}
|
||||
gnupg_process_release (proc);
|
||||
gpgrt_process_release (proc);
|
||||
es_fclose (errfp);
|
||||
}
|
||||
|
||||
|
@ -1732,7 +1731,7 @@ retrieve_options_from_program (gc_component_id_t component, int only_installed)
|
|||
const char *pgmname;
|
||||
const char *argv[2];
|
||||
estream_t outfp;
|
||||
gnupg_process_t proc;
|
||||
gpgrt_process_t proc;
|
||||
known_option_t *known_option;
|
||||
gc_option_t *option;
|
||||
char *line = NULL;
|
||||
|
@ -1765,7 +1764,7 @@ retrieve_options_from_program (gc_component_id_t component, int only_installed)
|
|||
/* First we need to read the option table from the program. */
|
||||
argv[0] = "--dump-option-table";
|
||||
argv[1] = NULL;
|
||||
err = gnupg_process_spawn (pgmname, argv, GNUPG_PROCESS_STDOUT_PIPE,
|
||||
err = gpgrt_process_spawn (pgmname, argv, GPGRT_PROCESS_STDOUT_PIPE,
|
||||
NULL, &proc);
|
||||
if (err)
|
||||
{
|
||||
|
@ -1773,7 +1772,7 @@ retrieve_options_from_program (gc_component_id_t component, int only_installed)
|
|||
pgmname, gpg_strerror (err));
|
||||
}
|
||||
|
||||
gnupg_process_get_streams (proc, 0, NULL, &outfp, NULL);
|
||||
gpgrt_process_get_streams (proc, 0, NULL, &outfp, NULL);
|
||||
|
||||
read_line_parm.pgmname = pgmname;
|
||||
read_line_parm.fp = outfp;
|
||||
|
@ -1933,17 +1932,17 @@ retrieve_options_from_program (gc_component_id_t component, int only_installed)
|
|||
line_len = read_line_parm.line_len;
|
||||
log_assert (opt_table_used + pseudo_count == opt_info_used);
|
||||
|
||||
err = gnupg_process_wait (proc, 1);
|
||||
err = gpgrt_process_wait (proc, 1);
|
||||
if (!err)
|
||||
{
|
||||
int exitcode;
|
||||
|
||||
gnupg_process_ctl (proc, GNUPG_PROCESS_GET_EXIT_ID, &exitcode);
|
||||
gpgrt_process_ctl (proc, GPGRT_PROCESS_GET_EXIT_ID, &exitcode);
|
||||
if (exitcode)
|
||||
gc_error (1, 0, "running %s failed (exitcode=%d): %s",
|
||||
pgmname, exitcode, gpg_strerror (err));
|
||||
}
|
||||
gnupg_process_release (proc);
|
||||
gpgrt_process_release (proc);
|
||||
|
||||
/* Make the gpgrt option table and the internal option table available. */
|
||||
gc_component[component].opt_table = opt_table;
|
||||
|
@ -1953,7 +1952,7 @@ retrieve_options_from_program (gc_component_id_t component, int only_installed)
|
|||
/* Now read the default options. */
|
||||
argv[0] = "--gpgconf-list";
|
||||
argv[1] = NULL;
|
||||
err = gnupg_process_spawn (pgmname, argv, GNUPG_PROCESS_STDOUT_PIPE,
|
||||
err = gpgrt_process_spawn (pgmname, argv, GPGRT_PROCESS_STDOUT_PIPE,
|
||||
NULL, &proc);
|
||||
if (err)
|
||||
{
|
||||
|
@ -1961,7 +1960,7 @@ retrieve_options_from_program (gc_component_id_t component, int only_installed)
|
|||
pgmname, gpg_strerror (err));
|
||||
}
|
||||
|
||||
gnupg_process_get_streams (proc, 0, NULL, &outfp, NULL);
|
||||
gpgrt_process_get_streams (proc, 0, NULL, &outfp, NULL);
|
||||
|
||||
while ((length = es_read_line (outfp, &line, &line_len, NULL)) > 0)
|
||||
{
|
||||
|
@ -2045,17 +2044,17 @@ retrieve_options_from_program (gc_component_id_t component, int only_installed)
|
|||
if (es_fclose (outfp))
|
||||
gc_error (1, errno, "error closing %s", pgmname);
|
||||
|
||||
err = gnupg_process_wait (proc, 1);
|
||||
err = gpgrt_process_wait (proc, 1);
|
||||
if (!err)
|
||||
{
|
||||
int exitcode;
|
||||
|
||||
gnupg_process_ctl (proc, GNUPG_PROCESS_GET_EXIT_ID, &exitcode);
|
||||
gpgrt_process_ctl (proc, GPGRT_PROCESS_GET_EXIT_ID, &exitcode);
|
||||
if (exitcode)
|
||||
gc_error (1, 0, "running %s failed (exitcode=%d): %s",
|
||||
pgmname, exitcode, gpg_strerror (err));
|
||||
}
|
||||
gnupg_process_release (proc);
|
||||
gpgrt_process_release (proc);
|
||||
|
||||
|
||||
/* At this point, we can parse the configuration file. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue