diff --git a/NEWS b/NEWS
index 566ee2a9d5..ba206afdfb 100644
--- a/NEWS
+++ b/NEWS
@@ -268,6 +268,9 @@ CHANGES WITH 256-rc1:
added to control the maximum log levels for the messages sent to this
socket.
+ * systemd-journald now also reads the journal.storage credential when
+ determining where to store journal files.
+
* systemd-vmspawn gained a new --forward-journal= option to forward the
virtual machine's journal entries to the host. This is done over a
AF_VSOCK socket, i.e. it does not require networking in the guest.
diff --git a/man/journald.conf.xml b/man/journald.conf.xml
index 1b07040da4..2d53eea137 100644
--- a/man/journald.conf.xml
+++ b/man/journald.conf.xml
@@ -103,6 +103,10 @@
Note that per-user journal files are not supported unless persistent storage is enabled, thus
making journalctl --user unavailable.
+ The storage to use can also be specified via the journal.storage
+ credential. Values configured via configuration files take priority over values configured via the
+ credential.
+
diff --git a/man/systemd-journald.service.xml b/man/systemd-journald.service.xml
index 8eeb209b07..cb06b3b8f8 100644
--- a/man/systemd-journald.service.xml
+++ b/man/systemd-journald.service.xml
@@ -220,6 +220,37 @@ systemd-tmpfiles --create --prefix /var/log/journal
+
+ Credentials
+
+ systemd-journald supports the service credentials logic as implemented by
+ ImportCredential=/LoadCredential=/SetCredential=
+ (see systemd.exec5 for
+ details). The following credentials are used when passed in:
+
+
+
+ journal.forward_to_socket
+
+ May contain a socket address to which logs should be forwarded. See
+ ForwardToSocket= in
+ journald.conf5.
+
+
+
+
+
+ journal.storage
+
+ May be used to specify where journal files should be stored. See
+ Storage= in
+ journald.conf5.
+
+
+
+
+
+
Kernel Command Line
diff --git a/man/systemd.system-credentials.xml b/man/systemd.system-credentials.xml
index e8e2985a42..d9fbae25ee 100644
--- a/man/systemd.system-credentials.xml
+++ b/man/systemd.system-credentials.xml
@@ -309,6 +309,18 @@
+
+ journal.storage
+
+ Used by
+ systemd-journald8
+ to determine where to store journal files, see
+ journald.conf5 for details.
+
+
+
+
+
vmm.notify_socket
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
index c78678f1f6..dfad063e47 100644
--- a/src/journal/journald-server.c
+++ b/src/journal/journald-server.c
@@ -2522,17 +2522,27 @@ static void server_load_credentials(Server *s) {
assert(s);
- /* if we already have a forward address from config don't load the credential */
- if (s->forward_to_socket.sockaddr.sa.sa_family != AF_UNSPEC)
- return log_debug("Socket forward address already set not loading journal.forward_to_socket");
-
r = read_credential("journal.forward_to_socket", &data, NULL);
if (r < 0)
- return (void) log_debug_errno(r, "Failed to read credential journal.forward_to_socket, ignoring: %m");
+ log_debug_errno(r, "Failed to read credential journal.forward_to_socket, ignoring: %m");
+ else {
+ r = socket_address_parse(&s->forward_to_socket, data);
+ if (r < 0)
+ log_debug_errno(r, "Failed to parse socket address '%s' from credential journal.forward_to_socket, ignoring: %m", (char *) data);
+ }
- r = socket_address_parse(&s->forward_to_socket, data);
+ data = mfree(data);
+
+ r = read_credential("journal.storage", &data, NULL);
if (r < 0)
- log_debug_errno(r, "Failed to parse credential journal.forward_to_socket, ignoring: %m");
+ log_debug_errno(r, "Failed to read credential journal.storage, ignoring: %m");
+ else {
+ r = storage_from_string(data);
+ if (r < 0)
+ log_debug_errno(r, "Failed to parse storage '%s' from credential journal.storage, ignoring: %m", (char *) data);
+ else
+ s->storage = r;
+ }
}
int server_new(Server **ret) {
@@ -2617,9 +2627,8 @@ int server_init(Server *s, const char *namespace) {
journal_reset_metrics(&s->system_storage.metrics);
journal_reset_metrics(&s->runtime_storage.metrics);
- server_parse_config_file(s);
-
server_load_credentials(s);
+ server_parse_config_file(s);
if (!s->namespace) {
/* Parse kernel command line, but only if we are not a namespace instance */