[svn] assuan - r317 - in trunk: . doc src tests
svn author marcus
cvs at cvs.gnupg.org
Thu Nov 5 13:00:36 CET 2009
Author: marcus
Date: 2009-11-05 13:00:35 +0100 (Thu, 05 Nov 2009)
New Revision: 317
Modified:
trunk/ChangeLog
trunk/NEWS
trunk/doc/ChangeLog
trunk/doc/assuan.texi
trunk/src/ChangeLog
trunk/src/assuan-connect.c
trunk/src/assuan-defs.h
trunk/src/assuan-pipe-connect.c
trunk/src/assuan-socket-connect.c
trunk/src/assuan-socket-server.c
trunk/src/assuan.h
trunk/src/context.c
trunk/src/libassuan.def
trunk/src/libassuan.vers
trunk/tests/fdpassing.c
Log:
2009-11-05 Marcus Brinkmann <marcus at g10code.de>
* tests/fdpassing.c (main): Call assuan_pipe_connect instead
of assuan_pipe_connect_ext.
doc/
2009-11-05 Marcus Brinkmann <marcus at g10code.de>
* assuan.texi (Client code): Document
ASSUAN_PIPE_CONNECT_FDPASSING and ASSUAN_PIPE_CONNECT_DETACHED.
(Server code): Document ASSUAN_SOCKET_SERVER_FDPASSING and
ASSUAN_SOCKET_SERVER_ACCEPTED.
(Utilities): Update documentation of assuan_get_peercred.
src/
2009-11-05 Marcus Brinkmann <marcus at g10code.de>
* assuan.h (struct _assuan_peercred, assuan_peercred_t): New.
(assuan_get_peercred): Define on all systems, return
assuan_peercred_t.
* assuan-defs.h (struct assuan_context_s): Move valid flag out of
peercred struct, use struct _assuan_peercred.
* libassuan.def: Add assuan_get_peercred.
* assuan-connect.c (assuan_get_peercred): Moved to ...
* context.c (assuan_get_peercred): ... here. Reimplement.
* assuan-socket-server.c (accept_connection_bottom): Adjust access
to peercred in context.
* assuan.h (ASSUAN_PIPE_CONNECT_FDPASSING)
(ASSUAN_PIPE_CONNECT_DETACHED, ASSUAN_SOCKET_SERVER_FDPASSING)
(ASSUAN_SOCKET_SERVER_ACCEPTED, ASSUAN_SOCKET_CONNECT_FDPASSING): New.
(assuan_pipe_connect_ext): Renamed to ...
(assuan_pipe_connect): ... this, overwriting old prototype.
(assuan_socket_connect_ext): Renamed to ...
(assuan_socket_connect): ... this, overwriting old prototype.
(assuan_init_socket_server_ext): Renamed to ...
(assuan_init_socket_server): ... this, overwriting old prototype.
* assuan-pipe-connect.c: Likewise for functions.
* assuan-socket-connect.c: Likewise.
* assuan-socket-server.c: Likewise.
* libassuan.def (assuan_init_socket_server_ext)
(assuan_pipe_connect_ext, assuan_socket_connect_ext): Removed.
* libassuan.vers: Likewise.
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2009-11-05 02:53:14 UTC (rev 316)
+++ trunk/ChangeLog 2009-11-05 12:00:35 UTC (rev 317)
@@ -1,3 +1,8 @@
+2009-11-05 Marcus Brinkmann <marcus at g10code.de>
+
+ * tests/fdpassing.c (main): Call assuan_pipe_connect instead
+ of assuan_pipe_connect_ext.
+
2009-11-04 Werner Koch <wk at g10code.com>
* tests/fdpassing.c (register_commands): Add NULL arg to
Modified: trunk/doc/ChangeLog
===================================================================
--- trunk/doc/ChangeLog 2009-11-05 02:53:14 UTC (rev 316)
+++ trunk/doc/ChangeLog 2009-11-05 12:00:35 UTC (rev 317)
@@ -1,5 +1,13 @@
2009-11-05 Marcus Brinkmann <marcus at g10code.de>
+ * assuan.texi: Update assuan_pipe_connect, assuan_socket_connect
+ and assuan_init_socket_connect.
+ (Client code): Document ASSUAN_PIPE_CONNECT_FDPASSING and
+ ASSUAN_PIPE_CONNECT_DETACHED.
+ (Server code): Document ASSUAN_SOCKET_SERVER_FDPASSING and
+ ASSUAN_SOCKET_SERVER_ACCEPTED.
+ (Utilities): Update documentation of assuan_get_peercred.
+
* assuan.texi (External I/O Loop Server): Document change to
assuan_process_next.
Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog 2009-11-05 02:53:14 UTC (rev 316)
+++ trunk/src/ChangeLog 2009-11-05 12:00:35 UTC (rev 317)
@@ -1,5 +1,31 @@
2009-11-05 Marcus Brinkmann <marcus at g10code.de>
+ * assuan.h (struct _assuan_peercred, assuan_peercred_t): New.
+ (assuan_get_peercred): Define on all systems, return
+ assuan_peercred_t.
+ * assuan-defs.h (struct assuan_context_s): Move valid flag out of
+ peercred struct, use struct _assuan_peercred.
+ * libassuan.def: Add assuan_get_peercred.
+ * assuan-connect.c (assuan_get_peercred): Moved to ...
+ * context.c (assuan_get_peercred): ... here. Reimplement.
+ * assuan-socket-server.c (accept_connection_bottom): Adjust access
+ to peercred in context.
+ * assuan.h (ASSUAN_PIPE_CONNECT_FDPASSING)
+ (ASSUAN_PIPE_CONNECT_DETACHED, ASSUAN_SOCKET_SERVER_FDPASSING)
+ (ASSUAN_SOCKET_SERVER_ACCEPTED, ASSUAN_SOCKET_CONNECT_FDPASSING): New.
+ (assuan_pipe_connect_ext): Renamed to ...
+ (assuan_pipe_connect): ... this, overwriting old prototype.
+ (assuan_socket_connect_ext): Renamed to ...
+ (assuan_socket_connect): ... this, overwriting old prototype.
+ (assuan_init_socket_server_ext): Renamed to ...
+ (assuan_init_socket_server): ... this, overwriting old prototype.
+ * assuan-pipe-connect.c: Likewise for functions.
+ * assuan-socket-connect.c: Likewise.
+ * assuan-socket-server.c: Likewise.
+ * libassuan.def (assuan_init_socket_server_ext)
+ (assuan_pipe_connect_ext, assuan_socket_connect_ext): Removed.
+ * libassuan.vers: Likewise.
+
* assuan-defs.h (assuan_context_t): Add member PROCESS_DONE.
* assuan.h (assuan_process_next): Add argument DONE to prototype.
* assuan-handler.c (assuan_process_next): Likewise, handle it.
Modified: trunk/NEWS
===================================================================
--- trunk/NEWS 2009-11-05 02:53:14 UTC (rev 316)
+++ trunk/NEWS 2009-11-05 12:00:35 UTC (rev 317)
@@ -10,12 +10,12 @@
context with assuan_new and use that. Instead of assuan_disconnect
or assuan_deinit_server, call assuan_release. Use
assuan_set_gpg_err_source instead of assuan_set_assuan_err_source.
- If you use assuan_pipe_connect or assuan_pipe_connect_ext with NAME
- of NULL, you have to provide a non-NULL ARGV argument and check
- that against "server" or "client" to determine which end you got
- after fork(). If you use the assuan sock interface, you must call
- assuan_sock_init after setting global context defaults. Add a NULL
- as the last arg to assuan_register_command.
+ If you use assuan_pipe_connect with NAME of NULL, you have to
+ provide a non-NULL ARGV argument and check that against "server" or
+ "client" to determine which end you got after fork(). If you use
+ the assuan sock interface, you must call assuan_sock_init after
+ setting global context defaults. Add a NULL as the last arg to
+ assuan_register_command.
* Pth support has changed. This now follows the same style as
libgcrypt by setting system hook callbacks.
@@ -44,13 +44,15 @@
assuan_new NEW
assuan_release NEW
assuan_init_socket_server CHANGED: Take ctx arg instead of pointer to ctx.
-assuan_init_socket_server_ext CHANGED: Take ctx arg instead of pointer to ctx.
+ CHANGED: As assuan_init_socket_server_ext was.
+assuan_init_socket_server_ext REMOVED
assuan_socket_connect CHANGED: Take ctx arg instead of pointer to ctx.
-assuan_socket_connect_ext CHANGED: Take ctx arg instead of pointer to ctx.
+ CHANGED: Is what assuan_socket_connect_ext was.
+assuan_socket_connect_ext REMOVED
assuan_pipe_connect CHANGED: Take ctx arg instead of pointer to ctx.
If NAME is NULL, ARGV will contain fork result.
-assuan_pipe_connect_ext CHANGED: Take ctx arg instead of pointer to ctx.
- If NAME is NULL, ARGV will contain fork result.
+ CHANGED: Is now what assuan_pipe_connect_ext was.
+assuan_pipe_connect_ext REMOVED
assuan_init_pipe_server CHANGED: Take ctx arg instead of pointer to ctx.
assuan_set_io_hooks REMOVED: Will come back in expanded form.
assuan_io_hooks_t REMOVED: Will come back in expanded form.
@@ -76,6 +78,13 @@
assuan_register_input_notify CHANGED: Handler returns error now.
assuan_register_output_notify CHANGED: Handler returns error now.
assuan_process_next CHANGED: New DONE argument instead EOF return.
+ASSUAN_PIPE_CONNECT_FDPASSING NEW
+ASSUAN_PIPE_CONNECT_DETACHED NEW
+ASSUAN_SOCKET_SERVER_FDPASSING NEW
+ASSUAN_SOCKET_SERVER_ACCEPTED NEW
+ASSUAN_SOCKET_CONNECT_FDPASSING NEW
+assuan_peercred_t NEW
+assuan_get_peercred CHANGED: Return assuan_peercred_t.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Modified: trunk/doc/assuan.texi
===================================================================
--- trunk/doc/assuan.texi 2009-11-05 02:53:14 UTC (rev 316)
+++ trunk/doc/assuan.texi 2009-11-05 12:00:35 UTC (rev 317)
@@ -937,7 +937,7 @@
sockets, the full-fledged variant of the above function should be
used:
- at deftypefun gpg_error_t assuan_pipe_connect_ext (@w{assuan_context_t *@var{ctx}}, at w{const char *@var{name}}, @w{const char *@var{argv}[]}, @w{assuan_fd_t *@var{fd_child_list}}, @w{void (*@var{atfork}) (void *, int)}, @w{void *@var{atforkvalue}}, @w{unsigned int @var{flags}})
+ at deftypefun gpg_error_t assuan_pipe_connect (@w{assuan_context_t *@var{ctx}}, at w{const char *@var{name}}, @w{const char *@var{argv}[]}, @w{assuan_fd_t *@var{fd_child_list}}, @w{void (*@var{atfork}) (void *, int)}, @w{void *@var{atforkvalue}}, @w{unsigned int @var{flags}})
A call to this functions forks the current process and executes the
program @var{name}, passing the arguments given in the NULL-terminated
@@ -961,7 +961,7 @@
@var{flags} is a bit vector and controls how the function acts:
@table @code
- at item bit 0 (value 1)
+ at item ASSUAN_PIPE_CONNECT_FDPASSING
If cleared a simple pipe based server is expected and the function
behaves similar to @code{assuan_pipe_connect}.
@@ -969,7 +969,7 @@
usually created using the @code{socketpair} function. It also enables
features only available with such servers.
- at item bit 7 (value 128)
+ at item ASSUAN_PIPE_CONNECT_DETACHED
If set and there is a need to start the server it will be started as a
background process. This flag is useful under W32 systems, so that no
new console is created and pops up a console window when starting the server
@@ -977,39 +977,23 @@
@end deftypefun
-For a pipe-based server you can also use the following legacy function:
-
- at deftypefun gpg_error_t assuan_pipe_connect (@w{assuan_context_t *@var{ctx}}, at w{const char *@var{name}}, @w{const char *@var{argv}[]}, @w{int *@var{fd_child_list}})
-
-A call to @code{assuan_pipe_connect} is equivalent to a call to
- at code{assuan_pipe_connect_ext} with @code{flags} being 0 and without
-an at-fork handler.
- at end deftypefun
-
If you are using a long running server listening either on a TCP or a
Unix domain socket, the following function is used to connect to the server:
- at deftypefun gpg_error_t assuan_socket_connect_ext (@w{assuan_context_t *@var{ctx}}, @w{const char *@var{name}}, @w{pid_t @var{server_pid}}, @w{unsigned int @var{flags}})
+ at deftypefun gpg_error_t assuan_socket_connect (@w{assuan_context_t *@var{ctx}}, @w{const char *@var{name}}, @w{pid_t @var{server_pid}}, @w{unsigned int @var{flags}})
Make a connection to the Unix domain socket @var{name} and return a
new Assuan context at @var{ctx}. @var{server_pid} is currently not
used but may become handy in the future; if you don't know the
server's process ID (PID), pass @code{-1}. With @var{flags} set to
- at code{1}, @code{sendmsg} and @code{recvmesg} are used for input and
-output and thereby enable the use of descriptor passing.
+ at code{ASSUAN_SOCKET_CONNECT_FDPASSIN}, @code{sendmsg} and
+ at code{recvmesg} are used for input and output and thereby enable the
+use of descriptor passing.
Connecting to a TCP server is not yet implemented. Standard URL
schemes are reserved for @var{name} specifying a TCP server.
@end deftypefun
- at deftypefun gpg_error_t assuan_socket_connect (@w{assuan_context_t *@var{ctx}}, @w{const char *@var{name}}, @w{pid_t @var{server_pid}})
-
-A call to @code{assuan_socket_connect} is equivalent to a call to
- at code{assuan_socket_connect_ext} with @code{flags} being 0.
-
-Same as above but no way to specify flags.
- at end deftypefun
-
Eventually, after using the Assuan connection, the resources should be
deallocated:
@@ -1132,7 +1116,7 @@
rc = assuan_init_pipe_server (&ctx, filedes);
@}
else
- rc = assuan_init_socket_server_ext (&ctx, fd, 2);
+ rc = assuan_init_socket_server (&ctx, fd, 2);
if (rc)
@{
fprintf (stderr, "server init failed: %s\n", gpg_strerror (rc));
@@ -1167,17 +1151,17 @@
If a file descriptor has been passed, the assuan context gets
initialized by the function:
- at deftypefun gpg_error_t assuan_init_socket_server_ext (@w{assuan_context_t *@var{r_ctx}}, @w{int @var{fd}}, @w{unsigned int @var{flags}})
+ at deftypefun gpg_error_t assuan_init_socket_server (@w{assuan_context_t *@var{r_ctx}}, @w{int @var{fd}}, @w{unsigned int @var{flags}})
The function takes the file descriptor @var{fd} which is expected to be
associated with a socket and returns a new Assuan context at
@var{r_ctx}. The following bits are currently defined for @var{flags}:
@table @code
- at item Bit 0
+ at item ASSUAN_SOCKET_SERVER_FDPASSING
If set, @code{sendmsg} and @code{recvmesg} are used for input and
output and thus enabling the use of descriptor passing.
- at item Bit 1
+ at item ASSUAN_SOCKET_SERVER_ACCEPTED
If set, @var{fd} refers to an already accepted socket. That is,
Libassuan won't call @var{accept} for it. It is suggested to set this
bit as it allows better control of the connection state.
@@ -1190,16 +1174,16 @@
@noindent
On the Windows platform the following function needs to be called after
-assuan_init_socket_server_ext:
+ at code{assuan_init_socket_server}:
@deftypefun void assuan_set_sock_nonce ( @
@w{assuan_context_t @var{ctx}}, @
@w{assuan_sock_nonce_t *@var{nonce}})
-Save a copy of @var{nonce} in context @var{ctx}. This should be used to
-register the server's nonce with a context established by
-assuan_init_socket_server. It is actually only needed for Windows but
-it does not harm to use it on other systems as well.
+Save a copy of @var{nonce} in context @var{ctx}. This should be used
+to register the server's nonce with a context established by
+ at code{assuan_init_socket_server}. It is actually only needed for
+Windows but it does not harm to use it on other systems as well.
@end deftypefun
@@ -1504,7 +1488,7 @@
should just implement the bind/connect/listen/accept stage yourself.
You can register the listen FD with your main event loop, accept the
connection when it becomes ready, and finally call
- at code{assuan_init_socket_server_ext} with the final argument being 2
+ at code{assuan_init_socket_server} with the final argument being 2
to create an Assuan context for this connection. This way you can
also handle multiple connections in parallel. The reference
implementation for this approach is DirMngr.
@@ -1726,13 +1710,29 @@
@end deftypefun
- at deftypefun gpg_error_t assuan_get_peercred (@w{assuan_context_t @var{ctx}}, @w{pid_t *@var{pid}}, @w{uid_t *@var{uid}}, @w{gid_t *@var{pid}})
+ at deftp {Data type} {assuan_peercred_t}
+This structure is used to store the peer credentials. The available
+members depend on the operating system.
+ at table @code
+ at item pid_t pid
+The process ID of the peer.
+
+ at item uid_t uid
+The user ID of the peer process.
+
+ at item gid_t gid
+The group ID of the peer process.
+ at end table
+ at end deftp
+
+
+ at deftypefun gpg_error_t assuan_get_peercred (@w{assuan_context_t @var{ctx}}, @w{assuan_peercred_t *@var{peercred}})
Return user credentials of the peer. This will work only on certain
-systems and only when connected over a socket. If you are not
-interested in some of the values, pass @code{NULL} instead of the
-address of an appropriate variable. @var{pid}, @var{uid} and @var{gid}
-are only set if the function succeeds and returns with @code{0}.
+systems and only when connected over a socket. On success, a pointer
+to the peer credentials is stored in @var{peercred}. The information
+is only valid as long as the state of the connection is unchanged (at
+least until the next assuan call to the same context).
As of now only the server is able to retrieve this information. Note,
that for getting the pid of the peer @code{assuan_get_pid} is usually
Modified: trunk/src/assuan-connect.c
===================================================================
--- trunk/src/assuan-connect.c 2009-11-05 02:53:14 UTC (rev 316)
+++ trunk/src/assuan-connect.c 2009-11-05 12:00:35 UTC (rev 317)
@@ -61,29 +61,3 @@
{
return (ctx && ctx->pid) ? ctx->pid : -1;
}
-
-
-#ifndef HAVE_W32_SYSTEM
-/* Return user credentials. PID, UID and GID may be given as NULL if
- you are not interested in a value. For getting the pid of the
- peer the assuan_get_pid is usually better suited. */
-gpg_error_t
-assuan_get_peercred (assuan_context_t ctx, pid_t *pid, uid_t *uid, gid_t *gid)
-{
- if (!ctx)
- return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE);
- if (!ctx->peercred.valid)
- return _assuan_error (ctx, GPG_ERR_ASS_GENERAL);
-
-#ifdef HAVE_SO_PEERCRED
- if (pid)
- *pid = ctx->peercred.pid;
- if (uid)
- *uid = ctx->peercred.uid;
- if (gid)
- *gid = ctx->peercred.gid;
-#endif
-
- return 0;
-}
-#endif /* HAVE_W32_SYSTEM */
Modified: trunk/src/assuan-defs.h
===================================================================
--- trunk/src/assuan-defs.h 2009-11-05 02:53:14 UTC (rev 316)
+++ trunk/src/assuan-defs.h 2009-11-05 12:00:35 UTC (rev 317)
@@ -95,6 +95,9 @@
/* Callback handlers replacing system I/O functions. */
struct assuan_system_hooks system;
+ int peercred_valid; /* Whether this structure has valid information. */
+ struct _assuan_peercred peercred;
+
/* Now come the members specific to subsystems or engines. FIXME:
This is not developed yet. See below for the legacy members. */
struct
@@ -169,15 +172,6 @@
assuan_sock_nonce_t listen_nonce; /* Used with LISTEN_FD. */
assuan_fd_t connected_fd; /* helper */
- struct {
- int valid; /* Whether this structure has valid information. */
-#ifdef HAVE_SO_PEERCRED
- pid_t pid; /* The pid of the peer. */
- uid_t uid; /* The uid of the peer. */
- gid_t gid; /* The gid of the peer. */
-#endif /* HAVE_SO_PEERCRED */
- } peercred;
-
/* Used for Unix domain sockets. */
struct sockaddr_un myaddr;
struct sockaddr_un serveraddr;
Modified: trunk/src/assuan-pipe-connect.c
===================================================================
--- trunk/src/assuan-pipe-connect.c 2009-11-05 02:53:14 UTC (rev 316)
+++ trunk/src/assuan-pipe-connect.c 2009-11-05 12:00:35 UTC (rev 317)
@@ -380,21 +380,6 @@
#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. */
-gpg_error_t
-assuan_pipe_connect (assuan_context_t ctx, const char *name,
- const char *argv[], int *fd_child_list)
-{
- TRACE1 (ctx, ASSUAN_LOG_CTX, "assuan_pipe_connect", ctx,
- "name=%s", name ? name : "(null)");
-
- return pipe_connect (ctx, name, argv, fd_child_list, NULL, NULL, 0);
-}
-
-
/* Connect to a server over a full-duplex socket (i.e. created by
socketpair), creating the assuan context and returning it in CTX.
The server filename is NAME, the argument vector in ARGV.
@@ -425,11 +410,11 @@
"server" in *ARGV (but it is sufficient to check only the first
character). */
gpg_error_t
-assuan_pipe_connect_ext (assuan_context_t ctx,
- const char *name, const char *argv[],
- int *fd_child_list,
- void (*atfork) (void *opaque, int reserved),
- void *atforkvalue, unsigned int flags)
+assuan_pipe_connect (assuan_context_t ctx,
+ const char *name, const char *argv[],
+ int *fd_child_list,
+ void (*atfork) (void *opaque, int reserved),
+ void *atforkvalue, unsigned int flags)
{
TRACE2 (ctx, ASSUAN_LOG_CTX, "assuan_pipe_connect_ext", ctx,
"name=%s,flags=0x%x", name ? name : "(null)", flags);
Modified: trunk/src/assuan-socket-connect.c
===================================================================
--- trunk/src/assuan-socket-connect.c 2009-11-05 02:53:14 UTC (rev 316)
+++ trunk/src/assuan-socket-connect.c 2009-11-05 12:00:35 UTC (rev 317)
@@ -78,23 +78,11 @@
/* 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
- become handy in the future. */
-gpg_error_t
-assuan_socket_connect (assuan_context_t ctx,
- const char *name, pid_t server_pid)
-{
- return assuan_socket_connect_ext (ctx, name, server_pid, 0);
-}
-
-
-/* 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
become handy in the future. With flags set to 1 sendmsg and
recvmsg are used. */
gpg_error_t
-assuan_socket_connect_ext (assuan_context_t ctx,
- const char *name, pid_t server_pid,
- unsigned int flags)
+assuan_socket_connect (assuan_context_t ctx, const char *name,
+ pid_t server_pid, unsigned int flags)
{
gpg_error_t err;
assuan_fd_t fd;
Modified: trunk/src/assuan-socket-server.c
===================================================================
--- trunk/src/assuan-socket-server.c 2009-11-05 02:53:14 UTC (rev 316)
+++ trunk/src/assuan-socket-server.c 2009-11-05 12:00:35 UTC (rev 317)
@@ -46,7 +46,7 @@
{
assuan_fd_t fd = ctx->connected_fd;
- ctx->peercred.valid = 0;
+ ctx->peercred_valid = 0;
#ifdef HAVE_SO_PEERCRED
{
struct ucred cr;
@@ -57,7 +57,7 @@
ctx->peercred.pid = cr.pid;
ctx->peercred.uid = cr.uid;
ctx->peercred.gid = cr.gid;
- ctx->peercred.valid = 1;
+ ctx->peercred_valid = 1;
/* This overrides any already set PID if the function returns
a valid one. */
@@ -137,22 +137,14 @@
ctx->cmdtbl = NULL;
}
-/* Initialize a server for the socket LISTEN_FD which has already be
- put into listen mode */
-gpg_error_t
-assuan_init_socket_server (assuan_context_t ctx, assuan_fd_t listen_fd)
-{
- return assuan_init_socket_server_ext (ctx, listen_fd, 0);
-}
-
/*
Flag bits: 0 - use sendmsg/recvmsg to allow descriptor passing
1 - FD has already been accepted.
*/
gpg_error_t
-assuan_init_socket_server_ext (assuan_context_t ctx, assuan_fd_t fd,
- unsigned int flags)
+assuan_init_socket_server (assuan_context_t ctx, assuan_fd_t fd,
+ unsigned int flags)
{
gpg_error_t rc;
Modified: trunk/src/assuan.h
===================================================================
--- trunk/src/assuan.h 2009-11-05 02:53:14 UTC (rev 316)
+++ trunk/src/assuan.h 2009-11-05 12:00:35 UTC (rev 317)
@@ -361,43 +361,44 @@
gpg_error_t assuan_init_pipe_server (assuan_context_t ctx, int filedes[2]);
/*-- assuan-socket-server.c --*/
+#define ASSUAN_SOCKET_SERVER_FDPASSING 1
+#define ASSUAN_SOCKET_SERVER_ACCEPTED 2
gpg_error_t assuan_init_socket_server (assuan_context_t ctx,
- assuan_fd_t listen_fd);
-gpg_error_t assuan_init_socket_server_ext (assuan_context_t ctx,
- assuan_fd_t fd,
- unsigned int flags);
+ assuan_fd_t listen_fd,
+ unsigned int flags);
void assuan_set_sock_nonce (assuan_context_t ctx, assuan_sock_nonce_t *nonce);
/*-- assuan-pipe-connect.c --*/
+#define ASSUAN_PIPE_CONNECT_FDPASSING 1
+#define ASSUAN_PIPE_CONNECT_DETACHED 128
gpg_error_t assuan_pipe_connect (assuan_context_t ctx,
const char *name,
const char *argv[],
- assuan_fd_t *fd_child_list);
-gpg_error_t assuan_pipe_connect_ext (assuan_context_t ctx,
- const char *name,
- const char *argv[],
- assuan_fd_t *fd_child_list,
- void (*atfork) (void *, int),
- void *atforkvalue,
- unsigned int flags);
+ assuan_fd_t *fd_child_list,
+ void (*atfork) (void *, int),
+ void *atforkvalue,
+ unsigned int flags);
/*-- assuan-socket-connect.c --*/
-gpg_error_t assuan_socket_connect (assuan_context_t ctx,
- const char *name,
- pid_t server_pid);
+#define ASSUAN_SOCKET_CONNECT_FDPASSING 1
+gpg_error_t assuan_socket_connect (assuan_context_t ctx, const char *name,
+ pid_t server_pid, unsigned int flags);
-gpg_error_t assuan_socket_connect_ext (assuan_context_t ctx,
- const char *name,
- pid_t server_pid,
- unsigned int flags);
-
/*-- assuan-connect.c --*/
pid_t assuan_get_pid (assuan_context_t ctx);
+struct _assuan_peercred
+{
#ifndef _WIN32
-gpg_error_t assuan_get_peercred (assuan_context_t ctx,
- pid_t *pid, uid_t *uid, gid_t *gid);
+ pid_t pid;
+ uid_t uid;
+ gid_t gid;
#endif
+};
+typedef struct _assuan_peercred *assuan_peercred_t;
+gpg_error_t assuan_get_peercred (assuan_context_t ctx,
+ assuan_peercred_t *peercred);
+
/*-- assuan-client.c --*/
gpg_error_t
assuan_transact (assuan_context_t ctx,
Modified: trunk/src/context.c
===================================================================
--- trunk/src/context.c 2009-11-05 02:53:14 UTC (rev 316)
+++ trunk/src/context.c 2009-11-05 12:00:35 UTC (rev 317)
@@ -169,3 +169,19 @@
ctx->err_str = text;
return err;
}
+
+
+/* Return user credentials. For getting the pid of the peer the
+ assuan_get_pid is usually better suited. */
+gpg_error_t
+assuan_get_peercred (assuan_context_t ctx, assuan_peercred_t *peercred)
+{
+ if (!ctx)
+ return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE);
+ if (!ctx->peercred_valid)
+ return _assuan_error (ctx, GPG_ERR_ASS_GENERAL);
+
+ *peercred = &ctx->peercred;
+
+ return 0;
+}
Modified: trunk/src/libassuan.def
===================================================================
--- trunk/src/libassuan.def 2009-11-05 02:53:14 UTC (rev 316)
+++ trunk/src/libassuan.def 2009-11-05 12:00:35 UTC (rev 317)
@@ -36,64 +36,62 @@
assuan_get_log_cb @15
assuan_get_malloc_hooks @16
assuan_get_output_fd @17
- assuan_get_pid @18
- assuan_get_pointer @19
- assuan_init_pipe_server @20
- assuan_init_socket_server @21
- assuan_init_socket_server_ext @22
+ assuan_get_peercred @18
+ assuan_get_pid @19
+ assuan_get_pointer @20
+ assuan_init_pipe_server @21
+ assuan_init_socket_server @22
assuan_inquire @23
assuan_inquire_ext @24
assuan_new @25
assuan_new_ext @26
assuan_pending_line @27
assuan_pipe_connect @28
- assuan_pipe_connect_ext @29
- assuan_process @30
- assuan_process_done @31
- assuan_process_next @32
- assuan_read_line @33
- assuan_receivefd @34
- assuan_register_bye_notify @35
- assuan_register_cancel_notify @36
- assuan_register_command @37
- assuan_register_input_notify @38
- assuan_register_option_handler @39
- assuan_register_output_notify @40
- assuan_register_post_cmd_notify @41
- assuan_register_reset_notify @42
- assuan_release @43
- assuan_send_data @44
- assuan_sendfd @45
- assuan_set_assuan_log_prefix @46
- assuan_set_error @47
- assuan_set_flag @48
- assuan_set_gpg_err_source @49
- assuan_set_hello_line @50
- assuan_set_io_monitor @51
- assuan_set_log_cb @52
- assuan_set_log_stream @53
- assuan_set_malloc_hooks @54
- assuan_set_okay_line @55
- assuan_set_pointer @56
- assuan_set_system_hooks @57
- assuan_sock_bind @58
- assuan_sock_check_nonce @59
- assuan_sock_close @60
- assuan_sock_connect @61
- assuan_sock_deinit @62
- assuan_sock_get_nonce @63
- assuan_sock_init @64
- assuan_sock_new @65
- assuan_socket_connect @66
- assuan_socket_connect_ext @67
- assuan_transact @68
- assuan_write_line @69
- assuan_write_status @70
- __assuan_close @71
- __assuan_pipe @72
- __assuan_socketpair @73
- __assuan_spawn @74
- __assuan_usleep @75
+ assuan_process @29
+ assuan_process_done @30
+ assuan_process_next @31
+ assuan_read_line @32
+ assuan_receivefd @33
+ assuan_register_bye_notify @34
+ assuan_register_cancel_notify @35
+ assuan_register_command @36
+ assuan_register_input_notify @37
+ assuan_register_option_handler @38
+ assuan_register_output_notify @39
+ assuan_register_post_cmd_notify @40
+ assuan_register_reset_notify @41
+ assuan_release @42
+ assuan_send_data @43
+ assuan_sendfd @44
+ assuan_set_assuan_log_prefix @45
+ assuan_set_error @46
+ assuan_set_flag @47
+ assuan_set_gpg_err_source @48
+ assuan_set_hello_line @49
+ assuan_set_io_monitor @50
+ assuan_set_log_cb @51
+ assuan_set_log_stream @52
+ assuan_set_malloc_hooks @53
+ assuan_set_okay_line @54
+ assuan_set_pointer @55
+ assuan_set_system_hooks @56
+ assuan_sock_bind @57
+ assuan_sock_check_nonce @58
+ assuan_sock_close @59
+ assuan_sock_connect @60
+ assuan_sock_deinit @61
+ assuan_sock_get_nonce @62
+ assuan_sock_init @63
+ assuan_sock_new @64
+ assuan_socket_connect @65
+ assuan_transact @66
+ assuan_write_line @67
+ assuan_write_status @68
+ __assuan_close @69
+ __assuan_pipe @70
+ __assuan_socketpair @71
+ __assuan_spawn @72
+ __assuan_usleep @73
; END
Modified: trunk/src/libassuan.vers
===================================================================
--- trunk/src/libassuan.vers 2009-11-05 02:53:14 UTC (rev 316)
+++ trunk/src/libassuan.vers 2009-11-05 12:00:35 UTC (rev 317)
@@ -44,7 +44,6 @@
assuan_get_pointer;
assuan_init_pipe_server;
assuan_init_socket_server;
- assuan_init_socket_server_ext;
assuan_inquire;
assuan_inquire_ext;
assuan_new;
@@ -52,7 +51,6 @@
assuan_new_ext;
assuan_pending_line;
assuan_pipe_connect;
- assuan_pipe_connect_ext;
assuan_process;
assuan_process_done;
assuan_process_next;
@@ -91,7 +89,6 @@
assuan_sock_init;
assuan_sock_new;
assuan_socket_connect;
- assuan_socket_connect_ext;
assuan_transact;
assuan_write_line;
assuan_write_status;
Modified: trunk/tests/fdpassing.c
===================================================================
--- trunk/tests/fdpassing.c 2009-11-05 02:53:14 UTC (rev 316)
+++ trunk/tests/fdpassing.c 2009-11-05 12:00:35 UTC (rev 317)
@@ -288,9 +288,9 @@
if (err)
log_fatal ("assuan_new failed: %s\n", gpg_strerror (err));
- err = assuan_pipe_connect_ext (ctx, with_exec? "./fdpassing":NULL,
- with_exec ? arglist : &loc,
- no_close_fds, NULL, NULL, 1);
+ err = assuan_pipe_connect (ctx, with_exec? "./fdpassing":NULL,
+ with_exec ? arglist : &loc,
+ no_close_fds, NULL, NULL, 1);
if (err)
{
log_error ("assuan_pipe_connect failed: %s\n", gpg_strerror (err));
More information about the Gnupg-commits
mailing list