chiark / gitweb /
journalctl: have a useful --setup-keys error message when using non-persistant logging
[elogind.git] / src / journal / journalctl.c
index 7baea237cb57690ba40eda5e7d5e157397a9d047..32665b7f787685d5e4e59f532c1cad7c936a4a68 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) {