dovecot-2.2: lib-storage: Added mail_user_dup()

dovecot at dovecot.org dovecot at dovecot.org
Mon Sep 15 21:22:12 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/9c673534ae93
changeset: 17804:9c673534ae93
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Sep 16 00:21:13 2014 +0300
description:
lib-storage: Added mail_user_dup()

diffstat:

 src/lib-storage/mail-storage-service.c |   2 ++
 src/lib-storage/mail-user.c            |  20 ++++++++++++++++++++
 src/lib-storage/mail-user.h            |   4 ++++
 3 files changed, 26 insertions(+), 0 deletions(-)

diffs (53 lines):

diff -r 59b920848699 -r 9c673534ae93 src/lib-storage/mail-storage-service.c
--- a/src/lib-storage/mail-storage-service.c	Tue Sep 16 00:01:33 2014 +0300
+++ b/src/lib-storage/mail-storage-service.c	Tue Sep 16 00:21:13 2014 +0300
@@ -633,6 +633,8 @@
 	const char *home = priv->home;
 	struct mail_user *mail_user;
 
+	/* NOTE: if more user initialization is added, add it also to
+	   mail_user_dup() */
 	mail_user = mail_user_alloc(user->input.username, user->user_info,
 				    user->user_set);
 	mail_user_set_home(mail_user, *home == '\0' ? NULL : home);
diff -r 59b920848699 -r 9c673534ae93 src/lib-storage/mail-user.c
--- a/src/lib-storage/mail-user.c	Tue Sep 16 00:01:33 2014 +0300
+++ b/src/lib-storage/mail-user.c	Tue Sep 16 00:21:13 2014 +0300
@@ -514,3 +514,23 @@
 	}
 	return storage;
 }
+
+struct mail_user *mail_user_dup(struct mail_user *user)
+{
+	struct mail_user *user2;
+
+	user2 = mail_user_alloc(user->username, user->set_info,
+				user->unexpanded_set);
+	if (user->_home != NULL)
+		mail_user_set_home(user2, user->_home);
+	mail_user_set_vars(user2, user->service,
+			   user->local_ip, user->remote_ip);
+	user2->uid = user->uid;
+	user2->gid = user->gid;
+	user2->anonymous = user->anonymous;
+	user2->admin = user->admin;
+	user2->auth_token = p_strdup(user2->pool, user->auth_token);
+	user2->auth_user = p_strdup(user2->pool, user->auth_user);
+	user2->session_id = p_strdup(user2->pool, user->session_id);
+	return user2;
+}
diff -r 59b920848699 -r 9c673534ae93 src/lib-storage/mail-user.h
--- a/src/lib-storage/mail-user.h	Tue Sep 16 00:01:33 2014 +0300
+++ b/src/lib-storage/mail-user.h	Tue Sep 16 00:21:13 2014 +0300
@@ -95,6 +95,10 @@
 void mail_user_ref(struct mail_user *user);
 void mail_user_unref(struct mail_user **user);
 
+/* Duplicate a mail_user. mail_user_init() and mail_namespaces_init() need to
+   be called before the user is usable. */
+struct mail_user *mail_user_dup(struct mail_user *user);
+
 /* Find another user from the given user's namespaces. */
 struct mail_user *mail_user_find(struct mail_user *user, const char *name);
 


More information about the dovecot-cvs mailing list