Commit e7a233b5 authored by Franco Fichtner's avatar Franco Fichtner

crash reporter: create new reports when necessary; closes #241

Also adds a custom user agent to make it easier to filter by version
and moves the crash reporter to a more visible location in the system
category.  :)
parent b2a5b917
......@@ -10,18 +10,15 @@
<CertificateAuthority VisibleName="Certificate Authority" url="/system_camanager.php*"/>
<CertificationRevocation VisibleName="Certification Revocation" url="/system_crlmanager.php*"/>
</Certificates>
<CrashReporter VisibleName="Crash Reporter" url="/crash_reporter.php"/>
<Firmware url="/ui/core/firmware/"/>
<HighAvailSync VisibleName="High Availability" url="/system_hasync.php"/>
<Routing url="/system_gateways.php">
<Routes url="/system_routes.php"/>
<RoutesEdit url="/system_routes_edit.php*"/>
<GatewayGroups url="/system_gateway_groups.php"/>
<GatewayGroupsEdit url="/system_gateway_groups_edit.php*"/>
</Routing>
<Settings url="/system_general.php">
<General VisibleName="General" url="/system_general.php"/>
<Admin_Access VisibleName="Admin Access" url="/system_advanced_admin.php"/>
......@@ -31,18 +28,14 @@
<System_Tunables VisibleName="System Tunables" url="/system_advanced_sysctl.php"/>
<Notifications url="/system_advanced_notifications.php"/>
</Settings>
<SetupWizard VisibleName="Setup Wizard" url="/wizard.php?xml=setup_wizard.xml"/>
<UserManager VisibleName="User Manager" url="/system_usermanager.php">
<Users url="/system_usermanager.php"/>
<Groups url="/system_groupmanager.php"/>
<Settings url="/system_usermanager_settings.php"/>
<Servers url="/system_authservers.php*"/>
</UserManager>
</System>
<Interfaces order="2" cssClass="glyphicon glyphicon-wrench">
<Assign VisibleName="(Assign)" order="999" url="/interfaces_assign.php">
<InterfaceAssignments VisibleName="Interface Addignments" url="/interfaces_assign.php"/>
......@@ -243,7 +236,6 @@
<BackupRestore VisibleName="Backup &amp; Restore" url="/diag_backup.php">
<History url="/diag_confbak.php"/>
</BackupRestore>
<CrashReporter VisibleName="Crash Reporter" url="/crash_reporter.php"/>
<DNSLookup VisibleName="DNS Lookup" url="/diag_dns.php"/>
<FactoryDefaults VisibleName="Factory Defaults" url="/diag_defaults.php"/>
<HaltSystem VisibleName="Halt System" url="/diag_halt.php"/>
......
......@@ -33,7 +33,7 @@ require_once("captiveportal.inc");
define("FILE_SIZE", 450000);
function upload_crash_report($files)
function upload_crash_report($files, $agent)
{
global $g;
......@@ -53,7 +53,7 @@ function upload_crash_report($files)
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_VERBOSE, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible;)');
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_SAFE_UPLOAD, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
......@@ -64,7 +64,7 @@ function upload_crash_report($files)
return !$response;
}
$pgtitle = array(gettext("Diagnostics"),gettext("Crash Reporter"));
$pgtitle = array(gettext('System'), gettext('Crash Reporter'));
include('head.inc');
$last_version = '/usr/local/opnsense/version/opnsense.last';
......@@ -79,6 +79,9 @@ $crash_report_header = sprintf(
shell_exec('/sbin/sysctl -b kern.hostuuid')
);
$pkgver = explode('-', trim(file_get_contents('/usr/local/opnsense/version/opnsense')));
$user_agent = $g['product_name'] . '/' . $pkgver[0];
?>
<body>
......@@ -116,7 +119,7 @@ $crash_report_header = sprintf(
$files_to_upload = glob('/var/crash/*');
echo gettext('ok') . '<br/>' . gettext('Uploading...');
flush();
$resp = upload_crash_report($files_to_upload);
$resp = upload_crash_report($files_to_upload, $user_agent);
echo ($resp ? gettext('ok') : gettext('failed')) . '</p>';
array_map('unlink', $files_to_upload);
} elseif (isset($_POST['Submit']) && $_POST['Submit'] == 'no') {
......@@ -124,17 +127,7 @@ $crash_report_header = sprintf(
@unlink('/tmp/PHP_errors.log');
}
if (get_crash_report(true) == '') {
echo '<br/><p><strong>';
if (isset($_POST['Submit']) && $_POST['Submit'] == 'yes') {
echo gettext('Thank you for submitting this crash report.');
} elseif ($_POST['Submit'] == 'no') {
echo gettext('Please consider submitting a crash report if the error persists.');
} else {
echo gettext('Luckily we have not detected a programming bug.');
}
echo '</strong></p>';
} else {
if (get_crash_report(true) != '' || (isset($_POST['Submit']) && $_POST['Submit'] == 'new')) {
$crash_files = glob("/var/crash/*");
$crash_reports['System Information'] = trim($crash_report_header);
$php_errors = @file_get_contents('/tmp/PHP_errors.log');
......@@ -161,6 +154,19 @@ $crash_report_header = sprintf(
foreach ($crash_reports as $report => $content) {
echo "<p>{$report}:<br/><pre>{$content}</pre></p>";
}
} else {
if (isset($_POST['Submit']) && $_POST['Submit'] == 'yes') {
echo '<br/><p><strong>';
echo gettext('Thank you for submitting this crash report.');
echo '</strong></p><br/>';
} elseif ($_POST['Submit'] == 'no') {
echo '<br/><p><strong>';
echo gettext('Please consider submitting a crash report if the error persists.');
echo '</strong></p><br/>';
} else {
echo '<br/><button name="Submit" type="submit" class="btn btn-primary pull-right" value="new">' . gettext('Report an issue') . '</button>';
echo '<p><strong>' . gettext('Luckily we have not detected a programming bug.') . '</strong></p><br/>';
}
}
?>
</div>
......
......@@ -625,10 +625,12 @@ date_default_timezone_set($timezone);
function get_crash_report($pedantic = false)
{
global $g;
$savemsg = "{$g['product_name']} has detected a crash report or programming bug. Click <a href='crash_reporter.php'>here</a> for more information.";
$skip_files = array('.', '..', 'minfree', '');
$savemsg = sprintf(
gettext('A problem was detected. Click %shere%s for more information.'),
'<a href="/crash_reporter.php">',
'</a>'
);
$skip_files = array('.', '..', 'minfree', 'bounds', '');
$count = 0;
if (file_exists('/tmp/PHP_errors.log')) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment