--- kerneloops-0.12+git20090217.orig/dmesg.c +++ kerneloops-0.12+git20090217/dmesg.c @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -36,101 +37,119 @@ #include "kerneloops.h" -static char **linepointer; +struct line_info { + char *ptr; + char level; +}; -static char *linelevel; +static struct line_info *lines_info; +static int lines_info_alloc; static int linecount; -#define MAX(A,B) ((A) > (B) ? (A) : (B)) +#define MIN(A,B) ((A) < (B) ? (A) : (B)) +#define REALLOC_CHUNK 1000 +static int set_line_info(int index, char *linepointer, char linelevel) +{ + if (index >= lines_info_alloc) { + struct line_info *new_info; + new_info = realloc(lines_info, + (lines_info_alloc + REALLOC_CHUNK) * sizeof(struct line_info)); + if (!new_info) + return -1; + lines_info_alloc += REALLOC_CHUNK; + lines_info = new_info; + } + + lines_info[index].ptr = linepointer; + lines_info[index].level = linelevel; + return 0; +} /* * This function splits the dmesg buffer data into lines - * (null terminated). The linepointer array is assumed to be - * allocated already. + * (null terminated). */ -static void fill_linepointers(char *buffer, int remove_syslog) +static int fill_lineinfo(char *buffer, size_t buflen, int remove_syslog) { - char *c; + char *c, *linepointer, linelevel; linecount = 0; + if (!buflen) + return 0; + buffer[buflen - 1] = '\n'; /* the buffer usually ends with \n, but let's make sure */ c = buffer; - while (c) { + while (c < buffer + buflen) { int len = 0; char *c9; - c9 = strchr(c, '\n'); - if (c9) - len = c9 - c; + c9 = memchr(c, '\n', buffer + buflen - c); /* a \n will always be found */ + assert(c9); + len = c9 - c; /* in /var/log/messages, we need to strip the first part off, upto the 3rd ':' */ if (remove_syslog) { char *c2; + int i; /* skip non-kernel lines */ c2 = memmem(c, len, "kernel:", 7); if (!c2) c2 = memmem(c, len, "kerneloops:", 11); - if (!c2) { - c2 = c9; - if (c2) { - c = c2 + 1; - continue; - } else - break; + if (!c2) + goto next_line; + + /* skip to message in "Jan 01 01:23:45 hostname kernel: message" */ + for (i = 0; i < 3; i++) { + c = memchr(c, ':', len); + if (!c) + goto next_line; + c++; + len = c9 - c; } - c = strchr(c, ':'); - if (!c) - break; - c++; - c = strchr(c, ':'); - if (!c) - break; c++; - c = strchr(c, ':'); - if (!c) - break; - c++; - if (*c) - c++; + len--; } - linepointer[linecount] = c; - linelevel[linecount] = 0; + linepointer = c; + linelevel = 0; /* store and remove kernel log level */ - if (*c == '<' && *(c+2) == '>') { - linelevel[linecount] = *(c+1); - c = c + 3; - linepointer[linecount] = c; + if (len >= 3 && *c == '<' && *(c+2) == '>') { + linelevel = *(c+1); + c += 3; + len -= 3; + linepointer = c; } /* remove jiffies time stamp counter if present */ if (*c == '[') { char *c2, *c3; - c2 = strchr(c, '.'); - c3 = strchr(c, ']'); + c2 = memchr(c, '.', len); + c3 = memchr(c, ']', len); if (c2 && c3 && (c2 < c3) && (c3-c) < 14 && (c2-c) < 8) { - c = c3+1; + c = c3 + 1; if (*c == ' ') c++; - linepointer[linecount] = c; + len = c9 - c; + linepointer = c; } } - c = strchr(c, '\n'); /* turn the \n into a string termination */ - if (c) { - *c = 0; - c = c+1; - } + assert(c + len == c9); + *c9 = '\0'; /* turn the \n into a string termination */ /* if we see our own marker, we know we submitted everything upto here already */ - if (strstr(linepointer[linecount], "www.kerneloops.org")) { + if (memmem(linepointer, len, "www.kerneloops.org", 18)) { linecount = 0; - linepointer[0] = NULL; + lines_info[0].ptr = NULL; } + if (set_line_info(linecount, linepointer, linelevel) < 0) + return -1; linecount++; +next_line: + c = c9 + 1; } + return 0; } - /* * extract_oops tries to find oops signatures in a log */ @@ -142,23 +161,17 @@ int oopsend; int inbacktrace = 0; - linepointer = calloc(buflen+1, sizeof(char*)); - if (!linepointer) - return; - linelevel = calloc(buflen+1, sizeof(char)); - if (!linelevel) { - free(linepointer); - linepointer = NULL; - return; - } + lines_info = NULL; + lines_info_alloc = 0; - fill_linepointers(buffer, remove_syslog); + if (fill_lineinfo(buffer, buflen, remove_syslog) < 0) + goto fail; oopsend = linecount; i = 0; while (i < linecount) { - char *c = linepointer[i]; + char *c = lines_info[i].ptr; if (c == NULL) { i++; @@ -187,7 +200,9 @@ if (strstr(c, "NETDEV WATCHDOG")) oopsstart = i; if (strstr(c, "WARNING:") && - !strstr(c, "appears to be on the same physical disk")) + !strstr(c, "appears to be on the same physical disk") && + !strstr(c, "ECC is NOT currently enabled by the BIOS") && + !strstr(c, "ECC is disabled by BIOS. Module will NOT be loaded.")) oopsstart = i; if (strstr(c, "Unable to handle kernel")) oopsstart = i; @@ -203,7 +218,7 @@ oopsstart = i-3; if (oopsstart >= 0 && testmode) { printf("Found start of oops at line %i\n", oopsstart); - printf(" start line is -%s-\n", linepointer[oopsstart]); + printf(" start line is -%s-\n", lines_info[oopsstart].ptr); if (oopsstart != i) printf(" trigger line is -%s-\n", c); } @@ -213,7 +228,7 @@ int i2; i2 = i+1; while (i2 < linecount && i2 < (i+50)) { - if (strstr(linepointer[i2], "---[ end trace")) { + if (strstr(lines_info[i2].ptr, "---[ end trace")) { inbacktrace = 1; i = i2; break; @@ -224,15 +239,15 @@ } /* a calltrace starts with "Call Trace:" or with the " [<.......>] function+0xFF/0xAA" pattern */ - if (oopsstart >= 0 && strstr(linepointer[i], "Call Trace:")) + if (oopsstart >= 0 && strstr(lines_info[i].ptr, "Call Trace:")) inbacktrace = 1; - else if (oopsstart >= 0 && inbacktrace == 0 && strlen(linepointer[i]) > 8) { + else if (oopsstart >= 0 && inbacktrace == 0 && strlen(lines_info[i].ptr) > 8) { char *c1, *c2, *c3; - c1 = strstr(linepointer[i], ">]"); - c2 = strstr(linepointer[i], "+0x"); - c3 = strstr(linepointer[i], "/0x"); - if (linepointer[i][0] == ' ' && linepointer[i][1] == '[' && linepointer[i][2] == '<' && c1 && c2 && c3) + c1 = strstr(lines_info[i].ptr, ">]"); + c2 = strstr(lines_info[i].ptr, "+0x"); + c3 = strstr(lines_info[i].ptr, "/0x"); + if (lines_info[i].ptr[0] == ' ' && lines_info[i].ptr[1] == '[' && lines_info[i].ptr[2] == '<' && c1 && c2 && c3) inbacktrace = 1; } else @@ -240,38 +255,38 @@ if (oopsstart >= 0 && inbacktrace > 0) { char c2, c3; - c2 = linepointer[i][0]; - c3 = linepointer[i][1]; + c2 = lines_info[i].ptr[0]; + c3 = lines_info[i].ptr[1]; /* line needs to start with " [" or have "] ["*/ if ((c2 != ' ' || c3 != '[') && - strstr(linepointer[i], "] [") == NULL && - strstr(linepointer[i], "--- Exception") == NULL && - strstr(linepointer[i], " LR =") == NULL && - strstr(linepointer[i], "<#DF>") == NULL && - strstr(linepointer[i], "") == NULL && - strstr(linepointer[i], "") == NULL && - strstr(linepointer[i], "<>") == NULL) + strstr(lines_info[i].ptr, "] [") == NULL && + strstr(lines_info[i].ptr, "--- Exception") == NULL && + strstr(lines_info[i].ptr, " LR =") == NULL && + strstr(lines_info[i].ptr, "<#DF>") == NULL && + strstr(lines_info[i].ptr, "") == NULL && + strstr(lines_info[i].ptr, "") == NULL && + strstr(lines_info[i].ptr, "<>") == NULL) oopsend = i-1; /* oops lines are always more than 8 long */ - if (strlen(linepointer[i]) < 8) + if (strlen(lines_info[i].ptr) < 8) oopsend = i-1; /* single oopses are of the same loglevel */ - if (linelevel[i] != prevlevel) + if (lines_info[i].level != prevlevel) oopsend = i-1; /* The Code: line means we're done with the backtrace */ - if (strstr(linepointer[i], "Code:") != NULL) + if (strstr(lines_info[i].ptr, "Code:") != NULL) oopsend = i; - if (strstr(linepointer[i], "Instruction dump::") != NULL) + if (strstr(lines_info[i].ptr, "Instruction dump::") != NULL) oopsend = i; /* if a new oops starts, this one has ended */ - if (strstr(linepointer[i], "WARNING:") != NULL && oopsstart != i) + if (strstr(lines_info[i].ptr, "WARNING:") != NULL && oopsstart != i) oopsend = i-1; - if (strstr(linepointer[i], "Unable to handle") != NULL && oopsstart != i) + if (strstr(lines_info[i].ptr, "Unable to handle") != NULL && oopsstart != i) oopsend = i-1; /* kernel end-of-oops marker */ - if (strstr(linepointer[i], "---[ end trace") != NULL) + if (strstr(lines_info[i].ptr, "---[ end trace") != NULL) oopsend = i; if (oopsend <= i) { @@ -281,12 +296,12 @@ len = 2; for (q = oopsstart; q <= oopsend; q++) - len += strlen(linepointer[q])+1; + len += strlen(lines_info[q].ptr)+1; oops = calloc(len, 1); for (q = oopsstart; q <= oopsend; q++) { - strcat(oops, linepointer[q]); + strcat(oops, lines_info[q].ptr); strcat(oops, "\n"); } /* too short oopses are invalid */ @@ -298,7 +313,7 @@ free(oops); } } - prevlevel = linelevel[i]; + prevlevel = lines_info[i].level; i++; if (oopsstart > 0 && i-oopsstart > 50) { oopsstart = -1; @@ -319,15 +334,15 @@ oopsend = i-1; len = 2; - while (oopsend > 0 && linepointer[oopsend] == NULL) + while (oopsend > 0 && lines_info[oopsend].ptr == NULL) oopsend--; for (q = oopsstart; q <= oopsend; q++) - len += strlen(linepointer[q])+1; + len += strlen(lines_info[q].ptr)+1; oops = calloc(len, 1); for (q = oopsstart; q <= oopsend; q++) { - strcat(oops, linepointer[q]); + strcat(oops, lines_info[q].ptr); strcat(oops, "\n"); } /* too short oopses are invalid */ @@ -338,10 +353,9 @@ oopsend = linecount; free(oops); } - free(linepointer); - free(linelevel); - linepointer = NULL; - linelevel = NULL; +fail: + free(lines_info); + lines_info = NULL; } int scan_dmesg(void __unused *unused) @@ -366,7 +380,7 @@ struct stat statb; FILE *file; int ret; - size_t buflen; + size_t buflen, nread; memset(&statb, 0, sizeof(statb)); @@ -380,13 +394,13 @@ * to /var/log/messages before we read it in... we try to * deal with it by reading at most 1023 bytes extra. If there's * more than that.. any oops will be in dmesg anyway. - * Do not try to allocate an absurt amount of memory; ignore + * Do not try to allocate an absurd amount of memory; ignore * older log messages because they are unlikely to have * sufficiently recent data to be useful. 32MB is more * than enough; it's not worth looping through more log * if the log is larger than that. */ - buflen = MAX(statb.st_size+1024, 32*1024*1024); + buflen = MIN(statb.st_size+1024, 32*1024*1024); buffer = calloc(buflen, 1); assert(buffer != NULL); @@ -396,11 +410,11 @@ return; } fseek(file, -buflen, SEEK_END); - ret = fread(buffer, 1, buflen-1, file); + nread = fread(buffer, 1, buflen, file); fclose(file); - if (ret > 0) - extract_oops(buffer, buflen-1, issyslog); + if (nread > 0) + extract_oops(buffer, nread, issyslog); free(buffer); if (opted_in >= 2) submit_queue(); --- kerneloops-0.12+git20090217.orig/kerneloops.h +++ kerneloops-0.12+git20090217/kerneloops.h @@ -45,6 +45,7 @@ extern int opted_in; extern int allow_distro_to_pass_on; extern char *submit_url; +extern char *submit_pipe; extern char *log_file; extern int testmode; --- kerneloops-0.12+git20090217.orig/kerneloops-submit.c +++ kerneloops-0.12+git20090217/kerneloops-submit.c @@ -0,0 +1,121 @@ +/* + * Copyright 2007, Intel Corporation + * + * This file is part of kerneloops.org + * + * This program file is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program in a file named COPYING; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Authors: + * Arjan van de Ven + * James Westby + */ + +#include +#include +#include +#include +#include +#include + +#include "kerneloops.h" + + +static void write_logfile(int count, char *result_url) +{ + openlog("kerneloops-submit", 0, LOG_KERN); + syslog(LOG_WARNING, "Submitted %i kernel oopses to www.kerneloops.org", count); + if (result_url && result_url[0]) + syslog(LOG_WARNING, "kerneloops.org: oops is posted as %s", result_url); + closelog(); +} + +static char result_url[4096]; + +static size_t writefunction( void *ptr, size_t size, size_t nmemb, void __attribute((unused)) *stream) +{ + char *c, *c1, *c2; + c = malloc(size*nmemb + 1); + memset(c, 0, size*nmemb + 1); + memcpy(c, ptr, size*nmemb); + c1 = strstr(c, "201 "); + if (c1) { + c1+=4; + c2 = strchr(c1, '\n'); + if (c2) *c2 = 0; + strncpy(result_url, c1, 4095); + } + return size * nmemb; +} + +void submit_oops(char *text) +{ + int result; + CURL *handle; + struct curl_httppost *post = NULL; + struct curl_httppost *last = NULL; + + handle = curl_easy_init(); + + curl_easy_setopt(handle, CURLOPT_URL, submit_url); + + /* set up the POST data */ + curl_formadd(&post, &last, + CURLFORM_COPYNAME, "oopsdata", + CURLFORM_COPYCONTENTS, text, CURLFORM_END); + + if (allow_distro_to_pass_on) { + curl_formadd(&post, &last, + CURLFORM_COPYNAME, "pass_on_allowed", + CURLFORM_COPYCONTENTS, "yes", CURLFORM_END); + } + + curl_easy_setopt(handle, CURLOPT_HTTPPOST, post); + curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, writefunction); + result = curl_easy_perform(handle); + + write_logfile(1, result_url); + + if (result_url) + printf("%s\n", result_url); + + curl_formfree(post); + curl_easy_cleanup(handle); +} + +int main(int __unused argc, char __unused **argv) +{ + char text[10000]; + size_t resp; + char *buf = text; + size_t to_read = 10000; + + while (!feof(stdin) && !ferror(stdin)) { + resp = fread(buf, 1, to_read, stdin); + buf = buf + resp; + to_read = to_read - resp; + } + + if (ferror(stdin)) { + write_logfile(1, "ferror(stdin)\n"); + return 1; + } + + read_config_file("/etc/kerneloops.conf"); + + submit_oops(text); + + return 0; +} --- kerneloops-0.12+git20090217.orig/kerneloops.conf +++ kerneloops-0.12+git20090217/kerneloops.conf @@ -37,5 +37,10 @@ # # Path to syslog file containing full kernel logging output # +log-file = /var/log/kern.log -log-file = /var/log/messages +# +# Script or program to pipe oops submits to +# Comment out for no pipe submission +# +submit-pipe = /usr/share/apport/kernel_oops --- kerneloops-0.12+git20090217.orig/kerneloops.c +++ kerneloops-0.12+git20090217/kerneloops.c @@ -24,10 +24,10 @@ #include #include +#include #include #include #include -#include #include #include @@ -119,7 +119,6 @@ dbus_message_append_args (message, DBUS_TYPE_STRING, &url, DBUS_TYPE_INVALID); dbus_connection_send(bus, message, NULL); dbus_message_unref(message); - syslog(LOG_WARNING, "kerneloops.org: oops is posted as %s", url); } message = dbus_message_new_signal("/org/kerneloops/submit/sent", @@ -185,12 +184,13 @@ dbus_connection_add_filter(bus, got_message, NULL, NULL); } - /* we scan dmesg before /var/log/messages; dmesg is a more accurate source normally */ - scan_dmesg(NULL); /* during boot... don't go too fast and slow the system down */ if (!testmode) sleep(10); - scan_filename(log_file, 1); + /* we scan dmesg before /var/log/messages; dmesg is a more accurate source normally */ + scan_dmesg(NULL); + /* Can cause an OOPS to be reported multiple times LP: #429000 */ + /* scan_filename(log_file, 1); */ if (argc > 2 && strstr(argv[1], "--file")) scan_filename(argv[2], 1); --- kerneloops-0.12+git20090217.orig/kerneloops.dbus +++ kerneloops-0.12+git20090217/kerneloops.dbus @@ -7,7 +7,7 @@ - + --- kerneloops-0.12+git20090217.orig/configfile.c +++ kerneloops-0.12+git20090217/configfile.c @@ -25,8 +25,10 @@ #include #include +#include #include #include +#include #include "kerneloops.h" @@ -37,6 +39,7 @@ int opted_in; int allow_distro_to_pass_on; char *submit_url; +char *submit_pipe; char *log_file; @@ -59,6 +62,9 @@ free(line); continue; } + c = strchr(line, '\n'); + if (c != NULL) + *c = '\0'; c = strstr(line, "allow-submit "); if (c) { c += 13; @@ -80,6 +86,17 @@ if (c) submit_url = strdup(c); } + c = strstr(line, "submit-pipe "); + if (c) { + c += 12; + while(*c) { + if ( !isspace(*c) && *c != '=') + break; + c++; + } + if (*c) + submit_pipe = strdup(c); + } c = strstr(line, "log-file "); if (c) { c += 9; --- kerneloops-0.12+git20090217.orig/Makefile +++ kerneloops-0.12+git20090217/Makefile @@ -12,16 +12,16 @@ CFLAGS := -O2 -g -fstack-protector -D_FORTIFY_SOURCE=2 -Wall -W -Wstrict-prototypes -Wundef -fno-common -Werror-implicit-function-declaration -Wdeclaration-after-statement -Wformat -Wformat-security -Werror=format-security -MY_CFLAGS := `pkg-config --cflags libnotify gtk+-2.0` +MY_CFLAGS := `pkg-config --cflags libnotify gtk+-2.0 dbus-glib-1` # # pkg-config tends to make programs pull in a ton of libraries, not all # are needed. -Wl,--as-needed tells the linker to just drop unused ones, # and that makes the applet load faster and use less memory. # -LDF_A := -Wl,--as-needed `pkg-config --libs libnotify gtk+-2.0` +LDF_A := -Wl,--as-needed `pkg-config --libs libnotify gtk+-2.0 dbus-glib-1` LDF_D := -Wl,--as-needed `pkg-config --libs glib-2.0 dbus-glib-1` `curl-config --libs` -Wl,"-z relro" -Wl,"-z now" -all: kerneloops kerneloops-applet kerneloops.8.gz +all: kerneloops kerneloops-applet kerneloops-submit kerneloops.8.gz noui: kerneloops kerneloops.8.gz @@ -36,11 +36,14 @@ kerneloops-applet: kerneloops-applet.o gcc kerneloops-applet.o $(LDF_A)-o kerneloops-applet +kerneloops-submit: kerneloops-submit.o configfile.o + gcc kerneloops-submit.o configfile.o $(LDF_D) -o kerneloops-submit + kerneloops.8.gz: kerneloops.8 gzip -9 -c $< > $@ clean: - rm -f *~ *.o *.ko DEADJOE kerneloops kerneloops-applet *.out */*~ kerneloops.8.gz + rm -f *~ *.o *.ko DEADJOE kerneloops kerneloops-applet *.out */*~ kerneloops.8.gz test/*.dbg @(cd po/ && $(MAKE) $@) dist: clean @@ -58,6 +61,10 @@ -mkdir -p $(DESTDIR)$(SBINDIR) install -m 0755 kerneloops $(DESTDIR)$(SBINDIR)/ +install-kerneloops-submit: kerneloops-submit + -mkdir -p $(DESTDIR)$(BINDIR) + install -m 0755 kerneloops-submit $(DESTDIR)$(BINDIR)/ + install-applet: kerneloops-applet -mkdir -p $(DESTDIR)$(BINDIR) -mkdir -p $(DESTDIR)/etc/xdg/autostart @@ -66,9 +73,9 @@ desktop-file-install --mode 0644 --dir=$(DESTDIR)/etc/xdg/autostart/ kerneloops-applet.desktop install -m 0644 icon.png $(DESTDIR)/usr/share/kerneloops/icon.png -install: install-system install-kerneloops install-applet +install: install-system install-kerneloops install-kerneloops-submit install-applet -install-noui: install-system install-kerneloops +install-noui: install-system install-kerneloops install-kerneloops-submit # This is for translators. To update your po with new strings, do : --- kerneloops-0.12+git20090217.orig/kerneloops.init +++ kerneloops-0.12+git20090217/kerneloops.init @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # kerneloops # @@ -11,8 +11,8 @@ # ### BEGIN INIT INFO # Provides: kerneloops -# Default-Start: 3 4 5 -# Default-Stop: 0 1 2 6 +# Default-Start: 2 3 4 5 +# Default-Stop: 1 # Required-Start: $local_fs $remote_fs $named $network $time $syslog # Required-Stop: $local_fs $remote_fs $syslog # Short-Description: Tool to automatically collect and submit kernel crash signatures @@ -22,31 +22,37 @@ ### END INIT INFO # Source function library. -. /etc/rc.d/init.d/functions +. /lib/lsb/init-functions exec="/usr/sbin/kerneloops" prog=$(basename $exec) +service="Kernel Oops catching service" +pidfile=/var/run/$prog.pid sconf="/etc/kerneloops.conf" -lockfile=/var/lock/subsys/$prog +enabled=1 -[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog +[ -x "$exec" ] || exit 0 + +[ -e /etc/default/$prog ] && . /etc/default/$prog + +[ "$enabled" = "1" ] || exit 0 start() { - echo -n $"Starting $prog:" - daemon $prog $OPTS + log_daemon_msg "Starting $service" "$prog" + start-stop-daemon --start --quiet --oknodo --chuid kernoops:adm --pidfile $pidfile --exec $exec retval=$? - echo - [ $retval -eq 0 ] && touch $lockfile + pidof -s kerneloops > $pidfile + log_end_msg "$retval" return $retval } stop() { - echo -n $"Stopping $prog: " - killproc $prog + log_daemon_msg "Stopping $service" "$prog" + start-stop-daemon --stop --quiet --oknodo --pidfile $pidfile retval=$? - echo - [ $retval -eq 0 ] && rm -f $lockfile + rm -f $pidfile + log_end_msg "$retval" return $retval } @@ -64,7 +70,7 @@ } fdr_status() { - status $prog + status_of_proc -p $pidfile $prog "$service" } @@ -79,7 +85,7 @@ fdr_status ;; condrestart|try-restart) - [ -f $lockfile ] || restart + pidof kerneloops >/dev/null || restart ;; *) echo $"Usage: $0 {start|stop|status|restart|try-restart|reload|force-reload}" --- kerneloops-0.12+git20090217.orig/submit.c +++ kerneloops-0.12+git20090217/submit.c @@ -25,15 +25,16 @@ #define _BSD_SOURCE #include #include +#include #include +#include #include #include #include +#include #include -#include - #include "kerneloops.h" @@ -84,6 +85,48 @@ return temp; } +/* Pipe the oops into another program for submission + * to other reporting data sinks. + * Silently return if the pipe executable/script is not + * there. This allows for safe removal of the other package + * without major panic attacks and log file chatter. + */ +static void pipe_oops(char *oops) { + FILE *pipe_file = NULL; + int err; + size_t wrote; + + if (submit_pipe && access(submit_pipe, X_OK) == 0) + ; + else + return; + + openlog("kerneloops", 0, LOG_KERN); + pipe_file = popen(submit_pipe, "w"); + if (pipe_file) { + wrote = fwrite(oops, 1, strlen(oops), pipe_file); + if (wrote == strlen(oops)) { + syslog(LOG_INFO, + "Wrote %d bytes of oops log to %s", wrote, submit_pipe); + } else { + syslog(LOG_ERR, + "Write to %s failed: %s\n", submit_pipe, + ferror(pipe_file) ? strerror(errno) : "short write"); + } + err = pclose(pipe_file); + if (err != 0) { + syslog(LOG_ERR, + "Close of pipe to %s failed: %s\n", submit_pipe, + err < 0 ? strerror(errno) : "non-zero exit from child"); + } + } else { + syslog(LOG_WARNING, + "popen to %s failed: %s\n", + submit_pipe, strerror(errno)); + } + closelog(); +} + void queue_oops(char *oops) { int i; @@ -112,7 +155,7 @@ } -void write_detail_file(void) +static void write_detail_file(void) { int temp_fileno; FILE *tmpf; @@ -143,14 +186,72 @@ close(temp_fileno); } -void unlink_detail_file(void) +static void unlink_detail_file(void) { if (detail_filename) { unlink(detail_filename); free(detail_filename); + detail_filename = NULL; } } +static void pipe_oopses(void) +{ + struct oops *oops; + struct oops *queue; + + if (access(submit_pipe, X_OK) != 0) { + printf("Cant access %s, not submitting oopses\n", submit_pipe); + return; + } + + queue = queued_oopses; + queued_oopses = NULL; + barrier(); + oops = queue; + while (oops) { + FILE *pipe_file; + int len; + char pipe[4096]; + + if (strstr(oops->text, "WARNING:")) + return; + + len = snprintf(pipe, 4096, "%s %d", submit_pipe, oops->checksum); + if (len > 4096) { + printf("Pipe name too long, aborting\n"); + return; + } + + pipe_file = popen(pipe, "w"); + if (pipe_file) { + size_t written = 0; + int err; + char *buf = oops->text; + size_t to_write = strlen(oops->text); + + do { + written = fwrite(buf, 1, to_write, pipe_file); + if (written == to_write) + break; + buf += written; + to_write -= written; + } while (errno == EINTR); + if (written < to_write) { + perror("aborting, writing to pipe failed"); + } + + err = pclose(pipe_file); + if (err != 0) + perror("closing pipe failed"); + } else { + perror("aborting, popen failed"); + return; + } + + oops = oops->next; + } +} static void print_queue(void) { @@ -175,39 +276,95 @@ } -static void write_logfile(int count) +static void write_logfile(int count, char *result_url) { openlog("kerneloops", 0, LOG_KERN); syslog(LOG_WARNING, "Submitted %i kernel oopses to www.kerneloops.org", count); + if (result_url && result_url[0]) + syslog(LOG_WARNING, "kerneloops.org: oops is posted as %s", result_url); closelog(); } -char result_url[4096]; +static char result_url[4096]; -size_t writefunction( void *ptr, size_t size, size_t nmemb, void __attribute((unused)) *stream) +int submit_oops(struct oops *oops) { - char *c, *c1, *c2; - c = malloc(size*nmemb + 1); - memset(c, 0, size*nmemb + 1); - memcpy(c, ptr, size*nmemb); - printf("received %s \n", c); - c1 = strstr(c, "201 "); - if (c1) { - c1+=4; - c2 = strchr(c1, '\n'); - if (c2) *c2 = 0; - strncpy(result_url, c1, 4095); + char *submit_prog = "kerneloops-submit"; + int in_pipe[2]; + int out_pipe[2]; + int pid; + + if (pipe(in_pipe)) { + perror("pipe"); + return 1; + } + + if (pipe(out_pipe)){ + perror("pipe"); + return 1; + } + + pid = fork(); + if (pid < 0) { + perror("fork"); + } else if (pid == 0) { + //child + close(in_pipe[1]); + close(out_pipe[0]); + dup2(in_pipe[0], 0); + dup2(out_pipe[1], 1); + if (execvp(submit_prog, NULL)) { + perror("execl"); + exit(255); + } + exit(0); + } else { + // parent + size_t written = 0; + char *buf = oops->text; + size_t to_write = strlen(oops->text); + int status; + ssize_t count; + char url[4096]; + close(in_pipe[0]); + close(out_pipe[1]); + do { + written = write(in_pipe[1], buf, to_write); + if (written == to_write) + break; + buf += written; + to_write -= written; + } while (errno == EINTR); + if (written < to_write) { + perror("aborting, writing to pipe failed"); + return 1; + } + close(in_pipe[1]); + waitpid(pid, &status, 0); + if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) { + perror("child failed"); + close(out_pipe[0]); + return 1; + } + count = read(out_pipe[0], url, 4095); + if (count < 0) { + perror("read from child"); + return 1; + } + close(out_pipe[0]); + printf("url is %s\n", url); + strncpy(result_url, url, 4095); } - return size * nmemb; + return 0; } void submit_queue(void) { - int result; struct oops *oops; struct oops *queue; int count = 0; + unlink_detail_file(); memset(result_url, 0, 4096); if (testmode) { @@ -220,42 +377,19 @@ barrier(); oops = queue; while (oops) { - CURL *handle; - struct curl_httppost *post = NULL; - struct curl_httppost *last = NULL; + int err; struct oops *next; - - handle = curl_easy_init(); - - printf("DEBUG SUBMIT URL is %s \n", submit_url); - curl_easy_setopt(handle, CURLOPT_URL, submit_url); - - /* set up the POST data */ - curl_formadd(&post, &last, - CURLFORM_COPYNAME, "oopsdata", - CURLFORM_COPYCONTENTS, oops->text, CURLFORM_END); - - if (allow_distro_to_pass_on) { - curl_formadd(&post, &last, - CURLFORM_COPYNAME, "pass_on_allowed", - CURLFORM_COPYCONTENTS, "yes", CURLFORM_END); - } - - curl_easy_setopt(handle, CURLOPT_HTTPPOST, post); - curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, writefunction); - result = curl_easy_perform(handle); - - curl_formfree(post); - curl_easy_cleanup(handle); + err = submit_oops(oops); next = oops->next; free(oops->text); free(oops); oops = next; - count++; + if (!err) + count++; } if (count && !testmode) - write_logfile(count); + write_logfile(count, result_url); if (count) dbus_say_thanks(result_url); @@ -263,10 +397,8 @@ * If we've reached the maximum count, we'll exit the program, * the program won't do any useful work anymore going forward. */ - if (submitted >= MAX_CHECKSUMS-1) { - unlink_detail_file(); + if (submitted >= MAX_CHECKSUMS-1) exit(EXIT_SUCCESS); - } } void clear_queue(void) @@ -284,17 +416,26 @@ free(oops); oops = next; } - write_logfile(0); + unlink_detail_file(); + write_logfile(0, NULL); } void ask_permission(void) { - if (!newoops && !pinged) + if (!newoops) return; - pinged = 0; - newoops = 0; - if (queued_oopses) { - write_detail_file(); - dbus_ask_permission(detail_filename); + if (!submit_pipe) { + if (!pinged) + return; + pinged = 0; + newoops = 0; + if (queued_oopses) { + write_detail_file(); + dbus_ask_permission(detail_filename); + } + } else { + if (queued_oopses) { + pipe_oopses(); + } } } --- kerneloops-0.12+git20090217.orig/kerneloops-applet.c +++ kerneloops-0.12+git20090217/kerneloops-applet.c @@ -140,58 +140,48 @@ gtk_widget_destroy(dialog); } - -/* Called only to display details */ -static void detail_action(NotifyNotification __unused *notify, - gchar __unused *action, gpointer __unused user_data) +static GtkWidget *create_detail_textview(void) { - GtkWidget *dialog; - GtkWidget *scrollwindow; + GtkWidget *sw; GtkWidget *view; GtkTextBuffer *buffer; GtkWidget *button_cancel; GtkWidget *button_send; GtkTextTag *fixed; GtkTextIter iter; - char *detail_data; struct stat statb; + char *detail_data; int detail_fd; int ret; - /* If anything goes wrong, return as early as possible... */ - if (!detail_file_name) - return; + return NULL; - memset(&statb, 0, sizeof(statb)); + memset(&statb, 0, sizeof(statb)); ret = stat(detail_file_name, &statb); if (statb.st_size < 1 || ret != 0) - return; + return NULL; detail_fd = open(detail_file_name, O_RDONLY); if (detail_fd < 0) - return; + return NULL; - detail_data = malloc(statb.st_size+1); + detail_data = malloc(statb.st_size + 1); if (!detail_data) - return; + return NULL; if (read(detail_fd, detail_data, statb.st_size) != statb.st_size) { free(detail_data); - return; + return NULL; } close(detail_fd); detail_data[statb.st_size] = '\0'; - dialog = gtk_dialog_new(); - gtk_window_set_title(GTK_WINDOW(dialog), _("Kernel failure details")); - gtk_widget_set_size_request(dialog, 600, 400); - scrollwindow = gtk_scrolled_window_new(NULL, NULL); - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (scrollwindow), + /* Scrolled window */ + sw = gtk_scrolled_window_new(NULL, NULL); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), scrollwindow, - TRUE, TRUE, 0); view = gtk_text_view_new(); buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW (view)); fixed = gtk_text_buffer_create_tag (buffer, "font", "font", "monospace", NULL); @@ -199,9 +189,29 @@ gtk_text_buffer_insert_with_tags(buffer, &iter, detail_data, -1, fixed, NULL); free(detail_data); - gtk_container_add (GTK_CONTAINER (scrollwindow), view); + gtk_container_add (GTK_CONTAINER (sw), view); gtk_text_view_set_editable(GTK_TEXT_VIEW(view), FALSE); + + return sw; +} + +/* Called only to display details */ +static void detail_action(NotifyNotification __unused *notify, + gchar __unused *action, gpointer __unused user_data) +{ + GtkWidget *dialog; + GtkWidget *sw; + GtkWidget *button_cancel; + GtkWidget *button_send; + + dialog = gtk_dialog_new(); + gtk_window_set_title(GTK_WINDOW(dialog), _("Kernel failure details")); + gtk_widget_set_size_request(dialog, 600, 400); + sw = create_detail_textview (); + gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), sw, + TRUE, TRUE, 0); + button_send = gtk_button_new_with_label (_("Send")); GTK_WIDGET_SET_FLAGS(button_send, GTK_CAN_DEFAULT); button_cancel = gtk_button_new_with_label (_("Cancel")); @@ -220,55 +230,143 @@ button_cancel, TRUE, TRUE, 0); gtk_widget_grab_default(button_send); - gtk_widget_show(view); - gtk_widget_show(button_send); - gtk_widget_show(button_cancel); - gtk_widget_show(scrollwindow); - gtk_widget_show(dialog); + gtk_widget_show_all(dialog); +} + +static gboolean can_support_actions (void) +{ + static gboolean supports_actions = FALSE; + static gboolean have_checked = FALSE; + + if (!have_checked) { + GList *caps = NULL; + GList *c; + + have_checked = TRUE; + + caps = notify_get_server_caps(); + if (caps != NULL) { + for (c = caps; c != NULL; c = c->next) { + if (strcmp ((char*)c->data, "actions") == 0) { + supports_actions = TRUE; + break; + } + } + } + + g_list_foreach (caps, (GFunc)g_free, NULL); + g_list_free (caps); + } + + return supports_actions; } static void got_a_message(void) { char *summary = _("Your system had a kernel failure"); - char *message = - _("There is diagnostic information available for this failure." - " Do you want to submit this information to the www.kerneloops.org" - " website for use by the Linux kernel developers?\n"); + char *message; - NotifyActionCallback callback = notify_action; + if (can_support_actions ()) { + NotifyActionCallback callback = notify_action; - /* if there's a notification active already, close it first */ - close_notification(); + message = + _("There is diagnostic information available for this failure." + " Do you want to submit this information to the www.kerneloops.org" + " website for use by the Linux kernel developers?\n"); - notify = notify_notification_new(summary, message, - "/usr/share/kerneloops/icon.png", NULL); + /* if there's a notification active already, close it first */ + close_notification(); - notify_notification_set_timeout(notify, 0); - notify_notification_set_urgency(notify, NOTIFY_URGENCY_CRITICAL); + notify = notify_notification_new(summary, message, + "/usr/share/kerneloops/icon.png"); + notify_notification_set_timeout(notify, 0); + notify_notification_set_urgency(notify, NOTIFY_URGENCY_CRITICAL); - /* - * add the buttons and default action - */ - - notify_notification_add_action(notify, "default", "action", - callback, "default", NULL); - - notify_notification_add_action(notify, "always", _("Always"), - callback, "always", NULL); - notify_notification_add_action(notify, "yes", _("Yes"), - callback, "yes", NULL); - notify_notification_add_action(notify, "no", _("No"), - callback, "no", NULL); - notify_notification_add_action(notify, "never", _("Never"), - callback, "never", NULL); - if (detail_file_name) { - notify_notification_add_action(notify, - "details", _("Show Details"), - detail_action, "details", NULL); - } - notify_notification_show(notify, NULL); + /* + * add the buttons and default action + */ + + notify_notification_add_action(notify, "default", "action", + callback, "default", NULL); + notify_notification_add_action(notify, "always", _("Always"), + callback, "always", NULL); + notify_notification_add_action(notify, "never", _("Never"), + callback, "never", NULL); + notify_notification_add_action(notify, "no", _("Don't Send"), + callback, "no", NULL); + notify_notification_add_action(notify, "yes", _("Send"), + callback, "yes", NULL); + if (detail_file_name) { + notify_notification_add_action(notify, + "details", _("Show Details"), + detail_action, "details", NULL); + } + + notify_notification_show(notify, NULL); + } else { + GtkWidget *dialog; + GtkWidget *image; + GtkWidget *expander; + GtkWidget *details; + GtkWidget *content_area; + gint response; + + message = + _("Information about a kernel failure on this computer" + " can be sent to kerneloops.org to help improve Linux." + " Do you want to send this information?"); + + dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_OTHER, + GTK_BUTTONS_NONE, NULL); + gtk_window_set_title (GTK_WINDOW (dialog), _("Kernel Failure")); + gtk_window_set_resizable (GTK_WINDOW (dialog), TRUE); + gtk_window_set_icon (GTK_WINDOW (dialog), NULL); + gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog), message); + + image = gtk_image_new_from_file ("/usr/share/kerneloops/icon.png"); + + if (image) + gtk_message_dialog_set_image (GTK_MESSAGE_DIALOG (dialog), image); + + expander = gtk_expander_new_with_mnemonic (_("Details")); + + details = create_detail_textview (); + gtk_container_add (GTK_CONTAINER (expander), details); + + content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); + gtk_box_pack_end (GTK_BOX (content_area), expander, TRUE, TRUE, 0); + + gtk_widget_show_all (content_area); + + gtk_dialog_add_buttons (GTK_DIALOG (dialog), + _("Always"), GTK_RESPONSE_ACCEPT, + _("Never"), GTK_RESPONSE_REJECT, + _("Don't Send"), GTK_RESPONSE_NO, + _("Send"), GTK_RESPONSE_YES, + NULL); + gtk_dialog_set_default_response (GTK_DIALOG (dialog), + GTK_RESPONSE_YES); + + response = gtk_dialog_run (GTK_DIALOG (dialog)); + switch (response) { + case GTK_RESPONSE_ACCEPT: + notify_action (NULL, NULL, "always"); + break; + case GTK_RESPONSE_REJECT: + notify_action (NULL, NULL, "never"); + break; + case GTK_RESPONSE_NO: + notify_action (NULL, NULL, "no"); + break; + case GTK_RESPONSE_YES: + notify_action (NULL, NULL, "yes"); + break; + } + + gtk_widget_hide (dialog); + } } char url_to_oops[4095]; @@ -307,20 +405,21 @@ url_to_oops[0] = 0; notify = notify_notification_new(summary, message, - "/usr/share/kerneloops/icon.png", NULL); + "/usr/share/kerneloops/icon.png"); notify_notification_set_timeout(notify, 5000); notify_notification_set_urgency(notify, NOTIFY_URGENCY_LOW); - - notify_notification_add_action(notify, "default", "action", - callback, "default", NULL); - - if (user_preference <= 0) - notify_notification_add_action(notify, "always", _("Always"), - callback, "always", NULL); - notify_notification_add_action(notify, "never", _("Never again"), - callback, "never", NULL); + if (can_support_actions ()) { + notify_notification_add_action(notify, "default", "action", + callback, "default", NULL); + + if (user_preference <= 0) + notify_notification_add_action(notify, "always", _("Always"), + callback, "always", NULL); + notify_notification_add_action(notify, "never", _("Never again"), + callback, "never", NULL); + } notify_notification_show(notify, NULL); g_free(message); --- kerneloops-0.12+git20090217.orig/po/fi.po +++ kerneloops-0.12+git20090217/po/fi.po @@ -0,0 +1,75 @@ +# Finnish translation of kerneloops. +# Copyright (C) kerneloops' COPYRIGHT HOLDER +# This file is distributed under the same license as the kerneloops package. +# Ville-Pekka Vainio , 2009 +msgid "" +msgstr "" +"Project-Id-Version: kerneloops git\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2008-01-01 06:36-0800\n" +"PO-Revision-Date: 2009-04-11 01:24+0300\n" +"Last-Translator: Ville-Pekka Vainio \n" +"Language-Team: Finnish\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: kerneloops-applet.c:170 kerneloops-applet.c:212 +msgid "Always" +msgstr "Aina" + +#: kerneloops-applet.c:332 +#, c-format +msgid "Connecting to system bus failed: %s\n" +msgstr "Järjestelmäväylään yhdistäminen epäonnistui: %s\n" + +#: kerneloops-applet.c:190 +msgid "" +"Diagnostic information from your Linux kernel has been sent to www.kerneloops.org for the Linux kernel " +"developers to work on. \n" +"Thank you for contributing to improve the quality of the Linux kernel.\n" +msgstr "" +"Linux-ytimen vianmääritystiedot on lähetetty osoitteeseen www.kerneloops.org ytimen kehittäjien " +"käytettäväksi. Kiitos osallistumisestasi Linux-ytimen laadun parantamiseen.\n" + +#: kerneloops-applet.c:188 +msgid "Kernel bug diagnostic information sent" +msgstr "Ytimen vianmääritystiedot on lähetetty" + +#: kerneloops-applet.c:176 +msgid "Never" +msgstr "Ei koskaan" + +#: kerneloops-applet.c:214 +msgid "Never again" +msgstr "Ei enää koskaan" + +#: kerneloops-applet.c:174 +msgid "No" +msgstr "Ei" + +#: kerneloops-applet.c:143 +msgid "" +"There is diagnostic information available for this failure. Do you want to " +"submit this information to the www." +"kerneloops.org website for use by the Linux kernel developers?\n" +msgstr "" +"Tästä viasta on saatavilla vianmääritystietoja. Haluatko lähettää nämä " +"tiedot www.kerneloops.org-sivustolle Linux-" +"ytimen kehittäjien käytettäväksi?\n" + +#: kerneloops-applet.c:172 +msgid "Yes" +msgstr "Kyllä" + +#: kerneloops-applet.c:141 +msgid "Your system had a kernel failure" +msgstr "Järjestelmän ytimessä on toimintahäiriö" + +#: kerneloops-applet.c:343 +msgid "kerneloops client" +msgstr "kerneloops-asiakasohjelma" --- kerneloops-0.12+git20090217.orig/po/de.po +++ kerneloops-0.12+git20090217/po/de.po @@ -0,0 +1,77 @@ +# translation of kerneloops to German +# Copyright (C) Chris Leick , 2009. +# This file is distributed under the same license as the kerneloops package. +# Chris Leick , 2009. +# +msgid "" +msgstr "" +"Project-Id-Version: kerneloops-0.10.2\n" +"Report-Msgid-Bugs-To: willy@debian.org\n" +"POT-Creation-Date: 2009-02-22 11:49+0100\n" +"PO-Revision-Date: 2009-03-16 13:05+0100\n" +"Last-Translator: Chris Leick \n" +"Language-Team: German \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: kerneloops-applet.c:170 kerneloops-applet.c:212 +msgid "Always" +msgstr "Immer" + +#: kerneloops-applet.c:332 +#, c-format +msgid "Connecting to system bus failed: %s\n" +msgstr "Verbinden zum System-Bus fehlgeschlagen: %s\n" + +#: kerneloops-applet.c:190 +msgid "" +"Diagnostic information from your Linux kernel has been sent to www.kerneloops.org for the Linux kernel " +"developers to work on. \n" +"Thank you for contributing to improve the quality of the Linux kernel.\n" +msgstr "" +"Diagnose-Information von Ihrem Linux-Kernel wurde an www.kerneloops.org gesandt, damit die " +"Kernel-Entwickler daran arbeiten können.\n" +"Vielen Dank, dass Sie zur Verbesserung des Linux-Kernels beitragen.\n" + +#: kerneloops-applet.c:188 +msgid "Kernel bug diagnostic information sent" +msgstr "Gesendete Kernel-Fehler-Diagnose-Information" + +#: kerneloops-applet.c:176 +msgid "Never" +msgstr "Niemals" + +#: kerneloops-applet.c:214 +msgid "Never again" +msgstr "Niemals wieder" + +#: kerneloops-applet.c:174 +msgid "No" +msgstr "Nein" + +#: kerneloops-applet.c:143 +msgid "" +"There is diagnostic information available for this failure. Do you want to " +"submit this information to the www." +"kerneloops.org website for use by the Linux kernel developers?\n" +msgstr "" +"Es sind dort Diagnose-Informationen für diesen Ausfall verfügbar. Möchten " +"Sie diese Information zu der www." +"kerneloops.org-Website für die Benutzung durch die " +"Linux-Kernel-Entwickler senden?\n" + +#: kerneloops-applet.c:172 +msgid "Yes" +msgstr "Ja" + +#: kerneloops-applet.c:141 +msgid "Your system had a kernel failure" +msgstr "Ihr System hatte einen Kernel-Ausfall" + +#: kerneloops-applet.c:343 +msgid "kerneloops client" +msgstr "kerneloops-Client" --- kerneloops-0.12+git20090217.orig/debian/copyright +++ kerneloops-0.12+git20090217/debian/copyright @@ -0,0 +1,16 @@ +This package was debianised by Matthew Wilcox in +December 2007. + +It was downloaded from http://www.kerneloops.org/ + +The primary upstream author is Arjan van de Ven + +Copyright: + +This software is supplied under the terms of the GNU General Public +License version 2. The full text of the license can be found at: + + http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + +On Debian/GNU systems, this can be found as /usr/share/common-licenses/GPL-2 . + --- kerneloops-0.12+git20090217.orig/debian/compat +++ kerneloops-0.12+git20090217/debian/compat @@ -0,0 +1 @@ +4 --- kerneloops-0.12+git20090217.orig/debian/kerneloops-applet.postinst +++ kerneloops-0.12+git20090217/debian/kerneloops-applet.postinst @@ -0,0 +1,24 @@ +#!/bin/sh + +set -e + +mv_conffile() { + OLDCONFFILE="$1" + NEWCONFFILE="$2" + + if [ -e "$OLDCONFFILE" ]; then + echo "Preserving user changes to $NEWCONFFILE ..." + mv -f "$NEWCONFFILE" "$NEWCONFFILE".dpkg-new + mv -f "$OLDCONFFILE" "$NEWCONFFILE" + fi +} + +case "$1" in +configure) + if dpkg --compare-versions "$2" le "0.12+git20090217-1ubuntu5"; then + mv_conffile "/etc/xdg/autostart/autostart/kerneloops-applet.desktop" "/etc/xdg/autostart/kerneloops-applet.desktop" + fi +esac + +#DEBHELPER# + --- kerneloops-0.12+git20090217.orig/debian/kerneloops-daemon.postinst +++ kerneloops-0.12+git20090217/debian/kerneloops-daemon.postinst @@ -0,0 +1,46 @@ +#!/bin/sh +# postinst script for kerneloops +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `configure' +# * `abort-upgrade' +# * `abort-remove' `in-favour' +# +# * `abort-remove' +# * `abort-deconfigure' `in-favour' +# `removing' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + configure) + # add the system user + NEED=kernoops + if ! getent passwd $NEED >/dev/null; then + adduser --quiet --system --disabled-password \ + --gecos "Kernel Oops Tracking Daemon" \ + --home / --no-create-home $NEED + fi + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 --- kerneloops-0.12+git20090217.orig/debian/control +++ kerneloops-0.12+git20090217/debian/control @@ -0,0 +1,38 @@ +Source: kerneloops +Build-Depends: debhelper (>= 4), libcurl4-gnutls-dev | libcurl-dev, libnotify-dev, desktop-file-utils, libgtk2.0-dev, libdbus-glib-1-dev +Section: utils +Priority: optional +Maintainer: Ubuntu Developers +XSBC-Original-Maintainer: Matthew Wilcox +Standards-Version: 3.8.1 +Homepage: http://www.kerneloops.org/ + +Package: kerneloops +Architecture: any +Depends: kerneloops-applet +Description: kernel oops tracker + This is a transitional package for splitting the kerneloops package + into the kerneloops-daemon package and the kerneloops-applet package. + In the future, the kerneloops package will contain only the + kerneloops daemon, and not the applet. If you want the kerneloops + applet, you should explicitly install the kerneloops-applet package. + +Package: kerneloops-daemon +Architecture: any +Depends: ${shlibs:Depends}, adduser +Conflicts: kerneloops (<< 0.12+git20090217-1ubuntu2) +Replaces: kerneloops (<< 0.12+git20090217-1ubuntu2) +Recommends: apport +Description: kernel oops tracker + kerneloops is a daemon that collects kernel crash information and then + submits the extracted signature to the kerneloops.org website for + statistical analysis and presentation to the Linux kernel developers. + +Package: kerneloops-applet +Architecture: any +Replaces: kerneloops (<< 0.12+git20090217-1ubuntu2) +Depends: ${shlibs:Depends}, kerneloops-daemon +Description: applet for the kernel oops tracker + The kerneloops applet allows the kerneloops crash reporting utility + to ask a desktop user for permission before submitting an oops report + to the kerneloops.org website. --- kerneloops-0.12+git20090217.orig/debian/kerneloops-applet.preinst +++ kerneloops-0.12+git20090217/debian/kerneloops-applet.preinst @@ -0,0 +1,25 @@ +#!/bin/sh + +set -e + +prep_mv_conffile() { + CONFFILE="$1" + + if [ -e "$CONFFILE" ]; then + md5sum="`md5sum \"$CONFFILE\" | sed -e \"s/ .*//\"`" + old_md5sum="`sed -n -e \"/^Conffiles:/,/^[^ ]/{\\\\' $CONFFILE'{s/.* //;p}}\" /var/lib/dpkg/status`" + if [ "$md5sum" = "$old_md5sum" ]; then + rm -f "$CONFFILE" + fi + fi +} + +case "$1" in +install|upgrade) + if dpkg --compare-versions "$2" le "0.12+git20090217-1ubuntu5"; then + prep_mv_conffile "/etc/xdg/autostart/autostart/kerneloops-applet.desktop" + fi +esac + +#DEBHELPER# + --- kerneloops-0.12+git20090217.orig/debian/rules +++ kerneloops-0.12+git20090217/debian/rules @@ -0,0 +1,60 @@ +#!/usr/bin/make -f + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +build: build-stamp +build-stamp: + dh_testdir + $(MAKE) $(if $(findstring noopt,$(DEB_BUILD_OPTIONS)),CFLAGS+=-O0,) +ifneq ($(findstring nocheck,$(DEB_BUILD_OPTIONS)),nocheck) + $(MAKE) tests +endif + touch build-stamp + +clean: + dh_testdir + dh_testroot + rm -f build-stamp + + $(MAKE) clean + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + # Add here commands to install the package into debian/ + $(MAKE) DESTDIR=`pwd`/debian/tmp install + install -D -m 0755 kerneloops.init `pwd`/debian/kerneloops-daemon/etc/init.d/kerneloops + install -D -m 0755 debian/kerneloops.default `pwd`/debian/kerneloops-daemon/etc/default/kerneloops + dh_install + +# Build architecture-independent files here. +binary-indep: build install +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: build install + dh_testdir + dh_testroot + dh_installchangelogs + dh_installdocs + dh_installexamples + dh_installinit -pkerneloops-daemon --name=kerneloops -o -- start 20 2 3 4 5 . stop 20 1 . +# dh_installdebconf +# dh_installman kerneloops.8 + dh_link + dh_strip + dh_compress + dh_fixperms + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install --- kerneloops-0.12+git20090217.orig/debian/kerneloops-daemon.postrm +++ kerneloops-0.12+git20090217/debian/kerneloops-daemon.postrm @@ -0,0 +1,41 @@ +#!/bin/sh +# postrm script for kerneloops +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `remove' +# * `purge' +# * `upgrade' +# * `failed-upgrade' +# * `abort-install' +# * `abort-install' +# * `abort-upgrade' +# * `disappear' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + purge) + deluser --quiet --system kernoops >/dev/null || true + ;; + + remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) + ;; + + *) + echo "postrm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 --- kerneloops-0.12+git20090217.orig/debian/kerneloops-daemon.install +++ kerneloops-0.12+git20090217/debian/kerneloops-daemon.install @@ -0,0 +1,4 @@ +debian/tmp/usr/sbin/kerneloops /usr/sbin/ +debian/tmp/usr/bin/kerneloops-submit /usr/bin/ +debian/tmp/usr/share/man/man8/* /usr/share/man/man8/ +debian/tmp/etc/kerneloops.conf /etc/ --- kerneloops-0.12+git20090217.orig/debian/kerneloops.default +++ kerneloops-0.12+git20090217/debian/kerneloops.default @@ -0,0 +1,3 @@ +# Whether the daemon should be started at boot time. +# Set to 1 to start. +enabled=1 --- kerneloops-0.12+git20090217.orig/debian/changelog +++ kerneloops-0.12+git20090217/debian/changelog @@ -0,0 +1,258 @@ +kerneloops (0.12+git20090217-1ubuntu12) oneiric; urgency=low + + [ Brian Murray ] + * submit.c: do not report OOPSes with WARNING in them (LP: #346303) + * debian/kerneloops.default: re-enable kerneloops for oneiric, now + that apport is enabled. + * kerneloops-applet.c: modify number of arguments for + notify_notification_new + + [ Kees Cook ] + * debian/control: add libgtk2.0-dev and libdbus-glib-1-dev to Build Depends. + * Makefile: add dbus to pkg-config calls. + + -- Brian Murray Wed, 13 Jul 2011 12:38:39 -0700 + +kerneloops (0.12+git20090217-1ubuntu11) natty; urgency=low + + * Disable kerneloops for final release. + + -- Brian Murray Thu, 14 Apr 2011 14:35:26 -0700 + +kerneloops (0.12+git20090217-1ubuntu10) natty; urgency=low + + * Re-enable kerneloops for natty, now that Apport is enabled again. + + -- Brian Murray Thu, 03 Mar 2011 13:22:44 -0800 + +kerneloops (0.12+git20090217-1ubuntu9) maverick; urgency=low + + * Disable kerneloops for final release. + + -- Martin Pitt Tue, 28 Sep 2010 09:34:47 +0200 + +kerneloops (0.12+git20090217-1ubuntu8) maverick; urgency=low + + * Re-enable kerneloops for maverick. + + -- James Westby Fri, 04 Jun 2010 13:57:14 -0400 + +kerneloops (0.12+git20090217-1ubuntu7) lucid; urgency=low + + * debian/kerneloops.default: Disable kerneloops for the final release. + + -- Martin Pitt Mon, 19 Apr 2010 10:35:48 +0200 + +kerneloops (0.12+git20090217-1ubuntu6) lucid; urgency=low + + * Avoid another way that edac complains loudly. (LP: #525792) + + -- James Westby Mon, 22 Feb 2010 19:48:37 +0000 + +kerneloops (0.12+git20090217-1ubuntu5) lucid; urgency=low + + * Avoid bug 422536's WARNING as it isn't a WARN(). + * Re-enable kerneloops by default. + * Call update-rc.d with arguments that mean the link isn't installed for + rc0 or rc6, matching the headers. (LP: #452000) + * Install the autostart file in the correct place (LP: #440301) + + -- James Westby Tue, 16 Feb 2010 17:27:25 +0000 + +kerneloops (0.12+git20090217-1ubuntu4.1) karmic-proposed; urgency=low + + * Don't start kerneloops on boot in stable releases, for the same reasons that + we disable appport. (LP: #471137) + + -- James Westby Mon, 02 Nov 2009 15:13:28 +0000 + +kerneloops (0.12+git20090217-1ubuntu4) karmic; urgency=low + + * Install the autostart file so that if the user installs kerneloops-applet + it will at least start, leaving them to just choose in the config file + whether to use it. + * Also add "Replaces kerneloops" on the kerneloops-applet package as + files moved there too. + + -- James Westby Thu, 24 Sep 2009 12:02:35 +0100 + +kerneloops (0.12+git20090217-1ubuntu3) karmic; urgency=low + + * Install kerneloops.conf in the kerneloops-daemon package. Thanks + Matt Zimmerman. (LP: #428891) + * Don't scan the log file, just rely on dmesg for now to avoid a flood + of duplicate reports. Thanks Matt Zimmerman. (LP: #429000) + + -- James Westby Mon, 14 Sep 2009 16:16:49 +0100 + +kerneloops (0.12+git20090217-1ubuntu2) karmic; urgency=low + + * Move submit-pipe to be before asking, and still use apport for Ubuntu. + This puts apport in control of prompting the user. + * Add apport to Recommends as it will be needed to report any oopses + now if you don't edit the configuration file. + * Add kerneloops-submit which will allow apport to submit an oops. + * Split kerneloops-applet and kerneloops-daemon package. This means that + servers can just install the daemon without gtk, and we don't have to + install the applet by default now that we will use apport to do the + prompting. Thanks Tim Abbott. (LP: #337757) + (-daemon isn't really needed at this stage, but that is the way Debian + plan to go, so we use that to avoid clashes) + * Don't try and start the daemon if it isn't there. Thanks again to Tim + Abbott. + + -- James Westby Tue, 25 Aug 2009 15:07:01 +0100 + +kerneloops (0.12+git20090217-1ubuntu1) karmic; urgency=low + + * Merge from Debian, remaining changes: + - Add a "submit-pipe" configuration option for passing the oops to + another tool. Set it to pipe to apport for Ubuntu. + - Ensure that the newline is not included in the value when parsing + string values (LP: #344813) + - Add Homepage field. + - Create a kernoops system user and run the daemon as that, using + start-stop-daemon. (Running in the adm group ensures it can + read the logs). + - Add postinst/postrm to add/remove the user. + - Depend on adduser. + - Tweak the dbus conf so that the new user can own the dbus names. + - Append -O0 to CFLAGS when building in debug mode honoring noopt + DEB_BUILD_OPTIONS. + - Honor nocheck in DEB_BUILD_OPTIONS. + - Change log-file option to point to /var/log/kern.log instead of + /var/log/messages. + - Debianise the default location. + - If the notification daemon doesn't support actions then use + a dialog instead. + * Remove debian/applied-patches as updating them is too much headache. + * Remove Vcs URIs as they don't point to the one used for packaging. + * The Makefile now deletes the test/*.dbg files, so debian/rules doesn't + have to. + * Don't stop the daemon in runlevels 0 or 6 as sendsigs can quite happily + kill it for us. + + -- James Westby Thu, 11 Jun 2009 13:15:41 +0100 + +kerneloops (0.12+git20090217-1) unstable; urgency=low + + * New upstream version (closes: #512174) + - Fixes log parsing (closes: #487796) + - Tells the user what is being sent (closes: #510026) + * Changed init script to start in runlevel 2 (closes: #484493) + * Include patch from Cyril Brulebois to report status (closes: #509022) + * Add watch file (closes: #506346) + * Add German translation (closes: #522412) + + -- Matthew Wilcox Thu, 23 Apr 2009 11:14:24 -0400 + +kerneloops (0.12-0ubuntu5) jaunty; urgency=low + + * debian/applied-patches/kerneloops-applet.c.patch: Updated patch to include + a fix for box packing so expander fills and expands submitted by Cody + Russell. (LP: #344377) + + -- Ken VanDine Wed, 25 Mar 2009 15:27:17 -0400 + +kerneloops (0.12-0ubuntu4) jaunty; urgency=low + + [ Ken VanDine ] + * debian/applied-patches/kerneloops-applet.c.patch: Convert notification to + a dialog. Applied inline, since package has no patch system. (LP: #344377) + * debian/rules: Remove test/*dbg, these should be cleaned by the Makefile + * debian/applied-patches/submit.c.patch: Fix the config parser so that it + will actually work with apport. Thanks to Matt Zimmerman for the patch! + (LP: #344813) + + [ Martin Pitt ] + * Moved *.patch to debian/applied-patches/, to be a little less confusing. + + -- Ken VanDine Thu, 19 Mar 2009 08:48:36 -0400 + +kerneloops (0.12-0ubuntu3) jaunty; urgency=low + + * debian/{postinst,postrm}: create/remove kernoops system user. + * kerneloops.init: + - Debianify defaults location. + - use start-stop-daemon to handle daemon init, including running + as non-root user with log-readable permissions (group "adm"). + * configfile.c, kerneloops.{c,h}, kerneloops.conf: + - create "log-file" config setting, populate to /var/log/kern.log. + * kerneloops.dbus: switch to "kernoops" user instead of "root". + * debian/control: + - add "adduser" as Depend now that there is a system user. + - document Vcs URIs. + - add Homepage URL. + - update standards version (no changes needed). + + -- Kees Cook Tue, 17 Feb 2009 14:43:23 -0800 + +kerneloops (0.12-0ubuntu2) jaunty; urgency=low + + * configfile.c:read_configfile(): Properly dereference "*c" configfile + parsing char* when checking chars. + * Append -O0 to CFLAGS when building in debug mode honoring noopt + DEB_BUILD_OPTIONS. + * Honor nocheck in DEB_BUILD_OPTIONS. + + -- Loic Minier Tue, 03 Feb 2009 11:07:28 +0100 + +kerneloops (0.12-0ubuntu1) jaunty; urgency=low + + * New upstream release. Adapt our patches, remove Matt's hardcoded + apport patch. + * Apply Jim Lieb's support for a "submit-pipe" configuration option + and set it to pipe to /usr/share/apport/kernel_oops. + + -- Martin Pitt Mon, 02 Feb 2009 15:30:21 +0100 + +kerneloops (0.10-2ubuntu2) jaunty; urgency=low + + * kerneloops.dbus: LP: #318774. + - send_path without send_destination applies to all services, since + destination already allowed, this line is unnecessary. + + -- Scott James Remnant Tue, 09 Dec 2008 17:11:02 -0800 + +kerneloops (0.10-2ubuntu1) intrepid; urgency=low + + * Add support for dumping an apport crash report if apport (>=0.115) is + installed + + -- Matt Zimmerman Fri, 19 Sep 2008 00:55:09 +0100 + +kerneloops (0.10-2) unstable; urgency=low + + * Fixed missing build dependency + + -- Matthew Wilcox Tue, 08 Apr 2008 06:44:14 -0400 + +kerneloops (0.10-1) unstable; urgency=low + + * New upstream version + * Install init.d script (closes: #459433) + * Depend on libcurl4-gnutls-dev | libcurl-dev in order to get the same + library on all the buildds + * Drop our manpage in favour of the one now provided by upstream + * Run test suite as part of build + + -- Matthew Wilcox Wed, 09 Jan 2008 20:43:31 -0500 + +kerneloops (0.7-1) unstable; urgency=low + + * New upstream version + - Fixes memory leak (closes: #458177) + + -- Matthew Wilcox Sat, 29 Dec 2007 13:03:23 -0500 + +kerneloops (0.3-1) unstable; urgency=low + + * New upstream version + + -- Matthew Wilcox Fri, 14 Dec 2007 10:47:41 -0500 + +kerneloops (0.1-1) unstable; urgency=low + + * Initial Release + + -- Matthew Wilcox Wed, 05 Dec 2007 17:30:10 -0500 --- kerneloops-0.12+git20090217.orig/debian/kerneloops-applet.install +++ kerneloops-0.12+git20090217/debian/kerneloops-applet.install @@ -0,0 +1,4 @@ +debian/tmp/usr/bin/kerneloops-applet /usr/bin +debian/tmp/usr/share/kerneloops /usr/share +debian/tmp/usr/share/locale /usr/share +debian/tmp/etc/xdg/autostart/ /etc/xdg/ --- kerneloops-0.12+git20090217.orig/debian/watch +++ kerneloops-0.12+git20090217/debian/watch @@ -0,0 +1,2 @@ +version=3 +http://www.kerneloops.org/download/kerneloops-(.*)\.tar\.gz