Hello,

These patches add support for defining pid-file & control-socket from
configuration file.

Claer

# HG changeset patch
# User MJP
# Date 1452430850 -3600
#      Sun Jan 10 14:00:50 2016 +0100
# Node ID 12ffa641c5d987c3e1373f8a9156f4951faa54ed
# Parent  5df6e3ec88c3933dd06ced5fd459921a8043cead
Add: In the configuration file, define the PID file to use (set pid-file).

diff -r 5df6e3ec88c3 -r 12ffa641c5d9 usr.sbin/npppd/npppd/npppd.c
--- usr.sbin/npppd/npppd/npppd.c        Sun Jan 10 13:41:40 2016 +0100
+++ usr.sbin/npppd/npppd/npppd.c        Sun Jan 10 14:00:50 2016 +0100
@@ -310,6 +310,9 @@
        }
 
        pidpath0 = DEFAULT_NPPPD_PIDFILE;
+       if (strlen(_this->conf.pid_file_path) > 0) {
+               pidpath0 = _this->conf.pid_file_path;
+       }
 
        /* initialize event(3) */
        event_init();
diff -r 5df6e3ec88c3 -r 12ffa641c5d9 usr.sbin/npppd/npppd/npppd.h
--- usr.sbin/npppd/npppd/npppd.h        Sun Jan 10 13:41:40 2016 +0100
+++ usr.sbin/npppd/npppd/npppd.h        Sun Jan 10 14:00:50 2016 +0100
@@ -193,6 +193,7 @@
 struct npppd_conf {
        int                                max_session;
        int                                user_max_session;
+       char                               pid_file_path[PATH_MAX];
        TAILQ_HEAD(tunnconfs, tunnconf)    tunnconfs;
        TAILQ_HEAD(authconfs, authconf)    authconfs;
        TAILQ_HEAD(ipcpconfs, ipcpconf)    ipcpconfs;
diff -r 5df6e3ec88c3 -r 12ffa641c5d9 usr.sbin/npppd/npppd/parse.y
--- usr.sbin/npppd/npppd/parse.y        Sun Jan 10 13:41:40 2016 +0100
+++ usr.sbin/npppd/npppd/parse.y        Sun Jan 10 14:00:50 2016 +0100
@@ -102,7 +102,7 @@
 
 %}
 
-%token SET MAX_SESSION USER_MAX_SESSION
+%token SET MAX_SESSION USER_MAX_SESSION PID_FILE
 %token TUNNEL LISTEN ON PROTOCOL
 %token MRU
 %token IP LCP PAP CHAP EAP MPPE CCP MSCHAPV2 STATEFUL STATELESS REQUIRED
@@ -171,6 +171,10 @@
 
 set            : SET MAX_SESSION NUMBER        { conf->max_session = $3; }
                | SET USER_MAX_SESSION NUMBER   { conf->user_max_session = $3; }
+               | SET PID_FILE STRING           {
+                       strlcpy(conf->pid_file_path, $3, 
sizeof(conf->pid_file_path));
+                       free($3);
+               }
                ;
 
 /*
@@ -1047,6 +1051,7 @@
                { "no",                           NO},
                { "on",                           ON},
                { "pap",                          PAP},
+               { "pid-file",                     PID_FILE},
                { "pipex",                        PIPEX},
                { "pool-address",                 POOL_ADDRESS},
                { "port",                         PORT},



# HG changeset patch
# User MJP
# Date 1452430858 -3600
#      Sun Jan 10 14:00:58 2016 +0100
# Node ID 6e76b1f3b116537de0e91ab176f7681cb9c9daed
# Parent  12ffa641c5d987c3e1373f8a9156f4951faa54ed
Add: In the configuration file, define the control socket to use (set 
control-socket).

diff -r 12ffa641c5d9 -r 6e76b1f3b116 usr.sbin/npppd/npppd/npppd.c
--- usr.sbin/npppd/npppd/npppd.c        Sun Jan 10 14:00:50 2016 +0100
+++ usr.sbin/npppd/npppd/npppd.c        Sun Jan 10 14:00:58 2016 +0100
@@ -317,6 +317,9 @@
        /* initialize event(3) */
        event_init();
        _this->ctl_sock.cs_name = NPPPD_SOCKET;
+       if (strlen(_this->conf.control_socket_path) > 0) {
+               _this->ctl_sock.cs_name = _this->conf.control_socket_path;
+       }
        _this->ctl_sock.cs_ctx = _this;
        if (control_init(&_this->ctl_sock) == -1) {
                log_printf(LOG_ERR, "control_init() failed %s(): %m",
diff -r 12ffa641c5d9 -r 6e76b1f3b116 usr.sbin/npppd/npppd/npppd.h
--- usr.sbin/npppd/npppd/npppd.h        Sun Jan 10 14:00:50 2016 +0100
+++ usr.sbin/npppd/npppd/npppd.h        Sun Jan 10 14:00:58 2016 +0100
@@ -194,6 +194,7 @@
        int                                max_session;
        int                                user_max_session;
        char                               pid_file_path[PATH_MAX];
+       char                               control_socket_path[PATH_MAX];
        TAILQ_HEAD(tunnconfs, tunnconf)    tunnconfs;
        TAILQ_HEAD(authconfs, authconf)    authconfs;
        TAILQ_HEAD(ipcpconfs, ipcpconf)    ipcpconfs;
diff -r 12ffa641c5d9 -r 6e76b1f3b116 usr.sbin/npppd/npppd/parse.y
--- usr.sbin/npppd/npppd/parse.y        Sun Jan 10 14:00:50 2016 +0100
+++ usr.sbin/npppd/npppd/parse.y        Sun Jan 10 14:00:58 2016 +0100
@@ -102,7 +102,7 @@
 
 %}
 
-%token SET MAX_SESSION USER_MAX_SESSION PID_FILE
+%token SET MAX_SESSION USER_MAX_SESSION PID_FILE CONTROL_SOCKET
 %token TUNNEL LISTEN ON PROTOCOL
 %token MRU
 %token IP LCP PAP CHAP EAP MPPE CCP MSCHAPV2 STATEFUL STATELESS REQUIRED
@@ -175,6 +175,10 @@
                        strlcpy(conf->pid_file_path, $3, 
sizeof(conf->pid_file_path));
                        free($3);
                }
+               | SET CONTROL_SOCKET STRING          {
+                       strlcpy(conf->control_socket_path, $3, 
sizeof(conf->control_socket_path));
+                       free($3);
+               }
                ;
 
 /*
@@ -997,6 +1001,7 @@
                { "ccp-timeout",                  CCP_TIMEOUT},
                { "chap",                         CHAP},
                { "chap-name",                    CHAP_NAME},
+               { "control-socket",               CONTROL_SOCKET},
                { "debug-dump-pktin",             DEBUG_DUMP_PKTIN},
                { "debug-dump-pktout",            DEBUG_DUMP_PKTOUT},
                { "dns-servers",                  DNS_SERVERS},



# HG changeset patch
# User MJP
# Date 1452436846 -3600
#      Sun Jan 10 15:40:46 2016 +0100
# Node ID 52f96bbfc0cb83010e78d49b63a185555bdc00a7
# Parent  6e76b1f3b116537de0e91ab176f7681cb9c9daed
Documentation: Update the default configuration file and the manual page (set 
pid-file, set control-socket).

diff -r 6e76b1f3b116 -r 52f96bbfc0cb usr.sbin/npppd/npppd/npppd.conf
--- usr.sbin/npppd/npppd/npppd.conf     Sun Jan 10 14:00:58 2016 +0100
+++ usr.sbin/npppd/npppd/npppd.conf     Sun Jan 10 15:40:46 2016 +0100
@@ -30,3 +30,6 @@
 # use tun(4) interface.  multiple ppp sessions concentrate one interface.
 #interface tun0  address 10.0.0.1 ipcp IPCP
 #bind tunnel from L2TP authenticated by LOCAL to tun0
+
+#set pid-file "/var/run/npppd.pid"
+#set control-socket "/var/run/npppd.sock"
diff -r 6e76b1f3b116 -r 52f96bbfc0cb usr.sbin/npppd/npppd/npppd.conf.5
--- usr.sbin/npppd/npppd/npppd.conf.5   Sun Jan 10 14:00:58 2016 +0100
+++ usr.sbin/npppd/npppd/npppd.conf.5   Sun Jan 10 15:40:46 2016 +0100
@@ -55,6 +55,14 @@
 .Sq 0
 means no limit.
 The default value is 0.
+.It Ic set pid-file Ar string
+Specify the path and the name of the process identifier file.
+The default value is
+.Dq /var/run/npppd.pid .
+.It Ic set control-socket Ar string
+Specify the path and the name of the control socket used by npppctl.
+The default value is
+.Dq /var/run/npppd.sock .
 .El
 .Sh TUNNEL
 The

Reply via email to