diff -Nru whoopsie-preferences-0.16/debian/bzr-builddeb.conf whoopsie-preferences-0.17/debian/bzr-builddeb.conf --- whoopsie-preferences-0.16/debian/bzr-builddeb.conf 2014-01-06 19:43:04.000000000 +0000 +++ whoopsie-preferences-0.17/debian/bzr-builddeb.conf 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -[BUILDDEB] -native = True diff -Nru whoopsie-preferences-0.16/debian/changelog whoopsie-preferences-0.17/debian/changelog --- whoopsie-preferences-0.16/debian/changelog 2015-04-02 09:43:42.000000000 +0000 +++ whoopsie-preferences-0.17/debian/changelog 2015-05-22 11:58:03.000000000 +0000 @@ -1,3 +1,10 @@ +whoopsie-preferences (0.17) wily; urgency=medium + + * Fall back to /etc/writable for /etc/whoopsie if we need to. Thanks seb128 + for the initial patch! (LP: #1437633) + + -- Iain Lane Fri, 22 May 2015 12:58:03 +0100 + whoopsie-preferences (0.16) vivid; urgency=medium * Only report that we don't report crashes under upstart if the override diff -Nru whoopsie-preferences-0.16/src/whoopsie-preferences.c whoopsie-preferences-0.17/src/whoopsie-preferences.c --- whoopsie-preferences-0.16/src/whoopsie-preferences.c 2015-04-02 11:39:20.000000000 +0000 +++ whoopsie-preferences-0.17/src/whoopsie-preferences.c 2015-05-22 11:21:09.000000000 +0000 @@ -23,6 +23,11 @@ #include #include #include +#include +#include +#include +#include + #include #include "libwhoopsie-preferences.h" @@ -34,6 +39,61 @@ static GKeyFile* key_file = NULL; static PolkitAuthority* authority = NULL; +/* Hack for Ubuntu phone: check if path is an existing symlink to + * /etc/writable; if it is, update that instead */ +static const char* writable_filename (const char *config) { + const char *result = config; + struct stat sb; + char *linkname = NULL; + char *dirname = NULL; + char *resolved_path = NULL; + ssize_t r; + static char realfile_buf[PATH_MAX]; + + g_assert (config); + g_assert (g_path_is_absolute (config)); + + if (lstat (config, &sb) == -1) { + goto out; + } + + linkname = g_malloc (sb.st_size + 1); + if (linkname == NULL) { + goto out; + } + + r = readlink (config, linkname, sb.st_size + 1); + + if (r < 0 || r > sb.st_size) { + goto out; + } + + linkname[sb.st_size] = '\0'; + + /* Make absolute if relative */ + if (!g_path_is_absolute (linkname)) { + dirname = g_path_get_dirname (config); + resolved_path = g_build_filename ( + dirname, + linkname, + NULL); + g_free (linkname); + linkname = resolved_path; + } + + if (g_str_has_prefix (linkname, "/etc/writable")) { + g_snprintf (realfile_buf, sizeof (realfile_buf), "%s", linkname); + result = realfile_buf; + } + +out: + g_debug ("Writable path for %s is %s", config, result); + + g_free (linkname); + g_free (dirname); + return result; +} + gboolean whoopsie_preferences_load_configuration (void) { @@ -42,7 +102,8 @@ gboolean ret = TRUE; GError* error = NULL; - if (g_key_file_load_from_file (key_file, CONFIG_PATH, + if (g_key_file_load_from_file (key_file, + writable_filename(CONFIG_PATH), G_KEY_FILE_KEEP_COMMENTS, NULL)) { return TRUE; } @@ -54,7 +115,7 @@ ret = FALSE; goto out; } - if (!g_file_set_contents (CONFIG_PATH, data, data_size, &error)) { + if (!g_file_set_contents (writable_filename(CONFIG_PATH), data, data_size, &error)) { g_print ("Could not write configuration: %s\n", error->message); ret = FALSE; goto out; @@ -281,7 +342,7 @@ g_print ("Could not process configuration: %s\n", error->message); return FALSE; } - if (!g_file_set_contents (CONFIG_PATH, data, data_size, &error)) { + if (!g_file_set_contents (writable_filename(CONFIG_PATH), data, data_size, &error)) { g_print ("Could not write configuration: %s\n", error->message); return FALSE; }