chiark / gitweb /
pam: fix build
[elogind.git] / src / manager.c
index f8cbcfcc98ff8fa7faf1f25dadf1ec7fa908e5f5..a549209ca6481c13bf09e07dd27adb81f083a511 100644 (file)
@@ -41,6 +41,8 @@
 #include <libaudit.h>
 #endif
 
+#include <systemd/sd-daemon.h>
+
 #include "manager.h"
 #include "hashmap.h"
 #include "macro.h"
@@ -58,7 +60,6 @@
 #include "special.h"
 #include "bus-errors.h"
 #include "exit-status.h"
-#include "sd-daemon.h"
 #include "virt.h"
 
 /* As soon as 16 units are in our GC queue, make sure to run a gc sweep */
@@ -194,6 +195,7 @@ static int manager_setup_signals(Manager *m) {
                         SIGRTMIN+21, /* systemd: disable status messages */
                         SIGRTMIN+22, /* systemd: set log level to LOG_DEBUG */
                         SIGRTMIN+23, /* systemd: set log level to LOG_INFO */
+                        SIGRTMIN+26, /* systemd: set log target to journal-or-kmsg */
                         SIGRTMIN+27, /* systemd: set log target to console */
                         SIGRTMIN+28, /* systemd: set log target to kmsg */
                         SIGRTMIN+29, /* systemd: set log target to syslog-or-kmsg */
@@ -231,7 +233,7 @@ int manager_new(ManagerRunningAs running_as, Manager **_m) {
         dual_timestamp_get(&m->startup_timestamp);
 
         m->running_as = running_as;
-        m->name_data_slot = m->subscribed_data_slot = -1;
+        m->name_data_slot = m->conn_data_slot = m->subscribed_data_slot = -1;
         m->exit_code = _MANAGER_EXIT_CODE_INVALID;
         m->pin_cgroupfs_fd = -1;
 
@@ -1609,7 +1611,9 @@ static int transaction_add_job_and_dependencies(
                                                 dbus_error_free(e);
                                 }
 
-                } else if (type == JOB_STOP || type == JOB_RESTART || type == JOB_TRY_RESTART) {
+                }
+
+                if (type == JOB_STOP || type == JOB_RESTART || type == JOB_TRY_RESTART) {
 
                         SET_FOREACH(dep, ret->unit->meta.dependencies[UNIT_REQUIRED_BY], i)
                                 if ((r = transaction_add_job_and_dependencies(m, type, dep, ret, true, override, false, false, ignore_order, e, NULL)) < 0) {
@@ -1632,6 +1636,20 @@ static int transaction_add_job_and_dependencies(
                                 }
                 }
 
+                if (type == JOB_RELOAD || type == JOB_RELOAD_OR_START) {
+
+                        SET_FOREACH(dep, ret->unit->meta.dependencies[UNIT_PROPAGATE_RELOAD_TO], i) {
+                                r = transaction_add_job_and_dependencies(m, JOB_RELOAD, dep, ret, false, override, false, false, ignore_order, e, NULL);
+
+                                if (r < 0) {
+                                        log_warning("Cannot add dependency reload job for unit %s, ignoring: %s", dep->meta.id, bus_error(e, r));
+
+                                        if (e)
+                                                dbus_error_free(e);
+                                }
+                        }
+                }
+
                 /* JOB_VERIFY_STARTED, JOB_RELOAD require no dependency handling */
         }
 
@@ -2276,6 +2294,11 @@ static int manager_process_signal_fd(Manager *m) {
                                 log_notice("Setting log level to info.");
                                 break;
 
+                        case 26:
+                                log_set_target(LOG_TARGET_JOURNAL_OR_KMSG);
+                                log_notice("Setting log target to journal-or-kmsg.");
+                                break;
+
                         case 27:
                                 log_set_target(LOG_TARGET_CONSOLE);
                                 log_notice("Setting log target to console.");
@@ -3104,7 +3127,7 @@ int manager_set_default_controllers(Manager *m, char **controllers) {
         return 0;
 }
 
-void manager_recheck_syslog(Manager *m) {
+void manager_recheck_journal(Manager *m) {
         Unit *u;
 
         assert(m);
@@ -3112,36 +3135,20 @@ void manager_recheck_syslog(Manager *m) {
         if (m->running_as != MANAGER_SYSTEM)
                 return;
 
-        if ((u = manager_get_unit(m, SPECIAL_SYSLOG_SOCKET))) {
-                SocketState state;
-
-                state = SOCKET(u)->state;
-
-                if (state != SOCKET_DEAD &&
-                    state != SOCKET_FAILED &&
-                    state != SOCKET_RUNNING) {
-
-                        /* Hmm, the socket is not set up, or is still
-                         * listening, let's better not try to use
-                         * it. Note that we have no problem if the
-                         * socket is completely down, since there
-                         * might be a foreign /dev/log socket around
-                         * and we want to make use of that.
-                         */
-
-                        log_close_syslog();
-                        return;
-                }
+        u = manager_get_unit(m, SPECIAL_JOURNALD_SOCKET);
+        if (u && SOCKET(u)->state != SOCKET_RUNNING) {
+                log_close_journal();
+                return;
         }
 
-        if ((u = manager_get_unit(m, SPECIAL_SYSLOG_TARGET)))
-                if (TARGET(u)->state != TARGET_ACTIVE) {
-                        log_close_syslog();
-                        return;
-                }
+        u = manager_get_unit(m, SPECIAL_JOURNALD_SERVICE);
+        if (u && SERVICE(u)->state != SERVICE_RUNNING) {
+                log_close_journal();
+                return;
+        }
 
-        /* Hmm, OK, so the socket is either fully up, or fully down,
-         * and the target is up, then let's make use of the socket */
+        /* Hmm, OK, so the socket is fully up and the service is up
+         * too, then let's make use of the thing. */
         log_open();
 }