diff options
author | Matthew Grooms <mgrooms@pfsense.org> | 2008-09-08 16:06:41 +0000 |
---|---|---|
committer | Matthew Grooms <mgrooms@pfsense.org> | 2008-09-08 16:06:41 +0000 |
commit | 76369bfce7c8a1563aee1f085183e0d0693d248d (patch) | |
tree | a85c2d5558fb86a32bed214d0aece0a4b583493b /etc | |
parent | 035e4289f5e51029e6e62ab8ad6fcf05cb9dda37 (diff) | |
download | pfsense-76369bfce7c8a1563aee1f085183e0d0693d248d.zip pfsense-76369bfce7c8a1563aee1f085183e0d0693d248d.tar.gz |
Correct a bug where we attempt to kill an OpenVPN process even though its
pid file does not exist.
Diffstat (limited to 'etc')
-rw-r--r-- | etc/inc/openvpn.inc | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/etc/inc/openvpn.inc b/etc/inc/openvpn.inc index 51f9f85..ee2461b 100644 --- a/etc/inc/openvpn.inc +++ b/etc/inc/openvpn.inc @@ -482,17 +482,21 @@ function openvpn_restart($mode, & $settings) { $vpnid = $settings['vpnid']; $mode_id = $mode.$vpnid; - /* read the pid file */ + /* kill the process if running */ $pfile = $g['varrun_path']."/openvpn_{$mode_id}.pid"; - $pid = rtrim(file_get_contents($pfile)); - unlink($pfile); + if (file_exists($pfile)) { - /* send the process a term signal */ - posix_kill($pid, SIGTERM); + /* read the pid file */ + $pid = rtrim(file_get_contents($pfile)); + unlink($pfile); - /* wait until the process exits */ - while(posix_kill($pid, 0)) - usleep(250000); + /* send a term signal to the process */ + posix_kill($pid, SIGTERM); + + /* wait until the process exits */ + while(posix_kill($pid, 0)) + usleep(250000); + } if ($settings['disable']) return; @@ -515,13 +519,17 @@ function openvpn_delete($mode, & $settings) { else $devname = "ovpnc{$vpnid}"; - /* read the pid file */ + /* kill the process if running */ $pfile = "{$g['varrun_path']}/openvpn_{$mode_id}.pid"; - $pid = trim(file_get_contents($pfile)); - unlink($pfile); + if (file_exists($pfile)) { - /* send the process a term signal */ - posix_kill($pid, SIGTERM); + /* read the pid file */ + $pid = trim(file_get_contents($pfile)); + unlink($pfile); + + /* send a term signal to the process */ + posix_kill($pid, SIGTERM); + } /* remove the device from the openvpn group */ mwexec("/sbin/ifconfig {$devname} -group openvpn"); |