]> dgit.raspbian.org Git - dovecot.git/commitdiff
[PATCH 1/2] lib-storage: Allow NULL path in mailbox_list_mkdir_root()
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 23 Jun 2026 14:59:45 +0000 (14:59 +0000)
committerNoah Meyerhans <noahm@debian.org>
Wed, 16 Sep 2026 19:06:35 +0000 (15:06 -0400)
When path is NULL, look up the root directory path of the given type via
mailbox_list_get_root_path() and create that. If there is no path of the
requested type, nothing is done. This avoids open-coding the common
get_root_path() + mkdir_root() pair at call sites.

Gbp-Pq: Name 0001-lib-storage-Allow-NULL-path-in-mailbox_list_mkdir_ro.patch

src/lib-storage/mailbox-list.c
src/lib-storage/mailbox-list.h

index 9712d1d679990a863f64e9bc0cd8d8732c2940be..a61a8530c8051ca6e89543c83f7318351570baa8 100644 (file)
@@ -1019,6 +1019,10 @@ int mailbox_list_mkdir_root(struct mailbox_list *list, const char *path,
 {
        const char *error;
 
+       if (path == NULL &&
+           !mailbox_list_get_root_path(list, type, &path))
+               return 0;
+
        if (mailbox_list_try_mkdir_root(list, path, type, &error) < 0) {
                mailbox_list_set_critical(list, "%s", error);
                return -1;
index e9785de695a969f25c4ada9769d13b553987a1e6..14a2f5bd8e1eaeb94ad57821fdeea2e1fce3cbd5 100644 (file)
@@ -177,7 +177,9 @@ void mailbox_list_get_permissions(struct mailbox_list *list, const char *name,
 void mailbox_list_get_root_permissions(struct mailbox_list *list,
                                       struct mailbox_permissions *permissions_r);
 /* mkdir() a root directory of given type with proper permissions. The path can
-   be either the root itself or point to a directory under the root. */
+   be either the root itself or point to a directory under the root. If path is
+   NULL, the root path of the given type is looked up automatically; if there is
+   no such path, nothing is done. */
 int mailbox_list_mkdir_root(struct mailbox_list *list, const char *path,
                            enum mailbox_list_path_type type);
 /* Like mailbox_list_mkdir_root(), but don't log an error if it fails. */