chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
localectl: add support for listing X11 keymap information
[elogind.git]
/
src
/
locale
/
localed.c
diff --git
a/src/locale/localed.c
b/src/locale/localed.c
index a2d381406c6da0ac3beb9809e154b4da7e9ae7ca..df812ee651ea1f71a36c3ecb48c85058665f94ce 100644
(file)
--- a/
src/locale/localed.c
+++ b/
src/locale/localed.c
@@
-31,6
+31,10
@@
#include "dbus-common.h"
#include "polkit.h"
#include "def.h"
#include "dbus-common.h"
#include "polkit.h"
#include "def.h"
+#include "env-util.h"
+#include "fileio.h"
+#include "fileio-label.h"
+#include "label.h"
#define INTERFACE \
" <interface name=\"org.freedesktop.locale1\">\n" \
#define INTERFACE \
" <interface name=\"org.freedesktop.locale1\">\n" \
@@
-351,7
+355,7
@@
static int write_data_locale(void) {
int r, p;
char **l = NULL;
int r, p;
char **l = NULL;
- r = load_env_file("/etc/locale.conf", &l);
+ r = load_env_file("/etc/locale.conf",
NULL,
&l);
if (r < 0 && r != -ENOENT)
return r;
if (r < 0 && r != -ENOENT)
return r;
@@
-389,7
+393,7
@@
static int write_data_locale(void) {
return 0;
}
return 0;
}
- r = write_env_file("/etc/locale.conf", l);
+ r = write_env_file
_label
("/etc/locale.conf", l);
strv_free(l);
return r;
strv_free(l);
return r;
@@
-490,7
+494,7
@@
static int write_data_vconsole(void) {
int r;
char **l = NULL;
int r;
char **l = NULL;
- r = load_env_file("/etc/vconsole.conf", &l);
+ r = load_env_file("/etc/vconsole.conf",
NULL,
&l);
if (r < 0 && r != -ENOENT)
return r;
if (r < 0 && r != -ENOENT)
return r;
@@
-545,7
+549,7
@@
static int write_data_vconsole(void) {
return 0;
}
return 0;
}
- r = write_env_file("/etc/vconsole.conf", l);
+ r = write_env_file
_label
("/etc/vconsole.conf", l);
strv_free(l);
return r;
strv_free(l);
return r;
@@
-567,7
+571,7
@@
static int write_data_x11(void) {
return 0;
}
return 0;
}
- mkdir_p
arents
_label("/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)
@@
-853,7
+857,7
@@
static int convert_x11_to_vconsole(DBusConnection *connection) {
* layout stripped off. */
if (x > 0 &&
strlen(a[1]) == x &&
* layout stripped off. */
if (x > 0 &&
strlen(a[1]) == x &&
- strn
cmp(state.x11_layout, a[1], x) == 0
)
+ strn
eq(state.x11_layout, a[1], x)
)
matching = 5;
else {
size_t w;
matching = 5;
else {
size_t w;
@@
-1039,7
+1043,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;
@@
-1150,6
+1156,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);
@@
-1220,6
+1230,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);
@@
-1261,7
+1277,7
@@
static DBusHandlerResult locale_message_handler(
if (!(reply = dbus_message_new_method_return(message)))
goto oom;
if (!(reply = dbus_message_new_method_return(message)))
goto oom;
- if (!
dbus_connection_send(connection, reply, NULL
))
+ if (!
bus_maybe_send_reply(connection, message, reply
))
goto oom;
dbus_message_unref(reply);
goto oom;
dbus_message_unref(reply);
@@
-1351,7
+1367,7
@@
int main(int argc, char *argv[]) {
log_set_target(LOG_TARGET_AUTO);
log_parse_environment();
log_open();
log_set_target(LOG_TARGET_AUTO);
log_parse_environment();
log_open();
-
+ label_init("/etc");
umask(0022);
if (argc == 2 && streq(argv[1], "--introspect")) {
umask(0022);
if (argc == 2 && streq(argv[1], "--introspect")) {