mirror of
https://github.com/systemd/systemd.git
synced 2025-03-31 14:50:15 +03:00
journal-send: introduce journal_stream_path helper
This commit is contained in:
parent
baaca3db6a
commit
2a11593178
@ -41,6 +41,7 @@
|
||||
#include "hexdecoct.h"
|
||||
#include "io-util.h"
|
||||
#include "iovec-util.h"
|
||||
#include "journal-send.h"
|
||||
#include "missing_ioprio.h"
|
||||
#include "missing_prctl.h"
|
||||
#include "missing_securebits.h"
|
||||
@ -159,9 +160,11 @@ static int connect_journal_socket(
|
||||
const char *j;
|
||||
int r;
|
||||
|
||||
j = log_namespace ?
|
||||
strjoina("/run/systemd/journal.", log_namespace, "/stdout") :
|
||||
"/run/systemd/journal/stdout";
|
||||
assert(fd >= 0);
|
||||
|
||||
j = journal_stream_path(log_namespace);
|
||||
if (!j)
|
||||
return -EINVAL;
|
||||
|
||||
if (gid_is_valid(gid)) {
|
||||
oldgid = getgid();
|
||||
|
@ -2,6 +2,23 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "syslog-util.h"
|
||||
|
||||
int journal_fd_nonblock(bool nonblock);
|
||||
void close_journal_fd(void);
|
||||
|
||||
/* We declare sd_journal_stream_fd() as async-signal-safe. So instead of strjoin(), which calls malloc()
|
||||
* internally, use a macro + alloca(). */
|
||||
#define journal_stream_path(log_namespace) \
|
||||
({ \
|
||||
const char *_ns = (log_namespace), *_ret; \
|
||||
if (!_ns) \
|
||||
_ret = "/run/systemd/journal/stdout"; \
|
||||
else if (log_namespace_name_valid(_ns)) \
|
||||
_ret = strjoina("/run/systemd/journal.", _ns, "/stdout"); \
|
||||
else \
|
||||
_ret = NULL; \
|
||||
_ret; \
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user