From: Timo Sirainen Date: Tue, 23 Jun 2026 14:59:45 +0000 (+0000) Subject: [PATCH 1/2] lib-storage: Allow NULL path in mailbox_list_mkdir_root() X-Git-Tag: archive/raspbian/1%2.4.1+dfsg1-6+rpi1+deb13u7^2~118 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=a43c232e654596f0f9792f4a5e2a43f63cb1c9f6;p=dovecot.git [PATCH 1/2] lib-storage: Allow NULL path in mailbox_list_mkdir_root() 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 --- diff --git a/src/lib-storage/mailbox-list.c b/src/lib-storage/mailbox-list.c index 9712d1d..a61a853 100644 --- a/src/lib-storage/mailbox-list.c +++ b/src/lib-storage/mailbox-list.c @@ -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; diff --git a/src/lib-storage/mailbox-list.h b/src/lib-storage/mailbox-list.h index e9785de..14a2f5b 100644 --- a/src/lib-storage/mailbox-list.h +++ b/src/lib-storage/mailbox-list.h @@ -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. */