summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShogo Matsumoto <shogo.matsumoto@fujitsu.com>2019-09-08 22:44:51 -0400
committerPanu Matilainen <pmatilai@redhat.com>2019-11-18 12:46:29 +0200
commitb1e85a9172b8f17fece8cb3882ae95a8937a9f13 (patch)
treefe0ba1a6c53cf700356c4fff0f03e36b44a4687b
parentcb0493a67b35c9dc520afc3f3c5a19d3a1824e07 (diff)
downloadrpm-b1e85a9172b8f17fece8cb3882ae95a8937a9f13.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)
-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 0628188ba..9cb722761 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);