Page MenuHome GnuPG

No OneTemporary

diff --git a/assuan/ChangeLog b/assuan/ChangeLog
index 4f835521..3aef8395 100644
--- a/assuan/ChangeLog
+++ b/assuan/ChangeLog
@@ -1,588 +1,594 @@
2005-10-01 Marcus Brinkmann <marcus@g10code.de>
+ * assuan.h (assuan_pipe_connect, assuan_pipe_connect2): Make type
+ of ARGV parameter const in prototype.
+ * assuan-pipe-connect.c (assuan_pipe_connect,
+ assuan_pipe_connect2): Likewise in declaration.
+ (assuan_pipe_connect2): Add braindead cast to make execv happy.
+
* assuan-client.c (assuan_transact): Change LINE, S and D from
unsigned char * to char * to silence gcc warning.
* assuan-util.c (_assuan_log_sanitized_string): Add explicit cast
to silence gcc warning.
* assuan-inquire.c (assuan_inquire): Likewise.
2005-08-19 Werner Koch <wk@g10code.com>
* funopen.c, assuan-socket.c: Copied from libassuan CVS.
* assuan-pipe-connect.c (assuan_pipe_connect2): Add missing
declaration of PID.
2005-08-09 Werner Koch <wk@g10code.com>
* README.1st: Adjusted to cope with changes done in upstream Assuan.
Merged changes for W32 support from libassuan.
* assuan.h [_ASSUAN_EXT_SYM_PREFIX]: New.
* assuan-io.c [_ASSUAN_NO_PTH]: New.
* assuan-pipe-connect.c (fix_signals) [_ASSUAN_NO_FIXED_SIGNALS]: New.
(assuan_pipe_connect2) [_ASSUAN_USE_DOUBLE_FORK]: Use double fork.
(fix_signals) [_ASSUAN_USE_DOUBLE_FORK]: Do not wait..
* assuan-logging.c, assuan-io.c: Include config.h
Replaced all usages of _WIN32 by the new HAVE_W32_SYSTEM because
there is nothing winning in this API.
* assuan-pipe-connect.c (assuan_pipe_connect2) [_WIN32]: Return
error Not Imlemented.
* assuan-logging.c (_assuan_w32_strerror): New.
* assuan-defs.h (w32_strerror): new.
* assuan-pipe-connect.c (assuan_pipe_connect2, fix_signals):
Factored signal code out to new function.
(build_w32_commandline, create_inheritable_pipe): New. Taken
from gnupg 1.9.
(assuan_pipe_connect2) [W32]: Implemented for W32.
* assuan-pipe-server.c (assuan_init_pipe_server) [W32]: Map file
descriptors using _get_osfhandle.
* assuan-socket-connect.c (assuan_socket_connect) [W32]: Allow for
a drive letter in the path.
* assuan-client.c (assuan_transact): Handle empty and comment
commands correctly.
* assuan-util.c (_assuan_calloc): Avoid integer overflow.
* assuan-util.c (assuan_set_flag, assuan_get_flag): New.
* assuan-defs.h (struct assuan_context_s): New field flags.
* assuan.h (assuan_flag_t): New with one flag value
ASSUAN_NO_WAITPID for now.
* assuan-pipe-connect.c (do_finish): Take care of the no_waitpid
flag.
* mkerrors: Include config.h into assuan-errors.c. This is
required so that assuan.h knows about the W32 macro.
2005-08-09 Timo Schulz <twoaday@g10code.com> (ported from libassuan by wk)
* assuan-io.c (_assuan_simple_read, _assuan_simple_write): W32
support.
* assuan-socket.c (_assuan_close): New.
(_assuan_sock_new): New.
(_assuan_sock_bind): New.
2005-03-22 Werner Koch <wk@g10code.com>
* assuan-defs.h (struct assuan_io): Renamed elements READ and
WRITE to READFNC and WRITEFNC to avoid problems with read defined
as macro. Changed callers. Noted by Ville Skyttä.
2004-12-16 Marcus Brinkmann <marcus@g10code.de>
* assuan-pipe-connect.c (do_finish): Do not wait for child to finish.
(assuan_pipe_connect): Use double-fork approach.
* assuan-connect.c (assuan_disconnect): Do not write BYE to the
status line.
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* README.1st: Add copyright notice.
2004-06-23 Marcus Brinkmann <marcus@g10code.de>
* assuan-domain-connect.c [HAVE_SYS_UIO_H]: Include <sys/uio.h>.
* assuan-handler.c: Include <errno.h>.
2004-06-08 Marcus Brinkmann <marcus@g10code.de>
* assuan-buffer.c (assuan_write_line): If the line is longer than
the maximum line length, bail out early.
2004-04-19 Werner Koch <wk@gnupg.org>
* assuan-socket-connect.c: Include sys/types.h
* assuan-socket-server.c: Ditto
* assuan-domain-connect.c: Ditto.
2004-02-18 Werner Koch <wk@gnupg.org>
* assuan-handler.c (assuan_get_data_fp): Fail with ENOSYS if we
can't implement this.
2004-02-13 Werner Koch <wk@gnupg.org>
* assuan-domain-connect.c: Removed the unneeded alloca.h
2003-08-13 Werner Koch <wk@gnupg.org>
* assuan-inquire.c (assuan_inquire): Increase length of cmdbuf to
the Assuan limit.
2003-06-24 Werner Koch <wk@gnupg.org>
* mkerrors: Kludge to print libgpg-error values in an easier
readable way.
2003-04-29 Werner Koch <wk@gnupg.org>
* libassuan.m4: New. Based on libgrypt.m4.
* Makefile.am (m4data_DATA): New.
* assuan.h (AssuanCommand): Removed.
* assuan-handler.c: Remove the cmd_id element,
(assuan_register_command): Likewise. Note that semantics changed.
(_assuan_register_std_commands): Adjusted.
2003-02-22 Neal H. Walfield <neal@g10code.de>
* Makefile.am (bin_SCRIPTS): Renamed from bin_PROGRAMS.
2003-02-18 Neal H. Walfield <neal@g10code.de>
* Makefile.am (libassuan_a_LIBADD): New variable.
* funopen.c: Move from ../common.
* isascii.c: Likewise.
* memrchr.c: Likewise.
* putc_unlocked.c: Likewise.
2003-02-18 Neal H. Walfield <neal@g10code.de>
* assuan-handler.c (_IO_cookie_io_functions_t): Remove.
(cookie_io_functions_t): Remove.
(fopencookie): Remove prototype.
(assuan_get_data_fp): Use funopen, not fopencookie.
2003-02-18 Neal H. Walfield <neal@g10code.de>
* libassuan-config.in: New file.
* Makefile.am (bin_PROGRAMS): New variable.
2003-02-17 Neal H. Walfield <neal@g10code.de>
* .cvsignore: New file.
2003-02-17 Neal H. Walfield <neal@g10code.de>
* Makefile.am (lib_LIBRARIES): Use this instead of . . .
(noinst_LIBRARIES): . . . this.
(include_HEADERS): New variable.
(libassuan_a_SOURCES): Remove assuan.h, add assuan-logging.c.
* assuan.h (assuan_set_assuan_log_stream): New prototype.
(assuan_get_assuan_log_stream): Likewise.
(assuan_get_assuan_log_prefix): Likewise.
* assuan-logging.c: New file.
* assuan-buffer.c [HAVE_JNLIB_LOGGIN]: Do not include
"../jnlib/logging.h".
(my_log_prefix): Remove function.
(_assuan_read_line): Use assuan_get_assuan_log_prefix in lieu of
my_log_prefix.
(assuan_write_line): Likewise.
(_assuan_cookie_write_data): Likewise.
(_assuan_cookie_write_flush): Likewise.
* assuan-domain-connect.c (LOGERROR, LOGERROR1, LOGERROR2,
LOGERRORX): Remove.
(LOG): New macro.
(domain_reader): Use it.
(domain_writer): Likewise.
(domain_sendfd): Likewise.
(domain_receivefd): Likewise.
(_assuan_domain_init): Likewise.
(assuan_domain_connect): Likewise.
* assuan-pipe-connect.c [HAVE_JNLIB_LOGGIN]: Do not include
"../jnlib/logging.h".
(LOGERROR, LOGERROR1, LOGERROR2, LOGERRORX): Remove.
(LOG): New macro.
(assuan_pipe_connect): Use it.
* assuan-socket-connect.c [HAVE_JNLIB_LOGGIN]: Do not include
"../jnlib/logging.h".
(LOGERROR, LOGERROR1, LOGERROR2, LOGERRORX): Remove.
(LOG): New macro.
(assuan_socket_connect): Use it.
(socket_reader): Remove dead code.
(socket_writer): Likewise.
* assuan-util.c [HAVE_JNLIB_LOGGIN]: Do not include
"../jnlib/logging.h".
(_assuan_log_sanitized_string): Use assuan_get_assuan_log_stream,
not jnlib.
2002-11-24 Neal H. Walfield <neal@g10code.de>
* assuan.h (assuan_command_parse_fd): New prototype.
* assuan-handler.c (assuan_command_parse_fd): Rename from
parse_cmd_input_output. Export.
(std_handler_input): Update to use assuan_command_parse_fd.
(std_handler_output): Likewise.
2002-11-24 Neal H. Walfield <neal@g10code.de>
* assuan.h (assuan_sendfd): New prototype.
(assuan_receivefd): New prototype.
* assuan-buffer.c (assuan_sendfd): New function.
(assuan_receivefd): New function.
* assuan-handler.c (parse_cmd_input_output): Recognize incoming
file descriptors and act appropriately.
* assuan-defs.h (struct assuan_io): Add fields sendfd and
receivefd.
(struct assuan_context_s): Add fields pendingfds and
pendingfdscount.
* assuan-pipe-server.c (_assuan_new_context): Update IO to reflect
new features.
* assuan-domain-connect.c (do_deinit): Cleanup any unreceived file
descriptors.
(domain_reader): Receive file descriptors.
(domain_sendfd): New function.
(domain_receivefd): New function.
(_assuan_domain_init): Update initialization code to reflect new
features.
2002-11-24 Neal H. Walfield <neal@g10code.de>
* assuan-domain-connect.c (do_finish): Remove.
(_assuan_domain_init): Use default handlers where possible.
Add an assert and update comments.
* assuan-domain-server.c (accept_connection): Remove.
(assuan_init_domain_server): Use default handlers where possible.
Put the server in pipe mode: it can only be used by a single
client.
2002-11-24 Neal H. Walfield <neal@g10code.de>
* assuan.h: Add prototype for assuan_domain_connect and
assuan_init_domain_server.
* assuan-defs.h: Include <unistd.h>.
Add prototype for _assuan_domain_init.
* assuan-domain-connect.c: New file.
* assuan-domain-server.c: New file.
* Makefile.am (libassuan_a_SOURCES): Add assuan-domain-connect.c
and assuan-domain-server.c
2002-11-23 Neal H. Walfield <neal@g10code.de>
* Makefile.am (libassuan_a_SOURCES): Add assuan-io.c.
* assuan-io.c: Restore.
(_assuan_simple_read): Rename from _assuan_read.
(_assuan_simple_write): Rename from _assuan_write.
* assuan-defs.h (_assuan_simple_read): New prototype.
(_assuan_simple_write): Likewise.
* assuan-pipe-server.c (pipe_reader): Remove.
(pipe_writer): Remove.
(_assuan_new_context): Initialize IO is with _assuan_simple_read
and _assuan_simple_write.
* assuan-socket-connect.c (socket_reader): Remove.
(socket_writer): Remove.
(assuan_socket_connect): Initialize IO is with _assuan_simple_read
and _assuan_simple_write.
* assuan-socket-server.c (io): New local variable.
(assuan_init_socket_server): Initialize CTX->io.
(assuan_init_connected_socket_server): Likewise.
2002-11-23 Neal H. Walfield <neal@g10code.de>
* assuan-buffer.c (readline): Use memrchr.
(_assuan_read_line): Rewritten to use the string functions.
2002-11-20 Neal H. Walfield <neal@g10code.de>
* assuan-socket-connect.c (assuan_socket_connect): Pass PF_LOCAL
to socket(), not AF_UNIX: it expects a PF_* macro and the former
is more portable.
(assuan_socket_connect): Use AF_LOCAL, not AF_UNIX which is more
POSIXy.
2002-11-20 Neal H. Walfield <neal@g10code.de>
* assuan-defs.h (struct assuan_io): New structure.
(struct assuan_context_s): New field, io.
(_assuan_read): Depreciated.
(_assuan_write): Likewise.
* assuan-pipe-server.c: Include <unistd.h>.
(pipe_reader): New function.
(pipe_writer): Likewise.
(_assuan_new_context.IO): New local static. Set to pipe_reader
and pipe_writer. Use it to initialize new context.
* assuan-socket-connect.c (socket_reader): New function.
(socket_writer): New function.
(assuan_socket_connect.IO): New local static. Set to socket_reader
and socket_writer. Use it to initialize new context.
* assuan-buffer.c (writen): Take an ASSUAN_CONTEXT rather than a
file descriptor. Do not use _assuan_write but the write method
in the supplied context.
(readline): Likewise for _assuan_read.
(assuan_write_line): When calling writen, pass CTX; not the file
descriptor directly.
(_assuan_cookie_write_data): Likewise.
(_assuan_cookie_write_flush): Likewise.
(_assuan_read_line): Likewise for readline.
* Makefile.am (libassuan_a_SOURCES): Remove assuan-io.c.
* assuan-io.c: Removed.
2002-11-10 Werner Koch <wk@gnupg.org>
* assuan-pipe-connect.c (assuan_pipe_connect): Changed the order
of the dups to handle cases where we have already used fd 2 for
other things.
2002-10-31 Neal H. Walfield <neal@g10code.de>
* assuan-util.c: Include <ctype.h>.
(_assuan_log_print_buffer): Elide the magic numbers preferring the
standard isfoo functions. Use putc_unlocked where possible.
(_assuan_log_sanitized_string): Rewrite to use putc_unlocked and
the isfoo functions.
2002-09-05 Neal H. Walfield <neal@g10code.de>
* assuan-defs.h (_assuan_read_wrapper): Depreciated.
* assuan-util.c (_assuan_read_wrapper): Removed.
* assuan-defs.h (_assuan_write_wrapper): Depreciated.
* assuan-util.c (_assuan_write_wrapper): Removed.
* assuan.h (assuan_set_io_fun): Depreciated.
* assuan-util.c (assuan_set_io_fun): Removed.
* assuan-defs.h (_assuan_read): New function.
(_assuan_write): Likewise.
* assuan-io.c: New file.
* assuan-buffer.c (writen): Use _assuan_write rather than doing
the work here.
(readline): Likewise for _assuan_read.
* Makefile.am (libassuan_a_SOURCES): Add assuan-io.c.
2002-08-16 Werner Koch <wk@gnupg.org>
* assuan.h: Renamed Bad_Certificate_Path to Bad_Certificate_Chain.
2002-07-30 Werner Koch <wk@gnupg.org>
Changed the license from GPL to LGPL.
2002-07-23 Werner Koch <wk@gnupg.org>
* assuan-handler.c (_IO_cookie_io_functions_t): Define it here if
it does not exists.
2002-06-27 Werner Koch <wk@gnupg.org>
* assuan-pipe-connect.c (assuan_pipe_connect): No special handling
for the log_fd and stderr. Connect stderr to /dev/null if it
should not be retained.
2002-06-26 Werner Koch <wk@gnupg.org>
* assuan-buffer.c (assuan_write_line): Make sure we never
accidently print an extra LF.
2002-05-23 Werner Koch <wk@gnupg.org>
* assuan-util.c (assuan_set_io_func): New.
* assuan-buffer.c (writen, readline): Use the new functions
instead of pth.
* assuan-socket-server.c (accept_connection): Don't use the
pth_accept - using the assuan included accept code would be a bad
idea within Pth so we don't need a replacement function.
2002-05-22 Werner Koch <wk@gnupg.org>
* assuan-socket-server.c (assuan_init_connected_socket_server): New.
(accept_connection): Factored most code out to..
(accept_connection_bottom): .. new function.
2002-04-04 Werner Koch <wk@gnupg.org>
* assuan-buffer.c (my_log_prefix): New. Use it for all i/o debug
output.
2002-03-06 Werner Koch <wk@gnupg.org>
* assuan-client.c (_assuan_read_from_server): Detect END.
(assuan_transact): Pass it to the data callback.
2002-02-27 Werner Koch <wk@gnupg.org>
* assuan-client.c (assuan_transact): Add 2 more arguments to
support status lines. Passing NULL yields the old behaviour.
* assuan-handler.c (process_request): Flush data lines send
without using the data fp.
2002-02-14 Werner Koch <wk@gnupg.org>
* assuan-inquire.c (assuan_inquire): Check for a cancel command
and return ASSUAN_Canceled. Allow for non-data inquiry.
* assuan.h: Add a few token specific error codes.
2002-02-13 Werner Koch <wk@gnupg.org>
* assuan-defs.h (assuan_context_s): New var CLIENT_PID.
* assuan-pipe-server.c (_assuan_new_context): set default value.
* assuan-socket-server.c (accept_connection): get the actual pid.
2002-02-12 Werner Koch <wk@gnupg.org>
* assuan-buffer.c (writen,readline) [USE_GNU_PT]: Use pth_read/write.
* assuan-socket-server.c (accept_connection) [USE_GNU_PTH]: Ditto.
2002-02-01 Marcus Brinkmann <marcus@g10code.de>
* Makefile.am (MOSTLYCLEANFILES): New variable.
2002-01-23 Werner Koch <wk@gnupg.org>
* assuan-socket-connect.c (LOGERRORX): and removed typo.
2002-01-22 Marcus Brinkmann <marcus@g10code.de>
* assuan-socket-connect.c (LOGERRORX): Reverse arguments to fputs.
2002-01-21 Werner Koch <wk@gnupg.org>
* assuan-connect.c: Move all except assuan_get_pid to...
* assuan-pipe-connect.c: this.
(assuan_pipe_disconnect): Removed.
(do_finish, do_deinit): New
(assuan_pipe_connect): and set them into the context.
* assuan-socket-connect.c: New.
* assuan-util.c (_assuan_log_sanitized_string): New.
* assuan-pipe-server.c (assuan_init_pipe_server): Factored most
code out to ...
(_assuan_new_context): new func.
(_assuan_release_context): New
* assuan-connect.c (assuan_pipe_connect): Use the new functions.
2002-01-20 Werner Koch <wk@gnupg.org>
* assuan.h: Added Invalid Option error code.
* assuan-handler.c (std_handler_option): New.
(std_cmd_tbl): Add OPTION as standard command.
(assuan_register_option_handler): New.
(dispatch_command): Use case insensitive matching as a fallback.
(my_strcasecmp): New.
2002-01-19 Werner Koch <wk@gnupg.org>
* assuan-buffer.c (_assuan_read_line): Add output logging.
(assuan_write_line): Ditto.
(_assuan_cookie_write_data): Ditto.
(_assuan_cookie_write_flush): Ditto.
* assuan-util.c (_assuan_log_print_buffer): New.
(assuan_set_log_stream): New.
(assuan_begin_confidential): New.
(assuan_end_confidential): New.
* assuan-defs.h: Add a few handler variables.
* assuan-pipe-server.c (assuan_deinit_pipe_server): Removed.
(deinit_pipe_server): New.
(assuan_deinit_server): New. Changed all callers to use this.
* assuan-listen.c (assuan_accept): Use the accept handler.
* assuan-handler.c (process_request): Use the close Handler.
* assuan-socket-server.c: New.
2002-01-14 Werner Koch <wk@gnupg.org>
* assuan-client.c (_assuan_read_from_server): Skip spaces after
the keyword.
2002-01-03 Werner Koch <wk@gnupg.org>
* assuan-handler.c (assuan_set_okay_line): New.
(process_request): And use it here.
2002-01-02 Werner Koch <wk@gnupg.org>
* assuan-inquire.c (init_membuf,put_membuf,get_membuf): Apply a
hidden 0 behind the buffer so that the buffer can be used as a
string in certain contexts.
2001-12-14 Marcus Brinkmann <marcus@g10code.de>
* assuan-connect.c (assuan_pipe_connect): New argument
FD_CHILD_LIST. Don't close those fds.
* assuan.h: Likewise for prototype.
2001-12-14 Werner Koch <wk@gnupg.org>
* assuan-listen.c (assuan_close_input_fd): New.
(assuan_close_output_fd): New.
* assuan-handler.c (std_handler_reset): Always close them after a
reset command.
(std_handler_bye): Likewise.
2001-12-14 Marcus Brinkmann <marcus@g10code.de>
* assuan-buffer.c (_assuan_read_line): New variable ATTICLEN, use
it to save the length of the attic line.
Rediddle the code a bit to make it more clear what happens.
2001-12-14 Marcus Brinkmann <marcus@g10code.de>
* assuan-defs.h (LINELENGTH): Define as ASSUAN_LINELENGTH.
assuan.h: Define ASSUAN_LINELENGTH.
2001-12-13 Marcus Brinkmann <marcus@g10code.de>
* assuan-buffer.c (assuan_read_line): Fix order of execution to
get correct return values.
2001-12-13 Werner Koch <wk@gnupg.org>
* assuan-handler.c (assuan_get_active_fds): Fixed silly bug,
pretty obvious that nobody ever tested this function.
2001-12-12 Werner Koch <wk@gnupg.org>
* assuan-connect.c (assuan_pipe_connect): Implemented the inital
handshake.
* assuan-client.c (read_from_server): Renamed to
(_assuan_read_from_server): this and made external.
* assuan-listen.c (assuan_set_hello_line): New.
(assuan_accept): Use a custom hello line is available.
* assuan-buffer.c (assuan_read_line): New.
(assuan_pending_line): New.
(_assuan_write_line): Renamed to ..
(assuan_write_line): this, made public and changed all callers.
2001-12-04 Werner Koch <wk@gnupg.org>
* assuan-connect.c (assuan_pipe_connect): Add more error reporting.
* assuan-client.c: New.
* assuan-inquire.c: New.
* assuan-handler.c (process_request): Check for nested invocations.
2001-11-27 Werner Koch <wk@gnupg.org>
* assuan-handler.c (assuan_register_input_notify): New.
(assuan_register_output_notify): New.
2001-11-26 Werner Koch <wk@gnupg.org>
* assuan.h: Added more status codes.
2001-11-25 Werner Koch <wk@gnupg.org>
* assuan-handler.c (assuan_register_bye_notify)
(assuan_register_reset_notify)
(assuan_register_cancel_notify): New and call them from the
standard handlers.
(assuan_process): Moved bulk of function to ..
(process_request): .. new.
(assuan_process_next): One shot version of above.
(assuan_get_active_fds): New.
2001-11-24 Werner Koch <wk@gnupg.org>
* assuan-connect.c (assuan_get_pid): New.
* assuan-buffer.c (_assuan_read_line): Deal with reads of more
than a line.
* assuan-defs.h: Add space in the context for this.
Copyright 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
This file is free software; as a special exception the author gives
unlimited permission to copy and/or distribute it, with or without
modifications, as long as this notice is preserved.
This file is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
diff --git a/assuan/assuan-pipe-connect.c b/assuan/assuan-pipe-connect.c
index cbc131f7..ecedb166 100644
--- a/assuan/assuan-pipe-connect.c
+++ b/assuan/assuan-pipe-connect.c
@@ -1,619 +1,619 @@
/* assuan-pipe-connect.c - Establish a pipe connection (client)
- * Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
+ * Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
*
* This file is part of Assuan.
*
* Assuan 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.
*
* Assuan is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* 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 <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/types.h>
#ifndef HAVE_W32_SYSTEM
#include <sys/wait.h>
#else
#include <windows.h>
#endif
#include "assuan-defs.h"
#ifdef _POSIX_OPEN_MAX
#define MAX_OPEN_FDS _POSIX_OPEN_MAX
#else
#define MAX_OPEN_FDS 20
#endif
#ifdef HAVE_W32_SYSTEM
/* We assume that a HANDLE can be represented by an int which should
be true for all i386 systems (HANDLE is defined as void *) and
these are the only systems for which Windows is available. Further
we assume that -1 denotes an invalid handle. */
#define fd_to_handle(a) ((HANDLE)(a))
#define handle_to_fd(a) ((int)(a))
#define pid_to_handle(a) ((HANDLE)(a))
#define handle_to_pid(a) ((int)(a))
#endif /*HAVE_W32_SYSTEM*/
/* This should be called to make sure that SIGPIPE gets ignored. */
static void
fix_signals (void)
{
#ifndef _ASSUAN_NO_FIXED_SIGNALS
#ifndef HAVE_DOSISH_SYSTEM /* No SIGPIPE for these systems. */
static int fixed_signals;
if (!fixed_signals)
{
struct sigaction act;
sigaction (SIGPIPE, NULL, &act);
if (act.sa_handler == SIG_DFL)
{
act.sa_handler = SIG_IGN;
sigemptyset (&act.sa_mask);
act.sa_flags = 0;
sigaction (SIGPIPE, &act, NULL);
}
fixed_signals = 1;
/* FIXME: This is not MT safe */
}
#endif /*HAVE_DOSISH_SYSTEM*/
#endif /*!_ASSUAN_NO_FIXED_SIGNALS*/
}
#ifndef HAVE_W32_SYSTEM
static int
writen (int fd, const char *buffer, size_t length)
{
while (length)
{
int nwritten = write (fd, buffer, length);
if (nwritten < 0)
{
if (errno == EINTR)
continue;
return -1; /* write error */
}
length -= nwritten;
buffer += nwritten;
}
return 0; /* okay */
}
#endif
static int
do_finish (assuan_context_t ctx)
{
if (ctx->inbound.fd != -1)
{
_assuan_close (ctx->inbound.fd);
ctx->inbound.fd = -1;
}
if (ctx->outbound.fd != -1)
{
_assuan_close (ctx->outbound.fd);
ctx->outbound.fd = -1;
}
if (ctx->pid != -1 && ctx->pid)
{
#ifndef HAVE_W32_SYSTEM
#ifndef _ASSUAN_USE_DOUBLE_FORK
if (!ctx->flags.no_waitpid)
waitpid (ctx->pid, NULL, 0);
ctx->pid = -1;
#endif
#endif /*!HAVE_W32_SYSTEM*/
}
return 0;
}
static void
do_deinit (assuan_context_t ctx)
{
do_finish (ctx);
}
#ifdef HAVE_W32_SYSTEM
/* Build a command line for use with W32's CreateProcess. On success
CMDLINE gets the address of a newly allocated string. */
static int
build_w32_commandline (char * const *argv, char **cmdline)
{
int i, n;
const char *s;
char *buf, *p;
*cmdline = NULL;
n = 0;
for (i=0; (s=argv[i]); i++)
{
n += strlen (s) + 1 + 2; /* (1 space, 2 quoting */
for (; *s; s++)
if (*s == '\"')
n++; /* Need to double inner quotes. */
}
n++;
buf = p = xtrymalloc (n);
if (!buf)
return -1;
for (i=0; argv[i]; i++)
{
if (i)
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]);
}
*cmdline= buf;
return 0;
}
#endif /*HAVE_W32_SYSTEM*/
#ifdef HAVE_W32_SYSTEM
/* Create pipe where one end end is inheritable. */
static int
create_inheritable_pipe (int filedes[2], int for_write)
{
HANDLE r, w, h;
SECURITY_ATTRIBUTES sec_attr;
memset (&sec_attr, 0, sizeof sec_attr );
sec_attr.nLength = sizeof sec_attr;
sec_attr.bInheritHandle = FALSE;
if (!CreatePipe (&r, &w, &sec_attr, 0))
{
_assuan_log_printf ("CreatePipe failed: %s\n", w32_strerror (-1));
return -1;
}
if (!DuplicateHandle (GetCurrentProcess(), for_write? r : w,
GetCurrentProcess(), &h, 0,
TRUE, DUPLICATE_SAME_ACCESS ))
{
_assuan_log_printf ("DuplicateHandle failed: %s\n", w32_strerror (-1));
CloseHandle (r);
CloseHandle (w);
return -1;
}
if (for_write)
{
CloseHandle (r);
r = h;
}
else
{
CloseHandle (w);
w = h;
}
filedes[0] = handle_to_fd (r);
filedes[1] = handle_to_fd (w);
return 0;
}
#endif /*HAVE_W32_SYSTEM*/
/* Connect to a server over a pipe, creating the assuan context and
returning it in CTX. The server filename is NAME, the argument
vector in ARGV. FD_CHILD_LIST is a -1 terminated list of file
descriptors not to close in the child. ATFORK is called in the
child right after the fork; ATFORKVALUE is passed as the first
argument and 0 is passed as the second argument. The ATFORK
function should only act if the second value is 0. */
assuan_error_t
assuan_pipe_connect2 (assuan_context_t *ctx,
- const char *name, char *const argv[],
+ const char *name, const char *const argv[],
int *fd_child_list,
void (*atfork) (void *opaque, int reserved),
void *atforkvalue)
{
#ifdef HAVE_W32_SYSTEM
assuan_error_t err;
int rp[2];
int wp[2];
char mypidstr[50];
char *cmdline;
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 fd, *fdp;
HANDLE nullfd = INVALID_HANDLE_VALUE;
if (!ctx || !name || !argv || !argv[0])
return ASSUAN_Invalid_Value;
fix_signals ();
sprintf (mypidstr, "%lu", (unsigned long)getpid ());
/* Build the command line. */
if (build_w32_commandline (argv, &cmdline))
return ASSUAN_Out_Of_Core;
/* Create thew two pipes. */
if (create_inheritable_pipe (rp, 0))
{
xfree (cmdline);
return ASSUAN_General_Error;
}
if (create_inheritable_pipe (wp, 1))
{
CloseHandle (fd_to_handle (rp[0]));
CloseHandle (fd_to_handle (rp[1]));
xfree (cmdline);
return ASSUAN_General_Error;
}
err = _assuan_new_context (ctx);
if (err)
{
CloseHandle (fd_to_handle (rp[0]));
CloseHandle (fd_to_handle (rp[1]));
CloseHandle (fd_to_handle (wp[0]));
CloseHandle (fd_to_handle (wp[1]));
xfree (cmdline);
return ASSUAN_General_Error;
}
(*ctx)->pipe_mode = 1;
(*ctx)->inbound.fd = rp[0]; /* Our inbound is read end of read pipe. */
(*ctx)->outbound.fd = wp[1]; /* Our outbound is write end of write pipe. */
(*ctx)->deinit_handler = do_deinit;
(*ctx)->finish_handler = do_finish;
/* fixme: Actually we should set the "_assuan_pipe_connect_pid" env
variable. However this requires us to write a full environment
handler, because the strings are expected in sorted order. The
suggestion given in the MS Reference Library, to save the old
value, changeit, create proces and restore it, is not thread
safe. */
/* Start the process. */
memset (&sec_attr, 0, sizeof sec_attr );
sec_attr.nLength = sizeof sec_attr;
sec_attr.bInheritHandle = FALSE;
memset (&si, 0, sizeof si);
si.cb = sizeof (si);
si.dwFlags = STARTF_USESTDHANDLES;
si.hStdInput = fd_to_handle (wp[0]);
si.hStdOutput = fd_to_handle (rp[1]);
/* Dup stderr to /dev/null unless it is in the list of FDs to be
passed to the child. */
fd = fileno (stderr);
fdp = fd_child_list;
if (fdp)
{
for (; *fdp != -1 && *fdp != fd; fdp++)
;
}
if (!fdp || *fdp == -1)
{
nullfd = CreateFile ("nul", GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, 0, NULL);
if (nullfd == INVALID_HANDLE_VALUE)
{
_assuan_log_printf ("can't open `nul': %s\n", w32_strerror (-1));
CloseHandle (fd_to_handle (rp[0]));
CloseHandle (fd_to_handle (rp[1]));
CloseHandle (fd_to_handle (wp[0]));
CloseHandle (fd_to_handle (wp[1]));
xfree (cmdline);
_assuan_release_context (*ctx);
return -1;
}
si.hStdError = nullfd;
}
else
si.hStdError = fd_to_handle (_get_osfhandle (fd));
/* 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. */
/* _assuan_log_printf ("CreateProcess, path=`%s' cmdline=`%s'\n", */
/* name, cmdline); */
if (!CreateProcess (name, /* Program to start. */
cmdline, /* Command line arguments. */
&sec_attr, /* Process security attributes. */
&sec_attr, /* Thread security attributes. */
TRUE, /* Inherit handles. */
(CREATE_DEFAULT_ERROR_MODE
| GetPriorityClass (GetCurrentProcess ())
| CREATE_SUSPENDED), /* Creation flags. */
NULL, /* Environment. */
NULL, /* Use current drive/directory. */
&si, /* Startup information. */
&pi /* Returns process information. */
))
{
_assuan_log_printf ("CreateProcess failed: %s\n", w32_strerror (-1));
CloseHandle (fd_to_handle (rp[0]));
CloseHandle (fd_to_handle (rp[1]));
CloseHandle (fd_to_handle (wp[0]));
CloseHandle (fd_to_handle (wp[1]));
if (nullfd != INVALID_HANDLE_VALUE)
CloseHandle (nullfd);
xfree (cmdline);
_assuan_release_context (*ctx);
return ASSUAN_General_Error;
}
xfree (cmdline);
cmdline = NULL;
if (nullfd != INVALID_HANDLE_VALUE)
{
CloseHandle (nullfd);
nullfd = INVALID_HANDLE_VALUE;
}
CloseHandle (fd_to_handle (rp[1]));
CloseHandle (fd_to_handle (wp[0]));
/* _assuan_log_printf ("CreateProcess ready: hProcess=%p hThread=%p" */
/* " dwProcessID=%d dwThreadId=%d\n", */
/* pi.hProcess, pi.hThread, */
/* (int) pi.dwProcessId, (int) pi.dwThreadId); */
ResumeThread (pi.hThread);
CloseHandle (pi.hThread);
(*ctx)->pid = 0; /* We don't use the PID. */
CloseHandle (pi.hProcess); /* We don't need to wait for the process. */
#else /*!HAVE_W32_SYSTEM*/
assuan_error_t err;
int rp[2];
int wp[2];
char mypidstr[50];
if (!ctx || !name || !argv || !argv[0])
return ASSUAN_Invalid_Value;
fix_signals ();
sprintf (mypidstr, "%lu", (unsigned long)getpid ());
if (pipe (rp) < 0)
return ASSUAN_General_Error;
if (pipe (wp) < 0)
{
close (rp[0]);
close (rp[1]);
return ASSUAN_General_Error;
}
err = _assuan_new_context (ctx);
if (err)
{
close (rp[0]);
close (rp[1]);
close (wp[0]);
close (wp[1]);
return err;
}
(*ctx)->pipe_mode = 1;
(*ctx)->inbound.fd = rp[0]; /* Our inbound is read end of read pipe. */
(*ctx)->outbound.fd = wp[1]; /* Our outbound is write end of write pipe. */
(*ctx)->deinit_handler = do_deinit;
(*ctx)->finish_handler = do_finish;
/* FIXME: For GPGME we should better use _gpgme_io_spawn. The PID
stored here is actually soon useless. */
(*ctx)->pid = fork ();
if ((*ctx)->pid < 0)
{
close (rp[0]);
close (rp[1]);
close (wp[0]);
close (wp[1]);
_assuan_release_context (*ctx);
return ASSUAN_General_Error;
}
if ((*ctx)->pid == 0)
{
#ifdef _ASSUAN_USE_DOUBLE_FORK
pid_t pid;
if ((pid = fork ()) == 0)
#endif
{
int i, n;
char errbuf[512];
int *fdp;
if (atfork)
atfork (atforkvalue, 0);
/* Dup handles to stdin/stdout. */
if (rp[1] != STDOUT_FILENO)
{
if (dup2 (rp[1], STDOUT_FILENO) == -1)
{
_assuan_log_printf ("dup2 failed in child: %s\n",
strerror (errno));
_exit (4);
}
}
if (wp[0] != STDIN_FILENO)
{
if (dup2 (wp[0], STDIN_FILENO) == -1)
{
_assuan_log_printf ("dup2 failed in child: %s\n",
strerror (errno));
_exit (4);
}
}
/* Dup stderr to /dev/null unless it is in the list of FDs to be
passed to the child. */
fdp = fd_child_list;
if (fdp)
{
for (; *fdp != -1 && *fdp != STDERR_FILENO; fdp++)
;
}
if (!fdp || *fdp == -1)
{
int fd = open ("/dev/null", O_WRONLY);
if (fd == -1)
{
_assuan_log_printf ("can't open `/dev/null': %s\n",
strerror (errno));
_exit (4);
}
if (dup2 (fd, STDERR_FILENO) == -1)
{
_assuan_log_printf ("dup2(dev/null, 2) failed: %s\n",
strerror (errno));
_exit (4);
}
}
/* Close all files which will not be duped and are not in the
fd_child_list. */
n = sysconf (_SC_OPEN_MAX);
if (n < 0)
n = MAX_OPEN_FDS;
for (i=0; i < n; i++)
{
if ( i == STDIN_FILENO || i == STDOUT_FILENO
|| i == STDERR_FILENO)
continue;
fdp = fd_child_list;
if (fdp)
{
while (*fdp != -1 && *fdp != i)
fdp++;
}
if (!(fdp && *fdp != -1))
close(i);
}
errno = 0;
/* We store our parents pid in the environment so that the
execed assuan server is able to read the actual pid of the
client. The server can't use getppid becuase it might have
been double forked before the assuan server has been
initialized. */
setenv ("_assuan_pipe_connect_pid", mypidstr, 1);
- execv (name, argv);
+ execv (name, (char *const *) argv);
/* oops - use the pipe to tell the parent about it */
snprintf (errbuf, sizeof(errbuf)-1,
"ERR %d can't exec `%s': %.50s\n",
ASSUAN_Problem_Starting_Server, name, strerror (errno));
errbuf[sizeof(errbuf)-1] = 0;
writen (1, errbuf, strlen (errbuf));
_exit (4);
}
#ifdef _ASSUAN_USE_DOUBLE_FORK
if (pid == -1)
_exit (1);
else
_exit (0);
#endif
}
#ifdef _ASSUAN_USE_DOUBLE_FORK
waitpid ((*ctx)->pid, NULL, 0);
(*ctx)->pid = -1;
#endif
close (rp[1]);
close (wp[0]);
#endif /*!HAVE_W32_SYSTEM*/
/* initial handshake */
{
int okay, off;
err = _assuan_read_from_server (*ctx, &okay, &off);
if (err)
_assuan_log_printf ("can't connect server: %s\n",
assuan_strerror (err));
else if (okay != 1)
{
_assuan_log_printf ("can't connect server: `%s'\n",
(*ctx)->inbound.line);
err = ASSUAN_Connect_Failed;
}
}
if (err)
{
assuan_disconnect (*ctx);
*ctx = NULL;
}
return err;
}
/* Connect to a server over a pipe, creating the assuan context and
returning it in CTX. The server filename is NAME, the argument
vector in ARGV. FD_CHILD_LIST is a -1 terminated list of file
descriptors not to close in the child. */
assuan_error_t
-assuan_pipe_connect (assuan_context_t *ctx, const char *name, char *const argv[],
- int *fd_child_list)
+assuan_pipe_connect (assuan_context_t *ctx, const char *name,
+ const char *const argv[], int *fd_child_list)
{
return assuan_pipe_connect2 (ctx, name, argv, fd_child_list, NULL, NULL);
}
diff --git a/assuan/assuan.h b/assuan/assuan.h
index 68336edc..b2641b24 100644
--- a/assuan/assuan.h
+++ b/assuan/assuan.h
@@ -1,483 +1,485 @@
/* assuan.c - Definitions for the Assuan IPC library
* Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
*
* This file is part of Assuan.
*
* Assuan 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.
*
* Assuan is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifndef ASSUAN_H
#define ASSUAN_H
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
/* To use this file with libraries the following macros are often
useful:
#define _ASSUAN_EXT_SYM_PREFIX _foo_
This prefixes all external symbols with "_foo_".
#define _ASSUAN_NO_PTH
This avoids inclusion of special GNU Pth hacks.
#define _ASSUAN_NO_FIXED_SIGNALS
This disables changing of certain signal handler; i.e. SIGPIPE.
#define _ASSUAN_USE_DOUBLE_FORK
Use a double fork approach when connecting to a server through a pipe.
*/
/**** Begin GPGME specific modifications. ******/
#define _ASSUAN_EXT_SYM_PREFIX _gpgme_
#define _ASSUAN_NO_PTH
#define _ASSUAN_NO_FIXED_SIGNALS
#define _ASSUAN_USE_DOUBLE_FORK
#ifdef _ASSUAN_IN_GPGME_BUILD_ASSUAN
int _gpgme_io_read (int fd, void *buffer, size_t count);
int _gpgme_io_write (int fd, const void *buffer, size_t count);
ssize_t _gpgme_ath_waitpid (pid_t pid, int *status, int options);
#ifdef HAVE_W32_SYSTEM
int _gpgme_ath_accept (int s, void *addr, int *length_ptr);
#else /*!HAVE_W32_SYSTEM*/
struct sockaddr;
struct msghdr;
ssize_t _gpgme_ath_select (int nfd, fd_set *rset, fd_set *wset, fd_set *eset,
struct timeval *timeout);
int _gpgme_ath_accept (int s, struct sockaddr *addr, socklen_t *length_ptr);
int _gpgme_ath_connect (int s, struct sockaddr *addr, socklen_t length);
int _gpgme_ath_sendmsg (int s, const struct msghdr *msg, int flags);
int _gpgme_ath_recvmsg (int s, struct msghdr *msg, int flags);
#endif /*!HAVE_W32_SYSTEM*/
#define read _gpgme_io_read
#define write _gpgme_io_write
#define waitpid _gpgme_ath_waitpid
#define select _gpgme_ath_select
#define accept _gpgme_ath_accept
#define connect _gpgme_ath_connect
#define sendmsg _gpgme_ath_sendmsg
#define recvmsg _gpgme_ath_recvmsg
#endif /*_ASSUAN_IN_GPGME_BUILD_ASSUAN*/
/**** End GPGME specific modifications. ******/
#ifdef _ASSUAN_EXT_SYM_PREFIX
#define _ASSUAN_PREFIX1(x,y) x ## y
#define _ASSUAN_PREFIX2(x,y) _ASSUAN_PREFIX1(x,y)
#define _ASSUAN_PREFIX(x) _ASSUAN_PREFIX2(_ASSUAN_EXT_SYM_PREFIX,x)
#define assuan_ _ASSUAN_PREFIX(assuan_)
#define assuan_register_command _ASSUAN_PREFIX(assuan_register_command)
#define assuan_register_bye_notify _ASSUAN_PREFIX(assuan_register_bye_notify)
#define assuan_register_reset_notify \
_ASSUAN_PREFIX(assuan_register_reset_notify)
#define assuan_register_cancel_notify \
_ASSUAN_PREFIX(assuan_register_cancel_notify)
#define assuan_register_input_notify \
_ASSUAN_PREFIX(assuan_register_input_notify)
#define assuan_register_output_notify \
_ASSUAN_PREFIX(assuan_register_output_notify)
#define assuan_register_option_handler \
_ASSUAN_PREFIX(assuan_register_option_handler)
#define assuan_process _ASSUAN_PREFIX(assuan_process)
#define assuan_process_next _ASSUAN_PREFIX(assuan_process_next)
#define assuan_get_active_fds _ASSUAN_PREFIX(assuan_get_active_fds)
#define assuan_get_data_fp _ASSUAN_PREFIX(assuan_get_data_fp)
#define assuan_set_okay_line _ASSUAN_PREFIX(assuan_set_okay_line)
#define assuan_write_status _ASSUAN_PREFIX(assuan_write_status)
#define assuan_command_parse_fd _ASSUAN_PREFIX(assuan_command_parse_fd)
#define assuan_set_hello_line _ASSUAN_PREFIX(assuan_set_hello_line)
#define assuan_accept _ASSUAN_PREFIX(assuan_accept)
#define assuan_get_input_fd _ASSUAN_PREFIX(assuan_get_input_fd)
#define assuan_get_output_fd _ASSUAN_PREFIX(assuan_get_output_fd)
#define assuan_close_input_fd _ASSUAN_PREFIX(assuan_close_input_fd)
#define assuan_close_output_fd _ASSUAN_PREFIX(assuan_close_output_fd)
#define assuan_init_pipe_server _ASSUAN_PREFIX(assuan_init_pipe_server)
#define assuan_deinit_server _ASSUAN_PREFIX(assuan_deinit_server)
#define assuan_init_socket_server _ASSUAN_PREFIX(assuan_init_socket_server)
#define assuan_init_connected_socket_server \
_ASSUAN_PREFIX(assuan_init_connected_socket_server)
#define assuan_pipe_connect _ASSUAN_PREFIX(assuan_pipe_connect)
#define assuan_socket_connect _ASSUAN_PREFIX(assuan_socket_connect)
#define assuan_domain_connect _ASSUAN_PREFIX(assuan_domain_connect)
#define assuan_init_domain_server _ASSUAN_PREFIX(assuan_init_domain_server)
#define assuan_disconnect _ASSUAN_PREFIX(assuan_disconnect)
#define assuan_get_pid _ASSUAN_PREFIX(assuan_get_pid)
#define assuan_transact _ASSUAN_PREFIX(assuan_transact)
#define assuan_inquire _ASSUAN_PREFIX(assuan_inquire)
#define assuan_read_line _ASSUAN_PREFIX(assuan_read_line)
#define assuan_pending_line _ASSUAN_PREFIX(assuan_pending_line)
#define assuan_write_line _ASSUAN_PREFIX(assuan_write_line)
#define assuan_send_data _ASSUAN_PREFIX(assuan_send_data)
#define assuan_sendfd _ASSUAN_PREFIX(assuan_sendfd)
#define assuan_receivefd _ASSUAN_PREFIX(assuan_receivefd)
#define assuan_set_malloc_hooks _ASSUAN_PREFIX(assuan_set_malloc_hooks)
#define assuan_set_log_stream _ASSUAN_PREFIX(assuan_set_log_stream)
#define assuan_set_error _ASSUAN_PREFIX(assuan_set_error)
#define assuan_set_pointer _ASSUAN_PREFIX(assuan_set_pointer)
#define assuan_get_pointer _ASSUAN_PREFIX(assuan_get_pointer)
#define assuan_begin_confidential _ASSUAN_PREFIX(assuan_begin_confidential)
#define assuan_end_confidential _ASSUAN_PREFIX(assuan_end_confidential)
#define assuan_strerror _ASSUAN_PREFIX(assuan_strerror)
#define assuan_set_assuan_log_stream \
_ASSUAN_PREFIX(assuan_set_assuan_log_stream)
#define assuan_get_assuan_log_stream \
_ASSUAN_PREFIX(assuan_get_assuan_log_stream)
#define assuan_get_assuan_log_prefix \
_ASSUAN_PREFIX(assuan_get_assuan_log_prefix)
#define assuan_set_flag _ASSUAN_PREFIX(assuan_set_flag)
#define assuan_get_flag _ASSUAN_PREFIX(assuan_get_flag)
/* And now the internal functions, argh... */
#define _assuan_read_line _ASSUAN_PREFIX(_assuan_read_line)
#define _assuan_cookie_write_data _ASSUAN_PREFIX(_assuan_cookie_write_data)
#define _assuan_cookie_write_flush _ASSUAN_PREFIX(_assuan_cookie_write_flush)
#define _assuan_read_from_server _ASSUAN_PREFIX(_assuan_read_from_server)
#define _assuan_domain_init _ASSUAN_PREFIX(_assuan_domain_init)
#define _assuan_register_std_commands \
_ASSUAN_PREFIX(_assuan_register_std_commands)
#define _assuan_simple_read _ASSUAN_PREFIX(_assuan_simple_read)
#define _assuan_simple_write _ASSUAN_PREFIX(_assuan_simple_write)
#define _assuan_simple_read _ASSUAN_PREFIX(_assuan_simple_read)
#define _assuan_simple_write _ASSUAN_PREFIX(_assuan_simple_write)
#define _assuan_new_context _ASSUAN_PREFIX(_assuan_new_context)
#define _assuan_release_context _ASSUAN_PREFIX(_assuan_release_context)
#define _assuan_malloc _ASSUAN_PREFIX(_assuan_malloc)
#define _assuan_realloc _ASSUAN_PREFIX(_assuan_realloc)
#define _assuan_calloc _ASSUAN_PREFIX(_assuan_calloc)
#define _assuan_free _ASSUAN_PREFIX(_assuan_free)
#define _assuan_log_print_buffer _ASSUAN_PREFIX(_assuan_log_print_buffer)
#define _assuan_log_sanitized_string \
_ASSUAN_PREFIX(_assuan_log_sanitized_string)
#define _assuan_log_printf _ASSUAN_PREFIX(_assuan_log_printf)
#define _assuan_set_default_log_stream \
_ASSUAN_PREFIX(_assuan_set_default_log_stream)
#define _assuan_w32_strerror _ASSUAN_PREFIX(_assuan_w32_strerror)
#define _assuan_write_line _ASSUAN_PREFIX(_assuan_write_line)
#define _assuan_close _ASSUAN_PREFIX(_assuan_close)
#define _assuan_sock_new _ASSUAN_PREFIX(_assuan_sock_new)
#define _assuan_sock_bind _ASSUAN_PREFIX(_assuan_sock_bind)
#define _assuan_sock_connect _ASSUAN_PREFIX(_assuan_sock_connect)
#endif /*_ASSUAN_EXT_SYM_PREFIX*/
#ifdef __cplusplus
extern "C"
{
#if 0
}
#endif
#endif
typedef enum
{
ASSUAN_No_Error = 0,
ASSUAN_General_Error = 1,
ASSUAN_Out_Of_Core = 2,
ASSUAN_Invalid_Value = 3,
ASSUAN_Timeout = 4,
ASSUAN_Read_Error = 5,
ASSUAN_Write_Error = 6,
ASSUAN_Problem_Starting_Server = 7,
ASSUAN_Not_A_Server = 8,
ASSUAN_Not_A_Client = 9,
ASSUAN_Nested_Commands = 10,
ASSUAN_Invalid_Response = 11,
ASSUAN_No_Data_Callback = 12,
ASSUAN_No_Inquire_Callback = 13,
ASSUAN_Connect_Failed = 14,
ASSUAN_Accept_Failed = 15,
/* Error codes above 99 are meant as status codes */
ASSUAN_Not_Implemented = 100,
ASSUAN_Server_Fault = 101,
ASSUAN_Invalid_Command = 102,
ASSUAN_Unknown_Command = 103,
ASSUAN_Syntax_Error = 104,
ASSUAN_Parameter_Error = 105,
ASSUAN_Parameter_Conflict = 106,
ASSUAN_Line_Too_Long = 107,
ASSUAN_Line_Not_Terminated = 108,
ASSUAN_No_Input = 109,
ASSUAN_No_Output = 110,
ASSUAN_Canceled = 111,
ASSUAN_Unsupported_Algorithm = 112,
ASSUAN_Server_Resource_Problem = 113,
ASSUAN_Server_IO_Error = 114,
ASSUAN_Server_Bug = 115,
ASSUAN_No_Data_Available = 116,
ASSUAN_Invalid_Data = 117,
ASSUAN_Unexpected_Command = 118,
ASSUAN_Too_Much_Data = 119,
ASSUAN_Inquire_Unknown = 120,
ASSUAN_Inquire_Error = 121,
ASSUAN_Invalid_Option = 122,
ASSUAN_Invalid_Index = 123,
ASSUAN_Unexpected_Status = 124,
ASSUAN_Unexpected_Data = 125,
ASSUAN_Invalid_Status = 126,
ASSUAN_Locale_Problem = 127,
ASSUAN_Not_Confirmed = 128,
/* Warning: Don't use the rror codes, below they are deprecated. */
ASSUAN_Bad_Certificate = 201,
ASSUAN_Bad_Certificate_Chain = 202,
ASSUAN_Missing_Certificate = 203,
ASSUAN_Bad_Signature = 204,
ASSUAN_No_Agent = 205,
ASSUAN_Agent_Error = 206,
ASSUAN_No_Public_Key = 207,
ASSUAN_No_Secret_Key = 208,
ASSUAN_Invalid_Name = 209,
ASSUAN_Cert_Revoked = 301,
ASSUAN_No_CRL_For_Cert = 302,
ASSUAN_CRL_Too_Old = 303,
ASSUAN_Not_Trusted = 304,
ASSUAN_Card_Error = 401,
ASSUAN_Invalid_Card = 402,
ASSUAN_No_PKCS15_App = 403,
ASSUAN_Card_Not_Present = 404,
ASSUAN_Invalid_Id = 405,
/* Error codes in the range 1000 to 9999 may be used by applications
at their own discretion. */
ASSUAN_USER_ERROR_FIRST = 1000,
ASSUAN_USER_ERROR_LAST = 9999
} assuan_error_t;
typedef assuan_error_t AssuanError; /* Deprecated. */
/* This is a list of pre-registered ASSUAN commands */
/* NOTE, these command IDs are now deprectated and solely exists for
compatibility reasons. */
typedef enum
{
ASSUAN_CMD_NOP = 0,
ASSUAN_CMD_CANCEL, /* cancel the current request */
ASSUAN_CMD_BYE,
ASSUAN_CMD_AUTH,
ASSUAN_CMD_RESET,
ASSUAN_CMD_OPTION,
ASSUAN_CMD_DATA,
ASSUAN_CMD_END,
ASSUAN_CMD_INPUT,
ASSUAN_CMD_OUTPUT,
ASSUAN_CMD_USER = 256 /* Other commands should be used with this offset*/
} AssuanCommand;
/* Definitions of flags for assuan_set_flag(). */
typedef enum
{
/* When using a pipe server, by default Assuan will wait for the
forked process to die in assuan_disconnect. In certain cases
this is not desirable. By setting this flag, the waitpid will
be skipped and the caller is responsible to cleanup a forked
process. */
ASSUAN_NO_WAITPID = 1
}
assuan_flag_t;
#define ASSUAN_LINELENGTH 1002 /* 1000 + [CR,]LF */
struct assuan_context_s;
typedef struct assuan_context_s *assuan_context_t;
typedef struct assuan_context_s *ASSUAN_CONTEXT;
/*-- assuan-handler.c --*/
int assuan_register_command (assuan_context_t ctx,
const char *cmd_string,
int (*handler)(assuan_context_t, char *));
int assuan_register_bye_notify (assuan_context_t ctx,
void (*fnc)(assuan_context_t));
int assuan_register_reset_notify (assuan_context_t ctx,
void (*fnc)(assuan_context_t));
int assuan_register_cancel_notify (assuan_context_t ctx,
void (*fnc)(assuan_context_t));
int assuan_register_input_notify (assuan_context_t ctx,
void (*fnc)(assuan_context_t, const char *));
int assuan_register_output_notify (assuan_context_t ctx,
void (*fnc)(assuan_context_t, const char *));
int assuan_register_option_handler (assuan_context_t ctx,
int (*fnc)(assuan_context_t,
const char*, const char*));
int assuan_process (assuan_context_t ctx);
int assuan_process_next (assuan_context_t ctx);
int assuan_get_active_fds (assuan_context_t ctx, int what,
int *fdarray, int fdarraysize);
FILE *assuan_get_data_fp (assuan_context_t ctx);
assuan_error_t assuan_set_okay_line (assuan_context_t ctx, const char *line);
assuan_error_t assuan_write_status (assuan_context_t ctx,
const char *keyword, const char *text);
/* Negotiate a file descriptor. If LINE contains "FD=N", returns N
assuming a local file descriptor. If LINE contains "FD" reads a
file descriptor via CTX and stores it in *RDF (the CTX must be
capable of passing file descriptors). */
assuan_error_t assuan_command_parse_fd (assuan_context_t ctx, char *line,
int *rfd);
/*-- assuan-listen.c --*/
assuan_error_t assuan_set_hello_line (assuan_context_t ctx, const char *line);
assuan_error_t assuan_accept (assuan_context_t ctx);
int assuan_get_input_fd (assuan_context_t ctx);
int assuan_get_output_fd (assuan_context_t ctx);
assuan_error_t assuan_close_input_fd (assuan_context_t ctx);
assuan_error_t assuan_close_output_fd (assuan_context_t ctx);
/*-- assuan-pipe-server.c --*/
int assuan_init_pipe_server (assuan_context_t *r_ctx, int filedes[2]);
void assuan_deinit_server (assuan_context_t ctx);
/*-- assuan-socket-server.c --*/
int assuan_init_socket_server (assuan_context_t *r_ctx, int listen_fd);
int assuan_init_connected_socket_server (assuan_context_t *r_ctx, int fd);
/*-- assuan-pipe-connect.c --*/
assuan_error_t assuan_pipe_connect (assuan_context_t *ctx, const char *name,
- char *const argv[], int *fd_child_list);
+ const char *const argv[],
+ int *fd_child_list);
assuan_error_t assuan_pipe_connect2 (assuan_context_t *ctx, const char *name,
- char *const argv[], int *fd_child_list,
+ const char *const argv[],
+ int *fd_child_list,
void (*atfork) (void*, int),
void *atforkvalue);
/*-- assuan-socket-connect.c --*/
assuan_error_t assuan_socket_connect (assuan_context_t *ctx, const char *name,
pid_t server_pid);
/*-- assuan-domain-connect.c --*/
/* Connect to a Unix domain socket server. RENDEZVOUSFD is
bidirectional file descriptor (normally returned via socketpair)
which the client can use to rendezvous with the server. SERVER s
the server's pid. */
assuan_error_t assuan_domain_connect (assuan_context_t *r_ctx,
int rendezvousfd,
pid_t server);
/*-- assuan-domain-server.c --*/
/* RENDEZVOUSFD is a bidirectional file descriptor (normally returned
via socketpair) that the domain server can use to rendezvous with
the client. CLIENT is the client's pid. */
assuan_error_t assuan_init_domain_server (assuan_context_t *r_ctx,
int rendezvousfd,
pid_t client);
/*-- assuan-connect.c --*/
void assuan_disconnect (assuan_context_t ctx);
pid_t assuan_get_pid (assuan_context_t ctx);
/*-- assuan-client.c --*/
assuan_error_t
assuan_transact (assuan_context_t ctx,
const char *command,
assuan_error_t (*data_cb)(void *, const void *, size_t),
void *data_cb_arg,
assuan_error_t (*inquire_cb)(void*, const char *),
void *inquire_cb_arg,
assuan_error_t (*status_cb)(void*, const char *),
void *status_cb_arg);
/*-- assuan-inquire.c --*/
assuan_error_t assuan_inquire (assuan_context_t ctx, const char *keyword,
unsigned char **r_buffer, size_t *r_length,
size_t maxlen);
/*-- assuan-buffer.c --*/
assuan_error_t assuan_read_line (assuan_context_t ctx,
char **line, size_t *linelen);
int assuan_pending_line (assuan_context_t ctx);
assuan_error_t assuan_write_line (assuan_context_t ctx, const char *line );
assuan_error_t assuan_send_data (assuan_context_t ctx,
const void *buffer, size_t length);
/* The file descriptor must be pending before assuan_receivefd is
call. This means that assuan_sendfd should be called *before* the
trigger is sent (normally via assuan_send_data ("I sent you a
descriptor")). */
assuan_error_t assuan_sendfd (assuan_context_t ctx, int fd);
assuan_error_t assuan_receivefd (assuan_context_t ctx, int *fd);
/*-- assuan-util.c --*/
void assuan_set_malloc_hooks ( void *(*new_alloc_func)(size_t n),
void *(*new_realloc_func)(void *p, size_t n),
void (*new_free_func)(void*) );
void assuan_set_log_stream (assuan_context_t ctx, FILE *fp);
int assuan_set_error (assuan_context_t ctx, int err, const char *text);
void assuan_set_pointer (assuan_context_t ctx, void *pointer);
void *assuan_get_pointer (assuan_context_t ctx);
void assuan_begin_confidential (assuan_context_t ctx);
void assuan_end_confidential (assuan_context_t ctx);
/* For context CTX, set the flag FLAG to VALUE. Values for flags
are usually 1 or 0 but certain flags might allow for other values;
see the description of the type assuan_flag_t for details. */
void assuan_set_flag (assuan_context_t ctx, assuan_flag_t flag, int value);
/* Return the VALUE of FLAG in context CTX. */
int assuan_get_flag (assuan_context_t ctx, assuan_flag_t flag);
/*-- assuan-errors.c (built) --*/
const char *assuan_strerror (assuan_error_t err);
/*-- assuan-logging.c --*/
/* Set the stream to which assuan should log message not associated
with a context. By default, this is stderr. The default value
will be changed when the first log stream is associated with a
context. Note, that this function is not thread-safe and should
in general be used right at startup. */
extern void assuan_set_assuan_log_stream (FILE *fp);
/* Return the stream which is currently being using for global logging. */
extern FILE *assuan_get_assuan_log_stream (void);
/* Set the prefix to be used at the start of a line emitted by assuan
on the log stream. The default is the empty string. Note, that
this function is not thread-safe and should in general be used
right at startup. */
void assuan_set_assuan_log_prefix (const char *text);
/* Return a prefix to be used at the start of a line emitted by assuan
on the log stream. The default implementation returns the empty
string, i.e. "" */
const char *assuan_get_assuan_log_prefix (void);
#ifdef __cplusplus
}
#endif
#endif /* ASSUAN_H */

File Metadata

Mime Type
text/x-diff
Expires
Mon, May 12, 6:10 PM (12 h, 55 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
61/a0/e986aa82c3d29f61e436698e4c8d

Event Timeline