chiark / gitweb /
socket: disable GC for pre-allocated per-connection service until it is used
[elogind.git] / src / systemctl.c
index 1e3385f8604074ff59ea09939cc2be1d722da66e..e49c5b8671c3af9c4e5a5e51bdc2e3e5536bd8e2 100644 (file)
@@ -311,6 +311,7 @@ static int dot_one_property(const char *name, const char *prop, DBusMessageIter
                 "RequisiteOverridable",  "[color=\"darkblue\"]",
                 "Wants",                 "[color=\"darkgrey\"]",
                 "Conflicts",             "[color=\"red\"]",
+                "ConflictedBy",          "[color=\"red\"]",
                 "After",                 "[color=\"green\"]"
         };
 
@@ -489,7 +490,7 @@ static int dot(DBusConnection *bus, char **args, unsigned n) {
 
         dbus_message_iter_recurse(&iter, &sub);
         while (dbus_message_iter_get_arg_type(&sub) != DBUS_TYPE_INVALID) {
-                const char *id, *description, *load_state, *active_state, *sub_state, *unit_path;
+                const char *id, *description, *load_state, *active_state, *sub_state, *following, *unit_path;
 
                 if (dbus_message_iter_get_arg_type(&sub) != DBUS_TYPE_STRUCT) {
                         log_error("Failed to parse reply.");
@@ -504,6 +505,7 @@ static int dot(DBusConnection *bus, char **args, unsigned n) {
                     bus_iter_get_basic_and_next(&sub2, DBUS_TYPE_STRING, &load_state, true) < 0 ||
                     bus_iter_get_basic_and_next(&sub2, DBUS_TYPE_STRING, &active_state, true) < 0 ||
                     bus_iter_get_basic_and_next(&sub2, DBUS_TYPE_STRING, &sub_state, true) < 0 ||
+                    bus_iter_get_basic_and_next(&sub2, DBUS_TYPE_STRING, &following, true) < 0 ||
                     bus_iter_get_basic_and_next(&sub2, DBUS_TYPE_OBJECT_PATH, &unit_path, true) < 0) {
                         log_error("Failed to parse reply.");
                         r = -EIO;
@@ -1528,14 +1530,15 @@ static void print_status_info(UnitStatusInfo *i) {
                                         printf(" (%s)", t);
                                         free(t);
                                 }
-                        } else {
+                        } else if (i->exit_code > 0) {
                                 printf(" (code=%s, ", sigchld_code_to_string(i->exit_code));
 
                                 if (i->exit_code == CLD_EXITED)
                                         printf("status=%i", i->exit_status);
                                 else
                                         printf("signal=%s", signal_to_string(i->exit_status));
-                                printf(")");                        }
+                                printf(")");
+                        }
                 }
 
                 if (i->main_pid > 0 && i->control_pid > 0)
@@ -3933,7 +3936,8 @@ static int halt_parse_argv(int argc, char *argv[]) {
                         break;
 
                 case 'p':
-                        arg_action = ACTION_POWEROFF;
+                        if (arg_action != ACTION_REBOOT)
+                                arg_action = ACTION_POWEROFF;
                         break;
 
                 case ARG_REBOOT:
@@ -4209,8 +4213,22 @@ static int parse_argv(int argc, char *argv[]) {
                         arg_action = ACTION_POWEROFF;
                         return shutdown_parse_argv(argc, argv);
                 } else if (strstr(program_invocation_short_name, "init")) {
-                        arg_action = ACTION_INVALID;
-                        return telinit_parse_argv(argc, argv);
+
+                        if (sd_booted() > 0) {
+                                arg_action = ACTION_INVALID;
+                                return telinit_parse_argv(argc, argv);
+                        } else {
+                                /* Hmm, so some other init system is
+                                 * running, we need to forward this
+                                 * request to it. For now we simply
+                                 * guess that it is Upstart. */
+
+                                execv("/lib/upstart/telinit", argv);
+
+                                log_error("Couldn't find an alternative telinit implementation to spawn.");
+                                return -EIO;
+                        }
+
                 } else if (strstr(program_invocation_short_name, "runlevel")) {
                         arg_action = ACTION_RUNLEVEL;
                         return runlevel_parse_argv(argc, argv);
@@ -4426,7 +4444,6 @@ static int systemctl_main(DBusConnection *bus, int argc, char *argv[], DBusError
         int left;
         unsigned i;
 
-        assert(bus);
         assert(argc >= 0);
         assert(argv);
         assert(error);
@@ -4517,18 +4534,17 @@ static int reload_with_fallback(DBusConnection *bus) {
 static int start_with_fallback(DBusConnection *bus) {
         int r;
 
-
         if (bus) {
                 /* First, try systemd via D-Bus. */
                 if ((r = start_unit(bus, NULL, 0)) > 0)
                         goto done;
-
-                /* Hmm, talking to systemd via D-Bus didn't work. Then
-                 * let's try to talk to Upstart via D-Bus. */
-                if ((r = talk_upstart()) > 0)
-                        goto done;
         }
 
+        /* Hmm, talking to systemd via D-Bus didn't work. Then
+         * let's try to talk to Upstart via D-Bus. */
+        if ((r = talk_upstart()) > 0)
+                goto done;
+
         /* Nothing else worked, so let's try
          * /dev/initctl */
         if ((r = talk_initctl()) != 0)