Reordered the locking and setting of user email addresses to avoid a race condition...
authorArt Cancro <ajc@citadel.org>
Wed, 27 Dec 2017 02:52:12 +0000 (21:52 -0500)
committerArt Cancro <ajc@citadel.org>
Wed, 27 Dec 2017 02:52:12 +0000 (21:52 -0500)
citadel/modules/upgrade/serv_upgrade.c
citadel/user_ops.c

index bc471dc1af349b9c28e51296b44038f66a5e985b..94c1406f49c5f08fdcf046ba04db7b385f5ad255 100644 (file)
@@ -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<num_m; ++i) {
-               syslog(LOG_DEBUG, "<%s> = <%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;
index 31864a27bdd336e86ffc36ef1168be98301de5c7..32af98e9105ec3cc5a1c230aac8631fd70f73891 100644 (file)
@@ -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