summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2023-04-17 14:02:02 +0200
committerWerner Koch <wk@gnupg.org>2023-04-17 14:05:35 +0200
commit0c29119e061cbdcb7342380938a25af91290f1a0 (patch)
treeaa6447e859b6c375bbc39054acfe13c597775272
parent806a5d18b988449fbaa3c2e6380acf3ae4580f4a (diff)
downloadgpgme-0c29119e061cbdcb7342380938a25af91290f1a0.tar.gz
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.
-rw-r--r--src/dirinfo.c12
-rw-r--r--src/gpgme-w32spawn.c33
2 files changed, 32 insertions, 13 deletions
diff --git a/src/dirinfo.c b/src/dirinfo.c
index 009bd580..de2a9180 100644
--- a/src/dirinfo.c
+++ b/src/dirinfo.c
@@ -32,6 +32,12 @@
#include "sema.h"
#include "sys-util.h"
+#ifdef HAVE_DOSISH_SYSTEM
+# define EXEEXT_S ".exe"
+#else
+# define EXEEXT_S ""
+#endif
+
DEFINE_STATIC_LOCK (dirinfo_lock);
/* Constants used internally to select the data. */
@@ -404,16 +410,18 @@ get_gpgconf_item (int what)
case WANT_GPG_WKS_CLIENT_NAME:
if (!dirinfo.gpg_wks_client_name && dirinfo.libexecdir)
dirinfo.gpg_wks_client_name = _gpgme_strconcat (dirinfo.libexecdir,
- "/",
+ DIRSEP_S,
"gpg-wks-client",
+ EXEEXT_S,
NULL);
result = dirinfo.gpg_wks_client_name;
break;
case WANT_GPGTAR_NAME:
if (!dirinfo.gpgtar_name && dirinfo.bindir)
dirinfo.gpgtar_name = _gpgme_strconcat (dirinfo.bindir,
- "/",
+ DIRSEP_S,
"gpgtar",
+ EXEEXT_S,
NULL);
result = dirinfo.gpgtar_name;
break;
diff --git a/src/gpgme-w32spawn.c b/src/gpgme-w32spawn.c
index 64913b01..09dbea75 100644
--- a/src/gpgme-w32spawn.c
+++ b/src/gpgme-w32spawn.c
@@ -40,10 +40,18 @@
#include "priv-io.h"
+/* #define DEBUG_TO_FILE 1 */
+
/* Name of this program. */
#define PGM "gpgme-w32spawn"
+#ifdef DEBUG_TO_FILE
+static FILE *mystderr;
+#else
+#define mystderr stderr
+#endif
+
static char *
@@ -126,7 +134,7 @@ my_spawn (char **argv, struct spawn_fd_item_s *fd_list, unsigned int flags)
i = 0;
while (argv[i])
{
- fprintf (stderr, PGM": argv[%2i] = %s\n", i, argv[i]);
+ fprintf (mystderr, PGM": argv[%2i] = %s\n", i, argv[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.hStdError = GetStdHandle (STD_ERROR_HANDLE);
- fprintf (stderr, PGM": spawning: %s\n", arg_string);
-
for (i = 0; fd_list[i].fd != -1; i++)
{
/* 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;
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)
{
si.hStdOutput = (HANDLE) fd_list[i].peer_name;
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)
{
si.hStdError = (HANDLE) fd_list[i].peer_name;
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 */
{
free (arg_string);
+ fprintf (mystderr, PGM": spawn error: %d\n", (int)GetLastError ());
/* FIXME: Should translate the error code. */
errno = EIO;
return -1;
@@ -252,7 +259,7 @@ my_spawn (char **argv, struct spawn_fd_item_s *fd_list, unsigned int flags)
if (func)
{
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);
}
}
@@ -418,7 +425,7 @@ translate_handles (const char *trans_file, const char * const *argv,
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;
}
@@ -455,6 +462,10 @@ main (int argc, const char * const *argv)
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);
if (!argv_spawn)
{
@@ -468,7 +479,7 @@ main (int argc, const char * const *argv)
rc = my_spawn (argv_spawn, fd_list, flags);
if (rc < 0)
{
- fprintf (stderr, PGM": executing `%s' failed: %s\n",
+ fprintf (mystderr, PGM": executing `%s' failed: %s\n",
argv[0], strerror (errno));
rc = 2;
goto leave;
@@ -476,12 +487,12 @@ main (int argc, const char * const *argv)
leave:
if (rc)
- fprintf (stderr, PGM": internal error\n");
+ fprintf (mystderr, PGM": internal error\n");
/* Always try to delete the temporary file. */
if (argc >= 2)
{
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 ());
}
return rc;