dovecot-2.2: *-login: Added %{passdb:*} fields to login_log_form...

dovecot at dovecot.org dovecot at dovecot.org
Fri Aug 28 12:44:30 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/170f2b9f4977
changeset: 19029:170f2b9f4977
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Aug 28 14:43:35 2015 +0200
description:
*-login: Added %{passdb:*} fields to login_log_format_elements

diffstat:

 src/login-common/client-common.c |  29 +++++++++++++++++++++++++++--
 src/login-common/client-common.h |   1 +
 src/login-common/sasl-server.c   |   1 +
 3 files changed, 29 insertions(+), 2 deletions(-)

diffs (74 lines):

diff -r 17220b7e1378 -r 170f2b9f4977 src/login-common/client-common.c
--- a/src/login-common/client-common.c	Thu Aug 27 18:39:58 2015 +0200
+++ b/src/login-common/client-common.c	Fri Aug 28 14:43:35 2015 +0200
@@ -587,13 +587,37 @@
 }
 
 static const char *
+client_var_expand_func_passdb(const char *data, void *context)
+{
+	struct client *client = context;
+	const char *field_name = data;
+	unsigned int i, field_name_len;
+
+	if (client->auth_passdb_args == NULL)
+		return NULL;
+
+	field_name_len = strlen(field_name);
+	for (i = 0; client->auth_passdb_args[i] != NULL; i++) {
+		if (strncmp(client->auth_passdb_args[i], field_name,
+			    field_name_len) == 0 &&
+		    client->auth_passdb_args[i][field_name_len] == '=')
+			return client->auth_passdb_args[i] + field_name_len+1;
+	}
+	return NULL;
+}
+
+static const char *
 client_get_log_str(struct client *client, const char *msg)
 {
-	static struct var_expand_table static_tab[3] = {
+	static const struct var_expand_table static_tab[3] = {
 		{ 's', NULL, NULL },
 		{ '$', NULL, NULL },
 		{ '\0', NULL, NULL }
 	};
+	static const struct var_expand_func_table func_table[] = {
+		{ "passdb", client_var_expand_func_passdb },
+		{ NULL, NULL }
+	};
 	const struct var_expand_table *var_expand_table;
 	struct var_expand_table *tab;
 	char *const *e;
@@ -609,7 +633,8 @@
 	str2 = t_str_new(128);
 	for (e = client->set->log_format_elements_split; *e != NULL; e++) {
 		pos = str_len(str);
-		var_expand(str, *e, var_expand_table);
+		var_expand_with_funcs(str, *e, var_expand_table,
+				      func_table, client);
 		if (have_username_key(*e)) {
 			/* username is added even if it's empty */
 		} else {
diff -r 17220b7e1378 -r 170f2b9f4977 src/login-common/client-common.h
--- a/src/login-common/client-common.h	Thu Aug 27 18:39:58 2015 +0200
+++ b/src/login-common/client-common.h	Fri Aug 28 14:43:35 2015 +0200
@@ -137,6 +137,7 @@
 	string_t *auth_response;
 	time_t auth_first_started, auth_finished;
 	const char *sasl_final_resp;
+	const char *const *auth_passdb_args;
 
 	unsigned int master_auth_id;
 	unsigned int master_tag;
diff -r 17220b7e1378 -r 170f2b9f4977 src/login-common/sasl-server.c
--- a/src/login-common/sasl-server.c	Thu Aug 27 18:39:58 2015 +0200
+++ b/src/login-common/sasl-server.c	Fri Aug 28 14:43:35 2015 +0200
@@ -234,6 +234,7 @@
 	case AUTH_REQUEST_STATUS_OK:
 		client->auth_request = NULL;
 		client->auth_successes++;
+		client->auth_passdb_args = p_strarray_dup(client->pool, args);
 
 		nologin = FALSE;
 		for (i = 0; args[i] != NULL; i++) {


More information about the dovecot-cvs mailing list