Skip to content

Commit

Permalink
lib-storage: Added mail_storage_service_all_init_mask()
Browse files Browse the repository at this point in the history
This allows providing a usermask hint to the userdb iteration lookup. For example
with LDAP this allows setting the base based on the @Domain.
  • Loading branch information
sirainen committed Apr 26, 2016
1 parent 92c610a commit 55e04e5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/lib-storage/mail-storage-service.c
Expand Up @@ -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;

Expand All @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions src/lib-storage/mail-storage-service.h
Expand Up @@ -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,
Expand Down

0 comments on commit 55e04e5

Please sign in to comment.