]> git.notmuchmail.org Git - notmuch/blobdiff - lib/open.cc
lib/open: canonicalize relative path read from config file
[notmuch] / lib / open.cc
index 6c3ef46fe5a620d9f00ffffd2947858e33efab51..d0493950ff0d48877c8536b0f6535110bde2bbe0 100644 (file)
@@ -196,11 +196,13 @@ _choose_database_path (void *ctx,
     if (! *database_path && key_file) {
        char *path = g_key_file_get_value (key_file, "database", "path", NULL);
        if (path) {
-           *database_path = talloc_strdup (ctx, path);
+           if (path[0] == '/')
+               *database_path = talloc_strdup (ctx, path);
+           else
+               *database_path = talloc_asprintf (ctx, "%s/%s", getenv ("HOME"), path);
            g_free (path);
        }
     }
-
     if (! *database_path) {
        *database_path = _xdg_dir (ctx, "XDG_DATA_HOME", ".local/share", profile);
        *split = true;