dovecot-2.2: doveadm user -m: Show all returned userdb fields.

dovecot at dovecot.org dovecot at dovecot.org
Mon Oct 29 20:09:54 EET 2012


details:   http://hg.dovecot.org/dovecot-2.2/rev/55422e122c27
changeset: 15344:55422e122c27
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Oct 29 20:07:13 2012 +0200
description:
doveadm user -m: Show all returned userdb fields.

diffstat:

 src/doveadm/doveadm-auth.c |  30 ++++++++++++++++++++++++++++--
 1 files changed, 28 insertions(+), 2 deletions(-)

diffs (59 lines):

diff -r fec539656811 -r 55422e122c27 src/doveadm/doveadm-auth.c
--- a/src/doveadm/doveadm-auth.c	Mon Oct 29 20:06:53 2012 +0200
+++ b/src/doveadm/doveadm-auth.c	Mon Oct 29 20:07:13 2012 +0200
@@ -303,7 +303,9 @@
 	struct mail_storage_service_user *service_user;
 	struct mail_user *user;
 	const struct mail_storage_settings *mail_set;
-	const char *error;
+	const char *key, *value, *error, *const *userdb_fields;
+	unsigned int i;
+	pool_t pool;
 	int ret;
 
 	memset(&service_input, 0, sizeof(service_input));
@@ -315,10 +317,16 @@
 	service_input.remote_ip = input->info.remote_ip;
 	service_input.remote_port = input->info.remote_port;
 
+	pool = pool_alloconly_create("userdb fields", 1024);
+	mail_storage_service_save_userdb_fields(storage_service, pool,
+						&userdb_fields);
+
 	if ((ret = mail_storage_service_lookup_next(storage_service, &service_input,
 						    &service_user, &user,
-						    &error)) <= 0)
+						    &error)) <= 0) {
+		pool_unref(&pool);
 		return ret == 0 ? 0 : -1;
+	}
 
 	if (show_field == NULL) {
 		doveadm_print_init(DOVEADM_PRINT_TYPE_TAB);
@@ -333,8 +341,26 @@
 	mail_set = mail_user_set_get_storage_set(user);
 	cmd_user_mail_input_field("mail", mail_set->mail_location, show_field);
 
+	if (userdb_fields != NULL) {
+		for (i = 0; userdb_fields[i] != NULL; i++) {
+			value = strchr(userdb_fields[i], '=');
+			if (value != NULL)
+				key = t_strdup_until(userdb_fields[i], value++);
+			else {
+				key = userdb_fields[i];
+				value = "";
+			}
+			if (strcmp(key, "uid") != 0 &&
+			    strcmp(key, "gid") != 0 &&
+			    strcmp(key, "home") != 0 &&
+			    strcmp(key, "mail") != 0)
+				cmd_user_mail_input_field(key, value, show_field);
+		}
+	}
+
 	mail_user_unref(&user);
 	mail_storage_service_user_free(&service_user);
+	pool_unref(&pool);
 	return 1;
 }
 


More information about the dovecot-cvs mailing list