#include <string.h>
#include <unistd.h>
-#include "label.h"
#include "sd-daemon.h"
#include "strv.h"
#include "conf-parser.h"
#include "bus-util.h"
#include "bus-error.h"
-#include "logind.h"
#include "udev-util.h"
+#include "signal-util.h"
+#include "logind.h"
Manager *manager_new(void) {
Manager *m;
if (!m->kill_exclude_users)
goto fail;
- m->suspend_mode = NULL;
- m->suspend_state = strv_new("mem", "standby", "freeze", NULL);
- if (!m->suspend_state)
- goto fail;
- m->hibernate_mode = strv_new("platform", "shutdown", NULL);
- if (!m->hibernate_mode)
- goto fail;
- m->hibernate_state = strv_new("disk", NULL);
- if (!m->hibernate_state)
- goto fail;
- m->hybrid_sleep_mode = strv_new("suspend", "platform", "shutdown", NULL);
- if (!m->hybrid_sleep_mode)
- goto fail;
- m->hybrid_sleep_state = strv_new("disk", NULL);
- if (!m->hybrid_sleep_state)
- goto fail;
-
m->udev = udev_new();
if (!m->udev)
goto fail;
sd_event_set_watchdog(m->event, true);
-
return m;
fail:
strv_free(m->kill_only_users);
strv_free(m->kill_exclude_users);
- strv_free(m->suspend_mode);
- strv_free(m->suspend_state);
- strv_free(m->hibernate_mode);
- strv_free(m->hibernate_state);
- strv_free(m->hybrid_sleep_mode);
- strv_free(m->hybrid_sleep_state);
-
free(m);
}
return 0;
}
+static int manager_dispatch_vcsa_udev(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
+ _cleanup_udev_device_unref_ struct udev_device *d = NULL;
+ Manager *m = userdata;
+ const char *name;
+
+ assert(m);
+
+ d = udev_monitor_receive_device(m->udev_vcsa_monitor);
+ if (!d)
+ return -ENOMEM;
+
+ name = udev_device_get_sysname(d);
+
+ /* Whenever a VCSA device is removed try to reallocate our
+ * VTs, to make sure our auto VTs never go away. */
+
+ if (name && startswith(name, "vcsa") && streq_ptr(udev_device_get_action(d), "remove"))
+ seat_preallocate_vts(m->seat0);
+
+ return 0;
+}
+
static int manager_dispatch_button_udev(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
_cleanup_udev_device_unref_ struct udev_device *d = NULL;
Manager *m = userdata;
return -EINVAL;
}
- r = ignore_signals(SIGRTMIN + 1, -1);
- if (r < 0)
- return log_error_errno(r, "Cannot ignore SIGRTMIN + 1: %m");
-
- r = sigprocmask_many(SIG_BLOCK, SIGRTMIN, -1);
- if (r < 0)
- return log_error_errno(r, "Cannot block SIGRTMIN: %m");
+ assert_se(ignore_signals(SIGRTMIN + 1, -1) >= 0);
+ assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGRTMIN, -1) >= 0);
r = sd_event_add_signal(m->event, NULL, SIGRTMIN, manager_vt_switch, m);
if (r < 0)
}
static int manager_parse_config_file(Manager *m) {
- const char *unit, *logind_conf, *sections;
- FILE *file;
- bool relaxed, allow_include, warn;
-
assert(m);
- unit = NULL;
- logind_conf = getenv("ELOGIND_CONF_FILE");
- if (!logind_conf)
- logind_conf = PKGSYSCONFDIR "/logind.conf";
- sections = "Login\0Sleep\0";
- file = NULL;
- relaxed = false;
- allow_include = false;
- warn = true;
-
- return config_parse(unit, logind_conf, file, sections,
- config_item_perf_lookup, logind_gperf_lookup,
- relaxed, allow_include, warn, m);
+ return config_parse_many("/etc/systemd/logind.conf",
+ CONF_DIRS_NULSTR("systemd/logind.conf"),
+ "Login\0",
+ config_item_perf_lookup, logind_gperf_lookup,
+ false, m);
}
int main(int argc, char *argv[]) {
* existence of /run/systemd/seats/ to determine whether
* logind is available, so please always make sure this check
* stays in. */
+ mkdir_label("/run/systemd", 0755);
mkdir_label("/run/systemd/seats", 0755);
mkdir_label("/run/systemd/users", 0755);
mkdir_label("/run/systemd/sessions", 0755);
- mkdir_label("/run/systemd/machines", 0755);
m = manager_new();
if (!m) {