From 508184ab17922de7d5f02d2552b3c5f17eef60cc Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Mon, 4 Mar 2019 18:48:51 +0100 Subject: add dbus checks --- logind.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'logind.c') diff --git a/logind.c b/logind.c index 6388df1..a2e9add 100644 --- a/logind.c +++ b/logind.c @@ -48,6 +48,8 @@ int logind_init(void) int logind_dbus_fd(void) { + if (!logind_dbus) + return -1; return sd_bus_get_fd(logind_dbus); } @@ -56,6 +58,9 @@ void logind_dbus_input(void) sd_bus_message *m = NULL; int ret; + if (!logind_dbus) + return; + do { ret = sd_bus_process(logind_dbus, &m); fprintf(stderr, "%s: path %s\n", __func__, @@ -70,6 +75,9 @@ int logind_take_control(void) sd_bus_message *m = NULL; int r; + if (!logind_dbus) + return -1; + r = sd_bus_call_method(logind_dbus, "org.freedesktop.login1", "/org/freedesktop/login1/session/self", @@ -94,6 +102,9 @@ int logind_release_control(void) sd_bus_message *m = NULL; int r; + if (!logind_dbus) + return -1; + r = sd_bus_call_method(logind_dbus, "org.freedesktop.login1", "/org/freedesktop/login1/session/self", -- cgit