mirror of
https://github.com/systemd/systemd.git
synced 2025-03-08 08:58:27 +03:00
Merge pull request #27579 from YHNdnzj/refuse-dbus-activation
core: refuse dbus activation if dbus is not running
This commit is contained in:
commit
8d3beb00c0
@ -21,6 +21,7 @@
|
||||
#include "path-util.h"
|
||||
#include "process-util.h"
|
||||
#include "selinux-access.h"
|
||||
#include "service.h"
|
||||
#include "signal-util.h"
|
||||
#include "special.h"
|
||||
#include "string-table.h"
|
||||
@ -1876,6 +1877,12 @@ int bus_unit_queue_job(
|
||||
(type == JOB_RELOAD_OR_START && job_type_collapse(type, u) == JOB_START && u->refuse_manual_start))
|
||||
return sd_bus_error_setf(error, BUS_ERROR_ONLY_BY_DEPENDENCY, "Operation refused, unit %s may be requested by dependency only (it is configured to refuse manual start/stop).", u->id);
|
||||
|
||||
/* dbus-broker issues StartUnit for activation requests, so let's apply the same check
|
||||
* used in signal_activation_request(). */
|
||||
if (type == JOB_START && u->type == UNIT_SERVICE &&
|
||||
SERVICE(u)->type == SERVICE_DBUS && !manager_dbus_is_running(u->manager))
|
||||
return sd_bus_error_set(error, BUS_ERROR_SHUTTING_DOWN, "Refusing activation, D-Bus is not running.");
|
||||
|
||||
r = sd_bus_message_new_method_return(message, &reply);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
@ -160,9 +160,8 @@ static int signal_activation_request(sd_bus_message *message, void *userdata, sd
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (manager_unit_inactive_or_pending(m, SPECIAL_DBUS_SERVICE) ||
|
||||
manager_unit_inactive_or_pending(m, SPECIAL_DBUS_SOCKET)) {
|
||||
r = sd_bus_error_set(&error, BUS_ERROR_SHUTTING_DOWN, "Refusing activation, D-Bus is shutting down.");
|
||||
if (!manager_dbus_is_running(m)) {
|
||||
r = sd_bus_error_set(&error, BUS_ERROR_SHUTTING_DOWN, "Refusing activation, D-Bus is not running.");
|
||||
goto failed;
|
||||
}
|
||||
|
||||
|
@ -1801,7 +1801,7 @@ static void manager_distribute_fds(Manager *m, FDSet *fds) {
|
||||
}
|
||||
}
|
||||
|
||||
static bool manager_dbus_is_running(Manager *m, bool deserialized) {
|
||||
bool manager_dbus_is_running_full(Manager *m, bool deserialized) {
|
||||
Unit *u;
|
||||
|
||||
assert(m);
|
||||
@ -1843,7 +1843,7 @@ static void manager_setup_bus(Manager *m) {
|
||||
(void) bus_init_system(m);
|
||||
|
||||
/* Let's connect to the bus now, but only if the unit is supposed to be up */
|
||||
if (manager_dbus_is_running(m, MANAGER_IS_RELOADING(m))) {
|
||||
if (manager_dbus_is_running_full(m, MANAGER_IS_RELOADING(m))) {
|
||||
(void) bus_init_api(m);
|
||||
|
||||
if (MANAGER_IS_SYSTEM(m))
|
||||
@ -2935,7 +2935,7 @@ static int manager_dispatch_signal_fd(sd_event_source *source, int fd, uint32_t
|
||||
break;
|
||||
|
||||
case SIGUSR1:
|
||||
if (manager_dbus_is_running(m, false)) {
|
||||
if (manager_dbus_is_running(m)) {
|
||||
log_info("Trying to reconnect to bus...");
|
||||
|
||||
(void) bus_init_api(m);
|
||||
@ -4140,7 +4140,7 @@ void manager_recheck_dbus(Manager *m) {
|
||||
if (MANAGER_IS_RELOADING(m))
|
||||
return; /* don't check while we are reloading… */
|
||||
|
||||
if (manager_dbus_is_running(m, false)) {
|
||||
if (manager_dbus_is_running(m)) {
|
||||
(void) bus_init_api(m);
|
||||
|
||||
if (MANAGER_IS_SYSTEM(m))
|
||||
|
@ -504,6 +504,11 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(Manager*, manager_free);
|
||||
|
||||
int manager_startup(Manager *m, FILE *serialization, FDSet *fds, const char *root);
|
||||
|
||||
bool manager_dbus_is_running_full(Manager *m, bool deserialized);
|
||||
static inline bool manager_dbus_is_running(Manager *m) {
|
||||
return manager_dbus_is_running_full(m, false);
|
||||
}
|
||||
|
||||
Job *manager_get_job(Manager *m, uint32_t id);
|
||||
Unit *manager_get_unit(Manager *m, const char *name);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user