core,w32: Fix invocation of gpgtar
* src/dirinfo.c (EXEEXT_S): New. (get_gpgconf_item): Append ".exe" to gpg-wks-client and gpgtar. * src/gpgme-w32spawn.c (mystderr): Add code to ease debugging.
This commit is contained in:
parent
806a5d18b9
commit
0c29119e06
@ -32,6 +32,12 @@
|
|||||||
#include "sema.h"
|
#include "sema.h"
|
||||||
#include "sys-util.h"
|
#include "sys-util.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_DOSISH_SYSTEM
|
||||||
|
# define EXEEXT_S ".exe"
|
||||||
|
#else
|
||||||
|
# define EXEEXT_S ""
|
||||||
|
#endif
|
||||||
|
|
||||||
DEFINE_STATIC_LOCK (dirinfo_lock);
|
DEFINE_STATIC_LOCK (dirinfo_lock);
|
||||||
|
|
||||||
/* Constants used internally to select the data. */
|
/* Constants used internally to select the data. */
|
||||||
@ -404,16 +410,18 @@ get_gpgconf_item (int what)
|
|||||||
case WANT_GPG_WKS_CLIENT_NAME:
|
case WANT_GPG_WKS_CLIENT_NAME:
|
||||||
if (!dirinfo.gpg_wks_client_name && dirinfo.libexecdir)
|
if (!dirinfo.gpg_wks_client_name && dirinfo.libexecdir)
|
||||||
dirinfo.gpg_wks_client_name = _gpgme_strconcat (dirinfo.libexecdir,
|
dirinfo.gpg_wks_client_name = _gpgme_strconcat (dirinfo.libexecdir,
|
||||||
"/",
|
DIRSEP_S,
|
||||||
"gpg-wks-client",
|
"gpg-wks-client",
|
||||||
|
EXEEXT_S,
|
||||||
NULL);
|
NULL);
|
||||||
result = dirinfo.gpg_wks_client_name;
|
result = dirinfo.gpg_wks_client_name;
|
||||||
break;
|
break;
|
||||||
case WANT_GPGTAR_NAME:
|
case WANT_GPGTAR_NAME:
|
||||||
if (!dirinfo.gpgtar_name && dirinfo.bindir)
|
if (!dirinfo.gpgtar_name && dirinfo.bindir)
|
||||||
dirinfo.gpgtar_name = _gpgme_strconcat (dirinfo.bindir,
|
dirinfo.gpgtar_name = _gpgme_strconcat (dirinfo.bindir,
|
||||||
"/",
|
DIRSEP_S,
|
||||||
"gpgtar",
|
"gpgtar",
|
||||||
|
EXEEXT_S,
|
||||||
NULL);
|
NULL);
|
||||||
result = dirinfo.gpgtar_name;
|
result = dirinfo.gpgtar_name;
|
||||||
break;
|
break;
|
||||||
|
@ -40,10 +40,18 @@
|
|||||||
|
|
||||||
#include "priv-io.h"
|
#include "priv-io.h"
|
||||||
|
|
||||||
|
/* #define DEBUG_TO_FILE 1 */
|
||||||
|
|
||||||
|
|
||||||
/* Name of this program. */
|
/* Name of this program. */
|
||||||
#define PGM "gpgme-w32spawn"
|
#define PGM "gpgme-w32spawn"
|
||||||
|
|
||||||
|
#ifdef DEBUG_TO_FILE
|
||||||
|
static FILE *mystderr;
|
||||||
|
#else
|
||||||
|
#define mystderr stderr
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
@ -126,7 +134,7 @@ my_spawn (char **argv, struct spawn_fd_item_s *fd_list, unsigned int flags)
|
|||||||
i = 0;
|
i = 0;
|
||||||
while (argv[i])
|
while (argv[i])
|
||||||
{
|
{
|
||||||
fprintf (stderr, PGM": argv[%2i] = %s\n", i, argv[i]);
|
fprintf (mystderr, PGM": argv[%2i] = %s\n", i, argv[i]);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,8 +154,6 @@ my_spawn (char **argv, struct spawn_fd_item_s *fd_list, unsigned int flags)
|
|||||||
si.hStdOutput = GetStdHandle (STD_OUTPUT_HANDLE);
|
si.hStdOutput = GetStdHandle (STD_OUTPUT_HANDLE);
|
||||||
si.hStdError = GetStdHandle (STD_ERROR_HANDLE);
|
si.hStdError = GetStdHandle (STD_ERROR_HANDLE);
|
||||||
|
|
||||||
fprintf (stderr, PGM": spawning: %s\n", arg_string);
|
|
||||||
|
|
||||||
for (i = 0; fd_list[i].fd != -1; i++)
|
for (i = 0; fd_list[i].fd != -1; i++)
|
||||||
{
|
{
|
||||||
/* The handle already is inheritable. */
|
/* The handle already is inheritable. */
|
||||||
@ -155,19 +161,19 @@ my_spawn (char **argv, struct spawn_fd_item_s *fd_list, unsigned int flags)
|
|||||||
{
|
{
|
||||||
si.hStdInput = (HANDLE) fd_list[i].peer_name;
|
si.hStdInput = (HANDLE) fd_list[i].peer_name;
|
||||||
duped_stdin = 1;
|
duped_stdin = 1;
|
||||||
fprintf (stderr, PGM": dup 0x%x to stdin\n", fd_list[i].peer_name);
|
fprintf (mystderr, PGM": dup 0x%x to stdin\n", fd_list[i].peer_name);
|
||||||
}
|
}
|
||||||
else if (fd_list[i].dup_to == 1)
|
else if (fd_list[i].dup_to == 1)
|
||||||
{
|
{
|
||||||
si.hStdOutput = (HANDLE) fd_list[i].peer_name;
|
si.hStdOutput = (HANDLE) fd_list[i].peer_name;
|
||||||
duped_stdout = 1;
|
duped_stdout = 1;
|
||||||
fprintf (stderr, PGM": dup 0x%x to stdout\n", fd_list[i].peer_name);
|
fprintf (mystderr, PGM": dup 0x%x to stdout\n", fd_list[i].peer_name);
|
||||||
}
|
}
|
||||||
else if (fd_list[i].dup_to == 2)
|
else if (fd_list[i].dup_to == 2)
|
||||||
{
|
{
|
||||||
si.hStdError = (HANDLE) fd_list[i].peer_name;
|
si.hStdError = (HANDLE) fd_list[i].peer_name;
|
||||||
duped_stderr = 1;
|
duped_stderr = 1;
|
||||||
fprintf (stderr, PGM":dup 0x%x to stderr\n", fd_list[i].peer_name);
|
fprintf (mystderr, PGM":dup 0x%x to stderr\n", fd_list[i].peer_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,6 +222,7 @@ my_spawn (char **argv, struct spawn_fd_item_s *fd_list, unsigned int flags)
|
|||||||
&pi)) /* returns process information */
|
&pi)) /* returns process information */
|
||||||
{
|
{
|
||||||
free (arg_string);
|
free (arg_string);
|
||||||
|
fprintf (mystderr, PGM": spawn error: %d\n", (int)GetLastError ());
|
||||||
/* FIXME: Should translate the error code. */
|
/* FIXME: Should translate the error code. */
|
||||||
errno = EIO;
|
errno = EIO;
|
||||||
return -1;
|
return -1;
|
||||||
@ -252,7 +259,7 @@ my_spawn (char **argv, struct spawn_fd_item_s *fd_list, unsigned int flags)
|
|||||||
if (func)
|
if (func)
|
||||||
{
|
{
|
||||||
int rc = func (pi.dwProcessId);
|
int rc = func (pi.dwProcessId);
|
||||||
fprintf (stderr, PGM": AllowSetForegroundWindow(%d): rc=%d\n",
|
fprintf (mystderr, PGM": AllowSetForegroundWindow(%d): rc=%d\n",
|
||||||
(int)pi.dwProcessId, rc);
|
(int)pi.dwProcessId, rc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -418,7 +425,7 @@ translate_handles (const char *trans_file, const char * const *argv,
|
|||||||
|
|
||||||
if (aidx >= n_args)
|
if (aidx >= n_args)
|
||||||
{
|
{
|
||||||
fprintf (stderr, PGM": translation file does not match args\n");
|
fprintf (mystderr, PGM": translation file does not match args\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -455,6 +462,10 @@ main (int argc, const char * const *argv)
|
|||||||
goto leave;
|
goto leave;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG_TO_FILE
|
||||||
|
mystderr = fopen ("h:/gpgme-w32spawn.log", "w");
|
||||||
|
#endif
|
||||||
|
|
||||||
argv_spawn = translate_handles (argv[1], &argv[2], fd_list, &flags);
|
argv_spawn = translate_handles (argv[1], &argv[2], fd_list, &flags);
|
||||||
if (!argv_spawn)
|
if (!argv_spawn)
|
||||||
{
|
{
|
||||||
@ -468,7 +479,7 @@ main (int argc, const char * const *argv)
|
|||||||
rc = my_spawn (argv_spawn, fd_list, flags);
|
rc = my_spawn (argv_spawn, fd_list, flags);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
{
|
{
|
||||||
fprintf (stderr, PGM": executing `%s' failed: %s\n",
|
fprintf (mystderr, PGM": executing `%s' failed: %s\n",
|
||||||
argv[0], strerror (errno));
|
argv[0], strerror (errno));
|
||||||
rc = 2;
|
rc = 2;
|
||||||
goto leave;
|
goto leave;
|
||||||
@ -476,12 +487,12 @@ main (int argc, const char * const *argv)
|
|||||||
|
|
||||||
leave:
|
leave:
|
||||||
if (rc)
|
if (rc)
|
||||||
fprintf (stderr, PGM": internal error\n");
|
fprintf (mystderr, PGM": internal error\n");
|
||||||
/* Always try to delete the temporary file. */
|
/* Always try to delete the temporary file. */
|
||||||
if (argc >= 2)
|
if (argc >= 2)
|
||||||
{
|
{
|
||||||
if (DeleteFile (argv[1]) == 0)
|
if (DeleteFile (argv[1]) == 0)
|
||||||
fprintf (stderr, PGM": failed to delete %s: ec=%ld\n",
|
fprintf (mystderr, PGM": failed to delete %s: ec=%ld\n",
|
||||||
argv[1], GetLastError ());
|
argv[1], GetLastError ());
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
|
Loading…
Reference in New Issue
Block a user