dovecot-2.2: auth: If passdb/userdb has a name, use it for the l...

dovecot at dovecot.org dovecot at dovecot.org
Thu Apr 17 12:26:09 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/917946c08f83
changeset: 17236:917946c08f83
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Apr 17 14:24:18 2014 +0200
description:
auth: If passdb/userdb has a name, use it for the log prefix instead of the driver name.

diffstat:

 src/auth/auth-request.c  |  13 +++++++++----
 src/auth/auth-settings.c |   8 ++++++--
 src/auth/auth-settings.h |   2 ++
 src/auth/auth.c          |   1 +
 4 files changed, 18 insertions(+), 6 deletions(-)

diffs (106 lines):

diff -r 9b095cec9332 -r 917946c08f83 src/auth/auth-request.c
--- a/src/auth/auth-request.c	Thu Apr 17 14:21:55 2014 +0200
+++ b/src/auth/auth-request.c	Thu Apr 17 14:24:18 2014 +0200
@@ -2139,10 +2139,15 @@
 	const char *ip, *name;
 
 	if (subsystem == AUTH_SUBSYS_DB) {
-		if (!auth_request->userdb_lookup)
-			name = auth_request->passdb->passdb->iface.name;
-		else
-			name = auth_request->userdb->userdb->iface->name;
+		if (!auth_request->userdb_lookup) {
+			name = auth_request->passdb->set->name[0] != '\0' ?
+				auth_request->passdb->set->name :
+				auth_request->passdb->passdb->iface.name;
+		} else {
+			name = auth_request->userdb->set->name[0] != '\0' ?
+				auth_request->userdb->set->name :
+				auth_request->userdb->userdb->iface->name;
+		}
 	} else if (subsystem == AUTH_SUBSYS_MECH) {
 		name = t_str_lcase(auth_request->mech->mech_name);
 	} else {
diff -r 9b095cec9332 -r 917946c08f83 src/auth/auth-settings.c
--- a/src/auth/auth-settings.c	Thu Apr 17 14:21:55 2014 +0200
+++ b/src/auth/auth-settings.c	Thu Apr 17 14:24:18 2014 +0200
@@ -107,6 +107,7 @@
 	{ type, #name, offsetof(struct auth_passdb_settings, name), NULL }
 
 static const struct setting_define auth_passdb_setting_defines[] = {
+	DEF(SET_STR, name),
 	DEF(SET_STR, driver),
 	DEF(SET_STR, args),
 	DEF(SET_STR, default_fields),
@@ -125,6 +126,7 @@
 };
 
 static const struct auth_passdb_settings auth_passdb_default_settings = {
+	.name = "",
 	.driver = "",
 	.args = "",
 	.default_fields = "",
@@ -144,7 +146,7 @@
 	.defines = auth_passdb_setting_defines,
 	.defaults = &auth_passdb_default_settings,
 
-	.type_offset = (size_t)-1,
+	.type_offset = offsetof(struct auth_passdb_settings, name),
 	.struct_size = sizeof(struct auth_passdb_settings),
 
 	.parent_offset = (size_t)-1,
@@ -158,6 +160,7 @@
 	{ type, #name, offsetof(struct auth_userdb_settings, name), NULL }
 
 static const struct setting_define auth_userdb_setting_defines[] = {
+	DEF(SET_STR, name),
 	DEF(SET_STR, driver),
 	DEF(SET_STR, args),
 	DEF(SET_STR, default_fields),
@@ -173,6 +176,7 @@
 
 static const struct auth_userdb_settings auth_userdb_default_settings = {
 	/* NOTE: when adding fields, update also auth.c:userdb_dummy_set */
+	.name = "",
 	.driver = "",
 	.args = "",
 	.default_fields = "",
@@ -188,7 +192,7 @@
 	.defines = auth_userdb_setting_defines,
 	.defaults = &auth_userdb_default_settings,
 
-	.type_offset = (size_t)-1,
+	.type_offset = offsetof(struct auth_userdb_settings, name),
 	.struct_size = sizeof(struct auth_userdb_settings),
 
 	.parent_offset = (size_t)-1,
diff -r 9b095cec9332 -r 917946c08f83 src/auth/auth-settings.h
--- a/src/auth/auth-settings.h	Thu Apr 17 14:21:55 2014 +0200
+++ b/src/auth/auth-settings.h	Thu Apr 17 14:24:18 2014 +0200
@@ -5,6 +5,7 @@
 struct master_service_settings_output;
 
 struct auth_passdb_settings {
+	const char *name;
 	const char *driver;
 	const char *args;
 	const char *default_fields;
@@ -20,6 +21,7 @@
 };
 
 struct auth_userdb_settings {
+	const char *name;
 	const char *driver;
 	const char *args;
 	const char *default_fields;
diff -r 9b095cec9332 -r 917946c08f83 src/auth/auth.c
--- a/src/auth/auth.c	Thu Apr 17 14:21:55 2014 +0200
+++ b/src/auth/auth.c	Thu Apr 17 14:24:18 2014 +0200
@@ -10,6 +10,7 @@
 #include "auth.h"
 
 struct auth_userdb_settings userdb_dummy_set = {
+	.name = "",
 	.driver = "static",
 	.args = "",
 	.default_fields = "",


More information about the dovecot-cvs mailing list