]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journal-send: check if $LOG_NAMESPACE denotes our /run/systemd/journal/ is already...
authorMike Yuan <me@yhndnzj.com>
Sat, 7 Feb 2026 20:22:56 +0000 (21:22 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 9 Feb 2026 08:41:47 +0000 (09:41 +0100)
src/libsystemd/sd-journal/journal-send.c

index d1a8ebdfad01ee7bd80b55c97b203716dc60eed3..5c7b007b131b2b45e75ebac2da7b48e25bdc857a 100644 (file)
@@ -387,6 +387,19 @@ _public_ int sd_journal_stream_fd_with_namespace(
         assert_return(priority >= 0, -EINVAL);
         assert_return(priority <= 7, -EINVAL);
 
+        if (name_space) {
+                /* If $LOG_NAMESPACE is set, we're already placed in a mountns with /run/systemd/journal/
+                 * being a bind mount for the journald namespace instance, in which case we shall go by
+                 * the standard journal socket path. */
+                const char *env = secure_getenv("LOG_NAMESPACE");
+                if (env) {
+                        if (!streq(name_space, env))
+                                return -EREMOTE;
+
+                        name_space = NULL;
+                }
+        }
+
         path = journal_stream_path(name_space);
         if (!path)
                 return -EINVAL;