LIST_FIELDS(StdoutStream, stdout_stream);
};
+static const char* const storage_table[] = {
+ [STORAGE_AUTO] = "auto",
+ [STORAGE_VOLATILE] = "volatile",
+ [STORAGE_PERSISTENT] = "persistent",
+ [STORAGE_NONE] = "none"
+};
+
+DEFINE_STRING_TABLE_LOOKUP(storage, Storage);
+DEFINE_CONFIG_PARSE_ENUM(config_parse_storage, storage, Storage, "Failed to parse storage setting");
+
static int server_flush_to_var(Server *s);
static uint64_t available_space(Server *s) {
free(p);
}
-
if (s->runtime_journal) {
if (asprintf(&p, "/run/log/journal/%s", ids) < 0) {
log_error("Out of memory.");
struct iovec *iovec, unsigned n, unsigned m,
struct ucred *ucred,
struct timeval *tv,
- const char *label, size_t label_len, const char *unit_id) {
+ const char *label, size_t label_len,
+ const char *unit_id) {
char *pid = NULL, *uid = NULL, *gid = NULL,
*source_time = NULL, *boot_id = NULL, *machine_id = NULL,
retry:
f = find_journal(s, realuid == 0 ? 0 : loginuid);
- if (!f)
- log_warning("Dropping message, as we can't find a place to store the data.");
- else {
+ if (f) {
r = journal_file_append_entry(f, NULL, iovec, n, &s->seqnum, NULL, NULL);
if ((r == -E2BIG || /* hit limit */
sd_id128_to_string(machine, ids);
- if (!s->system_journal) {
+ if (!s->system_journal &&
+ (s->storage == STORAGE_PERSISTENT ||
+ s->storage == STORAGE_AUTO)) {
+
+ /* If in auto mode: first try to create the machine
+ * path, but not the prefix.
+ *
+ * If in persistent mode: create /var/log/journal and
+ * the machine path */
+
+ if (s->storage & STORAGE_PERSISTENT)
+ (void) mkdir("/var/log/journal/", 0755);
- /* First try to create the machine path, but not the prefix */
fn = strappend("/var/log/journal/", ids);
if (!fn)
return -ENOMEM;
+
(void) mkdir(fn, 0755);
free(fn);
}
}
- if (!s->runtime_journal) {
+ if (!s->runtime_journal &&
+ (s->storage != STORAGE_NONE)) {
fn = join("/run/log/journal/", ids, "/system.journal", NULL);
if (!fn)
}
static int server_flush_to_var(Server *s) {
- char path[] = "/run/log/journal/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
Object *o = NULL;
int r;
sd_id128_t machine;
assert(s);
+ if (s->storage != STORAGE_AUTO &&
+ s->storage != STORAGE_PERSISTENT)
+ return 0;
+
if (!s->runtime_journal)
return 0;
s->runtime_journal = NULL;
if (r >= 0) {
+ char path[] = "/run/log/journal/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
sd_id128_to_string(machine, path + 17);
rm_rf(path, false, true, false);
}
assert(s->proc_kmsg_fd >= 0);
l = read(s->proc_kmsg_fd, s->proc_kmsg_buffer + s->proc_kmsg_length, sizeof(s->proc_kmsg_buffer) - 1 - s->proc_kmsg_length);
+ if (l == 0) /* the kernel is stupid and in some race
+ * conditions returns 0 in the middle of the
+ * stream. */
+ return 0;
if (l < 0) {
if (errno == EAGAIN || errno == EINTR)
goto finish;
}
- if (startswith(word, "systemd_journald.forward_to_syslog=")) {
+ if (startswith(word, "systemd.journald.forward_to_syslog=")) {
r = parse_boolean(word + 35);
if (r < 0)
log_warning("Failed to parse forward to syslog switch %s. Ignoring.", word + 35);
else
s->forward_to_syslog = r;
- } else if (startswith(word, "systemd_journald.forward_to_kmsg=")) {
+ } else if (startswith(word, "systemd.journald.forward_to_kmsg=")) {
r = parse_boolean(word + 33);
if (r < 0)
log_warning("Failed to parse forward to kmsg switch %s. Ignoring.", word + 33);
else
s->forward_to_kmsg = r;
- } else if (startswith(word, "systemd_journald.forward_to_console=")) {
+ } else if (startswith(word, "systemd.journald.forward_to_console=")) {
r = parse_boolean(word + 36);
if (r < 0)
log_warning("Failed to parse forward to console switch %s. Ignoring.", word + 36);
else
s->forward_to_console = r;
- }
+ } else if (startswith(word, "systemd.journald"))
+ log_warning("Invalid systemd.journald parameter. Ignoring.");
free(word);
}
s->rate_limit_burst = DEFAULT_RATE_LIMIT_BURST;
s->forward_to_syslog = true;
- s->import_proc_kmsg = true;
s->max_level_store = LOG_DEBUG;
s->max_level_syslog = LOG_DEBUG;