summaryrefslogtreecommitdiff
path: root/src/login/logind.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/login/logind.c')
-rw-r--r--src/login/logind.c138
1 files changed, 46 insertions, 92 deletions
diff --git a/src/login/logind.c b/src/login/logind.c
index d7fb1bf170..78220ff4dd 100644
--- a/src/login/logind.c
+++ b/src/login/logind.c
@@ -583,52 +583,36 @@ static int manager_connect_bus(Manager *m) {
assert(!m->bus);
r = sd_bus_default_system(&m->bus);
- if (r < 0) {
- log_error_errno(r, "Failed to connect to system bus: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to connect to system bus: %m");
r = sd_bus_add_object_vtable(m->bus, NULL, "/org/freedesktop/login1", "org.freedesktop.login1.Manager", manager_vtable, m);
- if (r < 0) {
- log_error_errno(r, "Failed to add manager object vtable: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to add manager object 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);
- if (r < 0) {
- log_error_errno(r, "Failed to add seat object vtable: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to add seat object vtable: %m");
r = sd_bus_add_node_enumerator(m->bus, NULL, "/org/freedesktop/login1/seat", seat_node_enumerator, m);
- if (r < 0) {
- log_error_errno(r, "Failed to add seat enumerator: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to add seat 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);
- if (r < 0) {
- log_error_errno(r, "Failed to add session object vtable: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to add session object vtable: %m");
r = sd_bus_add_node_enumerator(m->bus, NULL, "/org/freedesktop/login1/session", session_node_enumerator, m);
- if (r < 0) {
- log_error_errno(r, "Failed to add session enumerator: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to add session 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);
- if (r < 0) {
- log_error_errno(r, "Failed to add user object vtable: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to add user object vtable: %m");
r = sd_bus_add_node_enumerator(m->bus, NULL, "/org/freedesktop/login1/user", user_node_enumerator, m);
- if (r < 0) {
- log_error_errno(r, "Failed to add user enumerator: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to add user enumerator: %m");
r = sd_bus_add_match(m->bus,
NULL,
@@ -638,10 +622,8 @@ static int manager_connect_bus(Manager *m) {
"member='NameOwnerChanged',"
"path='/org/freedesktop/DBus'",
match_name_owner_changed, m);
- if (r < 0) {
- log_error_errno(r, "Failed to add match for NameOwnerChanged: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to add match for NameOwnerChanged: %m");
r = sd_bus_add_match(m->bus,
NULL,
@@ -651,10 +633,8 @@ static int manager_connect_bus(Manager *m) {
"member='JobRemoved',"
"path='/org/freedesktop/systemd1'",
match_job_removed, m);
- if (r < 0) {
- log_error_errno(r, "Failed to add match for JobRemoved: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to add match for JobRemoved: %m");
r = sd_bus_add_match(m->bus,
NULL,
@@ -664,10 +644,8 @@ static int manager_connect_bus(Manager *m) {
"member='UnitRemoved',"
"path='/org/freedesktop/systemd1'",
match_unit_removed, m);
- if (r < 0) {
- log_error_errno(r, "Failed to add match for UnitRemoved: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to add match for UnitRemoved: %m");
r = sd_bus_add_match(m->bus,
NULL,
@@ -676,10 +654,8 @@ static int manager_connect_bus(Manager *m) {
"interface='org.freedesktop.DBus.Properties',"
"member='PropertiesChanged'",
match_properties_changed, m);
- if (r < 0) {
- log_error_errno(r, "Failed to add match for PropertiesChanged: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to add match for PropertiesChanged: %m");
r = sd_bus_add_match(m->bus,
NULL,
@@ -689,10 +665,8 @@ static int manager_connect_bus(Manager *m) {
"member='Reloading',"
"path='/org/freedesktop/systemd1'",
match_reloading, m);
- if (r < 0) {
- log_error_errno(r, "Failed to add match for Reloading: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to add match for Reloading: %m");
r = sd_bus_call_method(
m->bus,
@@ -708,16 +682,12 @@ static int manager_connect_bus(Manager *m) {
}
r = sd_bus_request_name(m->bus, "org.freedesktop.login1", 0);
- if (r < 0) {
- log_error_errno(r, "Failed to register name: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to register name: %m");
r = sd_bus_attach_event(m->bus, m->event, 0);
- if (r < 0) {
- log_error_errno(r, "Failed to attach bus to event loop: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to attach bus to event loop: %m");
return 0;
}
@@ -806,16 +776,12 @@ static int manager_connect_console(Manager *m) {
}
r = ignore_signals(SIGRTMIN + 1, -1);
- if (r < 0) {
- log_error_errno(r, "Cannot ignore SIGRTMIN + 1: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Cannot ignore SIGRTMIN + 1: %m");
r = sigprocmask_many(SIG_BLOCK, SIGRTMIN, -1);
- if (r < 0) {
- log_error_errno(r, "Cannot block SIGRTMIN: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Cannot block SIGRTMIN: %m");
r = sd_event_add_signal(m->event, NULL, SIGRTMIN, manager_vt_switch, m);
if (r < 0)
@@ -1016,28 +982,20 @@ static int manager_dispatch_idle_action(sd_event_source *s, uint64_t t, void *us
CLOCK_MONOTONIC,
elapse, USEC_PER_SEC*30,
manager_dispatch_idle_action, m);
- if (r < 0) {
- log_error_errno(r, "Failed to add idle event source: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to add idle event source: %m");
r = sd_event_source_set_priority(m->idle_action_event_source, SD_EVENT_PRIORITY_IDLE+10);
- if (r < 0) {
- log_error_errno(r, "Failed to set idle event source priority: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to set idle event source priority: %m");
} else {
r = sd_event_source_set_time(m->idle_action_event_source, elapse);
- if (r < 0) {
- log_error_errno(r, "Failed to set idle event timer: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to set idle event timer: %m");
r = sd_event_source_set_enabled(m->idle_action_event_source, SD_EVENT_ONESHOT);
- if (r < 0) {
- log_error_errno(r, "Failed to enable idle event timer: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to enable idle event timer: %m");
}
return 0;
@@ -1061,10 +1019,8 @@ int manager_startup(Manager *m) {
/* Connect to udev */
r = manager_connect_udev(m);
- if (r < 0) {
- log_error_errno(r, "Failed to create udev watchers: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to create udev watchers: %m");
/* Connect to the bus */
r = manager_connect_bus(m);
@@ -1073,10 +1029,8 @@ int manager_startup(Manager *m) {
/* Instantiate magic seat 0 */
r = manager_add_seat(m, "seat0", &m->seat0);
- if (r < 0) {
- log_error_errno(r, "Failed to add seat0: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to add seat0: %m");
r = manager_set_lid_switch_ignore(m, 0 + IGNORE_LID_SWITCH_STARTUP_USEC);
if (r < 0)