2001-01-30 16:00:50 +00:00
|
|
|
|
/* w32-util.c - Utility functions for the W32 API
|
2013-08-02 10:48:30 +00:00
|
|
|
|
* Copyright (C) 1999 Free Software Foundation, Inc
|
|
|
|
|
* Copyright (C) 2001 Werner Koch (dd9jn)
|
|
|
|
|
* Copyright (C) 2001, 2002, 2003, 2004, 2007, 2013 g10 Code GmbH
|
|
|
|
|
*
|
|
|
|
|
* This file is part of GPGME.
|
|
|
|
|
*
|
|
|
|
|
* GPGME is free software; you can redistribute it and/or modify it
|
|
|
|
|
* under the terms of the GNU Lesser General Public License as
|
|
|
|
|
* published by the Free Software Foundation; either version 2.1 of
|
|
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* GPGME is distributed in the hope that it will be useful, but
|
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2016-11-16 12:27:00 +00:00
|
|
|
|
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
2013-08-02 10:48:30 +00:00
|
|
|
|
**/
|
2001-01-30 16:00:50 +00:00
|
|
|
|
|
2002-03-18 00:04:06 +00:00
|
|
|
|
#ifdef HAVE_CONFIG_H
|
2001-01-30 16:00:50 +00:00
|
|
|
|
#include <config.h>
|
2002-03-18 00:04:06 +00:00
|
|
|
|
#endif
|
2001-01-30 16:00:50 +00:00
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
#include <errno.h>
|
assuan/
2008-06-25 Marcus Brinkmann <marcus@g10code.de>
* assuan-pipe-connect.c (struct spawn_fd_item_s): Add new members.
(HANDLE_TRANSLATION): New macro.
(pipe_connect_gpgme): Adjust caller of _gpgme_io_spawn.
[HANDLE_TRANSLATION]: Return translated handles.
gpgme/
2008-06-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme-w32spawn.c: New file.
* Makefile.am (libexec_PROGRAMS) [HAVE_W32_SYSTEM]: New variable
with gpgme-w32spawn.
* engine-gpgsm.c (gpgsm_new): Use server translated handles.
(gpgsm_set_locale): Return early if locale value is NULL.
* util.h (_gpgme_mkstemp)
(_gpgme_get_w32spawn_path) [HAVE_W32_SYSTEM]: New function
prototypes.
* w32-util.c: Include <stdint.h>, <sys/stat.h> and <unistd.h>.
(letters, mkstemp, _gpgme_mkstemp, _gpgme_get_w32spawn_path): New
functions.
* rungpg.c (gpg_decrypt, gpg_encrypt, gpg_encrypt_sign)
(gpg_genkey, gpg_import, gpg_verify, gpg_sign): Pass data over
special filename FD rather than stdin.
(struct arg_and_data_s): Add member ARG_LOCP.
(struct fd_data_map_s): Add member ARG_LOC.
(struct engine_gpg): Add member ARG_LOC to status and colon.
(_add_arg, add_arg_with_locp): New function.
(add_arg_ext): Reimplement in terms of _add_arg.
(gpg_new): Remember argument location for status FD.
(build_argv): Set argument location if requested. Also set
argument location of fd_data_map for data items.
(start): Adjust caller of _gpgme_io_spawn.
* priv-io.h (struct spawn_fd_item_s): Add members peer_name and
arg_loc.
(_gpgme_io_spawn): Remove parent fd list argument.
* posix-io.c (get_max_fds): New function.
(_gpgme_io_dup): Add tracing.
(_gpgme_io_spawn): Remove parent fd list. Change meaning of child
fd list to contain all child fds that should be inherited. Close
all other file descriptors after fork.
* w32-io.c, w32-glib-io.c, w32-qt-io.c(_gpgme_io_spawn): Remove
parent fd list. Change meaning of child fd list to contain all
child fds that should be inherited. Do not inherit any file
descriptors, but DuplicateHandle them. Spawn process through
wrapper process. Provide wrapper process with a temporary file
containing handle translation data. Return translated handle
names.
* w32-io.c (reader): Add more tracing output.
(_gpgme_io_read): Likewise.
* engine-gpgconf.c (gpgconf_read): Adjust caller of
_gpgme_io_spawn.
* version.c (_gpgme_get_program_version): Likewise.
2008-06-25 16:52:31 +00:00
|
|
|
|
#include <stdint.h>
|
2010-11-02 16:27:46 +00:00
|
|
|
|
#ifdef HAVE_SYS_TIME_H
|
|
|
|
|
# include <sys/time.h>
|
|
|
|
|
#endif
|
2010-11-03 09:56:27 +00:00
|
|
|
|
#ifdef HAVE_SYS_TYPES_H
|
|
|
|
|
# include <sys/types.h>
|
|
|
|
|
#endif
|
|
|
|
|
#ifdef HAVE_SYS_STAT_H
|
|
|
|
|
# include <sys/stat.h>
|
|
|
|
|
#endif
|
2010-11-02 16:27:46 +00:00
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
|
# include <unistd.h>
|
|
|
|
|
#endif
|
2001-01-30 16:00:50 +00:00
|
|
|
|
#include <fcntl.h>
|
2002-03-18 00:04:06 +00:00
|
|
|
|
#include <io.h>
|
2001-01-30 16:00:50 +00:00
|
|
|
|
|
2013-02-26 16:06:39 +00:00
|
|
|
|
#if __MINGW64_VERSION_MAJOR >= 2
|
|
|
|
|
# define _WIN32_IE 0x0501 /* Required by mingw64 toolkit. */
|
|
|
|
|
#else
|
|
|
|
|
# define _WIN32_IE 0x0400 /* Required for SHGetSpecialFolderPathA. */
|
|
|
|
|
#endif
|
2010-11-02 16:27:46 +00:00
|
|
|
|
|
2010-11-02 20:17:57 +00:00
|
|
|
|
/* We need to include the windows stuff here prior to shlobj.h so that
|
|
|
|
|
we get the right winsock version. This is usually done in util.h
|
|
|
|
|
but that header also redefines some Windows functions which we need
|
|
|
|
|
to avoid unless having included shlobj.h. */
|
|
|
|
|
#include <winsock2.h>
|
2012-09-25 13:29:49 +00:00
|
|
|
|
#include <ws2tcpip.h>
|
2010-11-02 20:17:57 +00:00
|
|
|
|
#include <windows.h>
|
2010-11-02 16:27:46 +00:00
|
|
|
|
#include <shlobj.h>
|
2010-11-02 20:17:57 +00:00
|
|
|
|
|
|
|
|
|
#include "util.h"
|
2010-11-02 16:27:46 +00:00
|
|
|
|
#include "ath.h"
|
2003-01-19 22:05:40 +00:00
|
|
|
|
#include "sema.h"
|
2005-03-09 11:47:21 +00:00
|
|
|
|
#include "debug.h"
|
2013-08-02 13:25:23 +00:00
|
|
|
|
#include "sys-util.h"
|
2001-01-30 16:00:50 +00:00
|
|
|
|
|
2010-05-11 17:20:45 +00:00
|
|
|
|
|
|
|
|
|
#define HAVE_ALLOW_SET_FOREGROUND_WINDOW 1
|
2010-11-02 16:27:46 +00:00
|
|
|
|
#ifndef F_OK
|
|
|
|
|
# define F_OK 0
|
|
|
|
|
#endif
|
2010-05-11 17:20:45 +00:00
|
|
|
|
|
2018-05-17 15:41:53 +00:00
|
|
|
|
/* The Registry key used by GNUPG. */
|
|
|
|
|
#ifdef _WIN64
|
|
|
|
|
# define GNUPG_REGKEY_2 "Software\\Wow6432Node\\GNU\\GnuPG"
|
|
|
|
|
#else
|
|
|
|
|
# define GNUPG_REGKEY_2 "Software\\GNU\\GnuPG"
|
|
|
|
|
#endif
|
|
|
|
|
#ifdef _WIN64
|
|
|
|
|
# define GNUPG_REGKEY_3 "Software\\Wow6432Node\\GnuPG"
|
|
|
|
|
#else
|
|
|
|
|
# define GNUPG_REGKEY_3 "Software\\GnuPG"
|
|
|
|
|
#endif
|
2010-05-11 17:20:45 +00:00
|
|
|
|
|
2002-05-09 03:38:12 +00:00
|
|
|
|
DEFINE_STATIC_LOCK (get_path_lock);
|
|
|
|
|
|
2013-08-02 10:48:30 +00:00
|
|
|
|
/* The module handle of this DLL. If we are linked statically,
|
|
|
|
|
dllmain does not exists and thus the value of my_hmodule will be
|
|
|
|
|
NULL. The effect is that a GetModuleFileName always returns the
|
|
|
|
|
file name of the DLL or executable which contains the gpgme code. */
|
|
|
|
|
static HMODULE my_hmodule;
|
|
|
|
|
|
2014-01-06 16:16:52 +00:00
|
|
|
|
/* These variables store the malloced name of alternative default
|
|
|
|
|
binaries. The are set only once by gpgme_set_global_flag. */
|
|
|
|
|
static char *default_gpg_name;
|
|
|
|
|
static char *default_gpgconf_name;
|
2015-10-28 15:24:30 +00:00
|
|
|
|
/* If this variable is not NULL the value is assumed to be the
|
|
|
|
|
installation directory. The variable may only be set once by
|
|
|
|
|
gpgme_set_global_flag and accessed by _gpgme_get_inst_dir. */
|
|
|
|
|
static char *override_inst_dir;
|
2005-08-26 12:38:57 +00:00
|
|
|
|
|
2010-05-11 17:20:45 +00:00
|
|
|
|
#ifdef HAVE_ALLOW_SET_FOREGROUND_WINDOW
|
|
|
|
|
|
2005-08-26 12:38:57 +00:00
|
|
|
|
#define RTLD_LAZY 0
|
|
|
|
|
|
2010-11-03 10:33:10 +00:00
|
|
|
|
static GPG_ERR_INLINE void *
|
2005-08-26 12:38:57 +00:00
|
|
|
|
dlopen (const char * name, int flag)
|
|
|
|
|
{
|
|
|
|
|
void * hd = LoadLibrary (name);
|
2016-09-22 10:46:06 +00:00
|
|
|
|
|
|
|
|
|
(void)flag;
|
2005-08-26 12:38:57 +00:00
|
|
|
|
return hd;
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-03 10:33:10 +00:00
|
|
|
|
static GPG_ERR_INLINE void *
|
2005-08-26 12:38:57 +00:00
|
|
|
|
dlsym (void * hd, const char * sym)
|
|
|
|
|
{
|
|
|
|
|
if (hd && sym)
|
|
|
|
|
{
|
|
|
|
|
void * fnc = GetProcAddress (hd, sym);
|
|
|
|
|
if (!fnc)
|
|
|
|
|
return NULL;
|
|
|
|
|
return fnc;
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-03 10:33:10 +00:00
|
|
|
|
static GPG_ERR_INLINE int
|
2005-08-26 12:38:57 +00:00
|
|
|
|
dlclose (void * hd)
|
|
|
|
|
{
|
|
|
|
|
if (hd)
|
|
|
|
|
{
|
|
|
|
|
FreeLibrary (hd);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
return -1;
|
2012-09-25 13:29:49 +00:00
|
|
|
|
}
|
2010-05-11 17:20:45 +00:00
|
|
|
|
#endif /* HAVE_ALLOW_SET_FOREGROUND_WINDOW */
|
|
|
|
|
|
2013-08-02 10:48:30 +00:00
|
|
|
|
|
|
|
|
|
/* Return a malloced string encoded in UTF-8 from the wide char input
|
|
|
|
|
string STRING. Caller must free this value. Returns NULL and sets
|
|
|
|
|
ERRNO on failure. Calling this function with STRING set to NULL is
|
|
|
|
|
not defined. */
|
|
|
|
|
static char *
|
|
|
|
|
wchar_to_utf8 (const wchar_t *string)
|
|
|
|
|
{
|
|
|
|
|
int n;
|
|
|
|
|
char *result;
|
|
|
|
|
|
|
|
|
|
n = WideCharToMultiByte (CP_UTF8, 0, string, -1, NULL, 0, NULL, NULL);
|
|
|
|
|
if (n < 0)
|
|
|
|
|
{
|
|
|
|
|
gpg_err_set_errno (EINVAL);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result = malloc (n+1);
|
|
|
|
|
if (!result)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
n = WideCharToMultiByte (CP_UTF8, 0, string, -1, result, n, NULL, NULL);
|
|
|
|
|
if (n < 0)
|
|
|
|
|
{
|
|
|
|
|
free (result);
|
|
|
|
|
gpg_err_set_errno (EINVAL);
|
|
|
|
|
result = NULL;
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-01-06 16:16:52 +00:00
|
|
|
|
/* Replace all forward slashes by backslashes. */
|
|
|
|
|
static void
|
|
|
|
|
replace_slashes (char *string)
|
|
|
|
|
{
|
|
|
|
|
for (; *string; string++)
|
|
|
|
|
if (*string == '/')
|
|
|
|
|
*string = '\\';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Get the base name of NAME. Returns a pointer into NAME right after
|
|
|
|
|
the last slash or backslash or to NAME if no slash or backslash
|
|
|
|
|
exists. */
|
|
|
|
|
static const char *
|
|
|
|
|
get_basename (const char *name)
|
|
|
|
|
{
|
|
|
|
|
const char *mark, *s;
|
|
|
|
|
|
|
|
|
|
for (mark=NULL, s=name; *s; s++)
|
|
|
|
|
if (*s == '/' || *s == '\\')
|
|
|
|
|
mark = s;
|
|
|
|
|
|
|
|
|
|
return mark? mark+1 : name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2012-09-25 13:29:49 +00:00
|
|
|
|
void
|
2010-05-11 17:20:45 +00:00
|
|
|
|
_gpgme_allow_set_foreground_window (pid_t pid)
|
|
|
|
|
{
|
|
|
|
|
#ifdef HAVE_ALLOW_SET_FOREGROUND_WINDOW
|
|
|
|
|
static int initialized;
|
|
|
|
|
static BOOL (WINAPI * func)(DWORD);
|
|
|
|
|
void *handle;
|
|
|
|
|
|
|
|
|
|
if (!initialized)
|
|
|
|
|
{
|
|
|
|
|
/* Available since W2000; thus we dynload it. */
|
|
|
|
|
initialized = 1;
|
|
|
|
|
handle = dlopen ("user32.dll", RTLD_LAZY);
|
|
|
|
|
if (handle)
|
|
|
|
|
{
|
|
|
|
|
func = dlsym (handle, "AllowSetForegroundWindow");
|
|
|
|
|
if (!func)
|
|
|
|
|
{
|
|
|
|
|
dlclose (handle);
|
|
|
|
|
handle = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!pid || pid == (pid_t)(-1))
|
|
|
|
|
{
|
|
|
|
|
TRACE1 (DEBUG_ENGINE, "gpgme:AllowSetForegroundWindow", 0,
|
|
|
|
|
"no action for pid %d", (int)pid);
|
|
|
|
|
}
|
|
|
|
|
else if (func)
|
|
|
|
|
{
|
|
|
|
|
int rc = func (pid);
|
|
|
|
|
TRACE2 (DEBUG_ENGINE, "gpgme:AllowSetForegroundWindow", 0,
|
|
|
|
|
"called for pid %d; result=%d", (int)pid, rc);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
TRACE0 (DEBUG_ENGINE, "gpgme:AllowSetForegroundWindow", 0,
|
|
|
|
|
"function not available");
|
|
|
|
|
}
|
|
|
|
|
#endif /* HAVE_ALLOW_SET_FOREGROUND_WINDOW */
|
|
|
|
|
}
|
2005-08-26 12:38:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Return a string from the W32 Registry or NULL in case of error.
|
|
|
|
|
Caller must release the return value. A NULL for root is an alias
|
|
|
|
|
for HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE in turn. */
|
2001-01-30 16:00:50 +00:00
|
|
|
|
static char *
|
2002-03-18 00:04:06 +00:00
|
|
|
|
read_w32_registry_string (const char *root, const char *dir, const char *name)
|
2001-01-30 16:00:50 +00:00
|
|
|
|
{
|
2002-03-18 00:04:06 +00:00
|
|
|
|
HKEY root_key, key_handle;
|
2005-08-26 12:38:57 +00:00
|
|
|
|
DWORD n1, nbytes, type;
|
2002-03-18 00:04:06 +00:00
|
|
|
|
char *result = NULL;
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2010-05-11 17:20:45 +00:00
|
|
|
|
if (!root)
|
2002-03-18 00:04:06 +00:00
|
|
|
|
root_key = HKEY_CURRENT_USER;
|
2010-05-11 17:20:45 +00:00
|
|
|
|
else if (!strcmp( root, "HKEY_CLASSES_ROOT"))
|
2002-03-18 00:04:06 +00:00
|
|
|
|
root_key = HKEY_CLASSES_ROOT;
|
2010-05-11 17:20:45 +00:00
|
|
|
|
else if (!strcmp( root, "HKEY_CURRENT_USER"))
|
2002-03-18 00:04:06 +00:00
|
|
|
|
root_key = HKEY_CURRENT_USER;
|
2010-05-11 17:20:45 +00:00
|
|
|
|
else if (!strcmp( root, "HKEY_LOCAL_MACHINE"))
|
2002-03-18 00:04:06 +00:00
|
|
|
|
root_key = HKEY_LOCAL_MACHINE;
|
2010-05-11 17:20:45 +00:00
|
|
|
|
else if (!strcmp( root, "HKEY_USERS"))
|
2002-03-18 00:04:06 +00:00
|
|
|
|
root_key = HKEY_USERS;
|
2010-05-11 17:20:45 +00:00
|
|
|
|
else if (!strcmp( root, "HKEY_PERFORMANCE_DATA"))
|
2002-03-18 00:04:06 +00:00
|
|
|
|
root_key = HKEY_PERFORMANCE_DATA;
|
2010-05-11 17:20:45 +00:00
|
|
|
|
else if (!strcmp( root, "HKEY_CURRENT_CONFIG"))
|
2002-03-18 00:04:06 +00:00
|
|
|
|
root_key = HKEY_CURRENT_CONFIG;
|
|
|
|
|
else
|
|
|
|
|
return NULL;
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2010-05-11 17:20:45 +00:00
|
|
|
|
if (RegOpenKeyExA (root_key, dir, 0, KEY_READ, &key_handle))
|
2005-08-26 12:38:57 +00:00
|
|
|
|
{
|
|
|
|
|
if (root)
|
|
|
|
|
return NULL; /* no need for a RegClose, so return direct */
|
|
|
|
|
/* It seems to be common practise to fall back to HKLM. */
|
2010-05-11 17:20:45 +00:00
|
|
|
|
if (RegOpenKeyExA (HKEY_LOCAL_MACHINE, dir, 0, KEY_READ, &key_handle))
|
2005-08-26 12:38:57 +00:00
|
|
|
|
return NULL; /* still no need for a RegClose, so return direct */
|
|
|
|
|
}
|
2001-01-30 16:00:50 +00:00
|
|
|
|
|
2002-03-18 00:04:06 +00:00
|
|
|
|
nbytes = 1;
|
2010-05-11 17:20:45 +00:00
|
|
|
|
if (RegQueryValueExA (key_handle, name, 0, NULL, NULL, &nbytes))
|
2005-08-26 12:38:57 +00:00
|
|
|
|
{
|
|
|
|
|
if (root)
|
|
|
|
|
goto leave;
|
|
|
|
|
/* Try to fallback to HKLM also vor a missing value. */
|
|
|
|
|
RegCloseKey (key_handle);
|
2010-05-11 17:20:45 +00:00
|
|
|
|
if (RegOpenKeyExA (HKEY_LOCAL_MACHINE, dir, 0, KEY_READ, &key_handle))
|
2005-08-26 12:38:57 +00:00
|
|
|
|
return NULL; /* Nope. */
|
2010-05-11 17:20:45 +00:00
|
|
|
|
if (RegQueryValueExA (key_handle, name, 0, NULL, NULL, &nbytes))
|
2005-08-26 12:38:57 +00:00
|
|
|
|
goto leave;
|
|
|
|
|
}
|
2010-05-11 17:20:45 +00:00
|
|
|
|
n1 = nbytes + 1;
|
|
|
|
|
result = malloc (n1);
|
|
|
|
|
if (!result)
|
2002-03-18 00:04:06 +00:00
|
|
|
|
goto leave;
|
2010-05-11 17:20:45 +00:00
|
|
|
|
if (RegQueryValueExA (key_handle, name, 0, &type, (LPBYTE) result, &n1))
|
2002-03-18 00:04:06 +00:00
|
|
|
|
{
|
2010-05-11 17:20:45 +00:00
|
|
|
|
free (result);
|
|
|
|
|
result = NULL;
|
2002-03-18 00:04:06 +00:00
|
|
|
|
goto leave;
|
2001-01-30 16:00:50 +00:00
|
|
|
|
}
|
2005-08-26 12:38:57 +00:00
|
|
|
|
result[nbytes] = 0; /* Make sure it is really a string. */
|
2010-05-11 17:20:45 +00:00
|
|
|
|
|
2002-03-18 00:04:06 +00:00
|
|
|
|
leave:
|
2010-05-11 17:20:45 +00:00
|
|
|
|
RegCloseKey (key_handle);
|
2002-03-18 00:04:06 +00:00
|
|
|
|
return result;
|
2001-01-30 16:00:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-03-18 00:04:06 +00:00
|
|
|
|
|
2013-08-02 10:48:30 +00:00
|
|
|
|
/* Return the name of the directory with the gpgme DLL or the EXE (if
|
|
|
|
|
statically linked). May return NULL on severe errors. */
|
|
|
|
|
const char *
|
|
|
|
|
_gpgme_get_inst_dir (void)
|
2001-11-18 03:31:31 +00:00
|
|
|
|
{
|
2013-08-02 10:48:30 +00:00
|
|
|
|
static char *inst_dir;
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2015-10-28 15:24:30 +00:00
|
|
|
|
if (override_inst_dir)
|
|
|
|
|
return override_inst_dir;
|
|
|
|
|
|
2013-08-02 10:48:30 +00:00
|
|
|
|
LOCK (get_path_lock);
|
|
|
|
|
if (!inst_dir)
|
2001-11-18 03:31:31 +00:00
|
|
|
|
{
|
2013-08-02 10:48:30 +00:00
|
|
|
|
wchar_t *moddir;
|
2001-11-18 03:31:31 +00:00
|
|
|
|
|
2013-08-02 10:48:30 +00:00
|
|
|
|
moddir = malloc ((MAX_PATH+5) * sizeof *moddir);
|
|
|
|
|
if (moddir)
|
|
|
|
|
{
|
|
|
|
|
if (!GetModuleFileNameW (my_hmodule, moddir, MAX_PATH))
|
|
|
|
|
*moddir = 0;
|
|
|
|
|
if (!*moddir)
|
|
|
|
|
gpg_err_set_errno (ENOENT);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
inst_dir = wchar_to_utf8 (moddir);
|
|
|
|
|
if (inst_dir)
|
|
|
|
|
{
|
|
|
|
|
char *p = strrchr (inst_dir, '\\');
|
|
|
|
|
if (p)
|
|
|
|
|
*p = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
free (moddir);
|
|
|
|
|
}
|
2001-11-18 03:31:31 +00:00
|
|
|
|
}
|
2013-08-02 10:48:30 +00:00
|
|
|
|
UNLOCK (get_path_lock);
|
|
|
|
|
return inst_dir;
|
2001-11-18 03:31:31 +00:00
|
|
|
|
}
|
2001-01-30 16:00:50 +00:00
|
|
|
|
|
2002-03-18 00:04:06 +00:00
|
|
|
|
|
2007-11-28 16:31:05 +00:00
|
|
|
|
static char *
|
2013-08-02 10:48:30 +00:00
|
|
|
|
find_program_in_dir (const char *dir, const char *name)
|
2007-11-28 16:31:05 +00:00
|
|
|
|
{
|
2013-08-02 10:48:30 +00:00
|
|
|
|
char *result;
|
2007-11-28 16:31:05 +00:00
|
|
|
|
|
2016-10-10 10:19:48 +00:00
|
|
|
|
result = _gpgme_strconcat (dir, "\\", name, NULL);
|
2007-11-28 16:31:05 +00:00
|
|
|
|
if (!result)
|
2013-08-02 10:48:30 +00:00
|
|
|
|
return NULL;
|
2007-11-28 16:31:05 +00:00
|
|
|
|
|
|
|
|
|
if (access (result, F_OK))
|
|
|
|
|
{
|
|
|
|
|
free (result);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2008-01-04 Marcus Brinkmann <marcus@g10code.de>
* configure.ac: Support gpgconf.
gpgme/
2008-01-04 Marcus Brinkmann <marcus@g10code.de>
* Makefile.am (gpgconf_components): New variable.
(main_sources): Add gpgconf.c.
* gpgme.h (gpgme_protocol_t): New protocol GPGME_PROTOCOL_GPGCONF.
(gpgme_conf_level_t, gpgme_conf_type_t, gpgme_conf_arg_t)
(gpgme_conf_opt_t, gpgme_conf_comp_t, gpgme_conf_arg_new)
(gpgme_conf_arg_release, gpgme_conf_opt_change)
(gpgme_conf_release, gpgme_op_conf_load, gpgme_op_conf_save): New
types.
* gpgconf.c, engine-gpgconf.c: New files.
* engine.h: (_gpgme_engine_op_conf_load,
(_gpgme_engine_op_conf_save): New prototypes.
* op-support.c (_gpgme_op_reset): Ignore not implemented locale
function.
* posix-util.c (_gpgme_get_gpgconf_path): New function.
* w32-util.c (_gpgme_get_gpgconf_path): New function.
* engine-gpgsm.c:
(_gpgme_engine_ops_gpgsm): Add stubs for conf_load and conf_save.
* rungpg.c:
(_gpgme_engine_ops_gpg): Add stubs for conf_load and conf_save.
* gpgme.def: Add new gpgconf related interfaces.
* libgpgme.vers: Likewise.
* util.h (_gpgme_get_gpgconf_path): New prototype.
* gpgme.h (gpgme_protocol_t): Add GPGME_PROTOCOL_GPGCONF.
* engine-backend.h (_gpgme_engine_ops_gpgconf): New prototype.
(struct engine_ops): Add members for conf_load and conf_save.
* engine.c (engine_ops): Add _gpgme_engine_ops_gpgconf.
(_gpgme_engine_op_conf_load,
(_gpgme_engine_op_conf_save): New functions.
(gpgme_get_engine_info): Allow protocol GPGME_PROTOCOL_GPGCONF.
tests/
2008-01-04 Marcus Brinkmann <marcus@g10code.de>
* Makefile.am (TESTS_ENVIRONMENT): Use absolute path for
GNUPGHOME.
* gpg/Makefile.am (TESTS_ENVIRONMENT): Use absolute path for
GNUPGHOME.
* gpgsm/Makefile.am (TESTS_ENVIRONMENT): Use absolute path for
GNUPGHOME.
* gpg/Makefile.am (TESTS): Add t-gpgconf.
t-gpgconf.c: New file.
2008-01-04 14:31:15 +00:00
|
|
|
|
|
2005-08-26 12:38:57 +00:00
|
|
|
|
static char *
|
|
|
|
|
find_program_at_standard_place (const char *name)
|
|
|
|
|
{
|
|
|
|
|
char path[MAX_PATH];
|
|
|
|
|
char *result = NULL;
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2018-10-18 04:19:34 +00:00
|
|
|
|
/* See https://wiki.tcl-lang.org/page/Getting+Windows+%22special+folders%22+with+Ffidl for details on compatibility.
|
2015-10-28 15:26:03 +00:00
|
|
|
|
|
|
|
|
|
We First try the generic place and then fallback to the x86
|
|
|
|
|
(i.e. 32 bit) place. This will prefer a 64 bit of the program
|
|
|
|
|
over a 32 bit version on 64 bit Windows if installed. */
|
2016-11-04 07:10:34 +00:00
|
|
|
|
if (SHGetSpecialFolderPathA (NULL, path, CSIDL_PROGRAM_FILES, 0))
|
|
|
|
|
{
|
|
|
|
|
result = _gpgme_strconcat (path, "\\", name, NULL);
|
|
|
|
|
if (result && access (result, F_OK))
|
|
|
|
|
{
|
|
|
|
|
free (result);
|
|
|
|
|
result = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!result
|
|
|
|
|
&& SHGetSpecialFolderPathA (NULL, path, CSIDL_PROGRAM_FILESX86, 0))
|
2005-08-26 12:38:57 +00:00
|
|
|
|
{
|
2016-09-22 10:41:55 +00:00
|
|
|
|
result = _gpgme_strconcat (path, "\\", name, NULL);
|
|
|
|
|
if (result && access (result, F_OK))
|
2005-08-26 12:38:57 +00:00
|
|
|
|
{
|
2016-09-22 10:41:55 +00:00
|
|
|
|
free (result);
|
|
|
|
|
result = NULL;
|
2005-08-26 12:38:57 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2007-11-28 16:31:05 +00:00
|
|
|
|
|
2014-01-06 16:16:52 +00:00
|
|
|
|
/* Set the default name for the gpg binary. This function may only be
|
|
|
|
|
called by gpgme_set_global_flag. Returns 0 on success. */
|
|
|
|
|
int
|
|
|
|
|
_gpgme_set_default_gpg_name (const char *name)
|
|
|
|
|
{
|
|
|
|
|
if (!default_gpg_name)
|
|
|
|
|
{
|
2016-09-22 10:41:55 +00:00
|
|
|
|
default_gpg_name = _gpgme_strconcat (name, ".exe", NULL);
|
2014-01-06 16:16:52 +00:00
|
|
|
|
if (default_gpg_name)
|
2016-09-22 10:41:55 +00:00
|
|
|
|
replace_slashes (default_gpg_name);
|
2014-01-06 16:16:52 +00:00
|
|
|
|
}
|
|
|
|
|
return !default_gpg_name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Set the default name for the gpgconf binary. This function may only be
|
|
|
|
|
called by gpgme_set_global_flag. Returns 0 on success. */
|
|
|
|
|
int
|
|
|
|
|
_gpgme_set_default_gpgconf_name (const char *name)
|
|
|
|
|
{
|
|
|
|
|
if (!default_gpgconf_name)
|
|
|
|
|
{
|
2016-09-22 10:41:55 +00:00
|
|
|
|
default_gpgconf_name = _gpgme_strconcat (name, ".exe", NULL);
|
2014-01-06 16:16:52 +00:00
|
|
|
|
if (default_gpgconf_name)
|
2016-09-22 10:41:55 +00:00
|
|
|
|
replace_slashes (default_gpgconf_name);
|
2014-01-06 16:16:52 +00:00
|
|
|
|
}
|
|
|
|
|
return !default_gpgconf_name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2015-10-28 15:24:30 +00:00
|
|
|
|
/* Set the override installation directory. This function may only be
|
|
|
|
|
called by gpgme_set_global_flag. Returns 0 on success. */
|
|
|
|
|
int
|
|
|
|
|
_gpgme_set_override_inst_dir (const char *dir)
|
|
|
|
|
{
|
|
|
|
|
if (!override_inst_dir)
|
|
|
|
|
{
|
2016-09-22 10:41:55 +00:00
|
|
|
|
override_inst_dir = strdup (dir);
|
2015-10-28 15:24:30 +00:00
|
|
|
|
if (override_inst_dir)
|
|
|
|
|
{
|
|
|
|
|
replace_slashes (override_inst_dir);
|
|
|
|
|
/* Remove a trailing slash. */
|
|
|
|
|
if (*override_inst_dir
|
|
|
|
|
&& override_inst_dir[strlen (override_inst_dir)-1] == '\\')
|
|
|
|
|
override_inst_dir[strlen (override_inst_dir)-1] = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return !override_inst_dir;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2013-12-27 15:08:20 +00:00
|
|
|
|
/* Return the full file name of the GPG binary. This function is used
|
2015-08-24 14:34:29 +00:00
|
|
|
|
iff gpgconf was not found and thus it can be assumed that gpg2 is
|
2013-12-27 15:08:20 +00:00
|
|
|
|
not installed. This function is only called by get_gpgconf_item
|
|
|
|
|
and may not be called concurrently. */
|
|
|
|
|
char *
|
2001-01-30 16:00:50 +00:00
|
|
|
|
_gpgme_get_gpg_path (void)
|
|
|
|
|
{
|
2015-08-24 14:34:29 +00:00
|
|
|
|
char *gpg = NULL;
|
|
|
|
|
const char *name, *inst_dir;
|
2002-05-09 03:38:12 +00:00
|
|
|
|
|
2015-08-24 14:34:29 +00:00
|
|
|
|
name = default_gpg_name? get_basename (default_gpg_name) : "gpg.exe";
|
|
|
|
|
|
|
|
|
|
/* 1. Try to find gpg.exe in the installation directory of gpgme. */
|
2013-08-02 10:48:30 +00:00
|
|
|
|
inst_dir = _gpgme_get_inst_dir ();
|
2015-08-24 14:34:29 +00:00
|
|
|
|
if (inst_dir)
|
|
|
|
|
{
|
|
|
|
|
gpg = find_program_in_dir (inst_dir, name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 2. Try to find gpg.exe using that ancient registry key. */
|
2013-12-27 15:08:20 +00:00
|
|
|
|
if (!gpg)
|
2014-01-06 16:16:52 +00:00
|
|
|
|
{
|
2015-08-24 14:34:29 +00:00
|
|
|
|
char *dir;
|
|
|
|
|
|
|
|
|
|
dir = read_w32_registry_string ("HKEY_LOCAL_MACHINE",
|
2018-05-17 15:41:53 +00:00
|
|
|
|
GNUPG_REGKEY_2,
|
2015-08-24 14:34:29 +00:00
|
|
|
|
"Install Directory");
|
|
|
|
|
if (dir)
|
|
|
|
|
{
|
|
|
|
|
gpg = find_program_in_dir (dir, name);
|
|
|
|
|
free (dir);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 3. Try to find gpg.exe below CSIDL_PROGRAM_FILES. */
|
|
|
|
|
if (!gpg)
|
|
|
|
|
{
|
|
|
|
|
name = default_gpg_name? default_gpg_name : "GNU\\GnuPG\\gpg.exe";
|
2014-01-06 16:16:52 +00:00
|
|
|
|
gpg = find_program_at_standard_place (name);
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-24 14:34:29 +00:00
|
|
|
|
/* 4. Print a debug message if not found. */
|
|
|
|
|
if (!gpg)
|
|
|
|
|
_gpgme_debug (DEBUG_ENGINE, "_gpgme_get_gpg_path: '%s' not found", name);
|
|
|
|
|
|
2013-12-27 15:08:20 +00:00
|
|
|
|
return gpg;
|
2001-11-18 03:31:31 +00:00
|
|
|
|
}
|
2006-01-26 10:23:15 +00:00
|
|
|
|
|
2014-01-06 16:16:52 +00:00
|
|
|
|
|
2013-12-27 15:08:20 +00:00
|
|
|
|
/* This function is only called by get_gpgconf_item and may not be
|
|
|
|
|
called concurrently. */
|
|
|
|
|
char *
|
2008-01-04 Marcus Brinkmann <marcus@g10code.de>
* configure.ac: Support gpgconf.
gpgme/
2008-01-04 Marcus Brinkmann <marcus@g10code.de>
* Makefile.am (gpgconf_components): New variable.
(main_sources): Add gpgconf.c.
* gpgme.h (gpgme_protocol_t): New protocol GPGME_PROTOCOL_GPGCONF.
(gpgme_conf_level_t, gpgme_conf_type_t, gpgme_conf_arg_t)
(gpgme_conf_opt_t, gpgme_conf_comp_t, gpgme_conf_arg_new)
(gpgme_conf_arg_release, gpgme_conf_opt_change)
(gpgme_conf_release, gpgme_op_conf_load, gpgme_op_conf_save): New
types.
* gpgconf.c, engine-gpgconf.c: New files.
* engine.h: (_gpgme_engine_op_conf_load,
(_gpgme_engine_op_conf_save): New prototypes.
* op-support.c (_gpgme_op_reset): Ignore not implemented locale
function.
* posix-util.c (_gpgme_get_gpgconf_path): New function.
* w32-util.c (_gpgme_get_gpgconf_path): New function.
* engine-gpgsm.c:
(_gpgme_engine_ops_gpgsm): Add stubs for conf_load and conf_save.
* rungpg.c:
(_gpgme_engine_ops_gpg): Add stubs for conf_load and conf_save.
* gpgme.def: Add new gpgconf related interfaces.
* libgpgme.vers: Likewise.
* util.h (_gpgme_get_gpgconf_path): New prototype.
* gpgme.h (gpgme_protocol_t): Add GPGME_PROTOCOL_GPGCONF.
* engine-backend.h (_gpgme_engine_ops_gpgconf): New prototype.
(struct engine_ops): Add members for conf_load and conf_save.
* engine.c (engine_ops): Add _gpgme_engine_ops_gpgconf.
(_gpgme_engine_op_conf_load,
(_gpgme_engine_op_conf_save): New functions.
(gpgme_get_engine_info): Allow protocol GPGME_PROTOCOL_GPGCONF.
tests/
2008-01-04 Marcus Brinkmann <marcus@g10code.de>
* Makefile.am (TESTS_ENVIRONMENT): Use absolute path for
GNUPGHOME.
* gpg/Makefile.am (TESTS_ENVIRONMENT): Use absolute path for
GNUPGHOME.
* gpgsm/Makefile.am (TESTS_ENVIRONMENT): Use absolute path for
GNUPGHOME.
* gpg/Makefile.am (TESTS): Add t-gpgconf.
t-gpgconf.c: New file.
2008-01-04 14:31:15 +00:00
|
|
|
|
_gpgme_get_gpgconf_path (void)
|
|
|
|
|
{
|
2015-08-24 14:34:29 +00:00
|
|
|
|
char *gpgconf = NULL;
|
2014-01-06 16:16:52 +00:00
|
|
|
|
const char *inst_dir, *name;
|
2008-01-04 Marcus Brinkmann <marcus@g10code.de>
* configure.ac: Support gpgconf.
gpgme/
2008-01-04 Marcus Brinkmann <marcus@g10code.de>
* Makefile.am (gpgconf_components): New variable.
(main_sources): Add gpgconf.c.
* gpgme.h (gpgme_protocol_t): New protocol GPGME_PROTOCOL_GPGCONF.
(gpgme_conf_level_t, gpgme_conf_type_t, gpgme_conf_arg_t)
(gpgme_conf_opt_t, gpgme_conf_comp_t, gpgme_conf_arg_new)
(gpgme_conf_arg_release, gpgme_conf_opt_change)
(gpgme_conf_release, gpgme_op_conf_load, gpgme_op_conf_save): New
types.
* gpgconf.c, engine-gpgconf.c: New files.
* engine.h: (_gpgme_engine_op_conf_load,
(_gpgme_engine_op_conf_save): New prototypes.
* op-support.c (_gpgme_op_reset): Ignore not implemented locale
function.
* posix-util.c (_gpgme_get_gpgconf_path): New function.
* w32-util.c (_gpgme_get_gpgconf_path): New function.
* engine-gpgsm.c:
(_gpgme_engine_ops_gpgsm): Add stubs for conf_load and conf_save.
* rungpg.c:
(_gpgme_engine_ops_gpg): Add stubs for conf_load and conf_save.
* gpgme.def: Add new gpgconf related interfaces.
* libgpgme.vers: Likewise.
* util.h (_gpgme_get_gpgconf_path): New prototype.
* gpgme.h (gpgme_protocol_t): Add GPGME_PROTOCOL_GPGCONF.
* engine-backend.h (_gpgme_engine_ops_gpgconf): New prototype.
(struct engine_ops): Add members for conf_load and conf_save.
* engine.c (engine_ops): Add _gpgme_engine_ops_gpgconf.
(_gpgme_engine_op_conf_load,
(_gpgme_engine_op_conf_save): New functions.
(gpgme_get_engine_info): Allow protocol GPGME_PROTOCOL_GPGCONF.
tests/
2008-01-04 Marcus Brinkmann <marcus@g10code.de>
* Makefile.am (TESTS_ENVIRONMENT): Use absolute path for
GNUPGHOME.
* gpg/Makefile.am (TESTS_ENVIRONMENT): Use absolute path for
GNUPGHOME.
* gpgsm/Makefile.am (TESTS_ENVIRONMENT): Use absolute path for
GNUPGHOME.
* gpg/Makefile.am (TESTS): Add t-gpgconf.
t-gpgconf.c: New file.
2008-01-04 14:31:15 +00:00
|
|
|
|
|
2015-08-24 14:34:29 +00:00
|
|
|
|
name = default_gpgconf_name? get_basename(default_gpgconf_name):"gpgconf.exe";
|
|
|
|
|
|
|
|
|
|
/* 1. Try to find gpgconf.exe in the installation directory of gpgme. */
|
2013-08-02 10:48:30 +00:00
|
|
|
|
inst_dir = _gpgme_get_inst_dir ();
|
2015-08-24 14:34:29 +00:00
|
|
|
|
if (inst_dir)
|
|
|
|
|
{
|
|
|
|
|
gpgconf = find_program_in_dir (inst_dir, name);
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-24 17:59:43 +00:00
|
|
|
|
/* 2. Try to find gpgconf.exe from GnuPG >= 2.1 below CSIDL_PROGRAM_FILES. */
|
|
|
|
|
if (!gpgconf)
|
|
|
|
|
{
|
|
|
|
|
const char *name2 = (default_gpgconf_name ? default_gpgconf_name
|
|
|
|
|
/**/ : "GnuPG\\bin\\gpgconf.exe");
|
|
|
|
|
gpgconf = find_program_at_standard_place (name2);
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-01 12:11:13 +00:00
|
|
|
|
/* 3. Try to find gpgconf.exe using the Windows registry. */
|
2013-12-27 15:08:20 +00:00
|
|
|
|
if (!gpgconf)
|
2014-01-06 16:16:52 +00:00
|
|
|
|
{
|
2015-08-24 14:34:29 +00:00
|
|
|
|
char *dir;
|
|
|
|
|
|
2016-03-01 12:11:13 +00:00
|
|
|
|
dir = read_w32_registry_string (NULL,
|
2018-05-17 15:41:53 +00:00
|
|
|
|
GNUPG_REGKEY_2,
|
2015-08-24 14:34:29 +00:00
|
|
|
|
"Install Directory");
|
2016-03-01 12:11:13 +00:00
|
|
|
|
if (!dir)
|
|
|
|
|
{
|
|
|
|
|
char *tmp = read_w32_registry_string (NULL,
|
2018-05-17 15:41:53 +00:00
|
|
|
|
GNUPG_REGKEY_3,
|
2016-03-01 12:11:13 +00:00
|
|
|
|
"Install Directory");
|
|
|
|
|
if (tmp)
|
|
|
|
|
{
|
2017-02-02 11:35:59 +00:00
|
|
|
|
dir = _gpgme_strconcat (tmp, "\\bin", NULL);
|
2016-03-01 12:11:13 +00:00
|
|
|
|
free (tmp);
|
2017-02-02 11:35:59 +00:00
|
|
|
|
if (!dir)
|
|
|
|
|
return NULL;
|
2016-03-01 12:11:13 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-08-24 14:34:29 +00:00
|
|
|
|
if (dir)
|
|
|
|
|
{
|
|
|
|
|
gpgconf = find_program_in_dir (dir, name);
|
|
|
|
|
free (dir);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-24 17:59:43 +00:00
|
|
|
|
/* 4. Try to find gpgconf.exe from Gpg4win below CSIDL_PROGRAM_FILES. */
|
2015-08-24 14:34:29 +00:00
|
|
|
|
if (!gpgconf)
|
|
|
|
|
{
|
2015-08-24 17:59:43 +00:00
|
|
|
|
gpgconf = find_program_at_standard_place ("GNU\\GnuPG\\gpgconf.exe");
|
2014-01-06 16:16:52 +00:00
|
|
|
|
}
|
2015-08-24 14:34:29 +00:00
|
|
|
|
|
2018-05-17 15:41:53 +00:00
|
|
|
|
/* 5. Try to find gpgconf.exe relative to us. */
|
|
|
|
|
if (!gpgconf && inst_dir)
|
|
|
|
|
{
|
|
|
|
|
char *dir = _gpgme_strconcat (inst_dir, "\\..\\..\\GnuPG\\bin");
|
|
|
|
|
gpgconf = find_program_in_dir (dir, name);
|
|
|
|
|
free (dir);
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-24 17:59:43 +00:00
|
|
|
|
/* 5. Print a debug message if not found. */
|
2015-08-24 14:34:29 +00:00
|
|
|
|
if (!gpgconf)
|
|
|
|
|
_gpgme_debug (DEBUG_ENGINE, "_gpgme_get_gpgconf_path: '%s' not found",name);
|
|
|
|
|
|
2013-12-27 15:08:20 +00:00
|
|
|
|
return gpgconf;
|
2009-10-22 16:44:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
assuan/
2008-06-25 Marcus Brinkmann <marcus@g10code.de>
* assuan-pipe-connect.c (struct spawn_fd_item_s): Add new members.
(HANDLE_TRANSLATION): New macro.
(pipe_connect_gpgme): Adjust caller of _gpgme_io_spawn.
[HANDLE_TRANSLATION]: Return translated handles.
gpgme/
2008-06-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme-w32spawn.c: New file.
* Makefile.am (libexec_PROGRAMS) [HAVE_W32_SYSTEM]: New variable
with gpgme-w32spawn.
* engine-gpgsm.c (gpgsm_new): Use server translated handles.
(gpgsm_set_locale): Return early if locale value is NULL.
* util.h (_gpgme_mkstemp)
(_gpgme_get_w32spawn_path) [HAVE_W32_SYSTEM]: New function
prototypes.
* w32-util.c: Include <stdint.h>, <sys/stat.h> and <unistd.h>.
(letters, mkstemp, _gpgme_mkstemp, _gpgme_get_w32spawn_path): New
functions.
* rungpg.c (gpg_decrypt, gpg_encrypt, gpg_encrypt_sign)
(gpg_genkey, gpg_import, gpg_verify, gpg_sign): Pass data over
special filename FD rather than stdin.
(struct arg_and_data_s): Add member ARG_LOCP.
(struct fd_data_map_s): Add member ARG_LOC.
(struct engine_gpg): Add member ARG_LOC to status and colon.
(_add_arg, add_arg_with_locp): New function.
(add_arg_ext): Reimplement in terms of _add_arg.
(gpg_new): Remember argument location for status FD.
(build_argv): Set argument location if requested. Also set
argument location of fd_data_map for data items.
(start): Adjust caller of _gpgme_io_spawn.
* priv-io.h (struct spawn_fd_item_s): Add members peer_name and
arg_loc.
(_gpgme_io_spawn): Remove parent fd list argument.
* posix-io.c (get_max_fds): New function.
(_gpgme_io_dup): Add tracing.
(_gpgme_io_spawn): Remove parent fd list. Change meaning of child
fd list to contain all child fds that should be inherited. Close
all other file descriptors after fork.
* w32-io.c, w32-glib-io.c, w32-qt-io.c(_gpgme_io_spawn): Remove
parent fd list. Change meaning of child fd list to contain all
child fds that should be inherited. Do not inherit any file
descriptors, but DuplicateHandle them. Spawn process through
wrapper process. Provide wrapper process with a temporary file
containing handle translation data. Return translated handle
names.
* w32-io.c (reader): Add more tracing output.
(_gpgme_io_read): Likewise.
* engine-gpgconf.c (gpgconf_read): Adjust caller of
_gpgme_io_spawn.
* version.c (_gpgme_get_program_version): Likewise.
2008-06-25 16:52:31 +00:00
|
|
|
|
const char *
|
|
|
|
|
_gpgme_get_w32spawn_path (void)
|
|
|
|
|
{
|
|
|
|
|
static char *w32spawn_program;
|
2013-08-02 10:48:30 +00:00
|
|
|
|
const char *inst_dir;
|
assuan/
2008-06-25 Marcus Brinkmann <marcus@g10code.de>
* assuan-pipe-connect.c (struct spawn_fd_item_s): Add new members.
(HANDLE_TRANSLATION): New macro.
(pipe_connect_gpgme): Adjust caller of _gpgme_io_spawn.
[HANDLE_TRANSLATION]: Return translated handles.
gpgme/
2008-06-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme-w32spawn.c: New file.
* Makefile.am (libexec_PROGRAMS) [HAVE_W32_SYSTEM]: New variable
with gpgme-w32spawn.
* engine-gpgsm.c (gpgsm_new): Use server translated handles.
(gpgsm_set_locale): Return early if locale value is NULL.
* util.h (_gpgme_mkstemp)
(_gpgme_get_w32spawn_path) [HAVE_W32_SYSTEM]: New function
prototypes.
* w32-util.c: Include <stdint.h>, <sys/stat.h> and <unistd.h>.
(letters, mkstemp, _gpgme_mkstemp, _gpgme_get_w32spawn_path): New
functions.
* rungpg.c (gpg_decrypt, gpg_encrypt, gpg_encrypt_sign)
(gpg_genkey, gpg_import, gpg_verify, gpg_sign): Pass data over
special filename FD rather than stdin.
(struct arg_and_data_s): Add member ARG_LOCP.
(struct fd_data_map_s): Add member ARG_LOC.
(struct engine_gpg): Add member ARG_LOC to status and colon.
(_add_arg, add_arg_with_locp): New function.
(add_arg_ext): Reimplement in terms of _add_arg.
(gpg_new): Remember argument location for status FD.
(build_argv): Set argument location if requested. Also set
argument location of fd_data_map for data items.
(start): Adjust caller of _gpgme_io_spawn.
* priv-io.h (struct spawn_fd_item_s): Add members peer_name and
arg_loc.
(_gpgme_io_spawn): Remove parent fd list argument.
* posix-io.c (get_max_fds): New function.
(_gpgme_io_dup): Add tracing.
(_gpgme_io_spawn): Remove parent fd list. Change meaning of child
fd list to contain all child fds that should be inherited. Close
all other file descriptors after fork.
* w32-io.c, w32-glib-io.c, w32-qt-io.c(_gpgme_io_spawn): Remove
parent fd list. Change meaning of child fd list to contain all
child fds that should be inherited. Do not inherit any file
descriptors, but DuplicateHandle them. Spawn process through
wrapper process. Provide wrapper process with a temporary file
containing handle translation data. Return translated handle
names.
* w32-io.c (reader): Add more tracing output.
(_gpgme_io_read): Likewise.
* engine-gpgconf.c (gpgconf_read): Adjust caller of
_gpgme_io_spawn.
* version.c (_gpgme_get_program_version): Likewise.
2008-06-25 16:52:31 +00:00
|
|
|
|
|
2013-08-02 10:48:30 +00:00
|
|
|
|
inst_dir = _gpgme_get_inst_dir ();
|
assuan/
2008-06-25 Marcus Brinkmann <marcus@g10code.de>
* assuan-pipe-connect.c (struct spawn_fd_item_s): Add new members.
(HANDLE_TRANSLATION): New macro.
(pipe_connect_gpgme): Adjust caller of _gpgme_io_spawn.
[HANDLE_TRANSLATION]: Return translated handles.
gpgme/
2008-06-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme-w32spawn.c: New file.
* Makefile.am (libexec_PROGRAMS) [HAVE_W32_SYSTEM]: New variable
with gpgme-w32spawn.
* engine-gpgsm.c (gpgsm_new): Use server translated handles.
(gpgsm_set_locale): Return early if locale value is NULL.
* util.h (_gpgme_mkstemp)
(_gpgme_get_w32spawn_path) [HAVE_W32_SYSTEM]: New function
prototypes.
* w32-util.c: Include <stdint.h>, <sys/stat.h> and <unistd.h>.
(letters, mkstemp, _gpgme_mkstemp, _gpgme_get_w32spawn_path): New
functions.
* rungpg.c (gpg_decrypt, gpg_encrypt, gpg_encrypt_sign)
(gpg_genkey, gpg_import, gpg_verify, gpg_sign): Pass data over
special filename FD rather than stdin.
(struct arg_and_data_s): Add member ARG_LOCP.
(struct fd_data_map_s): Add member ARG_LOC.
(struct engine_gpg): Add member ARG_LOC to status and colon.
(_add_arg, add_arg_with_locp): New function.
(add_arg_ext): Reimplement in terms of _add_arg.
(gpg_new): Remember argument location for status FD.
(build_argv): Set argument location if requested. Also set
argument location of fd_data_map for data items.
(start): Adjust caller of _gpgme_io_spawn.
* priv-io.h (struct spawn_fd_item_s): Add members peer_name and
arg_loc.
(_gpgme_io_spawn): Remove parent fd list argument.
* posix-io.c (get_max_fds): New function.
(_gpgme_io_dup): Add tracing.
(_gpgme_io_spawn): Remove parent fd list. Change meaning of child
fd list to contain all child fds that should be inherited. Close
all other file descriptors after fork.
* w32-io.c, w32-glib-io.c, w32-qt-io.c(_gpgme_io_spawn): Remove
parent fd list. Change meaning of child fd list to contain all
child fds that should be inherited. Do not inherit any file
descriptors, but DuplicateHandle them. Spawn process through
wrapper process. Provide wrapper process with a temporary file
containing handle translation data. Return translated handle
names.
* w32-io.c (reader): Add more tracing output.
(_gpgme_io_read): Likewise.
* engine-gpgconf.c (gpgconf_read): Adjust caller of
_gpgme_io_spawn.
* version.c (_gpgme_get_program_version): Likewise.
2008-06-25 16:52:31 +00:00
|
|
|
|
LOCK (get_path_lock);
|
|
|
|
|
if (!w32spawn_program)
|
2015-08-24 14:34:29 +00:00
|
|
|
|
w32spawn_program = find_program_in_dir (inst_dir, "gpgme-w32spawn.exe");
|
assuan/
2008-06-25 Marcus Brinkmann <marcus@g10code.de>
* assuan-pipe-connect.c (struct spawn_fd_item_s): Add new members.
(HANDLE_TRANSLATION): New macro.
(pipe_connect_gpgme): Adjust caller of _gpgme_io_spawn.
[HANDLE_TRANSLATION]: Return translated handles.
gpgme/
2008-06-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme-w32spawn.c: New file.
* Makefile.am (libexec_PROGRAMS) [HAVE_W32_SYSTEM]: New variable
with gpgme-w32spawn.
* engine-gpgsm.c (gpgsm_new): Use server translated handles.
(gpgsm_set_locale): Return early if locale value is NULL.
* util.h (_gpgme_mkstemp)
(_gpgme_get_w32spawn_path) [HAVE_W32_SYSTEM]: New function
prototypes.
* w32-util.c: Include <stdint.h>, <sys/stat.h> and <unistd.h>.
(letters, mkstemp, _gpgme_mkstemp, _gpgme_get_w32spawn_path): New
functions.
* rungpg.c (gpg_decrypt, gpg_encrypt, gpg_encrypt_sign)
(gpg_genkey, gpg_import, gpg_verify, gpg_sign): Pass data over
special filename FD rather than stdin.
(struct arg_and_data_s): Add member ARG_LOCP.
(struct fd_data_map_s): Add member ARG_LOC.
(struct engine_gpg): Add member ARG_LOC to status and colon.
(_add_arg, add_arg_with_locp): New function.
(add_arg_ext): Reimplement in terms of _add_arg.
(gpg_new): Remember argument location for status FD.
(build_argv): Set argument location if requested. Also set
argument location of fd_data_map for data items.
(start): Adjust caller of _gpgme_io_spawn.
* priv-io.h (struct spawn_fd_item_s): Add members peer_name and
arg_loc.
(_gpgme_io_spawn): Remove parent fd list argument.
* posix-io.c (get_max_fds): New function.
(_gpgme_io_dup): Add tracing.
(_gpgme_io_spawn): Remove parent fd list. Change meaning of child
fd list to contain all child fds that should be inherited. Close
all other file descriptors after fork.
* w32-io.c, w32-glib-io.c, w32-qt-io.c(_gpgme_io_spawn): Remove
parent fd list. Change meaning of child fd list to contain all
child fds that should be inherited. Do not inherit any file
descriptors, but DuplicateHandle them. Spawn process through
wrapper process. Provide wrapper process with a temporary file
containing handle translation data. Return translated handle
names.
* w32-io.c (reader): Add more tracing output.
(_gpgme_io_read): Likewise.
* engine-gpgconf.c (gpgconf_read): Adjust caller of
_gpgme_io_spawn.
* version.c (_gpgme_get_program_version): Likewise.
2008-06-25 16:52:31 +00:00
|
|
|
|
UNLOCK (get_path_lock);
|
|
|
|
|
return w32spawn_program;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-01-26 10:23:15 +00:00
|
|
|
|
/* Return an integer value from gpgme specific configuration
|
|
|
|
|
entries. VALUE receives that value; function returns true if a value
|
|
|
|
|
has been configured and false if not. */
|
|
|
|
|
int
|
|
|
|
|
_gpgme_get_conf_int (const char *key, int *value)
|
|
|
|
|
{
|
|
|
|
|
char *tmp = read_w32_registry_string (NULL, "Software\\GNU\\gpgme", key);
|
|
|
|
|
if (!tmp)
|
|
|
|
|
return 0;
|
|
|
|
|
*value = atoi (tmp);
|
|
|
|
|
free (tmp);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2008-02-14 19:51:21 +00:00
|
|
|
|
|
2011-02-02 12:47:53 +00:00
|
|
|
|
|
2018-10-31 11:27:27 +00:00
|
|
|
|
|
assuan/
2008-06-25 Marcus Brinkmann <marcus@g10code.de>
* assuan-pipe-connect.c (struct spawn_fd_item_s): Add new members.
(HANDLE_TRANSLATION): New macro.
(pipe_connect_gpgme): Adjust caller of _gpgme_io_spawn.
[HANDLE_TRANSLATION]: Return translated handles.
gpgme/
2008-06-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme-w32spawn.c: New file.
* Makefile.am (libexec_PROGRAMS) [HAVE_W32_SYSTEM]: New variable
with gpgme-w32spawn.
* engine-gpgsm.c (gpgsm_new): Use server translated handles.
(gpgsm_set_locale): Return early if locale value is NULL.
* util.h (_gpgme_mkstemp)
(_gpgme_get_w32spawn_path) [HAVE_W32_SYSTEM]: New function
prototypes.
* w32-util.c: Include <stdint.h>, <sys/stat.h> and <unistd.h>.
(letters, mkstemp, _gpgme_mkstemp, _gpgme_get_w32spawn_path): New
functions.
* rungpg.c (gpg_decrypt, gpg_encrypt, gpg_encrypt_sign)
(gpg_genkey, gpg_import, gpg_verify, gpg_sign): Pass data over
special filename FD rather than stdin.
(struct arg_and_data_s): Add member ARG_LOCP.
(struct fd_data_map_s): Add member ARG_LOC.
(struct engine_gpg): Add member ARG_LOC to status and colon.
(_add_arg, add_arg_with_locp): New function.
(add_arg_ext): Reimplement in terms of _add_arg.
(gpg_new): Remember argument location for status FD.
(build_argv): Set argument location if requested. Also set
argument location of fd_data_map for data items.
(start): Adjust caller of _gpgme_io_spawn.
* priv-io.h (struct spawn_fd_item_s): Add members peer_name and
arg_loc.
(_gpgme_io_spawn): Remove parent fd list argument.
* posix-io.c (get_max_fds): New function.
(_gpgme_io_dup): Add tracing.
(_gpgme_io_spawn): Remove parent fd list. Change meaning of child
fd list to contain all child fds that should be inherited. Close
all other file descriptors after fork.
* w32-io.c, w32-glib-io.c, w32-qt-io.c(_gpgme_io_spawn): Remove
parent fd list. Change meaning of child fd list to contain all
child fds that should be inherited. Do not inherit any file
descriptors, but DuplicateHandle them. Spawn process through
wrapper process. Provide wrapper process with a temporary file
containing handle translation data. Return translated handle
names.
* w32-io.c (reader): Add more tracing output.
(_gpgme_io_read): Likewise.
* engine-gpgconf.c (gpgconf_read): Adjust caller of
_gpgme_io_spawn.
* version.c (_gpgme_get_program_version): Likewise.
2008-06-25 16:52:31 +00:00
|
|
|
|
/* mkstemp extracted from libc/sysdeps/posix/tempname.c. Copyright
|
|
|
|
|
(C) 1991-1999, 2000, 2001, 2006 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
|
version 2.1 of the License, or (at your option) any later version. */
|
|
|
|
|
|
|
|
|
|
static const char letters[] =
|
|
|
|
|
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
|
|
|
|
|
|
|
|
|
/* Generate a temporary file name based on TMPL. TMPL must match the
|
|
|
|
|
rules for mk[s]temp (i.e. end in "XXXXXX"). The name constructed
|
|
|
|
|
does not exist at the time of the call to mkstemp. TMPL is
|
|
|
|
|
overwritten with the result. */
|
|
|
|
|
static int
|
2015-12-09 10:39:26 +00:00
|
|
|
|
my_mkstemp (char *tmpl)
|
assuan/
2008-06-25 Marcus Brinkmann <marcus@g10code.de>
* assuan-pipe-connect.c (struct spawn_fd_item_s): Add new members.
(HANDLE_TRANSLATION): New macro.
(pipe_connect_gpgme): Adjust caller of _gpgme_io_spawn.
[HANDLE_TRANSLATION]: Return translated handles.
gpgme/
2008-06-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme-w32spawn.c: New file.
* Makefile.am (libexec_PROGRAMS) [HAVE_W32_SYSTEM]: New variable
with gpgme-w32spawn.
* engine-gpgsm.c (gpgsm_new): Use server translated handles.
(gpgsm_set_locale): Return early if locale value is NULL.
* util.h (_gpgme_mkstemp)
(_gpgme_get_w32spawn_path) [HAVE_W32_SYSTEM]: New function
prototypes.
* w32-util.c: Include <stdint.h>, <sys/stat.h> and <unistd.h>.
(letters, mkstemp, _gpgme_mkstemp, _gpgme_get_w32spawn_path): New
functions.
* rungpg.c (gpg_decrypt, gpg_encrypt, gpg_encrypt_sign)
(gpg_genkey, gpg_import, gpg_verify, gpg_sign): Pass data over
special filename FD rather than stdin.
(struct arg_and_data_s): Add member ARG_LOCP.
(struct fd_data_map_s): Add member ARG_LOC.
(struct engine_gpg): Add member ARG_LOC to status and colon.
(_add_arg, add_arg_with_locp): New function.
(add_arg_ext): Reimplement in terms of _add_arg.
(gpg_new): Remember argument location for status FD.
(build_argv): Set argument location if requested. Also set
argument location of fd_data_map for data items.
(start): Adjust caller of _gpgme_io_spawn.
* priv-io.h (struct spawn_fd_item_s): Add members peer_name and
arg_loc.
(_gpgme_io_spawn): Remove parent fd list argument.
* posix-io.c (get_max_fds): New function.
(_gpgme_io_dup): Add tracing.
(_gpgme_io_spawn): Remove parent fd list. Change meaning of child
fd list to contain all child fds that should be inherited. Close
all other file descriptors after fork.
* w32-io.c, w32-glib-io.c, w32-qt-io.c(_gpgme_io_spawn): Remove
parent fd list. Change meaning of child fd list to contain all
child fds that should be inherited. Do not inherit any file
descriptors, but DuplicateHandle them. Spawn process through
wrapper process. Provide wrapper process with a temporary file
containing handle translation data. Return translated handle
names.
* w32-io.c (reader): Add more tracing output.
(_gpgme_io_read): Likewise.
* engine-gpgconf.c (gpgconf_read): Adjust caller of
_gpgme_io_spawn.
* version.c (_gpgme_get_program_version): Likewise.
2008-06-25 16:52:31 +00:00
|
|
|
|
{
|
|
|
|
|
int len;
|
|
|
|
|
char *XXXXXX;
|
|
|
|
|
static uint64_t value;
|
|
|
|
|
uint64_t random_time_bits;
|
|
|
|
|
unsigned int count;
|
2011-02-02 12:47:53 +00:00
|
|
|
|
int fd = -1;
|
assuan/
2008-06-25 Marcus Brinkmann <marcus@g10code.de>
* assuan-pipe-connect.c (struct spawn_fd_item_s): Add new members.
(HANDLE_TRANSLATION): New macro.
(pipe_connect_gpgme): Adjust caller of _gpgme_io_spawn.
[HANDLE_TRANSLATION]: Return translated handles.
gpgme/
2008-06-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme-w32spawn.c: New file.
* Makefile.am (libexec_PROGRAMS) [HAVE_W32_SYSTEM]: New variable
with gpgme-w32spawn.
* engine-gpgsm.c (gpgsm_new): Use server translated handles.
(gpgsm_set_locale): Return early if locale value is NULL.
* util.h (_gpgme_mkstemp)
(_gpgme_get_w32spawn_path) [HAVE_W32_SYSTEM]: New function
prototypes.
* w32-util.c: Include <stdint.h>, <sys/stat.h> and <unistd.h>.
(letters, mkstemp, _gpgme_mkstemp, _gpgme_get_w32spawn_path): New
functions.
* rungpg.c (gpg_decrypt, gpg_encrypt, gpg_encrypt_sign)
(gpg_genkey, gpg_import, gpg_verify, gpg_sign): Pass data over
special filename FD rather than stdin.
(struct arg_and_data_s): Add member ARG_LOCP.
(struct fd_data_map_s): Add member ARG_LOC.
(struct engine_gpg): Add member ARG_LOC to status and colon.
(_add_arg, add_arg_with_locp): New function.
(add_arg_ext): Reimplement in terms of _add_arg.
(gpg_new): Remember argument location for status FD.
(build_argv): Set argument location if requested. Also set
argument location of fd_data_map for data items.
(start): Adjust caller of _gpgme_io_spawn.
* priv-io.h (struct spawn_fd_item_s): Add members peer_name and
arg_loc.
(_gpgme_io_spawn): Remove parent fd list argument.
* posix-io.c (get_max_fds): New function.
(_gpgme_io_dup): Add tracing.
(_gpgme_io_spawn): Remove parent fd list. Change meaning of child
fd list to contain all child fds that should be inherited. Close
all other file descriptors after fork.
* w32-io.c, w32-glib-io.c, w32-qt-io.c(_gpgme_io_spawn): Remove
parent fd list. Change meaning of child fd list to contain all
child fds that should be inherited. Do not inherit any file
descriptors, but DuplicateHandle them. Spawn process through
wrapper process. Provide wrapper process with a temporary file
containing handle translation data. Return translated handle
names.
* w32-io.c (reader): Add more tracing output.
(_gpgme_io_read): Likewise.
* engine-gpgconf.c (gpgconf_read): Adjust caller of
_gpgme_io_spawn.
* version.c (_gpgme_get_program_version): Likewise.
2008-06-25 16:52:31 +00:00
|
|
|
|
int save_errno = errno;
|
|
|
|
|
|
|
|
|
|
/* A lower bound on the number of temporary files to attempt to
|
|
|
|
|
generate. The maximum total number of temporary file names that
|
|
|
|
|
can exist for a given template is 62**6. It should never be
|
|
|
|
|
necessary to try all these combinations. Instead if a reasonable
|
|
|
|
|
number of names is tried (we define reasonable as 62**3) fail to
|
|
|
|
|
give the system administrator the chance to remove the problems. */
|
|
|
|
|
#define ATTEMPTS_MIN (62 * 62 * 62)
|
|
|
|
|
|
|
|
|
|
/* The number of times to attempt to generate a temporary file. To
|
|
|
|
|
conform to POSIX, this must be no smaller than TMP_MAX. */
|
|
|
|
|
#if ATTEMPTS_MIN < TMP_MAX
|
|
|
|
|
unsigned int attempts = TMP_MAX;
|
|
|
|
|
#else
|
|
|
|
|
unsigned int attempts = ATTEMPTS_MIN;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
len = strlen (tmpl);
|
|
|
|
|
if (len < 6 || strcmp (&tmpl[len - 6], "XXXXXX"))
|
|
|
|
|
{
|
2010-05-06 Marcus Brinkmann <marcus@g10code.de>
* configure.ac: Require libgpg-error 1.8.
src/
2010-05-06 Marcus Brinkmann <marcus@g10code.de>
* sign.c, data-user.c, conversion.c, debug.c, verify.c, data.c,
decrypt.c, delete.c, assuan-support.c, import.c, engine-gpgsm.c,
data-mem.c, op-support.c, w32-io.c, w32-util.c, data-compat.c: Use
gpg_error_from_syserror instead gpg_error_from_errno, and use
gpg_err_set_errno to set error number.
* setenv.c: Include <gpg-error.h> and define __set_errno to use
gpg_err_set_errno.
* gpgme-tool.c (ARGP_ERR_UNKNOWN): Define to EDEADLOCK (which is
mapped in Windows CE) instead of E2BIG (which is not).
(gt_import_keys): Initialize err.
2010-05-06 13:39:55 +00:00
|
|
|
|
gpg_err_set_errno (EINVAL);
|
assuan/
2008-06-25 Marcus Brinkmann <marcus@g10code.de>
* assuan-pipe-connect.c (struct spawn_fd_item_s): Add new members.
(HANDLE_TRANSLATION): New macro.
(pipe_connect_gpgme): Adjust caller of _gpgme_io_spawn.
[HANDLE_TRANSLATION]: Return translated handles.
gpgme/
2008-06-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme-w32spawn.c: New file.
* Makefile.am (libexec_PROGRAMS) [HAVE_W32_SYSTEM]: New variable
with gpgme-w32spawn.
* engine-gpgsm.c (gpgsm_new): Use server translated handles.
(gpgsm_set_locale): Return early if locale value is NULL.
* util.h (_gpgme_mkstemp)
(_gpgme_get_w32spawn_path) [HAVE_W32_SYSTEM]: New function
prototypes.
* w32-util.c: Include <stdint.h>, <sys/stat.h> and <unistd.h>.
(letters, mkstemp, _gpgme_mkstemp, _gpgme_get_w32spawn_path): New
functions.
* rungpg.c (gpg_decrypt, gpg_encrypt, gpg_encrypt_sign)
(gpg_genkey, gpg_import, gpg_verify, gpg_sign): Pass data over
special filename FD rather than stdin.
(struct arg_and_data_s): Add member ARG_LOCP.
(struct fd_data_map_s): Add member ARG_LOC.
(struct engine_gpg): Add member ARG_LOC to status and colon.
(_add_arg, add_arg_with_locp): New function.
(add_arg_ext): Reimplement in terms of _add_arg.
(gpg_new): Remember argument location for status FD.
(build_argv): Set argument location if requested. Also set
argument location of fd_data_map for data items.
(start): Adjust caller of _gpgme_io_spawn.
* priv-io.h (struct spawn_fd_item_s): Add members peer_name and
arg_loc.
(_gpgme_io_spawn): Remove parent fd list argument.
* posix-io.c (get_max_fds): New function.
(_gpgme_io_dup): Add tracing.
(_gpgme_io_spawn): Remove parent fd list. Change meaning of child
fd list to contain all child fds that should be inherited. Close
all other file descriptors after fork.
* w32-io.c, w32-glib-io.c, w32-qt-io.c(_gpgme_io_spawn): Remove
parent fd list. Change meaning of child fd list to contain all
child fds that should be inherited. Do not inherit any file
descriptors, but DuplicateHandle them. Spawn process through
wrapper process. Provide wrapper process with a temporary file
containing handle translation data. Return translated handle
names.
* w32-io.c (reader): Add more tracing output.
(_gpgme_io_read): Likewise.
* engine-gpgconf.c (gpgconf_read): Adjust caller of
_gpgme_io_spawn.
* version.c (_gpgme_get_program_version): Likewise.
2008-06-25 16:52:31 +00:00
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* This is where the Xs start. */
|
|
|
|
|
XXXXXX = &tmpl[len - 6];
|
|
|
|
|
|
|
|
|
|
/* Get some more or less random data. */
|
|
|
|
|
{
|
2008-06-26 14:38:39 +00:00
|
|
|
|
FILETIME ft;
|
|
|
|
|
|
|
|
|
|
GetSystemTimeAsFileTime (&ft);
|
|
|
|
|
random_time_bits = (((uint64_t)ft.dwHighDateTime << 32)
|
|
|
|
|
| (uint64_t)ft.dwLowDateTime);
|
assuan/
2008-06-25 Marcus Brinkmann <marcus@g10code.de>
* assuan-pipe-connect.c (struct spawn_fd_item_s): Add new members.
(HANDLE_TRANSLATION): New macro.
(pipe_connect_gpgme): Adjust caller of _gpgme_io_spawn.
[HANDLE_TRANSLATION]: Return translated handles.
gpgme/
2008-06-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme-w32spawn.c: New file.
* Makefile.am (libexec_PROGRAMS) [HAVE_W32_SYSTEM]: New variable
with gpgme-w32spawn.
* engine-gpgsm.c (gpgsm_new): Use server translated handles.
(gpgsm_set_locale): Return early if locale value is NULL.
* util.h (_gpgme_mkstemp)
(_gpgme_get_w32spawn_path) [HAVE_W32_SYSTEM]: New function
prototypes.
* w32-util.c: Include <stdint.h>, <sys/stat.h> and <unistd.h>.
(letters, mkstemp, _gpgme_mkstemp, _gpgme_get_w32spawn_path): New
functions.
* rungpg.c (gpg_decrypt, gpg_encrypt, gpg_encrypt_sign)
(gpg_genkey, gpg_import, gpg_verify, gpg_sign): Pass data over
special filename FD rather than stdin.
(struct arg_and_data_s): Add member ARG_LOCP.
(struct fd_data_map_s): Add member ARG_LOC.
(struct engine_gpg): Add member ARG_LOC to status and colon.
(_add_arg, add_arg_with_locp): New function.
(add_arg_ext): Reimplement in terms of _add_arg.
(gpg_new): Remember argument location for status FD.
(build_argv): Set argument location if requested. Also set
argument location of fd_data_map for data items.
(start): Adjust caller of _gpgme_io_spawn.
* priv-io.h (struct spawn_fd_item_s): Add members peer_name and
arg_loc.
(_gpgme_io_spawn): Remove parent fd list argument.
* posix-io.c (get_max_fds): New function.
(_gpgme_io_dup): Add tracing.
(_gpgme_io_spawn): Remove parent fd list. Change meaning of child
fd list to contain all child fds that should be inherited. Close
all other file descriptors after fork.
* w32-io.c, w32-glib-io.c, w32-qt-io.c(_gpgme_io_spawn): Remove
parent fd list. Change meaning of child fd list to contain all
child fds that should be inherited. Do not inherit any file
descriptors, but DuplicateHandle them. Spawn process through
wrapper process. Provide wrapper process with a temporary file
containing handle translation data. Return translated handle
names.
* w32-io.c (reader): Add more tracing output.
(_gpgme_io_read): Likewise.
* engine-gpgconf.c (gpgconf_read): Adjust caller of
_gpgme_io_spawn.
* version.c (_gpgme_get_program_version): Likewise.
2008-06-25 16:52:31 +00:00
|
|
|
|
}
|
2010-05-11 17:20:45 +00:00
|
|
|
|
value += random_time_bits ^ ath_self ();
|
assuan/
2008-06-25 Marcus Brinkmann <marcus@g10code.de>
* assuan-pipe-connect.c (struct spawn_fd_item_s): Add new members.
(HANDLE_TRANSLATION): New macro.
(pipe_connect_gpgme): Adjust caller of _gpgme_io_spawn.
[HANDLE_TRANSLATION]: Return translated handles.
gpgme/
2008-06-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme-w32spawn.c: New file.
* Makefile.am (libexec_PROGRAMS) [HAVE_W32_SYSTEM]: New variable
with gpgme-w32spawn.
* engine-gpgsm.c (gpgsm_new): Use server translated handles.
(gpgsm_set_locale): Return early if locale value is NULL.
* util.h (_gpgme_mkstemp)
(_gpgme_get_w32spawn_path) [HAVE_W32_SYSTEM]: New function
prototypes.
* w32-util.c: Include <stdint.h>, <sys/stat.h> and <unistd.h>.
(letters, mkstemp, _gpgme_mkstemp, _gpgme_get_w32spawn_path): New
functions.
* rungpg.c (gpg_decrypt, gpg_encrypt, gpg_encrypt_sign)
(gpg_genkey, gpg_import, gpg_verify, gpg_sign): Pass data over
special filename FD rather than stdin.
(struct arg_and_data_s): Add member ARG_LOCP.
(struct fd_data_map_s): Add member ARG_LOC.
(struct engine_gpg): Add member ARG_LOC to status and colon.
(_add_arg, add_arg_with_locp): New function.
(add_arg_ext): Reimplement in terms of _add_arg.
(gpg_new): Remember argument location for status FD.
(build_argv): Set argument location if requested. Also set
argument location of fd_data_map for data items.
(start): Adjust caller of _gpgme_io_spawn.
* priv-io.h (struct spawn_fd_item_s): Add members peer_name and
arg_loc.
(_gpgme_io_spawn): Remove parent fd list argument.
* posix-io.c (get_max_fds): New function.
(_gpgme_io_dup): Add tracing.
(_gpgme_io_spawn): Remove parent fd list. Change meaning of child
fd list to contain all child fds that should be inherited. Close
all other file descriptors after fork.
* w32-io.c, w32-glib-io.c, w32-qt-io.c(_gpgme_io_spawn): Remove
parent fd list. Change meaning of child fd list to contain all
child fds that should be inherited. Do not inherit any file
descriptors, but DuplicateHandle them. Spawn process through
wrapper process. Provide wrapper process with a temporary file
containing handle translation data. Return translated handle
names.
* w32-io.c (reader): Add more tracing output.
(_gpgme_io_read): Likewise.
* engine-gpgconf.c (gpgconf_read): Adjust caller of
_gpgme_io_spawn.
* version.c (_gpgme_get_program_version): Likewise.
2008-06-25 16:52:31 +00:00
|
|
|
|
|
|
|
|
|
for (count = 0; count < attempts; value += 7777, ++count)
|
|
|
|
|
{
|
|
|
|
|
uint64_t v = value;
|
|
|
|
|
|
|
|
|
|
/* Fill in the random bits. */
|
|
|
|
|
XXXXXX[0] = letters[v % 62];
|
|
|
|
|
v /= 62;
|
|
|
|
|
XXXXXX[1] = letters[v % 62];
|
|
|
|
|
v /= 62;
|
|
|
|
|
XXXXXX[2] = letters[v % 62];
|
|
|
|
|
v /= 62;
|
|
|
|
|
XXXXXX[3] = letters[v % 62];
|
|
|
|
|
v /= 62;
|
|
|
|
|
XXXXXX[4] = letters[v % 62];
|
|
|
|
|
v /= 62;
|
|
|
|
|
XXXXXX[5] = letters[v % 62];
|
|
|
|
|
|
2011-02-02 12:47:53 +00:00
|
|
|
|
fd = open (tmpl, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
|
|
|
|
|
if (fd >= 0)
|
assuan/
2008-06-25 Marcus Brinkmann <marcus@g10code.de>
* assuan-pipe-connect.c (struct spawn_fd_item_s): Add new members.
(HANDLE_TRANSLATION): New macro.
(pipe_connect_gpgme): Adjust caller of _gpgme_io_spawn.
[HANDLE_TRANSLATION]: Return translated handles.
gpgme/
2008-06-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme-w32spawn.c: New file.
* Makefile.am (libexec_PROGRAMS) [HAVE_W32_SYSTEM]: New variable
with gpgme-w32spawn.
* engine-gpgsm.c (gpgsm_new): Use server translated handles.
(gpgsm_set_locale): Return early if locale value is NULL.
* util.h (_gpgme_mkstemp)
(_gpgme_get_w32spawn_path) [HAVE_W32_SYSTEM]: New function
prototypes.
* w32-util.c: Include <stdint.h>, <sys/stat.h> and <unistd.h>.
(letters, mkstemp, _gpgme_mkstemp, _gpgme_get_w32spawn_path): New
functions.
* rungpg.c (gpg_decrypt, gpg_encrypt, gpg_encrypt_sign)
(gpg_genkey, gpg_import, gpg_verify, gpg_sign): Pass data over
special filename FD rather than stdin.
(struct arg_and_data_s): Add member ARG_LOCP.
(struct fd_data_map_s): Add member ARG_LOC.
(struct engine_gpg): Add member ARG_LOC to status and colon.
(_add_arg, add_arg_with_locp): New function.
(add_arg_ext): Reimplement in terms of _add_arg.
(gpg_new): Remember argument location for status FD.
(build_argv): Set argument location if requested. Also set
argument location of fd_data_map for data items.
(start): Adjust caller of _gpgme_io_spawn.
* priv-io.h (struct spawn_fd_item_s): Add members peer_name and
arg_loc.
(_gpgme_io_spawn): Remove parent fd list argument.
* posix-io.c (get_max_fds): New function.
(_gpgme_io_dup): Add tracing.
(_gpgme_io_spawn): Remove parent fd list. Change meaning of child
fd list to contain all child fds that should be inherited. Close
all other file descriptors after fork.
* w32-io.c, w32-glib-io.c, w32-qt-io.c(_gpgme_io_spawn): Remove
parent fd list. Change meaning of child fd list to contain all
child fds that should be inherited. Do not inherit any file
descriptors, but DuplicateHandle them. Spawn process through
wrapper process. Provide wrapper process with a temporary file
containing handle translation data. Return translated handle
names.
* w32-io.c (reader): Add more tracing output.
(_gpgme_io_read): Likewise.
* engine-gpgconf.c (gpgconf_read): Adjust caller of
_gpgme_io_spawn.
* version.c (_gpgme_get_program_version): Likewise.
2008-06-25 16:52:31 +00:00
|
|
|
|
{
|
2010-05-06 Marcus Brinkmann <marcus@g10code.de>
* configure.ac: Require libgpg-error 1.8.
src/
2010-05-06 Marcus Brinkmann <marcus@g10code.de>
* sign.c, data-user.c, conversion.c, debug.c, verify.c, data.c,
decrypt.c, delete.c, assuan-support.c, import.c, engine-gpgsm.c,
data-mem.c, op-support.c, w32-io.c, w32-util.c, data-compat.c: Use
gpg_error_from_syserror instead gpg_error_from_errno, and use
gpg_err_set_errno to set error number.
* setenv.c: Include <gpg-error.h> and define __set_errno to use
gpg_err_set_errno.
* gpgme-tool.c (ARGP_ERR_UNKNOWN): Define to EDEADLOCK (which is
mapped in Windows CE) instead of E2BIG (which is not).
(gt_import_keys): Initialize err.
2010-05-06 13:39:55 +00:00
|
|
|
|
gpg_err_set_errno (save_errno);
|
2011-02-02 12:47:53 +00:00
|
|
|
|
return fd;
|
assuan/
2008-06-25 Marcus Brinkmann <marcus@g10code.de>
* assuan-pipe-connect.c (struct spawn_fd_item_s): Add new members.
(HANDLE_TRANSLATION): New macro.
(pipe_connect_gpgme): Adjust caller of _gpgme_io_spawn.
[HANDLE_TRANSLATION]: Return translated handles.
gpgme/
2008-06-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme-w32spawn.c: New file.
* Makefile.am (libexec_PROGRAMS) [HAVE_W32_SYSTEM]: New variable
with gpgme-w32spawn.
* engine-gpgsm.c (gpgsm_new): Use server translated handles.
(gpgsm_set_locale): Return early if locale value is NULL.
* util.h (_gpgme_mkstemp)
(_gpgme_get_w32spawn_path) [HAVE_W32_SYSTEM]: New function
prototypes.
* w32-util.c: Include <stdint.h>, <sys/stat.h> and <unistd.h>.
(letters, mkstemp, _gpgme_mkstemp, _gpgme_get_w32spawn_path): New
functions.
* rungpg.c (gpg_decrypt, gpg_encrypt, gpg_encrypt_sign)
(gpg_genkey, gpg_import, gpg_verify, gpg_sign): Pass data over
special filename FD rather than stdin.
(struct arg_and_data_s): Add member ARG_LOCP.
(struct fd_data_map_s): Add member ARG_LOC.
(struct engine_gpg): Add member ARG_LOC to status and colon.
(_add_arg, add_arg_with_locp): New function.
(add_arg_ext): Reimplement in terms of _add_arg.
(gpg_new): Remember argument location for status FD.
(build_argv): Set argument location if requested. Also set
argument location of fd_data_map for data items.
(start): Adjust caller of _gpgme_io_spawn.
* priv-io.h (struct spawn_fd_item_s): Add members peer_name and
arg_loc.
(_gpgme_io_spawn): Remove parent fd list argument.
* posix-io.c (get_max_fds): New function.
(_gpgme_io_dup): Add tracing.
(_gpgme_io_spawn): Remove parent fd list. Change meaning of child
fd list to contain all child fds that should be inherited. Close
all other file descriptors after fork.
* w32-io.c, w32-glib-io.c, w32-qt-io.c(_gpgme_io_spawn): Remove
parent fd list. Change meaning of child fd list to contain all
child fds that should be inherited. Do not inherit any file
descriptors, but DuplicateHandle them. Spawn process through
wrapper process. Provide wrapper process with a temporary file
containing handle translation data. Return translated handle
names.
* w32-io.c (reader): Add more tracing output.
(_gpgme_io_read): Likewise.
* engine-gpgconf.c (gpgconf_read): Adjust caller of
_gpgme_io_spawn.
* version.c (_gpgme_get_program_version): Likewise.
2008-06-25 16:52:31 +00:00
|
|
|
|
}
|
2011-02-02 12:47:53 +00:00
|
|
|
|
else if (errno != EEXIST)
|
|
|
|
|
return -1;
|
assuan/
2008-06-25 Marcus Brinkmann <marcus@g10code.de>
* assuan-pipe-connect.c (struct spawn_fd_item_s): Add new members.
(HANDLE_TRANSLATION): New macro.
(pipe_connect_gpgme): Adjust caller of _gpgme_io_spawn.
[HANDLE_TRANSLATION]: Return translated handles.
gpgme/
2008-06-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme-w32spawn.c: New file.
* Makefile.am (libexec_PROGRAMS) [HAVE_W32_SYSTEM]: New variable
with gpgme-w32spawn.
* engine-gpgsm.c (gpgsm_new): Use server translated handles.
(gpgsm_set_locale): Return early if locale value is NULL.
* util.h (_gpgme_mkstemp)
(_gpgme_get_w32spawn_path) [HAVE_W32_SYSTEM]: New function
prototypes.
* w32-util.c: Include <stdint.h>, <sys/stat.h> and <unistd.h>.
(letters, mkstemp, _gpgme_mkstemp, _gpgme_get_w32spawn_path): New
functions.
* rungpg.c (gpg_decrypt, gpg_encrypt, gpg_encrypt_sign)
(gpg_genkey, gpg_import, gpg_verify, gpg_sign): Pass data over
special filename FD rather than stdin.
(struct arg_and_data_s): Add member ARG_LOCP.
(struct fd_data_map_s): Add member ARG_LOC.
(struct engine_gpg): Add member ARG_LOC to status and colon.
(_add_arg, add_arg_with_locp): New function.
(add_arg_ext): Reimplement in terms of _add_arg.
(gpg_new): Remember argument location for status FD.
(build_argv): Set argument location if requested. Also set
argument location of fd_data_map for data items.
(start): Adjust caller of _gpgme_io_spawn.
* priv-io.h (struct spawn_fd_item_s): Add members peer_name and
arg_loc.
(_gpgme_io_spawn): Remove parent fd list argument.
* posix-io.c (get_max_fds): New function.
(_gpgme_io_dup): Add tracing.
(_gpgme_io_spawn): Remove parent fd list. Change meaning of child
fd list to contain all child fds that should be inherited. Close
all other file descriptors after fork.
* w32-io.c, w32-glib-io.c, w32-qt-io.c(_gpgme_io_spawn): Remove
parent fd list. Change meaning of child fd list to contain all
child fds that should be inherited. Do not inherit any file
descriptors, but DuplicateHandle them. Spawn process through
wrapper process. Provide wrapper process with a temporary file
containing handle translation data. Return translated handle
names.
* w32-io.c (reader): Add more tracing output.
(_gpgme_io_read): Likewise.
* engine-gpgconf.c (gpgconf_read): Adjust caller of
_gpgme_io_spawn.
* version.c (_gpgme_get_program_version): Likewise.
2008-06-25 16:52:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* We got out of the loop because we ran out of combinations to try. */
|
2010-05-06 Marcus Brinkmann <marcus@g10code.de>
* configure.ac: Require libgpg-error 1.8.
src/
2010-05-06 Marcus Brinkmann <marcus@g10code.de>
* sign.c, data-user.c, conversion.c, debug.c, verify.c, data.c,
decrypt.c, delete.c, assuan-support.c, import.c, engine-gpgsm.c,
data-mem.c, op-support.c, w32-io.c, w32-util.c, data-compat.c: Use
gpg_error_from_syserror instead gpg_error_from_errno, and use
gpg_err_set_errno to set error number.
* setenv.c: Include <gpg-error.h> and define __set_errno to use
gpg_err_set_errno.
* gpgme-tool.c (ARGP_ERR_UNKNOWN): Define to EDEADLOCK (which is
mapped in Windows CE) instead of E2BIG (which is not).
(gt_import_keys): Initialize err.
2010-05-06 13:39:55 +00:00
|
|
|
|
gpg_err_set_errno (EEXIST);
|
assuan/
2008-06-25 Marcus Brinkmann <marcus@g10code.de>
* assuan-pipe-connect.c (struct spawn_fd_item_s): Add new members.
(HANDLE_TRANSLATION): New macro.
(pipe_connect_gpgme): Adjust caller of _gpgme_io_spawn.
[HANDLE_TRANSLATION]: Return translated handles.
gpgme/
2008-06-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme-w32spawn.c: New file.
* Makefile.am (libexec_PROGRAMS) [HAVE_W32_SYSTEM]: New variable
with gpgme-w32spawn.
* engine-gpgsm.c (gpgsm_new): Use server translated handles.
(gpgsm_set_locale): Return early if locale value is NULL.
* util.h (_gpgme_mkstemp)
(_gpgme_get_w32spawn_path) [HAVE_W32_SYSTEM]: New function
prototypes.
* w32-util.c: Include <stdint.h>, <sys/stat.h> and <unistd.h>.
(letters, mkstemp, _gpgme_mkstemp, _gpgme_get_w32spawn_path): New
functions.
* rungpg.c (gpg_decrypt, gpg_encrypt, gpg_encrypt_sign)
(gpg_genkey, gpg_import, gpg_verify, gpg_sign): Pass data over
special filename FD rather than stdin.
(struct arg_and_data_s): Add member ARG_LOCP.
(struct fd_data_map_s): Add member ARG_LOC.
(struct engine_gpg): Add member ARG_LOC to status and colon.
(_add_arg, add_arg_with_locp): New function.
(add_arg_ext): Reimplement in terms of _add_arg.
(gpg_new): Remember argument location for status FD.
(build_argv): Set argument location if requested. Also set
argument location of fd_data_map for data items.
(start): Adjust caller of _gpgme_io_spawn.
* priv-io.h (struct spawn_fd_item_s): Add members peer_name and
arg_loc.
(_gpgme_io_spawn): Remove parent fd list argument.
* posix-io.c (get_max_fds): New function.
(_gpgme_io_dup): Add tracing.
(_gpgme_io_spawn): Remove parent fd list. Change meaning of child
fd list to contain all child fds that should be inherited. Close
all other file descriptors after fork.
* w32-io.c, w32-glib-io.c, w32-qt-io.c(_gpgme_io_spawn): Remove
parent fd list. Change meaning of child fd list to contain all
child fds that should be inherited. Do not inherit any file
descriptors, but DuplicateHandle them. Spawn process through
wrapper process. Provide wrapper process with a temporary file
containing handle translation data. Return translated handle
names.
* w32-io.c (reader): Add more tracing output.
(_gpgme_io_read): Likewise.
* engine-gpgconf.c (gpgconf_read): Adjust caller of
_gpgme_io_spawn.
* version.c (_gpgme_get_program_version): Likewise.
2008-06-25 16:52:31 +00:00
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
_gpgme_mkstemp (int *fd, char **name)
|
|
|
|
|
{
|
|
|
|
|
char tmp[MAX_PATH + 2];
|
|
|
|
|
char *tmpname;
|
|
|
|
|
int err;
|
|
|
|
|
|
|
|
|
|
*fd = -1;
|
|
|
|
|
*name = NULL;
|
|
|
|
|
|
2010-05-11 17:20:45 +00:00
|
|
|
|
err = GetTempPathA (MAX_PATH + 1, tmp);
|
assuan/
2008-06-25 Marcus Brinkmann <marcus@g10code.de>
* assuan-pipe-connect.c (struct spawn_fd_item_s): Add new members.
(HANDLE_TRANSLATION): New macro.
(pipe_connect_gpgme): Adjust caller of _gpgme_io_spawn.
[HANDLE_TRANSLATION]: Return translated handles.
gpgme/
2008-06-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme-w32spawn.c: New file.
* Makefile.am (libexec_PROGRAMS) [HAVE_W32_SYSTEM]: New variable
with gpgme-w32spawn.
* engine-gpgsm.c (gpgsm_new): Use server translated handles.
(gpgsm_set_locale): Return early if locale value is NULL.
* util.h (_gpgme_mkstemp)
(_gpgme_get_w32spawn_path) [HAVE_W32_SYSTEM]: New function
prototypes.
* w32-util.c: Include <stdint.h>, <sys/stat.h> and <unistd.h>.
(letters, mkstemp, _gpgme_mkstemp, _gpgme_get_w32spawn_path): New
functions.
* rungpg.c (gpg_decrypt, gpg_encrypt, gpg_encrypt_sign)
(gpg_genkey, gpg_import, gpg_verify, gpg_sign): Pass data over
special filename FD rather than stdin.
(struct arg_and_data_s): Add member ARG_LOCP.
(struct fd_data_map_s): Add member ARG_LOC.
(struct engine_gpg): Add member ARG_LOC to status and colon.
(_add_arg, add_arg_with_locp): New function.
(add_arg_ext): Reimplement in terms of _add_arg.
(gpg_new): Remember argument location for status FD.
(build_argv): Set argument location if requested. Also set
argument location of fd_data_map for data items.
(start): Adjust caller of _gpgme_io_spawn.
* priv-io.h (struct spawn_fd_item_s): Add members peer_name and
arg_loc.
(_gpgme_io_spawn): Remove parent fd list argument.
* posix-io.c (get_max_fds): New function.
(_gpgme_io_dup): Add tracing.
(_gpgme_io_spawn): Remove parent fd list. Change meaning of child
fd list to contain all child fds that should be inherited. Close
all other file descriptors after fork.
* w32-io.c, w32-glib-io.c, w32-qt-io.c(_gpgme_io_spawn): Remove
parent fd list. Change meaning of child fd list to contain all
child fds that should be inherited. Do not inherit any file
descriptors, but DuplicateHandle them. Spawn process through
wrapper process. Provide wrapper process with a temporary file
containing handle translation data. Return translated handle
names.
* w32-io.c (reader): Add more tracing output.
(_gpgme_io_read): Likewise.
* engine-gpgconf.c (gpgconf_read): Adjust caller of
_gpgme_io_spawn.
* version.c (_gpgme_get_program_version): Likewise.
2008-06-25 16:52:31 +00:00
|
|
|
|
if (err == 0 || err > MAX_PATH + 1)
|
|
|
|
|
strcpy (tmp,"c:\\windows\\temp");
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
int len = strlen(tmp);
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
assuan/
2008-06-25 Marcus Brinkmann <marcus@g10code.de>
* assuan-pipe-connect.c (struct spawn_fd_item_s): Add new members.
(HANDLE_TRANSLATION): New macro.
(pipe_connect_gpgme): Adjust caller of _gpgme_io_spawn.
[HANDLE_TRANSLATION]: Return translated handles.
gpgme/
2008-06-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme-w32spawn.c: New file.
* Makefile.am (libexec_PROGRAMS) [HAVE_W32_SYSTEM]: New variable
with gpgme-w32spawn.
* engine-gpgsm.c (gpgsm_new): Use server translated handles.
(gpgsm_set_locale): Return early if locale value is NULL.
* util.h (_gpgme_mkstemp)
(_gpgme_get_w32spawn_path) [HAVE_W32_SYSTEM]: New function
prototypes.
* w32-util.c: Include <stdint.h>, <sys/stat.h> and <unistd.h>.
(letters, mkstemp, _gpgme_mkstemp, _gpgme_get_w32spawn_path): New
functions.
* rungpg.c (gpg_decrypt, gpg_encrypt, gpg_encrypt_sign)
(gpg_genkey, gpg_import, gpg_verify, gpg_sign): Pass data over
special filename FD rather than stdin.
(struct arg_and_data_s): Add member ARG_LOCP.
(struct fd_data_map_s): Add member ARG_LOC.
(struct engine_gpg): Add member ARG_LOC to status and colon.
(_add_arg, add_arg_with_locp): New function.
(add_arg_ext): Reimplement in terms of _add_arg.
(gpg_new): Remember argument location for status FD.
(build_argv): Set argument location if requested. Also set
argument location of fd_data_map for data items.
(start): Adjust caller of _gpgme_io_spawn.
* priv-io.h (struct spawn_fd_item_s): Add members peer_name and
arg_loc.
(_gpgme_io_spawn): Remove parent fd list argument.
* posix-io.c (get_max_fds): New function.
(_gpgme_io_dup): Add tracing.
(_gpgme_io_spawn): Remove parent fd list. Change meaning of child
fd list to contain all child fds that should be inherited. Close
all other file descriptors after fork.
* w32-io.c, w32-glib-io.c, w32-qt-io.c(_gpgme_io_spawn): Remove
parent fd list. Change meaning of child fd list to contain all
child fds that should be inherited. Do not inherit any file
descriptors, but DuplicateHandle them. Spawn process through
wrapper process. Provide wrapper process with a temporary file
containing handle translation data. Return translated handle
names.
* w32-io.c (reader): Add more tracing output.
(_gpgme_io_read): Likewise.
* engine-gpgconf.c (gpgconf_read): Adjust caller of
_gpgme_io_spawn.
* version.c (_gpgme_get_program_version): Likewise.
2008-06-25 16:52:31 +00:00
|
|
|
|
/* GetTempPath may return with \ on the end */
|
|
|
|
|
while(len > 0 && tmp[len - 1] == '\\')
|
|
|
|
|
{
|
|
|
|
|
tmp[len-1] = '\0';
|
|
|
|
|
len--;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-22 10:41:55 +00:00
|
|
|
|
tmpname = _gpgme_strconcat (tmp, "\\gpgme-XXXXXX", NULL);
|
assuan/
2008-06-25 Marcus Brinkmann <marcus@g10code.de>
* assuan-pipe-connect.c (struct spawn_fd_item_s): Add new members.
(HANDLE_TRANSLATION): New macro.
(pipe_connect_gpgme): Adjust caller of _gpgme_io_spawn.
[HANDLE_TRANSLATION]: Return translated handles.
gpgme/
2008-06-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme-w32spawn.c: New file.
* Makefile.am (libexec_PROGRAMS) [HAVE_W32_SYSTEM]: New variable
with gpgme-w32spawn.
* engine-gpgsm.c (gpgsm_new): Use server translated handles.
(gpgsm_set_locale): Return early if locale value is NULL.
* util.h (_gpgme_mkstemp)
(_gpgme_get_w32spawn_path) [HAVE_W32_SYSTEM]: New function
prototypes.
* w32-util.c: Include <stdint.h>, <sys/stat.h> and <unistd.h>.
(letters, mkstemp, _gpgme_mkstemp, _gpgme_get_w32spawn_path): New
functions.
* rungpg.c (gpg_decrypt, gpg_encrypt, gpg_encrypt_sign)
(gpg_genkey, gpg_import, gpg_verify, gpg_sign): Pass data over
special filename FD rather than stdin.
(struct arg_and_data_s): Add member ARG_LOCP.
(struct fd_data_map_s): Add member ARG_LOC.
(struct engine_gpg): Add member ARG_LOC to status and colon.
(_add_arg, add_arg_with_locp): New function.
(add_arg_ext): Reimplement in terms of _add_arg.
(gpg_new): Remember argument location for status FD.
(build_argv): Set argument location if requested. Also set
argument location of fd_data_map for data items.
(start): Adjust caller of _gpgme_io_spawn.
* priv-io.h (struct spawn_fd_item_s): Add members peer_name and
arg_loc.
(_gpgme_io_spawn): Remove parent fd list argument.
* posix-io.c (get_max_fds): New function.
(_gpgme_io_dup): Add tracing.
(_gpgme_io_spawn): Remove parent fd list. Change meaning of child
fd list to contain all child fds that should be inherited. Close
all other file descriptors after fork.
* w32-io.c, w32-glib-io.c, w32-qt-io.c(_gpgme_io_spawn): Remove
parent fd list. Change meaning of child fd list to contain all
child fds that should be inherited. Do not inherit any file
descriptors, but DuplicateHandle them. Spawn process through
wrapper process. Provide wrapper process with a temporary file
containing handle translation data. Return translated handle
names.
* w32-io.c (reader): Add more tracing output.
(_gpgme_io_read): Likewise.
* engine-gpgconf.c (gpgconf_read): Adjust caller of
_gpgme_io_spawn.
* version.c (_gpgme_get_program_version): Likewise.
2008-06-25 16:52:31 +00:00
|
|
|
|
if (!tmpname)
|
|
|
|
|
return -1;
|
2015-12-09 10:39:26 +00:00
|
|
|
|
*fd = my_mkstemp (tmpname);
|
2016-09-22 10:46:06 +00:00
|
|
|
|
if (*fd < 0)
|
2014-04-15 14:40:48 +00:00
|
|
|
|
{
|
|
|
|
|
free (tmpname);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
assuan/
2008-06-25 Marcus Brinkmann <marcus@g10code.de>
* assuan-pipe-connect.c (struct spawn_fd_item_s): Add new members.
(HANDLE_TRANSLATION): New macro.
(pipe_connect_gpgme): Adjust caller of _gpgme_io_spawn.
[HANDLE_TRANSLATION]: Return translated handles.
gpgme/
2008-06-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme-w32spawn.c: New file.
* Makefile.am (libexec_PROGRAMS) [HAVE_W32_SYSTEM]: New variable
with gpgme-w32spawn.
* engine-gpgsm.c (gpgsm_new): Use server translated handles.
(gpgsm_set_locale): Return early if locale value is NULL.
* util.h (_gpgme_mkstemp)
(_gpgme_get_w32spawn_path) [HAVE_W32_SYSTEM]: New function
prototypes.
* w32-util.c: Include <stdint.h>, <sys/stat.h> and <unistd.h>.
(letters, mkstemp, _gpgme_mkstemp, _gpgme_get_w32spawn_path): New
functions.
* rungpg.c (gpg_decrypt, gpg_encrypt, gpg_encrypt_sign)
(gpg_genkey, gpg_import, gpg_verify, gpg_sign): Pass data over
special filename FD rather than stdin.
(struct arg_and_data_s): Add member ARG_LOCP.
(struct fd_data_map_s): Add member ARG_LOC.
(struct engine_gpg): Add member ARG_LOC to status and colon.
(_add_arg, add_arg_with_locp): New function.
(add_arg_ext): Reimplement in terms of _add_arg.
(gpg_new): Remember argument location for status FD.
(build_argv): Set argument location if requested. Also set
argument location of fd_data_map for data items.
(start): Adjust caller of _gpgme_io_spawn.
* priv-io.h (struct spawn_fd_item_s): Add members peer_name and
arg_loc.
(_gpgme_io_spawn): Remove parent fd list argument.
* posix-io.c (get_max_fds): New function.
(_gpgme_io_dup): Add tracing.
(_gpgme_io_spawn): Remove parent fd list. Change meaning of child
fd list to contain all child fds that should be inherited. Close
all other file descriptors after fork.
* w32-io.c, w32-glib-io.c, w32-qt-io.c(_gpgme_io_spawn): Remove
parent fd list. Change meaning of child fd list to contain all
child fds that should be inherited. Do not inherit any file
descriptors, but DuplicateHandle them. Spawn process through
wrapper process. Provide wrapper process with a temporary file
containing handle translation data. Return translated handle
names.
* w32-io.c (reader): Add more tracing output.
(_gpgme_io_read): Likewise.
* engine-gpgconf.c (gpgconf_read): Adjust caller of
_gpgme_io_spawn.
* version.c (_gpgme_get_program_version): Likewise.
2008-06-25 16:52:31 +00:00
|
|
|
|
|
|
|
|
|
*name = tmpname;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2010-10-07 10:58:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-08-02 10:48:30 +00:00
|
|
|
|
/* Entry point called by the DLL loader. */
|
|
|
|
|
#ifdef DLL_EXPORT
|
|
|
|
|
int WINAPI
|
|
|
|
|
DllMain (HINSTANCE hinst, DWORD reason, LPVOID reserved)
|
|
|
|
|
{
|
|
|
|
|
(void)reserved;
|
|
|
|
|
|
|
|
|
|
if (reason == DLL_PROCESS_ATTACH)
|
|
|
|
|
my_hmodule = hinst;
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
#endif /*DLL_EXPORT*/
|