summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShogo Matsumoto <shogo.matsumoto@fujitsu.com>2019-09-08 22:44:51 -0400
committerPanu Matilainen <pmatilai@redhat.com>2020-03-26 11:57:58 +0200
commitf5e8cd83042834fe09738a7986a071692f99628e (patch)
tree7ed21d06f4b9323226f230a73690ff12d7147eb5
parent0efe6d7cb59a2413d58e018bd7fe14cadbd29fb6 (diff)
downloadrpm-f5e8cd83042834fe09738a7986a071692f99628e.tar.gz
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)
-rw-r--r--plugins/systemd_inhibit.c4
1 files changed, 3 insertions, 1 deletions
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);