chiark / gitweb /
journald: after the cgroup rework processes may be in both user and system units...
[elogind.git] / src / journal / journald-server.c
index 6beaa8a72932da5170407007f0d2ed5016bfd0f6..60c32b1eff28797e7abc3e6c50b2e9780138aa07 100644 (file)
@@ -578,6 +578,13 @@ static void dispatch_message_real(
                         IOVEC_SET_STRING(iovec[n++], x);
                 }
 
+                r = get_process_capeff(ucred->pid, &t);
+                if (r >= 0) {
+                        x = strappenda("_CAP_EFFECTIVE=", t);
+                        free(t);
+                        IOVEC_SET_STRING(iovec[n++], x);
+                }
+
 #ifdef HAVE_AUDIT
                 r = audit_session_from_pid(ucred->pid, &audit);
                 if (r >= 0) {
@@ -616,19 +623,20 @@ static void dispatch_message_real(
                         if (cg_path_get_unit(c, &t) >= 0) {
                                 x = strappenda("_SYSTEMD_UNIT=", t);
                                 free(t);
-                        } else if (cg_path_get_user_unit(c, &t) >= 0) {
+                                IOVEC_SET_STRING(iovec[n++], x);
+                        } else if (unit_id && !session) {
+                                x = strappenda("_SYSTEMD_UNIT=", unit_id);
+                                IOVEC_SET_STRING(iovec[n++], x);
+                        }
+
+                        if (cg_path_get_user_unit(c, &t) >= 0) {
                                 x = strappenda("_SYSTEMD_USER_UNIT=", t);
                                 free(t);
-                        } else if (unit_id) {
-                                if (session)
-                                        x = strappenda("_SYSTEMD_USER_UNIT=", unit_id);
-                                else
-                                        x = strappenda("_SYSTEMD_UNIT=", unit_id);
-                        } else
-                                x = NULL;
-
-                        if (x)
                                 IOVEC_SET_STRING(iovec[n++], x);
+                        } else if (unit_id && session) {
+                                x = strappenda("_SYSTEMD_USER_UNIT=", unit_id);
+                                IOVEC_SET_STRING(iovec[n++], x);
+                        }
 
                         free(c);
                 }
@@ -721,14 +729,14 @@ static void dispatch_message_real(
                         if (cg_path_get_unit(c, &t) >= 0) {
                                 x = strappenda("OBJECT_SYSTEMD_UNIT=", t);
                                 free(t);
-                        } else if (cg_path_get_user_unit(c, &t) >= 0) {
+                                IOVEC_SET_STRING(iovec[n++], x);
+                        }
+
+                        if (cg_path_get_user_unit(c, &t) >= 0) {
                                 x = strappenda("OBJECT_SYSTEMD_USER_UNIT=", t);
                                 free(t);
-                        } else
-                                x = NULL;
-
-                        if (x)
                                 IOVEC_SET_STRING(iovec[n++], x);
+                        }
 
                         free(c);
                 }
@@ -838,6 +846,11 @@ void server_dispatch_message(
         if (LOG_PRI(priority) > s->max_level_store)
                 return;
 
+        /* Stop early in case the information will not be stored
+         * in a journal. */
+        if (s->storage == STORAGE_NONE)
+                return;
+
         if (!ucred)
                 goto finish;