dovecot-2.2: lib-storage: Sort userdb fields before importing them.
dovecot at dovecot.org
dovecot at dovecot.org
Sat May 19 22:28:25 EEST 2012
details: http://hg.dovecot.org/dovecot-2.2/rev/875eeb3052a9
changeset: 14232:875eeb3052a9
user: Timo Sirainen <tss at iki.fi>
date: Sat May 19 22:28:19 2012 +0300
description:
lib-storage: Sort userdb fields before importing them.
This avoids requiring manual sorting in some situations, such as when
defining new namespaces.
diffstat:
src/lib-storage/mail-storage-service.c | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
diffs (33 lines):
diff -r 10a475d725a1 -r 875eeb3052a9 src/lib-storage/mail-storage-service.c
--- a/src/lib-storage/mail-storage-service.c Fri May 04 00:48:45 2012 +0300
+++ b/src/lib-storage/mail-storage-service.c Sat May 19 22:28:19 2012 +0300
@@ -907,6 +907,21 @@
user_set->mail_plugins, &mod_set);
}
+static int extra_field_key_cmp_p(const char *const *s1, const char *const *s2)
+{
+ const char *p1 = *s1, *p2 = *s2;
+
+ for (; *p1 == *p2; p1++, p2++) {
+ if (*p1 == '\0')
+ return 0;
+ }
+ if (*p1 == '=')
+ return -1;
+ if (*p2 == '=')
+ return 1;
+ return *p1 - *p2;
+}
+
int mail_storage_service_lookup(struct mail_storage_service_ctx *ctx,
const struct mail_storage_service_input *input,
struct mail_storage_service_user **user_r,
@@ -992,6 +1007,7 @@
if (userdb_fields != NULL) {
auth_user_fields_parse(userdb_fields, temp_pool, &reply);
+ array_sort(&reply.extra_fields, extra_field_key_cmp_p);
if (user_reply_handle(ctx, user, &reply, &error) < 0) {
i_error("user %s: Invalid settings in userdb: %s",
username, error);
More information about the dovecot-cvs
mailing list