summaryrefslogtreecommitdiff
path: root/src/conf_mode
diff options
context:
space:
mode:
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-xsrc/conf_mode/interfaces-pppoe.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/conf_mode/interfaces-pppoe.py b/src/conf_mode/interfaces-pppoe.py
index e6e71e501..02d3cf3ce 100755
--- a/src/conf_mode/interfaces-pppoe.py
+++ b/src/conf_mode/interfaces-pppoe.py
@@ -21,6 +21,8 @@ from copy import deepcopy
from jinja2 import Template
from subprocess import Popen, PIPE
from time import sleep
+from pwd import getpwnam
+from grp import getgrnam
from vyos.config import Config
from vyos.ifconfig import Interface
@@ -71,7 +73,7 @@ persist
ifname {{ intf }}
ipparam {{ intf }}
debug
-logfile /var/log/vyatta/ppp_{{ intf }}.log
+logfile {{ logfile }}
{% if 'auto' in default_route -%}
defaultroute
{% elif 'force' in default_route -%}
@@ -94,6 +96,8 @@ rp_pppoe_service "{{ service_name }}"
"""
+PPP_LOGFILE = '/var/log/vyatta/ppp_{}.log'
+
default_config_data = {
'access_concentrator': '',
'auth_username': '',
@@ -108,6 +112,7 @@ default_config_data = {
'ipv6_autoconf': False,
'ipv6_enable': False,
'local_address': '',
+ 'logfile': '',
'mtu': '1492',
'name_server': True,
'remote_address': '',
@@ -127,6 +132,7 @@ def get_config():
# determine tagNode instance
try:
pppoe['intf'] = os.environ['VYOS_TAGNODE_VALUE']
+ pppoe['logfile'] = PPP_LOGFILE.format(pppoe['intf'])
except KeyError as E:
print("Interface not specified")
@@ -212,6 +218,9 @@ def verify(pppoe):
if not pppoe['source_interface']:
raise ConfigError('PPPoE source interface is missing')
+ if pppoe['source_interface'] not in interfaces():
+ raise ConfigError('PPPoE source interface does not exist')
+
return None
def generate(pppoe):
@@ -241,7 +250,12 @@ def apply(pppoe):
return None
if not pppoe['disable']:
- # Dial PPPoE connection
+ # make logfile owned by root / vyattacfg
+ uid = getpwnam('root').pw_uid
+ gid = getgrnam('vyattacfg').gr_gid
+ os.chown(pppoe['logfile'], uid, gid)
+
+ # dial PPPoE connection
cmd = 'systemctl start ppp@{}.service'.format(pppoe['intf'])
subprocess_cmd(cmd)