1
Description: Save user language settings to ~/.profile.
2
Author: Gunnar Hjalmarsson <ubuntu@gunnar.cc>
4
Index: accountsservice/src/user.c
5
===================================================================
6
--- accountsservice.orig/src/user.c 2011-08-16 07:58:54.655991000 +0200
7
+++ accountsservice/src/user.c 2011-08-16 08:07:53.569526881 +0200
11
#define ICONDIR LOCALSTATEDIR "/lib/AccountsService/icons"
12
+#define LANGTOOLSDIR DATADIR "/language-tools"
16
@@ -1048,9 +1049,46 @@
20
- gchar *language = data;
21
+ gchar *language = data;
23
+ gchar *command[] = { LANGTOOLSDIR "/set-language-helper", user->user_name, language, NULL };
24
+ const gchar *allowed_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890._+-@:";
25
+ gchar *validated_language;
26
+ GError *error = NULL;
28
if (g_strcmp0 (user->language, language) != 0) {
30
+ /* test for odd characters in arguments */
31
+ for (i = 1; i <= 2; i++) {
32
+ if (strlen (command[i]) != strspn (command[i], allowed_chars)) {
33
+ throw_error (context, ERROR_FAILED, "non-permitted character(s) in argument");
38
+ /* set language related environment variables in ~/.profile */
39
+ if (!g_spawn_sync ( NULL,
42
+ G_SPAWN_STDERR_TO_DEV_NULL,
45
+ &validated_language,
49
+ throw_error (context, ERROR_FAILED, "running '%s' failed: %s", command[0], error->message);
50
+ g_error_free (error);
53
+ if (validated_language != NULL && strlen (validated_language) > 1) {
54
+ language = g_strndup (validated_language, strspn (validated_language, allowed_chars));
55
+ g_free (validated_language);
57
+ throw_error (context, ERROR_FAILED, "running '%s' failed: no output", command[0]);
61
g_free (user->language);
62
user->language = g_strdup (language);