From 136d81c13c79aa510404e8cf7a63ea631b017209 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sun, 4 Oct 2020 19:13:31 +0200 Subject: pppoe-server: T2953: prepare common chap-secrets file --- data/templates/accel-ppp/chap-secrets.config_dict.tmpl | 12 ++++++++++++ data/templates/accel-ppp/chap-secrets.pppoe.tmpl | 12 ------------ src/conf_mode/service_pppoe-server.py | 3 ++- 3 files changed, 14 insertions(+), 13 deletions(-) create mode 100644 data/templates/accel-ppp/chap-secrets.config_dict.tmpl delete mode 100644 data/templates/accel-ppp/chap-secrets.pppoe.tmpl diff --git a/data/templates/accel-ppp/chap-secrets.config_dict.tmpl b/data/templates/accel-ppp/chap-secrets.config_dict.tmpl new file mode 100644 index 000000000..da64b64d5 --- /dev/null +++ b/data/templates/accel-ppp/chap-secrets.config_dict.tmpl @@ -0,0 +1,12 @@ +# username server password acceptable local IP addresses shaper +{% if authentication is defined and authentication.local_users is defined and authentication.local_users.username is defined %} +{% for user, user_config in authentication.local_users.username.items() %} +{% if user_config.disabled is not defined %} +{% if user_config.rate_limit is defined %} +{{ "%-12s" | format(user) }} * {{ "%-16s" | format(user_config.password) }} {{ "%-16s" | format(user_config.static_ip) }} {{ user_config.rate_limit.download }}/{{ user_config.rate_limit.upload }} +{% else %} +{{ "%-12s" | format(user) }} * {{ "%-16s" | format(user_config.password) }} {{ "%-16s" | format(user_config.static_ip) }} +{% endif %} +{% endif %} +{% endfor %} +{% endif %} diff --git a/data/templates/accel-ppp/chap-secrets.pppoe.tmpl b/data/templates/accel-ppp/chap-secrets.pppoe.tmpl deleted file mode 100644 index da64b64d5..000000000 --- a/data/templates/accel-ppp/chap-secrets.pppoe.tmpl +++ /dev/null @@ -1,12 +0,0 @@ -# username server password acceptable local IP addresses shaper -{% if authentication is defined and authentication.local_users is defined and authentication.local_users.username is defined %} -{% for user, user_config in authentication.local_users.username.items() %} -{% if user_config.disabled is not defined %} -{% if user_config.rate_limit is defined %} -{{ "%-12s" | format(user) }} * {{ "%-16s" | format(user_config.password) }} {{ "%-16s" | format(user_config.static_ip) }} {{ user_config.rate_limit.download }}/{{ user_config.rate_limit.upload }} -{% else %} -{{ "%-12s" | format(user) }} * {{ "%-16s" | format(user_config.password) }} {{ "%-16s" | format(user_config.static_ip) }} -{% endif %} -{% endif %} -{% endfor %} -{% endif %} diff --git a/src/conf_mode/service_pppoe-server.py b/src/conf_mode/service_pppoe-server.py index 445311391..30b382c69 100755 --- a/src/conf_mode/service_pppoe-server.py +++ b/src/conf_mode/service_pppoe-server.py @@ -164,7 +164,8 @@ def generate(pppoe): render(pppoe_conf, 'accel-ppp/pppoe.config.tmpl', pppoe, trim_blocks=True) if vyos_dict_search('authentication.mode', pppoe) == 'local': - render(pppoe_chap_secrets, 'accel-ppp/chap-secrets.pppoe.tmpl', pppoe, trim_blocks=True, permission=0o640) + render(pppoe_chap_secrets, 'accel-ppp/chap-secrets.config_dict.tmpl', + pppoe, trim_blocks=True, permission=0o640) else: if os.path.exists(pppoe_chap_secrets): os.unlink(pppoe_chap_secrets) -- cgit v1.2.3