summaryrefslogtreecommitdiff
path: root/src
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:35 +0100
commit36c9e15a60a4f99e6881702d6142711fa535f77d (patch)
tree9c3b6ceafba9118bb10132a794d080dc61ea37c7 /src
parent4c288cf08078bf7806dd34f103819e686bd11ad7 (diff)
downloadvyos-1x-36c9e15a60a4f99e6881702d6142711fa535f77d.tar.gz
vyos-1x-36c9e15a60a4f99e6881702d6142711fa535f77d.zip
openvpn: T2994: proper cleanup all files on interface deletion
(cherry picked from commit c0aaa0b8707c17fe86e6483b3f5caecaa3f7fd72)
Diffstat (limited to 'src')
-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()