summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNIIBE Yutaka <gniibe@fsij.org>2022-11-07 11:54:44 +0900
committerNIIBE Yutaka <gniibe@fsij.org>2022-11-07 11:58:59 +0900
commit4b3f2e4ac67491f1cf7f1f7ab25fee44b7e6bb96 (patch)
treed77b741680153c955de9ffe6522cfc5bcf2c10e2
parent1c6812093082487a68f87b825acc3e4c19d7424e (diff)
parenta1f480468a3b41f3843833654c0b56c33552519c (diff)
downloadlibassuan-4b3f2e4ac67491f1cf7f1f7ab25fee44b7e6bb96.tar.gz
Merge branch 'master' into gniibe/t6236
-rw-r--r--src/assuan-pipe-server.c5
-rw-r--r--src/client.c2
-rw-r--r--tests/Makefile.am2
-rw-r--r--tests/fdpassing.c36
4 files changed, 27 insertions, 18 deletions
diff --git a/src/assuan-pipe-server.c b/src/assuan-pipe-server.c
index 7977b83..5c960a6 100644
--- a/src/assuan-pipe-server.c
+++ b/src/assuan-pipe-server.c
@@ -87,6 +87,11 @@ assuan_init_pipe_server (assuan_context_t ctx, assuan_fd_t filedes[2])
infd = filedes[0];
outfd = filedes[1];
}
+ else
+ {
+ infd = assuan_fd_from_posix_fd (0);
+ outfd = assuan_fd_from_posix_fd (1);
+ }
#else
s = getenv ("_assuan_connection_fd");
if (s && *s && is_valid_socket (s))
diff --git a/src/client.c b/src/client.c
index 1746788..dcb2a1a 100644
--- a/src/client.c
+++ b/src/client.c
@@ -51,7 +51,7 @@ _assuan_client_finish (assuan_context_t ctx)
if (ctx->pid != ASSUAN_INVALID_PID && ctx->pid)
{
if (!ctx->flags.is_socket)
- _assuan_waitpid (ctx, ctx->pid, ctx->flags.no_waitpid, NULL, 0);
+ _assuan_waitpid (ctx, ctx->pid, ctx->flags.no_waitpid, NULL, 0);
ctx->pid = ASSUAN_INVALID_PID;
}
diff --git a/tests/Makefile.am b/tests/Makefile.am
index f61cec5..317c66d 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -28,8 +28,8 @@ CLEANFILES =
TESTS = version
if HAVE_W32_SYSTEM
-testtools =
TESTS += fdpassing
+testtools =
else
TESTS += pipeconnect
testtools = socks5
diff --git a/tests/fdpassing.c b/tests/fdpassing.c
index 6323a41..9e1b6e9 100644
--- a/tests/fdpassing.c
+++ b/tests/fdpassing.c
@@ -48,7 +48,7 @@ cmd_echo (assuan_context_t ctx, char *line)
log_info ("got ECHO command (%s)\n", line);
- fd = assuan_get_input_fd (ctx);
+ fd = (int)assuan_get_input_fd (ctx);
if (fd == -1)
return gpg_error (GPG_ERR_ASS_NO_INPUT);
fp = fdopen (fd, "r");
@@ -102,18 +102,14 @@ server (void)
{
int rc;
assuan_context_t ctx;
- assuan_fd_t filedes[2];
log_info ("server started\n");
- filedes[0] = _get_osfhandle (0);
- filedes[1] = _get_osfhandle (1);
-
rc = assuan_new (&ctx);
if (rc)
log_fatal ("assuan_new failed: %s\n", gpg_strerror (rc));
- rc = assuan_init_pipe_server (ctx, filedes);
+ rc = assuan_init_pipe_server (ctx, NULL);
if (rc)
log_fatal ("assuan_init_pipe_server failed: %s\n", gpg_strerror (rc));
@@ -121,7 +117,7 @@ server (void)
if (rc)
log_fatal ("register_commands failed: %s\n", gpg_strerror(rc));
- // assuan_set_log_stream (ctx, stderr);
+ assuan_set_log_stream (ctx, stderr);
for (;;)
{
@@ -175,7 +171,7 @@ client (assuan_context_t ctx, const char *fname)
return -1;
}
- rc = assuan_sendfd (ctx, fileno (fp));
+ rc = assuan_sendfd (ctx, (assuan_fd_t)fileno (fp));
if (rc)
{
fclose (fp);
@@ -221,7 +217,7 @@ main (int argc, char **argv)
int last_argc = -1;
assuan_context_t ctx;
gpg_error_t err;
- int no_close_fds[2];
+ assuan_fd_t no_close_fds[2];
const char *arglist[10];
int is_server = 0;
int with_exec = 0;
@@ -242,7 +238,7 @@ main (int argc, char **argv)
"\n"
"Options:\n"
" --verbose Show what is going on\n"
-" --with-exec Exec the child. Default is just a fork\n"
+" --with-exec Exec the child. Default is just a fork on POSIX machine\n"
);
exit (0);
}
@@ -268,6 +264,9 @@ main (int argc, char **argv)
}
}
+#ifdef HAVE_W32_SYSTEM
+ with_exec = 1;
+#endif
assuan_set_assuan_log_prefix (log_prefix);
@@ -279,12 +278,19 @@ main (int argc, char **argv)
else
{
const char *loc;
+ const char *program_name;
- no_close_fds[0] = _get_osfhandle (fileno (stderr));
- no_close_fds[1] = -1;
+#ifdef HAVE_W32_SYSTEM
+ program_name = "fdpassing.exe";
+#else
+ program_name = "fdpassing";
+#endif
+
+ no_close_fds[0] = verbose? assuan_fd_from_posix_fd (2): (assuan_fd_t)-1;
+ no_close_fds[1] = (assuan_fd_t)-1;
if (with_exec)
{
- arglist[0] = "fdpassing.exe";
+ arglist[0] = program_name;
arglist[1] = "--server";
arglist[2] = verbose? "--verbose":NULL;
arglist[3] = NULL;
@@ -294,9 +300,7 @@ main (int argc, char **argv)
if (err)
log_fatal ("assuan_new failed: %s\n", gpg_strerror (err));
- assuan_set_log_stream (ctx, stderr);
-
- err = assuan_pipe_connect (ctx, with_exec? "./fdpassing.exe":NULL,
+ err = assuan_pipe_connect (ctx, with_exec? program_name : NULL,
with_exec ? arglist : &loc,
no_close_fds, NULL, NULL, 1);
if (err)