diff options
Diffstat (limited to 'src/locale')
-rw-r--r-- | src/locale/localectl.c | 10 | ||||
-rw-r--r-- | src/locale/localed.c | 66 |
2 files changed, 51 insertions, 25 deletions
diff --git a/src/locale/localectl.c b/src/locale/localectl.c index 41a88a828c..8c60339e3e 100644 --- a/src/locale/localectl.c +++ b/src/locale/localectl.c @@ -23,25 +23,19 @@ #include <locale.h> #include <stdlib.h> #include <stdbool.h> -#include <unistd.h> #include <getopt.h> #include <string.h> #include <ftw.h> -#include <sys/mman.h> -#include <fcntl.h> #include "sd-bus.h" #include "bus-util.h" #include "bus-error.h" -#include "bus-message.h" #include "util.h" #include "spawn-polkit-agent.h" #include "build.h" #include "strv.h" #include "pager.h" #include "set.h" -#include "path-util.h" -#include "utf8.h" #include "def.h" #include "virt.h" #include "fileio.h" @@ -83,7 +77,7 @@ typedef struct StatusInfo { const char *x11_options; } StatusInfo; -static void print_overriden_variables(void) { +static void print_overridden_variables(void) { int r; char *variables[_VARIABLE_LC_MAX] = {}; LocaleVariable j; @@ -182,7 +176,7 @@ static int show_status(sd_bus *bus, char **args, unsigned n) { goto fail; } - print_overriden_variables(); + print_overridden_variables(); print_status_info(&info); fail: diff --git a/src/locale/localed.c b/src/locale/localed.c index d1c90d613a..0e59350e98 100644 --- a/src/locale/localed.c +++ b/src/locale/localed.c @@ -33,7 +33,6 @@ #include "env-util.h" #include "fileio.h" #include "fileio-label.h" -#include "label.h" #include "bus-util.h" #include "bus-error.h" #include "bus-message.h" @@ -228,7 +227,7 @@ static int x11_read_data(Context *c) { if (in_section && first_word(l, "Option")) { _cleanup_strv_free_ char **a = NULL; - r = strv_split_quoted(&a, l, false); + r = strv_split_quoted(&a, l, 0); if (r < 0) return r; @@ -251,7 +250,7 @@ static int x11_read_data(Context *c) { } else if (!in_section && first_word(l, "Section")) { _cleanup_strv_free_ char **a = NULL; - r = strv_split_quoted(&a, l, false); + r = strv_split_quoted(&a, l, 0); if (r < 0) return -ENOMEM; @@ -540,7 +539,7 @@ static int read_next_mapping(const char* filename, if (l[0] == 0 || l[0] == '#') continue; - r = strv_split_quoted(&b, l, false); + r = strv_split_quoted(&b, l, 0); if (r < 0) return r; @@ -870,7 +869,7 @@ static int property_get_locale( return sd_bus_message_append_strv(reply, l); } -static int method_set_locale(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *error) { +static int method_set_locale(sd_bus_message *m, void *userdata, sd_bus_error *error) { Context *c = userdata; _cleanup_strv_free_ char **l = NULL; char **i; @@ -881,6 +880,9 @@ static int method_set_locale(sd_bus *bus, sd_bus_message *m, void *userdata, sd_ int p; int r; + assert(m); + assert(c); + r = bus_message_read_strv_extend(m, &l); if (r < 0) return r; @@ -949,7 +951,14 @@ static int method_set_locale(sd_bus *bus, sd_bus_message *m, void *userdata, sd_ if (modified) { _cleanup_strv_free_ char **settings = NULL; - r = bus_verify_polkit_async(m, CAP_SYS_ADMIN, "org.freedesktop.locale1.set-locale", interactive, &c->polkit_registry, error); + r = bus_verify_polkit_async( + m, + CAP_SYS_ADMIN, + "org.freedesktop.locale1.set-locale", + interactive, + UID_INVALID, + &c->polkit_registry, + error); if (r < 0) return r; if (r == 0) @@ -983,7 +992,7 @@ static int method_set_locale(sd_bus *bus, sd_bus_message *m, void *userdata, sd_ return sd_bus_error_set_errnof(error, r, "Failed to set locale: %s", strerror(-r)); } - locale_update_system_manager(c, bus); + locale_update_system_manager(c, sd_bus_message_get_bus(m)); if (settings) { _cleanup_free_ char *line; @@ -993,7 +1002,8 @@ static int method_set_locale(sd_bus *bus, sd_bus_message *m, void *userdata, sd_ } else log_info("Changed locale to unset."); - sd_bus_emit_properties_changed(bus, + (void) sd_bus_emit_properties_changed( + sd_bus_message_get_bus(m), "/org/freedesktop/locale1", "org.freedesktop.locale1", "Locale", NULL); @@ -1004,12 +1014,15 @@ static int method_set_locale(sd_bus *bus, sd_bus_message *m, void *userdata, sd_ return sd_bus_reply_method_return(m, NULL); } -static int method_set_vc_keyboard(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *error) { +static int method_set_vc_keyboard(sd_bus_message *m, void *userdata, sd_bus_error *error) { Context *c = userdata; const char *keymap, *keymap_toggle; int convert, interactive; int r; + assert(m); + assert(c); + r = sd_bus_message_read(m, "ssbb", &keymap, &keymap_toggle, &convert, &interactive); if (r < 0) return r; @@ -1027,7 +1040,14 @@ static int method_set_vc_keyboard(sd_bus *bus, sd_bus_message *m, void *userdata (keymap_toggle && (!filename_is_valid(keymap_toggle) || !string_is_safe(keymap_toggle)))) return sd_bus_error_set_errnof(error, -EINVAL, "Received invalid keymap data"); - r = bus_verify_polkit_async(m, CAP_SYS_ADMIN, "org.freedesktop.locale1.set-keyboard", interactive, &c->polkit_registry, error); + r = bus_verify_polkit_async( + m, + CAP_SYS_ADMIN, + "org.freedesktop.locale1.set-keyboard", + interactive, + UID_INVALID, + &c->polkit_registry, + error); if (r < 0) return r; if (r == 0) @@ -1046,17 +1066,18 @@ static int method_set_vc_keyboard(sd_bus *bus, sd_bus_message *m, void *userdata log_info("Changed virtual console keymap to '%s' toggle '%s'", strempty(c->vc_keymap), strempty(c->vc_keymap_toggle)); - r = vconsole_reload(bus); + r = vconsole_reload(sd_bus_message_get_bus(m)); if (r < 0) log_error_errno(r, "Failed to request keymap reload: %m"); - sd_bus_emit_properties_changed(bus, + (void) sd_bus_emit_properties_changed( + sd_bus_message_get_bus(m), "/org/freedesktop/locale1", "org.freedesktop.locale1", "VConsoleKeymap", "VConsoleKeymapToggle", NULL); if (convert) { - r = vconsole_convert_to_x11(c, bus); + r = vconsole_convert_to_x11(c, sd_bus_message_get_bus(m)); if (r < 0) log_error_errno(r, "Failed to convert keymap data: %m"); } @@ -1113,12 +1134,15 @@ static int verify_xkb_rmlvo(const char *model, const char *layout, const char *v } #endif -static int method_set_x11_keyboard(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *error) { +static int method_set_x11_keyboard(sd_bus_message *m, void *userdata, sd_bus_error *error) { Context *c = userdata; const char *layout, *model, *variant, *options; int convert, interactive; int r; + assert(m); + assert(c); + r = sd_bus_message_read(m, "ssssbb", &layout, &model, &variant, &options, &convert, &interactive); if (r < 0) return r; @@ -1146,7 +1170,14 @@ static int method_set_x11_keyboard(sd_bus *bus, sd_bus_message *m, void *userdat (options && !string_is_safe(options))) return sd_bus_error_set_errnof(error, -EINVAL, "Received invalid keyboard data"); - r = bus_verify_polkit_async(m, CAP_SYS_ADMIN, "org.freedesktop.locale1.set-keyboard", interactive, &c->polkit_registry, error); + r = bus_verify_polkit_async( + m, + CAP_SYS_ADMIN, + "org.freedesktop.locale1.set-keyboard", + interactive, + UID_INVALID, + &c->polkit_registry, + error); if (r < 0) return r; if (r == 0) @@ -1177,13 +1208,14 @@ static int method_set_x11_keyboard(sd_bus *bus, sd_bus_message *m, void *userdat strempty(c->x11_variant), strempty(c->x11_options)); - sd_bus_emit_properties_changed(bus, + (void) sd_bus_emit_properties_changed( + sd_bus_message_get_bus(m), "/org/freedesktop/locale1", "org.freedesktop.locale1", "X11Layout", "X11Model", "X11Variant", "X11Options", NULL); if (convert) { - r = x11_convert_to_vconsole(c, bus); + r = x11_convert_to_vconsole(c, sd_bus_message_get_bus(m)); if (r < 0) log_error_errno(r, "Failed to convert keymap data: %m"); } |