#include "strv.h"
#include "dbus-common.h"
#include "polkit.h"
+#include "def.h"
#define INTERFACE \
" <interface name=\"org.freedesktop.locale1\">\n" \
* using LANG instead. */
PROP_LANG,
+ PROP_LANGUAGE,
PROP_LC_CTYPE,
PROP_LC_NUMERIC,
PROP_LC_TIME,
static const char * const names[_PROP_MAX] = {
[PROP_LANG] = "LANG",
+ [PROP_LANGUAGE] = "LANGUAGE",
[PROP_LC_CTYPE] = "LC_CTYPE",
[PROP_LC_NUMERIC] = "LC_NUMERIC",
[PROP_LC_TIME] = "LC_TIME",
NULL
};
+static usec_t remain_until = 0;
+
static void free_data(void) {
int p;
r = parse_env_file("/etc/locale.conf", NEWLINE,
"LANG", &data[PROP_LANG],
+ "LANGUAGE", &data[PROP_LANGUAGE],
"LC_CTYPE", &data[PROP_LC_CTYPE],
"LC_NUMERIC", &data[PROP_LC_NUMERIC],
"LC_TIME", &data[PROP_LC_TIME],
}
if (strv_isempty(l)) {
+ strv_free(l);
if (unlink("/etc/locale.conf") < 0)
return errno == ENOENT ? 0 : -errno;
}
}
+ strv_free(l);
+
for (p = 0; p < _PROP_MAX; p++) {
if (passed[p])
continue;
goto fail;
}
- if (!dbus_connection_register_object_path(bus, "/org/freedesktop/locale1", &locale_vtable, NULL)) {
+ dbus_connection_set_exit_on_disconnect(bus, FALSE);
+
+ 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;
goto fail;
int main(int argc, char *argv[]) {
int r;
DBusConnection *bus = NULL;
+ bool exiting = false;
log_set_target(LOG_TARGET_AUTO);
log_parse_environment();
log_open();
+ umask(0022);
+
if (argc == 2 && streq(argv[1], "--introspect")) {
fputs(DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE
"<node>\n", stdout);
goto finish;
}
- umask(0022);
-
r = read_data();
if (r < 0) {
log_error("Failed to read locale data: %s", strerror(-r));
if (r < 0)
goto finish;
- while (dbus_connection_read_write_dispatch(bus, -1))
- ;
+ remain_until = now(CLOCK_MONOTONIC) + DEFAULT_EXIT_USEC;
+ for (;;) {
+
+ if (!dbus_connection_read_write_dispatch(bus, exiting ? -1 : (int) (DEFAULT_EXIT_USEC/USEC_PER_MSEC)))
+ break;
+
+ if (!exiting && remain_until < now(CLOCK_MONOTONIC)) {
+ exiting = true;
+ bus_async_unregister_and_exit(bus, "org.freedesktop.locale1");
+ }
+ }
r = 0;