Mercurial > dovecot > original-hg > dovecot-1.2
changeset 6149:a744ae38a9e1 HEAD
Having =key=value in pass_attrs or user_attrs allows returning static
key=value pairs.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 25 Jul 2007 09:21:35 +0300 |
parents | 668a768fc8fd |
children | 6d6f0e4bd20d |
files | src/auth/db-ldap.c |
diffstat | 1 files changed, 34 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/auth/db-ldap.c Wed Jul 25 09:11:43 2007 +0300 +++ b/src/auth/db-ldap.c Wed Jul 25 09:21:35 2007 +0300 @@ -52,6 +52,7 @@ char *attr, **vals; const char *name, *value, *template, *val_1_arr[2]; + const char *const *static_attrs; BerElement *ber; string_t *var, *debug; @@ -622,6 +623,7 @@ const char *skip_attr) { const char *const *attr; + string_t *static_data; char *name, *value, *p; unsigned int i, j, size; @@ -630,6 +632,7 @@ t_push(); attr = t_strsplit(attrlist, ","); + static_data = t_str_new(128); /* @UNSAFE */ for (size = 0; attr[size] != NULL; size++) ; @@ -639,9 +642,15 @@ p = strchr(attr[i], '='); if (p == NULL) name = value = p_strdup(conn->pool, attr[i]); - else { + else if (p != attr[i]) { name = p_strdup_until(conn->pool, attr[i], p); value = p_strdup(conn->pool, p + 1); + } else { + /* =<static key>=<static value> */ + if (str_len(static_data) > 0) + str_append_c(static_data, ','); + str_append(static_data, p + 1); + continue; } if (*name != '\0' && @@ -650,6 +659,10 @@ (*attr_names_r)[j++] = name; } } + if (str_len(static_data) > 0) { + hash_insert(attr_map, "", + p_strdup(conn->pool, str_c(static_data))); + } t_pop(); } @@ -704,6 +717,7 @@ struct hash_table *attr_map) { struct db_ldap_result_iterate_context *ctx; + const char *static_data; ctx = t_new(struct db_ldap_result_iterate_context, 1); ctx->conn = conn; @@ -711,6 +725,10 @@ ctx->auth_request = auth_request; ctx->attr_map = attr_map; + static_data = hash_lookup(attr_map, ""); + if (static_data != NULL) + ctx->static_attrs = t_strsplit(static_data, ","); + if (auth_request->auth->verbose_debug) ctx->debug = t_str_new(256); @@ -787,6 +805,8 @@ static bool db_ldap_result_int_next(struct db_ldap_result_iterate_context *ctx) { + const char *p; + while (ctx->attr != NULL) { if (ctx->vals == NULL) { /* a new attribute */ @@ -808,6 +828,19 @@ ctx->ber); } + if (ctx->static_attrs != NULL && *ctx->static_attrs != NULL) { + p = strchr(*ctx->static_attrs, '='); + if (p == NULL) { + ctx->name = *ctx->static_attrs; + ctx->value = ""; + } else { + ctx->name = t_strdup_until(*ctx->static_attrs, p); + ctx->value = p + 1; + } + ctx->static_attrs++; + return TRUE; + } + db_ldap_result_iterate_finish(ctx); return FALSE; }