From f5e8cd83042834fe09738a7986a071692f99628e Mon Sep 17 00:00:00 2001 From: Shogo Matsumoto Date: Sun, 8 Sep 2019 22:44:51 -0400 Subject: Suppress inhibition lock warning message when DBus service is not available The message may just confuse users if DBus is not running as default, e.g. single-user mode. We suppress it when DBus is not available, which is done by checking two cases: socket does not exist (DBUS_ERROR_FILE_NOT_FOUND), or unable to connect to server (DBUS_ERROR_NO_SERVER). Note that this is an approximate but not an exact way to detect whether DBus service should be running in the environment or not. (cherry picked from commit 708e61307bc3fd027b016fdf5a1d1a5274c1843c) (cherry picked from commit b1e85a9172b8f17fece8cb3882ae95a8937a9f13) --- plugins/systemd_inhibit.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/systemd_inhibit.c b/plugins/systemd_inhibit.c index e2cbcffbb..0ddca9cd8 100644 --- a/plugins/systemd_inhibit.c +++ b/plugins/systemd_inhibit.c @@ -52,7 +52,9 @@ static int inhibit(void) dbus_message_unref(reply); } - if (dbus_error_is_set(&err)) { + if (dbus_error_is_set(&err) + && !dbus_error_has_name(&err, DBUS_ERROR_NO_SERVER) + && !dbus_error_has_name(&err, DBUS_ERROR_FILE_NOT_FOUND)) { rpmlog(RPMLOG_WARNING, "Unable to get systemd shutdown inhibition lock: %s\n", err.message); -- cgit v1.2.1