From 2d6bbf341d0554fb33179dfe7757b6e22f993fe6 Mon Sep 17 00:00:00 2001
From: Konstantin Tokarev <ktokarev@smartlabs.tv>
Date: Tue, 1 Dec 2015 21:52:38 +0300
Subject: [PATCH] Moved usingsyslog from svr_runopts to runopts.

---
 cli-runopts.c | 3 +++
 runopts.h     | 2 +-
 svr-main.c    | 4 ++--
 svr-runopts.c | 4 ++--
 svr-session.c | 4 ++--
 5 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/cli-runopts.c b/cli-runopts.c
index 0522221e..25a2f161 100644
--- a/cli-runopts.c
+++ b/cli-runopts.c
@@ -172,6 +172,9 @@ void cli_getopts(int argc, char ** argv) {
 #ifdef ENABLE_USER_ALGO_LIST
 	opts.cipher_list = NULL;
 	opts.mac_list = NULL;
+#endif
+#ifndef DISABLE_SYSLOG
+	opts.usingsyslog = 0;
 #endif
 	/* not yet
 	opts.ipv4 = 1;
diff --git a/runopts.h b/runopts.h
index 92c105b0..613ccf15 100644
--- a/runopts.h
+++ b/runopts.h
@@ -40,6 +40,7 @@ typedef struct runopts {
 	unsigned int recv_window;
 	time_t keepalive_secs; /* Time between sending keepalives. 0 is off */
 	time_t idle_timeout_secs; /* Exit if no traffic is sent/received in this time */
+	int usingsyslog;
 
 #ifndef DISABLE_ZLIB
 	/* TODO: add a commandline flag. Currently this is on by default if compression
@@ -70,7 +71,6 @@ typedef struct svr_runopts {
 	char * bannerfile;
 
 	int forkbg;
-	int usingsyslog;
 
 	/* ports and addresses are arrays of the portcount 
 	listening ports. strings are malloced. */
diff --git a/svr-main.c b/svr-main.c
index cc59332d..8bd1a78d 100644
--- a/svr-main.c
+++ b/svr-main.c
@@ -145,7 +145,7 @@ void main_noinetd() {
 	if (svr_opts.forkbg) {
 		int closefds = 0;
 #ifndef DEBUG_TRACE
-		if (!svr_opts.usingsyslog) {
+		if (!opts.usingsyslog) {
 			closefds = 1;
 		}
 #endif
@@ -367,8 +367,8 @@ static void commonsetup() {
 
 	struct sigaction sa_chld;
 #ifndef DISABLE_SYSLOG
-	if (svr_opts.usingsyslog) {
 		startsyslog();
+	if (opts.usingsyslog) {
 	}
 #endif
 
diff --git a/svr-runopts.c b/svr-runopts.c
index 0e709987..8f60059f 100644
--- a/svr-runopts.c
+++ b/svr-runopts.c
@@ -158,7 +158,7 @@ void svr_getopts(int argc, char ** argv) {
 	svr_opts.domotd = 1;
 #endif
 #ifndef DISABLE_SYSLOG
-	svr_opts.usingsyslog = 1;
+	opts.usingsyslog = 1;
 #endif
 	opts.recv_window = DEFAULT_RECV_WINDOW;
 	opts.keepalive_secs = DEFAULT_KEEPALIVE;
@@ -189,7 +189,7 @@ void svr_getopts(int argc, char ** argv) {
 					break;
 #ifndef DISABLE_SYSLOG
 				case 'E':
-					svr_opts.usingsyslog = 0;
+					opts.usingsyslog = 0;
 					break;
 #endif
 #ifdef ENABLE_SVR_LOCALTCPFWD
diff --git a/svr-session.c b/svr-session.c
index ea9ca7e2..c3785626 100644
--- a/svr-session.c
+++ b/svr-session.c
@@ -204,7 +204,7 @@ void svr_dropbear_log(int priority, const char* format, va_list param) {
 	vsnprintf(printbuf, sizeof(printbuf), format, param);
 
 #ifndef DISABLE_SYSLOG
-	if (svr_opts.usingsyslog) {
+	if (opts.usingsyslog) {
 		syslog(priority, "%s", printbuf);
 	}
 #endif
@@ -215,7 +215,7 @@ void svr_dropbear_log(int priority, const char* format, va_list param) {
 	havetrace = debug_trace;
 #endif
 
-	if (!svr_opts.usingsyslog || havetrace)
+	if (!opts.usingsyslog || havetrace)
 	{
 		struct tm * local_tm = NULL;
 		timesec = time(NULL);
-- 
GitLab