journal-send: check if $LOG_NAMESPACE denotes our /run/systemd/journal/ is already namespaced properly

This commit is contained in:
Mike Yuan
2026-02-09 09:41:47 +01:00
committed by Daan De Meyer
parent a2e55fceee
commit 8b7e98f183
+13
View 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;