]> code.citadel.org Git - citadel.git/blobdiff - citadel/user_ops.c
The user principal identity is now used as the JID in all XMPP protocol stanzas.
[citadel.git] / citadel / user_ops.c
index 9a39b06b6754b7b4c940fbd0e06acf0959476411..0507fc6baca99c4132d008d1f7f32bf91414addb 100644 (file)
@@ -697,6 +697,12 @@ void do_login(void)
                AutoGenerateEmailAddressForUser(&CC->user);
        }
 
+       /* Populate the user principal identity, which is consistent and never aliased */
+       strcpy(CC->cs_principal_id, "wowowowow");
+       makeuserkey(CC->cs_principal_id, CC->user.fullname, sizeof CC->user.fullname);
+       strcat(CC->cs_principal_id, "@");
+       strcat(CC->cs_principal_id, CtdlGetConfigStr("c_fqdn"));
+
        /*
         * Populate cs_inet_email and cs_inet_other_emails with valid email addresses from the user record
         */
@@ -1202,32 +1208,39 @@ void ForEachUser(void (*CallBack) (char *, void *out_data), void *in_data)
                struct feu *next;
                char username[USERNAME_SIZE];
        };
-       struct feu *usernames = NULL;
+       struct feu *ufirst = NULL;
+       struct feu *ulast = NULL;
        struct feu *f = NULL;
 
        cdb_rewind(CDB_USERS);
 
-       // Phase 1 : load list of usernames
+       // Phase 1 : build a linked list of all our user account names
        while (cdbus = cdb_next_item(CDB_USERS), cdbus != NULL) {
                usptr = (struct ctdluser *) cdbus->ptr;
 
                if (strlen(usptr->fullname) > 0) {
                        f = malloc(sizeof(struct feu));
-                       f->next = usernames;
+                       f->next = NULL;
                        strncpy(f->username, usptr->fullname, USERNAME_SIZE);
-                       usernames = f;
+
+                       if (ufirst == NULL) {
+                               ufirst = f;
+                               ulast = f;
+                       }
+                       else {
+                               ulast->next = f;
+                               ulast = f;
+                       }
                }
        }
 
-       // Phase 2 : perform the callback for each username
-       while (usernames != NULL) {
-               (*CallBack) (usernames->username, in_data);
-               f = usernames;
-               usernames = usernames->next;
+       // Phase 2 : perform the callback for each user while de-allocating the list
+       while (ufirst != NULL) {
+               (*CallBack) (ufirst->username, in_data);
+               f = ufirst;
+               ufirst = ufirst->next;
                free(f);
        }
-
-       free(usernames);
 }