aboutsummaryrefslogtreecommitdiffstats
path: root/config/servicewatchdog/servicewatchdog.inc
diff options
context:
space:
mode:
authorjim-p <jimp@pfsense.org>2013-08-29 10:17:39 -0400
committerjim-p <jimp@pfsense.org>2013-08-29 10:17:39 -0400
commit6f8bef0a95e943f35144b342f12013638dde27e3 (patch)
tree63bce4b579ae85a203b225891ee5f13303a89e53 /config/servicewatchdog/servicewatchdog.inc
parente3ffcea32677a506ecf142e427845ecae7451497 (diff)
downloadpfsense-packages-6f8bef0a95e943f35144b342f12013638dde27e3.tar.gz
pfsense-packages-6f8bef0a95e943f35144b342f12013638dde27e3.tar.bz2
pfsense-packages-6f8bef0a95e943f35144b342f12013638dde27e3.zip
Fixup service matching so that OpenVPN and CP instances aren't missing after one was added.
Diffstat (limited to 'config/servicewatchdog/servicewatchdog.inc')
-rw-r--r--config/servicewatchdog/servicewatchdog.inc44
1 files changed, 44 insertions, 0 deletions
diff --git a/config/servicewatchdog/servicewatchdog.inc b/config/servicewatchdog/servicewatchdog.inc
index 6e5f1f55..1bdb1ce9 100644
--- a/config/servicewatchdog/servicewatchdog.inc
+++ b/config/servicewatchdog/servicewatchdog.inc
@@ -4,6 +4,50 @@ require_once("services.inc");
require_once("service-utils.inc");
require_once("util.inc");
+function servicewatchdog_service_matches($svc1, $svc2) {
+ /* If the arrays are equal, it must be the same service. */
+ if ($svc1 == $svc2)
+ return true;
+ /* If the names are different, they must not be the same. */
+ if ($svc1['name'] != $svc2['name'])
+ return false;
+ switch ($svc1['name']) {
+ case "openvpn":
+ if (($svc1['mode'] == $svc2['mode']) && ($svc1['vpnid'] == $svc2['vpnid']))
+ return true;
+ else
+ return false;
+ break;
+ case "captiveportal":
+ if ($svc1['zone'] == $svc2['zone'])
+ return true;
+ else
+ return false;
+ break;
+ default:
+ /* Other services must be the same if the name matches. */
+ return true;
+ }
+}
+
+function servicewatchdog_is_service_watched($svc) {
+ global $config;
+ if (!is_array($config['installedpackages']['servicewatchdog']['item'])) {
+ $config['installedpackages']['servicewatchdog']['item'] = array();
+ }
+ $a_pwservices = &$config['installedpackages']['servicewatchdog']['item'];
+ $blacklisted_services = array("cron");
+
+ if (empty($svc['name']) || in_array($svc['name'], $blacklisted_services))
+ return true;
+
+ foreach ($a_pwservices as $a_svc) {
+ if (servicewatchdog_service_matches($svc, $a_svc))
+ return true;
+ }
+ return false;
+}
+
function servicewatchdog_cron_job() {
global $config;
if (!is_array($config['installedpackages']['servicewatchdog']['item'])) {