1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
9 #include <xkbcommon/xkbcommon.h>
15 #include "alloc-util.h"
16 #include "bus-error.h"
17 #include "bus-log-control-api.h"
18 #include "bus-message.h"
19 #include "bus-polkit.h"
21 #include "dlfcn-util.h"
23 #include "localed-util.h"
25 #include "main-func.h"
26 #include "missing_capability.h"
27 #include "path-util.h"
28 #include "selinux-util.h"
29 #include "service-util.h"
30 #include "signal-util.h"
31 #include "string-util.h"
33 #include "user-util.h"
35 static int locale_update_system_manager(sd_bus
*bus
, char **l_set
, char **l_unset
) {
36 _cleanup_(sd_bus_message_unrefp
) sd_bus_message
*m
= NULL
;
37 _cleanup_(sd_bus_error_free
) sd_bus_error error
= SD_BUS_ERROR_NULL
;
42 r
= sd_bus_message_new_method_call(bus
, &m
,
43 "org.freedesktop.systemd1",
44 "/org/freedesktop/systemd1",
45 "org.freedesktop.systemd1.Manager",
46 "UnsetAndSetEnvironment");
48 return bus_log_create_error(r
);
50 r
= sd_bus_message_append_strv(m
, l_unset
);
52 return bus_log_create_error(r
);
54 r
= sd_bus_message_append_strv(m
, l_set
);
56 return bus_log_create_error(r
);
58 r
= sd_bus_call(bus
, m
, 0, &error
, NULL
);
60 return log_error_errno(r
, "Failed to update the manager environment: %s", bus_error_message(&error
, r
));
65 static int vconsole_reload(sd_bus
*bus
) {
66 _cleanup_(sd_bus_error_free
) sd_bus_error error
= SD_BUS_ERROR_NULL
;
71 r
= sd_bus_call_method(bus
,
72 "org.freedesktop.systemd1",
73 "/org/freedesktop/systemd1",
74 "org.freedesktop.systemd1.Manager",
78 "ss", "systemd-vconsole-setup.service", "replace");
81 return log_error_errno(r
, "Failed to issue method call: %s", bus_error_message(&error
, r
));
86 static int vconsole_convert_to_x11_and_emit(Context
*c
, sd_bus_message
*m
) {
91 r
= x11_read_data(c
, m
);
95 r
= vconsole_convert_to_x11(c
);
100 r
= x11_write_data(c
);
102 return log_error_errno(r
, "Failed to write X11 keyboard layout: %m");
104 sd_bus_emit_properties_changed(sd_bus_message_get_bus(m
),
105 "/org/freedesktop/locale1",
106 "org.freedesktop.locale1",
107 "X11Layout", "X11Model", "X11Variant", "X11Options", NULL
);
112 static int x11_convert_to_vconsole_and_emit(Context
*c
, sd_bus_message
*m
) {
117 r
= vconsole_read_data(c
, m
);
121 r
= x11_convert_to_vconsole(c
);
126 r
= vconsole_write_data(c
);
128 log_error_errno(r
, "Failed to save virtual console keymap: %m");
130 sd_bus_emit_properties_changed(sd_bus_message_get_bus(m
),
131 "/org/freedesktop/locale1",
132 "org.freedesktop.locale1",
133 "VConsoleKeymap", "VConsoleKeymapToggle", NULL
);
135 return vconsole_reload(sd_bus_message_get_bus(m
));
138 static int property_get_locale(
141 const char *interface
,
142 const char *property
,
143 sd_bus_message
*reply
,
145 sd_bus_error
*error
) {
147 Context
*c
= userdata
;
148 _cleanup_strv_free_
char **l
= NULL
;
151 r
= locale_read_data(c
, reply
);
155 r
= locale_context_build_env(&c
->locale_context
, &l
, NULL
);
159 return sd_bus_message_append_strv(reply
, l
);
162 static int property_get_vconsole(
165 const char *interface
,
166 const char *property
,
167 sd_bus_message
*reply
,
169 sd_bus_error
*error
) {
171 Context
*c
= userdata
;
174 r
= vconsole_read_data(c
, reply
);
178 if (streq(property
, "VConsoleKeymap"))
179 return sd_bus_message_append_basic(reply
, 's', c
->vc_keymap
);
180 else if (streq(property
, "VConsoleKeymapToggle"))
181 return sd_bus_message_append_basic(reply
, 's', c
->vc_keymap_toggle
);
186 static int property_get_xkb(
189 const char *interface
,
190 const char *property
,
191 sd_bus_message
*reply
,
193 sd_bus_error
*error
) {
195 Context
*c
= userdata
;
198 r
= x11_read_data(c
, reply
);
202 if (streq(property
, "X11Layout"))
203 return sd_bus_message_append_basic(reply
, 's', c
->x11_layout
);
204 else if (streq(property
, "X11Model"))
205 return sd_bus_message_append_basic(reply
, 's', c
->x11_model
);
206 else if (streq(property
, "X11Variant"))
207 return sd_bus_message_append_basic(reply
, 's', c
->x11_variant
);
208 else if (streq(property
, "X11Options"))
209 return sd_bus_message_append_basic(reply
, 's', c
->x11_options
);
214 static int process_locale_list_item(
215 const char *assignment
,
216 char *new_locale
[static _VARIABLE_LC_MAX
],
218 sd_bus_error
*error
) {
223 for (LocaleVariable p
= 0; p
< _VARIABLE_LC_MAX
; p
++) {
224 const char *name
, *e
;
226 assert_se(name
= locale_variable_to_string(p
));
228 e
= startswith(assignment
, name
);
237 if (!locale_is_valid(e
))
238 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Locale %s is not valid, refusing.", e
);
239 if (!use_localegen
&& locale_is_installed(e
) <= 0)
240 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Locale %s not installed, refusing.", e
);
242 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Locale variable %s set twice, refusing.", name
);
244 new_locale
[p
] = strdup(e
);
251 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Locale assignment %s not valid, refusing.", assignment
);
254 static int locale_gen_process_locale(char *new_locale
[static _VARIABLE_LC_MAX
],
255 sd_bus_error
*error
) {
259 for (LocaleVariable p
= 0; p
< _VARIABLE_LC_MAX
; p
++) {
260 if (p
== VARIABLE_LANGUAGE
)
262 if (isempty(new_locale
[p
]))
264 if (locale_is_installed(new_locale
[p
]))
267 r
= locale_gen_enable_locale(new_locale
[p
]);
269 log_error_errno(r
, "Refused to enable locale for generation: %m");
270 return sd_bus_error_setf(error
,
271 SD_BUS_ERROR_INVALID_ARGS
,
272 "Specified locale is not installed and non-UTF-8 locale will not be auto-generated: %s",
274 } else if (r
== -EINVAL
) {
275 log_error_errno(r
, "Failed to enable invalid locale %s for generation.", new_locale
[p
]);
276 return sd_bus_error_setf(error
,
277 SD_BUS_ERROR_INVALID_ARGS
,
278 "Can not enable locale generation for invalid locale: %s",
281 log_error_errno(r
, "Failed to enable locale for generation: %m");
282 return sd_bus_error_set_errnof(error
, r
, "Failed to enable locale generation: %m");
285 r
= locale_gen_run();
287 log_error_errno(r
, "Failed to generate locale: %m");
288 return sd_bus_error_set_errnof(error
, r
, "Failed to generate locale: %m");
295 static int method_set_locale(sd_bus_message
*m
, void *userdata
, sd_bus_error
*error
) {
296 _cleanup_(locale_variables_freep
) char *new_locale
[_VARIABLE_LC_MAX
] = {};
297 _cleanup_strv_free_
char **l
= NULL
, **l_set
= NULL
, **l_unset
= NULL
;
298 Context
*c
= userdata
;
305 r
= sd_bus_message_read_strv(m
, &l
);
309 r
= sd_bus_message_read_basic(m
, 'b', &interactive
);
313 use_localegen
= locale_gen_check_available();
315 /* If single locale without variable name is provided, then we assume it is LANG=. */
316 if (strv_length(l
) == 1 && !strchr(l
[0], '=')) {
317 if (!locale_is_valid(l
[0]))
318 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Invalid locale specification: %s", l
[0]);
319 if (!use_localegen
&& locale_is_installed(l
[0]) <= 0)
320 return sd_bus_error_setf(error
, SD_BUS_ERROR_INVALID_ARGS
, "Specified locale is not installed: %s", l
[0]);
322 new_locale
[VARIABLE_LANG
] = strdup(l
[0]);
323 if (!new_locale
[VARIABLE_LANG
])
329 /* Check whether a variable is valid */
331 r
= process_locale_list_item(*i
, new_locale
, use_localegen
, error
);
336 /* If LANG was specified, but not LANGUAGE, check if we should
337 * set it based on the language fallback table. */
338 if (!isempty(new_locale
[VARIABLE_LANG
]) &&
339 isempty(new_locale
[VARIABLE_LANGUAGE
])) {
340 _cleanup_free_
char *language
= NULL
;
342 (void) find_language_fallback(new_locale
[VARIABLE_LANG
], &language
);
344 log_debug("Converted LANG=%s to LANGUAGE=%s", new_locale
[VARIABLE_LANG
], language
);
345 free_and_replace(new_locale
[VARIABLE_LANGUAGE
], language
);
349 r
= locale_read_data(c
, m
);
351 log_error_errno(r
, "Failed to read locale data: %m");
352 return sd_bus_error_set(error
, SD_BUS_ERROR_FAILED
, "Failed to read locale data");
355 /* Merge with the current settings */
356 r
= locale_context_merge(&c
->locale_context
, new_locale
);
360 locale_variables_simplify(new_locale
);
362 if (locale_context_equal(&c
->locale_context
, new_locale
)) {
363 log_debug("Locale settings were not modified.");
364 return sd_bus_reply_method_return(m
, NULL
);
367 r
= bus_verify_polkit_async(
370 "org.freedesktop.locale1.set-locale",
379 return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
381 /* Generate locale in case it is missing and the system is using locale-gen */
383 r
= locale_gen_process_locale(new_locale
, error
);
388 locale_context_take(&c
->locale_context
, new_locale
);
390 /* Write locale configuration */
391 r
= locale_context_save(&c
->locale_context
, &l_set
, &l_unset
);
393 log_error_errno(r
, "Failed to set locale: %m");
394 return sd_bus_error_set_errnof(error
, r
, "Failed to set locale: %m");
397 (void) locale_update_system_manager(sd_bus_message_get_bus(m
), l_set
, l_unset
);
399 if (!strv_isempty(l_set
)) {
400 _cleanup_free_
char *line
= NULL
;
402 line
= strv_join(l_set
, ", ");
403 log_info("Changed locale to %s.", strnull(line
));
405 log_info("Changed locale to unset.");
407 (void) sd_bus_emit_properties_changed(
408 sd_bus_message_get_bus(m
),
409 "/org/freedesktop/locale1",
410 "org.freedesktop.locale1",
413 return sd_bus_reply_method_return(m
, NULL
);
416 static int method_set_vc_keyboard(sd_bus_message
*m
, void *userdata
, sd_bus_error
*error
) {
417 Context
*c
= userdata
;
418 const char *keymap
, *keymap_toggle
;
419 int convert
, interactive
, r
;
424 r
= sd_bus_message_read(m
, "ssbb", &keymap
, &keymap_toggle
, &convert
, &interactive
);
428 keymap
= empty_to_null(keymap
);
429 keymap_toggle
= empty_to_null(keymap_toggle
);
431 r
= vconsole_read_data(c
, m
);
433 log_error_errno(r
, "Failed to read virtual console keymap data: %m");
434 return sd_bus_error_set_errnof(error
, r
, "Failed to read virtual console keymap data: %m");
437 FOREACH_STRING(name
, keymap
?: keymap_toggle
, keymap
? keymap_toggle
: NULL
) {
438 r
= keymap_exists(name
); /* This also verifies that the keymap name is kosher. */
440 log_error_errno(r
, "Failed to check keymap %s: %m", name
);
441 return sd_bus_error_set_errnof(error
, r
, "Failed to check keymap %s: %m", name
);
444 return sd_bus_error_setf(error
, SD_BUS_ERROR_FAILED
, "Keymap %s is not installed.", name
);
447 if (streq_ptr(keymap
, c
->vc_keymap
) &&
448 streq_ptr(keymap_toggle
, c
->vc_keymap_toggle
))
449 return sd_bus_reply_method_return(m
, NULL
);
451 r
= bus_verify_polkit_async(
454 "org.freedesktop.locale1.set-keyboard",
463 return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
465 if (free_and_strdup(&c
->vc_keymap
, keymap
) < 0 ||
466 free_and_strdup(&c
->vc_keymap_toggle
, keymap_toggle
) < 0)
469 r
= vconsole_write_data(c
);
471 log_error_errno(r
, "Failed to set virtual console keymap: %m");
472 return sd_bus_error_set_errnof(error
, r
, "Failed to set virtual console keymap: %m");
475 log_info("Changed virtual console keymap to '%s' toggle '%s'",
476 strempty(c
->vc_keymap
), strempty(c
->vc_keymap_toggle
));
478 (void) vconsole_reload(sd_bus_message_get_bus(m
));
480 (void) sd_bus_emit_properties_changed(
481 sd_bus_message_get_bus(m
),
482 "/org/freedesktop/locale1",
483 "org.freedesktop.locale1",
484 "VConsoleKeymap", "VConsoleKeymapToggle", NULL
);
487 r
= vconsole_convert_to_x11_and_emit(c
, m
);
489 log_error_errno(r
, "Failed to convert keymap data: %m");
492 return sd_bus_reply_method_return(m
, NULL
);
498 static void log_xkb(struct xkb_context
*ctx
, enum xkb_log_level lvl
, const char *format
, va_list args
) {
501 fmt
= strjoina("libxkbcommon: ", format
);
502 DISABLE_WARNING_FORMAT_NONLITERAL
;
503 log_internalv(LOG_DEBUG
, 0, PROJECT_FILE
, __LINE__
, __func__
, fmt
, args
);
507 #define LOAD_SYMBOL(symbol, dl, name) \
509 (symbol) = (typeof(symbol)) dlvsym((dl), (name), "V_0.5.0"); \
510 (symbol) ? 0 : -EOPNOTSUPP; \
513 static int verify_xkb_rmlvo(const char *model
, const char *layout
, const char *variant
, const char *options
) {
515 /* We dlopen() the library in order to make the dependency soft. The library (and what it pulls in) is huge
516 * after all, hence let's support XKB maps when the library is around, and refuse otherwise. The function
517 * pointers to the shared library are below: */
519 struct xkb_context
* (*symbol_xkb_context_new
)(enum xkb_context_flags flags
) = NULL
;
520 void (*symbol_xkb_context_unref
)(struct xkb_context
*context
) = NULL
;
521 void (*symbol_xkb_context_set_log_fn
)(struct xkb_context
*context
, void (*log_fn
)(struct xkb_context
*context
, enum xkb_log_level level
, const char *format
, va_list args
)) = NULL
;
522 struct xkb_keymap
* (*symbol_xkb_keymap_new_from_names
)(struct xkb_context
*context
, const struct xkb_rule_names
*names
, enum xkb_keymap_compile_flags flags
) = NULL
;
523 void (*symbol_xkb_keymap_unref
)(struct xkb_keymap
*keymap
) = NULL
;
525 const struct xkb_rule_names rmlvo
= {
531 struct xkb_context
*ctx
= NULL
;
532 struct xkb_keymap
*km
= NULL
;
533 _cleanup_(dlclosep
) void *dl
= NULL
;
536 /* Compile keymap from RMLVO information to check out its validity */
538 dl
= dlopen("libxkbcommon.so.0", RTLD_LAZY
);
542 r
= LOAD_SYMBOL(symbol_xkb_context_new
, dl
, "xkb_context_new");
546 r
= LOAD_SYMBOL(symbol_xkb_context_unref
, dl
, "xkb_context_unref");
550 r
= LOAD_SYMBOL(symbol_xkb_context_set_log_fn
, dl
, "xkb_context_set_log_fn");
554 r
= LOAD_SYMBOL(symbol_xkb_keymap_new_from_names
, dl
, "xkb_keymap_new_from_names");
558 r
= LOAD_SYMBOL(symbol_xkb_keymap_unref
, dl
, "xkb_keymap_unref");
562 ctx
= symbol_xkb_context_new(XKB_CONTEXT_NO_ENVIRONMENT_NAMES
);
568 symbol_xkb_context_set_log_fn(ctx
, log_xkb
);
570 km
= symbol_xkb_keymap_new_from_names(ctx
, &rmlvo
, XKB_KEYMAP_COMPILE_NO_FLAGS
);
579 if (symbol_xkb_keymap_unref
&& km
)
580 symbol_xkb_keymap_unref(km
);
582 if (symbol_xkb_context_unref
&& ctx
)
583 symbol_xkb_context_unref(ctx
);
590 static int verify_xkb_rmlvo(const char *model
, const char *layout
, const char *variant
, const char *options
) {
596 static int method_set_x11_keyboard(sd_bus_message
*m
, void *userdata
, sd_bus_error
*error
) {
597 Context
*c
= userdata
;
598 const char *layout
, *model
, *variant
, *options
;
599 int convert
, interactive
, r
;
604 r
= sd_bus_message_read(m
, "ssssbb", &layout
, &model
, &variant
, &options
, &convert
, &interactive
);
608 layout
= empty_to_null(layout
);
609 model
= empty_to_null(model
);
610 variant
= empty_to_null(variant
);
611 options
= empty_to_null(options
);
613 r
= x11_read_data(c
, m
);
615 log_error_errno(r
, "Failed to read x11 keyboard layout data: %m");
616 return sd_bus_error_set(error
, SD_BUS_ERROR_FAILED
, "Failed to read x11 keyboard layout data");
619 if (streq_ptr(layout
, c
->x11_layout
) &&
620 streq_ptr(model
, c
->x11_model
) &&
621 streq_ptr(variant
, c
->x11_variant
) &&
622 streq_ptr(options
, c
->x11_options
))
623 return sd_bus_reply_method_return(m
, NULL
);
625 if ((layout
&& !string_is_safe(layout
)) ||
626 (model
&& !string_is_safe(model
)) ||
627 (variant
&& !string_is_safe(variant
)) ||
628 (options
&& !string_is_safe(options
)))
629 return sd_bus_error_set(error
, SD_BUS_ERROR_INVALID_ARGS
, "Received invalid keyboard data");
631 r
= verify_xkb_rmlvo(model
, layout
, variant
, options
);
633 log_error_errno(r
, "Cannot compile XKB keymap for new x11 keyboard layout ('%s' / '%s' / '%s' / '%s'): %m",
634 strempty(model
), strempty(layout
), strempty(variant
), strempty(options
));
636 if (r
== -EOPNOTSUPP
)
637 return sd_bus_error_set(error
, SD_BUS_ERROR_NOT_SUPPORTED
, "Local keyboard configuration not supported on this system.");
639 return sd_bus_error_set(error
, SD_BUS_ERROR_INVALID_ARGS
, "Specified keymap cannot be compiled, refusing as invalid.");
642 r
= bus_verify_polkit_async(
645 "org.freedesktop.locale1.set-keyboard",
654 return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
656 if (free_and_strdup(&c
->x11_layout
, layout
) < 0 ||
657 free_and_strdup(&c
->x11_model
, model
) < 0 ||
658 free_and_strdup(&c
->x11_variant
, variant
) < 0 ||
659 free_and_strdup(&c
->x11_options
, options
) < 0)
662 r
= x11_write_data(c
);
664 log_error_errno(r
, "Failed to set X11 keyboard layout: %m");
665 return sd_bus_error_set_errnof(error
, r
, "Failed to set X11 keyboard layout: %m");
668 log_info("Changed X11 keyboard layout to '%s' model '%s' variant '%s' options '%s'",
669 strempty(c
->x11_layout
),
670 strempty(c
->x11_model
),
671 strempty(c
->x11_variant
),
672 strempty(c
->x11_options
));
674 (void) sd_bus_emit_properties_changed(
675 sd_bus_message_get_bus(m
),
676 "/org/freedesktop/locale1",
677 "org.freedesktop.locale1",
678 "X11Layout", "X11Model", "X11Variant", "X11Options", NULL
);
681 r
= x11_convert_to_vconsole_and_emit(c
, m
);
683 log_error_errno(r
, "Failed to convert keymap data: %m");
686 return sd_bus_reply_method_return(m
, NULL
);
689 static const sd_bus_vtable locale_vtable
[] = {
690 SD_BUS_VTABLE_START(0),
691 SD_BUS_PROPERTY("Locale", "as", property_get_locale
, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE
),
692 SD_BUS_PROPERTY("X11Layout", "s", property_get_xkb
, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE
),
693 SD_BUS_PROPERTY("X11Model", "s", property_get_xkb
, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE
),
694 SD_BUS_PROPERTY("X11Variant", "s", property_get_xkb
, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE
),
695 SD_BUS_PROPERTY("X11Options", "s", property_get_xkb
, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE
),
696 SD_BUS_PROPERTY("VConsoleKeymap", "s", property_get_vconsole
, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE
),
697 SD_BUS_PROPERTY("VConsoleKeymapToggle", "s", property_get_vconsole
, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE
),
699 SD_BUS_METHOD_WITH_NAMES("SetLocale",
702 SD_BUS_PARAM(interactive
),
705 SD_BUS_VTABLE_UNPRIVILEGED
),
706 SD_BUS_METHOD_WITH_NAMES("SetVConsoleKeyboard",
709 SD_BUS_PARAM(keymap_toggle
)
710 SD_BUS_PARAM(convert
)
711 SD_BUS_PARAM(interactive
),
713 method_set_vc_keyboard
,
714 SD_BUS_VTABLE_UNPRIVILEGED
),
715 SD_BUS_METHOD_WITH_NAMES("SetX11Keyboard",
719 SD_BUS_PARAM(variant
)
720 SD_BUS_PARAM(options
)
721 SD_BUS_PARAM(convert
)
722 SD_BUS_PARAM(interactive
),
724 method_set_x11_keyboard
,
725 SD_BUS_VTABLE_UNPRIVILEGED
),
730 static const BusObjectImplementation manager_object
= {
731 "/org/freedesktop/locale1",
732 "org.freedesktop.locale1",
733 .vtables
= BUS_VTABLES(locale_vtable
),
736 static int connect_bus(Context
*c
, sd_event
*event
, sd_bus
**_bus
) {
737 _cleanup_(sd_bus_flush_close_unrefp
) sd_bus
*bus
= NULL
;
744 r
= sd_bus_default_system(&bus
);
746 return log_error_errno(r
, "Failed to get system bus connection: %m");
748 r
= bus_add_implementation(bus
, &manager_object
, c
);
752 r
= bus_log_control_api_register(bus
);
756 r
= sd_bus_request_name_async(bus
, NULL
, "org.freedesktop.locale1", 0, NULL
, NULL
);
758 return log_error_errno(r
, "Failed to request name: %m");
760 r
= sd_bus_attach_event(bus
, event
, 0);
762 return log_error_errno(r
, "Failed to attach bus to event loop: %m");
764 *_bus
= TAKE_PTR(bus
);
769 static int run(int argc
, char *argv
[]) {
770 _cleanup_(context_clear
) Context context
= {
771 .locale_context
.mtime
= USEC_INFINITY
,
772 .vc_mtime
= USEC_INFINITY
,
773 .x11_mtime
= USEC_INFINITY
,
775 _cleanup_(sd_event_unrefp
) sd_event
*event
= NULL
;
776 _cleanup_(sd_bus_flush_close_unrefp
) sd_bus
*bus
= NULL
;
781 r
= service_parse_argv("systemd-localed.service",
782 "Manage system locale settings and key mappings.",
783 BUS_IMPLEMENTATIONS(&manager_object
,
784 &log_control_object
),
791 r
= mac_selinux_init();
795 assert_se(sigprocmask_many(SIG_BLOCK
, NULL
, SIGTERM
, SIGINT
, -1) >= 0);
797 r
= sd_event_default(&event
);
799 return log_error_errno(r
, "Failed to allocate event loop: %m");
801 (void) sd_event_set_watchdog(event
, true);
803 r
= sd_event_add_signal(event
, NULL
, SIGINT
, NULL
, NULL
);
805 return log_error_errno(r
, "Failed to install SIGINT handler: %m");
807 r
= sd_event_add_signal(event
, NULL
, SIGTERM
, NULL
, NULL
);
809 return log_error_errno(r
, "Failed to install SIGTERM handler: %m");
811 r
= connect_bus(&context
, event
, &bus
);
815 r
= bus_event_loop_with_idle(event
, bus
, "org.freedesktop.locale1", DEFAULT_EXIT_USEC
, NULL
, NULL
);
817 return log_error_errno(r
, "Failed to run event loop: %m");
822 DEFINE_MAIN_FUNCTION(run
);