diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/journal/journald-gperf.gperf | 1 | ||||
-rw-r--r-- | src/journal/journald.c | 37 | ||||
-rw-r--r-- | src/journal/journald.h | 16 | ||||
-rw-r--r-- | src/login/logind.conf | 1 |
4 files changed, 48 insertions, 7 deletions
diff --git a/src/journal/journald-gperf.gperf b/src/journal/journald-gperf.gperf index c9b0fbb0e2..4fe2ea0ec6 100644 --- a/src/journal/journald-gperf.gperf +++ b/src/journal/journald-gperf.gperf @@ -34,3 +34,4 @@ Journal.MaxLevelStore, config_parse_level, 0, offsetof(Server, max_leve Journal.MaxLevelSyslog, config_parse_level, 0, offsetof(Server, max_level_syslog) Journal.MaxLevelKMsg, config_parse_level, 0, offsetof(Server, max_level_kmsg) Journal.MaxLevelConsole, config_parse_level, 0, offsetof(Server, max_level_console) +Journal.Storage, config_parse_storage, 0, offsetof(Server, storage) diff --git a/src/journal/journald.c b/src/journal/journald.c index 7ea68aab3c..08597ae3eb 100644 --- a/src/journal/journald.c +++ b/src/journal/journald.c @@ -111,6 +111,16 @@ struct StdoutStream { LIST_FIELDS(StdoutStream, stdout_stream); }; +static const char* const storage_table[] = { + [STORAGE_AUTO] = "auto", + [STORAGE_VOLATILE] = "volatile", + [STORAGE_PERMANENT] = "permanent", + [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) { @@ -397,7 +407,6 @@ static void server_vacuum(Server *s) { free(p); } - if (s->runtime_journal) { if (asprintf(&p, "/run/log/journal/%s", ids) < 0) { log_error("Out of memory."); @@ -625,9 +634,7 @@ static void dispatch_message_real( 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 */ @@ -1955,12 +1962,23 @@ static int system_journal_open(Server *s) { sd_id128_to_string(machine, ids); - if (!s->system_journal) { + if (!s->system_journal && + (s->storage == STORAGE_PERMANENT || + s->storage == STORAGE_AUTO)) { + + /* If in auto mode: first try to create the machine + * path, but not the prefix. + * + * If in permanent mode: create /var/log/journal and + * the machine path */ + + if (s->storage & STORAGE_PERMANENT) + (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); @@ -1988,7 +2006,8 @@ static int system_journal_open(Server *s) { } } - if (!s->runtime_journal) { + if (!s->runtime_journal && + (s->storage != STORAGE_NONE)) { fn = join("/run/log/journal/", ids, "/system.journal", NULL); if (!fn) @@ -2048,6 +2067,10 @@ static int server_flush_to_var(Server *s) { assert(s); + if (s->storage != STORAGE_AUTO && + s->storage != STORAGE_PERMANENT) + return 0; + if (!s->runtime_journal) return 0; diff --git a/src/journal/journald.h b/src/journal/journald.h index 159364d930..34deb8561e 100644 --- a/src/journal/journald.h +++ b/src/journal/journald.h @@ -33,6 +33,15 @@ #include "journal-rate-limit.h" #include "list.h" +typedef enum Storage { + STORAGE_AUTO, + STORAGE_VOLATILE, + STORAGE_PERMANENT, + STORAGE_NONE, + _STORAGE_MAX, + _STORAGE_INVALID = -1 +} Storage; + typedef struct StdoutStream StdoutStream; typedef struct Server { @@ -86,9 +95,16 @@ typedef struct Server { int max_level_syslog; int max_level_kmsg; int max_level_console; + + Storage storage; } Server; /* gperf lookup function */ const struct ConfigPerfItem* journald_gperf_lookup(const char *key, unsigned length); +int config_parse_storage(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); + +const char *storage_to_string(Storage s); +Storage storage_from_string(const char *s); + #endif diff --git a/src/login/logind.conf b/src/login/logind.conf index 78496a0ef1..c3798f7c7c 100644 --- a/src/login/logind.conf +++ b/src/login/logind.conf @@ -18,3 +18,4 @@ #HandlePowerKey=no-session #HandleSleepKey=tty-session #HandleLidSwitch=off +#Storage=auto |