From 90beb50551e3fe8be777115cb6ea88b8f54b76b1 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Sat, 1 Feb 2003 18:53:06 +0000 Subject: [PATCH] 2003-02-01 Marcus Brinkmann * assuan/: Update files to 2002-11-10 version of assuan. gpgme/ 2003-02-01 Marcus Brinkmann * engine-gpgsm.c (map_assuan_error): Replace ASSUAN_Bad_Certificate_Path with ASSUAN_Bad_Certificate_Chain. (gpgsm_new): Use assuan_pipe_connect instead assuan_pipe_connect2. * util.h (DIMof): Remove macro. * ops.h (_gpgme_op_event_cb, _gpgme_op_event_cb_user, _gpgme_data_unread): Prototypes removed. --- ChangeLog | 4 ++ assuan/ChangeLog | 74 ++++++++++++++++++-- assuan/Makefile.am | 37 +++++----- assuan/assuan-buffer.c | 79 ++++++++++----------- assuan/assuan-client.c | 26 +++---- assuan/assuan-connect.c | 26 +++---- assuan/assuan-defs.h | 34 +++++---- assuan/assuan-handler.c | 46 ++++++++---- assuan/assuan-inquire.c | 24 +++---- assuan/assuan-io.c | 60 ++++++++++++++++ assuan/assuan-listen.c | 26 +++---- assuan/assuan-pipe-connect.c | 123 +++++++++++++++----------------- assuan/assuan-pipe-server.c | 28 ++++---- assuan/assuan-socket-connect.c | 26 +++---- assuan/assuan-socket-server.c | 104 +++++++++++++++++---------- assuan/assuan-util.c | 124 +++++++++++++++++++++------------ assuan/assuan.h | 34 +++++---- assuan/mkerrors | 26 +++---- gpgme/ChangeLog | 11 +++ gpgme/engine-gpgsm.c | 7 +- gpgme/ops.h | 6 -- gpgme/util.h | 1 - 22 files changed, 564 insertions(+), 362 deletions(-) create mode 100644 assuan/assuan-io.c diff --git a/ChangeLog b/ChangeLog index 5a9e954a..12959596 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2003-02-01 Marcus Brinkmann + + * assuan/: Update files to 2002-11-10 version of assuan. + 2003-01-29 Marcus Brinkmann * bonobo/gpgme.c, bonobo/main.c, bonobo/main.h, bonobo/Makefile, diff --git a/assuan/ChangeLog b/assuan/ChangeLog index 0cf53b89..85dc5ef8 100644 --- a/assuan/ChangeLog +++ b/assuan/ChangeLog @@ -1,12 +1,74 @@ -2002-05-03 Werner Koch +2002-11-10 Werner Koch - * assuan-pipe-connect.c (assuan_pipe_connect2): New to extend - assuan_pipe_connect with some flags. Implemented a bitbucket for - stderr. + * 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-04-26 Werner Koch +2002-10-31 Neal H. Walfield - * Makefile.am: Create libtool libraries + * assuan-util.c: Include . + (_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 + + * 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 + + * assuan.h: Renamed Bad_Certificate_Path to Bad_Certificate_Chain. + +2002-07-30 Werner Koch + + Changed the license from GPL to LGPL. + +2002-07-23 Werner Koch + + * assuan-handler.c (_IO_cookie_io_functions_t): Define it here if + it does not exists. + +2002-06-27 Werner Koch + + * 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 + + * assuan-buffer.c (assuan_write_line): Make sure we never + accidently print an extra LF. + +2002-05-23 Werner Koch + + * 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 + + * 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 diff --git a/assuan/Makefile.am b/assuan/Makefile.am index 8d11e15a..57c95fa3 100644 --- a/assuan/Makefile.am +++ b/assuan/Makefile.am @@ -1,21 +1,21 @@ -# Assuan Makefile for test purposes -# Copyright (C) 2001 Free Software Foundation, Inc. +# Assuan Makefile +# Copyright (C) 2001, 2002 Free Software Foundation, Inc. # -# This file is part of GnuPG. +# This file is part of Assuan. # -# GnuPG is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# GnuPG 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 General Public License for more details. -# -# You should have received a copy of the GNU 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 +# 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 ## Process this file with automake to produce Makefile.in @@ -27,7 +27,7 @@ MOSTLYCLEANFILES = assuan-errors.c noinst_LTLIBRARIES = libassuan.la -#libassuan_a_LDFLAGS = +#libassuan_la_LDFLAGS = libassuan_la_SOURCES = \ assuan.h \ assuan-defs.h \ @@ -42,7 +42,8 @@ libassuan_la_SOURCES = \ assuan-pipe-server.c \ assuan-socket-server.c \ assuan-pipe-connect.c \ - assuan-socket-connect.c + assuan-socket-connect.c \ + assuan-io.c assuan-errors.c : assuan.h diff --git a/assuan/assuan-buffer.c b/assuan/assuan-buffer.c index 29f94794..8017183e 100644 --- a/assuan/assuan-buffer.c +++ b/assuan/assuan-buffer.c @@ -1,21 +1,21 @@ /* assuan-buffer.c - read and send data - * Copyright (C) 2001 Free Software Foundation, Inc. + * Copyright (C) 2001, 2002 Free Software Foundation, Inc. * - * This file is part of GnuPG. + * This file is part of Assuan. * - * GnuPG is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * 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. * - * GnuPG 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 General Public License for more details. + * 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 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 + * 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 */ #include @@ -25,9 +25,6 @@ #include #include #include -#ifdef USE_GNU_PTH -# include -#endif #include "assuan-defs.h" #ifdef HAVE_JNLIB_LOGGING @@ -51,11 +48,7 @@ writen ( int fd, const char *buffer, size_t length ) { while (length) { -#ifdef USE_GNU_PTH - int nwritten = pth_write (fd, buffer, length); -#else - int nwritten = write (fd, buffer, length); -#endif + ssize_t nwritten = _assuan_write (fd, buffer, length); if (nwritten < 0) { @@ -80,11 +73,8 @@ readline (int fd, char *buf, size_t buflen, int *r_nread, int *eof) *r_nread = 0; while (nleft > 0) { -#ifdef USE_GNU_PTH - int n = pth_read (fd, buf, nleft); -#else - int n = read (fd, buf, nleft); -#endif + ssize_t n = _assuan_read (fd, buf, nleft); + if (n < 0) { if (errno == EINTR) @@ -210,13 +200,12 @@ _assuan_read_line (ASSUAN_CONTEXT ctx) /* Read the next line from the client or server and return a pointer - to a buffer with holding that line. linelen returns the length of - the line. This buffer is valid until another read operation is - done on this buffer. The caller is allowed to modify this buffer. - He should only use the buffer if the function returns without an - error. + in *LINE to a buffer holding the line. LINELEN is the length of + *LINE. The buffer is valid until the next read operation on it. + The caller may modify the buffer. The buffer is invalid (i.e. must + not be used) if an error is returned. - Returns: 0 on success or an assuan error code + Returns 0 on success or an assuan error code. See also: assuan_pending_line(). */ AssuanError @@ -234,8 +223,8 @@ assuan_read_line (ASSUAN_CONTEXT ctx, char **line, size_t *linelen) } -/* Return true when a full line is pending for a read, without the need - for actual IO */ +/* Return true if a full line is buffered (i.e. an entire line may be + read without any I/O). */ int assuan_pending_line (ASSUAN_CONTEXT ctx) { @@ -247,23 +236,31 @@ AssuanError assuan_write_line (ASSUAN_CONTEXT ctx, const char *line ) { int rc; - + size_t len; + const char *s; + if (!ctx) return ASSUAN_Invalid_Value; - /* fixme: we should do some kind of line buffering */ + /* Make sure that we never take a LF from the user - this might + violate the protocol. */ + s = strchr (line, '\n'); + len = s? (s-line) : strlen (line); + + /* fixme: we should do some kind of line buffering. */ if (ctx->log_fp) { fprintf (ctx->log_fp, "%s[%p] -> ", my_log_prefix (), ctx); + if (s) + fputs ("[supplied line contained a LF]", ctx->log_fp); if (ctx->confidential) fputs ("[Confidential data not shown]", ctx->log_fp); else - _assuan_log_print_buffer (ctx->log_fp, - line, strlen (line)); + _assuan_log_print_buffer (ctx->log_fp, line, len); putc ('\n', ctx->log_fp); } - rc = writen (ctx->outbound.fd, line, strlen(line)); + rc = writen (ctx->outbound.fd, line, len); if (rc) rc = ASSUAN_Write_Error; if (!rc) @@ -435,7 +432,3 @@ assuan_send_data (ASSUAN_CONTEXT ctx, const void *buffer, size_t length) return 0; } - - - - diff --git a/assuan/assuan-client.c b/assuan/assuan-client.c index 6c7a6e3e..d5c0ec81 100644 --- a/assuan/assuan-client.c +++ b/assuan/assuan-client.c @@ -1,21 +1,21 @@ /* assuan-client.c - client functions - * Copyright (C) 2001 Free Software Foundation, Inc. + * Copyright (C) 2001, 2002 Free Software Foundation, Inc. * - * This file is part of GnuPG. + * This file is part of Assuan. * - * GnuPG is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * 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. * - * GnuPG 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 General Public License for more details. + * 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 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 + * 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 */ #include diff --git a/assuan/assuan-connect.c b/assuan/assuan-connect.c index 49d4aac2..009aaab4 100644 --- a/assuan/assuan-connect.c +++ b/assuan/assuan-connect.c @@ -1,21 +1,21 @@ /* assuan-connect.c - Establish a connection (client) - * Copyright (C) 2001 Free Software Foundation, Inc. + * Copyright (C) 2001, 2002 Free Software Foundation, Inc. * - * This file is part of GnuPG. + * This file is part of Assuan. * - * GnuPG is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * 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. * - * GnuPG 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 General Public License for more details. + * 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 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 + * 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 diff --git a/assuan/assuan-defs.h b/assuan/assuan-defs.h index 6c502bf9..f8858692 100644 --- a/assuan/assuan-defs.h +++ b/assuan/assuan-defs.h @@ -1,21 +1,21 @@ /* assuan-defs.c - Internal definitions to Assuan - * Copyright (C) 2001 Free Software Foundation, Inc. + * Copyright (C) 2001, 2002 Free Software Foundation, Inc. * - * This file is part of GnuPG. + * This file is part of Assuan. * - * GnuPG is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * 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. * - * GnuPG 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 General Public License for more details. + * 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 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 + * 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_DEFS_H @@ -76,6 +76,7 @@ struct assuan_context_s { pid_t pid; /* In pipe mode, the pid of the child server process. In socket mode, the pid of the server */ int listen_fd; /* The fd we are listening on (used by socket servers) */ + int connected_fd; /* helper */ pid_t client_pid; /* for a socket server the PID of the client or -1 if not available */ @@ -101,6 +102,7 @@ struct assuan_context_s { }; + /*-- assuan-pipe-server.c --*/ int _assuan_new_context (ASSUAN_CONTEXT *r_ctx); void _assuan_release_context (ASSUAN_CONTEXT ctx); @@ -134,6 +136,12 @@ void _assuan_free (void *p); void _assuan_log_print_buffer (FILE *fp, const void *buffer, size_t length); void _assuan_log_sanitized_string (const char *string); +/*-- assuan-io.c --*/ + +/* Wraps the standard read and write functions to do the Right + Thing depending on our linkage. */ +ssize_t _assuan_read (int fd, void *buffer, size_t size); +ssize_t _assuan_write (int fd, const void *buffer, size_t size); #endif /*ASSUAN_DEFS_H*/ diff --git a/assuan/assuan-handler.c b/assuan/assuan-handler.c index 69b34b4f..6ddfe889 100644 --- a/assuan/assuan-handler.c +++ b/assuan/assuan-handler.c @@ -1,21 +1,21 @@ /* assuan-handler.c - dispatch commands - * Copyright (C) 2001 Free Software Foundation, Inc. + * Copyright (C) 2001, 2002 Free Software Foundation, Inc. * - * This file is part of GnuPG. + * This file is part of Assuan. * - * GnuPG is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * 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. * - * GnuPG 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 General Public License for more details. + * 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 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 + * 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 */ #include @@ -29,6 +29,26 @@ #define digitp(a) ((a) >= '0' && (a) <= '9') +#if !HAVE_FOPENCOOKIE +/* Provide structure for our dummy replacement function. Usually this + is defined in ../common/util.h but assuan should be self + contained. */ +/* Fixme: Remove fopencoookie :-(( */ +typedef struct +{ + ssize_t (*read)(void*,char*,size_t); + ssize_t (*write)(void*,const char*,size_t); + int (*seek)(void*,off_t*,int); + int (*close)(void*); +} _IO_cookie_io_functions_t; +typedef _IO_cookie_io_functions_t cookie_io_functions_t; +FILE *fopencookie (void *cookie, const char *opentype, + cookie_io_functions_t funclist); +#endif /*!HAVE_FOPENCOOKIE*/ + + + + static int dummy_handler (ASSUAN_CONTEXT ctx, char *line) { diff --git a/assuan/assuan-inquire.c b/assuan/assuan-inquire.c index 2bac1303..197e2101 100644 --- a/assuan/assuan-inquire.c +++ b/assuan/assuan-inquire.c @@ -1,21 +1,21 @@ /* assuan-inquire.c - handle inquire stuff * Copyright (C) 2001, 2002 Free Software Foundation, Inc. * - * This file is part of GnuPG. + * This file is part of Assuan. * - * GnuPG is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * 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. * - * GnuPG 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 General Public License for more details. + * 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 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 + * 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 */ #include diff --git a/assuan/assuan-io.c b/assuan/assuan-io.c new file mode 100644 index 00000000..135cb02d --- /dev/null +++ b/assuan/assuan-io.c @@ -0,0 +1,60 @@ +/* assuan-buffer.c - Wraps the read and write functions. + * Copyright (C) 2002 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 + */ + +#include +#include + +extern ssize_t pth_read (int fd, void *buffer, size_t size); +extern ssize_t pth_write (int fd, const void *buffer, size_t size); + +#pragma weak pth_read +#pragma weak pth_write + +ssize_t +_assuan_read (int fd, void *buffer, size_t size) +{ + static ssize_t (*reader) (int, void *, size_t); + + if (! reader) + { + if (pth_read) + reader = pth_read; + else + reader = read; + } + + return reader (fd, buffer, size); +} + +ssize_t +_assuan_write (int fd, const void *buffer, size_t size) +{ + static ssize_t (*writer) (int, const void *, size_t); + + if (! writer) + { + if (pth_write) + writer = pth_write; + else + writer = write; + } + + return writer (fd, buffer, size); +} diff --git a/assuan/assuan-listen.c b/assuan/assuan-listen.c index db63ad2b..3d4ee5f6 100644 --- a/assuan/assuan-listen.c +++ b/assuan/assuan-listen.c @@ -1,21 +1,21 @@ /* assuan-listen.c - Wait for a connection (server) - * Copyright (C) 2001 Free Software Foundation, Inc. + * Copyright (C) 2001, 2002 Free Software Foundation, Inc. * - * This file is part of GnuPG. + * This file is part of Assuan. * - * GnuPG is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * 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. * - * GnuPG 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 General Public License for more details. + * 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 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 + * 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 */ #include diff --git a/assuan/assuan-pipe-connect.c b/assuan/assuan-pipe-connect.c index 6614dab9..d7595c9f 100644 --- a/assuan/assuan-pipe-connect.c +++ b/assuan/assuan-pipe-connect.c @@ -1,21 +1,21 @@ /* assuan-pipe-connect.c - Establish a pipe connection (client) - * Copyright (C) 2001 Free Software Foundation, Inc. + * Copyright (C) 2001, 2002 Free Software Foundation, Inc. * - * This file is part of GnuPG. + * This file is part of Assuan. * - * GnuPG is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * 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. * - * GnuPG 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 General Public License for more details. + * 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 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 + * 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 @@ -28,10 +28,9 @@ #include #include #include +#include #include #include -#include -#include #include "assuan-defs.h" @@ -104,9 +103,8 @@ do_deinit (ASSUAN_CONTEXT ctx) vector in ARGV. FD_CHILD_LIST is a -1 terminated list of file descriptors not to close in the child. */ AssuanError -assuan_pipe_connect2 (ASSUAN_CONTEXT *ctx, const char *name, - char *const argv[], int *fd_child_list, - unsigned int connect_flags) +assuan_pipe_connect (ASSUAN_CONTEXT *ctx, const char *name, char *const argv[], + int *fd_child_list) { static int fixed_signals = 0; AssuanError err; @@ -172,35 +170,9 @@ assuan_pipe_connect2 (ASSUAN_CONTEXT *ctx, const char *name, { int i, n; char errbuf[512]; -#ifdef HAVE_JNLIB_LOGGING - int log_fd = log_get_fd (); -#endif - /* close all files which will not be duped but keep stderr - and log_stream for now */ - n = sysconf (_SC_OPEN_MAX); - if (n < 0) - n = MAX_OPEN_FDS; - for (i=0; i < n; i++) - { - int *fdp = fd_child_list; + int *fdp; - if (fdp) - { - while (*fdp != -1 && *fdp != i) - fdp++; - } - - if (!(fdp && *fdp != -1) - && i != fileno (stderr) -#ifdef HAVE_JNLIB_LOGGING - && i != log_fd -#endif - && i != rp[1] && i != wp[0]) - close(i); - } - errno = 0; - - /* Dup handles and to stdin/stdout and exec */ + /* Dup handles to stdin/stdout. */ if (rp[1] != STDOUT_FILENO) { if (dup2 (rp[1], STDOUT_FILENO) == -1) @@ -208,7 +180,6 @@ assuan_pipe_connect2 (ASSUAN_CONTEXT *ctx, const char *name, LOGERROR1 ("dup2 failed in child: %s\n", strerror (errno)); _exit (4); } - close (rp[1]); } if (wp[0] != STDIN_FILENO) { @@ -217,26 +188,53 @@ assuan_pipe_connect2 (ASSUAN_CONTEXT *ctx, const char *name, LOGERROR1 ("dup2 failed in child: %s\n", strerror (errno)); _exit (4); } - close (wp[0]); } - if ((connect_flags & 1)) - { /* dup stderr to /dev/null so that the application output - won't get clobbered with output from the backend */ - int fdzero = open ("/dev/null", O_WRONLY); - if (fdzero == -1) - { - LOGERROR1 ("can't open `/dev/null': %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) + { + LOGERROR1 ("can't open `/dev/null': %s\n", strerror (errno)); + _exit (4); } - if (dup2 (fdzero, 2) == -1) + if (dup2 (fd, STDERR_FILENO) == -1) { LOGERROR1 ("dup2(dev/null, 2) failed: %s\n", strerror (errno)); _exit (4); } - close (fdzero); } + + /* 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; + execv (name, argv); /* oops - use the pipe to tell the parent about it */ snprintf (errbuf, sizeof(errbuf)-1, "ERR %d can't exec `%s': %.50s\n", @@ -274,15 +272,6 @@ assuan_pipe_connect2 (ASSUAN_CONTEXT *ctx, const char *name, return err; } -AssuanError -assuan_pipe_connect (ASSUAN_CONTEXT *ctx, const char *name, char *const argv[], - int *fd_child_list) -{ - return assuan_pipe_connect2 (ctx, name, argv, fd_child_list, 0); -} - - - diff --git a/assuan/assuan-pipe-server.c b/assuan/assuan-pipe-server.c index 5c5d1248..82bb3228 100644 --- a/assuan/assuan-pipe-server.c +++ b/assuan/assuan-pipe-server.c @@ -1,21 +1,21 @@ /* assuan-pipe-server.c - Assuan server working over a pipe - * Copyright (C) 2001 Free Software Foundation, Inc. + * Copyright (C) 2001, 2002 Free Software Foundation, Inc. * - * This file is part of GnuPG. + * This file is part of Assuan. * - * GnuPG is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * 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. * - * GnuPG 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 General Public License for more details. + * 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 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 + * 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 */ #include @@ -46,7 +46,7 @@ finish_connection (ASSUAN_CONTEXT ctx) /* Create a new context. Note that the handlers are set up for a pipe - server/client - this wau we don't need extra dummy functions */ + server/client - this way we don't need extra dummy functions */ int _assuan_new_context (ASSUAN_CONTEXT *r_ctx) { diff --git a/assuan/assuan-socket-connect.c b/assuan/assuan-socket-connect.c index 748a91ff..64a22bf5 100644 --- a/assuan/assuan-socket-connect.c +++ b/assuan/assuan-socket-connect.c @@ -1,21 +1,21 @@ /* assuan-socket-connect.c - Assuan socket based client * Copyright (C) 2002 Free Software Foundation, Inc. * - * This file is part of GnuPG. + * This file is part of Assuan. * - * GnuPG is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * 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. * - * GnuPG 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 General Public License for more details. + * 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 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 + * 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 */ #include @@ -66,7 +66,7 @@ do_deinit (ASSUAN_CONTEXT ctx) /* Make a connection to the Unix domain socket NAME and return a new Assuan context in CTX. SERVER_PID is currently not used but may - becode handy in future. */ + become handy in the future. */ AssuanError assuan_socket_connect (ASSUAN_CONTEXT *r_ctx, const char *name, pid_t server_pid) diff --git a/assuan/assuan-socket-server.c b/assuan/assuan-socket-server.c index 39dd84a1..bfa9cfa7 100644 --- a/assuan/assuan-socket-server.c +++ b/assuan/assuan-socket-server.c @@ -1,21 +1,21 @@ /* assuan-socket-server.c - Assuan socket based server * Copyright (C) 2002 Free Software Foundation, Inc. * - * This file is part of GnuPG. + * This file is part of Assuan. * - * GnuPG is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * 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. * - * GnuPG 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 General Public License for more details. + * 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 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 + * 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 */ #include @@ -25,31 +25,15 @@ #include #include #include -#ifdef USE_GNU_PTH -# include -#endif #include "assuan-defs.h" static int -accept_connection (ASSUAN_CONTEXT ctx) +accept_connection_bottom (ASSUAN_CONTEXT ctx) { - int fd; - struct sockaddr_un clnt_addr; - size_t len = sizeof clnt_addr; + int fd = ctx->connected_fd; ctx->client_pid = (pid_t)-1; -#ifdef USE_GNU_PTH - fd = pth_accept (ctx->listen_fd, (struct sockaddr*)&clnt_addr, &len ); -#else - fd = accept (ctx->listen_fd, (struct sockaddr*)&clnt_addr, &len ); -#endif - if (fd == -1) - { - ctx->os_errno = errno; - return ASSUAN_Accept_Failed; - } - #ifdef HAVE_SO_PEERCRED { struct ucred cr; @@ -75,6 +59,26 @@ accept_connection (ASSUAN_CONTEXT ctx) return 0; } + +static int +accept_connection (ASSUAN_CONTEXT ctx) +{ + int fd; + struct sockaddr_un clnt_addr; + size_t len = sizeof clnt_addr; + + ctx->client_pid = (pid_t)-1; + fd = accept (ctx->listen_fd, (struct sockaddr*)&clnt_addr, &len ); + if (fd == -1) + { + ctx->os_errno = errno; + return ASSUAN_Accept_Failed; + } + + ctx->connected_fd = fd; + return accept_connection_bottom (ctx); +} + static int finish_connection (ASSUAN_CONTEXT ctx) { @@ -116,6 +120,7 @@ assuan_init_socket_server (ASSUAN_CONTEXT *r_ctx, int listen_fd) ctx->outbound.fd = -1; ctx->listen_fd = listen_fd; + ctx->connected_fd = -1; ctx->deinit_handler = deinit_socket_server; ctx->accept_handler = accept_connection; ctx->finish_handler = finish_connection; @@ -128,12 +133,37 @@ assuan_init_socket_server (ASSUAN_CONTEXT *r_ctx, int listen_fd) return rc; } - - - - - - - +/* Initialize a server using the already accepted socket FD. */ +int +assuan_init_connected_socket_server (ASSUAN_CONTEXT *r_ctx, int fd) +{ + ASSUAN_CONTEXT ctx; + int rc; + + *r_ctx = NULL; + ctx = xtrycalloc (1, sizeof *ctx); + if (!ctx) + return ASSUAN_Out_Of_Core; + ctx->is_server = 1; + ctx->pipe_mode = 1; /* we wan't a second accept to indicate EOF */ + ctx->input_fd = -1; + ctx->output_fd = -1; + + ctx->inbound.fd = -1; + ctx->outbound.fd = -1; + + ctx->listen_fd = -1; + ctx->connected_fd = fd; + ctx->deinit_handler = deinit_socket_server; + ctx->accept_handler = accept_connection_bottom; + ctx->finish_handler = finish_connection; + + rc = _assuan_register_std_commands (ctx); + if (rc) + xfree (ctx); + else + *r_ctx = ctx; + return rc; +} diff --git a/assuan/assuan-util.c b/assuan/assuan-util.c index 4153ef8d..76f7f065 100644 --- a/assuan/assuan-util.c +++ b/assuan/assuan-util.c @@ -1,27 +1,28 @@ /* assuan-util.c - Utility functions for Assuan - * Copyright (C) 2001 Free Software Foundation, Inc. + * Copyright (C) 2001, 2002 Free Software Foundation, Inc. * - * This file is part of GnuPG. + * This file is part of Assuan. * - * GnuPG is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * 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. * - * GnuPG 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 General Public License for more details. + * 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 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 + * 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 */ #include #include #include #include +#include #include "assuan-defs.h" @@ -29,13 +30,10 @@ #include "../jnlib/logging.h" #endif - static void *(*alloc_func)(size_t n) = malloc; static void *(*realloc_func)(void *p, size_t n) = realloc; static void (*free_func)(void*) = free; - - void assuan_set_malloc_hooks ( void *(*new_alloc_func)(size_t n), void *(*new_realloc_func)(void *p, size_t n), @@ -74,7 +72,6 @@ _assuan_free (void *p) free_func (p); } - /* Store the error in the context so that the error sending function can take out a descriptive text. Inside the assuan code, use the @@ -131,6 +128,8 @@ assuan_end_confidential (ASSUAN_CONTEXT ctx) } } +/* Dump a possibly binary string (used for debugging). Distinguish + ascii text from binary and print it accordingly. */ void _assuan_log_print_buffer (FILE *fp, const void *buffer, size_t length) { @@ -138,26 +137,31 @@ _assuan_log_print_buffer (FILE *fp, const void *buffer, size_t length) int n; for (n=length,s=buffer; n; n--, s++) - { - if (*s < ' ' || (*s >= 0x7f && *s <= 0xa0)) - break; - } + if (!isascii (*s) || iscntrl (*s) || !isprint (*s)) + break; + s = buffer; if (!n && *s != '[') fwrite (buffer, length, 1, fp); else { - putc ('[', fp); +#ifdef HAVE_FLOCKFILE + flockfile (fp); +#endif + putc_unlocked ('[', fp); for (n=0; n < length; n++, s++) fprintf (fp, " %02x", *s); - putc (' ', fp); - putc (']', fp); + putc_unlocked (' ', fp); + putc_unlocked (']', fp); +#ifdef HAVE_FUNLOCKFILE + funlockfile (fp); +#endif } } -/* print a user supplied string after filtering out potential bad - characters*/ +/* Log a user supplied string. Escapes non-printable before + printing. */ void _assuan_log_sanitized_string (const char *string) { @@ -168,29 +172,59 @@ _assuan_log_sanitized_string (const char *string) FILE *fp = stderr; #endif + if (! *s) + return; + +#ifdef HAVE_FLOCKFILE + flockfile (fp); +#endif + for (; *s; s++) { - if (*s < 0x20 || (*s >= 0x7f && *s <= 0xa0)) - { - putc ('\\', fp); - if (*s == '\n') - putc ('n', fp); - else if (*s == '\r') - putc ('r', fp); - else if (*s == '\f') - putc ('f', fp); - else if (*s == '\v') - putc ('v', fp); - else if (*s == '\b') - putc ('b', fp); - else if (!*s) - putc ('0', fp); - else - fprintf (fp, "x%02x", *s ); + int c = 0; + + switch (*s) + { + case '\r': + c = 'r'; + break; + + case '\n': + c = 'n'; + break; + + case '\f': + c = 'f'; + break; + + case '\v': + c = 'v'; + break; + + case '\b': + c = 'b'; + break; + + default: + if (isascii (*s) && isprint (*s)) + putc_unlocked (*s, fp); + else + { + putc_unlocked ('\\', fp); + fprintf (fp, "x%02x", *s); + } + } + + if (c) + { + putc_unlocked ('\\', fp); + putc_unlocked (c, fp); } - else - putc (*s, fp); } + +#ifdef HAVE_FUNLOCKFILE + funlockfile (fp); +#endif } diff --git a/assuan/assuan.h b/assuan/assuan.h index e18c46e6..d8b874eb 100644 --- a/assuan/assuan.h +++ b/assuan/assuan.h @@ -1,21 +1,21 @@ -/* assuan.c - Definitions for the Assuna protocol +/* assuan.c - Definitions for the Assuan protocol * Copyright (C) 2001, 2002 Free Software Foundation, Inc. * - * This file is part of GnuPG. + * This file is part of Assuan. * - * GnuPG is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * 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. * - * GnuPG 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 General Public License for more details. + * 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 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 + * 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 @@ -23,6 +23,7 @@ #include #include +#include /* for ssize_t */ #ifdef __cplusplus extern "C" { @@ -81,7 +82,7 @@ typedef enum { ASSUAN_Not_Confirmed = 128, ASSUAN_Bad_Certificate = 201, - ASSUAN_Bad_Certificate_Path = 202, + ASSUAN_Bad_Certificate_Chain = 202, ASSUAN_Missing_Certificate = 203, ASSUAN_Bad_Signature = 204, ASSUAN_No_Agent = 205, @@ -170,15 +171,12 @@ void assuan_deinit_server (ASSUAN_CONTEXT ctx); /*-- assuan-socket-server.c --*/ int assuan_init_socket_server (ASSUAN_CONTEXT *r_ctx, int listen_fd); +int assuan_init_connected_socket_server (ASSUAN_CONTEXT *r_ctx, int fd); /*-- assuan-pipe-connect.c --*/ AssuanError assuan_pipe_connect (ASSUAN_CONTEXT *ctx, const char *name, char *const argv[], int *fd_child_list); -AssuanError assuan_pipe_connect2 (ASSUAN_CONTEXT *ctx, const char *name, - char *const argv[], int *fd_child_list, - unsigned int connect_flags); - /*-- assuan-socket-connect.c --*/ AssuanError assuan_socket_connect (ASSUAN_CONTEXT *ctx, const char *name, pid_t server_pid); diff --git a/assuan/mkerrors b/assuan/mkerrors index 13eabde7..d0c59ff3 100755 --- a/assuan/mkerrors +++ b/assuan/mkerrors @@ -1,23 +1,23 @@ #!/bin/sh # mkerrors - Extract error strings from assuan.h # and create C source for assuan_strerror -# Copyright (C) 2001 Free Software Foundation, Inc. +# Copyright (C) 2001, 2002 Free Software Foundation, Inc. # -# This file is part of GnuPG. +# This file is part of Assuan. # -# GnuPG is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# 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. # -# GnuPG 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 General Public License for more details. +# 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 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 +# 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 cat < + + * engine-gpgsm.c (map_assuan_error): Replace + ASSUAN_Bad_Certificate_Path with ASSUAN_Bad_Certificate_Chain. + (gpgsm_new): Use assuan_pipe_connect instead assuan_pipe_connect2. + + * util.h (DIMof): Remove macro. + + * ops.h (_gpgme_op_event_cb, _gpgme_op_event_cb_user, + _gpgme_data_unread): Prototypes removed. + 2003-01-30 Marcus Brinkmann * types.h: File removed. diff --git a/gpgme/engine-gpgsm.c b/gpgme/engine-gpgsm.c index 475d917f..da420fa5 100644 --- a/gpgme/engine-gpgsm.c +++ b/gpgme/engine-gpgsm.c @@ -228,7 +228,7 @@ map_assuan_error (AssuanError err) return GPGME_Invalid_Engine; /* XXX: Need something more useful. */ case ASSUAN_Bad_Certificate: - case ASSUAN_Bad_Certificate_Path: + case ASSUAN_Bad_Certificate_Chain: case ASSUAN_Missing_Certificate: case ASSUAN_No_Public_Key: case ASSUAN_No_Secret_Key: @@ -365,9 +365,8 @@ gpgsm_new (void **engine) argv[1] = "--server"; argv[2] = NULL; - err = assuan_pipe_connect2 (&gpgsm->assuan_ctx, - _gpgme_get_gpgsm_path (), argv, child_fds, - 1 /* dup stderr to /dev/null */); + err = assuan_pipe_connect (&gpgsm->assuan_ctx, + _gpgme_get_gpgsm_path (), argv, child_fds); /* We need to know the fd used by assuan for reads. We do this by using the assumption that the first returned fd from diff --git a/gpgme/ops.h b/gpgme/ops.h index 49e1afe3..b3377a2d 100644 --- a/gpgme/ops.h +++ b/gpgme/ops.h @@ -28,9 +28,6 @@ void _gpgme_release_result (GpgmeCtx ctx); void _gpgme_set_op_info (GpgmeCtx c, GpgmeData info); -void _gpgme_op_event_cb (void *data, GpgmeEventIO type, void *type_data); -void _gpgme_op_event_cb_user (void *data, GpgmeEventIO type, void *type_data); - /*-- wait.c --*/ GpgmeError _gpgme_wait_one (GpgmeCtx ctx); GpgmeError _gpgme_wait_on_condition (GpgmeCtx ctx, volatile int *cond); @@ -53,9 +50,6 @@ GpgmeError _gpgme_data_append_for_xml ( GpgmeData dh, GpgmeError _gpgme_data_append_percentstring_for_xml ( GpgmeData dh, const char *string ); -GpgmeError _gpgme_data_unread (GpgmeData dh, - const char *buffer, size_t length ); - GpgmeError _gpgme_data_inbound_handler (void *opaque, int fd); GpgmeError _gpgme_data_outbound_handler (void *opaque, int fd); diff --git a/gpgme/util.h b/gpgme/util.h index a2805876..2734115e 100644 --- a/gpgme/util.h +++ b/gpgme/util.h @@ -25,7 +25,6 @@ #define DIM(v) (sizeof(v)/sizeof((v)[0])) -#define DIMof(type,member) DIM(((type *)0)->member) /*-- {posix,w32}-util.c --*/