mirror of
https://github.com/pfsense/pfsense.git
synced 2025-10-26 11:38:35 +00:00
Correct a bug where we attempt to kill an OpenVPN process even though its
pid file does not exist.
This commit is contained in:
parent
035e4289f5
commit
76369bfce7
@ -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");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user