dovecot: Added "username" and "domain" fields for modifying the ...
dovecot at dovecot.org
dovecot at dovecot.org
Sun Oct 21 00:03:26 EEST 2007
details: http://hg.dovecot.org/dovecot/rev/d573bc2a967d
changeset: 6575:d573bc2a967d
user: Timo Sirainen <tss at iki.fi>
date: Sun Oct 21 00:02:13 2007 +0300
description:
Added "username" and "domain" fields for modifying the username.
diffstat:
1 file changed, 23 insertions(+), 2 deletions(-)
src/auth/auth-request.c | 25 +++++++++++++++++++++++--
diffs (42 lines):
diff -r ab3a1a8ade55 -r d573bc2a967d src/auth/auth-request.c
--- a/src/auth/auth-request.c Sat Oct 20 23:47:30 2007 +0300
+++ b/src/auth/auth-request.c Sun Oct 21 00:02:13 2007 +0300
@@ -944,6 +944,8 @@ void auth_request_set_field(struct auth_
const char *name, const char *value,
const char *default_scheme)
{
+ const char *p;
+
i_assert(*name != '\0');
i_assert(value != NULL);
@@ -967,8 +969,27 @@ void auth_request_set_field(struct auth_
return;
}
- if (strcmp(name, "user") == 0) {
- /* update username to be exactly as it's in database */
+ if (strcmp(name, "user") == 0 ||
+ strcmp(name, "username") == 0 || strcmp(name, "domain") == 0) {
+ /* update username */
+ if (strcmp(name, "username") == 0 &&
+ strchr(value, '@') == NULL &&
+ (p = strchr(request->user, '@')) != NULL) {
+ /* preserve the current @domain */
+ value = t_strconcat(value, p, NULL);
+ } else if (strcmp(name, "domain") == 0) {
+ p = strchr(request->user, '@');
+ if (p == NULL) {
+ /* add the domain */
+ value = t_strconcat(request->user, "@",
+ value, NULL);
+ } else {
+ /* replace the existing domain */
+ p = t_strdup_until(request->user, p + 1);
+ value = t_strconcat(p, value, NULL);
+ }
+ }
+
if (strcmp(request->user, value) != 0) {
/* remember the original username for cache */
if (request->original_username == NULL) {
More information about the dovecot-cvs
mailing list