int allow_distro_to_pass_on;
char *submit_url[MAX_URLS];
char *build_release;
+char *core_folder;
int url_count = 0;
extern int do_unlink;
if (c)
build_release = strdup(c);
}
+ c = strstr(line, "core-folder");
+ if (c) {
+ c += 11;
+ c = strstr(c, "/");
+ if (c)
+ core_folder = strdup(c);
+ }
free(line);
}
fclose(file);
build_release = strdup("/etc/meego-release");
if (!url_count)
submit_url[url_count++] = strdup("http://crashdb.meego.com/submitbug.php");
+ if (!core_folder)
+ core_folder = strdup("/tmp/corewatcher/");
}
memset(oops, 0, sizeof(struct oops));
oops->application = strdup(appfile);
oops->text = c1;
+ oops->filename = strdup(corefile);
return oops;
}
if (!(pid = strstr(filename, ".")))
return;
- snprintf(detail_filename, 8192, "/tmp/%s.txt", ++pid);
+ snprintf(detail_filename, 8192, "%s%s.txt", core_folder, ++pid);
if ((fd = open(detail_filename, O_WRONLY | O_CREAT | O_TRUNC, 0)) != -1) {
write(fd, text, strlen(text));
fchmod(fd, 0644);
{
struct oops *oops;
char newfile[8192];
+
oops = extract_core(filename);
if (!oops) {
return;
}
- queue_backtrace(oops);
- fprintf(stderr, "---[start of coredump]---\n%s\n---[end of coredump]---\n", oops->text);
+ /* if this oops hasn't been processed before need to write details out and rename */
+ if (!strstr(filename, ".processed")) {
- /* try to write coredump text details to text file */
- write_core_detail_file(filename, oops->text);
+ fprintf(stderr, "---[start of coredump]---\n%s\n---[end of coredump]---\n", oops->text);
- sprintf(newfile,"%s.processed", filename);
- if (do_unlink)
- unlink(filename);
- else
+ /* try to write coredump text details to text file */
+ write_core_detail_file(filename, oops->text);
+
+ sprintf(newfile,"%s%s.processed", core_folder, filename);
rename(filename, newfile);
+ free(oops->filename);
+ oops->filename = strdup(newfile);
+ }
+
+ queue_backtrace(oops);
free(oops->application);
free(oops->text);
+ free(oops->filename);
free(oops);
}
if (!dir)
return 1;
- fprintf(stderr, "+ scanning...\n");
+ fprintf(stderr, "+ scanning /tmp/...\n");
do {
entry = readdir(dir);
if (!entry)
fprintf(stderr, "+ Looking at %s\n", path);
process_corefile(path);
} while (entry);
+ closedir(dir);
+
+ dir = opendir(core_folder);
+ if (!dir)
+ return 1;
+
+ fprintf(stderr, "+ scanning %s...\n", core_folder);
+ do {
+ entry = readdir(dir);
+ if (!entry)
+ break;
+ if (!strstr(entry->d_name, ".processed"))
+ continue;
+ sprintf(path, "%s%s", core_folder, entry->d_name);
+ fprintf(stderr, "+ Looking at %s\n", path);
+ process_corefile(path);
+ } while(entry);
+ closedir(dir);
if (opted_in >= 2)
submit_queue();
else if (opted_in >= 1)
ask_permission();
- closedir(dir);
return 1;
}
# Location for the MeeGo build release file
#
-release-info = /etc/meego-release
\ No newline at end of file
+release-info = /etc/meego-release
+
+#
+# Location to store meego coredumps after they are processed
+#
+
+core-folder = /tmp/corewatcher/
\ No newline at end of file
struct oops *next;
char *application;
char *text;
+ char *filename;
unsigned int checksum;
};
extern char *submit_url[MAX_URLS];
extern int url_count;
extern char *build_release;
+extern char *core_folder;
extern int testmode;
extern int pinged;
*/
static struct oops *queued_backtraces;
static int newoops;
+static int unsubmittedoops;
/* For communicating details to the applet, we write the
* details in a file, and provide the filename to the applet
new->checksum = sum;
new->application = strdup(oops->application);
new->text = strdup(oops->text);
+ new->filename = strdup(oops->filename);
queued_backtraces = new;
- newoops = 1;
+ unsubmittedoops = 1;
}
curl_easy_setopt(handle, CURLOPT_HTTPPOST, post);
curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, writefunction);
result = curl_easy_perform(handle);
-
curl_formfree(post);
- dbus_say_thanks(oops, result_url);
+
+ if (!result) {
+ struct oops *new;
+ new = malloc(sizeof(struct oops));
+ memset(new, 0, sizeof(struct oops));
+ new->next = queued_backtraces;
+ new->checksum = oops->checksum;
+ new->application = strdup(oops->application);
+ new->text = strdup(oops->text);
+ queued_backtraces = new;
+ newoops = 1;
+ } else {
+ char newfile[8192];
+ char oldfile[8192];
+ char *c;
+
+ memset(newfile, 0, sizeof(newfile));
+ memset(oldfile, 0, sizeof(oldfile));
+
+ strncpy(oldfile, oops->filename, 8192);
+ oldfile[8191] = '\0';
+ c = strstr(oldfile, ".processed");
+ if (c) {
+ oldfile[strlen(oldfile) - strlen(c)] = '\0';
+ }
+
+ sprintf(newfile,"%s%s.submitted", core_folder, oldfile);
+ if (do_unlink)
+ unlink(oops->filename);
+ else
+ rename(oops->filename, newfile);
+
+ dbus_say_thanks(oops, result_url);
+ }
next = oops->next;
free(oops->text);
void ask_permission(void)
{
- if (!newoops && !pinged)
+ if (!newoops && !pinged && !unsubmittedoops)
return;
pinged = 0;
newoops = 0;
+ unsubmittedoops = 0;
if (queued_backtraces) {
write_detail_file();
dbus_ask_permission(detail_filename);