From 2a6661305c4f05b312225f42ad931caa9df896b5 Mon Sep 17 00:00:00 2001 From: jim-p Date: Wed, 14 Aug 2013 08:48:46 -0400 Subject: Remove prior CSC entry when cleaning up. Fixes #3143 --- etc/inc/openvpn.inc | 10 ++++++++++ usr/local/www/vpn_openvpn_csc.php | 7 +++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/etc/inc/openvpn.inc b/etc/inc/openvpn.inc index d66e89f..75eba9e 100644 --- a/etc/inc/openvpn.inc +++ b/etc/inc/openvpn.inc @@ -838,6 +838,16 @@ function openvpn_delete($mode, & $settings) { mwexec("/bin/rm {$g['varetc_path']}/openvpn/{$mode_id}.*"); } +function openvpn_cleanup_csc($common_name) { + global $g, $config; + if (empty($common_name)) + return; + $fpath = "{$g['varetc_path']}/openvpn-csc/" . basename($common_name); + if (is_file($fpath)) + unlink_if_exists($fpath); + return; +} + function openvpn_resync_csc(& $settings) { global $g, $config; diff --git a/usr/local/www/vpn_openvpn_csc.php b/usr/local/www/vpn_openvpn_csc.php index 80726f4..a3893c9 100644 --- a/usr/local/www/vpn_openvpn_csc.php +++ b/usr/local/www/vpn_openvpn_csc.php @@ -210,11 +210,14 @@ if ($_POST) { $csc['nbdd_server1'] = $pconfig['nbdd_server1']; } - if (isset($id) && $a_csc[$id]) + if (isset($id) && $a_csc[$id]) { + $old_csc_cn = $a_csc[$id]['common_name']; $a_csc[$id] = $csc; - else + } else $a_csc[] = $csc; + if (!empty($old_csc_cn)) + openvpn_cleanup_csc($old_csc_cn); openvpn_resync_csc($csc); write_config(); -- cgit v1.1