diff -Nru accountsservice-0.6.15/debian/changelog accountsservice-0.6.15/debian/changelog --- accountsservice-0.6.15/debian/changelog 2012-02-15 16:55:25.000000000 +0000 +++ accountsservice-0.6.15/debian/changelog 2012-02-21 11:18:08.000000000 +0000 @@ -1,3 +1,12 @@ +accountsservice (0.6.15-2ubuntu8) precise; urgency=low + + * debian/patches/0010-set-language.patch: + - Call for setlocale() in the user_locale_validate() function in + src/user.c replaced with 'locale -a' to allow a newly generated + locale to be instantly used for regional formats (LP: #930785). + + -- Gunnar Hjalmarsson Thu, 16 Feb 2012 14:43:00 +0100 + accountsservice (0.6.15-2ubuntu7) precise; urgency=low * debian/patches/0013-add-has-message-support.patch: diff -Nru accountsservice-0.6.15/debian/patches/0010-set-language.patch accountsservice-0.6.15/debian/patches/0010-set-language.patch --- accountsservice-0.6.15/debian/patches/0010-set-language.patch 2012-02-11 03:31:35.000000000 +0000 +++ accountsservice-0.6.15/debian/patches/0010-set-language.patch 2012-02-21 11:17:56.000000000 +0000 @@ -31,7 +31,7 @@ break; case PROP_X_SESSION: g_value_set_string (value, user->x_session); -@@ -1085,6 +1093,352 @@ +@@ -1085,6 +1093,397 @@ return TRUE; } @@ -133,28 +133,73 @@ +} + +static gchar * -+user_locale_validate (const gchar *locale, ++user_locale_validate (User *user, ++ const gchar *locale, + DBusGMethodInvocation *context) +{ -+ gchar *validated_locale = NULL; -+ gchar *tmp_locale = NULL; -+ gchar *current = g_strdup (setlocale (LC_ALL, NULL)); ++ gchar *validated_locale = NULL; ++ gchar *tmp_locale = NULL; ++ gchar *tmp_locale_utf8 = NULL; ++ gboolean ret = FALSE; ++ gchar *output = NULL; ++ GError *error = NULL; ++ gboolean found = FALSE; + + if (locale == NULL || strlen (locale) < 2) + goto out; + tmp_locale = g_strdup (locale); + g_strchomp (tmp_locale); + -+ if (!setlocale (LC_ALL, tmp_locale)) { ++ /* When a new language has been installed, we want to be able to instantly ++ set a locale for that language to denote the regional formats. For that ++ reason we make use of 'locale -a' instead of calling setlocale(). */ ++ ++ if (!user_drop_privileges_to_user (user)) ++ goto out; ++ ret = g_spawn_command_line_sync ("locale -a", &output, NULL, NULL, &error); ++ user_regain_privileges (); ++ if (!ret) { ++ throw_error (context, ERROR_FAILED, "Failed to run 'locale -a': %s", error->message); ++ g_clear_error (&error); ++ goto out; ++ } ++ ++ /* Replace 'UTF-8' with 'utf8' since 'locale -a' outputs the latter. */ ++ tmp_locale_utf8 = g_strdup (tmp_locale); ++ if (g_strrstr (tmp_locale_utf8, ".UTF-8")) { ++ gchar **tokens = g_strsplit_set (tmp_locale_utf8, ".8", 3); ++ g_free (tmp_locale_utf8); ++ tmp_locale_utf8 = g_strconcat (tokens[0], ".utf8", tokens[2], NULL); ++ g_strfreev (tokens); ++ } ++ ++ gchar **tokens; ++ int i; ++ g_strchomp (output); ++ tokens = g_strsplit (output, "\n", -1); ++ for (i = 0; tokens[i]; i++) { ++ if (g_strcmp0 (tokens[i], "C") == 0 || ++ g_strcmp0 (tokens[i], "C.UTF-8") == 0 || ++ g_strcmp0 (tokens[i], "POSIX") == 0) ++ continue; ++ ++ if (g_strcmp0 (tokens[i], tmp_locale_utf8) == 0) { ++ found = TRUE; ++ break; ++ } ++ } ++ g_strfreev (tokens); ++ ++ if (!found) { + throw_error (context, ERROR_FAILED, "'%s' is not a valid locale name", tmp_locale); + goto out; + } + validated_locale = user_locale_utf8_fix (tmp_locale); + +out: -+ setlocale (LC_ALL, current); + g_free (tmp_locale); -+ g_free (current); ++ g_free (tmp_locale_utf8); ++ g_free (output); + + return validated_locale; +} @@ -350,7 +395,7 @@ + tmp = lang; + if (tmp) { + *profile_formats = user_update_environment (user, -+ user_locale_validate (tmp, context), ++ user_locale_validate (user, tmp, context), + "save-to-pam-env", + context); + if (*profile_formats == NULL) @@ -384,7 +429,7 @@ static void user_change_language_authorized_cb (Daemon *daemon, User *user, -@@ -1092,12 +1446,94 @@ +@@ -1092,12 +1491,94 @@ gpointer data) { @@ -470,7 +515,7 @@ + + if (locale != NULL && strlen (locale) > 0) { + gchar *formats_locale = user_update_environment (user, -+ user_locale_validate (locale, context), ++ user_locale_validate (user, locale, context), + "save-to-pam-env", + context); + if (formats_locale != NULL) { @@ -483,7 +528,7 @@ save_extra_data (user); g_signal_emit (user, signals[CHANGED], 0); -@@ -1105,6 +1541,8 @@ +@@ -1105,6 +1586,8 @@ g_object_notify (G_OBJECT (user), "language"); } @@ -492,7 +537,7 @@ dbus_g_method_return (context); } -@@ -1156,11 +1594,38 @@ +@@ -1156,11 +1639,38 @@ gpointer data) { @@ -511,7 +556,7 @@ + + if (g_strcmp0 (user->formats_locale, data) != 0 || is_migrate) { + gchar *formats_locale = user_update_environment (user, -+ user_locale_validate (data, context), ++ user_locale_validate (user, data, context), + "save-to-pam-env", + context); + if (formats_locale != NULL) { @@ -535,7 +580,7 @@ save_extra_data (user); -@@ -1169,6 +1634,7 @@ +@@ -1169,6 +1679,7 @@ g_object_notify (G_OBJECT (user), "formats_locale"); } diff -Nru accountsservice-0.6.15/debian/patches/0011-add-background-file-support.patch accountsservice-0.6.15/debian/patches/0011-add-background-file-support.patch --- accountsservice-0.6.15/debian/patches/0011-add-background-file-support.patch 2012-02-11 03:31:35.000000000 +0000 +++ accountsservice-0.6.15/debian/patches/0011-add-background-file-support.patch 2012-02-21 11:17:56.000000000 +0000 @@ -273,7 +273,7 @@ if (user->icon_file) g_key_file_set_string (keyfile, "User", "Icon", user->icon_file); } -@@ -1906,6 +1929,94 @@ +@@ -1951,6 +1974,94 @@ } static void diff -Nru accountsservice-0.6.15/debian/patches/0012-add-keyboard-layout-support.patch accountsservice-0.6.15/debian/patches/0012-add-keyboard-layout-support.patch --- accountsservice-0.6.15/debian/patches/0012-add-keyboard-layout-support.patch 2012-02-11 03:48:09.000000000 +0000 +++ accountsservice-0.6.15/debian/patches/0012-add-keyboard-layout-support.patch 2012-02-21 11:17:56.000000000 +0000 @@ -144,7 +144,7 @@ if (user->background_file) g_key_file_set_string (keyfile, "User", "Background", user->background_file); -@@ -1955,6 +1978,63 @@ +@@ -2000,6 +2023,63 @@ } static void diff -Nru accountsservice-0.6.15/debian/patches/0013-add-has-message-support.patch accountsservice-0.6.15/debian/patches/0013-add-has-message-support.patch --- accountsservice-0.6.15/debian/patches/0013-add-has-message-support.patch 2012-02-15 16:55:05.000000000 +0000 +++ accountsservice-0.6.15/debian/patches/0013-add-has-message-support.patch 2012-02-21 11:17:56.000000000 +0000 @@ -232,7 +232,7 @@ user->x_keyboard_layouts = NULL; user->background_file = NULL; user->icon_file = NULL; -@@ -1978,6 +1991,60 @@ +@@ -2023,6 +2036,60 @@ } static void