]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Added mail_storage_service_all_init_mask()
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 26 Apr 2016 08:11:57 +0000 (11:11 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 26 Apr 2016 12:54:42 +0000 (15:54 +0300)
This allows providing a usermask hint to the userdb iteration lookup. For example
with LDAP this allows setting the base based on the @domain.

src/lib-storage/mail-storage-service.c
src/lib-storage/mail-storage-service.h

index b94d08b513809a575305cc942a534353c6005f96..b347e7e157ed874840b249ce6d3c135ef82e6d58 100644 (file)
@@ -1529,6 +1529,12 @@ mail_storage_service_all_iter_deinit(struct mail_storage_service_ctx *ctx)
 }
 
 void mail_storage_service_all_init(struct mail_storage_service_ctx *ctx)
+{
+       mail_storage_service_all_init_mask(ctx, "");
+}
+
+void mail_storage_service_all_init_mask(struct mail_storage_service_ctx *ctx,
+                                       const char *user_mask_hint)
 {
        enum auth_master_flags flags = 0;
 
@@ -1542,7 +1548,8 @@ void mail_storage_service_all_init(struct mail_storage_service_ctx *ctx)
                flags |= AUTH_MASTER_FLAG_DEBUG;
        ctx->iter_conn = auth_master_init(auth_master_get_socket_path(ctx->conn),
                                          flags);
-       ctx->auth_list = auth_master_user_list_init(ctx->iter_conn, "", NULL);
+       ctx->auth_list = auth_master_user_list_init(ctx->iter_conn,
+                                                   user_mask_hint, NULL);
 }
 
 int mail_storage_service_all_next(struct mail_storage_service_ctx *ctx,
index 65b633194d1af92d3dc0396571195fdf3d3ac704..603aeaccb7fd77d3b4bec915295a5387d768d89c 100644 (file)
@@ -111,6 +111,11 @@ int mail_storage_service_lookup_next(struct mail_storage_service_ctx *ctx,
 void mail_storage_service_user_free(struct mail_storage_service_user **user);
 /* Initialize iterating through all users. */
 void mail_storage_service_all_init(struct mail_storage_service_ctx *ctx);
+/* Same as mail_storage_service_all_init(), but give a user mask hint to the
+   userdb iteration lookup. This itself isn't yet guaranteed to filter out any
+   usernames. */
+void mail_storage_service_all_init_mask(struct mail_storage_service_ctx *ctx,
+                                       const char *user_mask_hint);
 /* Iterate through all usernames. Returns 1 if username was returned, 0 if
    there are no more users, -1 if error. */
 int mail_storage_service_all_next(struct mail_storage_service_ctx *ctx,