diff options
author | NIIBE Yutaka <gniibe@fsij.org> | 2022-11-09 11:33:28 +0900 |
---|---|---|
committer | NIIBE Yutaka <gniibe@fsij.org> | 2022-11-09 11:33:28 +0900 |
commit | ba84b780df973ba7ca7f7c51fbd1b6d1a69b8c01 (patch) | |
tree | 30ad44e96e632df10d7c74c0e9426c3602c6bdb9 | |
parent | 7e6f3f007d64b6b6b402c8459c8ba6b39289f4ff (diff) | |
download | libassuan-ba84b780df973ba7ca7f7c51fbd1b6d1a69b8c01.tar.gz |
w32: Have PROCESS_HANDLE in struct assuan_context_s.
* src/assuan-defs.h (struct assuan_context_s): Add process_handle
field. It's "int" instead of DWORD, because of getpid function.
* src/assuan-pipe-connect.c (initial_handshake): Set ->process_handle,
not override ->pid.
* src/assuan-socket-connect.c (assuan_connect_finalize): Likewise.
* src/system-w32.c (w32_fdpass_send): Use ->process_handle.
--
In the client code, ctx->pid (by the function assuan_get_pid) may be
used to watch the finish of server process. Thus, it should not be
overridden. See: gnupg/agent/call-daemon.c.
GnuPG-bug-id: 6236
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
-rw-r--r-- | src/assuan-defs.h | 3 | ||||
-rw-r--r-- | src/assuan-pipe-connect.c | 10 | ||||
-rw-r--r-- | src/assuan-socket-connect.c | 12 | ||||
-rw-r--r-- | src/system-w32.c | 2 |
4 files changed, 17 insertions, 10 deletions
diff --git a/src/assuan-defs.h b/src/assuan-defs.h index 68bd983..0cdb08d 100644 --- a/src/assuan-defs.h +++ b/src/assuan-defs.h @@ -180,6 +180,9 @@ struct assuan_context_s int max_accepts; /* If we can not handle more than one connection, set this to 1, otherwise to -1. */ pid_t pid; /* The pid of the peer. */ +#if defined(HAVE_W64_SYSTEM) || defined(HAVE_W32_SYSTEM) + int process_handle; /* process handle of the server for FD passing. */ +#endif assuan_fd_t listen_fd; /* The fd we are listening on (used by socket servers) */ assuan_sock_nonce_t listen_nonce; /* Used with LISTEN_FD. */ diff --git a/src/assuan-pipe-connect.c b/src/assuan-pipe-connect.c index fc56334..17d3c95 100644 --- a/src/assuan-pipe-connect.c +++ b/src/assuan-pipe-connect.c @@ -106,9 +106,9 @@ initial_handshake (assuan_context_t ctx) "can't connect server: %s", gpg_strerror (err)); else if (response == ASSUAN_RESPONSE_OK) { -#ifdef HAVE_W32_SYSTEM +#if defined(HAVE_W64_SYSTEM) || defined(HAVE_W32_SYSTEM) const char *line = ctx->inbound.line + off; - int pid = ASSUAN_INVALID_PID; + int process_handle = ASSUAN_INVALID_PID; /* Parse the message: OK ..., process %i */ line = strchr (line, ','); @@ -119,11 +119,11 @@ initial_handshake (assuan_context_t ctx) { line = strchr (line + 1, ' '); if (line) - pid = atoi (line + 1); + process_handle = atoi (line + 1); } } - if (pid != ASSUAN_INVALID_PID) - ctx->pid = pid; + if (process_handle != ASSUAN_INVALID_PID) + ctx->process_handle = process_handle; #else ; #endif diff --git a/src/assuan-socket-connect.c b/src/assuan-socket-connect.c index 457edfe..629399e 100644 --- a/src/assuan-socket-connect.c +++ b/src/assuan-socket-connect.c @@ -133,8 +133,9 @@ _assuan_connect_finalize (assuan_context_t ctx, assuan_fd_t fd, "can't connect to server: %s\n", gpg_strerror (err)); else if (response == ASSUAN_RESPONSE_OK) { +#if defined(HAVE_W64_SYSTEM) || defined(HAVE_W32_SYSTEM) const char *line = ctx->inbound.line + off; - int pid = ASSUAN_INVALID_PID; + int process_handle = ASSUAN_INVALID_PID; /* Parse the message: OK ..., process %i */ line = strchr (line, ','); @@ -145,11 +146,14 @@ _assuan_connect_finalize (assuan_context_t ctx, assuan_fd_t fd, { line = strchr (line + 1, ' '); if (line) - pid = atoi (line + 1); + process_handle = atoi (line + 1); } } - if (pid != ASSUAN_INVALID_PID) - ctx->pid = pid; + if (process_handle != ASSUAN_INVALID_PID) + ctx->process_handle = process_handle; +#else + ; +#endif } else { diff --git a/src/system-w32.c b/src/system-w32.c index 76ff2a0..0d6681f 100644 --- a/src/system-w32.c +++ b/src/system-w32.c @@ -205,7 +205,7 @@ w32_fdpass_send (assuan_context_t ctx, assuan_fd_t fd) fd_converted_to_integer = (intptr_t)fd; fd0 = (int)fd_converted_to_integer; /* Bit pattern is possibly truncated. */ - err = get_file_handle (fd0, ctx->pid, &file_handle); + err = get_file_handle (fd0, ctx->process_handle, &file_handle); if (err) return err; |