From: Shawn Landden Date: Sat, 13 Jul 2013 03:57:15 +0000 (-0700) Subject: journalctl: have a useful --setup-keys error message when using non-persistant logging X-Git-Tag: v206~113 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=b98e3866fddf2edfa13fc1b4323aa84f89336ff2 journalctl: have a useful --setup-keys error message when using non-persistant logging Generating seed... Generating key pair... Generating sealing key... Failed to open /var/log/journal/33f46101703a10c5fc6fa4f451840101/fss.tmp.k2wDDU: No such file or directory --- diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c index 7baea237c..32665b7f7 100644 --- a/src/journal/journalctl.c +++ b/src/journal/journalctl.c @@ -725,6 +725,19 @@ static int setup_keys(void) { char *p = NULL, *k = NULL; struct FSSHeader h; uint64_t n; + struct stat st; + + r = stat("/var/log/journal", &st); + if (r < 0 && errno != ENOENT && errno != ENOTDIR) { + log_error("stat(\"%s\") failed: %m", "/var/log/journal"); + return -errno; + } + + if (r < 0 || !S_ISDIR(st.st_mode)) { + log_error("%s is not a directory, must be using persistent logging for FSS.", + "/var/log/journal"); + return r < 0 ? -errno : -ENOTDIR; + } r = sd_id128_get_machine(&machine); if (r < 0) {