chiark / gitweb /
cgroup: don't recheck all the time whether the systemd hierarchy is mounted, to make...
[elogind.git] / src / manager.c
index 6ccb03fab45b58fbe5687c9c4e35a2aa1cf0ea81..df75eca8c48d6167bcc468b33d3662c7309d93d1 100644 (file)
@@ -90,8 +90,10 @@ static int manager_setup_notify(Manager *m) {
 
         if (getpid() != 1)
                 snprintf(sa.un.sun_path, sizeof(sa.un.sun_path), NOTIFY_SOCKET_USER "/%llu", random_ull());
-        else
+        else {
+                unlink(NOTIFY_SOCKET_SYSTEM);
                 strncpy(sa.un.sun_path, NOTIFY_SOCKET_SYSTEM, sizeof(sa.un.sun_path));
+        }
 
         if (sa.un.sun_path[0] == '@')
                 sa.un.sun_path[0] = 0;
@@ -2055,6 +2057,8 @@ static int manager_process_signal_fd(Manager *m) {
         assert(m);
 
         for (;;) {
+                char *p = NULL;
+
                 if ((n = read(m->signal_watch.fd, &sfsi, sizeof(sfsi))) != sizeof(sfsi)) {
 
                         if (n >= 0)
@@ -2066,7 +2070,11 @@ static int manager_process_signal_fd(Manager *m) {
                         return -errno;
                 }
 
-                log_debug("Received SIG%s", strna(signal_to_string(sfsi.ssi_signo)));
+                get_process_name(sfsi.ssi_pid, &p);
+                log_debug("Received SIG%s from PID %lu (%s)",
+                          strna(signal_to_string(sfsi.ssi_signo)),
+                          (unsigned long) sfsi.ssi_pid, strna(p));
+                free(p);
 
                 switch (sfsi.ssi_signo) {
 
@@ -2446,8 +2454,19 @@ void manager_send_unit_audit(Manager *m, Unit *u, int type, bool success) {
                 return;
         }
 
-        if (audit_log_user_comm_message(m->audit_fd, type, "", p, NULL, NULL, NULL, success) < 0)
-                log_error("Failed to send audit message: %m");
+        if (audit_log_user_comm_message(m->audit_fd, type, "", p, NULL, NULL, NULL, success) < 0) {
+                log_warning("Failed to send audit message: %m");
+
+                if (errno == EPERM) {
+                        /* We aren't allowed to send audit messages?
+                         * Then let's not retry again, to avoid
+                         * spamming the user with the same and same
+                         * messages over and over. */
+
+                        audit_close(m->audit_fd);
+                        m->audit_fd = -1;
+                }
+        }
 
         free(p);
 #endif
@@ -2822,7 +2841,8 @@ void manager_check_finished(Manager *m) {
 
         dual_timestamp_get(&m->finish_timestamp);
 
-        if (m->running_as == MANAGER_SYSTEM) {
+        if (m->running_as == MANAGER_SYSTEM && detect_container(NULL) <= 0) {
+
                 if (dual_timestamp_is_set(&m->initrd_timestamp)) {
                         log_info("Startup finished in %s (kernel) + %s (initrd) + %s (userspace) = %s.",
                                  format_timespan(kernel, sizeof(kernel),