mirror of
https://github.com/pfsense/pfsense.git
synced 2025-10-26 11:38:35 +00:00
Add safety belts to code in rc.openvpn to avoid php errors to leave stale locks around
This commit is contained in:
parent
48085d0cc8
commit
5d1bde9670
@ -41,19 +41,22 @@ require_once("openvpn.inc");
|
||||
function openvpn_resync_if_needed ($mode, $ovpn_settings, $interface) {
|
||||
global $g, $config;
|
||||
|
||||
$resync_needed = false;
|
||||
if (empty($interface)) {
|
||||
$resync_needed = true;
|
||||
} else {
|
||||
$resync_needed = true;
|
||||
if (!empty($interface)) {
|
||||
$mode_id = $mode . $ovpn_settings['vpnid'];
|
||||
$fpath = "{$g['varetc_path']}/openvpn/{$mode_id}.interface";
|
||||
$current_device = file_get_contents($fpath);
|
||||
$new_device = get_failover_interface($ovpn_settings['interface']);
|
||||
$this_device = $config['interfaces'][$interface]['if'];
|
||||
if (($current_device != $new_device) || ($current_device == $this_device) || ($new_device == $this_device))
|
||||
$resync_needed = true;
|
||||
if (file_exists($fpath)) {
|
||||
$current_device = file_get_contents($fpath);
|
||||
$current_device = trim($current_device, " \t\n");
|
||||
$new_device = get_failover_interface($ovpn_settings['interface']);
|
||||
if (isset($config['interfaces'][$interface])) {
|
||||
$this_device = $config['interfaces'][$interface]['if'];
|
||||
if (($current_device == $new_device) || ($current_device != $this_device) || ($new_device != $this_device))
|
||||
$resync_needed = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($resync_needed) {
|
||||
if ($resync_needed == true) {
|
||||
log_error("OpenVPN: Resync " . $mode_id . " " . $ovpn_settings['description']);
|
||||
openvpn_resync($mode, $ovpn_settings);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user