logind.c revision 0a1beeb64207eaa88ab9236787b1cbc2f704ae14
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering This file is part of systemd.
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering Copyright 2011 Lennart Poettering
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering systemd is free software; you can redistribute it and/or modify it
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering under the terms of the GNU Lesser General Public License as published by
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering (at your option) any later version.
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering systemd is distributed in the hope that it will be useful, but
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering Lesser General Public License for more details.
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering You should have received a copy of the GNU Lesser General Public License
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
m->lid_switch_ignore_inhibited = true;
if (!m->devices || !m->seats || !m->sessions || !m->users || !m->inhibitors || !m->buttons || !m->busnames ||
goto fail;
if (!m->kill_exclude_users)
goto fail;
if (!m->udev)
goto fail;
goto fail;
fail:
manager_free(m);
return NULL;
User *u;
Device *d;
Seat *s;
Inhibitor *i;
Button *b;
assert(m);
user_free(u);
device_free(d);
seat_free(s);
inhibitor_free(i);
button_free(b);
if (m->udev_seat_monitor)
if (m->udev_device_monitor)
if (m->udev_vcsa_monitor)
if (m->udev_button_monitor)
if (m->udev)
free(m);
assert(m);
return -ENOMEM;
r = udev_enumerate_scan_devices(e);
return -ENOMEM;
k = manager_process_seat_device(m, d);
assert(m);
return -ENOMEM;
r = udev_enumerate_scan_devices(e);
return -ENOMEM;
k = manager_process_button_device(m, d);
assert(m);
return -errno;
Seat *s;
k = seat_load(s);
assert(m);
return -errno;
assert(m);
r = manager_enumerate_linger_users(m);
return -errno;
User *u;
k = user_load(u);
assert(m);
return -errno;
struct Session *s;
r = -EINVAL;
k = session_load(s);
assert(m);
return -errno;
Inhibitor *i;
k = inhibitor_load(i);
static int manager_dispatch_seat_udev(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
assert(m);
return -ENOMEM;
manager_process_seat_device(m, d);
static int manager_dispatch_device_udev(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
assert(m);
return -ENOMEM;
manager_process_seat_device(m, d);
static int manager_dispatch_vcsa_udev(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
const char *name;
assert(m);
return -ENOMEM;
static int manager_dispatch_button_udev(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
assert(m);
return -ENOMEM;
assert(m);
assert(m);
if (m->reserve_vt <= 0)
return log_oom();
if (m->reserve_vt_fd < 0) {
return -errno;
assert(m);
r = sd_bus_add_object_vtable(m->bus, NULL, "/org/freedesktop/login1", "org.freedesktop.login1.Manager", manager_vtable, m);
r = sd_bus_add_fallback_vtable(m->bus, NULL, "/org/freedesktop/login1/seat", "org.freedesktop.login1.Seat", seat_vtable, seat_object_find, m);
r = sd_bus_add_node_enumerator(m->bus, NULL, "/org/freedesktop/login1/seat", seat_node_enumerator, m);
r = sd_bus_add_fallback_vtable(m->bus, NULL, "/org/freedesktop/login1/session", "org.freedesktop.login1.Session", session_vtable, session_object_find, m);
r = sd_bus_add_node_enumerator(m->bus, NULL, "/org/freedesktop/login1/session", session_node_enumerator, m);
r = sd_bus_add_fallback_vtable(m->bus, NULL, "/org/freedesktop/login1/user", "org.freedesktop.login1.User", user_vtable, user_object_find, m);
r = sd_bus_add_node_enumerator(m->bus, NULL, "/org/freedesktop/login1/user", user_node_enumerator, m);
NULL,
"path='/org/freedesktop/DBus'",
NULL,
"sender='org.freedesktop.systemd1',"
"interface='org.freedesktop.systemd1.Manager',"
"path='/org/freedesktop/systemd1'",
match_job_removed, m);
NULL,
"sender='org.freedesktop.systemd1',"
"interface='org.freedesktop.systemd1.Manager',"
"path='/org/freedesktop/systemd1'",
match_unit_removed, m);
NULL,
"sender='org.freedesktop.systemd1',"
NULL,
"sender='org.freedesktop.systemd1',"
"interface='org.freedesktop.systemd1.Manager',"
"path='/org/freedesktop/systemd1'",
match_reloading, m);
r = sd_bus_call_method(
m->bus,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
&error,
assert(m);
if (m->console_active_fd < 0) {
return -errno;
r = sd_event_add_io(m->event, &m->console_active_event_source, m->console_active_fd, 0, manager_dispatch_console, m);
return -EINVAL;
assert(m);
if (!m->udev_seat_monitor)
return -ENOMEM;
r = sd_event_add_io(m->event, &m->udev_seat_event_source, udev_monitor_get_fd(m->udev_seat_monitor), EPOLLIN, manager_dispatch_seat_udev, m);
if (!m->udev_device_monitor)
return -ENOMEM;
r = sd_event_add_io(m->event, &m->udev_device_event_source, udev_monitor_get_fd(m->udev_device_monitor), EPOLLIN, manager_dispatch_device_udev, m);
if (!m->udev_button_monitor)
return -ENOMEM;
r = sd_event_add_io(m->event, &m->udev_button_event_source, udev_monitor_get_fd(m->udev_button_monitor), EPOLLIN, manager_dispatch_button_udev, m);
if (!m->udev_vcsa_monitor)
return -ENOMEM;
r = sd_event_add_io(m->event, &m->udev_vcsa_event_source, udev_monitor_get_fd(m->udev_vcsa_monitor), EPOLLIN, manager_dispatch_vcsa_udev, m);
assert(m);
assert(m);
m->idle_action_usec <= 0)
(m->idle_action_not_before_usec <= 0 || n >= m->idle_action_not_before_usec + m->idle_action_usec)) {
m->idle_action_not_before_usec = n;
if (!m->idle_action_event_source) {
r = sd_event_add_time(
m->event,
Iterator i;
assert(m);
r = manager_connect_console(m);
r = manager_connect_udev(m);
r = manager_connect_bus(m);
r = manager_enumerate_devices(m);
r = manager_enumerate_seats(m);
r = manager_enumerate_users(m);
r = manager_enumerate_sessions(m);
r = manager_enumerate_inhibitors(m);
r = manager_enumerate_buttons(m);
manager_gc(m, false);
assert(m);
if (r == SD_EVENT_FINISHED)
manager_gc(m, true);
if (manager_dispatch_delayed(m) > 0)
usec_t x, y;
us = x >= y ? 0 : y - x;
assert(m);
log_open();
r = -EINVAL;
goto finish;
m = manager_new();
r = log_oom();
goto finish;
r = manager_startup(m);
goto finish;
sd_notify(false,
r = manager_run(m);
sd_notify(false,
manager_free(m);