2007-10-02 12:02:08 +00:00
|
|
|
|
/* w32-qt-io.c - W32 Glib I/O functions
|
2007-09-06 22:41:11 +00:00
|
|
|
|
Copyright (C) 2000 Werner Koch (dd9jn)
|
|
|
|
|
Copyright (C) 2001, 2002, 2004, 2005, 2007 g10 Code GmbH
|
|
|
|
|
|
|
|
|
|
This file is part of GPGME.
|
2014-04-10 09:39:14 +00:00
|
|
|
|
|
2007-09-06 22:41:11 +00:00
|
|
|
|
GPGME is free software; you can redistribute it and/or modify it
|
|
|
|
|
under the terms of the GNU Lesser General Public License as
|
|
|
|
|
published by the Free Software Foundation; either version 2.1 of
|
|
|
|
|
the License, or (at your option) any later version.
|
2014-04-10 09:39:14 +00:00
|
|
|
|
|
2007-09-06 22:41:11 +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
|
|
|
|
|
Lesser General Public License for more details.
|
2014-04-10 09:39:14 +00:00
|
|
|
|
|
2007-09-06 22:41:11 +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. */
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
#include <config.h>
|
|
|
|
|
#endif
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <sys/time.h>
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
#include <windows.h>
|
|
|
|
|
#include <io.h>
|
|
|
|
|
|
|
|
|
|
#include "kdpipeiodevice.h"
|
|
|
|
|
|
|
|
|
|
extern "C"
|
|
|
|
|
{
|
|
|
|
|
#include "util.h"
|
|
|
|
|
#include "priv-io.h"
|
|
|
|
|
#include "sema.h"
|
|
|
|
|
#include "debug.h"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifndef O_BINARY
|
|
|
|
|
#ifdef _O_BINARY
|
|
|
|
|
#define O_BINARY _O_BINARY
|
|
|
|
|
#else
|
|
|
|
|
#define O_BINARY 0
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
2007-09-25 16:34:02 +00:00
|
|
|
|
using _gpgme_::KDPipeIODevice;
|
|
|
|
|
|
2007-09-06 22:41:11 +00:00
|
|
|
|
|
|
|
|
|
/* This file is an ugly hack to get GPGME working with Qt on Windows
|
|
|
|
|
targets. On Windows, you can not select() on file descriptors.
|
2007-09-25 16:34:02 +00:00
|
|
|
|
|
2007-09-06 22:41:11 +00:00
|
|
|
|
The only way to check if there is something to read is to read
|
|
|
|
|
something. This means that GPGME can not let Qt check for data
|
|
|
|
|
without letting Qt also handle the data on Windows targets.
|
|
|
|
|
|
|
|
|
|
The ugly consequence is that we need to work on QIODevices in
|
|
|
|
|
GPGME, creating a Qt dependency. Also, we need to export an
|
|
|
|
|
interface for the application to get at GPGME's QIODevices. There
|
|
|
|
|
is no good way to abstract all this with callbacks, because the
|
|
|
|
|
whole thing is also interconnected with the creation of pipes and
|
|
|
|
|
child processes.
|
|
|
|
|
|
|
|
|
|
The following rule applies only to this I/O backend:
|
|
|
|
|
|
|
|
|
|
* ALL operations must use the user defined event loop. GPGME can
|
|
|
|
|
not anymore provide its own event loop. This is mostly a sanity
|
|
|
|
|
requirement: Although we have in theory all information we need to
|
|
|
|
|
make the GPGME W32 code for select still work, it would be a big
|
|
|
|
|
complication and require changes throughout GPGME.
|
|
|
|
|
|
|
|
|
|
Eventually, we probably have to bite the bullet and make some
|
|
|
|
|
really nice callback interfaces to let the user control all this at
|
|
|
|
|
a per-context level. */
|
|
|
|
|
|
2007-10-04 14:09:58 +00:00
|
|
|
|
#define MAX_SLAFD 1024
|
2007-09-27 22:21:10 +00:00
|
|
|
|
|
|
|
|
|
struct DeviceEntry {
|
2007-10-05 00:20:43 +00:00
|
|
|
|
DeviceEntry() : iodev( 0 ), refCount( 1 ), blocking( true ) {}
|
2007-10-04 14:09:58 +00:00
|
|
|
|
KDPipeIODevice* iodev;
|
2007-10-05 00:20:43 +00:00
|
|
|
|
bool blocking;
|
2007-09-27 22:21:10 +00:00
|
|
|
|
mutable int refCount;
|
|
|
|
|
void ref() const { ++refCount; }
|
2007-10-04 14:09:58 +00:00
|
|
|
|
int unref() const { assert( refCount > 0 ); return --refCount; }
|
2007-09-27 22:21:10 +00:00
|
|
|
|
};
|
2007-09-06 22:41:11 +00:00
|
|
|
|
|
2007-09-27 22:21:10 +00:00
|
|
|
|
DeviceEntry* iodevice_table[MAX_SLAFD];
|
2007-09-06 22:41:11 +00:00
|
|
|
|
|
|
|
|
|
|
2007-10-04 14:09:58 +00:00
|
|
|
|
static KDPipeIODevice *
|
2007-09-06 22:41:11 +00:00
|
|
|
|
find_channel (int fd, int create)
|
|
|
|
|
{
|
2007-10-04 14:09:58 +00:00
|
|
|
|
assert( fd < MAX_SLAFD );
|
2007-09-06 22:41:11 +00:00
|
|
|
|
if (fd < 0 || fd >= MAX_SLAFD)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
if (create && !iodevice_table[fd])
|
2007-09-27 22:21:10 +00:00
|
|
|
|
{
|
|
|
|
|
DeviceEntry* entry = new DeviceEntry;
|
|
|
|
|
entry->iodev = new KDPipeIODevice
|
|
|
|
|
(fd, QIODevice::ReadWrite|QIODevice::Unbuffered);
|
2014-04-10 09:39:14 +00:00
|
|
|
|
iodevice_table[fd] = entry;
|
2007-09-27 22:21:10 +00:00
|
|
|
|
}
|
|
|
|
|
return iodevice_table[fd] ? iodevice_table[fd]->iodev : 0;
|
2007-09-06 22:41:11 +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
|
2007-10-04 14:09:58 +00:00
|
|
|
|
_gpgme_io_fd2str (char *buf, int buflen, int fd)
|
2007-09-06 22:41:11 +00:00
|
|
|
|
{
|
2007-10-04 14:09:58 +00:00
|
|
|
|
return snprintf (buf, buflen, "%d", (long)_get_osfhandle( fd ) );
|
2007-09-06 22:41:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
_gpgme_io_subsystem_init (void)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static struct
|
|
|
|
|
{
|
|
|
|
|
_gpgme_close_notify_handler_t handler;
|
|
|
|
|
void *value;
|
|
|
|
|
} notify_table[MAX_SLAFD];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
_gpgme_io_read (int fd, void *buffer, size_t count)
|
|
|
|
|
{
|
|
|
|
|
int saved_errno = 0;
|
|
|
|
|
qint64 nread;
|
2007-10-04 14:09:58 +00:00
|
|
|
|
KDPipeIODevice *chan;
|
2007-09-06 22:41:11 +00:00
|
|
|
|
TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_read", fd,
|
|
|
|
|
"buffer=%p, count=%u", buffer, count);
|
|
|
|
|
|
|
|
|
|
chan = find_channel (fd, 0);
|
|
|
|
|
if (!chan)
|
|
|
|
|
{
|
|
|
|
|
TRACE_LOG ("no channel registered");
|
|
|
|
|
errno = EINVAL;
|
|
|
|
|
return TRACE_SYSRES (-1);
|
|
|
|
|
}
|
|
|
|
|
TRACE_LOG1 ("channel %p", chan);
|
2007-10-05 00:20:43 +00:00
|
|
|
|
if ( iodevice_table[fd] && !iodevice_table[fd]->blocking && chan->readWouldBlock() ) {
|
|
|
|
|
errno = EAGAIN;
|
|
|
|
|
return TRACE_SYSRES( -1 );
|
|
|
|
|
}
|
2014-04-10 09:39:14 +00:00
|
|
|
|
|
2007-09-07 19:38:50 +00:00
|
|
|
|
nread = chan->read ((char *) buffer, count);
|
|
|
|
|
if (nread < 0)
|
|
|
|
|
{
|
|
|
|
|
TRACE_LOG1 ("err %s", qPrintable (chan->errorString ()));
|
|
|
|
|
saved_errno = EIO;
|
|
|
|
|
nread = -1;
|
2007-09-06 22:41:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-09-07 19:38:50 +00:00
|
|
|
|
TRACE_LOGBUF ((char *) buffer, nread);
|
2007-09-06 22:41:11 +00:00
|
|
|
|
|
|
|
|
|
errno = saved_errno;
|
|
|
|
|
return TRACE_SYSRES (nread);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
_gpgme_io_write (int fd, const void *buffer, size_t count)
|
|
|
|
|
{
|
|
|
|
|
qint64 nwritten;
|
2007-10-04 14:09:58 +00:00
|
|
|
|
KDPipeIODevice *chan;
|
2007-09-06 22:41:11 +00:00
|
|
|
|
TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_write", fd,
|
|
|
|
|
"buffer=%p, count=%u", buffer, count);
|
2007-09-07 19:38:50 +00:00
|
|
|
|
TRACE_LOGBUF ((char *) buffer, count);
|
2007-09-06 22:41:11 +00:00
|
|
|
|
|
|
|
|
|
chan = find_channel (fd, 0);
|
|
|
|
|
if (!chan)
|
|
|
|
|
{
|
|
|
|
|
TRACE_LOG ("fd %d: no channel registered");
|
|
|
|
|
errno = EINVAL;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2007-10-05 00:20:43 +00:00
|
|
|
|
if ( iodevice_table[fd] && !iodevice_table[fd]->blocking && chan->writeWouldBlock() )
|
|
|
|
|
{
|
|
|
|
|
errno = EAGAIN;
|
|
|
|
|
return TRACE_SYSRES( -1 );
|
|
|
|
|
}
|
2007-09-07 19:38:50 +00:00
|
|
|
|
nwritten = chan->write ((char *) buffer, count);
|
2007-09-06 22:41:11 +00:00
|
|
|
|
|
|
|
|
|
if (nwritten < 0)
|
|
|
|
|
{
|
|
|
|
|
nwritten = -1;
|
|
|
|
|
errno = EIO;
|
2007-09-07 19:38:50 +00:00
|
|
|
|
return TRACE_SYSRES(-1);
|
2007-09-06 22:41:11 +00:00
|
|
|
|
}
|
|
|
|
|
errno = 0;
|
|
|
|
|
return TRACE_SYSRES (nwritten);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
_gpgme_io_pipe (int filedes[2], int inherit_idx)
|
|
|
|
|
{
|
2007-10-04 14:09:58 +00:00
|
|
|
|
KDPipeIODevice *chan;
|
2007-09-06 22:41:11 +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-09-06 22:41:11 +00:00
|
|
|
|
|
|
|
|
|
#define PIPEBUF_SIZE 4096
|
|
|
|
|
if (_pipe (filedes, PIPEBUF_SIZE, O_NOINHERIT | O_BINARY) == -1)
|
|
|
|
|
return TRACE_SYSRES (-1);
|
|
|
|
|
|
|
|
|
|
/* Make one end inheritable. */
|
|
|
|
|
if (inherit_idx == 0)
|
|
|
|
|
{
|
|
|
|
|
int new_read;
|
|
|
|
|
|
|
|
|
|
new_read = _dup (filedes[0]);
|
|
|
|
|
_close (filedes[0]);
|
|
|
|
|
filedes[0] = new_read;
|
|
|
|
|
|
|
|
|
|
if (new_read < 0)
|
|
|
|
|
{
|
|
|
|
|
_close (filedes[1]);
|
|
|
|
|
return TRACE_SYSRES (-1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (inherit_idx == 1)
|
|
|
|
|
{
|
|
|
|
|
int new_write;
|
|
|
|
|
|
|
|
|
|
new_write = _dup (filedes[1]);
|
|
|
|
|
_close (filedes[1]);
|
|
|
|
|
filedes[1] = new_write;
|
|
|
|
|
|
|
|
|
|
if (new_write < 0)
|
|
|
|
|
{
|
|
|
|
|
_close (filedes[0]);
|
|
|
|
|
return TRACE_SYSRES (-1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Now we have a pipe with the right end inheritable. The other end
|
|
|
|
|
should have a giochannel. */
|
2007-09-27 22:21:10 +00:00
|
|
|
|
|
2007-09-06 22:41:11 +00:00
|
|
|
|
chan = find_channel (filedes[1 - inherit_idx], 1);
|
2007-09-27 22:21:10 +00:00
|
|
|
|
|
2007-09-06 22:41:11 +00:00
|
|
|
|
if (!chan)
|
|
|
|
|
{
|
|
|
|
|
int saved_errno = errno;
|
|
|
|
|
_close (filedes[0]);
|
|
|
|
|
_close (filedes[1]);
|
|
|
|
|
errno = saved_errno;
|
|
|
|
|
return TRACE_SYSRES (-1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRACE_SUC5 ("read=0x%x/%p, write=0x%x/%p, channel=%p",
|
|
|
|
|
filedes[0], (HANDLE) _get_osfhandle (filedes[0]),
|
|
|
|
|
filedes[1], (HANDLE) _get_osfhandle (filedes[1]),
|
|
|
|
|
chan);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
_gpgme_io_close (int fd)
|
|
|
|
|
{
|
2007-10-04 14:09:58 +00:00
|
|
|
|
KDPipeIODevice *chan;
|
2007-09-06 22:41:11 +00:00
|
|
|
|
TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_close", fd);
|
|
|
|
|
|
|
|
|
|
if (fd < 0 || fd >= MAX_SLAFD)
|
|
|
|
|
{
|
|
|
|
|
errno = EBADF;
|
|
|
|
|
return TRACE_SYSRES (-1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* First call the notify handler. */
|
|
|
|
|
if (notify_table[fd].handler)
|
|
|
|
|
{
|
|
|
|
|
notify_table[fd].handler (fd, notify_table[fd].value);
|
|
|
|
|
notify_table[fd].handler = NULL;
|
|
|
|
|
notify_table[fd].value = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-10 09:39:14 +00:00
|
|
|
|
/* Then do the close. */
|
|
|
|
|
|
2007-09-27 22:21:10 +00:00
|
|
|
|
DeviceEntry* const entry = iodevice_table[fd];
|
2007-10-04 14:09:58 +00:00
|
|
|
|
if ( entry ) {
|
|
|
|
|
if ( entry->unref() == 0 ) {
|
|
|
|
|
entry->iodev->close();
|
|
|
|
|
delete entry->iodev;
|
|
|
|
|
delete entry;
|
|
|
|
|
iodevice_table[fd] = 0;
|
2007-09-27 22:21:10 +00:00
|
|
|
|
}
|
2007-10-04 14:09:58 +00:00
|
|
|
|
} else {
|
|
|
|
|
_close( fd );
|
2007-09-27 22:21:10 +00:00
|
|
|
|
}
|
2007-10-04 14:09:58 +00:00
|
|
|
|
|
2014-04-10 09:39:14 +00:00
|
|
|
|
|
2007-10-04 14:09:58 +00:00
|
|
|
|
|
2007-09-06 22:41:11 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
_gpgme_io_set_close_notify (int fd, _gpgme_close_notify_handler_t handler,
|
|
|
|
|
void *value)
|
|
|
|
|
{
|
|
|
|
|
TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_set_close_notify", fd,
|
|
|
|
|
"close_handler=%p/%p", handler, value);
|
|
|
|
|
|
|
|
|
|
assert (fd != -1);
|
|
|
|
|
|
|
|
|
|
if (fd < 0 || fd >= (int) DIM (notify_table))
|
|
|
|
|
{
|
|
|
|
|
errno = EINVAL;
|
|
|
|
|
return TRACE_SYSRES (-1);
|
|
|
|
|
}
|
|
|
|
|
notify_table[fd].handler = handler;
|
|
|
|
|
notify_table[fd].value = value;
|
|
|
|
|
return TRACE_SYSRES (0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
_gpgme_io_set_nonblocking (int fd)
|
|
|
|
|
{
|
2007-10-05 00:20:43 +00:00
|
|
|
|
DeviceEntry* const entry = iodevice_table[fd];
|
|
|
|
|
assert( entry );
|
2014-04-10 09:39:14 +00:00
|
|
|
|
entry->blocking = false;
|
2007-09-06 22:41:11 +00:00
|
|
|
|
TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_set_nonblocking", fd);
|
|
|
|
|
return TRACE_SYSRES (0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static char *
|
|
|
|
|
build_commandline (char **argv)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
int n = 0;
|
|
|
|
|
char *buf;
|
|
|
|
|
char *p;
|
2014-04-10 09:39:14 +00:00
|
|
|
|
|
2007-09-06 22:41:11 +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)
|
2007-09-27 22:21:10 +00:00
|
|
|
|
{
|
2007-09-06 22:41:11 +00:00
|
|
|
|
/* 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++;
|
|
|
|
|
|
2007-09-07 19:38:50 +00:00
|
|
|
|
buf = p = (char *) malloc (n);
|
2007-09-06 22:41:11 +00:00
|
|
|
|
if (!buf)
|
|
|
|
|
return NULL;
|
|
|
|
|
for (i = 0; argv[i]; i++)
|
|
|
|
|
{
|
|
|
|
|
char *argvp = argv[i];
|
|
|
|
|
|
|
|
|
|
*(p++) = '"';
|
|
|
|
|
while (*argvp)
|
|
|
|
|
{
|
|
|
|
|
if (*argvp == '\\' || *argvp == '"')
|
|
|
|
|
*(p++) = '\\';
|
|
|
|
|
*(p++) = *(argvp++);
|
|
|
|
|
}
|
|
|
|
|
*(p++) = '"';
|
|
|
|
|
*(p++) = ' ';
|
|
|
|
|
}
|
|
|
|
|
*(p++) = 0;
|
|
|
|
|
|
|
|
|
|
return buf;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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)
|
2007-09-06 22:41:11 +00:00
|
|
|
|
{
|
|
|
|
|
SECURITY_ATTRIBUTES sec_attr;
|
|
|
|
|
PROCESS_INFORMATION pi =
|
|
|
|
|
{
|
|
|
|
|
NULL, /* returns process handle */
|
|
|
|
|
0, /* returns primary thread handle */
|
|
|
|
|
0, /* returns pid */
|
|
|
|
|
0 /* returns tid */
|
|
|
|
|
};
|
|
|
|
|
STARTUPINFO si;
|
|
|
|
|
int cr_flags = CREATE_DEFAULT_ERROR_MODE
|
|
|
|
|
| GetPriorityClass (GetCurrentProcess ());
|
|
|
|
|
int 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
|
|
|
|
char **args;
|
2007-09-06 22:41:11 +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;
|
|
|
|
|
|
2007-09-06 22:41:11 +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++;
|
|
|
|
|
}
|
2014-04-10 09:39:14 +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
|
|
|
|
/* 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 = (char **) calloc (2 + i + 1, sizeof (*args));
|
|
|
|
|
args[0] = (char *) _gpgme_get_w32spawn_path ();
|
|
|
|
|
args[1] = tmp_name;
|
|
|
|
|
args[2] = const_cast<char *>(path);
|
|
|
|
|
memcpy (&args[3], &argv[1], i * sizeof (*args));
|
|
|
|
|
|
2007-09-06 22:41:11 +00:00
|
|
|
|
memset (&sec_attr, 0, sizeof sec_attr);
|
|
|
|
|
sec_attr.nLength = sizeof sec_attr;
|
|
|
|
|
sec_attr.bInheritHandle = FALSE;
|
2014-04-10 09:39:14 +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-09-06 22:41:11 +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);
|
|
|
|
|
DeleteFile (tmp_name);
|
|
|
|
|
return TRACE_SYSRES (-1);
|
|
|
|
|
}
|
2014-04-10 09:39:14 +00:00
|
|
|
|
|
2007-09-06 22:41:11 +00:00
|
|
|
|
memset (&si, 0, sizeof si);
|
|
|
|
|
si.cb = sizeof (si);
|
|
|
|
|
si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
|
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.wShowWindow = debug_me ? SW_SHOW : SW_HIDE;
|
|
|
|
|
si.hStdInput = INVALID_HANDLE_VALUE;
|
|
|
|
|
si.hStdOutput = INVALID_HANDLE_VALUE;
|
|
|
|
|
si.hStdError = INVALID_HANDLE_VALUE;
|
|
|
|
|
|
2007-09-06 22:41:11 +00:00
|
|
|
|
cr_flags |= CREATE_SUSPENDED;
|
2014-04-10 09:39:14 +00:00
|
|
|
|
if ((flags & IOSPAWN_FLAG_DETACHED))
|
|
|
|
|
cr_flags |= DETACHED_PROCESS;
|
assuan/
2008-06-25 Marcus Brinkmann <marcus@g10code.de>
* assuan-pipe-connect.c (struct spawn_fd_item_s): Add new members.
(HANDLE_TRANSLATION): New macro.
(pipe_connect_gpgme): Adjust caller of _gpgme_io_spawn.
[HANDLE_TRANSLATION]: Return translated handles.
gpgme/
2008-06-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme-w32spawn.c: New file.
* Makefile.am (libexec_PROGRAMS) [HAVE_W32_SYSTEM]: New variable
with gpgme-w32spawn.
* engine-gpgsm.c (gpgsm_new): Use server translated handles.
(gpgsm_set_locale): Return early if locale value is NULL.
* util.h (_gpgme_mkstemp)
(_gpgme_get_w32spawn_path) [HAVE_W32_SYSTEM]: New function
prototypes.
* w32-util.c: Include <stdint.h>, <sys/stat.h> and <unistd.h>.
(letters, mkstemp, _gpgme_mkstemp, _gpgme_get_w32spawn_path): New
functions.
* rungpg.c (gpg_decrypt, gpg_encrypt, gpg_encrypt_sign)
(gpg_genkey, gpg_import, gpg_verify, gpg_sign): Pass data over
special filename FD rather than stdin.
(struct arg_and_data_s): Add member ARG_LOCP.
(struct fd_data_map_s): Add member ARG_LOC.
(struct engine_gpg): Add member ARG_LOC to status and colon.
(_add_arg, add_arg_with_locp): New function.
(add_arg_ext): Reimplement in terms of _add_arg.
(gpg_new): Remember argument location for status FD.
(build_argv): Set argument location if requested. Also set
argument location of fd_data_map for data items.
(start): Adjust caller of _gpgme_io_spawn.
* priv-io.h (struct spawn_fd_item_s): Add members peer_name and
arg_loc.
(_gpgme_io_spawn): Remove parent fd list argument.
* posix-io.c (get_max_fds): New function.
(_gpgme_io_dup): Add tracing.
(_gpgme_io_spawn): Remove parent fd list. Change meaning of child
fd list to contain all child fds that should be inherited. Close
all other file descriptors after fork.
* w32-io.c, w32-glib-io.c, w32-qt-io.c(_gpgme_io_spawn): Remove
parent fd list. Change meaning of child fd list to contain all
child fds that should be inherited. Do not inherit any file
descriptors, but DuplicateHandle them. Spawn process through
wrapper process. Provide wrapper process with a temporary file
containing handle translation data. Return translated handle
names.
* w32-io.c (reader): Add more tracing output.
(_gpgme_io_read): Likewise.
* engine-gpgconf.c (gpgconf_read): Adjust caller of
_gpgme_io_spawn.
* version.c (_gpgme_get_program_version): Likewise.
2008-06-25 16:52:31 +00:00
|
|
|
|
if (!CreateProcessA (_gpgme_get_w32spawn_path (),
|
2007-09-06 22:41:11 +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-09-06 22:41:11 +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-09-06 22:41:11 +00:00
|
|
|
|
NULL, /* use current drive/directory */
|
|
|
|
|
&si, /* startup information */
|
|
|
|
|
&pi)) /* returns process information */
|
|
|
|
|
{
|
|
|
|
|
TRACE_LOG1 ("CreateProcess failed: ec=%d", (int) GetLastError ());
|
|
|
|
|
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);
|
|
|
|
|
DeleteFile (tmp_name);
|
|
|
|
|
|
2007-09-06 22:41:11 +00:00
|
|
|
|
/* FIXME: Should translate the error code. */
|
|
|
|
|
errno = EIO;
|
|
|
|
|
return TRACE_SYSRES (-1);
|
|
|
|
|
}
|
assuan/
2008-06-25 Marcus Brinkmann <marcus@g10code.de>
* assuan-pipe-connect.c (struct spawn_fd_item_s): Add new members.
(HANDLE_TRANSLATION): New macro.
(pipe_connect_gpgme): Adjust caller of _gpgme_io_spawn.
[HANDLE_TRANSLATION]: Return translated handles.
gpgme/
2008-06-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme-w32spawn.c: New file.
* Makefile.am (libexec_PROGRAMS) [HAVE_W32_SYSTEM]: New variable
with gpgme-w32spawn.
* engine-gpgsm.c (gpgsm_new): Use server translated handles.
(gpgsm_set_locale): Return early if locale value is NULL.
* util.h (_gpgme_mkstemp)
(_gpgme_get_w32spawn_path) [HAVE_W32_SYSTEM]: New function
prototypes.
* w32-util.c: Include <stdint.h>, <sys/stat.h> and <unistd.h>.
(letters, mkstemp, _gpgme_mkstemp, _gpgme_get_w32spawn_path): New
functions.
* rungpg.c (gpg_decrypt, gpg_encrypt, gpg_encrypt_sign)
(gpg_genkey, gpg_import, gpg_verify, gpg_sign): Pass data over
special filename FD rather than stdin.
(struct arg_and_data_s): Add member ARG_LOCP.
(struct fd_data_map_s): Add member ARG_LOC.
(struct engine_gpg): Add member ARG_LOC to status and colon.
(_add_arg, add_arg_with_locp): New function.
(add_arg_ext): Reimplement in terms of _add_arg.
(gpg_new): Remember argument location for status FD.
(build_argv): Set argument location if requested. Also set
argument location of fd_data_map for data items.
(start): Adjust caller of _gpgme_io_spawn.
* priv-io.h (struct spawn_fd_item_s): Add members peer_name and
arg_loc.
(_gpgme_io_spawn): Remove parent fd list argument.
* posix-io.c (get_max_fds): New function.
(_gpgme_io_dup): Add tracing.
(_gpgme_io_spawn): Remove parent fd list. Change meaning of child
fd list to contain all child fds that should be inherited. Close
all other file descriptors after fork.
* w32-io.c, w32-glib-io.c, w32-qt-io.c(_gpgme_io_spawn): Remove
parent fd list. Change meaning of child fd list to contain all
child fds that should be inherited. Do not inherit any file
descriptors, but DuplicateHandle them. Spawn process through
wrapper process. Provide wrapper process with a temporary file
containing handle translation data. Return translated handle
names.
* w32-io.c (reader): Add more tracing output.
(_gpgme_io_read): Likewise.
* engine-gpgconf.c (gpgconf_read): Adjust caller of
_gpgme_io_spawn.
* version.c (_gpgme_get_program_version): Likewise.
2008-06-25 16:52:31 +00:00
|
|
|
|
|
|
|
|
|
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-09-06 22:41:11 +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
|
|
|
|
HANDLE hd;
|
|
|
|
|
|
|
|
|
|
if (!DuplicateHandle (GetCurrentProcess(),
|
|
|
|
|
(HANDLE) _get_osfhandle (fd_list[i].fd),
|
|
|
|
|
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);
|
|
|
|
|
DeleteFile (tmp_name);
|
2007-10-04 14:09:58 +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
|
|
|
|
/* FIXME: Should translate the error code. */
|
|
|
|
|
errno = EIO;
|
|
|
|
|
return TRACE_SYSRES (-1);
|
|
|
|
|
}
|
|
|
|
|
/* Return the child name of this handle. */
|
|
|
|
|
fd_list[i].peer_name = (int) hd;
|
|
|
|
|
}
|
2014-04-10 09:39:14 +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. */
|
|
|
|
|
#define BUFFER_MAX 800
|
|
|
|
|
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;
|
2014-04-10 09:39:14 +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). */
|
2014-04-10 09:39:14 +00:00
|
|
|
|
|
2007-09-06 22:41:11 +00:00
|
|
|
|
TRACE_LOG4 ("CreateProcess ready: hProcess=%p, hThread=%p, "
|
|
|
|
|
"dwProcessID=%d, dwThreadId=%d",
|
2014-04-10 09:39:14 +00:00
|
|
|
|
pi.hProcess, pi.hThread,
|
2007-09-06 22:41:11 +00:00
|
|
|
|
(int) pi.dwProcessId, (int) pi.dwThreadId);
|
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
|
|
|
|
|
2008-02-14 19:51:21 +00:00
|
|
|
|
if (r_pid)
|
|
|
|
|
*r_pid = (pid_t)pi.dwProcessId;
|
2014-04-10 09:39:14 +00:00
|
|
|
|
|
2007-09-06 22:41:11 +00:00
|
|
|
|
if (ResumeThread (pi.hThread) < 0)
|
|
|
|
|
TRACE_LOG1 ("ResumeThread failed: ec=%d", (int) GetLastError ());
|
2014-04-10 09:39:14 +00:00
|
|
|
|
|
2007-09-06 22:41:11 +00:00
|
|
|
|
if (!CloseHandle (pi.hThread))
|
|
|
|
|
TRACE_LOG1 ("CloseHandle of thread failed: ec=%d",
|
|
|
|
|
(int) GetLastError ());
|
|
|
|
|
|
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
|
|
|
|
|
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++)
|
|
|
|
|
_gpgme_io_close (fd_list[i].fd);
|
|
|
|
|
|
|
|
|
|
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);
|
2007-09-06 22:41:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Select on the list of fds. Returns: -1 = error, 0 = timeout or
|
|
|
|
|
nothing to select, > 0 = number of signaled fds. */
|
|
|
|
|
int
|
|
|
|
|
_gpgme_io_select (struct io_select_fd_s *fds, size_t nfds, int nonblock)
|
|
|
|
|
{
|
|
|
|
|
/* Use a 1s timeout. */
|
|
|
|
|
|
|
|
|
|
void *dbg_help = NULL;
|
|
|
|
|
TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_select", fds,
|
|
|
|
|
"nfds=%u, nonblock=%u", nfds, nonblock);
|
|
|
|
|
|
2007-10-04 14:09:58 +00:00
|
|
|
|
int count = 0;
|
2007-09-06 22:41:11 +00:00
|
|
|
|
|
|
|
|
|
TRACE_SEQ (dbg_help, "select on [ ");
|
2007-10-04 14:09:58 +00:00
|
|
|
|
for (int i = 0; i < nfds; i++)
|
2007-09-06 22:41:11 +00:00
|
|
|
|
{
|
|
|
|
|
if (fds[i].fd == -1)
|
|
|
|
|
{
|
|
|
|
|
fds[i].signaled = 0;
|
2007-10-04 14:09:58 +00:00
|
|
|
|
}
|
|
|
|
|
else if (fds[i].for_read )
|
|
|
|
|
{
|
2008-04-22 11:20:50 +00:00
|
|
|
|
KDPipeIODevice * const chan = find_channel (fds[i].fd, 0);
|
|
|
|
|
assert (chan);
|
|
|
|
|
if ( nonblock )
|
|
|
|
|
fds[i].signaled = chan->readWouldBlock() ? 0 : 1;
|
|
|
|
|
else
|
|
|
|
|
fds[i].signaled = chan->waitForReadyRead( 1000 ) ? 1 : 0;
|
2007-10-04 14:09:58 +00:00
|
|
|
|
TRACE_ADD1 (dbg_help, "w0x%x ", fds[i].fd);
|
2014-04-10 09:39:14 +00:00
|
|
|
|
if ( fds[i].signaled )
|
2007-10-04 14:09:58 +00:00
|
|
|
|
count++;
|
2007-09-06 22:41:11 +00:00
|
|
|
|
}
|
|
|
|
|
else if (fds[i].for_write)
|
|
|
|
|
{
|
2007-10-04 14:09:58 +00:00
|
|
|
|
const KDPipeIODevice * const chan = find_channel (fds[i].fd, 0);
|
2007-09-06 22:41:11 +00:00
|
|
|
|
assert (chan);
|
2008-04-22 11:20:50 +00:00
|
|
|
|
fds[i].signaled = nonblock ? ( chan->writeWouldBlock() ? 0 : 1 ) : 1;
|
2007-09-06 22:41:11 +00:00
|
|
|
|
TRACE_ADD1 (dbg_help, "w0x%x ", fds[i].fd);
|
2014-04-10 09:39:14 +00:00
|
|
|
|
if ( fds[i].signaled )
|
2007-10-04 14:09:58 +00:00
|
|
|
|
count++;
|
2007-09-06 22:41:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2014-04-10 09:39:14 +00:00
|
|
|
|
TRACE_END (dbg_help, "]");
|
2007-09-06 22:41:11 +00:00
|
|
|
|
|
|
|
|
|
return TRACE_SYSRES (count);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Look up the qiodevice for file descriptor FD. */
|
|
|
|
|
extern "C"
|
|
|
|
|
void *
|
|
|
|
|
gpgme_get_fdptr (int fd)
|
|
|
|
|
{
|
|
|
|
|
return find_channel (fd, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Obsolete compatibility interface. */
|
|
|
|
|
extern "C"
|
|
|
|
|
void *
|
|
|
|
|
gpgme_get_giochannel (int fd)
|
|
|
|
|
{
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2007-09-27 22:21:10 +00:00
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
_gpgme_io_dup (int fd)
|
|
|
|
|
{
|
2007-10-04 14:09:58 +00:00
|
|
|
|
assert( iodevice_table[fd] );
|
|
|
|
|
iodevice_table[fd]->ref();
|
2007-10-02 15:56:37 +00:00
|
|
|
|
return fd;
|
2007-09-27 22:21:10 +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
|
|
|
|
|
|
|
|
|
extern "C"
|
|
|
|
|
int
|
|
|
|
|
_gpgme_io_socket (int domain, int type, int proto)
|
|
|
|
|
{
|
|
|
|
|
errno = EIO;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extern "C"
|
|
|
|
|
int
|
|
|
|
|
_gpgme_io_connect (int fd, struct sockaddr *addr, int addrlen)
|
|
|
|
|
{
|
|
|
|
|
errno = EIO;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|