diff options
author | Christian Poessinger <christian@poessinger.com> | 2021-01-17 19:12:15 +0100 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2021-01-17 19:12:35 +0100 |
commit | 36c9e15a60a4f99e6881702d6142711fa535f77d (patch) | |
tree | 9c3b6ceafba9118bb10132a794d080dc61ea37c7 /src | |
parent | 4c288cf08078bf7806dd34f103819e686bd11ad7 (diff) | |
download | vyos-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-x | src/conf_mode/interfaces-openvpn.py | 12 |
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() |