chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
systemd-analyze: pipe through SED_PROCESS
[elogind.git]
/
src
/
locale
/
localed.c
diff --git
a/src/locale/localed.c
b/src/locale/localed.c
index e9f9f86878e74ff49cf5be6d8b1bb8cd2136bbe4..bb2a3a2e5422cea56ac865052f836c80b1de11c4 100644
(file)
--- a/
src/locale/localed.c
+++ b/
src/locale/localed.c
@@
-6,16
+6,16
@@
Copyright 2011 Lennart Poettering
systemd is free software; you can redistribute it and/or modify it
Copyright 2011 Lennart Poettering
systemd 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; either version 2 of the License, or
+ under the terms of the GNU
Lesser
General Public License as published by
+ the Free Software Foundation; either version 2
.1
of the License, or
(at your option) any later version.
systemd 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
(at your option) any later version.
systemd 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.
+
Lesser
General Public License for more details.
- You should have received a copy of the GNU General Public License
+ You should have received a copy of the GNU
Lesser
General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
@@
-26,6
+26,7
@@
#include <unistd.h>
#include "util.h"
#include <unistd.h>
#include "util.h"
+#include "mkdir.h"
#include "strv.h"
#include "dbus-common.h"
#include "polkit.h"
#include "strv.h"
#include "dbus-common.h"
#include "polkit.h"
@@
-270,24
+271,8
@@
static int read_data_x11(void) {
free_data_x11();
f = fopen("/etc/X11/xorg.conf.d/00-keyboard.conf", "re");
free_data_x11();
f = fopen("/etc/X11/xorg.conf.d/00-keyboard.conf", "re");
- if (!f) {
- if (errno == ENOENT) {
-
-#ifdef TARGET_FEDORA
- f = fopen("/etc/X11/xorg.conf.d/00-system-setup-keyboard.conf", "re");
- if (!f) {
- if (errno == ENOENT)
- return 0;
- else
- return -errno;
- }
-#else
- return 0;
-#endif
-
- } else
- return -errno;
- }
+ if (!f)
+ return errno == ENOENT ? 0 : -errno;
while (fgets(line, sizeof(line), f)) {
char *l;
while (fgets(line, sizeof(line), f)) {
char *l;
@@
-424,7
+409,7
@@
static void push_data(DBusConnection *bus) {
l_set = new0(char*, _PROP_MAX);
l_unset = new0(char*, _PROP_MAX);
if (!l_set || !l_unset) {
l_set = new0(char*, _PROP_MAX);
l_unset = new0(char*, _PROP_MAX);
if (!l_set || !l_unset) {
- log_
error("Out of memory"
);
+ log_
oom(
);
goto finish;
}
goto finish;
}
@@
-437,7
+422,7
@@
static void push_data(DBusConnection *bus) {
char *s;
if (asprintf(&s, "%s=%s", names[p], data[p]) < 0) {
char *s;
if (asprintf(&s, "%s=%s", names[p], data[p]) < 0) {
- log_
error("Out of memory"
);
+ log_
oom(
);
goto finish;
}
goto finish;
}
@@
-455,30
+440,30
@@
static void push_data(DBusConnection *bus) {
dbus_message_iter_init_append(m, &iter);
if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "s", &sub)) {
dbus_message_iter_init_append(m, &iter);
if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "s", &sub)) {
- log_
error("Out of memory."
);
+ log_
oom(
);
goto finish;
}
STRV_FOREACH(t, l_unset)
if (!dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, t)) {
goto finish;
}
STRV_FOREACH(t, l_unset)
if (!dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, t)) {
- log_
error("Out of memory."
);
+ log_
oom(
);
goto finish;
}
if (!dbus_message_iter_close_container(&iter, &sub) ||
!dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "s", &sub)) {
goto finish;
}
if (!dbus_message_iter_close_container(&iter, &sub) ||
!dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "s", &sub)) {
- log_
error("Out of memory."
);
+ log_
oom(
);
goto finish;
}
STRV_FOREACH(t, l_set)
if (!dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, t)) {
goto finish;
}
STRV_FOREACH(t, l_set)
if (!dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, t)) {
- log_
error("Out of memory."
);
+ log_
oom(
);
goto finish;
}
if (!dbus_message_iter_close_container(&iter, &sub)) {
goto finish;
}
if (!dbus_message_iter_close_container(&iter, &sub)) {
- log_
error("Out of memory."
);
+ log_
oom(
);
goto finish;
}
goto finish;
}
@@
-576,21
+561,13
@@
static int write_data_x11(void) {
isempty(state.x11_variant) &&
isempty(state.x11_options)) {
isempty(state.x11_variant) &&
isempty(state.x11_options)) {
-#ifdef TARGET_FEDORA
- unlink("/etc/X11/xorg.conf.d/00-system-setup-keyboard.conf");
-
- /* Symlink this to /dev/null, so that s-s-k (if it is
- * still running) doesn't recreate this. */
- symlink("/dev/null", "/etc/X11/xorg.conf.d/00-system-setup-keyboard.conf");
-#endif
-
if (unlink("/etc/X11/xorg.conf.d/00-keyboard.conf") < 0)
return errno == ENOENT ? 0 : -errno;
return 0;
}
if (unlink("/etc/X11/xorg.conf.d/00-keyboard.conf") < 0)
return errno == ENOENT ? 0 : -errno;
return 0;
}
- mkdir_p
arents
("/etc/X11/xorg.conf.d", 0755);
+ mkdir_p
_label
("/etc/X11/xorg.conf.d", 0755);
r = fopen_temporary("/etc/X11/xorg.conf.d/00-keyboard.conf", &f, &temp_path);
if (r < 0)
r = fopen_temporary("/etc/X11/xorg.conf.d/00-keyboard.conf", &f, &temp_path);
if (r < 0)
@@
-623,18
+600,8
@@
static int write_data_x11(void) {
r = -errno;
unlink("/etc/X11/xorg.conf.d/00-keyboard.conf");
unlink(temp_path);
r = -errno;
unlink("/etc/X11/xorg.conf.d/00-keyboard.conf");
unlink(temp_path);
- } else {
-
-#ifdef TARGET_FEDORA
- unlink("/etc/X11/xorg.conf.d/00-system-setup-keyboard.conf");
-
- /* Symlink this to /dev/null, so that s-s-k (if it is
- * still running) doesn't recreate this. */
- symlink("/dev/null", "/etc/X11/xorg.conf.d/00-system-setup-keyboard.conf");
-#endif
-
+ } else
r = 0;
r = 0;
- }
fclose(f);
free(temp_path);
fclose(f);
free(temp_path);
@@
-1072,7
+1039,9
@@
static DBusHandlerResult locale_message_handler(
size_t k;
k = strlen(names[p]);
size_t k;
k = strlen(names[p]);
- if (startswith(*i, names[p]) && (*i)[k] == '=') {
+ if (startswith(*i, names[p]) &&
+ (*i)[k] == '=' &&
+ string_is_safe((*i) + k + 1)) {
valid = true;
passed[p] = true;
valid = true;
passed[p] = true;
@@
-1156,7
+1125,9
@@
static DBusHandlerResult locale_message_handler(
"Locale\0");
if (!changed)
goto oom;
"Locale\0");
if (!changed)
goto oom;
- }
+ } else
+ strv_free(l);
+
} else if (dbus_message_is_method_call(message, "org.freedesktop.locale1", "SetVConsoleKeyboard")) {
const char *keymap, *keymap_toggle;
} else if (dbus_message_is_method_call(message, "org.freedesktop.locale1", "SetVConsoleKeyboard")) {
const char *keymap, *keymap_toggle;
@@
-1181,6
+1152,10
@@
static DBusHandlerResult locale_message_handler(
if (!streq_ptr(keymap, state.vc_keymap) ||
!streq_ptr(keymap_toggle, state.vc_keymap_toggle)) {
if (!streq_ptr(keymap, state.vc_keymap) ||
!streq_ptr(keymap_toggle, state.vc_keymap_toggle)) {
+ if ((keymap && (!filename_is_safe(keymap) || !string_is_safe(keymap))) ||
+ (keymap_toggle && (!filename_is_safe(keymap_toggle) || !string_is_safe(keymap_toggle))))
+ return bus_send_error_reply(connection, message, NULL, -EINVAL);
+
r = verify_polkit(connection, message, "org.freedesktop.locale1.set-keyboard", interactive, NULL, &error);
if (r < 0)
return bus_send_error_reply(connection, message, &error, r);
r = verify_polkit(connection, message, "org.freedesktop.locale1.set-keyboard", interactive, NULL, &error);
if (r < 0)
return bus_send_error_reply(connection, message, &error, r);
@@
-1251,6
+1226,12
@@
static DBusHandlerResult locale_message_handler(
!streq_ptr(variant, state.x11_variant) ||
!streq_ptr(options, state.x11_options)) {
!streq_ptr(variant, state.x11_variant) ||
!streq_ptr(options, state.x11_options)) {
+ if ((layout && !string_is_safe(layout)) ||
+ (model && !string_is_safe(model)) ||
+ (variant && !string_is_safe(variant)) ||
+ (options && !string_is_safe(options)))
+ return bus_send_error_reply(connection, message, NULL, -EINVAL);
+
r = verify_polkit(connection, message, "org.freedesktop.locale1.set-keyboard", interactive, NULL, &error);
if (r < 0)
return bus_send_error_reply(connection, message, &error, r);
r = verify_polkit(connection, message, "org.freedesktop.locale1.set-keyboard", interactive, NULL, &error);
if (r < 0)
return bus_send_error_reply(connection, message, &error, r);
@@
-1343,8
+1324,7
@@
static int connect_bus(DBusConnection **_bus) {
if (!dbus_connection_register_object_path(bus, "/org/freedesktop/locale1", &locale_vtable, NULL) ||
!dbus_connection_add_filter(bus, bus_exit_idle_filter, &remain_until, NULL)) {
if (!dbus_connection_register_object_path(bus, "/org/freedesktop/locale1", &locale_vtable, NULL) ||
!dbus_connection_add_filter(bus, bus_exit_idle_filter, &remain_until, NULL)) {
- log_error("Not enough memory");
- r = -ENOMEM;
+ r = log_oom();
goto fail;
}
goto fail;
}