From 4c784ba6a0328985908081a7f0991894960eaa2a Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Tue, 26 Dec 2017 21:52:12 -0500 Subject: [PATCH] Reordered the locking and setting of user email addresses to avoid a race condition right after an upgrade if a user logs in --- citadel/modules/upgrade/serv_upgrade.c | 9 +-------- citadel/user_ops.c | 6 +++--- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/citadel/modules/upgrade/serv_upgrade.c b/citadel/modules/upgrade/serv_upgrade.c index bc471dc1a..94c1406f4 100644 --- a/citadel/modules/upgrade/serv_upgrade.c +++ b/citadel/modules/upgrade/serv_upgrade.c @@ -490,16 +490,9 @@ void miafvtur_backend(struct ctdluser *usbuf, void *data) { } /* this is the calling mode where we do the processing */ - int i; - struct ctdluser u; - for (i=0; i = <%s>", m[i].name, m[i].emails); - if (CtdlGetUser(&u, m[i].name) == 0) { - safestrncpy(u.emailaddrs, m[i].emails, sizeof u.emailaddrs); - CtdlPutUser(&u); - } + CtdlSetEmailAddressesForUser(m[i].name, m[i].emails); } free(m); num_m = 0; diff --git a/citadel/user_ops.c b/citadel/user_ops.c index 31864a27b..32af98e91 100644 --- a/citadel/user_ops.c +++ b/citadel/user_ops.c @@ -644,6 +644,7 @@ void do_login(void) CCC->user.axlevel = AxAideU; } } + CtdlPutUserLock(&CCC->user); /* * If we are using LDAP authentication, extract the user's email addresses from the directory. @@ -660,13 +661,12 @@ void do_login(void) #endif /* - * No email address for user? Make one up. - */ + * No email address for user? Make one up. (commented out because it appears to break things) if (IsEmptyStr(CCC->user.emailaddrs)) { sprintf(CCC->user.emailaddrs, "cit%ld@%s", CCC->user.usernum, CtdlGetConfigStr("c_fqdn")); } + */ - CtdlPutUserLock(&CCC->user); /* * Populate cs_inet_email and cs_inet_other_emails with valid email addresses from the user record -- 2.30.2