]> err.no Git - systemd/commitdiff
dbus: don't accept activation requests anymore if we are going down anyway
authorLennart Poettering <lennart@poettering.net>
Wed, 1 Sep 2010 01:30:59 +0000 (03:30 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 1 Sep 2010 01:30:59 +0000 (03:30 +0200)
fixme
src/bus-errors.h
src/dbus.c
src/manager.c
src/manager.h
src/special.h

diff --git a/fixme b/fixme
index 58fb81e772f589bbd2f743acbc809e82988fd3bc..c986d74a9a416c87dc73bd7640aaad8bd6a93ea5 100644 (file)
--- a/fixme
+++ b/fixme
@@ -80,6 +80,12 @@ v9:
 
 * fix terminal setup
 
+* figure out ssh disconnect hang
+
+* home.mount failing should not be able to cancel umount.target (IgnoreDependencyFailure=yes borked?)
+
+* disallow further dbus+socket activation on shutdown
+
 External:
 
 * place /etc/inittab with explaining blurb.
index a63350cc2332466dccb1d6aae1877120f7486346..2db1b77f2212c65ad7ff784dd582f6836d661f20 100644 (file)
@@ -41,6 +41,7 @@
 #define BUS_ERROR_TRANSACTION_IS_DESTRUCTIVE "org.freedesktop.systemd1.TransactionIsDestructive"
 #define BUS_ERROR_TRANSACTION_JOBS_CONFLICTING "org.freedesktop.systemd1.TransactionJobsConflicting"
 #define BUS_ERROR_TRANSACTION_ORDER_IS_CYCLIC "org.freedesktop.systemd1.TransactionOrderIsCyclic"
+#define BUS_ERROR_SHUTTING_DOWN "org.freedesktop.systemd1.ShuttingDown"
 
 static inline const char *bus_error(const DBusError *e, int r) {
         if (e && e->message)
index 952806bb2ac9feab08a5161d4687534abf784c09..8c969eab630c6879968a38b3e5a36c19d6cab475 100644 (file)
@@ -43,6 +43,7 @@
 #include "dbus-timer.h"
 #include "dbus-path.h"
 #include "bus-errors.h"
+#include "special.h"
 
 #define CONNECTIONS_MAX 52
 
@@ -383,13 +384,19 @@ static DBusHandlerResult api_bus_message_filter(DBusConnection *connection, DBus
 
                         log_debug("Got D-Bus activation request for %s", name);
 
-                        r = manager_load_unit(m, name, NULL, &error, &u);
+                        if (manager_unit_pending_inactive(m, SPECIAL_DBUS_SERVICE) ||
+                            manager_unit_pending_inactive(m, SPECIAL_DBUS_SOCKET)) {
+                                r = -EADDRNOTAVAIL;
+                                dbus_set_error(&error, BUS_ERROR_SHUTTING_DOWN, "Refusing activation, D-Bus is shutting down.");
+                        } else {
+                                r = manager_load_unit(m, name, NULL, &error, &u);
 
-                        if (r >= 0 && u->meta.refuse_manual_start)
-                                r = -EPERM;
+                                if (r >= 0 && u->meta.refuse_manual_start)
+                                        r = -EPERM;
 
-                        if (r >= 0)
-                                r = manager_add_job(m, JOB_START, u, JOB_REPLACE, true, &error, NULL);
+                                if (r >= 0)
+                                        r = manager_add_job(m, JOB_START, u, JOB_REPLACE, true, &error, NULL);
+                        }
 
                         if (r < 0) {
                                 const char *id, *text;
index 517473b802de5a0aa8408c83213e539f54743c39..ff1c70b4845762446c80382b1051a528aa0e7962 100644 (file)
@@ -2584,6 +2584,26 @@ int manager_set_console(Manager *m, const char *console) {
         return 0;
 }
 
+bool manager_unit_pending_inactive(Manager *m, const char *name) {
+        Unit *u;
+
+        assert(m);
+        assert(name);
+
+        /* Returns true if the unit is inactive or going down */
+
+        if (!(u = manager_get_unit(m, name)))
+                return true;
+
+        if (UNIT_IS_INACTIVE_OR_DEACTIVATING(unit_active_state(u)))
+                return true;
+
+        if (u->meta.job && u->meta.job->type == JOB_STOP)
+                return true;
+
+        return false;
+}
+
 static const char* const manager_running_as_table[_MANAGER_RUNNING_AS_MAX] = {
         [MANAGER_SYSTEM] = "system",
         [MANAGER_SESSION] = "session"
index 77c20764972312ef951a9efa0bca473b0cc5eccc..445537239cb33b9cb2082084285686b7e853dbf5 100644 (file)
@@ -259,6 +259,8 @@ void manager_reset_failed(Manager *m);
 
 void manager_send_unit_audit(Manager *m, Unit *u, int type, bool success);
 
+bool manager_unit_pending_inactive(Manager *m, const char *name);
+
 const char *manager_running_as_to_string(ManagerRunningAs i);
 ManagerRunningAs manager_running_as_from_string(const char *s);
 
index 0cc5cc647ba93ba57b0e07677d81a6ab40adb383..d0359db1f51d20710c6b1178e74066f8c1ef5b52 100644 (file)
@@ -59,6 +59,7 @@
 #define SPECIAL_POWEROFF_TARGET "poweroff.target"
 #define SPECIAL_REBOOT_TARGET "reboot.target"
 #define SPECIAL_DBUS_SERVICE "dbus.service"
+#define SPECIAL_DBUS_SOCKET "dbus.socket"
 #define SPECIAL_GETTY_TARGET "getty.target"
 #define SPECIAL_SERIAL_GETTY_SERVICE "serial-getty@.service"