From 4c288cf08078bf7806dd34f103819e686bd11ad7 Mon Sep 17 00:00:00 2001
From: Christian Poessinger <christian@poessinger.com>
Date: Sun, 17 Jan 2021 18:39:21 +0100
Subject: openvpn: T2381: bugfix rendering multiple openvpn-options from CLI

The CLI statement "set interfaces openvpn vtun10 openvpn-option '--tun-mtu 1500
--fragment 1300 --mssfix'" will render in vtun10.conf to:
  --tun-mtu 1500 --fragment 1300 --mssfix

On startup OpenVPN complains about:

openvpn-vtun10: Options error: Unrecognized option or missing or extra
                parameter(s) in vtun10.conf:76: tun-mtu (2.4.7)

The options must be split on -- to a new configuration line.

(cherry picked from commit f8a8ee02d0ede240f555ffa558665df686df24a8)
---
 data/templates/openvpn/server.conf.tmpl | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/data/templates/openvpn/server.conf.tmpl b/data/templates/openvpn/server.conf.tmpl
index b3b0c936a..79288e40f 100644
--- a/data/templates/openvpn/server.conf.tmpl
+++ b/data/templates/openvpn/server.conf.tmpl
@@ -281,6 +281,10 @@ compat-names
 # Custom options added by user (not validated)
 #
 {%   for option in openvpn_option %}
-{{ option }}
+{%     for argument in option.split('--') %}
+{%       if argument is defined and argument != '' %}
+--{{ argument }}
+{%       endif %}
+{%     endfor %}
 {%   endfor %}
 {% endif %}
-- 
cgit v1.2.3