Update from newpg.
This commit is contained in:
parent
d5e1994ee4
commit
102009c336
@ -1,3 +1,17 @@
|
|||||||
|
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>
|
2001-12-14 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
* assuan-buffer.c (_assuan_read_line): New variable ATTICLEN, use
|
* assuan-buffer.c (_assuan_read_line): New variable ATTICLEN, use
|
||||||
@ -9,11 +23,6 @@
|
|||||||
* assuan-defs.h (LINELENGTH): Define as ASSUAN_LINELENGTH.
|
* assuan-defs.h (LINELENGTH): Define as ASSUAN_LINELENGTH.
|
||||||
assuan.h: Define ASSUAN_LINELENGTH.
|
assuan.h: Define ASSUAN_LINELENGTH.
|
||||||
|
|
||||||
2001-12-13 Marcus Brinkmann <marcus@g10code.de>
|
|
||||||
|
|
||||||
* assuan-connect.c (assuan_pipe_connect): Remove code that closes
|
|
||||||
all the little file descriptors we set up.
|
|
||||||
|
|
||||||
2001-12-13 Marcus Brinkmann <marcus@g10code.de>
|
2001-12-13 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
* assuan-buffer.c (assuan_read_line): Fix order of execution to
|
* assuan-buffer.c (assuan_read_line): Fix order of execution to
|
||||||
|
@ -71,9 +71,11 @@ writen ( int fd, const char *buffer, size_t length )
|
|||||||
|
|
||||||
/* Connect to a server over a pipe, creating the assuan context and
|
/* Connect to a server over a pipe, creating the assuan context and
|
||||||
returning it in CTX. The server filename is NAME, the argument
|
returning it in CTX. The server filename is NAME, the argument
|
||||||
vector in ARGV. */
|
vector in ARGV. FD_CHILD_LIST is a -1 terminated list of file
|
||||||
|
descriptors not to close in the child. */
|
||||||
AssuanError
|
AssuanError
|
||||||
assuan_pipe_connect (ASSUAN_CONTEXT *ctx, const char *name, char *const argv[])
|
assuan_pipe_connect (ASSUAN_CONTEXT *ctx, const char *name, char *const argv[],
|
||||||
|
int *fd_child_list)
|
||||||
{
|
{
|
||||||
static int fixed_signals = 0;
|
static int fixed_signals = 0;
|
||||||
AssuanError err;
|
AssuanError err;
|
||||||
@ -137,10 +139,35 @@ assuan_pipe_connect (ASSUAN_CONTEXT *ctx, const char *name, char *const argv[])
|
|||||||
|
|
||||||
if ((*ctx)->pid == 0)
|
if ((*ctx)->pid == 0)
|
||||||
{
|
{
|
||||||
|
int i, n;
|
||||||
char errbuf[512];
|
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;
|
||||||
|
|
||||||
close (rp[0]);
|
if (fdp)
|
||||||
close (wp[1]);
|
{
|
||||||
|
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 and to stdin/stdout and exec */
|
||||||
if (rp[1] != STDOUT_FILENO)
|
if (rp[1] != STDOUT_FILENO)
|
||||||
|
@ -54,6 +54,8 @@ std_handler_bye (ASSUAN_CONTEXT ctx, char *line)
|
|||||||
{
|
{
|
||||||
if (ctx->bye_notify_fnc)
|
if (ctx->bye_notify_fnc)
|
||||||
ctx->bye_notify_fnc (ctx);
|
ctx->bye_notify_fnc (ctx);
|
||||||
|
assuan_close_input_fd (ctx);
|
||||||
|
assuan_close_output_fd (ctx);
|
||||||
return -1; /* pretty simple :-) */
|
return -1; /* pretty simple :-) */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,6 +70,8 @@ std_handler_reset (ASSUAN_CONTEXT ctx, char *line)
|
|||||||
{
|
{
|
||||||
if (ctx->reset_notify_fnc)
|
if (ctx->reset_notify_fnc)
|
||||||
ctx->reset_notify_fnc (ctx);
|
ctx->reset_notify_fnc (ctx);
|
||||||
|
assuan_close_input_fd (ctx);
|
||||||
|
assuan_close_output_fd (ctx);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -458,7 +462,8 @@ assuan_process_next (ASSUAN_CONTEXT ctx)
|
|||||||
*
|
*
|
||||||
* Return all active filedescriptors for the given context. This
|
* Return all active filedescriptors for the given context. This
|
||||||
* function can be used to select on the fds and call
|
* function can be used to select on the fds and call
|
||||||
* assuan_process_next() if there is an active one.
|
* assuan_process_next() if there is an active one. The first fd in
|
||||||
|
* the array is the one used for the command connection.
|
||||||
*
|
*
|
||||||
* Note, that write FDs are not yet supported.
|
* Note, that write FDs are not yet supported.
|
||||||
*
|
*
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "assuan-defs.h"
|
#include "assuan-defs.h"
|
||||||
|
|
||||||
@ -106,3 +107,28 @@ assuan_get_output_fd (ASSUAN_CONTEXT ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Close the fd descriptor set by the command INPUT FD=n. We handle
|
||||||
|
this fd inside assuan so that we can do some initial checks */
|
||||||
|
AssuanError
|
||||||
|
assuan_close_input_fd (ASSUAN_CONTEXT ctx)
|
||||||
|
{
|
||||||
|
if (!ctx || ctx->input_fd == -1)
|
||||||
|
return ASSUAN_Invalid_Value;
|
||||||
|
close (ctx->input_fd);
|
||||||
|
ctx->input_fd = -1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Close the fd descriptor set by the command OUTPUT FD=n. We handle
|
||||||
|
this fd inside assuan so that we can do some initial checks */
|
||||||
|
AssuanError
|
||||||
|
assuan_close_output_fd (ASSUAN_CONTEXT ctx)
|
||||||
|
{
|
||||||
|
if (!ctx || ctx->output_fd == -1)
|
||||||
|
return ASSUAN_Invalid_Value;
|
||||||
|
|
||||||
|
close (ctx->output_fd);
|
||||||
|
ctx->output_fd = -1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -136,6 +136,8 @@ AssuanError assuan_set_hello_line (ASSUAN_CONTEXT ctx, const char *line);
|
|||||||
AssuanError assuan_accept (ASSUAN_CONTEXT ctx);
|
AssuanError assuan_accept (ASSUAN_CONTEXT ctx);
|
||||||
int assuan_get_input_fd (ASSUAN_CONTEXT ctx);
|
int assuan_get_input_fd (ASSUAN_CONTEXT ctx);
|
||||||
int assuan_get_output_fd (ASSUAN_CONTEXT ctx);
|
int assuan_get_output_fd (ASSUAN_CONTEXT ctx);
|
||||||
|
AssuanError assuan_close_input_fd (ASSUAN_CONTEXT ctx);
|
||||||
|
AssuanError assuan_close_output_fd (ASSUAN_CONTEXT ctx);
|
||||||
|
|
||||||
|
|
||||||
/*-- assuan-pipe-server.c --*/
|
/*-- assuan-pipe-server.c --*/
|
||||||
@ -145,7 +147,7 @@ void assuan_deinit_pipe_server (ASSUAN_CONTEXT ctx);
|
|||||||
|
|
||||||
/*-- assuan-connect.c --*/
|
/*-- assuan-connect.c --*/
|
||||||
AssuanError assuan_pipe_connect (ASSUAN_CONTEXT *ctx, const char *name,
|
AssuanError assuan_pipe_connect (ASSUAN_CONTEXT *ctx, const char *name,
|
||||||
char *const argv[]);
|
char *const argv[], int *fd_child_list);
|
||||||
void assuan_pipe_disconnect (ASSUAN_CONTEXT ctx);
|
void assuan_pipe_disconnect (ASSUAN_CONTEXT ctx);
|
||||||
pid_t assuan_get_pid (ASSUAN_CONTEXT ctx);
|
pid_t assuan_get_pid (ASSUAN_CONTEXT ctx);
|
||||||
|
|
||||||
@ -189,5 +191,3 @@ const char *assuan_strerror (AssuanError err);
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif /*ASSUAN_H*/
|
#endif /*ASSUAN_H*/
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user