[systemd-devel] [PATCH] journalctl: have a useful --setup-keys error message when using non-persistant logging

Shawn Landden shawnlandden at gmail.com
Fri Jul 12 20:57:15 PDT 2013


Generating seed...

Generating key pair...
Generating sealing key...
Failed to open /var/log/journal/33f46101703a10c5fc6fa4f451840101/fss.tmp.k2wDDU: No such file or directory
---
 src/journal/journalctl.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index 7baea23..458d80d 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -725,6 +725,23 @@ static int setup_keys(void) {
         char *p = NULL, *k = NULL;
         struct FSSHeader h;
         uint64_t n;
+        stat st;
+
+        r = stat("/var/log/journal", &st);
+        if (r < 0) {
+                if (errno == ENOENT || errno == ENOTDIR) {
+                        log_error("%s is not a directory, must be using persistant logging for FSS: %s", "/var/log/journal", strerror(errno));
+                        return -errno;
+                } else {
+                        log_error("stat(\"%s\") failed: %m", "/var/log/journal");
+                        return -errno;
+                }
+        }
+
+        if (!S_ISDIR(st.st_mode)) {
+                log_error("%s is not a directory, must be using persistant logging for FSS: %s", "/var/log/journal", strerror(ENOTDIR));
+                return -ENOTDIR;
+        }
 
         r = sd_id128_get_machine(&machine);
         if (r < 0) {
-- 
1.8.3.2



More information about the systemd-devel mailing list