* CC->cs_inet_email is now a string buffer, not a pointer
authorArt Cancro <ajc@citadel.org>
Fri, 29 Nov 2002 15:44:41 +0000 (15:44 +0000)
committerArt Cancro <ajc@citadel.org>
Fri, 29 Nov 2002 15:44:41 +0000 (15:44 +0000)
* Initialize CC->cs_inet_email with a default address, so it always
  contains something even when the directory doesn't
* Augment CHEK command to return the user's preferred Internet e-mail addr.

citadel/ChangeLog
citadel/msgbase.c
citadel/serv_vcard.c
citadel/server.h
citadel/techdoc/session.txt
citadel/user_ops.c

index c758001b1f2f849268c6a962977f1813e2edb54d..22931584b5f8594e94942948465c02efaafff544 100644 (file)
@@ -1,4 +1,10 @@
  $Log$
+ Revision 601.74  2002/11/29 15:44:41  ajc
+ * CC->cs_inet_email is now a string buffer, not a pointer
+ * Initialize CC->cs_inet_email with a default address, so it always
+   contains something even when the directory doesn't
+ * Augment CHEK command to return the user's preferred Internet e-mail addr.
+
  Revision 601.73  2002/11/27 21:05:31  nixo
  added dot ungoto functionality.
  It allows you to enter a room to ungoto, it will look
@@ -4242,4 +4248,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
-
index c13f744074f12d58fe3471f15abf4d5c754d70aa..c78d7e345e23155c6466edb1a56d31d4eb77d29c 100644 (file)
@@ -2302,7 +2302,7 @@ struct CtdlMessage *CtdlMakeMessage(
                msg->cm_fields['D'] = strdoop(dest_node);
        }
 
-       if ( (author == &CC->usersupp) && (CC->cs_inet_email != NULL) ) {
+       if ( (author == &CC->usersupp) && (strlen(CC->cs_inet_email) > 0) ) {
                msg->cm_fields['F'] = strdoop(CC->cs_inet_email);
        }
 
index 11ec58d3bf9f6de99b719ba6c3fa6d776ca17d1c..4c30c1fbf01303b789176936fdf68fb481fcae9b 100644 (file)
@@ -204,14 +204,6 @@ void vcard_populate_cs_inet_email(struct vCard *v) {
        int continue_searching = 1;
        int instance = 0;
 
-       /* 
-        * Clear whatever was in there previously.
-        */
-       if (CC->cs_inet_email != NULL) {
-               phree(CC->cs_inet_email);
-               CC->cs_inet_email = NULL;
-       }
-
        /* Go through the vCard searching for *all* instances of
         * the "email;internet" key
         */
@@ -224,7 +216,10 @@ void vcard_populate_cs_inet_email(struct vCard *v) {
                        if (strlen(addr) > 0) {
                                if (IsDirectory(addr)) {
                                        continue_searching = 0;
-                                       CC->cs_inet_email = strdoop(addr);
+                                       safestrncpy(CC->cs_inet_email,
+                                               addr,
+                                               sizeof(CC->cs_inet_email)
+                                       );
                                }
                        }
                        phree(addr);
@@ -775,23 +770,12 @@ void vcard_session_login_hook(void) {
 }
 
 
-/*
- * When a user logs out...
- */
-void vcard_session_logout_hook(void) {
-       if (CC->cs_inet_email != NULL) {
-               phree(CC->cs_inet_email);
-               CC->cs_inet_email = NULL;
-       }
-}
-
 
 char *Dynamic_Module_Init(void)
 {
        SYM_VCARD = CtdlGetDynamicSymbol();
        CtdlRegisterSessionHook(vcard_session_startup_hook, EVT_START);
        CtdlRegisterSessionHook(vcard_session_login_hook, EVT_LOGIN);
-       CtdlRegisterSessionHook(vcard_session_logout_hook, EVT_LOGOUT);
        CtdlRegisterMessageHook(vcard_upload_beforesave, EVT_BEFORESAVE);
        CtdlRegisterMessageHook(vcard_upload_aftersave, EVT_AFTERSAVE);
        CtdlRegisterDeleteHook(vcard_delete_remove);
index 5cbcabbb93f25318dacdbe2244059d2d9a43ea26..a685c7fb5ea69720ada425f8c09feae8a768c3a1 100644 (file)
@@ -112,7 +112,7 @@ struct CitContext {
        char cs_host[64];       /* host logged in from */
 
        /* The Internet type of thing */
-       char *cs_inet_email;    /* Return address of outbound Internet mail */
+       char cs_inet_email[SIZ];/* Return address of outbound Internet mail */
 
        FILE *download_fp;      /* Fields relating to file transfer */
        FILE *upload_fp;
index 94a82bb973a207009ca83fbe55a3d7d74efb5c6a..35e3b04841799063f08d6ff6749a71fe9feb7381 100644 (file)
@@ -1043,6 +1043,7 @@ it returns OK and the following parameters:
  0: Number of new private messages in Mail>
  1: Nonzero if the user needs to register
  2: (Relevant to Aides only) Nonzero if new users require validation
+ 3: The user's preferred Internet e-mail address
  
  
  DELF   (DELete a File)
index 534a0102d9996eb9ea1b9e0887d85b524f76c4f9..0dfad787acdb54b5d2be2e8ee810b10ba367b700 100644 (file)
@@ -17,6 +17,7 @@
 #include <fcntl.h>
 #include <signal.h>
 #include <pwd.h>
+#include <ctype.h>
 #include <sys/types.h>
 #include <sys/wait.h>
 
@@ -388,6 +389,8 @@ void cmd_user(char *cmdbuf)
  */
 void session_startup(void)
 {
+       int i;
+
        syslog(LOG_NOTICE, "session %d: user <%s> logged in",
               CC->cs_pid, CC->curr_user);
 
@@ -403,6 +406,19 @@ void session_startup(void)
        }
        lputuser(&CC->usersupp);
 
+       /*
+        * Populate CC->cs_inet_email with a default address.  This will be
+        * overwritten with the user's directory address, if one exists, when
+        * the vCard module's login hook runs.
+        */
+       snprintf(CC->cs_inet_email, sizeof CC->cs_inet_email, "%s@%s",
+               CC->usersupp.fullname, config.c_fqdn);
+       for (i=0; i<strlen(CC->cs_inet_email); ++i) {
+               if (isspace(CC->cs_inet_email[i])) {
+                       CC->cs_inet_email[i] = '_';
+               }
+       }
+
        /* Create any personal rooms required by the system.
         * (Technically, MAILROOM should be there already, but just in case...)
         */
@@ -460,14 +476,6 @@ void logout(struct CitContext *who)
                network_talking_to(who->net_node, NTT_REMOVE);
        }
 
-       /*
-        * Yes, we really need to free EVERY LAST BYTE we allocated.
-        */
-       if (who->cs_inet_email != NULL) {
-               phree(who->cs_inet_email);
-               who->cs_inet_email = NULL;
-       }
-
        /* Do modular stuff... */
        PerformSessionHooks(EVT_LOGOUT);
 }
@@ -1287,7 +1295,7 @@ void cmd_chek(void)
        /* check for mail */
        mail = InitialMailCheck();
 
-       cprintf("%d %d|%d|%d\n", CIT_OK, mail, regis, vali);
+       cprintf("%d %d|%d|%d|%s|\n", CIT_OK, mail, regis, vali, CC->cs_inet_email);
 }