summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-01-17 19:12:15 +0100
committerChristian Poessinger <christian@poessinger.com>2021-01-17 19:12:15 +0100
commitc0aaa0b8707c17fe86e6483b3f5caecaa3f7fd72 (patch)
tree0ced18c93aa56102e5e3c8b0c7da5bd23b812865
parentf8a8ee02d0ede240f555ffa558665df686df24a8 (diff)
downloadvyos-1x-c0aaa0b8707c17fe86e6483b3f5caecaa3f7fd72.tar.gz
vyos-1x-c0aaa0b8707c17fe86e6483b3f5caecaa3f7fd72.zip
openvpn: T2994: proper cleanup all files on interface deletion
-rwxr-xr-xsrc/conf_mode/interfaces-openvpn.py12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/conf_mode/interfaces-openvpn.py b/src/conf_mode/interfaces-openvpn.py
index e4a6a5ec1..ee6f05fcd 100755
--- a/src/conf_mode/interfaces-openvpn.py
+++ b/src/conf_mode/interfaces-openvpn.py
@@ -17,6 +17,7 @@
import os
import re
+from glob import glob
from sys import exit
from ipaddress import IPv4Address
from ipaddress import IPv4Network
@@ -488,14 +489,9 @@ def apply(openvpn):
# Do some cleanup when OpenVPN is disabled/deleted
if 'deleted' in openvpn or 'disable' in openvpn:
- # cleanup old configuration files
- cleanup = []
- cleanup.append(cfg_file.format(**openvpn))
- cleanup.append(openvpn['auth_user_pass_file'])
-
- for file in cleanup:
- if os.path.isfile(file):
- os.unlink(file)
+ for cleanup_file in glob(f'/run/openvpn/{interface}.*'):
+ if os.path.isfile(cleanup_file):
+ os.unlink(cleanup_file)
if interface in interfaces():
VTunIf(interface).remove()