diff options
-rw-r--r-- | doc/assuan.texi | 2 | ||||
-rw-r--r-- | src/ChangeLog | 14 | ||||
-rw-r--r-- | src/assuan-pipe-connect.c | 4 | ||||
-rw-r--r-- | src/gpgcedev.c | 15 | ||||
-rw-r--r-- | src/gpgcemgr.c | 2 | ||||
-rw-r--r-- | src/system-w32.c | 3 | ||||
-rw-r--r-- | src/system-w32ce.c | 21 | ||||
-rw-r--r-- | src/system.c | 2 |
8 files changed, 50 insertions, 13 deletions
diff --git a/doc/assuan.texi b/doc/assuan.texi index 9176973..d1ce90b 100644 --- a/doc/assuan.texi +++ b/doc/assuan.texi @@ -948,7 +948,7 @@ reset to the default system hooks. @deftypefun void assuan_ctx_set_system_hooks (@w{assuan_context_t @var{ctx}}, @w{assuan_system_hooks_t @var{system_hooks}}) Set the system hooks for context @var{ctx}. There is currently no way -to reset tot the default system hooks, create a new context for that. +to reset to the default system hooks, create a new context for that. @end deftypefun The following system hook collections are defined by the library for diff --git a/src/ChangeLog b/src/ChangeLog index a9e107e..6db791a 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -2,6 +2,20 @@ * Makefile.am (EXTRA_DIST): Add gpgcedev.def. +2010-04-13 Werner Koch <wk@g10code.com> + + * gpgcedev.c (get_new_opnctx): Always clear IS_WRITE. + +2010-04-08 Werner Koch <wk@g10code.com> + + * gpgcedev.c (GPG_Read, GPG_Write): If the context is not + associated return ERROR_PIPE_NOT_CONNECTED. + * system-w32ce.c (__assuan_read, __assuan_write): Return EAGAIN for + ERROR_PIPE_NOT_CONNECTED. + + * assuan-pipe-connect.c (pipe_connect): Use + _assuan_close_inheritable also in the spawn error case. + 2010-04-06 Werner Koch <wk@g10code.com> * posix-includes.inc.h, w32-includes.inc.h: New. diff --git a/src/assuan-pipe-connect.c b/src/assuan-pipe-connect.c index 4eccdde..92f2bcc 100644 --- a/src/assuan-pipe-connect.c +++ b/src/assuan-pipe-connect.c @@ -190,8 +190,8 @@ pipe_connect (assuan_context_t ctx, { rc = gpg_err_code_from_syserror (); _assuan_close (ctx, rp[0]); - _assuan_close (ctx, rp[1]); - _assuan_close (ctx, wp[0]); + _assuan_close_inheritable (ctx, rp[1]); + _assuan_close_inheritable (ctx, wp[0]); _assuan_close (ctx, wp[1]); return _assuan_error (ctx, rc); } diff --git a/src/gpgcedev.c b/src/gpgcedev.c index 8508474..a295dd6 100644 --- a/src/gpgcedev.c +++ b/src/gpgcedev.c @@ -169,6 +169,11 @@ get_new_opnctx (void) opnctx = opnctx_table + idx; opnctx->assoc = NULL; opnctx->rvid = create_rendezvous_id (); + opnctx->is_write = 0; + opnctx->access_code = 0; + opnctx->share_mode = 0; + InitializeCriticalSection (&opnctx->critsect); + opnctx->locked = 0; opnctx->buffer_size = 512; opnctx->buffer = malloc (opnctx->buffer_size); if (!opnctx->buffer) @@ -182,7 +187,6 @@ get_new_opnctx (void) opnctx->space_available = INVALID_HANDLE_VALUE; opnctx->inuse = 1; - InitializeCriticalSection (&opnctx->critsect); EnterCriticalSection (&opnctx->critsect); opnctx->locked = 1; @@ -437,11 +441,12 @@ GPG_Read (DWORD opnctx_arg, void *buffer, DWORD count) if (rctx->is_write) { SetLastError (ERROR_INVALID_ACCESS); + log_debug ("GPG_Read(%p) -> invalid access\n", (void*)rctx); goto leave; } if (!rctx->assoc) { - SetLastError (ERROR_BROKEN_PIPE); + SetLastError (ERROR_PIPE_NOT_CONNECTED); goto leave; } @@ -508,11 +513,12 @@ GPG_Write (DWORD opnctx_arg, const void *buffer, DWORD count) if (!wctx->is_write) { SetLastError (ERROR_INVALID_ACCESS); + log_debug ("GPG_Write(%p) -> invalid access\n", (void*)wctx); goto leave; } if (!wctx->assoc) { - SetLastError (ERROR_BROKEN_PIPE); + SetLastError (ERROR_PIPE_NOT_CONNECTED); goto leave; } if (!count) @@ -601,6 +607,7 @@ make_pipe (opnctx_t ctx, LONG rvid) if (!(peerctx->access_code & GENERIC_WRITE)) { SetLastError (ERROR_INVALID_ACCESS); + log_debug (" make_pipe(%p) write end -> invalid access\n", ctx); goto leave; } peerctx->space_available = CreateEvent (NULL, FALSE, FALSE, NULL); @@ -618,6 +625,7 @@ make_pipe (opnctx_t ctx, LONG rvid) if (!(peerctx->access_code & GENERIC_READ)) { SetLastError (ERROR_INVALID_ACCESS); + log_debug (" make_pipe(%p) read_end -> invalid access\n", ctx); goto leave; } ctx->space_available = CreateEvent (NULL, FALSE, FALSE, NULL); @@ -632,6 +640,7 @@ make_pipe (opnctx_t ctx, LONG rvid) else { SetLastError (ERROR_INVALID_ACCESS); + log_debug (" make_pipe(%p) no_access -> invalid access\n", ctx); goto leave; } diff --git a/src/gpgcemgr.c b/src/gpgcemgr.c index d5d354e..00e2ef8 100644 --- a/src/gpgcemgr.c +++ b/src/gpgcemgr.c @@ -1,4 +1,4 @@ -/* gpgcempg.c - Manager fopr GPG CE devices +/* gpgcempr.c - Manager for GPG CE devices Copyright (C) 2010 Free Software Foundation, Inc. This file is part of Assuan. diff --git a/src/system-w32.c b/src/system-w32.c index 85f0e40..6213579 100644 --- a/src/system-w32.c +++ b/src/system-w32.c @@ -402,7 +402,8 @@ __assuan_spawn (assuan_context_t ctx, pid_t *r_pid, const char *name, /* Note: We inherit all handles flagged as inheritable. This seems to be a security flaw but there seems to be no way of selecting - handles to inherit. */ + handles to inherit. A fix for this would be to use a helper + process like we have in gpgme. */ /* _assuan_log_printf ("CreateProcess, path=`%s' cmdline=`%s'\n", */ /* name, cmdline); */ if (!CreateProcess (name, /* Program to start. */ diff --git a/src/system-w32ce.c b/src/system-w32ce.c index 1ecb4d8..fb098da 100644 --- a/src/system-w32ce.c +++ b/src/system-w32ce.c @@ -301,6 +301,11 @@ __assuan_read (assuan_context_t ctx, assuan_fd_t fd, void *buffer, size_t size) gpg_err_set_errno (EPIPE); break; + case ERROR_PIPE_NOT_CONNECTED: + case ERROR_BUSY: + gpg_err_set_errno (EAGAIN); + break; + default: gpg_err_set_errno (EIO); } @@ -357,6 +362,11 @@ __assuan_write (assuan_context_t ctx, assuan_fd_t fd, const void *buffer, case ERROR_NO_DATA: gpg_err_set_errno (EPIPE); break; + + case ERROR_PIPE_NOT_CONNECTED: + case ERROR_BUSY: + gpg_err_set_errno (EAGAIN); + break; default: gpg_err_set_errno (EIO); @@ -505,9 +515,12 @@ __assuan_spawn (assuan_context_t ctx, pid_t *r_pid, const char *name, Because an RVID of 0 is an invalid value and HANDLES will never have this value either, we test for this as well. */ - /* FIXME: CHECKOUT WHAT TO DO WITH STDERR HERE. WE NEED TO DEFINE - WHETHER THE FD_CHILD_LIST HAS HANDLES OR RENDEZVOUS IDS. */ - + /* FIXME: As long as we can't decide whether a handle is a real + handler or an rendezvous id we can't do anything with the + FD_CHILD_LIST. We can't do much with stderr either, thus we + better don't pass stderr to the child at all. If we would do so + and it is not a rendezvous id the client would run into + problems. */ fd = assuan_fd_from_posix_fd (fileno (stderr)); fdp = fd_child_list; if (fdp) @@ -517,7 +530,7 @@ __assuan_spawn (assuan_context_t ctx, pid_t *r_pid, const char *name, } if (!fdp || *fdp == ASSUAN_INVALID_FD) fd_err_isnull = 1; - fd_err = fd; + fd_err = ASSUAN_INVALID_FD; if (build_w32_commandline (ctx, argv, fd_in, fd_out, fd_err, fd_err_isnull, &cmdline)) diff --git a/src/system.c b/src/system.c index 1f180e9..779b567 100644 --- a/src/system.c +++ b/src/system.c @@ -175,7 +175,7 @@ _assuan_close (assuan_context_t ctx, assuan_fd_t fd) int _assuan_close_inheritable (assuan_context_t ctx, assuan_fd_t fd) { - TRACE1 (ctx, ASSUAN_LOG_SYSIO, "_assuan_close", ctx, + TRACE1 (ctx, ASSUAN_LOG_SYSIO, "_assuan_close_inheritable", ctx, "fd=0x%x", fd); #ifdef HAVE_W32CE_SYSTEM |