diff options
Diffstat (limited to 'config/autoconfigbackup')
-rw-r--r-- | config/autoconfigbackup/autoconfigbackup.inc | 219 | ||||
-rw-r--r-- | config/autoconfigbackup/autoconfigbackup.php | 387 | ||||
-rw-r--r-- | config/autoconfigbackup/autoconfigbackup.xml | 162 | ||||
-rw-r--r-- | config/autoconfigbackup/autoconfigbackup_backup.php | 157 | ||||
-rw-r--r-- | config/autoconfigbackup/autoconfigbackup_stats.php | 214 | ||||
-rw-r--r-- | config/autoconfigbackup/certs/gd-class2-root.crt | 24 | ||||
-rw-r--r-- | config/autoconfigbackup/certs/gd_intermediate.crt | 29 | ||||
-rw-r--r-- | config/autoconfigbackup/crypt_acb.php | 129 | ||||
-rw-r--r-- | config/autoconfigbackup/parse_config_upload.php | 8 | ||||
-rw-r--r-- | config/autoconfigbackup/upload_config_filter.php | 8 |
10 files changed, 1337 insertions, 0 deletions
diff --git a/config/autoconfigbackup/autoconfigbackup.inc b/config/autoconfigbackup/autoconfigbackup.inc new file mode 100644 index 00000000..fd0d3169 --- /dev/null +++ b/config/autoconfigbackup/autoconfigbackup.inc @@ -0,0 +1,219 @@ +<?php +/* $Id$ */ +/* + autoconfigbackup.inc + Copyright (C) 2008 Scott Ullrich + + 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. + + 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 + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + 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. +*/ + +$pfSversion = str_replace("\n", "", file_get_contents("/etc/version")); +if(strstr($pfSversion, "1.2")) + require_once("crypt_acb.php"); + +/* ensures patches match */ +function custom_php_validation_command($post, $input_errors) { + global $_POST, $savemsg, $config; + + if($post['password'] <> $post['passwordagain']) + $input_errors[] = "Sorry, the entered passwords do not match."; + + if($post['crypto_password'] <> $post['crypto_password2']) + $input_errors[] = "Sorry, the entered encryption passwords do not match."; + + if($post['testconnection']) { + $status = test_connection($post); + if($status) + $savemsg = "Connection to portal.pfsense.org was tested with no errors."; + } + + // We do not need to store this value. + unset($_POST['testconnection']); +} + +function test_connection($post) { + global $savemsg, $config; + + // Seperator used during client / server communications + $oper_sep = "\|\|"; + + // Encryption password + $decrypt_password = $post['crypto_password']; + + // Defined username + $username = $post['username']; + + // Defined password + $password = $post['password']; + + // Set hostname + $hostname = $config['system']['hostname'] . "." . $config['system']['domain']; + + // URL to restore.php + $get_url = "https://{$username}:{$password}@portal.pfsense.org/pfSconfigbackups/restore.php"; + + // Populate available backups + $curl_session = curl_init(); + curl_setopt($curl_session, CURLOPT_URL, $get_url); + curl_setopt($curl_session, CURLOPT_SSL_VERIFYPEER, 0); + curl_setopt($curl_session, CURLOPT_POST, 1); + curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($curl_session, CURLOPT_POSTFIELDS, "action=showbackups&hostname={$hostname}"); + $data = curl_exec($curl_session); + + if (curl_errno($curl_session)) + return("An error occurred " . curl_error($curl_session)); + else + curl_close($curl_session); + + return; +} + +function upload_config($reasonm = "") { + global $config, $g, $input_errors; + + /* + * pfSense upload config to pfSense.org script + * This file plugs into filter.inc (/usr/local/pkg/pf) + * and runs every time the running firewall filter changes. + * + * Written by Scott Ullrich + * (C) 2008 BSD Perimeter LLC + * + */ + + if(file_exists("/tmp/acb_nooverwrite")) { + unlink("/tmp/acb_nooverwrite"); + $nooverwrite = "true"; + } else { + $nooverwrite = "false"; + } + + // Define some needed variables + if(!file_exists("/cf/conf/lastpfSbackup.txt")) { + conf_mount_rw(); + touch("/cf/conf/lastpfSbackup.txt"); + conf_mount_ro(); + } + + $last_backup_date = str_replace("\n", "", file_get_contents("/cf/conf/lastpfSbackup.txt")); + $last_config_change = $config['revision']['time']; + $hostname = $config['system']['hostname'] . "." . $config['system']['domain']; + if($reasonm) + $reason = $reasonm; + else + $reason = $config['revision']['description']; + $username = $config['installedpackages']['autoconfigbackup']['config'][0]['username']; + $password = $config['installedpackages']['autoconfigbackup']['config'][0]['password']; + $encryptpw = $config['installedpackages']['autoconfigbackup']['config'][0]['crypto_password']; + + // Define upload_url, must be present after other variable definitions due to username, password + $upload_url = "https://{$username}:{$password}@portal.pfsense.org/pfSconfigbackups/backup.php"; + + if(!$username or !$password or !$encryptpw) { + if(!file_exists("/cf/conf/autoconfigback.notice")) { + $notice_text = "Either the username, password or encryption password is not set for Automatic Configuration Backup. "; + $notice_text .= "Please correct this in Diagnostics -> AutoConfigBackup -> Settings."; + log_error($notice_text); + file_notice("AutoConfigBackup", $notice_text, $notice_text, ""); + conf_mount_rw(); + touch("/cf/conf/autoconfigback.notice"); + conf_mount_ro(); + } + } else { + /* If configuration has changed, upload to pfS */ + if($last_backup_date <> $last_config_change) { + + // Mount RW (if needed) + conf_mount_rw(); + // Lock config + config_lock(); + + $notice_text = "Beginning https://portal.pfsense.org configuration backup."; + log_error($notice_text); + update_filter_reload_status($notice_text); + + // Encrypt config.xml + $raw_config_sha256_hash = trim(`/sbin/sha256 /cf/conf/config.xml | awk '{ print $4 }'`); + $data = file_get_contents("/cf/conf/config.xml"); + $data = encrypt_data($data, $encryptpw); + tagfile_reformat($data, $data, "config.xml"); + + $post_fields = array( + 'reason' => urlencode($reason), + 'hostname' => urlencode($hostname), + 'configxml' => urlencode($data), + 'nooverwrite' => urlencode($nooverwrite), + 'raw_config_sha256_hash' => urlencode($raw_config_sha256_hash) + ); + + //url-ify the data for the POST + foreach($post_fields as $key=>$value) + $fields_string .= $key.'='.$value.'&'; + rtrim($fields_string,'&'); + + // Check configuration into the BSDP repo + $curl_session = curl_init(); + curl_setopt($curl_session, CURLOPT_URL, $upload_url); + curl_setopt($curl_session, CURLOPT_POST, count($post_fields)); + curl_setopt($curl_session, CURLOPT_POSTFIELDS, $fields_string); + curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($curl_session, CURLOPT_SSL_VERIFYPEER, 0); + $data = curl_exec($curl_session); + if (curl_errno($curl_session)) { + $fd = fopen("/tmp/backupdebug.txt", "w"); + fwrite($fd, $upload_url . "" . $fields_string . "\n\n"); + fwrite($fd, $data); + fwrite($fd, curl_error($curl_session)); + fclose($fd); + } else { + curl_close($curl_session); + } + + if(!strstr($data, "500")) { + $notice_text = "An error occured while uploading your pfSense configuration to portal.pfsense.org"; + log_error($notice_text . " - " . $data); + file_notice("autoconfigurationbackup", $notice_text, $data, ""); + update_filter_reload_status($notice_text . " - " . $data); + } else { + // Update last pfS backup time + $fd = fopen("/cf/conf/lastpfSbackup.txt", "w"); + fwrite($fd, $config['revision']['time']); + fclose($fd); + $notice_text = "End of portal.pfsense.org configuration backup (success)."; + log_error($notice_text); + update_filter_reload_status($notice_text); + } + + // Unlock config + config_unlock(); + // Mount image RO (if needed) + conf_mount_ro(); + + } else { + log_error("No https://portal.pfsense.org backup required."); + } + + } +} + +?>
\ No newline at end of file diff --git a/config/autoconfigbackup/autoconfigbackup.php b/config/autoconfigbackup/autoconfigbackup.php new file mode 100644 index 00000000..80db5543 --- /dev/null +++ b/config/autoconfigbackup/autoconfigbackup.php @@ -0,0 +1,387 @@ +<?php +/* $Id$ */ +/* + autoconfigbackup.php + Copyright (C) 2008 Scott Ullrich + 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. + + 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 + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + 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. +*/ + +require("guiconfig.inc"); + +$pfSversion = str_replace("\n", "", file_get_contents("/etc/version")); +if(strstr($pfSversion, "1.2")) + require("crypt_acb.php"); + +// Seperator used during client / server communications +$oper_sep = "\|\|"; + +// Encryption password +$decrypt_password = $config['installedpackages']['autoconfigbackup']['config'][0]['crypto_password']; + +// Defined username +$username = $config['installedpackages']['autoconfigbackup']['config'][0]['username']; + +// Defined password +$password = $config['installedpackages']['autoconfigbackup']['config'][0]['password']; + +// URL to restore.php +$get_url = "https://{$username}:{$password}@portal.pfsense.org/pfSconfigbackups/restore.php"; + +// URL to stats +$stats_url = "https://{$username}:{$password}@portal.pfsense.org/pfSconfigbackups/showstats.php"; + +// URL to delete.php +$del_url = "https://{$username}:{$password}@portal.pfsense.org/pfSconfigbackups/delete.php"; + +// Set hostname +if($_REQUEST['hostname']) + $hostname = $_REQUEST['hostname']; +else + $hostname = $config['system']['hostname'] . "." . $config['system']['domain']; + +// Hostname of local machine +$myhostname = $config['system']['hostname'] . "." . $config['system']['domain']; + +if(!$username) { + Header("Location: /pkg_edit.php?xml=autoconfigbackup.xml&id=0"); + exit; +} + +if($_REQUEST['savemsg']) + $savemsg = htmlentities($_REQUEST['savemsg']); + +if($_REQUEST['download']) + $pgtitle = "Diagnostics: Auto Configuration Backup revision information"; +else + $pgtitle = "Diagnostics: Auto Configuration Backup"; + +include("head.inc"); + +function get_hostnames() { + global $stats_url, $username, $oper_sep; + // Populate available backups + $curl_session = curl_init(); + curl_setopt($curl_session, CURLOPT_URL, $stats_url); + curl_setopt($curl_session, CURLOPT_SSL_VERIFYPEER, 0); + curl_setopt($curl_session, CURLOPT_POST, 1); + curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($curl_session, CURLOPT_POSTFIELDS, "action=showstats"); + $data = curl_exec($curl_session); + if (curl_errno($curl_session)) { + $fd = fopen("/tmp/acb_statsdebug.txt", "w"); + fwrite($fd, $stats_url . "" . "action=showstats" . "\n\n"); + fwrite($fd, $data); + fwrite($fd, curl_error($curl_session)); + fclose($fd); + } else { + curl_close($curl_session); + } + // Loop through and create new confvers + $data_split = split("\n", $data); + $statvers = array(); + foreach($data_split as $ds) { + $ds_split = split($oper_sep, $ds); + if($ds_split[0]) + $statvers[] = $ds_split[0];; + } + return $statvers; +} + +?> +<body link="#0000CC" vlink="#0000CC" alink="#0000CC"> +<div id='maincontent'> +<script src="/javascript/scriptaculous/prototype.js" type="text/javascript"></script> +<?php + include("fbegin.inc"); + if(strstr($pfSversion, "1.2")) + echo "<p class=\"pgtitle\">{$pgtitle}</p>"; + if($savemsg) { + echo "<div id='savemsg'>"; + print_info_box($savemsg); + echo "</div>"; + } + if ($input_errors) + print_input_errors($input_errors); + if($hostname <> $myhostname) + print_info_box("Warning! You are currently viewing an alternate hosts backup history ($hostname)"); +?> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr><td> +<div id='feedbackdiv'></div> + <?php + $tab_array = array(); + $tab_array[0] = array("Settings", false, "/pkg_edit.php?xml=autoconfigbackup.xml&id=0"); + if($_REQUEST['download']) + $active = false; + else + $active = true; + $tab_array[1] = array("Restore", $active, "/autoconfigbackup.php"); + if($_REQUEST['download']) + $tab_array[] = array("Revision", true, "/autoconfigbackup.php?download={$_REQUEST['download']}"); + $tab_array[] = array("Backup now", false, "/autoconfigbackup_backup.php"); + $tab_array[] = array("Stats", false, "/autoconfigbackup_stats.php"); + display_top_tabs($tab_array); + $hostnames = get_hostnames(); + ?> + </td></tr> + <tr> + <td> + <table id="backuptable" class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td colspan="2" align="left"> + <div id="loading"> + <img src="themes/metallic/images/misc/loader.gif"> Loading, please wait... + </div> + <?php + if($_REQUEST['rmver'] != "") { + $curl_session = curl_init(); + curl_setopt($curl_session, CURLOPT_URL, $del_url); + curl_setopt($curl_session, CURLOPT_POST, 3); + curl_setopt($curl_session, CURLOPT_SSL_VERIFYPEER, 0); + curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($curl_session, CURLOPT_POSTFIELDS, "action=delete" . + "&hostname=" . urlencode($hostname) . + "&revision=" . urlencode($_REQUEST['rmver'])); + $data = curl_exec($curl_session); + if (curl_errno($curl_session)) { + $fd = fopen("/tmp/acb_deletedebug.txt", "w"); + fwrite($fd, $get_url . "" . "action=delete&hostname=" . + urlencode($hostname) . "&revision=" . + urlencode($_REQUEST['rmver']) . "\n\n"); + fwrite($fd, $data); + fwrite($fd, curl_error($curl_session)); + fclose($fd); + $savemsg = "An error occurred while trying to remove the item from portal.pfsense.org."; + } else { + curl_close($curl_session); + $savemsg = "Backup revision {$_REQUEST['rmver']} has been removed."; + } + print_info_box($savemsg); + } + if($_REQUEST['newver'] != "") { + // Phone home and obtain backups + $curl_session = curl_init(); + curl_setopt($curl_session, CURLOPT_URL, $get_url); + curl_setopt($curl_session, CURLOPT_POST, 3); + curl_setopt($curl_session, CURLOPT_SSL_VERIFYPEER, 0); + curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($curl_session, CURLOPT_POSTFIELDS, "action=restore" . + "&hostname=" . urlencode($hostname) . + "&revision=" . urlencode($_REQUEST['newver'])); + $data = curl_exec($curl_session); + $data_split = split("\+\+\+\+", $data); + $sha256 = $data_split[0]; // sha256 + $data = $data_split[1]; + if (!tagfile_deformat($data, $data, "config.xml")) + $input_errors[] = "The downloaded file does not appear to contain an encrypted pfSense configuration."; + $data = decrypt_data($data, $decrypt_password); + $fd = fopen("/tmp/config_restore.xml", "w"); + fwrite($fd, $data); + fclose($fd); + if(strlen($data) < 50) + $input_errors[] = "The decrypted config.xml is under 50 characters, something went wrong. Aborting."; + $ondisksha256 = trim(`/sbin/sha256 /tmp/config_restore.xml | awk '{ print $4 }'`); + if($sha256 != "0" && $sha256 != "") // we might not have a sha256 on file for older backups + if($ondisksha256 <> $sha256) + $input_errors[] = "SHA256 values does not match, cannot restore."; + if (curl_errno($curl_session)) { + /* If an error occured, log the error in /tmp/ */ + $fd = fopen("/tmp/acb_restoredebug.txt", "w"); + fwrite($fd, $get_url . "" . "action=restore&hostname={$hostname}&revision=" . urlencode($_REQUEST['newver']) . "\n\n"); + fwrite($fd, $data); + fwrite($fd, curl_error($curl_session)); + fclose($fd); + } else { + curl_close($curl_session); + } + if(!$input_errors && $data) { + if(config_restore("/tmp/config_restore.xml") == 0) { + $savemsg = "Successfully reverted the pfSense configuration to revision " . urldecode($_REQUEST['newver']) . "."; + $savemsg .= <<<EOF + <p/> + <form action="reboot.php" method="post"> + Would you like to reboot? + <input name="Submit" type="submit" class="formbtn" value=" Yes "> + <input name="Submit" type="submit" class="formbtn" value=" No "> + </form> +EOF; + } else { + $savemsg = "Unable to revert to the selected configuration."; + } + print_info_box($savemsg); + } + unlink("/tmp/config_restore.xml"); + } + if($_REQUEST['download']) { + // Phone home and obtain backups + $curl_session = curl_init(); + curl_setopt($curl_session, CURLOPT_URL, $get_url); + curl_setopt($curl_session, CURLOPT_POST, 3); + curl_setopt($curl_session, CURLOPT_SSL_VERIFYPEER, 0); + curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($curl_session, CURLOPT_POSTFIELDS, "action=restore" . + "&hostname=" . urlencode($hostname) . + "&revision=" . urlencode($_REQUEST['download'])); + $data = curl_exec($curl_session); + if (!tagfile_deformat($data, $data1, "config.xml")) + $input_errors[] = "The downloaded file does not appear to contain an encrypted pfSense configuration."; + if ($input_errors) { + print_input_errors($input_errors); + } else { + $ds = split("\+\+\+\+", $data); + $revision = $_REQUEST['download']; + $sha256sum = $ds[0]; + if($sha256sum == "0") + $sha256sum = "None on file."; + $data = $ds[1]; + $configtype = "Encrypted"; + if (!tagfile_deformat($data, $data, "config.xml")) + $input_errors[] = "The downloaded file does not appear to contain an encrypted pfSense configuration."; + $data = decrypt_data($data, $decrypt_password); + if(!strstr($data, "pfsense")) { + $data = "Could not decrypt. Different encryption key?"; + $input_errors[] = "Could not decrypt config.xml"; + } + echo "<h2>Hostname</h2>"; + echo "<textarea rows='1' cols='70'>{$hostname}</textarea>"; + echo "<h2>Revision date/time</h2>"; + echo "<textarea name='download' rows='1' cols='70'>{$_REQUEST['download']}</textarea>"; + echo "<h2>Revision reason</h2>"; + echo "<textarea name='download' rows='1' cols='70'>{$_REQUEST['reason']}</textarea>"; + echo "<h2>SHA256 summary</h2>"; + echo "<textarea name='shasum' rows='1' cols='70'>{$sha256sum}</textarea>"; + echo "<h2>Encrypted config.xml</h2>"; + echo "<textarea name='config_xml' rows='40' cols='70'>{$ds[1]}</textarea>"; + echo "<h2>Decrypted config.xml</h2>"; + echo "<textarea name='dec_config_xml' rows='40' cols='70'>{$data}</textarea>"; + } + if(!$input_errors) + echo "<p/><input type=\"button\" value=\"Install this revision\" onClick=\"document.location='autoconfigbackup.php?newver=" . urlencode($_REQUEST['download']) . "';\">"; + echo "<script type=\"text/javascript\">"; + echo "$('loading').innerHTML = '';"; + echo "</script>"; + echo "</td></tr></table></div></td></td></tr></tr></table></form>"; + require("fend.inc"); + exit; + } + // Populate available backups + $curl_session = curl_init(); + curl_setopt($curl_session, CURLOPT_URL, $get_url); + curl_setopt($curl_session, CURLOPT_SSL_VERIFYPEER, 0); + curl_setopt($curl_session, CURLOPT_POST, 1); + curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($curl_session, CURLOPT_POSTFIELDS, "action=showbackups&hostname={$hostname}"); + $data = curl_exec($curl_session); + if (curl_errno($curl_session)) { + $fd = fopen("/tmp/acb_backupdebug.txt", "w"); + fwrite($fd, $get_url . "" . "action=showbackups" . "\n\n"); + fwrite($fd, $data); + fwrite($fd, curl_error($curl_session)); + fclose($fd); + } else { + curl_close($curl_session); + } + // Loop through and create new confvers + $data_split = split("\n", $data); + $confvers = array(); + foreach($data_split as $ds) { + $ds_split = split($oper_sep, $ds); + $tmp_array = array(); + $tmp_array['username'] = $ds_split[0]; + $tmp_array['reason'] = $ds_split[1]; + $tmp_array['time'] = $ds_split[2]; + if($ds_split[2] && $ds_split[0]) + $confvers[] = $tmp_array; + } + ?> + </td> + </tr> + <tr> + <td colspan="2"> + <center> + <b>Hostname:</b> + <select id="hostname" name="hostname" onChange="document.location='autoconfigbackup.php?hostname=' + this.value;"> + <?foreach($hostnames as $hn):?> + <option value='<?=$hn?>'><?=$hn?></option> + <?endforeach?> + <option value='<?=$hostname?>' SELECTED><?=$hostname?></option> + </select> + </td> + </tr> + + <tr> + <td width="30%" class="listhdrr">Date</td> + <td width="70%" class="listhdrr">Configuration Change</td> + </tr> +<?php + $counter = 0; + echo "<script type=\"text/javascript\">"; + echo "$('loading').innerHTML = '';"; + echo "</script>"; + foreach($confvers as $cv): +?> + <tr valign="top"> + <td class="listlr"> <?= $cv['time']; ?></td> + <td class="listbg"> <?= $cv['reason']; ?></td> + <td colspan="2" valign="middle" class="list" nowrap> + <a title="Restore this revision" onClick="return confirm('Are you sure you want to restore <?= $cv['time']; ?>?')" href="autoconfigbackup.php?hostname=<?=urlencode($hostname)?>&newver=<?=urlencode($cv['time']);?>"> + <img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"> + </a> + <a title="Show info" href="autoconfigbackup.php?download=<?=urlencode($cv['time']);?>&hostname=<?=urlencode($hostname)?>&reason=<?php echo urlencode($cv['reason']);?>"> + <img src="/themes/<?= $g['theme']; ?>/images/icons/icon_down.gif" width="17" height="17" border="0"> + </a> + <a title="Delete" onClick="return confirm('Are you sure you want to delete <?= $cv['time']; ?>?')"href="autoconfigbackup.php?hostname=<?=urlencode($hostname)?>&rmver=<?=urlencode($cv['time']);?>"> + <img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"> + </a> + </td> + </tr> +<?php + $counter++; + endforeach; + if($counter == 0) + echo "<tr><td colspan='3'><center>Sorry, we could not locate any backups at portal.pfsense.org for this hostname ({$hostname}).</td></tr>"; + else + echo "<tr><td colspan='3'><center><br/>Backups hosted currently for this hostname on portalpfsense.org: {$counter}.</td></tr>"; +?> + </table> + </div> + </td> + <tr> + <td> + <p> + <strong> + + <span class="red"> + Hint: + </span> + </strong> + Click the + sign next to the revision you would like to restore. + </p> + </td> + </tr> + </tr> +</table> +</form> +<?php include("fend.inc"); ?> +</body> +</html>
\ No newline at end of file diff --git a/config/autoconfigbackup/autoconfigbackup.xml b/config/autoconfigbackup/autoconfigbackup.xml new file mode 100644 index 00000000..5e5eaf73 --- /dev/null +++ b/config/autoconfigbackup/autoconfigbackup.xml @@ -0,0 +1,162 @@ +<?xml version="1.0" encoding="utf-8" ?> +<!DOCTYPE packagegui SYSTEM "./schema/packages.dtd"> +<?xml-stylesheet type="text/xsl" href="./xsl/package.xsl"?> +<packagegui> + <copyright> + <![CDATA[ + /* $Id$ */ + /* + autoconfigbackup.xml + part of pfSense (http://www.pfSense.com) + Copyright (C) 2008 BSD Perimeter + 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. + + 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 + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + 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> + <description>Automatically backs up your pfSense configuration. All contents are encrypted on the server. Requires pfSense Premium Support Portal Subscription from https://portal.pfsense.org</description> + <requirements>pfSense Premium Support Portal</requirements> + <name>AutoConfigBackup</name> + <version>1.0</version> + <title>Diagnostics: Auto Configuration Backup</title> + <savetext>Change</savetext> + <include_file>/usr/local/pkg/autoconfigbackup.inc</include_file> + <aftersaveredirect>pkg_edit.php?xml=autoconfigbackup.xml&id=0</aftersaveredirect> + <menu> + <name>AutoConfigBackup</name> + <tooltiptext>Set autoconfigbackup settings such as password and port.</tooltiptext> + <section>Diagnostics</section> + <url>/autoconfigbackup.php</url> + </menu> + <additional_files_needed> + <prefix>/usr/local/pkg/pf/</prefix> + <chmod>0755</chmod> + <item>http://www.pfsense.com/packages/config/autoconfigbackup/upload_config_filter.php</item> + </additional_files_needed> + <additional_files_needed> + <prefix>/usr/local/pkg/parse_config/</prefix> + <chmod>0755</chmod> + <item>http://www.pfsense.com/packages/config/autoconfigbackup/parse_config_upload.php</item> + </additional_files_needed> + <additional_files_needed> + <prefix>/usr/local/www/</prefix> + <chmod>0755</chmod> + <item>http://www.pfsense.com/packages/config/autoconfigbackup/autoconfigbackup.php</item> + </additional_files_needed> + <additional_files_needed> + <prefix>/usr/local/pkg/</prefix> + <chmod>0755</chmod> + <item>http://www.pfsense.com/packages/config/autoconfigbackup/autoconfigbackup.inc</item> + </additional_files_needed> + <additional_files_needed> + <prefix>/etc/inc/</prefix> + <chmod>0755</chmod> + <item>http://www.pfsense.com/packages/config/autoconfigbackup/crypt_acb.php</item> + </additional_files_needed> + <additional_files_needed> + <prefix>/usr/local/www/</prefix> + <chmod>0755</chmod> + <item>http://www.pfsense.com/packages/config/autoconfigbackup/autoconfigbackup_backup.php</item> + </additional_files_needed> + <additional_files_needed> + <prefix>/usr/local/www/</prefix> + <chmod>0755</chmod> + <item>http://www.pfsense.com/packages/config/autoconfigbackup/autoconfigbackup_stats.php</item> + </additional_files_needed> + <tabs> + <tab> + <text>Settings</text> + <url>/pkg_edit.php?xml=autoconfigbackup.xml&id=0</url> + <active/> + </tab> + <tab> + <text>Restore</text> + <url>/autoconfigbackup.php</url> + </tab> + <tab> + <text>Backup now</text> + <url>/autoconfigbackup_backup.php</url> + </tab> + <tab> + <text>Stats</text> + <url>/autoconfigbackup_stats.php</url> + </tab> + </tabs> + <fields> + <field> + <fielddescr>Subscription Username</fielddescr> + <fieldname>username</fieldname> + <description>Enter the subscription username for portal.pfsense.org</description> + <type>input</type> + </field> + <field> + <fielddescr>Subscription Password</fielddescr> + <fieldname>password</fieldname> + <description>Enter the password for portal.pfsense.org</description> + <type>password</type> + </field> + <field> + <fielddescr>Enter Password again</fielddescr> + <fieldname>passwordagain</fieldname> + <type>password</type> + </field> + <field> + <fielddescr>Encryption Password</fielddescr> + <description>This password will be used to encrypt config.xml before sending to portal.pfsense.org. Do not share the password and keep it safe!</description> + <fieldname>crypto_password</fieldname> + <type>password</type> + </field> + <field> + <fielddescr>Encryption Password again</fielddescr> + <description>Enter the encryption password again.</description> + <fieldname>crypto_password2</fieldname> + <type>password</type> + </field> + <field> + <fielddescr>Test connection</fielddescr> + <description>Check this box to test the connection to portal.pfsense.org.</description> + <fieldname>testconnection</fieldname> + <type>checkbox</type> + </field> + </fields> + <custom_php_validation_command> + custom_php_validation_command($_POST, &$input_errors); + </custom_php_validation_command> + <custom_php_global_functions> + </custom_php_global_functions> + <custom_add_php_command> + </custom_add_php_command> + <custom_php_resync_config_command> + <![CDATA[ + exec("echo > /cf/conf/lastpfSbackup.txt"); + filter_configure(); + if($savemsg) + $savemsg .= "<br/>"; + $savemsg .= "A configuration backup has been queued."; + ]]> + </custom_php_resync_config_command> + <custom_php_install_command> + </custom_php_install_command> + <custom_php_deinstall_command> + </custom_php_deinstall_command> +</packagegui> diff --git a/config/autoconfigbackup/autoconfigbackup_backup.php b/config/autoconfigbackup/autoconfigbackup_backup.php new file mode 100644 index 00000000..cebd7a56 --- /dev/null +++ b/config/autoconfigbackup/autoconfigbackup_backup.php @@ -0,0 +1,157 @@ +<?php +/* $Id$ */ +/* + autoconfigbackup_backup.php + Copyright (C) 2008 Scott Ullrich + 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. + + 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 + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + 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. +*/ + +require("globals.inc"); +require("guiconfig.inc"); +require("/usr/local/pkg/autoconfigbackup.inc"); + +$pfSversion = str_replace("\n", "", file_get_contents("/etc/version")); +if(strstr($pfSversion, "1.2")) + require("crypt_acb.php"); + +// Seperator used during client / server communications +$oper_sep = "\|\|"; + +// Encryption password +$decrypt_password = $config['installedpackages']['autoconfigbackup']['config'][0]['crypto_password']; + +// Defined username +$username = $config['installedpackages']['autoconfigbackup']['config'][0]['username']; + +// Defined password +$password = $config['installedpackages']['autoconfigbackup']['config'][0]['password']; + +// URL to restore.php +$get_url = "https://{$username}:{$password}@portal.pfsense.org/pfSconfigbackups/restore.php"; + +// URL to delete.php +$del_url = "https://{$username}:{$password}@portal.pfsense.org/pfSconfigbackups/delete.php"; + +// Set hostname +$hostname = $config['system']['hostname'] . "." . $config['system']['domain']; + +if(!$username) { + Header("Location: /pkg_edit.php?xml=autoconfigbackup.xml&id=0"); + exit; +} + +if($_POST) { + if($_REQUEST['nooverwrite']) + touch("/tmp/acb_nooverwrite"); + if($_REQUEST['reason']) + write_config($_REQUEST['reason']); + else + write_config("Backup invoked via Auto Config Backup."); + $config = parse_config(true); + exec("echo > /cf/conf/lastpfSbackup.txt"); + upload_config($_REQUEST['reason']); + $savemsg = "Backup completed successfully."; + $donotshowheader=true; +} + +$pgtitle = "Diagnostics: Auto Configuration Backup Now"; + +include("head.inc"); + +?> +<body link="#0000CC" vlink="#0000CC" alink="#0000CC"> +<div id='maincontent'> +<?php + include("fbegin.inc"); + if(strstr($pfSversion, "1.2")) + echo "<p class=\"pgtitle\">{$pgtitle}</p>"; + if($savemsg) { + print_info_box($savemsg); + } + if ($input_errors) + print_input_errors($input_errors); + +?> +<form method="post" action="autoconfigbackup_backup.php"> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td> + <div id='feedbackdiv'> + </div> + <?php + $tab_array = array(); + $tab_array[] = array("Settings", false, "/pkg_edit.php?xml=autoconfigbackup.xml&id=0"); + $tab_array[] = array("Restore", false, "/autoconfigbackup.php"); + $tab_array[] = array("Backup now", true, "/autoconfigbackup_backup.php"); + $tab_array[] = array("Stats", false, "/autoconfigbackup_stats.php"); + display_top_tabs($tab_array); + ?> + </td> + </tr> + <tr> + <td> + <table id="backuptable" class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td colspan="2" align="left"> + <table> + <tr> + <td align="right"> + Enter the backup reason: + </td> + <td> + <input name="reason" id="reason" size="80"> + </td> + </tr> + <tr> + <td align="right"> + Do not overwrite previous backups for this hostname: + </td> + <td> + <input type="checkbox" name="nooverwrite"> + </td> + </tr> + <tr> + <td> + + </td> + </tr> + <tr> + <td align="right"> + <input type="submit" name="Backup" value="Backup"> + </td> + </tr> + </table> + </td> + </tr> + </table> + </td> + </tr> + </div> + </td> + </tr> +</table> +</form> +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/config/autoconfigbackup/autoconfigbackup_stats.php b/config/autoconfigbackup/autoconfigbackup_stats.php new file mode 100644 index 00000000..65f02b2d --- /dev/null +++ b/config/autoconfigbackup/autoconfigbackup_stats.php @@ -0,0 +1,214 @@ +<?php +/* $Id$ */ +/* + autoconfigbackup_stats.php + Copyright (C) 2008 Scott Ullrich + 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. + + 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 + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + 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. +*/ + +require("globals.inc"); +require("guiconfig.inc"); +require("/usr/local/pkg/autoconfigbackup.inc"); + +$pfSversion = str_replace("\n", "", file_get_contents("/etc/version")); +if(strstr($pfSversion, "1.2")) + require("crypt_acb.php"); + +// Seperator used during client / server communications +$oper_sep = "\|\|"; + +// Encryption password +$decrypt_password = $config['installedpackages']['autoconfigbackup']['config'][0]['crypto_password']; + +// Defined username +$username = $config['installedpackages']['autoconfigbackup']['config'][0]['username']; + +// Defined password +$password = $config['installedpackages']['autoconfigbackup']['config'][0]['password']; + +// URL to restore.php +$get_url = "https://{$username}:{$password}@portal.pfsense.org/pfSconfigbackups/restore.php"; + +// URL to delete.php +$del_url = "https://{$username}:{$password}@portal.pfsense.org/pfSconfigbackups/delete.php"; + +// URL to stats.php +$stats_url = "https://{$username}:{$password}@portal.pfsense.org/pfSconfigbackups/showstats.php"; + +// Set hostname +$hostname = $config['system']['hostname'] . "." . $config['system']['domain']; + +if(!$username) { + Header("Location: /pkg_edit.php?xml=autoconfigbackup.xml&id=0"); + exit; +} + +if($_REQUEST['delhostname']) { + $curl_session = curl_init(); + curl_setopt($curl_session, CURLOPT_URL, $del_url); + curl_setopt($curl_session, CURLOPT_POST, 2); + curl_setopt($curl_session, CURLOPT_SSL_VERIFYPEER, 0); + curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($curl_session, CURLOPT_POSTFIELDS, "action=deletehostname&delhostname=" . urlencode($_REQUEST['delhostname'])); + $data = curl_exec($curl_session); + if (curl_errno($curl_session)) { + $fd = fopen("/tmp/acb_deletedebug.txt", "w"); + fwrite($fd, $get_url . "" . "action=deletehostname&hostname=" . + urlencode($_REQUEST['delhostname']) . "\n\n"); + fwrite($fd, $data); + fwrite($fd, curl_error($curl_session)); + fclose($fd); + $savemsg = "An error occurred while trying to remove the item from portal.pfsense.org."; + } else { + curl_close($curl_session); + $savemsg = "ALL backup revisions for {$_REQUEST['delhostname']} have been removed."; + } +} + +$pgtitle = "Diagnostics: Auto Configuration Stats"; + +include("head.inc"); + +?> +<body link="#0000CC" vlink="#0000CC" alink="#0000CC"> +<script src="/javascript/scriptaculous/prototype.js" type="text/javascript"></script> +<div id='maincontent'> +<?php + include("fbegin.inc"); + if(strstr($pfSversion, "1.2")) + echo "<p class=\"pgtitle\">{$pgtitle}</p>"; + if($savemsg) { + print_info_box($savemsg); + } + if ($input_errors) + print_input_errors($input_errors); + +?> +<form method="post" action="autoconfigbackup_stats.php"> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td> + <div id='feedbackdiv'> + </div> + <?php + $tab_array = array(); + $tab_array[] = array("Settings", false, "/pkg_edit.php?xml=autoconfigbackup.xml&id=0"); + $tab_array[] = array("Restore", false, "/autoconfigbackup.php"); + $tab_array[] = array("Backup now", false, "/autoconfigbackup_backup.php"); + $tab_array[] = array("Stats", true, "/autoconfigbackup_stats.php"); + display_top_tabs($tab_array); + ?> + </td> + </tr> + <tr> + <td> + <table id="backuptable" class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td colspan="2" align="left"> + <div id="loading"> + <img src="themes/metallic/images/misc/loader.gif"> Loading, please wait... + </div> + </tr> + <tr> + <td width="30%" class="listhdrr">Hostname</td> + <td width="70%" class="listhdrr">Backup count</td> + </tr> +<?php + // Populate available backups + $curl_session = curl_init(); + curl_setopt($curl_session, CURLOPT_URL, $stats_url); + curl_setopt($curl_session, CURLOPT_SSL_VERIFYPEER, 0); + curl_setopt($curl_session, CURLOPT_POST, 1); + curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($curl_session, CURLOPT_POSTFIELDS, "action=showstats"); + $data = curl_exec($curl_session); + if (curl_errno($curl_session)) { + $fd = fopen("/tmp/acb_statsdebug.txt", "w"); + fwrite($fd, $get_url . "" . "action=showstats" . "\n\n"); + fwrite($fd, $data); + fwrite($fd, curl_error($curl_session)); + fclose($fd); + } else { + curl_close($curl_session); + } + // Loop through and create new confvers + $data_split = split("\n", $data); + $statvers = array(); + foreach($data_split as $ds) { + $ds_split = split($oper_sep, $ds); + $tmp_array = array(); + $tmp_array['hostname'] = $ds_split[0]; + $tmp_array['hostnamecount'] = $ds_split[1]; + if($ds_split[0] && $ds_split[1]) + $statvers[] = $tmp_array; + } + $counter = 0; + echo "<script type=\"text/javascript\">"; + echo "$('loading').innerHTML = '';"; + echo "</script>"; + $total_backups = 0; + foreach($statvers as $cv): +?> + <tr valign="top"> + <td class="listlr"> + <?= $cv['hostname']; ?> + </td> + <td class="listbg"> + <?= $cv['hostnamecount']; ?> + </td> + <td> + <nobr> + <a title="View all backups for this host" href="autoconfigbackup.php?hostname=<?=urlencode($cv['hostname'])?>"> + <img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"> + </a> + <a title="Delete all backups for this host" onClick="return confirm('Are you sure you want to delete *ALL BACKUPS FOR THIS HOSTNAME* <?= $cv['hostname']; ?>?')" href="autoconfigbackup_stats.php?delhostname=<?=urlencode($cv['hostname'])?>"> + <img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"> + </a> + </nobr> + </td> + </tr> +<?php + $total_backups = $total_backups + $cv['hostnamecount']; + $counter++; + endforeach; + if($counter == 0) + echo "<tr><td colspan='3'><center>Sorry, we could not load the status information for the account ($username).</td></tr>"; +?> + <tr> + <td align="right"> + Total + </td> + <td> + <?=$total_backups?> + </td> + </tr> + </td> + </tr> +</table> +</td></tr> +</table> +</form> +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/config/autoconfigbackup/certs/gd-class2-root.crt b/config/autoconfigbackup/certs/gd-class2-root.crt new file mode 100644 index 00000000..42e8d1ee --- /dev/null +++ b/config/autoconfigbackup/certs/gd-class2-root.crt @@ -0,0 +1,24 @@ +-----BEGIN CERTIFICATE----- +MIIEADCCAuigAwIBAgIBADANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJVUzEh +MB8GA1UEChMYVGhlIEdvIERhZGR5IEdyb3VwLCBJbmMuMTEwLwYDVQQLEyhHbyBE +YWRkeSBDbGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTA0MDYyOTE3 +MDYyMFoXDTM0MDYyOTE3MDYyMFowYzELMAkGA1UEBhMCVVMxITAfBgNVBAoTGFRo +ZSBHbyBEYWRkeSBHcm91cCwgSW5jLjExMC8GA1UECxMoR28gRGFkZHkgQ2xhc3Mg +MiBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASAwDQYJKoZIhvcNAQEBBQADggEN +ADCCAQgCggEBAN6d1+pXGEmhW+vXX0iG6r7d/+TvZxz0ZWizV3GgXne77ZtJ6XCA +PVYYYwhv2vLM0D9/AlQiVBDYsoHUwHU9S3/Hd8M+eKsaA7Ugay9qK7HFiH7Eux6w +wdhFJ2+qN1j3hybX2C32qRe3H3I2TqYXP2WYktsqbl2i/ojgC95/5Y0V4evLOtXi +EqITLdiOr18SPaAIBQi2XKVlOARFmR6jYGB0xUGlcmIbYsUfb18aQr4CUWWoriMY +avx4A6lNf4DD+qta/KFApMoZFv6yyO9ecw3ud72a9nmYvLEHZ6IVDd2gWMZEewo+ +YihfukEHU1jPEX44dMX4/7VpkI+EdOqXG68CAQOjgcAwgb0wHQYDVR0OBBYEFNLE +sNKR1EwRcbNhyz2h/t2oatTjMIGNBgNVHSMEgYUwgYKAFNLEsNKR1EwRcbNhyz2h +/t2oatTjoWekZTBjMQswCQYDVQQGEwJVUzEhMB8GA1UEChMYVGhlIEdvIERhZGR5 +IEdyb3VwLCBJbmMuMTEwLwYDVQQLEyhHbyBEYWRkeSBDbGFzcyAyIENlcnRpZmlj +YXRpb24gQXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQAD +ggEBADJL87LKPpH8EsahB4yOd6AzBhRckB4Y9wimPQoZ+YeAEW5p5JYXMP80kWNy +OO7MHAGjHZQopDH2esRU1/blMVgDoszOYtuURXO1v0XJJLXVggKtI3lpjbi2Tc7P +TMozI+gciKqdi0FuFskg5YmezTvacPd+mSYgFFQlq25zheabIZ0KbIIOqPjCDPoQ +HmyW74cNxA9hi63ugyuV+I6ShHI56yDqg+2DzZduCLzrTia2cyvk0/ZM/iZx4mER +dEr/VxqHD3VILs9RaRegAhJhldXRQLIQTO7ErBBDpqWeCtWVYpoNz4iCxTIM5Cuf +ReYNnyicsbkqWletNw+vHX/bvZ8= +-----END CERTIFICATE----- diff --git a/config/autoconfigbackup/certs/gd_intermediate.crt b/config/autoconfigbackup/certs/gd_intermediate.crt new file mode 100644 index 00000000..33d97396 --- /dev/null +++ b/config/autoconfigbackup/certs/gd_intermediate.crt @@ -0,0 +1,29 @@ +-----BEGIN CERTIFICATE----- +MIIE3jCCA8agAwIBAgICAwEwDQYJKoZIhvcNAQEFBQAwYzELMAkGA1UEBhMCVVMx +ITAfBgNVBAoTGFRoZSBHbyBEYWRkeSBHcm91cCwgSW5jLjExMC8GA1UECxMoR28g +RGFkZHkgQ2xhc3MgMiBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNjExMTYw +MTU0MzdaFw0yNjExMTYwMTU0MzdaMIHKMQswCQYDVQQGEwJVUzEQMA4GA1UECBMH +QXJpem9uYTETMBEGA1UEBxMKU2NvdHRzZGFsZTEaMBgGA1UEChMRR29EYWRkeS5j +b20sIEluYy4xMzAxBgNVBAsTKmh0dHA6Ly9jZXJ0aWZpY2F0ZXMuZ29kYWRkeS5j +b20vcmVwb3NpdG9yeTEwMC4GA1UEAxMnR28gRGFkZHkgU2VjdXJlIENlcnRpZmlj +YXRpb24gQXV0aG9yaXR5MREwDwYDVQQFEwgwNzk2OTI4NzCCASIwDQYJKoZIhvcN +AQEBBQADggEPADCCAQoCggEBAMQt1RWMnCZM7DI161+4WQFapmGBWTtwY6vj3D3H +KrjJM9N55DrtPDAjhI6zMBS2sofDPZVUBJ7fmd0LJR4h3mUpfjWoqVTr9vcyOdQm +VZWt7/v+WIbXnvQAjYwqDL1CBM6nPwT27oDyqu9SoWlm2r4arV3aLGbqGmu75RpR +SgAvSMeYddi5Kcju+GZtCpyz8/x4fKL4o/K1w/O5epHBp+YlLpyo7RJlbmr2EkRT +cDCVw5wrWCs9CHRK8r5RsL+H0EwnWGu1NcWdrxcx+AuP7q2BNgWJCJjPOq8lh8BJ +6qf9Z/dFjpfMFDniNoW1fho3/Rb2cRGadDAW/hOUoz+EDU8CAwEAAaOCATIwggEu +MB0GA1UdDgQWBBT9rGEyk2xF1uLuhV+auud2mWjM5zAfBgNVHSMEGDAWgBTSxLDS +kdRMEXGzYcs9of7dqGrU4zASBgNVHRMBAf8ECDAGAQH/AgEAMDMGCCsGAQUFBwEB +BCcwJTAjBggrBgEFBQcwAYYXaHR0cDovL29jc3AuZ29kYWRkeS5jb20wRgYDVR0f +BD8wPTA7oDmgN4Y1aHR0cDovL2NlcnRpZmljYXRlcy5nb2RhZGR5LmNvbS9yZXBv +c2l0b3J5L2dkcm9vdC5jcmwwSwYDVR0gBEQwQjBABgRVHSAAMDgwNgYIKwYBBQUH +AgEWKmh0dHA6Ly9jZXJ0aWZpY2F0ZXMuZ29kYWRkeS5jb20vcmVwb3NpdG9yeTAO +BgNVHQ8BAf8EBAMCAQYwDQYJKoZIhvcNAQEFBQADggEBANKGwOy9+aG2Z+5mC6IG +OgRQjhVyrEp0lVPLN8tESe8HkGsz2ZbwlFalEzAFPIUyIXvJxwqoJKSQ3kbTJSMU +A2fCENZvD117esyfxVgqwcSeIaha86ykRvOe5GPLL5CkKSkB2XIsKd83ASe8T+5o +0yGPwLPk9Qnt0hCqU7S+8MxZC9Y7lhyVJEnfzuz9p0iRFEUOOjZv2kWzRaJBydTX +RE4+uXR21aITVSzGh6O1mawGhId/dQb8vxRMDsxuxN89txJx9OjxUUAiKEngHUuH +qDTMBqLdElrRhjZkAzVvb3du6/KFUJheqwNTrZEjYx8WnM25sgVjOuH0aBsXBTWV +U+4= +-----END CERTIFICATE-----
\ No newline at end of file diff --git a/config/autoconfigbackup/crypt_acb.php b/config/autoconfigbackup/crypt_acb.php new file mode 100644 index 00000000..804b6a41 --- /dev/null +++ b/config/autoconfigbackup/crypt_acb.php @@ -0,0 +1,129 @@ +<?php + +/* $Id$ */ +/* + Copyright (C) 2008 Shrew Soft Inc + 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. + + 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 + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + 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. + + DISABLE_PHP_LINT_CHECKING +*/ + + function crypt_data($val, $pass, $opt) { + $file = tempnam("/tmp", "php-encrypt"); + $fd = fopen("$file.dec", "w"); + fwrite($fd, $val); + fclose($fd); + exec("/usr/bin/openssl enc {$opt} -aes-256-cbc -in $file.dec -out $file.enc -k {$pass}"); + $result = file_get_contents("$file.enc"); + exec("rm $file"); + exec("rm $file.dec"); + exec("rm $file.enc"); + return $result; + } + + function crypt_dataA(& $data, $pass, $opt) { + log_error("entering crypt_data()"); + $pspec = "/usr/bin/openssl enc {$opt} -aes-256-cbc -k {$pass}"; + $dspec = array( 0 => array("pipe", "r"), + 1 => array("pipe", "w"), + 2 => array("pipe", "e")); + log_error("proc_open"); + $fp = proc_open($pspec, $dspec, $pipes); + if (!$fp) + return false; + log_error("writing to pipe[0]"); + fwrite($pipes[0], $data); + log_error("closing pipe[0]"); + fclose($pipes[0]); + + log_error("enter while()"); + + while (!feof($pipes[1])) { + $rslt .= fread($pipes[1], 8192); + } + + log_error("exit while()"); + + fclose($pipes[1]); + + proc_close($fp); + + return $rslt; + } + + function encrypt_data(& $data, $pass) { + return base64_encode(crypt_data($data, $pass, "-e")); + } + + function decrypt_data(& $data, $pass) { + return crypt_data(base64_decode($data), $pass, "-d"); + } + + function tagfile_reformat($in, & $out, $tag) { + + $out = "---- BEGIN {$tag} ----\n"; + + $size = 80; + $oset = 0; + while ($size >= 64) { + $line = substr($in, $oset, 64); + $out .= $line."\n"; + $size = strlen($line); + $oset += $size; + } + + $out .= "---- END {$tag} ----\n"; + + return true; + } + + function tagfile_deformat($in, & $out, $tag) { + + $btag_val = "---- BEGIN {$tag} ----"; + $etag_val = "---- END {$tag} ----"; + + $btag_len = strlen($btag_val); + $etag_len = strlen($etag_val); + + $btag_pos = stripos($in, $btag_val); + $etag_pos = stripos($in, $etag_val); + + if (($btag_pos === false) || ($etag_pos === false)) + return false; + + $body_pos = $btag_pos + $btag_len; + $body_len = strlen($in); + $body_len -= strlen($btag_len); + $body_len -= strlen($etag_len); + + $out = substr($in, $body_pos, $body_len); + + return true; + } + + function stripos($str,$needle) { + return strpos(strtolower($str), strtolower($needle)); + } + +?>
\ No newline at end of file diff --git a/config/autoconfigbackup/parse_config_upload.php b/config/autoconfigbackup/parse_config_upload.php new file mode 100644 index 00000000..ce592966 --- /dev/null +++ b/config/autoconfigbackup/parse_config_upload.php @@ -0,0 +1,8 @@ +<?php + +if(file_exists("/usr/local/pkg/autoconfigbackup.inc")) { + require_once("/usr/local/pkg/autoconfigbackup.inc"); + upload_config(); +} + +?> diff --git a/config/autoconfigbackup/upload_config_filter.php b/config/autoconfigbackup/upload_config_filter.php new file mode 100644 index 00000000..ce592966 --- /dev/null +++ b/config/autoconfigbackup/upload_config_filter.php @@ -0,0 +1,8 @@ +<?php + +if(file_exists("/usr/local/pkg/autoconfigbackup.inc")) { + require_once("/usr/local/pkg/autoconfigbackup.inc"); + upload_config(); +} + +?> |