]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
Print detailed error information when opening cmd pipe/socketpair fails
authorDimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
Sat, 25 Dec 2021 21:28:54 +0000 (22:28 +0100)
committerDaniel Lenski <dlenski@gmail.com>
Thu, 10 Feb 2022 22:56:10 +0000 (14:56 -0800)
Retrieve and print detailed information using GetLastError() and
strerror().

This should be more useful to end-users than the current message (simply
“Error opening cmd pipe”) and might have helped us to solve
https://gitlab.com/openconnect/openconnect/-/issues/228 more quickly.

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
Signed-off-by: Daniel Lenski <dlenski@gmail.com>
main.c

diff --git a/main.c b/main.c
index 26843adb9b8998ac5a11981bb8b36adcdfcf2edb..659e91398548ce1b69aa7b520951d133355dda0b 100644 (file)
--- a/main.c
+++ b/main.c
@@ -2186,7 +2186,15 @@ int main(int argc, char **argv)
        sig_vpninfo = vpninfo;
        sig_cmd_fd = openconnect_setup_cmd_pipe(vpninfo);
        if (sig_cmd_fd < 0) {
-               fprintf(stderr, _("Error opening cmd pipe\n"));
+#ifdef _WIN32
+               char *errstr = openconnect__win32_strerror(GetLastError());
+#else
+               const char *errstr = strerror(errno);
+#endif /* _WIN32 */
+               fprintf(stderr, _("Error opening cmd pipe: %s\n"), errstr);
+#ifdef _WIN32
+               free(errstr);
+#endif /* _WIN32 */
                exit(1);
        }
        vpninfo->cmd_fd_internal = 1;