summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-09-08 14:34:41 +0200
committerChristian Poessinger <christian@poessinger.com>2021-09-09 09:14:30 +0200
commit451a7d6d97ee48d715e410617bdbb7149537c41a (patch)
tree01a17054b8bee36d0d3737795f64a57bdc14d96a /src
parentadca504a2c5cd60be46a741ab3aef83fa4dfe4cf (diff)
downloadvyos-1x-451a7d6d97ee48d715e410617bdbb7149537c41a.tar.gz
vyos-1x-451a7d6d97ee48d715e410617bdbb7149537c41a.zip
openvpn: T3805: use vyos.util.makedir() to create system directories
(cherry picked from commit 84e912ab2f583864e637c2df137f62f3d4cbeb14)
Diffstat (limited to 'src')
-rwxr-xr-xsrc/conf_mode/interfaces-openvpn.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/conf_mode/interfaces-openvpn.py b/src/conf_mode/interfaces-openvpn.py
index 0a420f7bf..8da299914 100755
--- a/src/conf_mode/interfaces-openvpn.py
+++ b/src/conf_mode/interfaces-openvpn.py
@@ -40,6 +40,7 @@ from vyos.util import call
from vyos.util import chown
from vyos.util import chmod_600
from vyos.util import dict_search
+from vyos.util import makedir
from vyos.validate import is_addr_assigned
from vyos import ConfigError
@@ -425,6 +426,10 @@ def verify(openvpn):
def generate(openvpn):
interface = openvpn['ifname']
directory = os.path.dirname(cfg_file.format(**openvpn))
+ # create base config directory on demand
+ makedir(directory, user, group)
+ # enforce proper permissions on /run/openvpn
+ chown(directory, user, group)
# we can't know in advance which clients have been removed,
# thus all client configs will be removed and re-added on demand
@@ -436,9 +441,7 @@ def generate(openvpn):
return None
# create client config directory on demand
- if not os.path.exists(ccd_dir):
- os.makedirs(ccd_dir, 0o755)
- chown(ccd_dir, user, group)
+ makedir(ccd_dir, user, group)
# Fix file permissons for keys
fix_permissions = []