chiark / gitweb /
journalctl: have a useful --setup-keys error message when using non-persistant logging
authorShawn Landden <shawnlandden@gmail.com>
Sat, 13 Jul 2013 03:57:15 +0000 (20:57 -0700)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 13 Jul 2013 11:56:11 +0000 (07:56 -0400)
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

index 7baea23..32665b7 100644 (file)
@@ -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) {