summaryrefslogtreecommitdiffstats
path: root/etc/rc.openvpn
diff options
context:
space:
mode:
authorErmal <eri@pfsense.org>2013-09-04 08:31:34 +0000
committerErmal <eri@pfsense.org>2013-09-04 08:31:43 +0000
commitf33dcc5c79c54af7daf91a81cfdd7f489e8cb67c (patch)
tree0b177b37740819eaa3d325a759921836986a0d51 /etc/rc.openvpn
parentdc8b4c4ec62837814c3ae07eda7813cdc76ef369 (diff)
downloadpfsense-f33dcc5c79c54af7daf91a81cfdd7f489e8cb67c.zip
pfsense-f33dcc5c79c54af7daf91a81cfdd7f489e8cb67c.tar.gz
Add safety belts to code in rc.openvpn to avoid php errors to leave stale locks around
Diffstat (limited to 'etc/rc.openvpn')
-rwxr-xr-xetc/rc.openvpn23
1 files changed, 13 insertions, 10 deletions
diff --git a/etc/rc.openvpn b/etc/rc.openvpn
index e30d130..4cabffe 100755
--- a/etc/rc.openvpn
+++ b/etc/rc.openvpn
@@ -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);
}
OpenPOWER on IntegriCloud