Tell systemd when dbus is ready/shutting down/reloading config
(cherry picked from commit ac18e08d6959d479e839f40f26232a359e5a36fc)
This commit is contained in:
parent
a0779184b5
commit
10e71fd5ca
75
backport-bus-Also-tell-systemd-before-we-shut-down.patch
Normal file
75
backport-bus-Also-tell-systemd-before-we-shut-down.patch
Normal file
@ -0,0 +1,75 @@
|
||||
From 03c0db9ff51dedeb98f42c715a70a1bd10c7f595 Mon Sep 17 00:00:00 2001
|
||||
From: Simon McVittie <smcv@collabora.com>
|
||||
Date: Mon, 15 Jan 2018 15:31:55 +0000
|
||||
Subject: [PATCH] bus: Also tell systemd before we shut down
|
||||
|
||||
Signed-off-by: Simon McVittie <smcv@collabora.com>
|
||||
Reviewed-by: Philip Withnall <withnall@endlessm.com>
|
||||
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=104641
|
||||
---
|
||||
bus/main.c | 1 +
|
||||
dbus/dbus-sysdeps-util-unix.c | 12 ++++++++++++
|
||||
dbus/dbus-sysdeps-util-win.c | 5 +++++
|
||||
dbus/dbus-sysdeps.h | 1 +
|
||||
4 files changed, 19 insertions(+)
|
||||
|
||||
diff --git a/bus/main.c b/bus/main.c
|
||||
index 578aa989..28223899 100644
|
||||
--- a/bus/main.c
|
||||
+++ b/bus/main.c
|
||||
@@ -320,6 +320,7 @@ handle_reload_watch (DBusWatch *watch,
|
||||
loop = bus_context_get_loop (context);
|
||||
if (loop != NULL)
|
||||
{
|
||||
+ _dbus_daemon_report_stopping ();
|
||||
_dbus_loop_quit (loop);
|
||||
}
|
||||
}
|
||||
diff --git a/dbus/dbus-sysdeps-util-unix.c b/dbus/dbus-sysdeps-util-unix.c
|
||||
index 8a7c9278..24eba4e3 100644
|
||||
--- a/dbus/dbus-sysdeps-util-unix.c
|
||||
+++ b/dbus/dbus-sysdeps-util-unix.c
|
||||
@@ -1556,3 +1556,15 @@ _dbus_daemon_report_reloaded (void)
|
||||
_dbus_daemon_report_ready ();
|
||||
#endif
|
||||
}
|
||||
+
|
||||
+/**
|
||||
+ * Report to a service manager that the daemon calling this function is
|
||||
+ * shutting down. This is currently only implemented for systemd.
|
||||
+ */
|
||||
+void
|
||||
+_dbus_daemon_report_stopping (void)
|
||||
+{
|
||||
+#ifdef HAVE_SYSTEMD
|
||||
+ sd_notify (0, "STOPPING=1");
|
||||
+#endif
|
||||
+}
|
||||
diff --git a/dbus/dbus-sysdeps-util-win.c b/dbus/dbus-sysdeps-util-win.c
|
||||
index 917dd05e..a5c3bba6 100644
|
||||
--- a/dbus/dbus-sysdeps-util-win.c
|
||||
+++ b/dbus/dbus-sysdeps-util-win.c
|
||||
@@ -1669,3 +1669,8 @@ void
|
||||
_dbus_daemon_report_reloaded (void)
|
||||
{
|
||||
}
|
||||
+
|
||||
+void
|
||||
+_dbus_daemon_report_stopping (void)
|
||||
+{
|
||||
+}
|
||||
diff --git a/dbus/dbus-sysdeps.h b/dbus/dbus-sysdeps.h
|
||||
index d8e69589..0d1ff7c4 100644
|
||||
--- a/dbus/dbus-sysdeps.h
|
||||
+++ b/dbus/dbus-sysdeps.h
|
||||
@@ -690,6 +690,7 @@ void _dbus_rlimit_free (DBusRLimit *lim);
|
||||
void _dbus_daemon_report_ready (void);
|
||||
void _dbus_daemon_report_reloading (void);
|
||||
void _dbus_daemon_report_reloaded (void);
|
||||
+void _dbus_daemon_report_stopping (void);
|
||||
|
||||
/** @} */
|
||||
|
||||
--
|
||||
2.27.0
|
||||
|
||||
104
backport-bus-Also-tell-systemd-when-we-re-reloading.patch
Normal file
104
backport-bus-Also-tell-systemd-when-we-re-reloading.patch
Normal file
@ -0,0 +1,104 @@
|
||||
From c937a39e4ba1e297518edbd78feeb6f1cc764bd1 Mon Sep 17 00:00:00 2001
|
||||
From: Simon McVittie <smcv@collabora.com>
|
||||
Date: Mon, 15 Jan 2018 15:31:41 +0000
|
||||
Subject: [PATCH] bus: Also tell systemd when we're reloading
|
||||
|
||||
Signed-off-by: Simon McVittie <smcv@collabora.com>
|
||||
Reviewed-by: Philip Withnall <withnall@endlessm.com>
|
||||
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=104641
|
||||
---
|
||||
bus/bus.c | 4 ++++
|
||||
dbus/dbus-sysdeps-util-unix.c | 25 +++++++++++++++++++++++++
|
||||
dbus/dbus-sysdeps-util-win.c | 10 ++++++++++
|
||||
dbus/dbus-sysdeps.h | 2 ++
|
||||
4 files changed, 41 insertions(+)
|
||||
|
||||
diff --git a/bus/bus.c b/bus/bus.c
|
||||
index abb2ea2f..9fd9820b 100644
|
||||
--- a/bus/bus.c
|
||||
+++ b/bus/bus.c
|
||||
@@ -1065,6 +1065,8 @@ bus_context_reload_config (BusContext *context,
|
||||
DBusString config_file;
|
||||
dbus_bool_t ret;
|
||||
|
||||
+ _dbus_daemon_report_reloading ();
|
||||
+
|
||||
/* Flush the user database cache */
|
||||
_dbus_flush_caches ();
|
||||
|
||||
@@ -1095,6 +1097,8 @@ bus_context_reload_config (BusContext *context,
|
||||
bus_context_log (context, DBUS_SYSTEM_LOG_INFO, "Unable to reload configuration: %s", error->message);
|
||||
if (parser != NULL)
|
||||
bus_config_parser_unref (parser);
|
||||
+
|
||||
+ _dbus_daemon_report_reloaded ();
|
||||
return ret;
|
||||
}
|
||||
|
||||
diff --git a/dbus/dbus-sysdeps-util-unix.c b/dbus/dbus-sysdeps-util-unix.c
|
||||
index 838cd932..8a7c9278 100644
|
||||
--- a/dbus/dbus-sysdeps-util-unix.c
|
||||
+++ b/dbus/dbus-sysdeps-util-unix.c
|
||||
@@ -1531,3 +1531,28 @@ _dbus_daemon_report_ready (void)
|
||||
sd_notify (0, "READY=1");
|
||||
#endif
|
||||
}
|
||||
+
|
||||
+/**
|
||||
+ * Report to a service manager that the daemon calling this function is
|
||||
+ * reloading configuration. This is currently only implemented for systemd.
|
||||
+ */
|
||||
+void
|
||||
+_dbus_daemon_report_reloading (void)
|
||||
+{
|
||||
+#ifdef HAVE_SYSTEMD
|
||||
+ sd_notify (0, "RELOADING=1");
|
||||
+#endif
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ * Report to a service manager that the daemon calling this function is
|
||||
+ * reloading configuration. This is currently only implemented for systemd.
|
||||
+ */
|
||||
+void
|
||||
+_dbus_daemon_report_reloaded (void)
|
||||
+{
|
||||
+#ifdef HAVE_SYSTEMD
|
||||
+ /* For systemd, this is the same code */
|
||||
+ _dbus_daemon_report_ready ();
|
||||
+#endif
|
||||
+}
|
||||
diff --git a/dbus/dbus-sysdeps-util-win.c b/dbus/dbus-sysdeps-util-win.c
|
||||
index f613130e..917dd05e 100644
|
||||
--- a/dbus/dbus-sysdeps-util-win.c
|
||||
+++ b/dbus/dbus-sysdeps-util-win.c
|
||||
@@ -1659,3 +1659,13 @@ void
|
||||
_dbus_daemon_report_ready (void)
|
||||
{
|
||||
}
|
||||
+
|
||||
+void
|
||||
+_dbus_daemon_report_reloading (void)
|
||||
+{
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+_dbus_daemon_report_reloaded (void)
|
||||
+{
|
||||
+}
|
||||
diff --git a/dbus/dbus-sysdeps.h b/dbus/dbus-sysdeps.h
|
||||
index b2943906..d8e69589 100644
|
||||
--- a/dbus/dbus-sysdeps.h
|
||||
+++ b/dbus/dbus-sysdeps.h
|
||||
@@ -688,6 +688,8 @@ dbus_bool_t _dbus_test_append_different_username (DBusString *username);
|
||||
#endif /* DBUS_ENABLE_EMBEDDED_TESTS */
|
||||
|
||||
void _dbus_daemon_report_ready (void);
|
||||
+void _dbus_daemon_report_reloading (void);
|
||||
+void _dbus_daemon_report_reloaded (void);
|
||||
|
||||
/** @} */
|
||||
|
||||
--
|
||||
2.27.0
|
||||
|
||||
@ -0,0 +1,45 @@
|
||||
From 66246fff2a0bd005817fb9d108544da86973a81e Mon Sep 17 00:00:00 2001
|
||||
From: Simon McVittie <smcv@collabora.com>
|
||||
Date: Tue, 20 Mar 2018 12:33:51 +0000
|
||||
Subject: [PATCH] bus: Clear INVOCATION_ID when carrying out traditional
|
||||
activation
|
||||
|
||||
We weren't sure whether this one should be inherited or not, so I
|
||||
asked on systemd-devel, and Lennart thought it shouldn't.
|
||||
|
||||
Signed-off-by: Simon McVittie <smcv@collabora.com>
|
||||
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=104641
|
||||
Reviewed-by: Philip Withnall <withnall@endlessm.com>
|
||||
---
|
||||
bus/activation.c | 8 +++++++-
|
||||
1 file changed, 7 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/bus/activation.c b/bus/activation.c
|
||||
index 66640ba6..2a427d9c 100644
|
||||
--- a/bus/activation.c
|
||||
+++ b/bus/activation.c
|
||||
@@ -862,7 +862,6 @@ populate_environment (BusActivation *activation)
|
||||
* - TERM, WATCHDOG_*: Should not be set for dbus-daemon, so not applicable
|
||||
* - MAINPID, SERVICE_RESULT, EXIT_CODE, EXIT_STATUS: Not set for ExecStart,
|
||||
* so not applicable
|
||||
- * - INVOCATION_ID: TODO: Do we want to clear this or not? It isn't clear.
|
||||
*/
|
||||
|
||||
/* We give activated services their own Journal stream to avoid their
|
||||
@@ -878,6 +877,13 @@ populate_environment (BusActivation *activation)
|
||||
* (and NotifyAccess wouldn't let it write here anyway) */
|
||||
_dbus_hash_table_remove_string (activation->environment, "NOTIFY_SOCKET");
|
||||
|
||||
+ /* This identifies the dbus-daemon invocation. Whether it should be
|
||||
+ * inherited by "smaller" services isn't entirely clear-cut, but not
|
||||
+ * inheriting it makes traditional D-Bus activation under systemd a
|
||||
+ * little more consistent with systemd activation.
|
||||
+ * https://lists.freedesktop.org/archives/systemd-devel/2018-March/040467.html */
|
||||
+ _dbus_hash_table_remove_string (activation->environment, "INVOCATION_ID");
|
||||
+
|
||||
return retval;
|
||||
}
|
||||
|
||||
--
|
||||
2.27.0
|
||||
|
||||
@ -0,0 +1,57 @@
|
||||
From be4670767377a08b0c6cabbca1000ca614174c2c Mon Sep 17 00:00:00 2001
|
||||
From: Simon McVittie <smcv@collabora.com>
|
||||
Date: Mon, 15 Jan 2018 15:26:33 +0000
|
||||
Subject: [PATCH] bus: Don't pass systemd environment variables to activated
|
||||
services
|
||||
|
||||
Signed-off-by: Simon McVittie <smcv@collabora.com>
|
||||
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=104641
|
||||
Reviewed-by: Philip Withnall <withnall@endlessm.com>
|
||||
---
|
||||
bus/activation.c | 30 ++++++++++++++++++++++++++++++
|
||||
1 file changed, 30 insertions(+)
|
||||
|
||||
diff --git a/bus/activation.c b/bus/activation.c
|
||||
index edf96a2c..66640ba6 100644
|
||||
--- a/bus/activation.c
|
||||
+++ b/bus/activation.c
|
||||
@@ -848,6 +848,36 @@ populate_environment (BusActivation *activation)
|
||||
retval = _dbus_hash_table_from_array (activation->environment, environment, '=');
|
||||
dbus_free_string_array (environment);
|
||||
|
||||
+ /*
|
||||
+ * These environment variables are set by systemd for the dbus-daemon
|
||||
+ * itself, and are not applicable to our child processes.
|
||||
+ *
|
||||
+ * Of the other environment variables listed in systemd.exec(5):
|
||||
+ *
|
||||
+ * - XDG_RUNTIME_DIR, XDG_SESSION_ID, XDG_SEAT, XDG_VTNR: Properties of
|
||||
+ * the session and equally true for the activated service, should not
|
||||
+ * be reset
|
||||
+ * - PATH, LANG, USER, LOGNAME, HOME, SHELL, MANAGERPID: Equally true for
|
||||
+ * the activated service, should not be reset
|
||||
+ * - TERM, WATCHDOG_*: Should not be set for dbus-daemon, so not applicable
|
||||
+ * - MAINPID, SERVICE_RESULT, EXIT_CODE, EXIT_STATUS: Not set for ExecStart,
|
||||
+ * so not applicable
|
||||
+ * - INVOCATION_ID: TODO: Do we want to clear this or not? It isn't clear.
|
||||
+ */
|
||||
+
|
||||
+ /* We give activated services their own Journal stream to avoid their
|
||||
+ * logging being attributed to dbus-daemon */
|
||||
+ _dbus_hash_table_remove_string (activation->environment, "JOURNAL_STREAM");
|
||||
+
|
||||
+ /* This is dbus-daemon's listening socket, not the activatable service's */
|
||||
+ _dbus_hash_table_remove_string (activation->environment, "LISTEN_FDNAMES");
|
||||
+ _dbus_hash_table_remove_string (activation->environment, "LISTEN_FDS");
|
||||
+ _dbus_hash_table_remove_string (activation->environment, "LISTEN_PID");
|
||||
+
|
||||
+ /* This is dbus-daemon's status notification, not the activatable service's
|
||||
+ * (and NotifyAccess wouldn't let it write here anyway) */
|
||||
+ _dbus_hash_table_remove_string (activation->environment, "NOTIFY_SOCKET");
|
||||
+
|
||||
return retval;
|
||||
}
|
||||
|
||||
--
|
||||
2.27.0
|
||||
|
||||
103
backport-bus-Notify-systemd-when-we-are-ready.patch
Normal file
103
backport-bus-Notify-systemd-when-we-are-ready.patch
Normal file
@ -0,0 +1,103 @@
|
||||
From 18a0a8892b99f235e3897d9e5c600da00c61ef0a Mon Sep 17 00:00:00 2001
|
||||
From: Simon McVittie <smcv@collabora.com>
|
||||
Date: Mon, 15 Jan 2018 15:15:52 +0000
|
||||
Subject: [PATCH] bus: Notify systemd when we are ready
|
||||
|
||||
Signed-off-by: Simon McVittie <smcv@collabora.com>
|
||||
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=104641
|
||||
Reviewed-by: Philip Withnall <withnall@endlessm.com>
|
||||
---
|
||||
bus/dbus.service.in | 2 ++
|
||||
bus/main.c | 1 +
|
||||
bus/systemd-user/dbus.service.in | 2 ++
|
||||
dbus/dbus-sysdeps-util-unix.c | 12 ++++++++++++
|
||||
dbus/dbus-sysdeps-util-win.c | 5 +++++
|
||||
dbus/dbus-sysdeps.h | 2 ++
|
||||
6 files changed, 24 insertions(+)
|
||||
|
||||
diff --git a/bus/dbus.service.in b/bus/dbus.service.in
|
||||
index ca0b7e96..3713810b 100644
|
||||
--- a/bus/dbus.service.in
|
||||
+++ b/bus/dbus.service.in
|
||||
@@ -4,6 +4,8 @@ Documentation=man:dbus-daemon(1)
|
||||
Requires=dbus.socket
|
||||
|
||||
[Service]
|
||||
+Type=notify
|
||||
+NotifyAccess=main
|
||||
ExecStart=@EXPANDED_BINDIR@/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
|
||||
ExecReload=@EXPANDED_BINDIR@/dbus-send --print-reply --system --type=method_call --dest=org.freedesktop.DBus / org.freedesktop.DBus.ReloadConfig
|
||||
OOMScoreAdjust=-900
|
||||
diff --git a/bus/main.c b/bus/main.c
|
||||
index b3fcddd0..578aa989 100644
|
||||
--- a/bus/main.c
|
||||
+++ b/bus/main.c
|
||||
@@ -716,6 +716,7 @@ main (int argc, char **argv)
|
||||
#endif /* DBUS_UNIX */
|
||||
|
||||
_dbus_verbose ("We are on D-Bus...\n");
|
||||
+ _dbus_daemon_report_ready ();
|
||||
_dbus_loop_run (bus_context_get_loop (context));
|
||||
|
||||
bus_context_shutdown (context);
|
||||
diff --git a/bus/systemd-user/dbus.service.in b/bus/systemd-user/dbus.service.in
|
||||
index 7ceffbee..b291b923 100644
|
||||
--- a/bus/systemd-user/dbus.service.in
|
||||
+++ b/bus/systemd-user/dbus.service.in
|
||||
@@ -4,5 +4,7 @@ Documentation=man:dbus-daemon(1)
|
||||
Requires=dbus.socket
|
||||
|
||||
[Service]
|
||||
+Type=notify
|
||||
+NotifyAccess=main
|
||||
ExecStart=@EXPANDED_BINDIR@/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
|
||||
ExecReload=@EXPANDED_BINDIR@/dbus-send --print-reply --session --type=method_call --dest=org.freedesktop.DBus / org.freedesktop.DBus.ReloadConfig
|
||||
diff --git a/dbus/dbus-sysdeps-util-unix.c b/dbus/dbus-sysdeps-util-unix.c
|
||||
index b841bf63..838cd932 100644
|
||||
--- a/dbus/dbus-sysdeps-util-unix.c
|
||||
+++ b/dbus/dbus-sysdeps-util-unix.c
|
||||
@@ -1564,3 +1564,15 @@ _dbus_test_append_different_username (DBusString *username)
|
||||
}
|
||||
|
||||
#endif
|
||||
+
|
||||
+/**
|
||||
+ * Report to a service manager that the daemon calling this function is
|
||||
+ * ready for use. This is currently only implemented for systemd.
|
||||
+ */
|
||||
+void
|
||||
+_dbus_daemon_report_ready (void)
|
||||
+{
|
||||
+#ifdef HAVE_SYSTEMD
|
||||
+ sd_notify (0, "READY=1");
|
||||
+#endif
|
||||
+}
|
||||
diff --git a/dbus/dbus-sysdeps-util-win.c b/dbus/dbus-sysdeps-util-win.c
|
||||
index 1ef4ae6c..f613130e 100644
|
||||
--- a/dbus/dbus-sysdeps-util-win.c
|
||||
+++ b/dbus/dbus-sysdeps-util-win.c
|
||||
@@ -1678,3 +1678,8 @@ _dbus_test_append_different_uid (DBusString *uid)
|
||||
}
|
||||
|
||||
#endif
|
||||
+
|
||||
+void
|
||||
+_dbus_daemon_report_ready (void)
|
||||
+{
|
||||
+}
|
||||
diff --git a/dbus/dbus-sysdeps.h b/dbus/dbus-sysdeps.h
|
||||
index b9b0c440..b2943906 100644
|
||||
--- a/dbus/dbus-sysdeps.h
|
||||
+++ b/dbus/dbus-sysdeps.h
|
||||
@@ -687,6 +687,8 @@ dbus_bool_t _dbus_test_append_different_username (DBusString *username);
|
||||
#endif
|
||||
#endif /* DBUS_ENABLE_EMBEDDED_TESTS */
|
||||
|
||||
+void _dbus_daemon_report_ready (void);
|
||||
+
|
||||
/** @} */
|
||||
|
||||
DBUS_END_DECLS
|
||||
--
|
||||
2.27.0
|
||||
|
||||
11
dbus.spec
11
dbus.spec
@ -1,7 +1,7 @@
|
||||
Name: dbus
|
||||
Epoch: 1
|
||||
Version: 1.12.20
|
||||
Release: 5
|
||||
Release: 6
|
||||
Summary: System Message Bus
|
||||
License: AFLv3.0 or GPLv2+
|
||||
URL: http://www.freedesktop.org/Software/dbus/
|
||||
@ -11,6 +11,12 @@ Source1: 00-start-message-bus.sh
|
||||
Patch0001: bugfix-let-systemd-restart-dbus-when-the-it-enters-failed.patch
|
||||
Patch0002: print-load-average-when-activate-service-timeout.patch
|
||||
|
||||
Patch6000: backport-bus-Notify-systemd-when-we-are-ready.patch
|
||||
Patch6001: backport-bus-Also-tell-systemd-when-we-re-reloading.patch
|
||||
Patch6002: backport-bus-Also-tell-systemd-before-we-shut-down.patch
|
||||
Patch6003: backport-bus-Don-t-pass-systemd-environment-variables-to-acti.patch
|
||||
Patch6004: backport-bus-Clear-INVOCATION_ID-when-carrying-out-traditiona.patch
|
||||
|
||||
BuildRequires: systemd-devel expat-devel libselinux-devel audit-libs-devel doxygen xmlto cmake
|
||||
BuildRequires: autoconf-archive libtool libX11-devel libcap-ng-devel libxslt
|
||||
|
||||
@ -222,6 +228,9 @@ fi
|
||||
%exclude %{_pkgdocdir}/README
|
||||
|
||||
%changelog
|
||||
* Sat Jan 29 2022 licunlong <licunlong1@huawei.com> - 1:1.12.20-6
|
||||
- Tell systemd when dbus is ready/shutting down/reloading config.
|
||||
|
||||
* Tue Nov 30 2021 xuxiaozhou <xuxiaozhou1@huawei.com> - 1:1.12.20-5
|
||||
- add print-load-average-when-activate-service-timeout.patch for more debug information
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user