1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-01-20 14:37:08 +01:00

Support specifying the pipe name by the option.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka 2022-08-01 11:59:43 +09:00
parent 30df964607
commit c0a3748979
2 changed files with 37 additions and 39 deletions

View File

@ -230,7 +230,7 @@ static gpgrt_opt_t opts[] = {
/* */ "@" /* */ "@"
#endif #endif
), ),
ARGPARSE_s_n (oWin32OpenSSHSupport, "enable-win32-openssh-support", ARGPARSE_o_s (oWin32OpenSSHSupport, "enable-win32-openssh-support",
#ifdef HAVE_W32_SYSTEM #ifdef HAVE_W32_SYSTEM
/* */ N_("enable Win32-OpenSSH support") /* */ N_("enable Win32-OpenSSH support")
#else #else
@ -366,8 +366,9 @@ static int putty_support;
for the foreseeable future. */ for the foreseeable future. */
#define PUTTY_IPC_MAXLEN 16384 #define PUTTY_IPC_MAXLEN 16384
/* Flag indicating that support for Win32-OpenSSH has been enabled. */ /* Path to the pipe, which handles requests from Win32-OpenSSH. */
static int win32_openssh_support; static const char *win32_openssh_support;
#define W32_DEFAILT_AGENT_PIPE_NAME "\\\\.\\pipe\\openssh-ssh-agent"
#endif /*HAVE_W32_SYSTEM*/ #endif /*HAVE_W32_SYSTEM*/
/* The list of open file descriptors at startup. Note that this list /* The list of open file descriptors at startup. Note that this list
@ -1302,7 +1303,10 @@ main (int argc, char **argv)
case oWin32OpenSSHSupport: case oWin32OpenSSHSupport:
# ifdef HAVE_W32_SYSTEM # ifdef HAVE_W32_SYSTEM
win32_openssh_support = 1; if (pargs.r_type)
win32_openssh_support = pargs.r.ret_str;
else
win32_openssh_support = W32_DEFAILT_AGENT_PIPE_NAME;
# endif # endif
break; break;
@ -2763,9 +2767,7 @@ putty_message_thread (void *arg)
return NULL; return NULL;
} }
/* FIXME: it would be good to be specified by an option. */ #define BUFSIZE (5 * 1024)
#define AGENT_PIPE_NAME "\\\\.\\pipe\\openssh-ssh-agent"
#define BUFSIZE 5 * 1024
/* The thread handling Win32-OpenSSH requests through NamedPipe. */ /* The thread handling Win32-OpenSSH requests through NamedPipe. */
static void * static void *
@ -2785,7 +2787,7 @@ win32_openssh_thread (void *arg)
es_syshd_t syshd; es_syshd_t syshd;
npth_unprotect (); npth_unprotect ();
pipe = CreateNamedPipeA (AGENT_PIPE_NAME, PIPE_ACCESS_DUPLEX, pipe = CreateNamedPipeA (win32_openssh_support, PIPE_ACCESS_DUPLEX,
(PIPE_TYPE_BYTE | PIPE_READMODE_BYTE (PIPE_TYPE_BYTE | PIPE_READMODE_BYTE
| PIPE_WAIT | PIPE_REJECT_REMOTE_CLIENTS), | PIPE_WAIT | PIPE_REJECT_REMOTE_CLIENTS),
PIPE_UNLIMITED_INSTANCES, PIPE_UNLIMITED_INSTANCES,
@ -3042,10 +3044,8 @@ handle_connections (gnupg_fd_t listen_fd,
ret = npth_create (&thread, &tattr, putty_message_thread, NULL); ret = npth_create (&thread, &tattr, putty_message_thread, NULL);
if (ret) if (ret)
{
log_error ("error spawning putty message loop: %s\n", strerror (ret)); log_error ("error spawning putty message loop: %s\n", strerror (ret));
} }
}
if (win32_openssh_support) if (win32_openssh_support)
{ {
@ -3053,10 +3053,8 @@ handle_connections (gnupg_fd_t listen_fd,
ret = npth_create (&thread, &tattr, win32_openssh_thread, NULL); ret = npth_create (&thread, &tattr, win32_openssh_thread, NULL);
if (ret) if (ret)
{
log_error ("error spawning Win32-OpenSSH loop: %s\n", strerror (ret)); log_error ("error spawning Win32-OpenSSH loop: %s\n", strerror (ret));
} }
}
#endif /*HAVE_W32_SYSTEM*/ #endif /*HAVE_W32_SYSTEM*/
/* Set a flag to tell call-scd.c that it may enable event /* Set a flag to tell call-scd.c that it may enable event