aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config/servicewatchdog/services_servicewatchdog.php175
-rw-r--r--config/servicewatchdog/services_servicewatchdog_add.php4
-rw-r--r--config/servicewatchdog/servicewatchdog.inc25
-rw-r--r--config/servicewatchdog/servicewatchdog.xml2
-rw-r--r--config/servicewatchdog/servicewatchdog_cron.php3
-rw-r--r--config/systempatches/patches.inc23
-rw-r--r--config/systempatches/system_patches.php247
-rw-r--r--config/systempatches/system_patches_edit.php28
-rw-r--r--config/systempatches/systempatches.xml15
-rw-r--r--pkg_config.10.xml4
10 files changed, 298 insertions, 228 deletions
diff --git a/config/servicewatchdog/services_servicewatchdog.php b/config/servicewatchdog/services_servicewatchdog.php
index bd4d4442..6c91b98e 100644
--- a/config/servicewatchdog/services_servicewatchdog.php
+++ b/config/servicewatchdog/services_servicewatchdog.php
@@ -41,14 +41,16 @@ require_once("functions.inc");
require_once("service-utils.inc");
require_once("servicewatchdog.inc");
-if (!is_array($config['installedpackages']['servicewatchdog']['item']))
+if (!is_array($config['installedpackages']['servicewatchdog']['item'])) {
$config['installedpackages']['servicewatchdog']['item'] = array();
+}
$a_pwservices = &$config['installedpackages']['servicewatchdog']['item'];
/* if a custom message has been passed along, lets process it */
-if ($_GET['savemsg'])
+if ($_GET['savemsg']) {
$savemsg = $_GET['savemsg'];
+}
if ($_GET['act'] == "del") {
if ($a_pwservices[$_GET['id']]) {
@@ -65,13 +67,15 @@ if (isset($_POST['Update'])) {
if (is_array($_POST['notifies']) && count($_POST['notifies'])) {
/* Check each service and set the notify flag only for those chosen, remove those that are unset. */
foreach ($a_pwservices as $idx => $thisservice) {
- if (!is_array($thisservice))
+ if (!is_array($thisservice)) {
continue;
+ }
if (in_array($idx, $_POST['notifies'])) {
$a_pwservices[$idx]['notify'] = true;
} else {
- if (isset($a_pwservices[$idx]['notify']))
+ if (isset($a_pwservices[$idx]['notify'])) {
unset($a_pwservices[$idx]['notify']);
+ }
}
}
} else { /* No notifies selected, remove them all. */
@@ -111,26 +115,31 @@ if (isset($_POST['del_x'])) {
/* copy all services < $movebtn and not selected */
for ($i = 0; $i < $movebtn; $i++) {
- if (!in_array($i, $_POST['pwservices']))
+ if (!in_array($i, $_POST['pwservices'])) {
$a_pwservices_new[] = $a_pwservices[$i];
+ }
}
/* copy all selected services */
for ($i = 0; $i < count($a_pwservices); $i++) {
- if ($i == $movebtn)
+ if ($i == $movebtn) {
continue;
- if (in_array($i, $_POST['pwservices']))
+ }
+ if (in_array($i, $_POST['pwservices'])) {
$a_pwservices_new[] = $a_pwservices[$i];
+ }
}
/* copy $movebtn service */
- if ($movebtn < count($a_pwservices))
+ if ($movebtn < count($a_pwservices)) {
$a_pwservices_new[] = $a_pwservices[$movebtn];
+ }
/* copy all services > $movebtn and not selected */
for ($i = $movebtn+1; $i < count($a_pwservices); $i++) {
- if (!in_array($i, $_POST['pwservices']))
+ if (!in_array($i, $_POST['pwservices'])) {
$a_pwservices_new[] = $a_pwservices[$i];
+ }
}
$a_pwservices = $a_pwservices_new;
servicewatchdog_cron_job();
@@ -141,7 +150,7 @@ if (isset($_POST['del_x'])) {
}
$closehead = false;
-$pgtitle = array(gettext("Services"),gettext("Service Watchdog"));
+$pgtitle = array(gettext("Services"), gettext("Service Watchdog"));
include("head.inc");
?>
@@ -160,83 +169,99 @@ include("head.inc");
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="services to monitor">
<tr><td><div id="mainarea">
<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="main area">
-<tr><td colspan="8" align="center">
-<?php echo gettext("This page allows you to select services to be monitored so that they may be automatically restarted if they crash or are stopped."); ?>
-<br/><br/>
-</td></tr>
-<tr id="frheader">
-<td width="5%" class="list">&nbsp;</td>
-<td width="5%" class="listhdrr">Notify</td>
-<td width="30%" class="listhdrr"><?=gettext("Service Name");?></td>
-<td width="60%" class="listhdrr"><?=gettext("Description");?></td>
-<td width="5%" class="list">
-<table border="0" cellspacing="0" cellpadding="1" summary="buttons">
- <tr><td width="17">
- <?php if (count($a_pwservices) == 0): ?>
- <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x_d.gif" width="17" height="17" title="<?=gettext("delete selected services");?>" border="0" alt="delete" />
- <?php else: ?>
- <input name="del" type="image" src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" title="<?=gettext("delete selected services"); ?>" onclick="return confirm('<?=gettext("Do you really want to delete the selected services?");?>')" />
- <?php endif; ?>
- </td>
- <td><a href="services_servicewatchdog_add.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" title="<?=gettext("add new service"); ?>" alt="add" /></a></td>
+ <tr>
+ <td colspan="8" align="center">
+ <?php echo gettext("This page allows you to select services to be monitored so that they may be automatically restarted if they crash or are stopped."); ?>
+ <br/><br/>
+ </td>
+ </tr>
+ <tr id="frheader">
+ <td width="5%" class="list">&nbsp;</td>
+ <td width="5%" class="listhdrr">Notify</td>
+ <td width="30%" class="listhdrr"><?=gettext("Service Name");?></td>
+ <td width="60%" class="listhdrr"><?=gettext("Description");?></td>
+ <td width="5%" class="list">
+ <table border="0" cellspacing="0" cellpadding="1" summary="buttons">
+ <tr>
+ <td width="17">
+ <?php if (count($a_pwservices) == 0): ?>
+ <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x_d.gif" width="17" height="17" title="<?=gettext("delete selected services");?>" border="0" alt="delete" />
+ <?php else: ?>
+ <input name="del" type="image" src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" title="<?=gettext("delete selected services"); ?>" onclick="return confirm('<?=gettext("Do you really want to delete the selected services?");?>')" />
+ <?php endif; ?>
+ </td>
+ <td><a href="services_servicewatchdog_add.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" title="<?=gettext("add new service"); ?>" alt="add" /></a></td>
+ </tr>
+ </table>
+ </td>
</tr>
-</table>
-</td>
-</tr>
<?php
$nservices = $i = 0;
foreach ($a_pwservices as $thisservice):
?>
<tr valign="top" id="fr<?=$nservices;?>">
- <td class="listt"><input type="checkbox" id="frc<?=$nservices;?>" name="pwservices[]" value="<?=$i;?>" onClick="fr_bgcolor('<?=$nservices;?>')" style="margin: 0; padding: 0; width: 15px; height: 15px;" /></td>
- <td class="listlr"><input type="checkbox" id="notify<?=$nservices;?>" name="notifies[]" value="<?=$i;?>" style="margin: 0; padding: 0; width: 15px; height: 15px;" <?PHP if (isset($thisservice['notify'])) echo 'checked="CHECKED"';?>/></td>
- <td class="listr" onclick="fr_toggle(<?=$nservices;?>)" id="frd<?=$nservices;?>" ondblclick="document.location='services_servicewatchdog_add.php?id=<?=$nservices;?>';">
- <?=$thisservice['name'];?>
- </td>
- <td class="listr" onclick="fr_toggle(<?=$nservices;?>)" id="frd<?=$nservices;?>" ondblclick="document.location='services_servicewatchdog_add.php?id=<?=$nservices;?>';">
- <?=$thisservice['description'];?>
- </td>
- <td valign="middle" class="list" nowrap>
- <table border="0" cellspacing="0" cellpadding="1" summary="add">
- <tr>
- <td><input onmouseover="fr_insline(<?=$nservices;?>, true)" onmouseout="fr_insline(<?=$nservices;?>, false)" name="move_<?=$i;?>" src="/themes/<?= $g['theme']; ?>/images/icons/icon_left.gif" title="<?=gettext("move selected services before this service");?>" height="17" type="image" width="17" border="0" /></td>
- <td align="center" valign="middle"><a href="services_servicewatchdog.php?act=del&amp;id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this service?");?>')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" title="<?=gettext("delete service");?>" alt="delete" /></a></td>
- </tr>
- </table>
- </td></tr>
-<?php $i++; $nservices++; endforeach; ?>
- <tr>
- <td class="list" colspan="4"></td>
- <td class="list" valign="middle" nowrap>
- <table border="0" cellspacing="0" cellpadding="1" summary="add">
+ <td class="listt"><input type="checkbox" id="frc<?=$nservices;?>" name="pwservices[]" value="<?=$i;?>" onClick="fr_bgcolor('<?=$nservices;?>')" style="margin: 0; padding: 0; width: 15px; height: 15px;" /></td>
+ <td class="listlr"><input type="checkbox" id="notify<?=$nservices;?>" name="notifies[]" value="<?=$i;?>" style="margin: 0; padding: 0; width: 15px; height: 15px;" <?PHP if (isset($thisservice['notify'])) echo 'checked="CHECKED"';?>/></td>
+ <td class="listr" onclick="fr_toggle(<?=$nservices;?>)" id="frd<?=$nservices;?>" ondblclick="document.location='services_servicewatchdog_add.php?id=<?=$nservices;?>';">
+ <?=$thisservice['name'];?>
+ </td>
+ <td class="listr" onclick="fr_toggle(<?=$nservices;?>)" id="frd<?=$nservices;?>" ondblclick="document.location='services_servicewatchdog_add.php?id=<?=$nservices;?>';">
+ <?=$thisservice['description'];?>
+ </td>
+ <td valign="middle" class="list" nowrap>
+ <table border="0" cellspacing="0" cellpadding="1" summary="add">
+ <tr>
+ <td><input onmouseover="fr_insline(<?=$nservices;?>, true)" onmouseout="fr_insline(<?=$nservices;?>, false)" name="move_<?=$i;?>" src="/themes/<?= $g['theme']; ?>/images/icons/icon_left.gif" title="<?=gettext("move selected services before this service");?>" height="17" type="image" width="17" border="0" /></td>
+ <td align="center" valign="middle"><a href="services_servicewatchdog.php?act=del&amp;id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this service?");?>')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" title="<?=gettext("delete service");?>" alt="delete" /></a></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+<?php
+ $i++;
+ $nservices++;
+endforeach;
+?>
<tr>
- <td><?php if ($nservices == 0): ?><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_left_d.gif" width="17" height="17" title="<?=gettext("move selected services to end"); ?>" border="0" alt="move" /><?php else: ?><input name="move_<?=$i;?>" type="image" src="/themes/<?= $g['theme']; ?>/images/icons/icon_left.gif" width="17" height="17" title="<?=gettext("move selected services to end");?>" border="0" alt="move" /><?php endif; ?></td>
+ <td class="list" colspan="4"></td>
+ <td class="list" valign="middle" nowrap>
+ <table border="0" cellspacing="0" cellpadding="1" summary="add">
+ <tr>
+ <td><?php if ($nservices == 0): ?><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_left_d.gif" width="17" height="17" title="<?=gettext("move selected services to end"); ?>" border="0" alt="move" /><?php else: ?><input name="move_<?=$i;?>" type="image" src="/themes/<?= $g['theme']; ?>/images/icons/icon_left.gif" width="17" height="17" title="<?=gettext("move selected services to end");?>" border="0" alt="move" /><?php endif; ?></td>
+ </tr>
+ <tr>
+ <td width="17">
+ <?php if (count($a_pwservices) == 0): ?>
+ <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x_d.gif" width="17" height="17" title="<?=gettext("delete selected services");?>" border="0" alt="delete" />
+ <?php else: ?>
+ <input name="del" type="image" src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" title="<?=gettext("delete selected services"); ?>" onclick="return confirm('<?=gettext("Do you really want to delete the selected services?");?>')" />
+ <?php endif; ?>
+ </td>
+ <td><a href="services_servicewatchdog_add.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" title="<?=gettext("add new service"); ?>" alt="add" /></a></td>
+ </tr>
+ </table>
+ </td>
</tr>
<tr>
- <td width="17">
- <?php if (count($a_pwservices) == 0): ?>
- <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x_d.gif" width="17" height="17" title="<?=gettext("delete selected services");?>" border="0" alt="delete" />
- <?php else: ?>
- <input name="del" type="image" src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" title="<?=gettext("delete selected services"); ?>" onclick="return confirm('<?=gettext("Do you really want to delete the selected services?");?>')" />
- <?php endif; ?>
- </td>
- <td><a href="services_servicewatchdog_add.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" title="<?=gettext("add new service"); ?>" alt="add" /></a></td>
+ <td></td>
+ <td colspan="4">
+ <?php echo gettext("Check Notify next to services to perform an e-mail notification when the service is restarted. Configure e-mail notifications to receive the alerts."); ?>
+ <br/>
+ <input name="Update" type="submit" class="formbtn" value="<?=gettext("Update Notification Settings"); ?>" />
+ <br/>
+ <br/>
+ </td>
+ <td></td>
</tr>
- </table>
- </td>
+ <tr>
+ <td></td>
+ <td colspan="4">
+ <?php echo gettext("Click to select a service and use the arrows to re-order them in the list. Higher services are checked first."); ?>
+ </td>
+ <td></td>
</tr>
- <tr><td></td><td colspan="4">
- <?php echo gettext("Check Notify next to services to perform an e-mail notification when the service is restarted. Configure e-mail notifications to receive the alerts."); ?>
- <br/>
- <input name="Update" type="submit" class="formbtn" value="<?=gettext("Update Notification Settings"); ?>" />
- <br/>
- <br/>
- </td><td></td></tr>
- <tr><td></td><td colspan="4">
- <?php echo gettext("Click to select a service and use the arrows to re-order them in the list. Higher services are checked first."); ?>
- </td><td></td></tr>
- </table>
+</table>
</div></td></tr>
</table>
</form>
diff --git a/config/servicewatchdog/services_servicewatchdog_add.php b/config/servicewatchdog/services_servicewatchdog_add.php
index 11e5e284..10f24797 100644
--- a/config/servicewatchdog/services_servicewatchdog_add.php
+++ b/config/servicewatchdog/services_servicewatchdog_add.php
@@ -55,7 +55,7 @@ unset($input_errors);
if ($_POST) {
if (!is_numeric($_POST['svcid']))
-
+ return;
if (!isset($system_services[$_POST['svcid']])) {
$input_errors[] = gettext("The supplied service appears to be invalid.");
@@ -72,7 +72,7 @@ if ($_POST) {
}
$closehead = false;
-$pgtitle = array(gettext("Services"),gettext("servicewatchdog"), gettext("Add"));
+$pgtitle = array(gettext("Services"), gettext("servicewatchdog"), gettext("Add"));
include("head.inc");
?>
diff --git a/config/servicewatchdog/servicewatchdog.inc b/config/servicewatchdog/servicewatchdog.inc
index 5b638836..817b92e0 100644
--- a/config/servicewatchdog/servicewatchdog.inc
+++ b/config/servicewatchdog/servicewatchdog.inc
@@ -7,23 +7,27 @@ require_once("notices.inc");
function servicewatchdog_service_matches($svc1, $svc2) {
/* If the arrays are equal, it must be the same service. */
- if ($svc1 == $svc2)
+ if ($svc1 == $svc2) {
return true;
+ }
/* If the names are different, they must not be the same. */
- if ($svc1['name'] != $svc2['name'])
+ if ($svc1['name'] != $svc2['name']) {
return false;
+ }
switch ($svc1['name']) {
case "openvpn":
- if (($svc1['mode'] == $svc2['mode']) && ($svc1['vpnid'] == $svc2['vpnid']))
+ if (($svc1['mode'] == $svc2['mode']) && ($svc1['vpnid'] == $svc2['vpnid'])) {
return true;
- else
+ } else {
return false;
+ }
break;
case "captiveportal":
- if ($svc1['zone'] == $svc2['zone'])
+ if ($svc1['zone'] == $svc2['zone']) {
return true;
- else
+ } else {
return false;
+ }
break;
default:
/* Other services must be the same if the name matches. */
@@ -39,12 +43,14 @@ function servicewatchdog_is_service_watched($svc) {
$a_pwservices = &$config['installedpackages']['servicewatchdog']['item'];
$blacklisted_services = array("cron");
- if (empty($svc['name']) || in_array($svc['name'], $blacklisted_services))
+ 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))
+ if (servicewatchdog_service_matches($svc, $a_svc)) {
return true;
+ }
}
return false;
}
@@ -77,8 +83,9 @@ function servicewatchdog_check_services() {
$descr = strlen($svc['description']) > 50 ? substr($svc['description'], 0, 50) . "..." : $svc['description'];
$error_message = "Service Watchdog detected service {$svc['name']} stopped. Restarting {$svc['name']} ({$descr})";
log_error($error_message);
- if (isset($svc['notify']))
+ if (isset($svc['notify'])) {
notify_via_smtp($error_message);
+ }
service_control_start($svc['name'], $svc);
}
}
diff --git a/config/servicewatchdog/servicewatchdog.xml b/config/servicewatchdog/servicewatchdog.xml
index 685ba997..5a1aebbb 100644
--- a/config/servicewatchdog/servicewatchdog.xml
+++ b/config/servicewatchdog/servicewatchdog.xml
@@ -40,7 +40,7 @@
<requirements>None</requirements>
<faq>Monitors for stopped services and restarts them.</faq>
<name>Service Watchdog</name>
- <version>1.6</version>
+ <version>1.7</version>
<title>Services: Service Watchdog</title>
<include_file>/usr/local/pkg/servicewatchdog.inc</include_file>
<menu>
diff --git a/config/servicewatchdog/servicewatchdog_cron.php b/config/servicewatchdog/servicewatchdog_cron.php
index 004afd97..9979917e 100644
--- a/config/servicewatchdog/servicewatchdog_cron.php
+++ b/config/servicewatchdog/servicewatchdog_cron.php
@@ -6,8 +6,9 @@ require_once("servicewatchdog.inc");
global $g;
/* Do nothing at bootup. */
-if ($g['booting'] || file_exists("{$g['varrun_path']}/booting"))
+if ($g['booting'] || file_exists("{$g['varrun_path']}/booting")) {
return;
+}
servicewatchdog_check_services();
?> \ No newline at end of file
diff --git a/config/systempatches/patches.inc b/config/systempatches/patches.inc
index 60c9a391..f47324c4 100644
--- a/config/systempatches/patches.inc
+++ b/config/systempatches/patches.inc
@@ -55,10 +55,11 @@ function patch_commit($patch, $action, $test=false, $fulldetail=false) {
$full_patch_command = "{$patch_cmd} --directory={$directory} {$force} {$pathstrip} {$filename} {$check} {$direction} {$whitespace}";
conf_mount_rw();
patch_write($patch);
- if (!$fulldetail)
+ if (!$fulldetail) {
$output = (mwexec($full_patch_command, true) == 0);
- else
+ } else {
$output = $full_patch_command . "\n\n" . shell_exec($full_patch_command . ' 2>&1');
+ }
patch_erase($patch);
conf_mount_ro();
return $output;
@@ -158,8 +159,9 @@ function bootup_apply_patches() {
foreach ($a_patches as $patch) {
/* Skip the patch if it should not be automatically applied. */
- if (!isset($patch['autoapply']))
+ if (!isset($patch['autoapply'])) {
continue;
+ }
/* If the patch can be reverted it is already applied, so skip it. */
if (!patch_test_revert($patch)) {
/* Only attempt to apply if it can be applied. */
@@ -173,12 +175,15 @@ function bootup_apply_patches() {
function patch_add_shellcmd() {
global $config;
$a_earlyshellcmd = &$config['system']['earlyshellcmd'];
- if (!is_array($a_earlyshellcmd))
+ if (!is_array($a_earlyshellcmd)) {
$a_earlyshellcmd = array();
+ }
$found = false;
- foreach ($a_earlyshellcmd as $idx => $cmd)
- if (stristr($cmd, "apply_patches.php"))
+ foreach ($a_earlyshellcmd as $idx => $cmd) {
+ if (stristr($cmd, "apply_patches.php")) {
$found = true;
+ }
+ }
if (!$found) {
$a_earlyshellcmd[] = "/usr/local/bin/php -f /usr/local/bin/apply_patches.php";
write_config("System Patches package added a shellcmd");
@@ -188,8 +193,9 @@ function patch_add_shellcmd() {
function patch_remove_shellcmd() {
global $config;
$a_earlyshellcmd = &$config['system']['earlyshellcmd'];
- if (!is_array($a_earlyshellcmd))
+ if (!is_array($a_earlyshellcmd)) {
$a_earlyshellcmd = array();
+ }
$removed = false;
foreach ($a_earlyshellcmd as $idx => $cmd) {
if (stristr($cmd, "apply_patches.php")) {
@@ -197,8 +203,9 @@ function patch_remove_shellcmd() {
$removed = true;
}
}
- if ($removed)
+ if ($removed) {
write_config("System Patches package removed a shellcmd");
+ }
}
?>
diff --git a/config/systempatches/system_patches.php b/config/systempatches/system_patches.php
index 43c8c22b..feeee07e 100644
--- a/config/systempatches/system_patches.php
+++ b/config/systempatches/system_patches.php
@@ -41,14 +41,16 @@ require_once("functions.inc");
require_once("itemid.inc");
require_once("patches.inc");
-if (!is_array($config['installedpackages']['patches']['item']))
+if (!is_array($config['installedpackages']['patches']['item'])) {
$config['installedpackages']['patches']['item'] = array();
+}
$a_patches = &$config['installedpackages']['patches']['item'];
/* if a custom message has been passed along, lets process it */
-if ($_GET['savemsg'])
+if ($_GET['savemsg']) {
$savemsg = $_GET['savemsg'];
+}
if ($_POST) {
$pconfig = $_POST;
@@ -116,26 +118,31 @@ if (isset($_POST['del_x'])) {
/* copy all patches < $movebtn and not selected */
for ($i = 0; $i < $movebtn; $i++) {
- if (!in_array($i, $_POST['patch']))
+ if (!in_array($i, $_POST['patch'])) {
$a_patches_new[] = $a_patches[$i];
+ }
}
/* copy all selected patches */
for ($i = 0; $i < count($a_patches); $i++) {
- if ($i == $movebtn)
+ if ($i == $movebtn) {
continue;
- if (in_array($i, $_POST['patch']))
+ }
+ if (in_array($i, $_POST['patch'])) {
$a_patches_new[] = $a_patches[$i];
+ }
}
/* copy $movebtn patch */
- if ($movebtn < count($a_patches))
+ if ($movebtn < count($a_patches)) {
$a_patches_new[] = $a_patches[$movebtn];
+ }
/* copy all patches > $movebtn and not selected */
for ($i = $movebtn+1; $i < count($a_patches); $i++) {
- if (!in_array($i, $_POST['patch']))
+ if (!in_array($i, $_POST['patch'])) {
$a_patches_new[] = $a_patches[$i];
+ }
}
$a_patches = $a_patches_new;
write_config();
@@ -164,41 +171,47 @@ include("head.inc");
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="system patches">
<tr><td><div id="mainarea">
<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="main area">
-<tr><td colspan="8" align="center">
-<?php echo gettext("This page allows you to add patches, either from the official code repository or ones pasted in from e-mail or other sources."); ?>
-<br/><br/>
-<strong><?php echo gettext("Use with caution!"); ?></strong>
-<br/><br/>
+ <tr>
+ <td colspan="8" align="center">
+ <?php echo gettext("This page allows you to add patches, either from the official code repository or ones pasted in from e-mail or other sources."); ?>
+ <br/><br/>
+ <strong><?php echo gettext("Use with caution!"); ?></strong>
+ <br/><br/>
<?php if (!empty($fulldetail)): ?>
-</td></tr>
-<tr><td></td><td colspan="7" align="left">Output of full patch <?php echo $_GET['fulltest']; ?> test:
-<pre><?php echo $fulldetail; ?></pre>
-<a href="system_patches.php">Close</a><br/><br/>
+ </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td colspan="7" align="left">Output of full patch <?php echo $_GET['fulltest']; ?> test:
+ <pre><?php echo $fulldetail; ?></pre>
+ <a href="system_patches.php">Close</a><br/><br/>
<?php endif; ?>
-</td></tr>
-<tr id="frheader">
-<td width="5%" class="list">&nbsp;</td>
-<td width="5%" class="listhdrr"><?=gettext("Description");?></td>
-<td width="60%" class="listhdrr"><?=gettext("URL/ID");?></td>
-<td width="5%" class="listhdrr"><?=gettext("Fetch");?></td>
-<td width="5%" class="listhdrr"><?=gettext("Test");?></td>
-<td width="5%" class="listhdrr"><?=gettext("Apply");?></td>
-<td width="5%" class="listhdr"><?=gettext("Revert");?></td>
-<td width="5%" class="listhdr"><?=gettext("Auto Apply");?></td>
-<td width="5%" class="list">
-<table border="0" cellspacing="0" cellpadding="1" summary="buttons">
- <tr><td width="17">
- <?php if (count($a_patches) == 0): ?>
- <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x_d.gif" width="17" height="17" title="<?=gettext("delete selected patches");?>" border="0" alt="delete" />
- <?php else: ?>
- <input name="del" type="image" src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" title="<?=gettext("delete selected patches"); ?>" onclick="return confirm('<?=gettext("Do you really want to delete the selected patches?");?>')" />
- <?php endif; ?>
- </td>
- <td><a href="system_patches_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" title="<?=gettext("add new patch"); ?>" alt="add" /></a></td>
+ </td>
+ </tr>
+ <tr id="frheader">
+ <td width="5%" class="list">&nbsp;</td>
+ <td width="5%" class="listhdrr"><?=gettext("Description");?></td>
+ <td width="60%" class="listhdrr"><?=gettext("URL/ID");?></td>
+ <td width="5%" class="listhdrr"><?=gettext("Fetch");?></td>
+ <td width="5%" class="listhdrr"><?=gettext("Test");?></td>
+ <td width="5%" class="listhdrr"><?=gettext("Apply");?></td>
+ <td width="5%" class="listhdr"><?=gettext("Revert");?></td>
+ <td width="5%" class="listhdr"><?=gettext("Auto Apply");?></td>
+ <td width="5%" class="list">
+ <table border="0" cellspacing="0" cellpadding="1" summary="buttons">
+ <tr>
+ <td width="17">
+ <?php if (count($a_patches) == 0): ?>
+ <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x_d.gif" width="17" height="17" title="<?=gettext("delete selected patches");?>" border="0" alt="delete" />
+ <?php else: ?>
+ <input name="del" type="image" src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" title="<?=gettext("delete selected patches"); ?>" onclick="return confirm('<?=gettext("Do you really want to delete the selected patches?");?>')" />
+ <?php endif; ?>
+ </td>
+ <td><a href="system_patches_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" title="<?=gettext("add new patch"); ?>" alt="add" /></a></td>
+ </tr>
+ </table>
+ </td>
</tr>
-</table>
-</td>
-</tr>
<?php
$npatches = $i = 0;
@@ -208,83 +221,93 @@ foreach ($a_patches as $thispatch):
?>
<tr valign="top" id="fr<?=$npatches;?>">
- <td class="listt"><input type="checkbox" id="frc<?=$npatches;?>" name="patch[]" value="<?=$i;?>" onClick="fr_bgcolor('<?=$npatches;?>')" style="margin: 0; padding: 0; width: 15px; height: 15px;" /></td>
- <td class="listlr" onclick="fr_toggle(<?=$npatches;?>)" id="frd<?=$npatches;?>" ondblclick="document.location='system_patches_edit.php?id=<?=$npatches;?>';">
- <?=$thispatch['descr'];?>
- </td>
- <td class="listr" onclick="fr_toggle(<?=$npatches;?>)" id="frd<?=$npatches;?>" ondblclick="document.location='system_patches_edit.php?id=<?=$npatches;?>';">
-
- <?php
- if (!empty($thispatch['location']))
- echo $thispatch['location'];
- elseif (!empty($thispatch['patch']))
- echo gettext("Saved Patch");
- ?>
- </td>
- <td class="listr" onclick="fr_toggle(<?=$npatches;?>)" id="frd<?=$npatches;?>" ondblclick="document.location='system_patches_edit.php?id=<?=$npatches;?>';">
- <?php if (empty($thispatch['patch'])): ?>
- <a href="system_patches.php?id=<?=$i;?>&amp;act=fetch"><?php echo gettext("Fetch"); ?></a>
- <?php elseif (!empty($thispatch['location'])): ?>
- <a href="system_patches.php?id=<?=$i;?>&amp;act=fetch"><?php echo gettext("Re-Fetch"); ?></a>
- <?php endif; ?>
- </td>
- <td class="listr" onclick="fr_toggle(<?=$npatches;?>)" id="frd<?=$npatches;?>" ondblclick="document.location='system_patches_edit.php?id=<?=$npatches;?>';">
- <?php if (!empty($thispatch['patch'])): ?>
- <a href="system_patches.php?id=<?=$i;?>&amp;act=test"><?php echo gettext("Test"); ?></a>
- <?php endif; ?>
- </td>
- <td class="listr" onclick="fr_toggle(<?=$npatches;?>)" id="frd<?=$npatches;?>" ondblclick="document.location='system_patches_edit.php?id=<?=$npatches;?>';">
- <?php if ($can_apply): ?>
- <a href="system_patches.php?id=<?=$i;?>&amp;act=apply"><?php echo gettext("Apply"); ?></a>
- <?php endif; ?>
- </td>
- <td class="listr" onclick="fr_toggle(<?=$npatches;?>)" id="frd<?=$npatches;?>" ondblclick="document.location='system_patches_edit.php?id=<?=$npatches;?>';">
- <?php if ($can_revert): ?>
- <a href="system_patches.php?id=<?=$i;?>&amp;act=revert"><?php echo gettext("Revert"); ?></a>
- <?php endif; ?>
- </td>
- <td class="listr" onclick="fr_toggle(<?=$npatches;?>)" id="frd<?=$npatches;?>" ondblclick="document.location='system_patches_edit.php?id=<?=$npatches;?>';">
- <?= isset($thispatch['autoapply']) ? "Yes" : "No" ?>
- </td>
- <td valign="middle" class="list" nowrap>
- <table border="0" cellspacing="0" cellpadding="1" summary="edit">
- <tr>
- <td><input onmouseover="fr_insline(<?=$npatches;?>, true)" onmouseout="fr_insline(<?=$npatches;?>, false)" name="move_<?=$i;?>" src="/themes/<?= $g['theme']; ?>/images/icons/icon_left.gif" title="<?=gettext("move selected patches before this patch");?>" height="17" type="image" width="17" border="0" /></td>
- <td><a href="system_patches_edit.php?id=<?=$i;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0" title="<?=gettext("edit patch"); ?>" alt="edit" /></a></td>
- </tr>
- <tr>
- <td align="center" valign="middle"><a href="system_patches.php?act=del&amp;id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this patch?");?>')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" title="<?=gettext("delete patch");?>" alt="delete" /></a></td>
- <td></td>
- </tr>
- </table>
- </td></tr>
-<?php $i++; $npatches++; endforeach; ?>
- <tr>
- <td class="list" colspan="8"></td>
- <td class="list" valign="middle" nowrap>
- <table border="0" cellspacing="0" cellpadding="1" summary="edit">
- <tr>
- <td><?php if ($npatches == 0): ?><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_left_d.gif" width="17" height="17" title="<?=gettext("move selected patches to end"); ?>" border="0" alt="move" /><?php else: ?><input name="move_<?=$i;?>" type="image" src="/themes/<?= $g['theme']; ?>/images/icons/icon_left.gif" width="17" height="17" title="<?=gettext("move selected patches to end");?>" border="0" alt="move" /><?php endif; ?></td>
+ <td class="listt"><input type="checkbox" id="frc<?=$npatches;?>" name="patch[]" value="<?=$i;?>" onClick="fr_bgcolor('<?=$npatches;?>')" style="margin: 0; padding: 0; width: 15px; height: 15px;" /></td>
+ <td class="listlr" onclick="fr_toggle(<?=$npatches;?>)" id="frd<?=$npatches;?>" ondblclick="document.location='system_patches_edit.php?id=<?=$npatches;?>';">
+ <?=$thispatch['descr'];?>
+ </td>
+ <td class="listr" onclick="fr_toggle(<?=$npatches;?>)" id="frd<?=$npatches;?>" ondblclick="document.location='system_patches_edit.php?id=<?=$npatches;?>';">
+
+ <?php
+ if (!empty($thispatch['location'])) {
+ echo $thispatch['location'];
+ } elseif (!empty($thispatch['patch'])) {
+ echo gettext("Saved Patch");
+ }
+ ?>
+ </td>
+ <td class="listr" onclick="fr_toggle(<?=$npatches;?>)" id="frd<?=$npatches;?>" ondblclick="document.location='system_patches_edit.php?id=<?=$npatches;?>';">
+ <?php if (empty($thispatch['patch'])): ?>
+ <a href="system_patches.php?id=<?=$i;?>&amp;act=fetch"><?php echo gettext("Fetch"); ?></a>
+ <?php elseif (!empty($thispatch['location'])): ?>
+ <a href="system_patches.php?id=<?=$i;?>&amp;act=fetch"><?php echo gettext("Re-Fetch"); ?></a>
+ <?php endif; ?>
+ </td>
+ <td class="listr" onclick="fr_toggle(<?=$npatches;?>)" id="frd<?=$npatches;?>" ondblclick="document.location='system_patches_edit.php?id=<?=$npatches;?>';">
+ <?php if (!empty($thispatch['patch'])): ?>
+ <a href="system_patches.php?id=<?=$i;?>&amp;act=test"><?php echo gettext("Test"); ?></a>
+ <?php endif; ?>
+ </td>
+ <td class="listr" onclick="fr_toggle(<?=$npatches;?>)" id="frd<?=$npatches;?>" ondblclick="document.location='system_patches_edit.php?id=<?=$npatches;?>';">
+ <?php if ($can_apply): ?>
+ <a href="system_patches.php?id=<?=$i;?>&amp;act=apply"><?php echo gettext("Apply"); ?></a>
+ <?php endif; ?>
+ </td>
+ <td class="listr" onclick="fr_toggle(<?=$npatches;?>)" id="frd<?=$npatches;?>" ondblclick="document.location='system_patches_edit.php?id=<?=$npatches;?>';">
+ <?php if ($can_revert): ?>
+ <a href="system_patches.php?id=<?=$i;?>&amp;act=revert"><?php echo gettext("Revert"); ?></a>
+ <?php endif; ?>
+ </td>
+ <td class="listr" onclick="fr_toggle(<?=$npatches;?>)" id="frd<?=$npatches;?>" ondblclick="document.location='system_patches_edit.php?id=<?=$npatches;?>';">
+ <?= isset($thispatch['autoapply']) ? "Yes" : "No" ?>
+ </td>
+ <td valign="middle" class="list" nowrap>
+ <table border="0" cellspacing="0" cellpadding="1" summary="edit">
+ <tr>
+ <td><input onmouseover="fr_insline(<?=$npatches;?>, true)" onmouseout="fr_insline(<?=$npatches;?>, false)" name="move_<?=$i;?>" src="/themes/<?= $g['theme']; ?>/images/icons/icon_left.gif" title="<?=gettext("move selected patches before this patch");?>" height="17" type="image" width="17" border="0" /></td>
+ <td><a href="system_patches_edit.php?id=<?=$i;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0" title="<?=gettext("edit patch"); ?>" alt="edit" /></a></td>
+ </tr>
+ <tr>
+ <td align="center" valign="middle"><a href="system_patches.php?act=del&amp;id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this patch?");?>')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" title="<?=gettext("delete patch");?>" alt="delete" /></a></td>
+ <td></td>
+ </tr>
+ </table>
+ </td>
</tr>
+<?php
+ $i++;
+ $npatches++;
+endforeach;
+?>
<tr>
- <td width="17">
- <?php if (count($a_patches) == 0): ?>
- <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x_d.gif" width="17" height="17" title="<?=gettext("delete selected patches");?>" border="0" alt="delete" />
- <?php else: ?>
- <input name="del" type="image" src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" title="<?=gettext("delete selected patches"); ?>" onclick="return confirm('<?=gettext("Do you really want to delete the selected patches?");?>')" />
- <?php endif; ?>
- </td>
- <td><a href="system_patches_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" title="<?=gettext("add new patch"); ?>" alt="add" /></a></td>
+ <td class="list" colspan="8"></td>
+ <td class="list" valign="middle" nowrap>
+ <table border="0" cellspacing="0" cellpadding="1" summary="edit">
+ <tr>
+ <td><?php if ($npatches == 0): ?><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_left_d.gif" width="17" height="17" title="<?=gettext("move selected patches to end"); ?>" border="0" alt="move" /><?php else: ?><input name="move_<?=$i;?>" type="image" src="/themes/<?= $g['theme']; ?>/images/icons/icon_left.gif" width="17" height="17" title="<?=gettext("move selected patches to end");?>" border="0" alt="move" /><?php endif; ?></td>
+ </tr>
+ <tr>
+ <td width="17">
+ <?php if (count($a_patches) == 0): ?>
+ <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x_d.gif" width="17" height="17" title="<?=gettext("delete selected patches");?>" border="0" alt="delete" />
+ <?php else: ?>
+ <input name="del" type="image" src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" title="<?=gettext("delete selected patches"); ?>" onclick="return confirm('<?=gettext("Do you really want to delete the selected patches?");?>')" />
+ <?php endif; ?>
+ </td>
+ <td><a href="system_patches_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" title="<?=gettext("add new patch"); ?>" alt="add" /></a></td>
+ </tr>
+ </table>
+ </td>
</tr>
- </table>
- </td>
+ <tr>
+ <td></td>
+ <td colspan="6">
+ <?php echo gettext("NOTE: Each patch is tested, and the appropriate action is shown. If neither 'Apply' or 'Revert' shows up, the patch cannot be used (check the pathstrip and whitespace options)."); ?>
+ <br/><br/>
+ <?php echo gettext("Use the 'Test' link to see if a patch can be applied or reverted. You can reorder patches so that higher patches apply later than lower patches."); ?>
+ </td>
+ <td></td>
</tr>
- <tr><td></td><td colspan="6">
- <?php echo gettext("NOTE: Each patch is tested, and the appropriate action is shown. If neither 'Apply' or 'Revert' shows up, the patch cannot be used (check the pathstrip and whitespace options)."); ?>
- <br/><br/>
- <?php echo gettext("Use the 'Test' link to see if a patch can be applied or reverted. You can reorder patches so that higher patches apply later than lower patches."); ?>
- </td><td></td></tr>
- </table>
+</table>
</div></td></tr>
</table>
</form>
diff --git a/config/systempatches/system_patches_edit.php b/config/systempatches/system_patches_edit.php
index 3e63038e..9e1f7a49 100644
--- a/config/systempatches/system_patches_edit.php
+++ b/config/systempatches/system_patches_edit.php
@@ -46,8 +46,9 @@ if (!is_array($config['installedpackages']['patches']['item'])) {
$a_patches = &$config['installedpackages']['patches']['item'];
$id = $_GET['id'];
-if (isset($_POST['id']))
+if (isset($_POST['id'])) {
$id = $_POST['id'];
+}
if (isset($_GET['dup'])) {
$id = $_GET['dup'];
@@ -69,8 +70,9 @@ if (isset($id) && $a_patches[$id]) {
$pconfig['ignorewhitespace'] = true;
}
-if (isset($_GET['dup']))
+if (isset($_GET['dup'])) {
unset($id);
+}
unset($input_errors);
@@ -87,10 +89,11 @@ if ($_POST) {
}
$pf_version=substr(trim(file_get_contents("/etc/version")),0,3);
- if ($pf_version < 2.1)
+ if ($pf_version < 2.1) {
$input_errors = eval('do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); return $input_errors;');
- else
+ } else {
do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
+ }
if (!empty($_POST['location']) && !is_commit_id($_POST['location']) && !is_URL($_POST['location'])) {
$input_errors[] = gettext("The supplied commit ID/URL appears to be invalid.");
@@ -111,10 +114,11 @@ if ($_POST) {
/* Strip DOS style carriage returns from textarea input */
$thispatch['patch'] = base64_encode(str_replace("\r", "", $_POST['patch']));
}
- if (is_github_url($thispatch['location']) && ($_POST['pathstrip'] == 0))
+ if (is_github_url($thispatch['location']) && ($_POST['pathstrip'] == 0)) {
$thispatch['pathstrip'] = 1;
- else
+ } else {
$thispatch['pathstrip'] = $_POST['pathstrip'];
+ }
$thispatch['basedir'] = empty($_POST['basedir']) ? "/" : $_POST['basedir'];
$thispatch['ignorewhitespace'] = isset($_POST['ignorewhitespace']);
$thispatch['autoapply'] = isset($_POST['autoapply']);
@@ -125,18 +129,20 @@ if ($_POST) {
}
// Update the patch entry now
- if (isset($id) && $a_patches[$id])
+ if (isset($id) && $a_patches[$id]) {
$a_patches[$id] = $thispatch;
- else {
- if (is_numeric($after))
+ } else {
+ if (is_numeric($after)) {
array_splice($a_patches, $after+1, 0, array($thispatch));
- else
+ } else {
$a_patches[] = $thispatch;
+ }
}
write_config();
- if ($thispatch['autoapply'])
+ if ($thispatch['autoapply']) {
patch_add_shellcmd();
+ }
header("Location: system_patches.php");
return;
}
diff --git a/config/systempatches/systempatches.xml b/config/systempatches/systempatches.xml
index 3cc1354a..ad7f5953 100644
--- a/config/systempatches/systempatches.xml
+++ b/config/systempatches/systempatches.xml
@@ -10,17 +10,18 @@
part of pfSense (http://www.pfSense.com)
Copyright (C) 2012 Jim Pingle
All rights reserved.
+*/
/* ========================================================================== */
/*
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
@@ -32,7 +33,7 @@
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
- */
+*/
/* ========================================================================== */
]]>
</copyright>
@@ -40,7 +41,7 @@
<requirements>None</requirements>
<faq>Applies patches supplied by the user to the firewall.</faq>
<name>System Patches</name>
- <version>1.0.3</version>
+ <version>1.0.4</version>
<title>System: Patches</title>
<include_file>/usr/local/pkg/patches.inc</include_file>
<menu>
diff --git a/pkg_config.10.xml b/pkg_config.10.xml
index 3bd7efd0..08837da6 100644
--- a/pkg_config.10.xml
+++ b/pkg_config.10.xml
@@ -1352,7 +1352,7 @@
<internal_name>System_Patches</internal_name>
<descr>A package to apply and maintain custom system patches.</descr>
<maintainer>jimp@pfsense.org</maintainer>
- <version>1.0.3</version>
+ <version>1.0.4</version>
<category>System</category>
<status>RELEASE</status>
<config_file>https://packages.pfsense.org/packages/config/systempatches/systempatches.xml</config_file>
@@ -1588,7 +1588,7 @@
<internal_name>Service_Watchdog</internal_name>
<descr>Monitors for stopped services and restarts them.</descr>
<maintainer>jimp@pfsense.org</maintainer>
- <version>1.6</version>
+ <version>1.7</version>
<category>Services</category>
<status>Release</status>
<config_file>https://packages.pfsense.org/packages/config/servicewatchdog/servicewatchdog.xml</config_file>