From 17371e0df05ccf57f858b852b8bec632ac889a18 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sun, 25 Apr 2021 06:07:31 +0100 Subject: [PATCH] Fix named_pipe_agent_exists(), which just didn't work. GetFileType() takes a HANDLE, not a pathname. So passing it the pathname of the agent named pipe would never have worked at all. I hadn't noticed, because the only call to that function logical-ORs its return value with that of wm_copydata_agent_exists(), and the latter _does_ work. So if you're running true Pageant, which presents both IPC interfaces, then there's no problem. But if a Pageant-emulating system wanted to present only the named-pipe version, then we wouldn't have detected it. Now we should do. --- windows/winpgntc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/windows/winpgntc.c b/windows/winpgntc.c index 07f75ce6..dd4de0c7 100644 --- a/windows/winpgntc.c +++ b/windows/winpgntc.c @@ -153,9 +153,13 @@ Socket *agent_connect(Plug *plug) static bool named_pipe_agent_exists(void) { char *pipename = agent_named_pipe_name(); - DWORD type = GetFileType(pipename); + WIN32_FIND_DATA data; + HANDLE ffh = FindFirstFile(pipename, &data); sfree(pipename); - return type == FILE_TYPE_PIPE; + if (ffh == INVALID_HANDLE_VALUE) + return false; + FindClose(ffh); + return true; } bool agent_exists(void)