You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

104 lines
3.2 KiB

From b3402a68a4d29e9b1ae4e012e39a7bcb14fea3cf Mon Sep 17 00:00:00 2001
From: Yousong Zhou <yszhou4tech@gmail.com>
Date: Thu, 30 Apr 2015 13:57:36 +0800
Subject: [PATCH 207/210] xl2tpd: introduce new option -l for using syslog as
the logging facility.
Defaults to old behaviour if no -l option was specified. Also update
manual doc to reflect this change.
---
doc/xl2tpd.8 | 5 +++++
file.h | 1 +
misc.c | 2 +-
xl2tpd.c | 13 ++++++++++++-
4 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/doc/xl2tpd.8 b/doc/xl2tpd.8
index 915b247..7afccac 100644
--- a/doc/xl2tpd.8
+++ b/doc/xl2tpd.8
@@ -20,6 +20,11 @@ This option prevents xl2tpd from detaching from the terminal and
daemonizing.
.TP
+.B -l
+This option tells xl2tpd to use syslog for logging even when \fB\-D\fR
+was specified.
+
+.TP
.B -c <config file>
Tells xl2tpd to use an alternate config file. Default is
/etc/xl2tpd/xl2tpd.conf. Fallback configuration file is
diff --git a/file.h b/file.h
index 89987ae..92df046 100644
--- a/file.h
+++ b/file.h
@@ -151,6 +151,7 @@ struct global
char pidfile[STRLEN]; /* File containing the pid number*/
char controlfile[STRLEN]; /* Control file name (named pipe) */
int daemon; /* Use daemon mode? */
+ int syslog; /* Use syslog for logging? */
int accesscontrol; /* Use access control? */
int forceuserspace; /* Force userspace? */
int packet_dump; /* Dump (print) all packets? */
diff --git a/misc.c b/misc.c
index 3092401..cccf4ca 100644
--- a/misc.c
+++ b/misc.c
@@ -57,7 +57,7 @@ void l2tp_log (int level, const char *fmt, ...)
vsnprintf (buf, sizeof (buf), fmt, args);
va_end (args);
- if(gconfig.daemon) {
+ if(gconfig.syslog) {
init_log();
SYSLOG_CALL( syslog (level, "%s", buf) );
} else {
diff --git a/xl2tpd.c b/xl2tpd.c
index 017adfd..1937690 100644
--- a/xl2tpd.c
+++ b/xl2tpd.c
@@ -1594,7 +1594,7 @@ void do_control ()
void usage(void) {
printf("\nxl2tpd version: %s\n", SERVER_VERSION);
printf("Usage: xl2tpd [-c <config file>] [-s <secret file>] [-p <pid file>]\n"
- " [-C <control file>] [-D]\n"
+ " [-C <control file>] [-D] [-l]\n"
" [-v, --version]\n");
printf("\n");
exit(1);
@@ -1605,6 +1605,7 @@ void init_args(int argc, char *argv[])
int i=0;
gconfig.daemon=1;
+ gconfig.syslog=-1;
memset(gconfig.altauthfile,0,STRLEN);
memset(gconfig.altconfigfile,0,STRLEN);
memset(gconfig.authfile,0,STRLEN);
@@ -1642,6 +1643,9 @@ void init_args(int argc, char *argv[])
else if (! strncmp(argv[i],"-D",2)) {
gconfig.daemon=0;
}
+ else if (! strncmp(argv[i],"-l",2)) {
+ gconfig.syslog=1;
+ }
else if (! strncmp(argv[i],"-s",2)) {
if(++i == argc)
usage();
@@ -1667,6 +1671,13 @@ void init_args(int argc, char *argv[])
usage();
}
}
+
+ /*
+ * defaults to syslog if no log facility was explicitly
+ * specified and we are about to daemonize
+ */
+ if (gconfig.syslog < 0)
+ gconfig.syslog = gconfig.daemon;
}
--
1.7.10.4