X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Flocale%2Flocaled.c;h=508a00079e20002eac837c9659cfd174bd321ecf;hb=f38857914ab5c9cc55aac05795e1886963a5fd04;hp=d6ffe67520506dea260f1ceadaba063a2ec0607f;hpb=7568345034f2890af745747783c5abfbf6eccf0f;p=elogind.git diff --git a/src/locale/localed.c b/src/locale/localed.c index d6ffe6752..508a00079 100644 --- a/src/locale/localed.c +++ b/src/locale/localed.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "sd-bus.h" @@ -131,12 +132,12 @@ static void context_free_locale(Context *c) { free_and_replace(&c->locale[p], NULL); } -static void context_free(Context *c, sd_bus *bus) { +static void context_free(Context *c) { context_free_locale(c); context_free_x11(c); context_free_vconsole(c); - bus_verify_polkit_async_registry_free(bus, c->polkit_registry); + bus_verify_polkit_async_registry_free(c->polkit_registry); }; static void locale_simplify(Context *c) { @@ -210,6 +211,7 @@ static int x11_read_data(Context *c) { FILE *f; char line[LINE_MAX]; bool in_section = false; + int r; context_free_x11(c); @@ -229,10 +231,10 @@ static int x11_read_data(Context *c) { if (in_section && first_word(l, "Option")) { char **a; - a = strv_split_quoted(l); - if (!a) { + r = strv_split_quoted(&a, l); + if (r < 0) { fclose(f); - return -ENOMEM; + return r; } if (strv_length(a) == 3) { @@ -256,8 +258,8 @@ static int x11_read_data(Context *c) { } else if (!in_section && first_word(l, "Section")) { char **a; - a = strv_split_quoted(l); - if (!a) { + r = strv_split_quoted(&a, l); + if (r < 0) { fclose(f); return -ENOMEM; } @@ -533,6 +535,7 @@ static int read_next_mapping(FILE *f, unsigned *n, char ***a) { for (;;) { char line[LINE_MAX]; char *l, **b; + int r; errno = 0; if (!fgets(line, sizeof(line), f)) { @@ -549,9 +552,9 @@ static int read_next_mapping(FILE *f, unsigned *n, char ***a) { if (l[0] == 0 || l[0] == '#') continue; - b = strv_split_quoted(l); - if (!b) - return -ENOMEM; + r = strv_split_quoted(&b, l); + if (r < 0) + return r; if (strv_length(b) < 5) { log_error("Invalid line "SYSTEMD_KBD_MODEL_MAP":%u, ignoring.", *n); @@ -874,9 +877,7 @@ static int method_set_locale(sd_bus *bus, sd_bus_message *m, void *userdata, sd_ } if (modified) { - r = bus_verify_polkit_async(bus, &c->polkit_registry, m, - "org.freedesktop.locale1.set-locale", interactive, - error, method_set_locale, c); + r = bus_verify_polkit_async(m, CAP_SYS_ADMIN, "org.freedesktop.locale1.set-locale", interactive, &c->polkit_registry, error); if (r < 0) return r; if (r == 0) @@ -952,9 +953,7 @@ static int method_set_vc_keyboard(sd_bus *bus, sd_bus_message *m, void *userdata (keymap_toggle && (!filename_is_safe(keymap_toggle) || !string_is_safe(keymap_toggle)))) return sd_bus_error_set_errnof(error, -EINVAL, "Received invalid keymap data"); - r = bus_verify_polkit_async(bus, &c->polkit_registry, m, - "org.freedesktop.locale1.set-keyboard", - interactive, error, method_set_vc_keyboard, c); + r = bus_verify_polkit_async(m, CAP_SYS_ADMIN, "org.freedesktop.locale1.set-keyboard", interactive, &c->polkit_registry, error); if (r < 0) return r; if (r == 0) @@ -1024,9 +1023,7 @@ 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(bus, &c->polkit_registry, m, - "org.freedesktop.locale1.set-keyboard", - interactive, error, method_set_x11_keyboard, c); + r = bus_verify_polkit_async(m, CAP_SYS_ADMIN, "org.freedesktop.locale1.set-keyboard", interactive, &c->polkit_registry, error); if (r < 0) return r; if (r == 0) @@ -1077,7 +1074,7 @@ static const sd_bus_vtable locale_vtable[] = { }; static int connect_bus(Context *c, sd_event *event, sd_bus **_bus) { - _cleanup_bus_unref_ sd_bus *bus = NULL; + _cleanup_bus_close_unref_ sd_bus *bus = NULL; int r; assert(c); @@ -1117,7 +1114,7 @@ static int connect_bus(Context *c, sd_event *event, sd_bus **_bus) { int main(int argc, char *argv[]) { Context context = {}; _cleanup_event_unref_ sd_event *event = NULL; - _cleanup_bus_unref_ sd_bus *bus = NULL; + _cleanup_bus_close_unref_ sd_bus *bus = NULL; int r; log_set_target(LOG_TARGET_AUTO); @@ -1158,7 +1155,7 @@ int main(int argc, char *argv[]) { } finish: - context_free(&context, bus); + context_free(&context); return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; }