From fef2c7fbb851dd99c9ad8e41f9557049419a97d0 Mon Sep 17 00:00:00 2001 From: Daniel Lenski Date: Mon, 4 Jan 2021 20:48:20 -0800 Subject: [PATCH] defer the switch to syslog until AFTER the tunnel is fully up, This way, initial connection information and background PID will be usefully printed to the console, as will errors which prevent the tunnel from being started (and thus cause OpenConnect to abort as soon as it's established a connection to the server). This is a further refinement of 557ac6cfa6d42045ac5ed5e65e2fb079106643fa (!117). Signed-off-by: Daniel Lenski --- main.c | 18 +++++++++--------- openconnect.8.in | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/main.c b/main.c index e2ed5117..da4a26bf 100644 --- a/main.c +++ b/main.c @@ -82,6 +82,7 @@ static int verbose = PRG_INFO; static int timestamp; #ifndef _WIN32 static int background; +static int use_syslog = 0; static FILE *pid_fp = NULL; static char *pidfile = NULL; #endif @@ -1506,7 +1507,14 @@ static void fully_up_cb(void *_vpninfo) { #ifndef _WIN32 if (background) pid_fp = background_self(vpninfo, pidfile); -#endif + +#ifndef __native_client__ + if (use_syslog) { + openlog("openconnect", LOG_PID, LOG_DAEMON); + vpninfo->progress = syslog_progress; + } +#endif /* !__native_client__ */ +#endif /* !_WIN32 */ } int main(int argc, char **argv) @@ -1531,7 +1539,6 @@ int main(int argc, char **argv) #ifndef _WIN32 struct sigaction sa; struct utsname utsbuf; - int use_syslog = 0; #endif #ifdef ENABLE_NLS @@ -2068,13 +2075,6 @@ int main(int argc, char **argv) } -#if !defined(_WIN32) && !defined(__native_client__) - if (use_syslog) { - openlog("openconnect", LOG_PID, LOG_DAEMON); - vpninfo->progress = syslog_progress; - } -#endif /* !_WIN32 && !__native_client__ */ - if (!vpninfo->vpnc_script) { vpn_progress(vpninfo, PRG_INFO, _("No --script argument provided; DNS and routing are not configured\n")); diff --git a/openconnect.8.in b/openconnect.8.in index 196bcc3c..55d43a06 100644 --- a/openconnect.8.in +++ b/openconnect.8.in @@ -226,7 +226,7 @@ Use for tunnel interface .TP .B \-l,\-\-syslog -Use syslog for progress messages +After tunnel is brought up, use syslog for further progress messages .TP .B \-\-timestamp Prepend a timestamp to each progress message