summaryrefslogtreecommitdiffstats
path: root/kbx
diff options
context:
space:
mode:
authorNIIBE Yutaka <gniibe@fsij.org>2023-07-06 03:25:15 +0200
committerNIIBE Yutaka <gniibe@fsij.org>2023-07-06 03:25:15 +0200
commit2abea42d9ce482d5d7eb4e6ecaa2ae798ba519a1 (patch)
treed27b99eb79af98e769f136cf0641e76d2f200042 /kbx
parentgpg: Fix gpg --server mode on Windows. (diff)
downloadgnupg2-2abea42d9ce482d5d7eb4e6ecaa2ae798ba519a1.tar.xz
gnupg2-2abea42d9ce482d5d7eb4e6ecaa2ae798ba519a1.zip
kbx: Use es_sysopen_nc instead of es_fdopen_nc.
* kbx/kbxserver.c (prepare_outstream): Use es_sysopen_nc and avoid the use of translate_sys2libc_fd. -- On Windows, it's better directly use the system HANDLE. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
Diffstat (limited to 'kbx')
-rw-r--r--kbx/kbxserver.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/kbx/kbxserver.c b/kbx/kbxserver.c
index ae9ae5c75..cc122fad5 100644
--- a/kbx/kbxserver.c
+++ b/kbx/kbxserver.c
@@ -131,21 +131,34 @@ get_assuan_ctx_from_ctrl (ctrl_t ctrl)
static gpg_error_t
prepare_outstream (ctrl_t ctrl)
{
- int fd;
+ gnupg_fd_t fd;
+ estream_t out_fp = NULL;
log_assert (ctrl && ctrl->server_local);
if (ctrl->server_local->outstream)
return 0; /* Already enabled. */
- fd = translate_sys2libc_fd
- (assuan_get_output_fd (get_assuan_ctx_from_ctrl (ctrl)), 1);
- if (fd == -1)
+ fd = assuan_get_output_fd (get_assuan_ctx_from_ctrl (ctrl));
+ if (fd == GNUPG_INVALID_FD)
return 0; /* No Output command active. */
+ else
+ {
+ es_syshd_t syshd;
+
+#ifdef HAVE_W32_SYSTEM
+ syshd.type = ES_SYSHD_HANDLE;
+ syshd.u.handle = fd;
+#else
+ syshd.type = ES_SYSHD_FD;
+ syshd.u.fd = fd;
+#endif
+ out_fp = es_sysopen_nc (&syshd, "w");
+ if (!out_fp)
+ return gpg_err_code_from_syserror ();
+ }
- ctrl->server_local->outstream = es_fdopen_nc (fd, "w");
- if (!ctrl->server_local->outstream)
- return gpg_err_code_from_syserror ();
+ ctrl->server_local->outstream = out_fp;
return 0;
}