2003-01-29 20:03:24 +00:00
|
|
|
|
/* w32-io.c - W32 API I/O functions.
|
|
|
|
|
Copyright (C) 2000 Werner Koch (dd9jn)
|
2010-04-16 14:08:41 +00:00
|
|
|
|
Copyright (C) 2001, 2002, 2003, 2004, 2007, 2010 g10 Code GmbH
|
2003-01-29 20:03:24 +00:00
|
|
|
|
|
|
|
|
|
This file is part of GPGME.
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2003-01-29 20:03:24 +00:00
|
|
|
|
GPGME is free software; you can redistribute it and/or modify it
|
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* README: Refer to COPYING.LESSER and "each file" instead of
COPYING.
* COPYING.LESSER: New file.
* gpgme.spec.in (%doc): Add COPYING.LESSER.
* acinclude.m4, configure.ac, Makefile.am: Change license to LGPL
2.1 or later.
* TODO: Add copyright notice.
* README.CVS: Likewise.
assuan/
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* README.1st: Add copyright notice.
doc/
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* Makefile.am: Change license to LGPL.
(gpgme_TEXINFOS): Replace gpl.texi with lesser.texi.
* gpgme.texi: Change license to LGPL (also for documentation of
GPGME's license).
* lesser.texi: New file.
* gpl.texi: File removed.
gpgme/
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* putc_unlocked.c, funopen.c: I just claim copyright on these
files and change their license to LGPL, because they are totally
trivial wrapper functions.
* isascii.c: Change copyright notice to the one from ctype/ctype.h
in the GNU C Library (CVS Head 2004-10-10), where isascii is
defined as a macro doing exactly the same as the function in this
file.
* memrchr.c: Update from the GNU C Library (CVS Head 2001-07-06).
* stpcpy.c: Update from the GNU C Library (CVS Head 2004-10-10).
* ath.c, ath-compat.c, ath.h, ath-pth.c, ath-pth-compat.c,
ath-pthread.c, ath-pthread-compat.c, context.h, conversion.c,
data.c, data-compat.c, data-fd.c, data.h, data-mem.c,
data-stream.c, data-user.c, debug.c, debug.h, decrypt.c,
decrypt-verify.c, delete.c, edit.c, encrypt.c, encrypt-sign.c,
engine-backend.h, engine.c, engine-gpgsm.c, engine.h, error.c,
export.c, genkey.c, get-env.c, gpgme.c, gpgme.h, import.c, io.h,
key.c, keylist.c, mkstatus, Makefile.am, ops.h, op-support.c,
passphrase.c, posix-io.c, posix-sema.c, posix-util.c, progress.c,
rungpg.c, sema.h, sign.c, signers.c, trust-item.c, trustlist.c,
util.h, verify.c, version.c, w32-io.c, w32-sema.c, w32-util.c,
wait.c, wait-global.c, wait.h, wait-private.c, wait-user.c: Change
license to LGPL.
tests/
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* gpg/mkdemodirs: Add copyright notice.
* gpgsm/Makefile.am, gpgsm/t-support.h, gpgsm/t-decrypt.c,
gpgsm/t-encrypt.c, gpgsm/t-export.c, gpgsm/t-genkey.c,
gpgsm/t-import.c, gpgsm/t-keylist.c, gpgsm/t-sign.c,
gpgsm/t-verify.c, gpg/Makefile.am, gpg/t-decrypt.c,
gpg/t-decrypt-verify.c, gpg/t-edit.c, gpg/t-encrypt.c,
gpg/t-encrypt-sign.c, gpg/t-encrypt-sym.c, gpg/t-eventloop.c,
gpg/t-export.c, gpg/t-genkey.c, gpg/t-import.c, gpg/t-keylist.c,
gpg/t-keylist-sig.c, gpg/t-sign.c, gpg/t-signers.c,
gpg/t-support.h, gpg/t-thread1.c, gpg/t-trustlist.c,
gpg/t-verify.c, Makefile.am, t-data.c, t-engine-info.c,
t-version.c: Change license to LGPL.
2004-12-07 21:13:39 +00:00
|
|
|
|
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.
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2003-01-29 20:03:24 +00:00
|
|
|
|
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
|
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* README: Refer to COPYING.LESSER and "each file" instead of
COPYING.
* COPYING.LESSER: New file.
* gpgme.spec.in (%doc): Add COPYING.LESSER.
* acinclude.m4, configure.ac, Makefile.am: Change license to LGPL
2.1 or later.
* TODO: Add copyright notice.
* README.CVS: Likewise.
assuan/
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* README.1st: Add copyright notice.
doc/
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* Makefile.am: Change license to LGPL.
(gpgme_TEXINFOS): Replace gpl.texi with lesser.texi.
* gpgme.texi: Change license to LGPL (also for documentation of
GPGME's license).
* lesser.texi: New file.
* gpl.texi: File removed.
gpgme/
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* putc_unlocked.c, funopen.c: I just claim copyright on these
files and change their license to LGPL, because they are totally
trivial wrapper functions.
* isascii.c: Change copyright notice to the one from ctype/ctype.h
in the GNU C Library (CVS Head 2004-10-10), where isascii is
defined as a macro doing exactly the same as the function in this
file.
* memrchr.c: Update from the GNU C Library (CVS Head 2001-07-06).
* stpcpy.c: Update from the GNU C Library (CVS Head 2004-10-10).
* ath.c, ath-compat.c, ath.h, ath-pth.c, ath-pth-compat.c,
ath-pthread.c, ath-pthread-compat.c, context.h, conversion.c,
data.c, data-compat.c, data-fd.c, data.h, data-mem.c,
data-stream.c, data-user.c, debug.c, debug.h, decrypt.c,
decrypt-verify.c, delete.c, edit.c, encrypt.c, encrypt-sign.c,
engine-backend.h, engine.c, engine-gpgsm.c, engine.h, error.c,
export.c, genkey.c, get-env.c, gpgme.c, gpgme.h, import.c, io.h,
key.c, keylist.c, mkstatus, Makefile.am, ops.h, op-support.c,
passphrase.c, posix-io.c, posix-sema.c, posix-util.c, progress.c,
rungpg.c, sema.h, sign.c, signers.c, trust-item.c, trustlist.c,
util.h, verify.c, version.c, w32-io.c, w32-sema.c, w32-util.c,
wait.c, wait-global.c, wait.h, wait-private.c, wait-user.c: Change
license to LGPL.
tests/
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* gpg/mkdemodirs: Add copyright notice.
* gpgsm/Makefile.am, gpgsm/t-support.h, gpgsm/t-decrypt.c,
gpgsm/t-encrypt.c, gpgsm/t-export.c, gpgsm/t-genkey.c,
gpgsm/t-import.c, gpgsm/t-keylist.c, gpgsm/t-sign.c,
gpgsm/t-verify.c, gpg/Makefile.am, gpg/t-decrypt.c,
gpg/t-decrypt-verify.c, gpg/t-edit.c, gpg/t-encrypt.c,
gpg/t-encrypt-sign.c, gpg/t-encrypt-sym.c, gpg/t-eventloop.c,
gpg/t-export.c, gpg/t-genkey.c, gpg/t-import.c, gpg/t-keylist.c,
gpg/t-keylist-sig.c, gpg/t-sign.c, gpg/t-signers.c,
gpg/t-support.h, gpg/t-thread1.c, gpg/t-trustlist.c,
gpg/t-verify.c, Makefile.am, t-data.c, t-engine-info.c,
t-version.c: Change license to LGPL.
2004-12-07 21:13:39 +00:00
|
|
|
|
Lesser General Public License for more details.
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* README: Refer to COPYING.LESSER and "each file" instead of
COPYING.
* COPYING.LESSER: New file.
* gpgme.spec.in (%doc): Add COPYING.LESSER.
* acinclude.m4, configure.ac, Makefile.am: Change license to LGPL
2.1 or later.
* TODO: Add copyright notice.
* README.CVS: Likewise.
assuan/
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* README.1st: Add copyright notice.
doc/
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* Makefile.am: Change license to LGPL.
(gpgme_TEXINFOS): Replace gpl.texi with lesser.texi.
* gpgme.texi: Change license to LGPL (also for documentation of
GPGME's license).
* lesser.texi: New file.
* gpl.texi: File removed.
gpgme/
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* putc_unlocked.c, funopen.c: I just claim copyright on these
files and change their license to LGPL, because they are totally
trivial wrapper functions.
* isascii.c: Change copyright notice to the one from ctype/ctype.h
in the GNU C Library (CVS Head 2004-10-10), where isascii is
defined as a macro doing exactly the same as the function in this
file.
* memrchr.c: Update from the GNU C Library (CVS Head 2001-07-06).
* stpcpy.c: Update from the GNU C Library (CVS Head 2004-10-10).
* ath.c, ath-compat.c, ath.h, ath-pth.c, ath-pth-compat.c,
ath-pthread.c, ath-pthread-compat.c, context.h, conversion.c,
data.c, data-compat.c, data-fd.c, data.h, data-mem.c,
data-stream.c, data-user.c, debug.c, debug.h, decrypt.c,
decrypt-verify.c, delete.c, edit.c, encrypt.c, encrypt-sign.c,
engine-backend.h, engine.c, engine-gpgsm.c, engine.h, error.c,
export.c, genkey.c, get-env.c, gpgme.c, gpgme.h, import.c, io.h,
key.c, keylist.c, mkstatus, Makefile.am, ops.h, op-support.c,
passphrase.c, posix-io.c, posix-sema.c, posix-util.c, progress.c,
rungpg.c, sema.h, sign.c, signers.c, trust-item.c, trustlist.c,
util.h, verify.c, version.c, w32-io.c, w32-sema.c, w32-util.c,
wait.c, wait-global.c, wait.h, wait-private.c, wait-user.c: Change
license to LGPL.
tests/
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* gpg/mkdemodirs: Add copyright notice.
* gpgsm/Makefile.am, gpgsm/t-support.h, gpgsm/t-decrypt.c,
gpgsm/t-encrypt.c, gpgsm/t-export.c, gpgsm/t-genkey.c,
gpgsm/t-import.c, gpgsm/t-keylist.c, gpgsm/t-sign.c,
gpgsm/t-verify.c, gpg/Makefile.am, gpg/t-decrypt.c,
gpg/t-decrypt-verify.c, gpg/t-edit.c, gpg/t-encrypt.c,
gpg/t-encrypt-sign.c, gpg/t-encrypt-sym.c, gpg/t-eventloop.c,
gpg/t-export.c, gpg/t-genkey.c, gpg/t-import.c, gpg/t-keylist.c,
gpg/t-keylist-sig.c, gpg/t-sign.c, gpg/t-signers.c,
gpg/t-support.h, gpg/t-thread1.c, gpg/t-trustlist.c,
gpg/t-verify.c, Makefile.am, t-data.c, t-engine-info.c,
t-version.c: Change license to LGPL.
2004-12-07 21:13:39 +00:00
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
License along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
|
02111-1307, USA. */
|
2000-11-22 17:10:48 +00:00
|
|
|
|
|
2002-03-18 00:04:06 +00:00
|
|
|
|
#ifdef HAVE_CONFIG_H
|
2000-11-22 17:10:48 +00:00
|
|
|
|
#include <config.h>
|
2002-03-18 00:04:06 +00:00
|
|
|
|
#endif
|
2000-11-22 17:10:48 +00:00
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
#include <fcntl.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
|
2002-03-18 00:04:06 +00:00
|
|
|
|
#include <io.h>
|
2000-11-22 17:10:48 +00:00
|
|
|
|
|
2010-11-02 16:27:46 +00:00
|
|
|
|
#include "util.h"
|
|
|
|
|
|
2010-06-09 13:33:31 +00:00
|
|
|
|
#ifdef HAVE_W32CE_SYSTEM
|
|
|
|
|
#include <assuan.h>
|
|
|
|
|
#include <winioctl.h>
|
|
|
|
|
#define GPGCEDEV_IOCTL_UNBLOCK \
|
|
|
|
|
CTL_CODE (FILE_DEVICE_STREAMS, 2050, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
2010-08-03 09:01:24 +00:00
|
|
|
|
#define GPGCEDEV_IOCTL_ASSIGN_RVID \
|
|
|
|
|
CTL_CODE (FILE_DEVICE_STREAMS, 2051, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
2010-06-09 13:33:31 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2001-01-30 11:01:41 +00:00
|
|
|
|
#include "sema.h"
|
2005-03-24 13:05:12 +00:00
|
|
|
|
#include "priv-io.h"
|
2005-03-09 11:47:21 +00:00
|
|
|
|
#include "debug.h"
|
2016-08-18 14:56:58 +00:00
|
|
|
|
#include "sys-util.h"
|
2000-11-23 15:28:15 +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
|
|
|
|
|
2010-06-10 13:49:19 +00:00
|
|
|
|
/* FIXME: Optimize. */
|
|
|
|
|
#define MAX_SLAFD 512
|
|
|
|
|
|
|
|
|
|
static struct
|
|
|
|
|
{
|
|
|
|
|
int used;
|
|
|
|
|
|
|
|
|
|
/* If this is not INVALID_HANDLE_VALUE, then it's a handle. */
|
|
|
|
|
HANDLE handle;
|
|
|
|
|
|
|
|
|
|
/* If this is not INVALID_SOCKET, then it's a Windows socket. */
|
|
|
|
|
int socket;
|
|
|
|
|
|
|
|
|
|
/* If this is not 0, then it's a rendezvous ID for the pipe server. */
|
|
|
|
|
int rvid;
|
|
|
|
|
|
|
|
|
|
/* DUP_FROM is -1 if this file descriptor was allocated by pipe or
|
|
|
|
|
socket functions. Only then should the handle or socket be
|
|
|
|
|
destroyed when this FD is closed. This, together with the fact
|
|
|
|
|
that dup'ed file descriptors are closed before the file
|
|
|
|
|
descriptors from which they are dup'ed are closed, ensures that
|
|
|
|
|
the handle or socket is always valid, and shared among all file
|
2015-12-02 10:28:07 +00:00
|
|
|
|
descriptors referring to the same underlying object.
|
2010-06-10 13:49:19 +00:00
|
|
|
|
|
|
|
|
|
The logic behind this is that there is only one reason for us to
|
|
|
|
|
dup file descriptors anyway: to allow simpler book-keeping of
|
|
|
|
|
file descriptors shared between GPGME and libassuan, which both
|
|
|
|
|
want to close something. Using the same handle for these
|
|
|
|
|
duplicates works just fine. */
|
|
|
|
|
int dup_from;
|
2012-09-25 13:29:49 +00:00
|
|
|
|
} fd_table[MAX_SLAFD];
|
2016-11-09 07:33:02 +00:00
|
|
|
|
DEFINE_STATIC_LOCK (fd_table_lock);
|
2010-06-10 13:49:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Returns the FD or -1 on resource limit. */
|
|
|
|
|
int
|
|
|
|
|
new_fd (void)
|
|
|
|
|
{
|
|
|
|
|
int idx;
|
|
|
|
|
|
2016-11-09 07:33:02 +00:00
|
|
|
|
LOCK (fd_table_lock);
|
|
|
|
|
|
2010-06-10 13:49:19 +00:00
|
|
|
|
for (idx = 0; idx < MAX_SLAFD; idx++)
|
|
|
|
|
if (! fd_table[idx].used)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
if (idx == MAX_SLAFD)
|
|
|
|
|
{
|
|
|
|
|
gpg_err_set_errno (EIO);
|
2016-11-09 07:33:02 +00:00
|
|
|
|
idx = -1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
fd_table[idx].used = 1;
|
|
|
|
|
fd_table[idx].handle = INVALID_HANDLE_VALUE;
|
|
|
|
|
fd_table[idx].socket = INVALID_SOCKET;
|
|
|
|
|
fd_table[idx].rvid = 0;
|
|
|
|
|
fd_table[idx].dup_from = -1;
|
2010-06-10 13:49:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-09 07:33:02 +00:00
|
|
|
|
UNLOCK (fd_table_lock);
|
2010-06-10 13:49:19 +00:00
|
|
|
|
|
|
|
|
|
return idx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
release_fd (int fd)
|
|
|
|
|
{
|
2016-11-09 07:33:02 +00:00
|
|
|
|
if (fd < 0 || fd >= MAX_SLAFD)
|
2010-06-10 13:49:19 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2016-11-09 07:33:02 +00:00
|
|
|
|
LOCK (fd_table_lock);
|
|
|
|
|
|
|
|
|
|
if (fd_table[fd].used)
|
|
|
|
|
{
|
|
|
|
|
fd_table[fd].used = 0;
|
|
|
|
|
fd_table[fd].handle = INVALID_HANDLE_VALUE;
|
|
|
|
|
fd_table[fd].socket = INVALID_SOCKET;
|
|
|
|
|
fd_table[fd].rvid = 0;
|
|
|
|
|
fd_table[fd].dup_from = -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UNLOCK (fd_table_lock);
|
2010-06-10 13:49:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-11-22 17:10:48 +00:00
|
|
|
|
|
2010-11-02 16:27:46 +00:00
|
|
|
|
#define handle_to_fd(a) ((int)(a))
|
2000-11-22 17:10:48 +00:00
|
|
|
|
|
2001-01-30 11:01:41 +00:00
|
|
|
|
#define READBUF_SIZE 4096
|
2001-02-28 10:18:38 +00:00
|
|
|
|
#define WRITEBUF_SIZE 4096
|
2005-09-23 13:29:04 +00:00
|
|
|
|
#define PIPEBUF_SIZE 4096
|
2010-06-10 13:49:19 +00:00
|
|
|
|
#define MAX_READERS 64
|
|
|
|
|
#define MAX_WRITERS 64
|
2001-01-30 11:01:41 +00:00
|
|
|
|
|
2007-07-13 00:43:17 +00:00
|
|
|
|
static struct
|
|
|
|
|
{
|
|
|
|
|
int inuse;
|
|
|
|
|
int fd;
|
|
|
|
|
_gpgme_close_notify_handler_t handler;
|
|
|
|
|
void *value;
|
2010-06-10 13:49:19 +00:00
|
|
|
|
} notify_table[MAX_SLAFD];
|
2001-02-20 13:31:56 +00:00
|
|
|
|
DEFINE_STATIC_LOCK (notify_table_lock);
|
|
|
|
|
|
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
struct reader_context_s
|
|
|
|
|
{
|
|
|
|
|
HANDLE file_hd;
|
2010-06-10 13:49:19 +00:00
|
|
|
|
int file_sock;
|
2012-09-25 13:29:49 +00:00
|
|
|
|
HANDLE thread_hd;
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
int refcount;
|
2001-02-20 13:31:56 +00:00
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
DECLARE_LOCK (mutex);
|
2001-01-30 11:01:41 +00:00
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
int stop_me;
|
|
|
|
|
int eof;
|
|
|
|
|
int eof_shortcut;
|
|
|
|
|
int error;
|
|
|
|
|
int error_code;
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
/* This is manually reset. */
|
|
|
|
|
HANDLE have_data_ev;
|
|
|
|
|
/* This is automatically reset. */
|
|
|
|
|
HANDLE have_space_ev;
|
2013-04-25 11:00:16 +00:00
|
|
|
|
/* This is manually reset but actually only triggered once. */
|
|
|
|
|
HANDLE close_ev;
|
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
size_t readpos, writepos;
|
|
|
|
|
char buffer[READBUF_SIZE];
|
2001-01-30 11:01:41 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
static struct
|
|
|
|
|
{
|
|
|
|
|
volatile int used;
|
|
|
|
|
int fd;
|
|
|
|
|
struct reader_context_s *context;
|
2001-01-30 11:01:41 +00:00
|
|
|
|
} reader_table[MAX_READERS];
|
|
|
|
|
static int reader_table_size= MAX_READERS;
|
|
|
|
|
DEFINE_STATIC_LOCK (reader_table_lock);
|
|
|
|
|
|
2001-02-28 10:18:38 +00:00
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
struct writer_context_s
|
|
|
|
|
{
|
|
|
|
|
HANDLE file_hd;
|
2010-06-10 13:49:19 +00:00
|
|
|
|
int file_sock;
|
2012-09-25 13:29:49 +00:00
|
|
|
|
HANDLE thread_hd;
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
int refcount;
|
2001-02-28 10:18:38 +00:00
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
DECLARE_LOCK (mutex);
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
int stop_me;
|
|
|
|
|
int error;
|
|
|
|
|
int error_code;
|
|
|
|
|
|
|
|
|
|
/* This is manually reset. */
|
|
|
|
|
HANDLE have_data;
|
|
|
|
|
HANDLE is_empty;
|
2013-04-25 11:00:16 +00:00
|
|
|
|
HANDLE close_ev;
|
2012-09-25 13:29:49 +00:00
|
|
|
|
size_t nbytes;
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
char buffer[WRITEBUF_SIZE];
|
2001-02-28 10:18:38 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
static struct
|
|
|
|
|
{
|
|
|
|
|
volatile int used;
|
|
|
|
|
int fd;
|
|
|
|
|
struct writer_context_s *context;
|
2001-02-28 10:18:38 +00:00
|
|
|
|
} writer_table[MAX_WRITERS];
|
|
|
|
|
static int writer_table_size= MAX_WRITERS;
|
|
|
|
|
DEFINE_STATIC_LOCK (writer_table_lock);
|
|
|
|
|
|
|
|
|
|
|
2006-01-26 10:23:15 +00:00
|
|
|
|
static int
|
|
|
|
|
get_desired_thread_priority (void)
|
|
|
|
|
{
|
|
|
|
|
int value;
|
|
|
|
|
|
|
|
|
|
if (!_gpgme_get_conf_int ("IOThreadPriority", &value))
|
|
|
|
|
{
|
|
|
|
|
value = THREAD_PRIORITY_HIGHEST;
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
TRACE1 (DEBUG_SYSIO, "gpgme:get_desired_thread_priority", 0,
|
|
|
|
|
"%d (default)", value);
|
2006-01-26 10:23:15 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
{
|
|
|
|
|
TRACE1 (DEBUG_SYSIO, "gpgme:get_desired_thread_priority", 0,
|
|
|
|
|
"%d (configured)", value);
|
|
|
|
|
}
|
2006-01-26 10:23:15 +00:00
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-01-30 11:01:41 +00:00
|
|
|
|
static HANDLE
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
set_synchronize (HANDLE hd)
|
2001-01-30 11:01:41 +00:00
|
|
|
|
{
|
2010-06-09 13:33:31 +00:00
|
|
|
|
#ifdef HAVE_W32CE_SYSTEM
|
|
|
|
|
return hd;
|
|
|
|
|
#else
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
HANDLE new_hd;
|
|
|
|
|
|
|
|
|
|
/* For NT we have to set the sync flag. It seems that the only way
|
|
|
|
|
to do it is by duplicating the handle. Tsss... */
|
|
|
|
|
if (!DuplicateHandle (GetCurrentProcess (), hd,
|
|
|
|
|
GetCurrentProcess (), &new_hd,
|
|
|
|
|
EVENT_MODIFY_STATE | SYNCHRONIZE, FALSE, 0))
|
|
|
|
|
{
|
|
|
|
|
TRACE1 (DEBUG_SYSIO, "gpgme:set_synchronize", hd,
|
|
|
|
|
"DuplicateHandle failed: ec=%d", (int) GetLastError ());
|
|
|
|
|
/* FIXME: Should translate the error code. */
|
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 (EIO);
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
return INVALID_HANDLE_VALUE;
|
2001-01-30 11:01:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
CloseHandle (hd);
|
|
|
|
|
return new_hd;
|
2010-06-09 13:33:31 +00:00
|
|
|
|
#endif
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
}
|
2001-01-30 11:01:41 +00:00
|
|
|
|
|
|
|
|
|
|
2012-09-25 13:29:49 +00:00
|
|
|
|
static DWORD CALLBACK
|
2001-01-30 11:01:41 +00:00
|
|
|
|
reader (void *arg)
|
|
|
|
|
{
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
struct reader_context_s *ctx = arg;
|
|
|
|
|
int nbytes;
|
|
|
|
|
DWORD nread;
|
2010-04-16 14:08:41 +00:00
|
|
|
|
int sock;
|
2013-05-06 18:23:47 +00:00
|
|
|
|
TRACE_BEG2 (DEBUG_SYSIO, "gpgme:reader", ctx->file_hd,
|
|
|
|
|
"file_sock=%d, thread=%p", ctx->file_sock, ctx->thread_hd);
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
|
2010-06-10 13:49:19 +00:00
|
|
|
|
if (ctx->file_hd != INVALID_HANDLE_VALUE)
|
|
|
|
|
sock = 0;
|
|
|
|
|
else
|
|
|
|
|
sock = 1;
|
2010-04-16 14:08:41 +00:00
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
for (;;)
|
|
|
|
|
{
|
|
|
|
|
LOCK (ctx->mutex);
|
|
|
|
|
/* Leave a 1 byte gap so that we can see whether it is empty or
|
|
|
|
|
full. */
|
|
|
|
|
if ((ctx->writepos + 1) % READBUF_SIZE == ctx->readpos)
|
2012-09-25 13:29:49 +00:00
|
|
|
|
{
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
/* Wait for space. */
|
|
|
|
|
if (!ResetEvent (ctx->have_space_ev))
|
|
|
|
|
TRACE_LOG1 ("ResetEvent failed: ec=%d", (int) GetLastError ());
|
|
|
|
|
UNLOCK (ctx->mutex);
|
|
|
|
|
TRACE_LOG ("waiting for space");
|
|
|
|
|
WaitForSingleObject (ctx->have_space_ev, INFINITE);
|
|
|
|
|
TRACE_LOG ("got space");
|
|
|
|
|
LOCK (ctx->mutex);
|
2001-01-30 11:01:41 +00:00
|
|
|
|
}
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
if (ctx->stop_me)
|
|
|
|
|
{
|
|
|
|
|
UNLOCK (ctx->mutex);
|
|
|
|
|
break;
|
2001-02-20 13:31:56 +00:00
|
|
|
|
}
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
nbytes = (ctx->readpos + READBUF_SIZE
|
|
|
|
|
- ctx->writepos - 1) % READBUF_SIZE;
|
|
|
|
|
if (nbytes > READBUF_SIZE - ctx->writepos)
|
|
|
|
|
nbytes = READBUF_SIZE - ctx->writepos;
|
|
|
|
|
UNLOCK (ctx->mutex);
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2010-04-16 14:08:41 +00:00
|
|
|
|
TRACE_LOG2 ("%s %d bytes", sock? "receiving":"reading", nbytes);
|
2010-01-25 16:04:27 +00:00
|
|
|
|
|
2010-06-10 13:49:19 +00:00
|
|
|
|
if (sock)
|
2010-01-25 16:04:27 +00:00
|
|
|
|
{
|
|
|
|
|
int n;
|
|
|
|
|
|
2010-06-10 13:49:19 +00:00
|
|
|
|
n = recv (ctx->file_sock, ctx->buffer + ctx->writepos, nbytes, 0);
|
2010-04-16 14:08:41 +00:00
|
|
|
|
if (n < 0)
|
2010-01-25 16:04:27 +00:00
|
|
|
|
{
|
|
|
|
|
ctx->error_code = (int) WSAGetLastError ();
|
|
|
|
|
if (ctx->error_code == ERROR_BROKEN_PIPE)
|
|
|
|
|
{
|
|
|
|
|
ctx->eof = 1;
|
|
|
|
|
TRACE_LOG ("got EOF (broken connection)");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2013-04-25 11:00:16 +00:00
|
|
|
|
/* Check whether the shutdown triggered the error -
|
|
|
|
|
no need to to print a warning in this case. */
|
|
|
|
|
if ( ctx->error_code == WSAECONNABORTED
|
|
|
|
|
|| ctx->error_code == WSAECONNRESET)
|
|
|
|
|
{
|
|
|
|
|
LOCK (ctx->mutex);
|
|
|
|
|
if (ctx->stop_me)
|
|
|
|
|
{
|
|
|
|
|
UNLOCK (ctx->mutex);
|
|
|
|
|
TRACE_LOG ("got shutdown");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
UNLOCK (ctx->mutex);
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-25 16:04:27 +00:00
|
|
|
|
ctx->error = 1;
|
|
|
|
|
TRACE_LOG1 ("recv error: ec=%d", ctx->error_code);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2001-01-31 12:39:53 +00:00
|
|
|
|
}
|
2010-04-16 14:08:41 +00:00
|
|
|
|
nread = n;
|
2010-01-25 16:04:27 +00:00
|
|
|
|
}
|
2010-04-16 14:08:41 +00:00
|
|
|
|
else
|
2010-01-25 16:04:27 +00:00
|
|
|
|
{
|
|
|
|
|
if (!ReadFile (ctx->file_hd,
|
|
|
|
|
ctx->buffer + ctx->writepos, nbytes, &nread, NULL))
|
|
|
|
|
{
|
|
|
|
|
ctx->error_code = (int) GetLastError ();
|
2010-06-09 13:33:31 +00:00
|
|
|
|
/* NOTE (W32CE): Do not ignore ERROR_BUSY! Check at
|
|
|
|
|
least stop_me if that happens. */
|
2010-01-25 16:04:27 +00:00
|
|
|
|
if (ctx->error_code == ERROR_BROKEN_PIPE)
|
|
|
|
|
{
|
|
|
|
|
ctx->eof = 1;
|
|
|
|
|
TRACE_LOG ("got EOF (broken pipe)");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ctx->error = 1;
|
|
|
|
|
TRACE_LOG1 ("read error: ec=%d", ctx->error_code);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2001-01-31 12:39:53 +00:00
|
|
|
|
}
|
2001-01-30 11:01:41 +00:00
|
|
|
|
}
|
2010-06-09 13:33:31 +00:00
|
|
|
|
LOCK (ctx->mutex);
|
|
|
|
|
if (ctx->stop_me)
|
|
|
|
|
{
|
|
|
|
|
UNLOCK (ctx->mutex);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
if (!nread)
|
|
|
|
|
{
|
|
|
|
|
ctx->eof = 1;
|
|
|
|
|
TRACE_LOG ("got eof");
|
2010-06-09 13:33:31 +00:00
|
|
|
|
UNLOCK (ctx->mutex);
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
break;
|
2001-01-30 11:01:41 +00:00
|
|
|
|
}
|
2013-04-25 11:00:16 +00:00
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
TRACE_LOG1 ("got %u bytes", nread);
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
ctx->writepos = (ctx->writepos + nread) % READBUF_SIZE;
|
|
|
|
|
if (!SetEvent (ctx->have_data_ev))
|
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
|
|
|
|
TRACE_LOG2 ("SetEvent (0x%x) failed: ec=%d", ctx->have_data_ev,
|
|
|
|
|
(int) GetLastError ());
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
UNLOCK (ctx->mutex);
|
2001-01-30 11:01:41 +00:00
|
|
|
|
}
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
/* Indicate that we have an error or EOF. */
|
|
|
|
|
if (!SetEvent (ctx->have_data_ev))
|
2013-04-25 11:00:16 +00:00
|
|
|
|
TRACE_LOG2 ("SetEvent (0x%x) failed: ec=%d", ctx->have_data_ev,
|
|
|
|
|
(int) GetLastError ());
|
|
|
|
|
|
|
|
|
|
TRACE_LOG ("waiting for close");
|
|
|
|
|
WaitForSingleObject (ctx->close_ev, INFINITE);
|
|
|
|
|
|
|
|
|
|
CloseHandle (ctx->close_ev);
|
|
|
|
|
CloseHandle (ctx->have_data_ev);
|
|
|
|
|
CloseHandle (ctx->have_space_ev);
|
|
|
|
|
CloseHandle (ctx->thread_hd);
|
|
|
|
|
DESTROY_LOCK (ctx->mutex);
|
|
|
|
|
free (ctx);
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
return TRACE_SUC ();
|
2001-01-30 11:01:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static struct reader_context_s *
|
2010-06-10 13:49:19 +00:00
|
|
|
|
create_reader (int fd)
|
2001-01-30 11:01:41 +00:00
|
|
|
|
{
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
struct reader_context_s *ctx;
|
|
|
|
|
SECURITY_ATTRIBUTES sec_attr;
|
|
|
|
|
DWORD tid;
|
|
|
|
|
|
|
|
|
|
TRACE_BEG (DEBUG_SYSIO, "gpgme:create_reader", fd);
|
|
|
|
|
|
|
|
|
|
memset (&sec_attr, 0, sizeof sec_attr);
|
|
|
|
|
sec_attr.nLength = sizeof sec_attr;
|
|
|
|
|
sec_attr.bInheritHandle = FALSE;
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
ctx = calloc (1, sizeof *ctx);
|
|
|
|
|
if (!ctx)
|
|
|
|
|
{
|
|
|
|
|
TRACE_SYSERR (errno);
|
|
|
|
|
return NULL;
|
2001-01-30 11:01:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-06-10 13:49:19 +00:00
|
|
|
|
if (fd < 0 || fd >= MAX_SLAFD || !fd_table[fd].used)
|
|
|
|
|
{
|
|
|
|
|
TRACE_SYSERR (EIO);
|
2014-04-15 14:40:48 +00:00
|
|
|
|
free (ctx);
|
2010-06-10 13:49:19 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2013-05-06 18:23:47 +00:00
|
|
|
|
TRACE_LOG4 ("fd=%d -> handle=%p socket=%d dupfrom=%d",
|
|
|
|
|
fd, fd_table[fd].handle, fd_table[fd].socket,
|
|
|
|
|
fd_table[fd].dup_from);
|
2010-06-10 13:49:19 +00:00
|
|
|
|
ctx->file_hd = fd_table[fd].handle;
|
|
|
|
|
ctx->file_sock = fd_table[fd].socket;
|
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
ctx->refcount = 1;
|
|
|
|
|
ctx->have_data_ev = CreateEvent (&sec_attr, TRUE, FALSE, NULL);
|
|
|
|
|
if (ctx->have_data_ev)
|
|
|
|
|
ctx->have_space_ev = CreateEvent (&sec_attr, FALSE, TRUE, NULL);
|
|
|
|
|
if (ctx->have_space_ev)
|
2013-04-25 11:00:16 +00:00
|
|
|
|
ctx->close_ev = CreateEvent (&sec_attr, TRUE, FALSE, NULL);
|
|
|
|
|
if (!ctx->have_data_ev || !ctx->have_space_ev || !ctx->close_ev)
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
{
|
|
|
|
|
TRACE_LOG1 ("CreateEvent failed: ec=%d", (int) GetLastError ());
|
|
|
|
|
if (ctx->have_data_ev)
|
|
|
|
|
CloseHandle (ctx->have_data_ev);
|
|
|
|
|
if (ctx->have_space_ev)
|
|
|
|
|
CloseHandle (ctx->have_space_ev);
|
2013-04-25 11:00:16 +00:00
|
|
|
|
if (ctx->close_ev)
|
|
|
|
|
CloseHandle (ctx->close_ev);
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
free (ctx);
|
|
|
|
|
/* FIXME: Translate the error code. */
|
|
|
|
|
TRACE_SYSERR (EIO);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ctx->have_data_ev = set_synchronize (ctx->have_data_ev);
|
|
|
|
|
INIT_LOCK (ctx->mutex);
|
|
|
|
|
|
2010-11-23 10:47:59 +00:00
|
|
|
|
#ifdef HAVE_W32CE_SYSTEM
|
|
|
|
|
ctx->thread_hd = CreateThread (&sec_attr, 64 * 1024, reader, ctx,
|
|
|
|
|
STACK_SIZE_PARAM_IS_A_RESERVATION, &tid);
|
|
|
|
|
#else
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
ctx->thread_hd = CreateThread (&sec_attr, 0, reader, ctx, 0, &tid);
|
2010-11-23 10:47:59 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
if (!ctx->thread_hd)
|
|
|
|
|
{
|
|
|
|
|
TRACE_LOG1 ("CreateThread failed: ec=%d", (int) GetLastError ());
|
|
|
|
|
DESTROY_LOCK (ctx->mutex);
|
|
|
|
|
if (ctx->have_data_ev)
|
|
|
|
|
CloseHandle (ctx->have_data_ev);
|
|
|
|
|
if (ctx->have_space_ev)
|
|
|
|
|
CloseHandle (ctx->have_space_ev);
|
2013-04-25 11:00:16 +00:00
|
|
|
|
if (ctx->close_ev)
|
|
|
|
|
CloseHandle (ctx->close_ev);
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
free (ctx);
|
|
|
|
|
TRACE_SYSERR (EIO);
|
|
|
|
|
return NULL;
|
2012-09-25 13:29:49 +00:00
|
|
|
|
}
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2005-09-23 13:29:04 +00:00
|
|
|
|
/* We set the priority of the thread higher because we know that
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
it only runs for a short time. This greatly helps to
|
|
|
|
|
increase the performance of the I/O. */
|
|
|
|
|
SetThreadPriority (ctx->thread_hd, get_desired_thread_priority ());
|
2005-09-23 13:29:04 +00:00
|
|
|
|
}
|
2001-01-30 11:01:41 +00:00
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
TRACE_SUC ();
|
|
|
|
|
return ctx;
|
2001-01-30 11:01:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
|
2013-04-25 11:00:16 +00:00
|
|
|
|
/* Prepare destruction of the reader thread for CTX. Returns 0 if a
|
|
|
|
|
call to this function is sufficient and destroy_reader_finish shall
|
|
|
|
|
not be called. */
|
2001-02-20 13:31:56 +00:00
|
|
|
|
static void
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
destroy_reader (struct reader_context_s *ctx)
|
2001-02-20 13:31:56 +00:00
|
|
|
|
{
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
LOCK (ctx->mutex);
|
|
|
|
|
ctx->refcount--;
|
|
|
|
|
if (ctx->refcount != 0)
|
|
|
|
|
{
|
|
|
|
|
UNLOCK (ctx->mutex);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ctx->stop_me = 1;
|
2012-09-25 13:29:49 +00:00
|
|
|
|
if (ctx->have_space_ev)
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
SetEvent (ctx->have_space_ev);
|
|
|
|
|
UNLOCK (ctx->mutex);
|
|
|
|
|
|
2010-06-09 13:33:31 +00:00
|
|
|
|
#ifdef HAVE_W32CE_SYSTEM
|
|
|
|
|
/* Scenario: We never create a full pipe, but already started
|
|
|
|
|
reading. Then we need to unblock the reader in the pipe driver
|
|
|
|
|
to make our reader thread notice that we want it to go away. */
|
|
|
|
|
|
2010-06-10 13:49:19 +00:00
|
|
|
|
if (ctx->file_hd != INVALID_HANDLE_VALUE)
|
2010-06-09 13:33:31 +00:00
|
|
|
|
{
|
2010-06-10 13:49:19 +00:00
|
|
|
|
if (!DeviceIoControl (ctx->file_hd, GPGCEDEV_IOCTL_UNBLOCK,
|
|
|
|
|
NULL, 0, NULL, 0, NULL, NULL))
|
|
|
|
|
{
|
|
|
|
|
TRACE1 (DEBUG_SYSIO, "gpgme:destroy_reader", ctx->file_hd,
|
|
|
|
|
"unblock control call failed for thread %p", ctx->thread_hd);
|
|
|
|
|
}
|
2010-06-09 13:33:31 +00:00
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2013-04-25 11:00:16 +00:00
|
|
|
|
/* The reader thread is usually blocking in recv or ReadFile. If
|
|
|
|
|
the peer does not send an EOF or breaks the pipe the WFSO might
|
|
|
|
|
get stuck waiting for the termination of the reader thread. This
|
|
|
|
|
happens quite often with sockets, thus we definitely need to get
|
|
|
|
|
out of the recv. A shutdown does this nicely. For handles
|
|
|
|
|
(i.e. pipes) it would also be nice to cancel the operation, but
|
|
|
|
|
such a feature is only available since Vista. Thus we need to
|
|
|
|
|
dlopen that syscall. */
|
|
|
|
|
if (ctx->file_hd != INVALID_HANDLE_VALUE)
|
|
|
|
|
{
|
|
|
|
|
/* Fixme: Call CancelSynchronousIo (handle_of_thread). */
|
|
|
|
|
}
|
|
|
|
|
else if (ctx->file_sock != INVALID_SOCKET)
|
|
|
|
|
{
|
|
|
|
|
if (shutdown (ctx->file_sock, 2))
|
|
|
|
|
TRACE2 (DEBUG_SYSIO, "gpgme:destroy_reader", ctx->file_hd,
|
|
|
|
|
"shutdown socket %d failed: %s",
|
|
|
|
|
ctx->file_sock, (int) WSAGetLastError ());
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-25 11:00:16 +00:00
|
|
|
|
/* After setting this event CTX is void. */
|
|
|
|
|
SetEvent (ctx->close_ev);
|
2001-02-20 13:31:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-01-30 11:01:41 +00:00
|
|
|
|
|
2013-04-25 11:00:16 +00:00
|
|
|
|
|
2007-07-16 17:26:09 +00:00
|
|
|
|
/* Find a reader context or create a new one. Note that the reader
|
|
|
|
|
context will last until a _gpgme_io_close. */
|
2001-01-30 11:01:41 +00:00
|
|
|
|
static struct reader_context_s *
|
|
|
|
|
find_reader (int fd, int start_it)
|
|
|
|
|
{
|
2007-07-16 17:26:09 +00:00
|
|
|
|
struct reader_context_s *rd = NULL;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
LOCK (reader_table_lock);
|
|
|
|
|
for (i = 0; i < reader_table_size; i++)
|
|
|
|
|
if (reader_table[i].used && reader_table[i].fd == fd)
|
|
|
|
|
rd = reader_table[i].context;
|
2001-01-30 11:01:41 +00:00
|
|
|
|
|
2007-07-16 17:26:09 +00:00
|
|
|
|
if (rd || !start_it)
|
|
|
|
|
{
|
|
|
|
|
UNLOCK (reader_table_lock);
|
|
|
|
|
return rd;
|
2001-01-30 11:01:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-07-16 17:26:09 +00:00
|
|
|
|
for (i = 0; i < reader_table_size; i++)
|
|
|
|
|
if (!reader_table[i].used)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
if (i != reader_table_size)
|
|
|
|
|
{
|
2010-06-10 13:49:19 +00:00
|
|
|
|
rd = create_reader (fd);
|
2010-09-01 00:46:19 +00:00
|
|
|
|
reader_table[i].fd = fd;
|
|
|
|
|
reader_table[i].context = rd;
|
|
|
|
|
reader_table[i].used = 1;
|
2001-01-30 11:01:41 +00:00
|
|
|
|
}
|
2007-07-16 17:26:09 +00:00
|
|
|
|
|
|
|
|
|
UNLOCK (reader_table_lock);
|
|
|
|
|
return rd;
|
2001-01-30 11:01:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-11-22 17:10:48 +00:00
|
|
|
|
int
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
_gpgme_io_read (int fd, void *buffer, size_t count)
|
2000-11-22 17:10:48 +00:00
|
|
|
|
{
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
int nread;
|
|
|
|
|
struct reader_context_s *ctx;
|
|
|
|
|
TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_read", fd,
|
|
|
|
|
"buffer=%p, count=%u", buffer, count);
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
ctx = find_reader (fd, 1);
|
|
|
|
|
if (!ctx)
|
|
|
|
|
{
|
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 (EBADF);
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
return TRACE_SYSRES (-1);
|
2001-01-31 12:39:53 +00:00
|
|
|
|
}
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
if (ctx->eof_shortcut)
|
|
|
|
|
return TRACE_SYSRES (0);
|
2001-01-30 11:01:41 +00:00
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
LOCK (ctx->mutex);
|
|
|
|
|
if (ctx->readpos == ctx->writepos && !ctx->error)
|
|
|
|
|
{
|
|
|
|
|
/* No data available. */
|
|
|
|
|
UNLOCK (ctx->mutex);
|
|
|
|
|
TRACE_LOG1 ("waiting for data from thread %p", ctx->thread_hd);
|
|
|
|
|
WaitForSingleObject (ctx->have_data_ev, INFINITE);
|
|
|
|
|
TRACE_LOG1 ("data from thread %p available", ctx->thread_hd);
|
|
|
|
|
LOCK (ctx->mutex);
|
2001-01-30 11:01:41 +00:00
|
|
|
|
}
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
if (ctx->readpos == ctx->writepos || ctx->error)
|
|
|
|
|
{
|
|
|
|
|
UNLOCK (ctx->mutex);
|
|
|
|
|
ctx->eof_shortcut = 1;
|
|
|
|
|
if (ctx->eof)
|
|
|
|
|
return TRACE_SYSRES (0);
|
|
|
|
|
if (!ctx->error)
|
|
|
|
|
{
|
|
|
|
|
TRACE_LOG ("EOF but ctx->eof flag not set");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
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 (ctx->error_code);
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
return TRACE_SYSRES (-1);
|
2001-01-31 12:39:53 +00:00
|
|
|
|
}
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
nread = ctx->readpos < ctx->writepos
|
|
|
|
|
? ctx->writepos - ctx->readpos
|
|
|
|
|
: READBUF_SIZE - ctx->readpos;
|
|
|
|
|
if (nread > count)
|
|
|
|
|
nread = count;
|
|
|
|
|
memcpy (buffer, ctx->buffer + ctx->readpos, nread);
|
|
|
|
|
ctx->readpos = (ctx->readpos + nread) % READBUF_SIZE;
|
|
|
|
|
if (ctx->readpos == ctx->writepos && !ctx->eof)
|
|
|
|
|
{
|
|
|
|
|
if (!ResetEvent (ctx->have_data_ev))
|
|
|
|
|
{
|
|
|
|
|
TRACE_LOG1 ("ResetEvent failed: ec=%d", (int) GetLastError ());
|
|
|
|
|
UNLOCK (ctx->mutex);
|
|
|
|
|
/* FIXME: Should translate the error code. */
|
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 (EIO);
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
return TRACE_SYSRES (-1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!SetEvent (ctx->have_space_ev))
|
|
|
|
|
{
|
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
|
|
|
|
TRACE_LOG2 ("SetEvent (0x%x) failed: ec=%d",
|
|
|
|
|
ctx->have_space_ev, (int) GetLastError ());
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
UNLOCK (ctx->mutex);
|
|
|
|
|
/* FIXME: Should translate the error code. */
|
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 (EIO);
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
return TRACE_SYSRES (-1);
|
2001-01-30 11:01:41 +00:00
|
|
|
|
}
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
UNLOCK (ctx->mutex);
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
TRACE_LOGBUF (buffer, nread);
|
|
|
|
|
return TRACE_SYSRES (nread);
|
|
|
|
|
}
|
2001-01-30 11:01:41 +00:00
|
|
|
|
|
2000-11-22 17:10:48 +00:00
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
/* The writer does use a simple buffering strategy so that we are
|
|
|
|
|
informed about write errors as soon as possible (i. e. with the the
|
|
|
|
|
next call to the write function. */
|
2012-09-25 13:29:49 +00:00
|
|
|
|
static DWORD CALLBACK
|
2001-02-28 10:18:38 +00:00
|
|
|
|
writer (void *arg)
|
2000-11-22 17:10:48 +00:00
|
|
|
|
{
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
struct writer_context_s *ctx = arg;
|
|
|
|
|
DWORD nwritten;
|
2010-04-16 14:08:41 +00:00
|
|
|
|
int sock;
|
2013-05-06 18:23:47 +00:00
|
|
|
|
TRACE_BEG2 (DEBUG_SYSIO, "gpgme:writer", ctx->file_hd,
|
|
|
|
|
"file_sock=%d, thread=%p", ctx->file_sock, ctx->thread_hd);
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
|
2010-06-10 13:49:19 +00:00
|
|
|
|
if (ctx->file_hd != INVALID_HANDLE_VALUE)
|
|
|
|
|
sock = 0;
|
|
|
|
|
else
|
|
|
|
|
sock = 1;
|
2010-04-16 14:08:41 +00:00
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
for (;;)
|
|
|
|
|
{
|
|
|
|
|
LOCK (ctx->mutex);
|
2017-01-23 14:08:23 +00:00
|
|
|
|
if (ctx->stop_me && !ctx->nbytes)
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
{
|
|
|
|
|
UNLOCK (ctx->mutex);
|
|
|
|
|
break;
|
2006-02-15 13:30:08 +00:00
|
|
|
|
}
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
if (!ctx->nbytes)
|
2012-09-25 13:29:49 +00:00
|
|
|
|
{
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
if (!SetEvent (ctx->is_empty))
|
|
|
|
|
TRACE_LOG1 ("SetEvent failed: ec=%d", (int) GetLastError ());
|
|
|
|
|
if (!ResetEvent (ctx->have_data))
|
|
|
|
|
TRACE_LOG1 ("ResetEvent failed: ec=%d", (int) GetLastError ());
|
|
|
|
|
UNLOCK (ctx->mutex);
|
|
|
|
|
TRACE_LOG ("idle");
|
|
|
|
|
WaitForSingleObject (ctx->have_data, INFINITE);
|
|
|
|
|
TRACE_LOG ("got data to send");
|
|
|
|
|
LOCK (ctx->mutex);
|
2001-02-28 10:18:38 +00:00
|
|
|
|
}
|
2017-01-23 14:08:23 +00:00
|
|
|
|
if (ctx->stop_me && !ctx->nbytes)
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
{
|
|
|
|
|
UNLOCK (ctx->mutex);
|
|
|
|
|
break;
|
2001-02-28 10:18:38 +00:00
|
|
|
|
}
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
UNLOCK (ctx->mutex);
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2010-04-16 14:08:41 +00:00
|
|
|
|
TRACE_LOG2 ("%s %d bytes", sock?"sending":"writing", ctx->nbytes);
|
|
|
|
|
|
2007-08-22 17:29:41 +00:00
|
|
|
|
/* Note that CTX->nbytes is not zero at this point, because
|
|
|
|
|
_gpgme_io_write always writes at least 1 byte before waking
|
|
|
|
|
us up, unless CTX->stop_me is true, which we catch above. */
|
2010-06-10 13:49:19 +00:00
|
|
|
|
if (sock)
|
2010-01-25 16:04:27 +00:00
|
|
|
|
{
|
|
|
|
|
/* We need to try send first because a socket handle can't
|
|
|
|
|
be used with WriteFile. */
|
|
|
|
|
int n;
|
2010-06-09 13:33:31 +00:00
|
|
|
|
|
2010-06-10 13:49:19 +00:00
|
|
|
|
n = send (ctx->file_sock, ctx->buffer, ctx->nbytes, 0);
|
2010-04-16 14:08:41 +00:00
|
|
|
|
if (n < 0)
|
2010-01-25 16:04:27 +00:00
|
|
|
|
{
|
|
|
|
|
ctx->error_code = (int) WSAGetLastError ();
|
|
|
|
|
ctx->error = 1;
|
|
|
|
|
TRACE_LOG1 ("send error: ec=%d", ctx->error_code);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2010-04-16 14:08:41 +00:00
|
|
|
|
nwritten = n;
|
2010-01-25 16:04:27 +00:00
|
|
|
|
}
|
2010-04-16 14:08:41 +00:00
|
|
|
|
else
|
2010-01-25 16:04:27 +00:00
|
|
|
|
{
|
|
|
|
|
if (!WriteFile (ctx->file_hd, ctx->buffer,
|
|
|
|
|
ctx->nbytes, &nwritten, NULL))
|
|
|
|
|
{
|
2010-06-09 13:33:31 +00:00
|
|
|
|
if (GetLastError () == ERROR_BUSY)
|
|
|
|
|
{
|
|
|
|
|
/* Probably stop_me is set now. */
|
|
|
|
|
TRACE_LOG ("pipe busy (unblocked?)");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-25 16:04:27 +00:00
|
|
|
|
ctx->error_code = (int) GetLastError ();
|
|
|
|
|
ctx->error = 1;
|
|
|
|
|
TRACE_LOG1 ("write error: ec=%d", ctx->error_code);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-08-22 17:29:41 +00:00
|
|
|
|
TRACE_LOG1 ("wrote %d bytes", (int) nwritten);
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2007-08-22 17:29:41 +00:00
|
|
|
|
LOCK (ctx->mutex);
|
|
|
|
|
ctx->nbytes -= nwritten;
|
|
|
|
|
UNLOCK (ctx->mutex);
|
2001-02-28 10:18:38 +00:00
|
|
|
|
}
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
/* Indicate that we have an error. */
|
|
|
|
|
if (!SetEvent (ctx->is_empty))
|
|
|
|
|
TRACE_LOG1 ("SetEvent failed: ec=%d", (int) GetLastError ());
|
2013-04-25 11:00:16 +00:00
|
|
|
|
|
|
|
|
|
TRACE_LOG ("waiting for close");
|
|
|
|
|
WaitForSingleObject (ctx->close_ev, INFINITE);
|
|
|
|
|
|
2017-01-23 14:08:23 +00:00
|
|
|
|
if (ctx->nbytes)
|
|
|
|
|
TRACE_LOG1 ("still %d bytes in buffer at close time", ctx->nbytes);
|
|
|
|
|
|
2013-04-25 11:00:16 +00:00
|
|
|
|
CloseHandle (ctx->close_ev);
|
|
|
|
|
CloseHandle (ctx->have_data);
|
|
|
|
|
CloseHandle (ctx->is_empty);
|
|
|
|
|
CloseHandle (ctx->thread_hd);
|
|
|
|
|
DESTROY_LOCK (ctx->mutex);
|
|
|
|
|
free (ctx);
|
2001-02-28 10:18:38 +00:00
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
return TRACE_SUC ();
|
2001-02-28 10:18:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static struct writer_context_s *
|
2010-06-10 13:49:19 +00:00
|
|
|
|
create_writer (int fd)
|
2001-02-28 10:18:38 +00:00
|
|
|
|
{
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
struct writer_context_s *ctx;
|
|
|
|
|
SECURITY_ATTRIBUTES sec_attr;
|
|
|
|
|
DWORD tid;
|
|
|
|
|
|
|
|
|
|
TRACE_BEG (DEBUG_SYSIO, "gpgme:create_writer", fd);
|
|
|
|
|
|
|
|
|
|
memset (&sec_attr, 0, sizeof sec_attr);
|
|
|
|
|
sec_attr.nLength = sizeof sec_attr;
|
|
|
|
|
sec_attr.bInheritHandle = FALSE;
|
|
|
|
|
|
|
|
|
|
ctx = calloc (1, sizeof *ctx);
|
|
|
|
|
if (!ctx)
|
|
|
|
|
{
|
|
|
|
|
TRACE_SYSERR (errno);
|
|
|
|
|
return NULL;
|
2001-02-28 10:18:38 +00:00
|
|
|
|
}
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2010-06-10 13:49:19 +00:00
|
|
|
|
if (fd < 0 || fd >= MAX_SLAFD || !fd_table[fd].used)
|
|
|
|
|
{
|
|
|
|
|
TRACE_SYSERR (EIO);
|
2014-04-15 14:40:48 +00:00
|
|
|
|
free (ctx);
|
2010-06-10 13:49:19 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2013-05-06 18:23:47 +00:00
|
|
|
|
TRACE_LOG4 ("fd=%d -> handle=%p socket=%d dupfrom=%d",
|
|
|
|
|
fd, fd_table[fd].handle, fd_table[fd].socket,
|
|
|
|
|
fd_table[fd].dup_from);
|
2010-06-10 13:49:19 +00:00
|
|
|
|
ctx->file_hd = fd_table[fd].handle;
|
|
|
|
|
ctx->file_sock = fd_table[fd].socket;
|
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
ctx->refcount = 1;
|
|
|
|
|
ctx->have_data = CreateEvent (&sec_attr, TRUE, FALSE, NULL);
|
|
|
|
|
if (ctx->have_data)
|
|
|
|
|
ctx->is_empty = CreateEvent (&sec_attr, TRUE, TRUE, NULL);
|
|
|
|
|
if (ctx->is_empty)
|
2013-04-25 11:00:16 +00:00
|
|
|
|
ctx->close_ev = CreateEvent (&sec_attr, TRUE, FALSE, NULL);
|
|
|
|
|
if (!ctx->have_data || !ctx->is_empty || !ctx->close_ev)
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
{
|
|
|
|
|
TRACE_LOG1 ("CreateEvent failed: ec=%d", (int) GetLastError ());
|
|
|
|
|
if (ctx->have_data)
|
|
|
|
|
CloseHandle (ctx->have_data);
|
|
|
|
|
if (ctx->is_empty)
|
|
|
|
|
CloseHandle (ctx->is_empty);
|
2013-04-25 11:00:16 +00:00
|
|
|
|
if (ctx->close_ev)
|
|
|
|
|
CloseHandle (ctx->close_ev);
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
free (ctx);
|
|
|
|
|
/* FIXME: Translate the error code. */
|
|
|
|
|
TRACE_SYSERR (EIO);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ctx->is_empty = set_synchronize (ctx->is_empty);
|
|
|
|
|
INIT_LOCK (ctx->mutex);
|
2001-02-28 10:18:38 +00:00
|
|
|
|
|
2010-11-23 10:47:59 +00:00
|
|
|
|
#ifdef HAVE_W32CE_SYSTEM
|
|
|
|
|
ctx->thread_hd = CreateThread (&sec_attr, 64 * 1024, writer, ctx,
|
|
|
|
|
STACK_SIZE_PARAM_IS_A_RESERVATION, &tid);
|
|
|
|
|
#else
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
ctx->thread_hd = CreateThread (&sec_attr, 0, writer, ctx, 0, &tid );
|
2010-11-23 10:47:59 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
if (!ctx->thread_hd)
|
|
|
|
|
{
|
|
|
|
|
TRACE_LOG1 ("CreateThread failed: ec=%d", (int) GetLastError ());
|
|
|
|
|
DESTROY_LOCK (ctx->mutex);
|
|
|
|
|
if (ctx->have_data)
|
|
|
|
|
CloseHandle (ctx->have_data);
|
|
|
|
|
if (ctx->is_empty)
|
|
|
|
|
CloseHandle (ctx->is_empty);
|
2013-04-25 11:00:16 +00:00
|
|
|
|
if (ctx->close_ev)
|
|
|
|
|
CloseHandle (ctx->close_ev);
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
free (ctx);
|
|
|
|
|
TRACE_SYSERR (EIO);
|
|
|
|
|
return NULL;
|
2012-09-25 13:29:49 +00:00
|
|
|
|
}
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* We set the priority of the thread higher because we know
|
|
|
|
|
that it only runs for a short time. This greatly helps to
|
|
|
|
|
increase the performance of the I/O. */
|
|
|
|
|
SetThreadPriority (ctx->thread_hd, get_desired_thread_priority ());
|
2005-09-23 13:29:04 +00:00
|
|
|
|
}
|
2001-02-28 10:18:38 +00:00
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
TRACE_SUC ();
|
|
|
|
|
return ctx;
|
2001-02-28 10:18:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-25 11:00:16 +00:00
|
|
|
|
|
2001-02-28 10:18:38 +00:00
|
|
|
|
static void
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
destroy_writer (struct writer_context_s *ctx)
|
2001-02-28 10:18:38 +00:00
|
|
|
|
{
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
LOCK (ctx->mutex);
|
|
|
|
|
ctx->refcount--;
|
|
|
|
|
if (ctx->refcount != 0)
|
|
|
|
|
{
|
|
|
|
|
UNLOCK (ctx->mutex);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ctx->stop_me = 1;
|
2012-09-25 13:29:49 +00:00
|
|
|
|
if (ctx->have_data)
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
SetEvent (ctx->have_data);
|
|
|
|
|
UNLOCK (ctx->mutex);
|
2010-06-09 13:33:31 +00:00
|
|
|
|
|
2017-01-23 14:08:23 +00:00
|
|
|
|
/* Give the writer a chance to flush the buffer. */
|
|
|
|
|
WaitForSingleObject (ctx->is_empty, INFINITE);
|
|
|
|
|
|
2010-06-09 13:33:31 +00:00
|
|
|
|
#ifdef HAVE_W32CE_SYSTEM
|
|
|
|
|
/* Scenario: We never create a full pipe, but already started
|
2010-08-03 09:01:24 +00:00
|
|
|
|
writing more than the pipe buffer. Then we need to unblock the
|
|
|
|
|
writer in the pipe driver to make our writer thread notice that
|
|
|
|
|
we want it to go away. */
|
2010-06-09 13:33:31 +00:00
|
|
|
|
|
|
|
|
|
if (!DeviceIoControl (ctx->file_hd, GPGCEDEV_IOCTL_UNBLOCK,
|
|
|
|
|
NULL, 0, NULL, 0, NULL, NULL))
|
|
|
|
|
{
|
|
|
|
|
TRACE1 (DEBUG_SYSIO, "gpgme:destroy_writer", ctx->file_hd,
|
|
|
|
|
"unblock control call failed for thread %p", ctx->thread_hd);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2013-04-25 11:00:16 +00:00
|
|
|
|
/* After setting this event CTX is void. */
|
|
|
|
|
SetEvent (ctx->close_ev);
|
2001-02-28 10:18:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
/* Find a writer context or create a new one. Note that the writer
|
|
|
|
|
context will last until a _gpgme_io_close. */
|
2001-02-28 10:18:38 +00:00
|
|
|
|
static struct writer_context_s *
|
|
|
|
|
find_writer (int fd, int start_it)
|
|
|
|
|
{
|
2007-07-16 17:26:09 +00:00
|
|
|
|
struct writer_context_s *wt = NULL;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
LOCK (writer_table_lock);
|
|
|
|
|
for (i = 0; i < writer_table_size; i++)
|
|
|
|
|
if (writer_table[i].used && writer_table[i].fd == fd)
|
|
|
|
|
wt = writer_table[i].context;
|
2001-02-28 10:18:38 +00:00
|
|
|
|
|
2007-07-16 17:26:09 +00:00
|
|
|
|
if (wt || !start_it)
|
|
|
|
|
{
|
|
|
|
|
UNLOCK (writer_table_lock);
|
|
|
|
|
return wt;
|
2001-02-28 10:18:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-07-16 17:26:09 +00:00
|
|
|
|
for (i = 0; i < writer_table_size; i++)
|
|
|
|
|
if (!writer_table[i].used)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
if (i != writer_table_size)
|
|
|
|
|
{
|
2010-06-10 13:49:19 +00:00
|
|
|
|
wt = create_writer (fd);
|
2010-09-01 00:46:19 +00:00
|
|
|
|
writer_table[i].fd = fd;
|
2012-09-25 13:29:49 +00:00
|
|
|
|
writer_table[i].context = wt;
|
2010-09-01 00:46:19 +00:00
|
|
|
|
writer_table[i].used = 1;
|
2001-02-28 10:18:38 +00:00
|
|
|
|
}
|
2007-07-16 17:26:09 +00:00
|
|
|
|
|
|
|
|
|
UNLOCK (writer_table_lock);
|
|
|
|
|
return wt;
|
2001-02-28 10:18:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
_gpgme_io_write (int fd, const void *buffer, size_t count)
|
2001-02-28 10:18:38 +00:00
|
|
|
|
{
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
struct writer_context_s *ctx;
|
|
|
|
|
TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_write", fd,
|
|
|
|
|
"buffer=%p, count=%u", buffer, count);
|
|
|
|
|
TRACE_LOGBUF (buffer, count);
|
|
|
|
|
|
2007-08-22 17:29:41 +00:00
|
|
|
|
if (count == 0)
|
2007-09-07 19:38:50 +00:00
|
|
|
|
return TRACE_SYSRES (0);
|
2007-08-22 17:29:41 +00:00
|
|
|
|
|
2010-09-01 00:46:19 +00:00
|
|
|
|
ctx = find_writer (fd, 1);
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
if (!ctx)
|
|
|
|
|
return TRACE_SYSRES (-1);
|
|
|
|
|
|
|
|
|
|
LOCK (ctx->mutex);
|
|
|
|
|
if (!ctx->error && ctx->nbytes)
|
|
|
|
|
{
|
|
|
|
|
/* Bytes are pending for send. */
|
|
|
|
|
|
|
|
|
|
/* Reset the is_empty event. Better safe than sorry. */
|
|
|
|
|
if (!ResetEvent (ctx->is_empty))
|
|
|
|
|
{
|
|
|
|
|
TRACE_LOG1 ("ResetEvent failed: ec=%d", (int) GetLastError ());
|
|
|
|
|
UNLOCK (ctx->mutex);
|
|
|
|
|
/* FIXME: Should translate the error code. */
|
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 (EIO);
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
return TRACE_SYSRES (-1);
|
|
|
|
|
}
|
|
|
|
|
UNLOCK (ctx->mutex);
|
|
|
|
|
TRACE_LOG1 ("waiting for empty buffer in thread %p", ctx->thread_hd);
|
|
|
|
|
WaitForSingleObject (ctx->is_empty, INFINITE);
|
|
|
|
|
TRACE_LOG1 ("thread %p buffer is empty", ctx->thread_hd);
|
|
|
|
|
LOCK (ctx->mutex);
|
2001-02-28 10:18:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
if (ctx->error)
|
|
|
|
|
{
|
|
|
|
|
UNLOCK (ctx->mutex);
|
2007-08-02 14:59:01 +00:00
|
|
|
|
if (ctx->error_code == ERROR_NO_DATA)
|
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 (EPIPE);
|
2007-08-02 14:59:01 +00:00
|
|
|
|
else
|
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 (EIO);
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
return TRACE_SYSRES (-1);
|
2001-02-28 10:18:38 +00:00
|
|
|
|
}
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
|
2015-12-02 10:28:07 +00:00
|
|
|
|
/* If no error occurred, the number of bytes in the buffer must be
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
zero. */
|
|
|
|
|
assert (!ctx->nbytes);
|
|
|
|
|
|
|
|
|
|
if (count > WRITEBUF_SIZE)
|
|
|
|
|
count = WRITEBUF_SIZE;
|
|
|
|
|
memcpy (ctx->buffer, buffer, count);
|
|
|
|
|
ctx->nbytes = count;
|
|
|
|
|
|
|
|
|
|
/* We have to reset the is_empty event early, because it is also
|
|
|
|
|
used by the select() implementation to probe the channel. */
|
|
|
|
|
if (!ResetEvent (ctx->is_empty))
|
|
|
|
|
{
|
|
|
|
|
TRACE_LOG1 ("ResetEvent failed: ec=%d", (int) GetLastError ());
|
|
|
|
|
UNLOCK (ctx->mutex);
|
|
|
|
|
/* FIXME: Should translate the error code. */
|
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 (EIO);
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
return TRACE_SYSRES (-1);
|
2000-11-22 17:10:48 +00:00
|
|
|
|
}
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
if (!SetEvent (ctx->have_data))
|
|
|
|
|
{
|
|
|
|
|
TRACE_LOG1 ("SetEvent failed: ec=%d", (int) GetLastError ());
|
|
|
|
|
UNLOCK (ctx->mutex);
|
|
|
|
|
/* FIXME: Should translate the error code. */
|
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 (EIO);
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
return TRACE_SYSRES (-1);
|
|
|
|
|
}
|
|
|
|
|
UNLOCK (ctx->mutex);
|
2006-02-15 13:30:08 +00:00
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
return TRACE_SYSRES ((int) count);
|
2000-11-22 17:10:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-02-28 10:18:38 +00:00
|
|
|
|
|
2000-11-22 17:10:48 +00:00
|
|
|
|
int
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
_gpgme_io_pipe (int filedes[2], int inherit_idx)
|
2000-11-22 17:10:48 +00:00
|
|
|
|
{
|
2010-06-10 13:49:19 +00:00
|
|
|
|
int rfd;
|
|
|
|
|
int wfd;
|
2010-06-09 13:33:31 +00:00
|
|
|
|
#ifdef HAVE_W32CE_SYSTEM
|
|
|
|
|
HANDLE hd;
|
|
|
|
|
int rvid;
|
2010-06-10 13:49:19 +00:00
|
|
|
|
#else
|
|
|
|
|
HANDLE rh;
|
|
|
|
|
HANDLE wh;
|
|
|
|
|
SECURITY_ATTRIBUTES sec_attr;
|
|
|
|
|
#endif
|
2010-06-09 13:33:31 +00:00
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_pipe", filedes,
|
|
|
|
|
"inherit_idx=%i (GPGME uses it for %s)",
|
2007-09-27 11:44:45 +00:00
|
|
|
|
inherit_idx, inherit_idx ? "reading" : "writing");
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
|
2010-06-10 13:49:19 +00:00
|
|
|
|
rfd = new_fd ();
|
|
|
|
|
if (rfd == -1)
|
|
|
|
|
return TRACE_SYSRES (-1);
|
|
|
|
|
wfd = new_fd ();
|
|
|
|
|
if (wfd == -1)
|
|
|
|
|
{
|
|
|
|
|
release_fd (rfd);
|
|
|
|
|
return TRACE_SYSRES (-1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_W32CE_SYSTEM
|
2010-06-09 13:33:31 +00:00
|
|
|
|
hd = _assuan_w32ce_prepare_pipe (&rvid, !inherit_idx);
|
|
|
|
|
if (hd == INVALID_HANDLE_VALUE)
|
|
|
|
|
{
|
|
|
|
|
TRACE_LOG1 ("_assuan_w32ce_prepare_pipe failed: ec=%d",
|
|
|
|
|
(int) GetLastError ());
|
2010-06-10 13:49:19 +00:00
|
|
|
|
release_fd (rfd);
|
|
|
|
|
release_fd (wfd);
|
2010-06-09 13:33:31 +00:00
|
|
|
|
/* FIXME: Should translate the error code. */
|
|
|
|
|
gpg_err_set_errno (EIO);
|
|
|
|
|
return TRACE_SYSRES (-1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (inherit_idx == 0)
|
|
|
|
|
{
|
2010-06-10 13:49:19 +00:00
|
|
|
|
fd_table[rfd].rvid = rvid;
|
|
|
|
|
fd_table[wfd].handle = hd;
|
2010-06-09 13:33:31 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2010-06-10 13:49:19 +00:00
|
|
|
|
fd_table[rfd].handle = hd;
|
|
|
|
|
fd_table[wfd].rvid = rvid;
|
2012-09-25 13:29:49 +00:00
|
|
|
|
}
|
2010-06-10 13:49:19 +00:00
|
|
|
|
|
2010-06-09 13:33:31 +00:00
|
|
|
|
#else
|
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
memset (&sec_attr, 0, sizeof (sec_attr));
|
|
|
|
|
sec_attr.nLength = sizeof (sec_attr);
|
|
|
|
|
sec_attr.bInheritHandle = FALSE;
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
if (!CreatePipe (&rh, &wh, &sec_attr, PIPEBUF_SIZE))
|
|
|
|
|
{
|
|
|
|
|
TRACE_LOG1 ("CreatePipe failed: ec=%d", (int) GetLastError ());
|
2010-06-10 13:49:19 +00:00
|
|
|
|
release_fd (rfd);
|
|
|
|
|
release_fd (wfd);
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
/* FIXME: Should translate the error code. */
|
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 (EIO);
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
return TRACE_SYSRES (-1);
|
|
|
|
|
}
|
2000-12-06 12:17:10 +00:00
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
/* Make one end inheritable. */
|
|
|
|
|
if (inherit_idx == 0)
|
|
|
|
|
{
|
|
|
|
|
HANDLE hd;
|
|
|
|
|
if (!DuplicateHandle (GetCurrentProcess(), rh,
|
|
|
|
|
GetCurrentProcess(), &hd, 0,
|
|
|
|
|
TRUE, DUPLICATE_SAME_ACCESS))
|
|
|
|
|
{
|
|
|
|
|
TRACE_LOG1 ("DuplicateHandle failed: ec=%d",
|
|
|
|
|
(int) GetLastError ());
|
2010-06-10 13:49:19 +00:00
|
|
|
|
release_fd (rfd);
|
|
|
|
|
release_fd (wfd);
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
CloseHandle (rh);
|
|
|
|
|
CloseHandle (wh);
|
|
|
|
|
/* FIXME: Should translate the error code. */
|
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 (EIO);
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
return TRACE_SYSRES (-1);
|
2000-12-06 12:17:10 +00:00
|
|
|
|
}
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
CloseHandle (rh);
|
|
|
|
|
rh = hd;
|
2000-12-06 12:17:10 +00:00
|
|
|
|
}
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
else if (inherit_idx == 1)
|
|
|
|
|
{
|
|
|
|
|
HANDLE hd;
|
|
|
|
|
if (!DuplicateHandle( GetCurrentProcess(), wh,
|
|
|
|
|
GetCurrentProcess(), &hd, 0,
|
|
|
|
|
TRUE, DUPLICATE_SAME_ACCESS))
|
|
|
|
|
{
|
|
|
|
|
TRACE_LOG1 ("DuplicateHandle failed: ec=%d",
|
|
|
|
|
(int) GetLastError ());
|
2010-06-10 13:49:19 +00:00
|
|
|
|
release_fd (rfd);
|
|
|
|
|
release_fd (wfd);
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
CloseHandle (rh);
|
|
|
|
|
CloseHandle (wh);
|
|
|
|
|
/* FIXME: Should translate the error code. */
|
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 (EIO);
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
return TRACE_SYSRES (-1);
|
2000-12-06 12:17:10 +00:00
|
|
|
|
}
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
CloseHandle (wh);
|
|
|
|
|
wh = hd;
|
2010-06-09 13:33:31 +00:00
|
|
|
|
}
|
2010-06-10 13:49:19 +00:00
|
|
|
|
fd_table[rfd].handle = rh;
|
|
|
|
|
fd_table[wfd].handle = wh;
|
2010-06-09 13:33:31 +00:00
|
|
|
|
#endif
|
2009-06-18 13:41:48 +00:00
|
|
|
|
|
2010-06-10 13:49:19 +00:00
|
|
|
|
filedes[0] = rfd;
|
|
|
|
|
filedes[1] = wfd;
|
|
|
|
|
return TRACE_SUC6 ("read=0x%x (%p/0x%x), write=0x%x (%p/0x%x)",
|
|
|
|
|
rfd, fd_table[rfd].handle, fd_table[rfd].rvid,
|
|
|
|
|
wfd, fd_table[wfd].handle, fd_table[wfd].rvid);
|
2000-11-23 15:28:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
|
2000-11-23 15:28:15 +00:00
|
|
|
|
int
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
_gpgme_io_close (int fd)
|
2000-11-23 15:28:15 +00:00
|
|
|
|
{
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
int i;
|
|
|
|
|
_gpgme_close_notify_handler_t handler = NULL;
|
|
|
|
|
void *value = NULL;
|
2010-06-10 13:49:19 +00:00
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_close", fd);
|
|
|
|
|
|
|
|
|
|
if (fd == -1)
|
|
|
|
|
{
|
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 (EBADF);
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
return TRACE_SYSRES (-1);
|
|
|
|
|
}
|
2010-06-10 13:49:19 +00:00
|
|
|
|
if (fd < 0 || fd >= MAX_SLAFD || !fd_table[fd].used)
|
|
|
|
|
{
|
|
|
|
|
gpg_err_set_errno (EBADF);
|
|
|
|
|
return TRACE_SYSRES (-1);
|
|
|
|
|
}
|
2010-06-09 13:33:31 +00:00
|
|
|
|
|
2013-05-06 18:23:47 +00:00
|
|
|
|
TRACE_LOG4 ("fd=%d -> handle=%p socket=%d dupfrom=%d",
|
|
|
|
|
fd, fd_table[fd].handle, fd_table[fd].socket,
|
|
|
|
|
fd_table[fd].dup_from);
|
|
|
|
|
|
2013-04-25 11:00:16 +00:00
|
|
|
|
LOCK (reader_table_lock);
|
|
|
|
|
for (i = 0; i < reader_table_size; i++)
|
|
|
|
|
{
|
|
|
|
|
if (reader_table[i].used && reader_table[i].fd == fd)
|
|
|
|
|
{
|
|
|
|
|
destroy_reader (reader_table[i].context);
|
|
|
|
|
reader_table[i].context = NULL;
|
|
|
|
|
reader_table[i].used = 0;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
UNLOCK (reader_table_lock);
|
|
|
|
|
|
|
|
|
|
LOCK (writer_table_lock);
|
|
|
|
|
for (i = 0; i < writer_table_size; i++)
|
|
|
|
|
{
|
|
|
|
|
if (writer_table[i].used && writer_table[i].fd == fd)
|
|
|
|
|
{
|
|
|
|
|
destroy_writer (writer_table[i].context);
|
|
|
|
|
writer_table[i].context = NULL;
|
|
|
|
|
writer_table[i].used = 0;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
UNLOCK (writer_table_lock);
|
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
LOCK (notify_table_lock);
|
|
|
|
|
for (i = 0; i < DIM (notify_table); i++)
|
|
|
|
|
{
|
|
|
|
|
if (notify_table[i].inuse && notify_table[i].fd == fd)
|
|
|
|
|
{
|
|
|
|
|
handler = notify_table[i].handler;
|
|
|
|
|
value = notify_table[i].value;
|
|
|
|
|
notify_table[i].handler = NULL;
|
|
|
|
|
notify_table[i].value = NULL;
|
|
|
|
|
notify_table[i].inuse = 0;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2001-02-20 13:31:56 +00:00
|
|
|
|
}
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
UNLOCK (notify_table_lock);
|
|
|
|
|
if (handler)
|
|
|
|
|
handler (fd, value);
|
|
|
|
|
|
2010-06-10 13:49:19 +00:00
|
|
|
|
if (fd_table[fd].dup_from == -1)
|
|
|
|
|
{
|
|
|
|
|
if (fd_table[fd].handle != INVALID_HANDLE_VALUE)
|
|
|
|
|
{
|
|
|
|
|
if (!CloseHandle (fd_table[fd].handle))
|
2012-09-25 13:29:49 +00:00
|
|
|
|
{
|
2010-06-10 13:49:19 +00:00
|
|
|
|
TRACE_LOG1 ("CloseHandle failed: ec=%d", (int) GetLastError ());
|
|
|
|
|
/* FIXME: Should translate the error code. */
|
|
|
|
|
gpg_err_set_errno (EIO);
|
|
|
|
|
return TRACE_SYSRES (-1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (fd_table[fd].socket != INVALID_SOCKET)
|
|
|
|
|
{
|
|
|
|
|
if (closesocket (fd_table[fd].socket))
|
2012-09-25 13:29:49 +00:00
|
|
|
|
{
|
2010-06-10 13:49:19 +00:00
|
|
|
|
TRACE_LOG1 ("closesocket failed: ec=%d", (int) WSAGetLastError ());
|
|
|
|
|
/* FIXME: Should translate the error code. */
|
|
|
|
|
gpg_err_set_errno (EIO);
|
|
|
|
|
return TRACE_SYSRES (-1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/* Nothing to do for RVIDs. */
|
2000-12-06 12:17:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-06-10 13:49:19 +00:00
|
|
|
|
release_fd (fd);
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
return TRACE_SYSRES (0);
|
2000-11-22 17:10:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
|
2001-02-20 13:31:56 +00:00
|
|
|
|
int
|
2007-07-13 00:43:17 +00:00
|
|
|
|
_gpgme_io_set_close_notify (int fd, _gpgme_close_notify_handler_t handler,
|
|
|
|
|
void *value)
|
2001-02-20 13:31:56 +00:00
|
|
|
|
{
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
int i;
|
|
|
|
|
TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_set_close_notify", fd,
|
|
|
|
|
"close_handler=%p/%p", handler, value);
|
2001-02-20 13:31:56 +00:00
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
assert (fd != -1);
|
2001-02-20 13:31:56 +00:00
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
LOCK (notify_table_lock);
|
|
|
|
|
for (i=0; i < DIM (notify_table); i++)
|
|
|
|
|
if (notify_table[i].inuse && notify_table[i].fd == fd)
|
|
|
|
|
break;
|
|
|
|
|
if (i == DIM (notify_table))
|
|
|
|
|
for (i = 0; i < DIM (notify_table); i++)
|
|
|
|
|
if (!notify_table[i].inuse)
|
|
|
|
|
break;
|
|
|
|
|
if (i == DIM (notify_table))
|
|
|
|
|
{
|
|
|
|
|
UNLOCK (notify_table_lock);
|
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);
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
return TRACE_SYSRES (-1);
|
2001-02-20 13:31:56 +00:00
|
|
|
|
}
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
notify_table[i].fd = fd;
|
|
|
|
|
notify_table[i].handler = handler;
|
|
|
|
|
notify_table[i].value = value;
|
|
|
|
|
notify_table[i].inuse = 1;
|
|
|
|
|
UNLOCK (notify_table_lock);
|
|
|
|
|
return TRACE_SYSRES (0);
|
2001-02-20 13:31:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-11-23 15:28:15 +00:00
|
|
|
|
|
2000-11-22 17:10:48 +00:00
|
|
|
|
int
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
_gpgme_io_set_nonblocking (int fd)
|
2000-11-22 17:10:48 +00:00
|
|
|
|
{
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
TRACE (DEBUG_SYSIO, "_gpgme_io_set_nonblocking", fd);
|
|
|
|
|
return 0;
|
2000-11-22 17:10:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-06-10 13:49:19 +00:00
|
|
|
|
|
2010-06-09 13:33:31 +00:00
|
|
|
|
#ifdef HAVE_W32CE_SYSTEM
|
|
|
|
|
static char *
|
|
|
|
|
build_commandline (char **argv, int fd0, int fd0_isnull,
|
|
|
|
|
int fd1, int fd1_isnull,
|
|
|
|
|
int fd2, int fd2_isnull)
|
|
|
|
|
{
|
|
|
|
|
int i, n;
|
|
|
|
|
const char *s;
|
|
|
|
|
char *buf, *p;
|
|
|
|
|
char fdbuf[3*30];
|
|
|
|
|
|
|
|
|
|
p = fdbuf;
|
|
|
|
|
*p = 0;
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2010-06-09 13:33:31 +00:00
|
|
|
|
if (fd0 != -1)
|
|
|
|
|
{
|
|
|
|
|
if (fd0_isnull)
|
|
|
|
|
strcpy (p, "-&S0=null ");
|
|
|
|
|
else
|
2010-06-10 13:49:19 +00:00
|
|
|
|
snprintf (p, 25, "-&S0=%d ", fd_table[fd0].rvid);
|
2010-06-09 13:33:31 +00:00
|
|
|
|
p += strlen (p);
|
|
|
|
|
}
|
|
|
|
|
if (fd1 != -1)
|
|
|
|
|
{
|
|
|
|
|
if (fd1_isnull)
|
|
|
|
|
strcpy (p, "-&S1=null ");
|
|
|
|
|
else
|
2010-06-10 13:49:19 +00:00
|
|
|
|
snprintf (p, 25, "-&S1=%d ", fd_table[fd1].rvid);
|
2010-06-09 13:33:31 +00:00
|
|
|
|
p += strlen (p);
|
|
|
|
|
}
|
|
|
|
|
if (fd2 != -1)
|
|
|
|
|
{
|
|
|
|
|
if (fd2_isnull)
|
|
|
|
|
strcpy (p, "-&S2=null ");
|
|
|
|
|
else
|
2010-06-10 13:49:19 +00:00
|
|
|
|
snprintf (p, 25, "-&S2=%d ", fd_table[fd2].rvid);
|
2010-06-09 13:33:31 +00:00
|
|
|
|
p += strlen (p);
|
|
|
|
|
}
|
|
|
|
|
strcpy (p, "-&S2=null ");
|
|
|
|
|
p += strlen (p);
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2010-06-09 13:33:31 +00:00
|
|
|
|
n = strlen (fdbuf);
|
|
|
|
|
for (i=0; (s = argv[i]); i++)
|
|
|
|
|
{
|
|
|
|
|
if (!i)
|
|
|
|
|
continue; /* Ignore argv[0]. */
|
|
|
|
|
n += strlen (s) + 1 + 2; /* (1 space, 2 quoting) */
|
|
|
|
|
for (; *s; s++)
|
|
|
|
|
if (*s == '\"')
|
|
|
|
|
n++; /* Need to double inner quotes. */
|
|
|
|
|
}
|
|
|
|
|
n++;
|
|
|
|
|
buf = p = malloc (n);
|
|
|
|
|
if (! buf)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
p = stpcpy (p, fdbuf);
|
2012-09-25 13:29:49 +00:00
|
|
|
|
for (i = 0; argv[i]; i++)
|
2010-06-09 13:33:31 +00:00
|
|
|
|
{
|
|
|
|
|
if (!i)
|
|
|
|
|
continue; /* Ignore argv[0]. */
|
|
|
|
|
if (i > 1)
|
|
|
|
|
p = stpcpy (p, " ");
|
|
|
|
|
|
|
|
|
|
if (! *argv[i]) /* Empty string. */
|
|
|
|
|
p = stpcpy (p, "\"\"");
|
|
|
|
|
else if (strpbrk (argv[i], " \t\n\v\f\""))
|
|
|
|
|
{
|
|
|
|
|
p = stpcpy (p, "\"");
|
|
|
|
|
for (s = argv[i]; *s; s++)
|
|
|
|
|
{
|
|
|
|
|
*p++ = *s;
|
|
|
|
|
if (*s == '\"')
|
|
|
|
|
*p++ = *s;
|
|
|
|
|
}
|
|
|
|
|
*p++ = '\"';
|
|
|
|
|
*p = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
p = stpcpy (p, argv[i]);
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-25 13:29:49 +00:00
|
|
|
|
return buf;
|
2010-06-09 13:33:31 +00:00
|
|
|
|
}
|
|
|
|
|
#else
|
2000-11-22 17:10:48 +00:00
|
|
|
|
static char *
|
2007-01-17 19:35:06 +00:00
|
|
|
|
build_commandline (char **argv)
|
2000-11-22 17:10:48 +00:00
|
|
|
|
{
|
2007-01-17 19:35:06 +00:00
|
|
|
|
int i;
|
|
|
|
|
int n = 0;
|
|
|
|
|
char *buf;
|
|
|
|
|
char *p;
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2007-01-17 19:35:06 +00:00
|
|
|
|
/* We have to quote some things because under Windows the program
|
|
|
|
|
parses the commandline and does some unquoting. We enclose the
|
|
|
|
|
whole argument in double-quotes, and escape literal double-quotes
|
|
|
|
|
as well as backslashes with a backslash. We end up with a
|
|
|
|
|
trailing space at the end of the line, but that is harmless. */
|
|
|
|
|
for (i = 0; argv[i]; i++)
|
|
|
|
|
{
|
|
|
|
|
p = argv[i];
|
|
|
|
|
/* The leading double-quote. */
|
|
|
|
|
n++;
|
|
|
|
|
while (*p)
|
|
|
|
|
{
|
|
|
|
|
/* An extra one for each literal that must be escaped. */
|
|
|
|
|
if (*p == '\\' || *p == '"')
|
|
|
|
|
n++;
|
|
|
|
|
n++;
|
|
|
|
|
p++;
|
|
|
|
|
}
|
|
|
|
|
/* The trailing double-quote and the delimiter. */
|
|
|
|
|
n += 2;
|
|
|
|
|
}
|
|
|
|
|
/* And a trailing zero. */
|
|
|
|
|
n++;
|
|
|
|
|
|
2005-09-13 14:17:04 +00:00
|
|
|
|
buf = p = malloc (n);
|
2007-01-17 19:35:06 +00:00
|
|
|
|
if (!buf)
|
2005-09-13 14:17:04 +00:00
|
|
|
|
return NULL;
|
2007-01-17 19:35:06 +00:00
|
|
|
|
for (i = 0; argv[i]; i++)
|
2005-09-13 14:17:04 +00:00
|
|
|
|
{
|
2007-01-17 19:35:06 +00:00
|
|
|
|
char *argvp = argv[i];
|
|
|
|
|
|
|
|
|
|
*(p++) = '"';
|
|
|
|
|
while (*argvp)
|
|
|
|
|
{
|
2007-01-26 12:08:12 +00:00
|
|
|
|
if (*argvp == '\\' || *argvp == '"')
|
2007-01-17 19:35:06 +00:00
|
|
|
|
*(p++) = '\\';
|
|
|
|
|
*(p++) = *(argvp++);
|
|
|
|
|
}
|
|
|
|
|
*(p++) = '"';
|
|
|
|
|
*(p++) = ' ';
|
2001-07-31 15:21:58 +00:00
|
|
|
|
}
|
2007-01-17 19:35:06 +00:00
|
|
|
|
*(p++) = 0;
|
|
|
|
|
|
2005-09-13 14:17:04 +00:00
|
|
|
|
return buf;
|
2000-11-22 17:10:48 +00:00
|
|
|
|
}
|
2010-06-09 13:33:31 +00:00
|
|
|
|
#endif
|
2000-11-22 17:10:48 +00:00
|
|
|
|
|
|
|
|
|
|
2000-11-23 15:28:15 +00:00
|
|
|
|
int
|
2009-06-12 16:58:45 +00:00
|
|
|
|
_gpgme_io_spawn (const char *path, char *const argv[], unsigned int flags,
|
2009-11-10 Marcus Brinkmann <marcus@g10code.de>
* configure.ac: Activate UIServer if FD passing is enabled and
Assuan is available.
m4/
2009-11-10 Marcus Brinkmann <marcus@g10code.de>
* libassuan.m4: Fix LIBASSUAN_VERSION.
src/
2009-11-10 Marcus Brinkmann <marcus@g10code.de>
* Makefile.am (uiserver_components): New variable.
(main_sources): Add it.
* ops.h, key.c (_gpgme_key_append_name): Take CONVERT argument,
implement it. Adjust callers.
(gpgme_key_from_uid): New function.
* gpgme.h.in (gpgme_protocol_t): Add GPGME_PROTOCOL_DEFAULT.
(gpgme_encrypt_flags_t): Add GPGME_ENCRYPT_PREPARE,
GPGME_ENCRYPT_EXPECT_SIGN.
(gpgme_set_sub_protocol, gpgme_key_from_uid): New functions.
* libgpgme.vers, gpgme.def: Add new functions.
* gpgme.c (gpgme_set_protocol): Add UIServer protocol.
(gpgme_set_sub_protocol): New function.
(gpgme_get_protocol_name): Add UIServer and default protocol.
* assuan-support.c: Return correct error values, implement
socketpair for POSIX.
* priv-io.h, posix-io.c, w32-io.c, w32-glib-io.c,
w32-qt-io.cpp (_gpgme_io_spawn): Add ATFORK and ATFORKVALUE
arguments. Implement it for POSIX. Adjust all callers.
* engine.h, engine-backend.h (_gpgme_engine_set_protocol)
(_gpgme_engine_op_decrypt_verify): New prototypes. Adjust all
users.
* engine.c (engine_ops, gpgme_get_engine_info): Add UIServer
engine.
(_gpgme_engine_set_protocol, _gpgme_engine_op_decrypt_verify): New
function.
* decrypt-verify.c (decrypt_verify_start): Call
_gpgme_engine_op_decrypt_verify.
* util.h, posix-util.c,
w32-util.c (_gpgme_get_uiserver_socket_path): New function.
* engine-gpgsm.c (gpgsm_set_fd): Fix _gpgme_io_pipe invocation.
* gpgme-tool.c: Some support for UIServer protocol.
* engine-uiserver.c: New file.
2009-11-10 09:07:19 +00:00
|
|
|
|
struct spawn_fd_item_s *fd_list,
|
|
|
|
|
void (*atfork) (void *opaque, int reserved),
|
|
|
|
|
void *atforkvalue, pid_t *r_pid)
|
2000-11-22 17:10:48 +00:00
|
|
|
|
{
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
PROCESS_INFORMATION pi =
|
|
|
|
|
{
|
|
|
|
|
NULL, /* returns process handle */
|
|
|
|
|
0, /* returns primary thread handle */
|
|
|
|
|
0, /* returns pid */
|
2008-02-14 19:51:21 +00:00
|
|
|
|
0 /* returns tid */
|
2000-11-22 17:10:48 +00:00
|
|
|
|
};
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
int i;
|
2010-06-09 13:33:31 +00:00
|
|
|
|
|
|
|
|
|
#ifdef HAVE_W32CE_SYSTEM
|
|
|
|
|
int fd_in = -1;
|
|
|
|
|
int fd_out = -1;
|
|
|
|
|
int fd_err = -1;
|
|
|
|
|
int fd_in_isnull = 1;
|
|
|
|
|
int fd_out_isnull = 1;
|
|
|
|
|
int fd_err_isnull = 1;
|
|
|
|
|
char *cmdline;
|
2010-08-03 09:01:24 +00:00
|
|
|
|
HANDLE hd = INVALID_HANDLE_VALUE;
|
2010-06-09 13:33:31 +00:00
|
|
|
|
|
|
|
|
|
TRACE_BEG1 (DEBUG_SYSIO, "_gpgme_io_spawn", path,
|
|
|
|
|
"path=%s", path);
|
|
|
|
|
i = 0;
|
|
|
|
|
while (argv[i])
|
|
|
|
|
{
|
|
|
|
|
TRACE_LOG2 ("argv[%2i] = %s", i, argv[i]);
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (i = 0; fd_list[i].fd != -1; i++)
|
|
|
|
|
{
|
2010-06-10 13:49:19 +00:00
|
|
|
|
int fd = fd_list[i].fd;
|
|
|
|
|
|
|
|
|
|
TRACE_LOG3 ("fd_list[%2i] = fd %i, dup_to %i", i, fd, fd_list[i].dup_to);
|
|
|
|
|
if (fd < 0 || fd >= MAX_SLAFD || !fd_table[fd].used)
|
|
|
|
|
{
|
|
|
|
|
TRACE_LOG1 ("invalid fd 0x%x", fd);
|
|
|
|
|
gpg_err_set_errno (EBADF);
|
|
|
|
|
return TRACE_SYSRES (-1);
|
|
|
|
|
}
|
|
|
|
|
if (fd_table[fd].rvid == 0)
|
|
|
|
|
{
|
|
|
|
|
TRACE_LOG1 ("fd 0x%x not inheritable (not an RVID)", fd);
|
|
|
|
|
gpg_err_set_errno (EBADF);
|
|
|
|
|
return TRACE_SYSRES (-1);
|
|
|
|
|
}
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2010-06-09 13:33:31 +00:00
|
|
|
|
if (fd_list[i].dup_to == 0)
|
|
|
|
|
{
|
|
|
|
|
fd_in = fd_list[i].fd;
|
|
|
|
|
fd_in_isnull = 0;
|
|
|
|
|
}
|
|
|
|
|
else if (fd_list[i].dup_to == 1)
|
|
|
|
|
{
|
|
|
|
|
fd_out = fd_list[i].fd;
|
|
|
|
|
fd_out_isnull = 0;
|
|
|
|
|
}
|
|
|
|
|
else if (fd_list[i].dup_to == 2)
|
|
|
|
|
{
|
|
|
|
|
fd_err = fd_list[i].fd;
|
|
|
|
|
fd_err_isnull = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cmdline = build_commandline (argv, fd_in, fd_in_isnull,
|
|
|
|
|
fd_out, fd_out_isnull, fd_err, fd_err_isnull);
|
|
|
|
|
if (!cmdline)
|
|
|
|
|
{
|
|
|
|
|
TRACE_LOG1 ("build_commandline failed: %s", strerror (errno));
|
|
|
|
|
return TRACE_SYSRES (-1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!CreateProcessA (path, /* Program to start. */
|
|
|
|
|
cmdline, /* Command line arguments. */
|
|
|
|
|
NULL, /* (not supported) */
|
|
|
|
|
NULL, /* (not supported) */
|
|
|
|
|
FALSE, /* (not supported) */
|
|
|
|
|
(CREATE_SUSPENDED), /* Creation flags. */
|
|
|
|
|
NULL, /* (not supported) */
|
|
|
|
|
NULL, /* (not supported) */
|
|
|
|
|
NULL, /* (not supported) */
|
|
|
|
|
&pi /* Returns process information.*/
|
|
|
|
|
))
|
|
|
|
|
{
|
|
|
|
|
TRACE_LOG1 ("CreateProcess failed: ec=%d", (int) GetLastError ());
|
|
|
|
|
free (cmdline);
|
|
|
|
|
gpg_err_set_errno (EIO);
|
|
|
|
|
return TRACE_SYSRES (-1);
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-03 09:01:24 +00:00
|
|
|
|
/* Create arbitrary pipe descriptor to send in ASSIGN_RVID
|
|
|
|
|
commands. Errors are ignored. We don't need read or write access,
|
|
|
|
|
as ASSIGN_RVID works without any permissions, yay! */
|
|
|
|
|
hd = CreateFile (L"GPG1:", 0, 0,
|
|
|
|
|
NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
|
if (hd == INVALID_HANDLE_VALUE)
|
|
|
|
|
{
|
2010-08-04 07:47:05 +00:00
|
|
|
|
TRACE_LOG1 ("CreateFile failed (ignored): ec=%d",
|
2010-08-03 09:01:24 +00:00
|
|
|
|
(int) GetLastError ());
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-09 13:33:31 +00:00
|
|
|
|
/* Insert the inherited handles. */
|
|
|
|
|
for (i = 0; fd_list[i].fd != -1; i++)
|
|
|
|
|
{
|
|
|
|
|
/* Return the child name of this handle. */
|
2010-06-10 13:49:19 +00:00
|
|
|
|
fd_list[i].peer_name = fd_table[fd_list[i].fd].rvid;
|
2010-08-03 09:01:24 +00:00
|
|
|
|
|
|
|
|
|
if (hd != INVALID_HANDLE_VALUE)
|
|
|
|
|
{
|
|
|
|
|
DWORD data[2];
|
|
|
|
|
data[0] = (DWORD) fd_table[fd_list[i].fd].rvid;
|
|
|
|
|
data[1] = pi.dwProcessId;
|
|
|
|
|
if (!DeviceIoControl (hd, GPGCEDEV_IOCTL_ASSIGN_RVID,
|
|
|
|
|
data, sizeof (data), NULL, 0, NULL, NULL))
|
|
|
|
|
{
|
2010-08-04 07:47:05 +00:00
|
|
|
|
TRACE_LOG3 ("ASSIGN_RVID(%i, %i) failed (ignored): %i",
|
2010-08-03 09:01:24 +00:00
|
|
|
|
data[0], data[1], (int) GetLastError ());
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-06-09 13:33:31 +00:00
|
|
|
|
}
|
2010-08-03 09:01:24 +00:00
|
|
|
|
if (hd != INVALID_HANDLE_VALUE)
|
|
|
|
|
CloseHandle (hd);
|
2010-06-09 13:33:31 +00:00
|
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
SECURITY_ATTRIBUTES sec_attr;
|
|
|
|
|
STARTUPINFOA si;
|
|
|
|
|
int cr_flags = CREATE_DEFAULT_ERROR_MODE;
|
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
|
|
|
|
char **args;
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
char *arg_string;
|
|
|
|
|
/* FIXME. */
|
|
|
|
|
int debug_me = 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
|
|
|
|
int tmp_fd;
|
|
|
|
|
char *tmp_name;
|
2015-10-28 15:27:49 +00:00
|
|
|
|
const char *spawnhelper;
|
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
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
TRACE_BEG1 (DEBUG_SYSIO, "_gpgme_io_spawn", path,
|
|
|
|
|
"path=%s", path);
|
|
|
|
|
i = 0;
|
|
|
|
|
while (argv[i])
|
|
|
|
|
{
|
|
|
|
|
TRACE_LOG2 ("argv[%2i] = %s", i, argv[i]);
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
|
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 do not inherit any handles by default, and just insert those
|
|
|
|
|
handles we want the child to have afterwards. But some handle
|
|
|
|
|
values occur on the command line, and we need to move
|
|
|
|
|
stdin/out/err to the right location. So we use a wrapper program
|
|
|
|
|
which gets the information from a temporary file. */
|
|
|
|
|
if (_gpgme_mkstemp (&tmp_fd, &tmp_name) < 0)
|
|
|
|
|
{
|
|
|
|
|
TRACE_LOG1 ("_gpgme_mkstemp failed: %s", strerror (errno));
|
|
|
|
|
return TRACE_SYSRES (-1);
|
|
|
|
|
}
|
|
|
|
|
TRACE_LOG1 ("tmp_name = %s", tmp_name);
|
|
|
|
|
|
|
|
|
|
args = calloc (2 + i + 1, sizeof (*args));
|
|
|
|
|
args[0] = (char *) _gpgme_get_w32spawn_path ();
|
|
|
|
|
args[1] = tmp_name;
|
2013-05-06 18:23:47 +00:00
|
|
|
|
args[2] = (char *)path;
|
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
|
|
|
|
memcpy (&args[3], &argv[1], i * sizeof (*args));
|
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
memset (&sec_attr, 0, sizeof sec_attr);
|
|
|
|
|
sec_attr.nLength = sizeof sec_attr;
|
|
|
|
|
sec_attr.bInheritHandle = FALSE;
|
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
|
|
|
|
arg_string = build_commandline (args);
|
|
|
|
|
free (args);
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
if (!arg_string)
|
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
|
|
|
|
{
|
|
|
|
|
close (tmp_fd);
|
2010-06-09 13:33:31 +00:00
|
|
|
|
DeleteFileA (tmp_name);
|
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 TRACE_SYSRES (-1);
|
|
|
|
|
}
|
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
memset (&si, 0, sizeof si);
|
|
|
|
|
si.cb = sizeof (si);
|
|
|
|
|
si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
|
|
|
|
|
si.wShowWindow = debug_me ? SW_SHOW : SW_HIDE;
|
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
|
|
|
|
si.hStdInput = INVALID_HANDLE_VALUE;
|
|
|
|
|
si.hStdOutput = INVALID_HANDLE_VALUE;
|
|
|
|
|
si.hStdError = INVALID_HANDLE_VALUE;
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
|
2011-02-02 13:07:05 +00:00
|
|
|
|
cr_flags |= CREATE_SUSPENDED;
|
2014-04-10 09:39:14 +00:00
|
|
|
|
if ((flags & IOSPAWN_FLAG_DETACHED))
|
|
|
|
|
cr_flags |= DETACHED_PROCESS;
|
2010-06-09 13:33:31 +00:00
|
|
|
|
cr_flags |= GetPriorityClass (GetCurrentProcess ());
|
2015-10-28 15:27:49 +00:00
|
|
|
|
spawnhelper = _gpgme_get_w32spawn_path ();
|
2016-08-18 14:56:58 +00:00
|
|
|
|
if (!spawnhelper)
|
|
|
|
|
{
|
|
|
|
|
/* This is a common mistake for new users of gpgme not to include
|
|
|
|
|
gpgme-w32spawn.exe with their binary. So we want to make
|
|
|
|
|
this transparent to developers. If users have somehow messed
|
|
|
|
|
up their installation this should also be properly communicated
|
|
|
|
|
as otherwise calls to gnupg will result in unsupported protocol
|
|
|
|
|
errors that do not explain a lot. */
|
|
|
|
|
char *msg;
|
|
|
|
|
gpgrt_asprintf (&msg, "gpgme-w32spawn.exe was not found in the "
|
|
|
|
|
"detected installation directory of GpgME"
|
|
|
|
|
"\n\t\"%s\"\n\n"
|
|
|
|
|
"Crypto operations will not work.\n\n"
|
|
|
|
|
"If you see this it indicates a problem "
|
|
|
|
|
"with your installation.\n"
|
|
|
|
|
"Please report the problem to your "
|
|
|
|
|
"distributor of GpgME.\n\n"
|
2017-02-02 11:35:59 +00:00
|
|
|
|
"Developer's Note: The install dir can be "
|
2016-08-18 14:56:58 +00:00
|
|
|
|
"manually set with: gpgme_set_global_flag",
|
|
|
|
|
_gpgme_get_inst_dir ());
|
|
|
|
|
MessageBoxA (NULL, msg, "GpgME not installed correctly", MB_OK);
|
2017-02-02 11:35:59 +00:00
|
|
|
|
gpgrt_free (msg);
|
2016-08-18 14:56:58 +00:00
|
|
|
|
gpg_err_set_errno (EIO);
|
|
|
|
|
return TRACE_SYSRES (-1);
|
|
|
|
|
}
|
2015-10-28 15:27:49 +00:00
|
|
|
|
if (!CreateProcessA (spawnhelper,
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
arg_string,
|
|
|
|
|
&sec_attr, /* process security attributes */
|
|
|
|
|
&sec_attr, /* thread security attributes */
|
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
|
|
|
|
FALSE, /* inherit handles */
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
cr_flags, /* creation flags */
|
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
|
|
|
|
NULL, /* environment */
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
NULL, /* use current drive/directory */
|
|
|
|
|
&si, /* startup information */
|
|
|
|
|
&pi)) /* returns process information */
|
|
|
|
|
{
|
2015-10-28 15:27:49 +00:00
|
|
|
|
int lasterr = (int)GetLastError ();
|
|
|
|
|
TRACE_LOG1 ("CreateProcess failed: ec=%d", lasterr);
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
free (arg_string);
|
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
|
|
|
|
close (tmp_fd);
|
2010-06-09 13:33:31 +00:00
|
|
|
|
DeleteFileA (tmp_name);
|
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
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
/* FIXME: Should translate the error code. */
|
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 (EIO);
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
return TRACE_SYSRES (-1);
|
2000-12-06 12:17:10 +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
|
|
|
|
free (arg_string);
|
|
|
|
|
|
2009-06-12 16:58:45 +00:00
|
|
|
|
if (flags & IOSPAWN_FLAG_ALLOW_SET_FG)
|
|
|
|
|
_gpgme_allow_set_foreground_window ((pid_t)pi.dwProcessId);
|
|
|
|
|
|
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
|
|
|
|
/* Insert the inherited handles. */
|
|
|
|
|
for (i = 0; fd_list[i].fd != -1; i++)
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
{
|
2011-02-02 13:07:05 +00:00
|
|
|
|
int fd = fd_list[i].fd;
|
|
|
|
|
HANDLE ohd = INVALID_HANDLE_VALUE;
|
|
|
|
|
HANDLE hd = INVALID_HANDLE_VALUE;
|
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
|
|
|
|
/* Make it inheritable for the wrapper process. */
|
2011-02-02 13:07:05 +00:00
|
|
|
|
if (fd >= 0 && fd < MAX_SLAFD && fd_table[fd].used)
|
|
|
|
|
ohd = fd_table[fd].handle;
|
|
|
|
|
|
|
|
|
|
if (!DuplicateHandle (GetCurrentProcess(), ohd,
|
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
|
|
|
|
pi.hProcess, &hd, 0, TRUE, DUPLICATE_SAME_ACCESS))
|
|
|
|
|
{
|
|
|
|
|
TRACE_LOG1 ("DuplicateHandle failed: ec=%d", (int) GetLastError ());
|
|
|
|
|
TerminateProcess (pi.hProcess, 0);
|
|
|
|
|
/* Just in case TerminateProcess didn't work, let the
|
|
|
|
|
process fail on its own. */
|
|
|
|
|
ResumeThread (pi.hThread);
|
|
|
|
|
CloseHandle (pi.hThread);
|
|
|
|
|
CloseHandle (pi.hProcess);
|
|
|
|
|
|
|
|
|
|
close (tmp_fd);
|
2010-06-09 13:33:31 +00:00
|
|
|
|
DeleteFileA (tmp_name);
|
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
|
|
|
|
|
|
|
|
|
/* FIXME: Should translate the error code. */
|
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 (EIO);
|
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 TRACE_SYSRES (-1);
|
|
|
|
|
}
|
|
|
|
|
/* Return the child name of this handle. */
|
|
|
|
|
fd_list[i].peer_name = handle_to_fd (hd);
|
2000-12-06 12:17:10 +00:00
|
|
|
|
}
|
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
|
|
|
|
/* Write the handle translation information to the temporary
|
|
|
|
|
file. */
|
|
|
|
|
{
|
|
|
|
|
/* Hold roughly MAX_TRANS quadruplets of 64 bit numbers in hex
|
|
|
|
|
notation: "0xFEDCBA9876543210" with an extra white space after
|
|
|
|
|
every quadruplet. 10*(19*4 + 1) - 1 = 769. This plans ahead
|
|
|
|
|
for a time when a HANDLE is 64 bit. */
|
2009-06-12 16:58:45 +00:00
|
|
|
|
#define BUFFER_MAX 810
|
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
|
|
|
|
char line[BUFFER_MAX + 1];
|
|
|
|
|
int res;
|
|
|
|
|
int written;
|
|
|
|
|
size_t len;
|
|
|
|
|
|
2009-06-12 16:58:45 +00:00
|
|
|
|
if ((flags & IOSPAWN_FLAG_ALLOW_SET_FG))
|
|
|
|
|
strcpy (line, "~1 \n");
|
|
|
|
|
else
|
|
|
|
|
strcpy (line, "\n");
|
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 (i = 0; fd_list[i].fd != -1; i++)
|
|
|
|
|
{
|
|
|
|
|
/* Strip the newline. */
|
|
|
|
|
len = strlen (line) - 1;
|
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
|
|
|
|
/* Format is: Local name, stdin/stdout/stderr, peer name, argv idx. */
|
|
|
|
|
snprintf (&line[len], BUFFER_MAX - len, "0x%x %d 0x%x %d \n",
|
|
|
|
|
fd_list[i].fd, fd_list[i].dup_to,
|
|
|
|
|
fd_list[i].peer_name, fd_list[i].arg_loc);
|
|
|
|
|
/* Rather safe than sorry. */
|
|
|
|
|
line[BUFFER_MAX - 1] = '\n';
|
|
|
|
|
line[BUFFER_MAX] = '\0';
|
|
|
|
|
}
|
|
|
|
|
len = strlen (line);
|
|
|
|
|
written = 0;
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
res = write (tmp_fd, &line[written], len - written);
|
|
|
|
|
if (res > 0)
|
|
|
|
|
written += res;
|
|
|
|
|
}
|
|
|
|
|
while (res > 0 || (res < 0 && errno == EAGAIN));
|
|
|
|
|
}
|
|
|
|
|
close (tmp_fd);
|
|
|
|
|
/* The temporary file is deleted by the gpgme-w32spawn process
|
|
|
|
|
(hopefully). */
|
2010-06-09 13:33:31 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
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
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
TRACE_LOG4 ("CreateProcess ready: hProcess=%p, hThread=%p, "
|
|
|
|
|
"dwProcessID=%d, dwThreadId=%d",
|
2012-09-25 13:29:49 +00:00
|
|
|
|
pi.hProcess, pi.hThread,
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
(int) pi.dwProcessId, (int) pi.dwThreadId);
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2008-02-14 19:51:21 +00:00
|
|
|
|
if (r_pid)
|
|
|
|
|
*r_pid = (pid_t)pi.dwProcessId;
|
2009-06-12 16:58:45 +00:00
|
|
|
|
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
if (ResumeThread (pi.hThread) < 0)
|
|
|
|
|
TRACE_LOG1 ("ResumeThread failed: ec=%d", (int) GetLastError ());
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
if (!CloseHandle (pi.hThread))
|
|
|
|
|
TRACE_LOG1 ("CloseHandle of thread failed: ec=%d",
|
|
|
|
|
(int) GetLastError ());
|
2000-11-22 17:10:48 +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
|
|
|
|
TRACE_LOG1 ("process=%p", pi.hProcess);
|
|
|
|
|
|
|
|
|
|
/* We don't need to wait for the process. */
|
|
|
|
|
if (!CloseHandle (pi.hProcess))
|
|
|
|
|
TRACE_LOG1 ("CloseHandle of process failed: ec=%d",
|
|
|
|
|
(int) GetLastError ());
|
2007-09-27 13:01:54 +00:00
|
|
|
|
|
2009-11-05 02:39:31 +00:00
|
|
|
|
if (! (flags & IOSPAWN_FLAG_NOCLOSE))
|
|
|
|
|
{
|
|
|
|
|
for (i = 0; fd_list[i].fd != -1; i++)
|
|
|
|
|
_gpgme_io_close (fd_list[i].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
|
|
|
|
|
|
|
|
|
for (i = 0; fd_list[i].fd != -1; i++)
|
|
|
|
|
if (fd_list[i].dup_to == -1)
|
|
|
|
|
TRACE_LOG3 ("fd[%i] = 0x%x -> 0x%x", i, fd_list[i].fd,
|
|
|
|
|
fd_list[i].peer_name);
|
|
|
|
|
else
|
|
|
|
|
TRACE_LOG4 ("fd[%i] = 0x%x -> 0x%x (std%s)", i, fd_list[i].fd,
|
|
|
|
|
fd_list[i].peer_name, (fd_list[i].dup_to == 0) ? "in" :
|
|
|
|
|
((fd_list[i].dup_to == 1) ? "out" : "err"));
|
2007-09-27 13:01:54 +00:00
|
|
|
|
|
|
|
|
|
return TRACE_SYSRES (0);
|
2000-11-22 17:10:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
/* Select on the list of fds. Returns: -1 = error, 0 = timeout or
|
|
|
|
|
nothing to select, > 0 = number of signaled fds. */
|
2000-11-22 17:10:48 +00:00
|
|
|
|
int
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
_gpgme_io_select (struct io_select_fd_s *fds, size_t nfds, int nonblock)
|
2000-11-22 17:10:48 +00:00
|
|
|
|
{
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
HANDLE waitbuf[MAXIMUM_WAIT_OBJECTS];
|
|
|
|
|
int waitidx[MAXIMUM_WAIT_OBJECTS];
|
|
|
|
|
int code;
|
|
|
|
|
int nwait;
|
|
|
|
|
int i;
|
|
|
|
|
int any;
|
|
|
|
|
int count;
|
|
|
|
|
void *dbg_help;
|
|
|
|
|
TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_select", fds,
|
|
|
|
|
"nfds=%u, nonblock=%u", nfds, nonblock);
|
2000-11-23 15:28:15 +00:00
|
|
|
|
|
2013-05-06 18:23:47 +00:00
|
|
|
|
#if 0
|
2000-12-06 12:17:10 +00:00
|
|
|
|
restart:
|
2013-05-06 18:23:47 +00:00
|
|
|
|
#endif
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
TRACE_SEQ (dbg_help, "select on [ ");
|
|
|
|
|
any = 0;
|
|
|
|
|
nwait = 0;
|
|
|
|
|
count = 0;
|
|
|
|
|
for (i=0; i < nfds; i++)
|
|
|
|
|
{
|
|
|
|
|
if (fds[i].fd == -1)
|
|
|
|
|
continue;
|
|
|
|
|
fds[i].signaled = 0;
|
|
|
|
|
if (fds[i].for_read || fds[i].for_write)
|
|
|
|
|
{
|
2007-09-28 16:23:53 +00:00
|
|
|
|
if (fds[i].for_read)
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
{
|
2010-09-01 00:46:19 +00:00
|
|
|
|
struct reader_context_s *ctx = find_reader (fds[i].fd,1);
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
if (!ctx)
|
|
|
|
|
TRACE_LOG1 ("error: no reader for FD 0x%x (ignored)",
|
|
|
|
|
fds[i].fd);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (nwait >= DIM (waitbuf))
|
|
|
|
|
{
|
|
|
|
|
TRACE_END (dbg_help, "oops ]");
|
|
|
|
|
TRACE_LOG ("Too many objects for WFMO!");
|
|
|
|
|
/* FIXME: Should translate the error code. */
|
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 (EIO);
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
return TRACE_SYSRES (-1);
|
2001-01-30 11:01:41 +00:00
|
|
|
|
}
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
waitidx[nwait] = i;
|
|
|
|
|
waitbuf[nwait++] = ctx->have_data_ev;
|
2001-01-30 11:01:41 +00:00
|
|
|
|
}
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
TRACE_ADD1 (dbg_help, "r0x%x ", fds[i].fd);
|
|
|
|
|
any = 1;
|
2001-02-20 13:31:56 +00:00
|
|
|
|
}
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
else if (fds[i].for_write)
|
|
|
|
|
{
|
2010-09-01 00:46:19 +00:00
|
|
|
|
struct writer_context_s *ctx = find_writer (fds[i].fd,1);
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
if (!ctx)
|
|
|
|
|
TRACE_LOG1 ("error: no writer for FD 0x%x (ignored)",
|
|
|
|
|
fds[i].fd);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (nwait >= DIM (waitbuf))
|
|
|
|
|
{
|
|
|
|
|
TRACE_END (dbg_help, "oops ]");
|
|
|
|
|
TRACE_LOG ("Too many objects for WFMO!");
|
|
|
|
|
/* FIXME: Should translate the error code. */
|
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 (EIO);
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
return TRACE_SYSRES (-1);
|
2001-02-28 10:18:38 +00:00
|
|
|
|
}
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
waitidx[nwait] = i;
|
|
|
|
|
waitbuf[nwait++] = ctx->is_empty;
|
2001-02-28 10:18:38 +00:00
|
|
|
|
}
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
TRACE_ADD1 (dbg_help, "w0x%x ", fds[i].fd);
|
|
|
|
|
any = 1;
|
2000-11-23 15:28:15 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
TRACE_END (dbg_help, "]");
|
2012-09-25 13:29:49 +00:00
|
|
|
|
if (!any)
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
return TRACE_SYSRES (0);
|
|
|
|
|
|
|
|
|
|
code = WaitForMultipleObjects (nwait, waitbuf, 0, nonblock ? 0 : 1000);
|
|
|
|
|
if (code >= WAIT_OBJECT_0 && code < WAIT_OBJECT_0 + nwait)
|
|
|
|
|
{
|
|
|
|
|
/* This WFMO is a really silly function: It does return either
|
|
|
|
|
the index of the signaled object or if 2 objects have been
|
|
|
|
|
signalled at the same time, the index of the object with the
|
|
|
|
|
lowest object is returned - so and how do we find out how
|
|
|
|
|
many objects have been signaled???. The only solution I can
|
|
|
|
|
imagine is to test each object starting with the returned
|
|
|
|
|
index individually - how dull. */
|
|
|
|
|
any = 0;
|
|
|
|
|
for (i = code - WAIT_OBJECT_0; i < nwait; i++)
|
|
|
|
|
{
|
|
|
|
|
if (WaitForSingleObject (waitbuf[i], 0) == WAIT_OBJECT_0)
|
|
|
|
|
{
|
|
|
|
|
assert (waitidx[i] >=0 && waitidx[i] < nfds);
|
|
|
|
|
fds[waitidx[i]].signaled = 1;
|
|
|
|
|
any = 1;
|
|
|
|
|
count++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!any)
|
|
|
|
|
{
|
|
|
|
|
TRACE_LOG ("no signaled objects found after WFMO");
|
|
|
|
|
count = -1;
|
|
|
|
|
}
|
2000-11-23 15:28:15 +00:00
|
|
|
|
}
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
else if (code == WAIT_TIMEOUT)
|
|
|
|
|
TRACE_LOG ("WFMO timed out");
|
|
|
|
|
else if (code == WAIT_FAILED)
|
|
|
|
|
{
|
|
|
|
|
int le = (int) GetLastError ();
|
2010-06-10 13:49:19 +00:00
|
|
|
|
#if 0
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
if (le == ERROR_INVALID_HANDLE)
|
|
|
|
|
{
|
|
|
|
|
int k;
|
|
|
|
|
int j = handle_to_fd (waitbuf[i]);
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
TRACE_LOG1 ("WFMO invalid handle %d removed", j);
|
|
|
|
|
for (k = 0 ; k < nfds; k++)
|
|
|
|
|
{
|
|
|
|
|
if (fds[k].fd == j)
|
|
|
|
|
{
|
|
|
|
|
fds[k].for_read = fds[k].for_write = 0;
|
|
|
|
|
goto restart;
|
2001-01-30 11:01:41 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
TRACE_LOG (" oops, or not???");
|
2001-01-30 11:01:41 +00:00
|
|
|
|
}
|
2010-06-10 13:49:19 +00:00
|
|
|
|
#endif
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
TRACE_LOG1 ("WFMO failed: %d", le);
|
|
|
|
|
count = -1;
|
2001-01-30 11:01:41 +00:00
|
|
|
|
}
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
TRACE_LOG1 ("WFMO returned %d", code);
|
|
|
|
|
count = -1;
|
2000-11-23 15:28:15 +00:00
|
|
|
|
}
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
if (count > 0)
|
|
|
|
|
{
|
|
|
|
|
TRACE_SEQ (dbg_help, "select OK [ ");
|
|
|
|
|
for (i = 0; i < nfds; i++)
|
|
|
|
|
{
|
|
|
|
|
if (fds[i].fd == -1)
|
|
|
|
|
continue;
|
|
|
|
|
if ((fds[i].for_read || fds[i].for_write) && fds[i].signaled)
|
|
|
|
|
TRACE_ADD2 (dbg_help, "%c0x%x ",
|
|
|
|
|
fds[i].for_read ? 'r' : 'w', fds[i].fd);
|
2001-01-31 12:39:53 +00:00
|
|
|
|
}
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
TRACE_END (dbg_help, "]");
|
2001-01-31 12:39:53 +00:00
|
|
|
|
}
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
|
|
|
|
|
if (count < 0)
|
|
|
|
|
{
|
|
|
|
|
/* FIXME: Should determine a proper error code. */
|
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 (EIO);
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
}
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
return TRACE_SYSRES (count);
|
2000-11-23 15:28:15 +00:00
|
|
|
|
}
|
2005-03-09 11:47:21 +00:00
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
|
2005-03-09 11:47:21 +00:00
|
|
|
|
void
|
|
|
|
|
_gpgme_io_subsystem_init (void)
|
|
|
|
|
{
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
/* Nothing to do. */
|
2005-03-09 11:47:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-11-18 14:00:50 +00:00
|
|
|
|
|
|
|
|
|
/* Write the printable version of FD to the buffer BUF of length
|
|
|
|
|
BUFLEN. The printable version is the representation on the command
|
|
|
|
|
line that the child process expects. */
|
|
|
|
|
int
|
|
|
|
|
_gpgme_io_fd2str (char *buf, int buflen, int fd)
|
|
|
|
|
{
|
2010-06-09 13:33:31 +00:00
|
|
|
|
#ifdef HAVE_W32CE_SYSTEM
|
|
|
|
|
/* FIXME: For now. See above. */
|
2010-06-10 13:49:19 +00:00
|
|
|
|
if (fd < 0 || fd >= MAX_SLAFD || !fd_table[fd].used
|
|
|
|
|
|| fd_table[fd].rvid == 0)
|
|
|
|
|
fd = -1;
|
|
|
|
|
else
|
|
|
|
|
fd = fd_table[fd].rvid;
|
2010-06-09 13:33:31 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2005-11-18 14:00:50 +00:00
|
|
|
|
return snprintf (buf, buflen, "%d", fd);
|
|
|
|
|
}
|
|
|
|
|
|
2007-07-16 17:26:09 +00:00
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
_gpgme_io_dup (int fd)
|
|
|
|
|
{
|
2010-06-10 13:49:19 +00:00
|
|
|
|
int newfd;
|
2007-07-16 17:26:09 +00:00
|
|
|
|
struct reader_context_s *rd_ctx;
|
|
|
|
|
struct writer_context_s *wt_ctx;
|
2010-06-10 13:49:19 +00:00
|
|
|
|
int i;
|
2007-07-16 17:26:09 +00:00
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_dup", fd);
|
|
|
|
|
|
2010-06-10 13:49:19 +00:00
|
|
|
|
if (fd < 0 || fd >= MAX_SLAFD || !fd_table[fd].used)
|
2007-07-16 17:26:09 +00:00
|
|
|
|
{
|
2010-06-10 13:49:19 +00:00
|
|
|
|
gpg_err_set_errno (EINVAL);
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
return TRACE_SYSRES (-1);
|
2007-07-16 17:26:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-06-10 13:49:19 +00:00
|
|
|
|
newfd = new_fd();
|
|
|
|
|
if (newfd == -1)
|
|
|
|
|
return TRACE_SYSRES (-1);
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2010-06-10 13:49:19 +00:00
|
|
|
|
fd_table[newfd].handle = fd_table[fd].handle;
|
|
|
|
|
fd_table[newfd].socket = fd_table[fd].socket;
|
|
|
|
|
fd_table[newfd].rvid = fd_table[fd].rvid;
|
|
|
|
|
fd_table[newfd].dup_from = fd;
|
|
|
|
|
|
2010-09-01 00:46:19 +00:00
|
|
|
|
rd_ctx = find_reader (fd, 1);
|
2007-07-16 17:26:09 +00:00
|
|
|
|
if (rd_ctx)
|
|
|
|
|
{
|
|
|
|
|
/* No need for locking, as the only races are against the reader
|
|
|
|
|
thread itself, which doesn't touch refcount. */
|
|
|
|
|
rd_ctx->refcount++;
|
|
|
|
|
|
|
|
|
|
LOCK (reader_table_lock);
|
|
|
|
|
for (i = 0; i < reader_table_size; i++)
|
|
|
|
|
if (!reader_table[i].used)
|
|
|
|
|
break;
|
|
|
|
|
/* FIXME. */
|
|
|
|
|
assert (i != reader_table_size);
|
2010-06-10 13:49:19 +00:00
|
|
|
|
reader_table[i].fd = newfd;
|
2007-07-16 17:26:09 +00:00
|
|
|
|
reader_table[i].context = rd_ctx;
|
|
|
|
|
reader_table[i].used = 1;
|
|
|
|
|
UNLOCK (reader_table_lock);
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-01 00:46:19 +00:00
|
|
|
|
wt_ctx = find_writer (fd, 1);
|
2007-07-16 17:26:09 +00:00
|
|
|
|
if (wt_ctx)
|
|
|
|
|
{
|
|
|
|
|
/* No need for locking, as the only races are against the writer
|
|
|
|
|
thread itself, which doesn't touch refcount. */
|
|
|
|
|
wt_ctx->refcount++;
|
|
|
|
|
|
|
|
|
|
LOCK (writer_table_lock);
|
|
|
|
|
for (i = 0; i < writer_table_size; i++)
|
|
|
|
|
if (!writer_table[i].used)
|
|
|
|
|
break;
|
|
|
|
|
/* FIXME. */
|
|
|
|
|
assert (i != writer_table_size);
|
2010-06-10 13:49:19 +00:00
|
|
|
|
writer_table[i].fd = newfd;
|
2007-07-16 17:26:09 +00:00
|
|
|
|
writer_table[i].context = wt_ctx;
|
|
|
|
|
writer_table[i].used = 1;
|
|
|
|
|
UNLOCK (writer_table_lock);
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-10 13:49:19 +00:00
|
|
|
|
return TRACE_SYSRES (newfd);
|
2007-07-16 17:26:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-11-17 18:45:14 +00:00
|
|
|
|
|
2007-09-06 22:41:11 +00:00
|
|
|
|
/* The following interface is only useful for GPGME Glib and Qt. */
|
2005-11-17 18:45:14 +00:00
|
|
|
|
|
2007-09-06 22:41:11 +00:00
|
|
|
|
/* Compatibility interface, obsolete. */
|
2005-11-17 18:45:14 +00:00
|
|
|
|
void *
|
|
|
|
|
gpgme_get_giochannel (int fd)
|
|
|
|
|
{
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2005-03-09 11:47:21 +00:00
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
|
2007-09-06 22:41:11 +00:00
|
|
|
|
/* Look up the giochannel or qiodevice for file descriptor FD. */
|
|
|
|
|
void *
|
|
|
|
|
gpgme_get_fdptr (int fd)
|
|
|
|
|
{
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
assuan/
2009-04-08 Marcus Brinkmann <marcus@g10code.de>
* assuan.h (_gpgme_io_socket): New prototype.
(_ASSUAN_CUSTOM_IO, _assuan_custom_close, _assuan_custom_read)
(_assuan_custom_write, _assuan_custom_pipe, _assuan_custom_socket)
(_assuan_custom_connect): New macros.
* assuan-socket.c (_assuan_close, _assuan_sock_new)
(_assuan_sock_connect) [_ASSUAN_CUSTOM_IO]: Use custom I/O function.
* assuan-buffer.c (assuan_read_line): Do not handle EAGAIN anymore.
* assuan-client.c (_assuan_read_from_server): Likewise.
* assuan-handler.c (process_next): Likewise
* assuan-inquire.c (assuan_inquire): Likewise.
src/
2009-04-08 Marcus Brinkmann <marcus@g10code.de>
* w32-glib-io.c (giochannel_table): New members used, fd, socket.
(find_channel): Drop CREATE argument.
(new_dummy_channel_from_fd, new_channel_from_fd)
(new_channel_from_socket): New functions.
(_gpgm_io_fd2str): Implement for sockets.
(_gpgme_io_write, _gpgme_io_read): Translate EAGAIN errors
correctly.
(_gpgme_io_pipe): Fix for new channel bookkeeping.
(_gpgme_io_close, _gpgme_io_dup): Likewise.
(wsa2errno, _gpgme_io_socket, _gpgme_io_connect): New.
* w32-io.c (MAX_READERS, MAX_WRITERS): Bump up to 40.
(wsa2errno, _gpgme_io_socket, _gpgme_io_connect): New.
* w32-qt-io.cpp (_gpgme_io_socket, _gpgme_io_connect): New stubs.
* version.c [HAVE_W32_SYSTEM]: Include "windows.h.
(do_subsystem_inits) [HAVE_W32_SYSTEM]: Call WSAStartup.
* engine-assuan.c (llass_status_handler): Ignore EAGAIN errors.
2009-04-08 18:53:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
wsa2errno (int err)
|
|
|
|
|
{
|
|
|
|
|
switch (err)
|
|
|
|
|
{
|
|
|
|
|
case WSAENOTSOCK:
|
|
|
|
|
return EINVAL;
|
|
|
|
|
case WSAEWOULDBLOCK:
|
|
|
|
|
return EAGAIN;
|
|
|
|
|
case ERROR_BROKEN_PIPE:
|
|
|
|
|
return EPIPE;
|
|
|
|
|
case WSANOTINITIALISED:
|
|
|
|
|
return ENOSYS;
|
|
|
|
|
default:
|
|
|
|
|
return EIO;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
_gpgme_io_socket (int domain, int type, int proto)
|
|
|
|
|
{
|
|
|
|
|
int res;
|
2010-06-10 13:49:19 +00:00
|
|
|
|
int fd;
|
assuan/
2009-04-08 Marcus Brinkmann <marcus@g10code.de>
* assuan.h (_gpgme_io_socket): New prototype.
(_ASSUAN_CUSTOM_IO, _assuan_custom_close, _assuan_custom_read)
(_assuan_custom_write, _assuan_custom_pipe, _assuan_custom_socket)
(_assuan_custom_connect): New macros.
* assuan-socket.c (_assuan_close, _assuan_sock_new)
(_assuan_sock_connect) [_ASSUAN_CUSTOM_IO]: Use custom I/O function.
* assuan-buffer.c (assuan_read_line): Do not handle EAGAIN anymore.
* assuan-client.c (_assuan_read_from_server): Likewise.
* assuan-handler.c (process_next): Likewise
* assuan-inquire.c (assuan_inquire): Likewise.
src/
2009-04-08 Marcus Brinkmann <marcus@g10code.de>
* w32-glib-io.c (giochannel_table): New members used, fd, socket.
(find_channel): Drop CREATE argument.
(new_dummy_channel_from_fd, new_channel_from_fd)
(new_channel_from_socket): New functions.
(_gpgm_io_fd2str): Implement for sockets.
(_gpgme_io_write, _gpgme_io_read): Translate EAGAIN errors
correctly.
(_gpgme_io_pipe): Fix for new channel bookkeeping.
(_gpgme_io_close, _gpgme_io_dup): Likewise.
(wsa2errno, _gpgme_io_socket, _gpgme_io_connect): New.
* w32-io.c (MAX_READERS, MAX_WRITERS): Bump up to 40.
(wsa2errno, _gpgme_io_socket, _gpgme_io_connect): New.
* w32-qt-io.cpp (_gpgme_io_socket, _gpgme_io_connect): New stubs.
* version.c [HAVE_W32_SYSTEM]: Include "windows.h.
(do_subsystem_inits) [HAVE_W32_SYSTEM]: Call WSAStartup.
* engine-assuan.c (llass_status_handler): Ignore EAGAIN errors.
2009-04-08 18:53:57 +00:00
|
|
|
|
|
|
|
|
|
TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_socket", domain,
|
|
|
|
|
"type=%i, protp=%i", type, proto);
|
|
|
|
|
|
2010-06-10 13:49:19 +00:00
|
|
|
|
fd = new_fd();
|
|
|
|
|
if (fd == -1)
|
|
|
|
|
return TRACE_SYSRES (-1);
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
assuan/
2009-04-08 Marcus Brinkmann <marcus@g10code.de>
* assuan.h (_gpgme_io_socket): New prototype.
(_ASSUAN_CUSTOM_IO, _assuan_custom_close, _assuan_custom_read)
(_assuan_custom_write, _assuan_custom_pipe, _assuan_custom_socket)
(_assuan_custom_connect): New macros.
* assuan-socket.c (_assuan_close, _assuan_sock_new)
(_assuan_sock_connect) [_ASSUAN_CUSTOM_IO]: Use custom I/O function.
* assuan-buffer.c (assuan_read_line): Do not handle EAGAIN anymore.
* assuan-client.c (_assuan_read_from_server): Likewise.
* assuan-handler.c (process_next): Likewise
* assuan-inquire.c (assuan_inquire): Likewise.
src/
2009-04-08 Marcus Brinkmann <marcus@g10code.de>
* w32-glib-io.c (giochannel_table): New members used, fd, socket.
(find_channel): Drop CREATE argument.
(new_dummy_channel_from_fd, new_channel_from_fd)
(new_channel_from_socket): New functions.
(_gpgm_io_fd2str): Implement for sockets.
(_gpgme_io_write, _gpgme_io_read): Translate EAGAIN errors
correctly.
(_gpgme_io_pipe): Fix for new channel bookkeeping.
(_gpgme_io_close, _gpgme_io_dup): Likewise.
(wsa2errno, _gpgme_io_socket, _gpgme_io_connect): New.
* w32-io.c (MAX_READERS, MAX_WRITERS): Bump up to 40.
(wsa2errno, _gpgme_io_socket, _gpgme_io_connect): New.
* w32-qt-io.cpp (_gpgme_io_socket, _gpgme_io_connect): New stubs.
* version.c [HAVE_W32_SYSTEM]: Include "windows.h.
(do_subsystem_inits) [HAVE_W32_SYSTEM]: Call WSAStartup.
* engine-assuan.c (llass_status_handler): Ignore EAGAIN errors.
2009-04-08 18:53:57 +00:00
|
|
|
|
res = socket (domain, type, proto);
|
|
|
|
|
if (res == INVALID_SOCKET)
|
|
|
|
|
{
|
2010-06-10 13:49:19 +00:00
|
|
|
|
release_fd (fd);
|
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 (wsa2errno (WSAGetLastError ()));
|
assuan/
2009-04-08 Marcus Brinkmann <marcus@g10code.de>
* assuan.h (_gpgme_io_socket): New prototype.
(_ASSUAN_CUSTOM_IO, _assuan_custom_close, _assuan_custom_read)
(_assuan_custom_write, _assuan_custom_pipe, _assuan_custom_socket)
(_assuan_custom_connect): New macros.
* assuan-socket.c (_assuan_close, _assuan_sock_new)
(_assuan_sock_connect) [_ASSUAN_CUSTOM_IO]: Use custom I/O function.
* assuan-buffer.c (assuan_read_line): Do not handle EAGAIN anymore.
* assuan-client.c (_assuan_read_from_server): Likewise.
* assuan-handler.c (process_next): Likewise
* assuan-inquire.c (assuan_inquire): Likewise.
src/
2009-04-08 Marcus Brinkmann <marcus@g10code.de>
* w32-glib-io.c (giochannel_table): New members used, fd, socket.
(find_channel): Drop CREATE argument.
(new_dummy_channel_from_fd, new_channel_from_fd)
(new_channel_from_socket): New functions.
(_gpgm_io_fd2str): Implement for sockets.
(_gpgme_io_write, _gpgme_io_read): Translate EAGAIN errors
correctly.
(_gpgme_io_pipe): Fix for new channel bookkeeping.
(_gpgme_io_close, _gpgme_io_dup): Likewise.
(wsa2errno, _gpgme_io_socket, _gpgme_io_connect): New.
* w32-io.c (MAX_READERS, MAX_WRITERS): Bump up to 40.
(wsa2errno, _gpgme_io_socket, _gpgme_io_connect): New.
* w32-qt-io.cpp (_gpgme_io_socket, _gpgme_io_connect): New stubs.
* version.c [HAVE_W32_SYSTEM]: Include "windows.h.
(do_subsystem_inits) [HAVE_W32_SYSTEM]: Call WSAStartup.
* engine-assuan.c (llass_status_handler): Ignore EAGAIN errors.
2009-04-08 18:53:57 +00:00
|
|
|
|
return TRACE_SYSRES (-1);
|
|
|
|
|
}
|
2010-06-10 13:49:19 +00:00
|
|
|
|
fd_table[fd].socket = res;
|
assuan/
2009-04-08 Marcus Brinkmann <marcus@g10code.de>
* assuan.h (_gpgme_io_socket): New prototype.
(_ASSUAN_CUSTOM_IO, _assuan_custom_close, _assuan_custom_read)
(_assuan_custom_write, _assuan_custom_pipe, _assuan_custom_socket)
(_assuan_custom_connect): New macros.
* assuan-socket.c (_assuan_close, _assuan_sock_new)
(_assuan_sock_connect) [_ASSUAN_CUSTOM_IO]: Use custom I/O function.
* assuan-buffer.c (assuan_read_line): Do not handle EAGAIN anymore.
* assuan-client.c (_assuan_read_from_server): Likewise.
* assuan-handler.c (process_next): Likewise
* assuan-inquire.c (assuan_inquire): Likewise.
src/
2009-04-08 Marcus Brinkmann <marcus@g10code.de>
* w32-glib-io.c (giochannel_table): New members used, fd, socket.
(find_channel): Drop CREATE argument.
(new_dummy_channel_from_fd, new_channel_from_fd)
(new_channel_from_socket): New functions.
(_gpgm_io_fd2str): Implement for sockets.
(_gpgme_io_write, _gpgme_io_read): Translate EAGAIN errors
correctly.
(_gpgme_io_pipe): Fix for new channel bookkeeping.
(_gpgme_io_close, _gpgme_io_dup): Likewise.
(wsa2errno, _gpgme_io_socket, _gpgme_io_connect): New.
* w32-io.c (MAX_READERS, MAX_WRITERS): Bump up to 40.
(wsa2errno, _gpgme_io_socket, _gpgme_io_connect): New.
* w32-qt-io.cpp (_gpgme_io_socket, _gpgme_io_connect): New stubs.
* version.c [HAVE_W32_SYSTEM]: Include "windows.h.
(do_subsystem_inits) [HAVE_W32_SYSTEM]: Call WSAStartup.
* engine-assuan.c (llass_status_handler): Ignore EAGAIN errors.
2009-04-08 18:53:57 +00:00
|
|
|
|
|
2010-06-10 13:49:19 +00:00
|
|
|
|
TRACE_SUC2 ("socket=0x%x (0x%x)", fd, fd_table[fd].socket);
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2011-02-03 11:38:28 +00:00
|
|
|
|
return fd;
|
assuan/
2009-04-08 Marcus Brinkmann <marcus@g10code.de>
* assuan.h (_gpgme_io_socket): New prototype.
(_ASSUAN_CUSTOM_IO, _assuan_custom_close, _assuan_custom_read)
(_assuan_custom_write, _assuan_custom_pipe, _assuan_custom_socket)
(_assuan_custom_connect): New macros.
* assuan-socket.c (_assuan_close, _assuan_sock_new)
(_assuan_sock_connect) [_ASSUAN_CUSTOM_IO]: Use custom I/O function.
* assuan-buffer.c (assuan_read_line): Do not handle EAGAIN anymore.
* assuan-client.c (_assuan_read_from_server): Likewise.
* assuan-handler.c (process_next): Likewise
* assuan-inquire.c (assuan_inquire): Likewise.
src/
2009-04-08 Marcus Brinkmann <marcus@g10code.de>
* w32-glib-io.c (giochannel_table): New members used, fd, socket.
(find_channel): Drop CREATE argument.
(new_dummy_channel_from_fd, new_channel_from_fd)
(new_channel_from_socket): New functions.
(_gpgm_io_fd2str): Implement for sockets.
(_gpgme_io_write, _gpgme_io_read): Translate EAGAIN errors
correctly.
(_gpgme_io_pipe): Fix for new channel bookkeeping.
(_gpgme_io_close, _gpgme_io_dup): Likewise.
(wsa2errno, _gpgme_io_socket, _gpgme_io_connect): New.
* w32-io.c (MAX_READERS, MAX_WRITERS): Bump up to 40.
(wsa2errno, _gpgme_io_socket, _gpgme_io_connect): New.
* w32-qt-io.cpp (_gpgme_io_socket, _gpgme_io_connect): New stubs.
* version.c [HAVE_W32_SYSTEM]: Include "windows.h.
(do_subsystem_inits) [HAVE_W32_SYSTEM]: Call WSAStartup.
* engine-assuan.c (llass_status_handler): Ignore EAGAIN errors.
2009-04-08 18:53:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
_gpgme_io_connect (int fd, struct sockaddr *addr, int addrlen)
|
|
|
|
|
{
|
|
|
|
|
int res;
|
|
|
|
|
|
|
|
|
|
TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_connect", fd,
|
|
|
|
|
"addr=%p, addrlen=%i", addr, addrlen);
|
|
|
|
|
|
2010-06-10 13:49:19 +00:00
|
|
|
|
if (fd < 0 || fd >= MAX_SLAFD || !fd_table[fd].used)
|
|
|
|
|
{
|
|
|
|
|
gpg_err_set_errno (EBADF);
|
|
|
|
|
return TRACE_SYSRES (-1);
|
|
|
|
|
}
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2010-06-10 13:49:19 +00:00
|
|
|
|
res = connect (fd_table[fd].socket, addr, addrlen);
|
2010-01-25 16:04:27 +00:00
|
|
|
|
if (res)
|
assuan/
2009-04-08 Marcus Brinkmann <marcus@g10code.de>
* assuan.h (_gpgme_io_socket): New prototype.
(_ASSUAN_CUSTOM_IO, _assuan_custom_close, _assuan_custom_read)
(_assuan_custom_write, _assuan_custom_pipe, _assuan_custom_socket)
(_assuan_custom_connect): New macros.
* assuan-socket.c (_assuan_close, _assuan_sock_new)
(_assuan_sock_connect) [_ASSUAN_CUSTOM_IO]: Use custom I/O function.
* assuan-buffer.c (assuan_read_line): Do not handle EAGAIN anymore.
* assuan-client.c (_assuan_read_from_server): Likewise.
* assuan-handler.c (process_next): Likewise
* assuan-inquire.c (assuan_inquire): Likewise.
src/
2009-04-08 Marcus Brinkmann <marcus@g10code.de>
* w32-glib-io.c (giochannel_table): New members used, fd, socket.
(find_channel): Drop CREATE argument.
(new_dummy_channel_from_fd, new_channel_from_fd)
(new_channel_from_socket): New functions.
(_gpgm_io_fd2str): Implement for sockets.
(_gpgme_io_write, _gpgme_io_read): Translate EAGAIN errors
correctly.
(_gpgme_io_pipe): Fix for new channel bookkeeping.
(_gpgme_io_close, _gpgme_io_dup): Likewise.
(wsa2errno, _gpgme_io_socket, _gpgme_io_connect): New.
* w32-io.c (MAX_READERS, MAX_WRITERS): Bump up to 40.
(wsa2errno, _gpgme_io_socket, _gpgme_io_connect): New.
* w32-qt-io.cpp (_gpgme_io_socket, _gpgme_io_connect): New stubs.
* version.c [HAVE_W32_SYSTEM]: Include "windows.h.
(do_subsystem_inits) [HAVE_W32_SYSTEM]: Call WSAStartup.
* engine-assuan.c (llass_status_handler): Ignore EAGAIN errors.
2009-04-08 18:53:57 +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 (wsa2errno (WSAGetLastError ()));
|
assuan/
2009-04-08 Marcus Brinkmann <marcus@g10code.de>
* assuan.h (_gpgme_io_socket): New prototype.
(_ASSUAN_CUSTOM_IO, _assuan_custom_close, _assuan_custom_read)
(_assuan_custom_write, _assuan_custom_pipe, _assuan_custom_socket)
(_assuan_custom_connect): New macros.
* assuan-socket.c (_assuan_close, _assuan_sock_new)
(_assuan_sock_connect) [_ASSUAN_CUSTOM_IO]: Use custom I/O function.
* assuan-buffer.c (assuan_read_line): Do not handle EAGAIN anymore.
* assuan-client.c (_assuan_read_from_server): Likewise.
* assuan-handler.c (process_next): Likewise
* assuan-inquire.c (assuan_inquire): Likewise.
src/
2009-04-08 Marcus Brinkmann <marcus@g10code.de>
* w32-glib-io.c (giochannel_table): New members used, fd, socket.
(find_channel): Drop CREATE argument.
(new_dummy_channel_from_fd, new_channel_from_fd)
(new_channel_from_socket): New functions.
(_gpgm_io_fd2str): Implement for sockets.
(_gpgme_io_write, _gpgme_io_read): Translate EAGAIN errors
correctly.
(_gpgme_io_pipe): Fix for new channel bookkeeping.
(_gpgme_io_close, _gpgme_io_dup): Likewise.
(wsa2errno, _gpgme_io_socket, _gpgme_io_connect): New.
* w32-io.c (MAX_READERS, MAX_WRITERS): Bump up to 40.
(wsa2errno, _gpgme_io_socket, _gpgme_io_connect): New.
* w32-qt-io.cpp (_gpgme_io_socket, _gpgme_io_connect): New stubs.
* version.c [HAVE_W32_SYSTEM]: Include "windows.h.
(do_subsystem_inits) [HAVE_W32_SYSTEM]: Call WSAStartup.
* engine-assuan.c (llass_status_handler): Ignore EAGAIN errors.
2009-04-08 18:53:57 +00:00
|
|
|
|
return TRACE_SYSRES (-1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRACE_SUC ();
|
|
|
|
|
}
|