]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
defer the switch to syslog until AFTER the tunnel is fully up,
authorDaniel Lenski <dlenski@gmail.com>
Tue, 5 Jan 2021 04:48:20 +0000 (20:48 -0800)
committerDaniel Lenski <dlenski@gmail.com>
Tue, 5 Jan 2021 04:52:43 +0000 (20:52 -0800)
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 <dlenski@gmail.com>
main.c
openconnect.8.in

diff --git a/main.c b/main.c
index e2ed51172d99ee78c77285f30c3af93f3b87c6ec..da4a26bf2ca2b8d2da95baba8034f17119cabf44 100644 (file)
--- 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"));
index 196bcc3ccc5c4d7f91c3d107feb9af520b434af7..55d43a061c6332be59f1c34fcb209ebab4ed2bf2 100644 (file)
@@ -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