Skip to content

Commit

Permalink
defer the switch to syslog until AFTER the tunnel is fully up,
Browse files Browse the repository at this point in the history
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 557ac6c (!117).

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
  • Loading branch information
dlenski committed Jan 5, 2021
1 parent b156b58 commit fef2c7f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions main.c
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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"));
Expand Down
2 changes: 1 addition & 1 deletion openconnect.8.in
Expand Up @@ -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
Expand Down

0 comments on commit fef2c7f

Please sign in to comment.