chiark / gitweb /
journalctl: fix --update-catalog with not --root arg
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 29 Mar 2013 14:09:21 +0000 (10:09 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 29 Mar 2013 14:12:41 +0000 (10:12 -0400)
grawity> `journalctl --update-catalog` from latest git prints:
         "Recursive mkdir .: Invalid argument" and
         "Failed to write : Invalid argument"

src/journal/journalctl.c

index 3ae6482e99ff8b0d860ecbd2060fe7b7fb7ca31c..c96d68dd4cbf1feeca0fbfcd15b152d3ac10d5aa 100644 (file)
@@ -1032,11 +1032,16 @@ int main(int argc, char *argv[]) {
             arg_action == ACTION_LIST_CATALOG ||
             arg_action == ACTION_DUMP_CATALOG) {
 
-                char _cleanup_free_ *database;
-                database =  strjoin(arg_root, "/", CATALOG_DATABASE, NULL);
-                if (!database) {
-                        r = log_oom();
-                        goto finish;
+                const char* database = CATALOG_DATABASE;
+                char _cleanup_free_ *copy = NULL;
+                if (arg_root) {
+                        copy = strjoin(arg_root, "/", CATALOG_DATABASE, NULL);
+                        if (!database) {
+                                r = log_oom();
+                                goto finish;
+                        }
+                        path_kill_slashes(copy);
+                        database = copy;
                 }
 
                 if (arg_action == ACTION_UPDATE_CATALOG) {