aboutsummaryrefslogtreecommitdiffstats
path: root/config/systempatches
diff options
context:
space:
mode:
Diffstat (limited to 'config/systempatches')
-rw-r--r--config/systempatches/apply_patches.php11
-rw-r--r--config/systempatches/patches.inc65
-rw-r--r--config/systempatches/system_patches.php8
-rw-r--r--config/systempatches/system_patches_edit.php6
-rw-r--r--config/systempatches/systempatches.xml14
5 files changed, 96 insertions, 8 deletions
diff --git a/config/systempatches/apply_patches.php b/config/systempatches/apply_patches.php
new file mode 100644
index 00000000..3ac0d671
--- /dev/null
+++ b/config/systempatches/apply_patches.php
@@ -0,0 +1,11 @@
+#!/usr/local/bin/php
+<?php
+require_once("config.inc");
+require_once("patches.inc");
+
+global $g, $config;
+
+echo "Applying patches...";
+bootup_apply_patches();
+echo "Done.\n";
+?> \ No newline at end of file
diff --git a/config/systempatches/patches.inc b/config/systempatches/patches.inc
index 89610565..0547f2cf 100644
--- a/config/systempatches/patches.inc
+++ b/config/systempatches/patches.inc
@@ -29,11 +29,19 @@
require_once("globals.inc");
require_once("util.inc");
-$git_root_url = "http://github.com/bsdperimeter/pfsense/commit/";
+$git_root_url = "http://github.com/pfsense/pfsense/commit/";
$patch_suffix = ".patch";
$patch_dir = "/var/patches";
$patch_cmd = "/usr/bin/patch";
+function patch_package_install() {
+ patch_add_shellcmd();
+}
+
+function patch_package_deinstall() {
+ patch_remove_shellcmd();
+}
+
function patch_commit($patch, $action, $test=false, $fulldetail=false) {
global $patch_dir, $patch_cmd, $patch_suffix;
$directory = empty($patch['basedir']) ? "/" : $patch['basedir'];
@@ -44,12 +52,14 @@ function patch_commit($patch, $action, $test=false, $fulldetail=false) {
$whitespace = isset($patch['ignorewhitespace']) ? "--ignore-whitespace" : "";
$pathstrip = '-p' . $patch['pathstrip'];
$full_patch_command = "{$patch_cmd} --directory={$directory} {$force} {$pathstrip} {$filename} {$check} {$direction} {$whitespace}";
+ conf_mount_rw();
patch_write($patch);
if (!$fulldetail)
$output = (mwexec($full_patch_command, true) == 0);
else
$output = $full_patch_command . "\n\n" . shell_exec($full_patch_command . ' 2>&1');
patch_erase($patch);
+ conf_mount_ro();
return $output;
}
@@ -139,4 +149,55 @@ function is_github_url($url) {
$urlbits = explode("/", $url);
return (substr($urlbits[2], -10) == "github.com");
}
-?> \ No newline at end of file
+
+function bootup_apply_patches() {
+ global $config;
+
+ $a_patches = &$config['installedpackages']['patches']['item'];
+
+ foreach ($a_patches as $patch) {
+ /* Skip the patch if it should not be automatically applied. */
+ 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. */
+ if (patch_test_apply($patch)) {
+ patch_apply($patch);
+ }
+ }
+ }
+}
+
+function patch_add_shellcmd() {
+ global $config;
+ $a_earlyshellcmd = &$config['system']['earlyshellcmd'];
+ if (!is_array($a_earlyshellcmd))
+ $a_earlyshellcmd = array();
+ $found = false;
+ 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");
+ }
+}
+
+function patch_remove_shellcmd() {
+ global $config;
+ $a_earlyshellcmd = &$config['system']['earlyshellcmd'];
+ if (!is_array($a_earlyshellcmd))
+ $a_earlyshellcmd = array();
+ $removed = false;
+ foreach ($a_earlyshellcmd as $idx => $cmd) {
+ if (stristr($cmd, "apply_patches.php")) {
+ unset($a_earlyshellcmd[$idx]);
+ $removed = true;
+ }
+ }
+ 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 1dd6470b..7fe860bd 100644
--- a/config/systempatches/system_patches.php
+++ b/config/systempatches/system_patches.php
@@ -179,11 +179,12 @@ include("head.inc");
<tr id="frheader">
<td width="5%" class="list">&nbsp;</td>
<td width="5%" class="listhdrr"><?=gettext("Description");?></td>
-<td width="65%" class="listhdrr"><?=gettext("URL/ID");?></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">
@@ -242,6 +243,9 @@ foreach ($a_patches as $thispatch):
<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>
@@ -256,7 +260,7 @@ foreach ($a_patches as $thispatch):
</td></tr>
<?php $i++; $npatches++; endforeach; ?>
<tr>
- <td class="list" colspan="7"></td>
+ <td class="list" colspan="8"></td>
<td class="list" valign="middle" nowrap>
<table border="0" cellspacing="0" cellpadding="1" summary="edit">
<tr>
diff --git a/config/systempatches/system_patches_edit.php b/config/systempatches/system_patches_edit.php
index 260a7300..5b30c9c5 100644
--- a/config/systempatches/system_patches_edit.php
+++ b/config/systempatches/system_patches_edit.php
@@ -127,6 +127,8 @@ if ($_POST) {
}
write_config();
+ if ($thispatch['autoapply'])
+ patch_add_shellcmd();
header("Location: system_patches.php");
return;
}
@@ -165,7 +167,7 @@ include("head.inc");
<tr>
<td width="22%" valign="top" class="vncell"><?=gettext("Patch Contents"); ?></td>
<td width="78%" class="vtable">
- <textarea name="patch" class="" id="patch" rows="15" cols="70" wrap="off"><?=base64_decode($pconfig['patch']);?></textarea>
+ <textarea name="patch" class="" id="patch" rows="15" cols="70" wrap="off"><?=htmlspecialchars(base64_decode($pconfig['patch']));?></textarea>
<br /> <span class="vexpl"><?=gettext("The contents of the patch. You can paste a patch here, or enter a URL/commit ID above, it can then be fetched into here automatically."); ?></span></td>
</tr>
<tr>
@@ -192,7 +194,6 @@ include("head.inc");
<span class="vexpl"><?=gettext("Set this option to ignore whitespace in the patch."); ?></span>
</td>
</tr>
-<!-- This isn't ready yet
<tr>
<td width="22%" valign="top" class="vncell"><?=gettext("Auto Apply"); ?></td>
<td width="78%" class="vtable">
@@ -201,7 +202,6 @@ include("head.inc");
<span class="vexpl"><?=gettext("Set this option to apply the patch automatically when possible, useful for patches to survive after firmware updates."); ?></span>
</td>
</tr>
--->
<tr>
<td width="22%" valign="top">&nbsp;</td>
<td width="78%">Patch id: <?php echo $pconfig['uniqid']; ?></td>
diff --git a/config/systempatches/systempatches.xml b/config/systempatches/systempatches.xml
index 3802ba58..c5e0a784 100644
--- a/config/systempatches/systempatches.xml
+++ b/config/systempatches/systempatches.xml
@@ -40,8 +40,9 @@
<requirements>None</requirements>
<faq>Applies patches supplied by the user to the firewall.</faq>
<name>System Patches</name>
- <version>0.5.1</version>
+ <version>0.9</version>
<title>System: Patches</title>
+ <include_file>/usr/local/pkg/patches.inc</include_file>
<menu>
<name>Patches</name>
<tooltiptext></tooltiptext>
@@ -59,8 +60,19 @@
<item>http://www.pfsense.com/packages/config/systempatches/system_patches_edit.php</item>
</additional_files_needed>
<additional_files_needed>
+ <prefix>/usr/local/bin/</prefix>
+ <chmod>755</chmod>
+ <item>http://www.pfsense.com/packages/config/systempatches/apply_patches.php</item>
+ </additional_files_needed>
+ <additional_files_needed>
<prefix>/usr/local/pkg/</prefix>
<chmod>644</chmod>
<item>http://www.pfsense.com/packages/config/systempatches/patches.inc</item>
</additional_files_needed>
+ <custom_php_install_command>
+ patch_package_install();
+ </custom_php_install_command>
+ <custom_php_deinstall_command>
+ patch_package_deinstall();
+ </custom_php_deinstall_command>
</packagegui> \ No newline at end of file