150
149
"InstallationMedia",
151
150
/* Dumps for debugging iwlwifi firmware crashes */
154
/* Fields we do not care about: */
152
/* System Image information from imaged systems */
158
/* Fields that we don't ever need, always */
159
static const char* unacceptable_fields[] = {
160
/* We do not need these since we retrace with ddebs on errors */
156
164
/* We would only want this to see how many bugs would otherwise go
158
/* "UnreportableReason", */
166
"UnreportableReason",
160
168
/* We'll have our own count in the database. */
161
/* "CrashCounter", */
171
/* MarkForUpload is redundant since the crash was uploaded. */
168
is_acceptable_field (const char* field)
180
is_in_field_list (const char* field, const char * field_list[])
172
184
g_return_val_if_fail (field, FALSE);
174
p = acceptable_fields;
176
188
if (strcmp (*p, field) == 0)
384
395
while (token_p < end && *token_p != '\n')
388
/* The length of this value string */
389
value_length = token_p - p;
391
/* Space for the leading newline too. */
392
value_pos = value_p - value;
393
value = g_realloc (value, value_pos + 1 + value_length + 1);
394
value_p = value + value_pos;
398
value = g_realloc (value, value_length + 1);
398
/* The length of this value string */
399
value_length = token_p - p;
401
/* Space for the leading newline too. */
402
value_pos = value_p - value;
403
if (INT_MAX - (1 + value_length + 1) < value_pos) {
405
g_quark_from_static_string ("whoopsie-quark"),
406
0, "Report value too long.");
401
memcpy (value_p, p, value_length);
402
value_p[value_length] = '\0';
403
for (char *c = value_p; c < value_p + value_length; c++)
404
/* If c is a control character. */
405
if (*c >= '\0' && *c < ' ')
407
value_p += value_length;
408
g_hash_table_insert (hash_table, key, value ? value : "");
409
value = g_realloc (value, value_pos + 1 + value_length + 1);
410
value_p = value + value_pos;
414
value = g_realloc (value, value_length + 1);
417
memcpy (value_p, p, value_length);
418
value_p[value_length] = '\0';
419
for (char *c = value_p; c < value_p + value_length; c++)
420
/* If c is a control character. */
421
if (*c >= '\0' && *c < ' ')
423
value_p += value_length;
424
g_hash_table_insert (hash_table, key, value ? value : "");
412
427
/* Reset the value pointer. */
462
473
if ((token_p - p) == 0) {
463
474
/* Empty value. The key likely has a child. */
465
} else if (ignore_field) {
468
477
if (!strncmp ("base64", p, 6)) {
469
478
/* Just a marker that the following lines are base64
485
g_hash_table_insert (hash_table, key, value ? value : "");
494
g_hash_table_insert (hash_table, key, value ? value : "");
490
497
g_mapped_file_unref (fp);
499
/* Remove entries that we don't want to send */
503
g_hash_table_iter_init(&iter, hash_table);
505
/* We want everything that is in our white list or less than
506
1 KB so that we don't end up DoSing our database. */
507
while (g_hash_table_iter_next(&iter, &key, &value)) {
508
if (!is_in_field_list((const char *)key, unacceptable_fields)) {
509
if (is_in_field_list((const char *)key, acceptable_fields))
511
if (strlen((const char *)value) < 1024)
515
g_hash_table_iter_steal(&iter);
516
destroy_key_and_value(key, value, NULL);
491
520
return hash_table;
541
570
curl_slist_free_all(list);
543
572
curl_easy_getinfo (curl, CURLINFO_RESPONSE_CODE, &response_code);
573
/* this actually what curl replied with */
545
574
log_msg ("Sent; server replied with: %s\n",
546
575
curl_easy_strerror (result_code));
547
576
log_msg ("Response code: %ld\n", response_code);
567
596
split_string (response_data, &command);
569
598
if (strcmp (command, "CORE") == 0) {
599
log_msg ("Reported OOPS ID %.36s\n", response_data);
570
600
core = g_hash_table_lookup (report, "CoreDump");
571
601
arch = g_hash_table_lookup (report, "Architecture");
572
602
if (core && arch) {
575
605
* their Internet connection, and we can always count on
576
606
* the next person in line to send it. */
577
607
log_msg ("Upload of the core dump failed.\n");
608
} else if (strcmp (command, "OOPSID") == 0) {
609
log_msg ("Reported OOPS ID %.36s\n", response_data);
579
611
log_msg ("Asked for a core dump that we don't have.\n");
612
} else if (strcmp (command, "OOPSID") == 0) {
613
log_msg ("Reported OOPS ID %.36s\n", response_data);
581
615
log_msg ("Got command: %s\n", command);
681
715
} else if (online_state && parse_and_upload_report (crash_file)) {
682
716
if (!mark_handled (crash_file))
683
log_msg ("Unable to mark report as seen (%s)\n", crash_file);
717
log_msg ("Unable to mark report as seen (%s) removing it.\n", crash_file);
718
g_unlink (crash_file);
687
721
g_free (upload_file);
688
722
g_free (crash_file);
690
724
g_dir_close (dir);
726
return G_SOURCE_CONTINUE;
695
729
void daemonize (void)
957
993
whoopsie_identifier);
996
/* Publish whoopsie-id */
997
g_file_set_contents (WHOOPSIE_ID_PATH, whoopsie_identifier, -1, NULL);
998
chmod (WHOOPSIE_ID_PATH, 00600);
960
1000
create_crash_directory ();
962
1002
drop_privileges (&err);