dovecot-2.2: auth: Return "nologin" and "proxy" fields to login ...

dovecot at dovecot.org dovecot at dovecot.org
Mon Mar 18 16:52:10 EET 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/d7d7cbcc2b67
changeset: 16033:d7d7cbcc2b67
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Mar 18 16:51:58 2013 +0200
description:
auth: Return "nologin" and "proxy" fields to login process without "=value".

diffstat:

 src/auth/auth-fields.c          |  11 +++++++++++
 src/auth/auth-fields.h          |   3 +++
 src/auth/auth-request-handler.c |   5 +++++
 3 files changed, 19 insertions(+), 0 deletions(-)

diffs (49 lines):

diff -r 1728871f6d21 -r d7d7cbcc2b67 src/auth/auth-fields.c
--- a/src/auth/auth-fields.c	Mon Mar 18 15:59:40 2013 +0200
+++ b/src/auth/auth-fields.c	Mon Mar 18 16:51:58 2013 +0200
@@ -175,6 +175,17 @@
 		array_count(&fields->fields) == 0;
 }
 
+void auth_fields_booleanize(struct auth_fields *fields, const char *key)
+{
+	struct auth_field *field;
+	unsigned int idx;
+
+	if (auth_fields_find_idx(fields, key, &idx)) {
+		field = array_idx_modifiable(&fields->fields, idx);
+		field->value = NULL;
+	}
+}
+
 void auth_fields_snapshot(struct auth_fields *fields)
 {
 	struct auth_field *field;
diff -r 1728871f6d21 -r d7d7cbcc2b67 src/auth/auth-fields.h
--- a/src/auth/auth-fields.h	Mon Mar 18 15:59:40 2013 +0200
+++ b/src/auth/auth-fields.h	Mon Mar 18 16:51:58 2013 +0200
@@ -34,6 +34,9 @@
 			enum auth_field_flags flags_mask,
 			enum auth_field_flags flags_result);
 bool auth_fields_is_empty(struct auth_fields *fields);
+/* If the field exists, clear its value (so the exported string will be "key"
+   instead of e.g. "key=y"). */
+void auth_fields_booleanize(struct auth_fields *fields, const char *key);
 
 /* Remember the current fields. */
 void auth_fields_snapshot(struct auth_fields *fields);
diff -r 1728871f6d21 -r d7d7cbcc2b67 src/auth/auth-request-handler.c
--- a/src/auth/auth-request-handler.c	Mon Mar 18 15:59:40 2013 +0200
+++ b/src/auth/auth-request-handler.c	Mon Mar 18 16:51:58 2013 +0200
@@ -244,6 +244,11 @@
 		auth_penalty_update(auth_penalty, request, 0);
 	}
 
+	/* sanitize these fields, since the login code currently assumes they
+	   are exactly in this format. */
+	auth_fields_booleanize(request->extra_fields, "nologin");
+	auth_fields_booleanize(request->extra_fields, "proxy");
+
 	str_printfa(str, "OK\t%u\tuser=", request->id);
 	str_append_tabescaped(str, request->user);
 	auth_str_append_extra_fields(request, str);


More information about the dovecot-cvs mailing list