diff --git a/lib/mu-store.cc b/lib/mu-store.cc index eff05e34..975b557b 100644 --- a/lib/mu-store.cc +++ b/lib/mu-store.cc @@ -89,8 +89,12 @@ struct Store::Private { Config make_config(XapianDb& xapian_db, const std::string& root_maildir, Option conf) { - Config config{xapian_db}; + if (!g_path_is_absolute(root_maildir.c_str())) + throw Error{Error::Code::File, + "root maildir path is not absolute ({})", + root_maildir}; + Config config{xapian_db}; if (conf) config.import_configurable(*conf); diff --git a/lib/mu-store.hh b/lib/mu-store.hh index e143b228..b6a09236 100644 --- a/lib/mu-store.hh +++ b/lib/mu-store.hh @@ -77,8 +77,8 @@ public: * Construct a store for a not-yet-existing document database * * @param path path to the database - * @param root_maildir maildir to use for this store - * @param config a configuration object + * @param root_maildir absolute path to maildir to use for this store + * @param conf a configuration object * * @return a store or an error */ diff --git a/man/mu-init.1.org b/man/mu-init.1.org index d0342d9c..38195e8d 100644 --- a/man/mu-init.1.org +++ b/man/mu-init.1.org @@ -22,7 +22,8 @@ use == as the root-maildir. By default, *mu* uses the *MAILDIR* environment; if it is not set, it uses =~/Maildir= if it is an existing directory. If neither of those can be used, the ~--maildir~ -option is required. +option is required; it must be an absolute path (but ~~/~ expansion is +performed). ** --my-address= diff --git a/mu/mu-cmd-init.cc b/mu/mu-cmd-init.cc index 210ead5c..26a96009 100644 --- a/mu/mu-cmd-init.cc +++ b/mu/mu-cmd-init.cc @@ -45,6 +45,9 @@ Mu::mu_cmd_init(const Options& opts) return Err(Error::Code::InvalidArgument, "missing --maildir parameter and could " "not determine default"); + else if (!g_path_is_absolute(opts.init.maildir.c_str())) + return Err(Error{Error::Code::File, + "--maildir is not absolute"}); MemDb mdb; Config conf{mdb};