]> code.citadel.org Git - citadel.git/blobdiff - citadel/user_ops.c
* Renamed "dynloader" to "serv_extensions" globally. We don't want people
[citadel.git] / citadel / user_ops.c
index 9b809fdf664a07728c3b8cac5ba7c0e65ade9b74..5e8acacd082a6f5280318ae75bee55877fe73de1 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>
 
@@ -41,7 +42,7 @@
 #include "server.h"
 #include "database.h"
 #include "user_ops.h"
-#include "dynloader.h"
+#include "serv_extensions.h"
 #include "sysdep_decls.h"
 #include "support.h"
 #include "room_ops.h"
@@ -61,7 +62,7 @@
 int getuser(struct usersupp *usbuf, char name[])
 {
 
-       char lowercase_name[32];
+       char lowercase_name[USERNAME_SIZE];
        int a;
        struct cdbdata *cdbus;
 
@@ -105,7 +106,7 @@ int lgetuser(struct usersupp *usbuf, char *name)
  */
 void putuser(struct usersupp *usbuf)
 {
-       char lowercase_name[32];
+       char lowercase_name[USERNAME_SIZE];
        int a;
 
        for (a = 0; a <= strlen(usbuf->fullname); ++a) {
@@ -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,8 +406,18 @@ void session_startup(void)
        }
        lputuser(&CC->usersupp);
 
-       /* Run any startup routines registered by loadable modules */
-       PerformSessionHooks(EVT_LOGIN);
+       /*
+        * 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...)
@@ -412,6 +425,9 @@ void session_startup(void)
        create_room(MAILROOM, 4, "", 0, 1, 0);
        create_room(SENTITEMS, 4, "", 0, 1, 0);
 
+       /* Run any startup routines registered by loadable modules */
+       PerformSessionHooks(EVT_LOGIN);
+
        /* Enter the lobby */
        usergoto(config.c_baseroom, 0, 0, NULL, NULL);
 
@@ -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);
 }
@@ -621,7 +629,7 @@ int purge_user(char pname[])
 {
        char filename[64];
        struct usersupp usbuf;
-       char lowercase_name[32];
+       char lowercase_name[USERNAME_SIZE];
        int a;
        struct CitContext *ccptr;
        int user_is_logged_in = 0;
@@ -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);
 }
 
 
@@ -1345,6 +1353,7 @@ void cmd_asup(char *cmdbuf)
 {
        struct usersupp usbuf;
        char requested_user[SIZ];
+       char notify[SIZ];
        int np;
        int newax;
        int deleted = 0;
@@ -1384,6 +1393,13 @@ void cmd_asup(char *cmdbuf)
                        deleted = 1;
                }
        }
+
+       if (deleted) {
+               sprintf(notify, "User <%s> deleted by %s\n",
+                       usbuf.fullname, CC->usersupp.fullname);
+               aide_message(notify);
+       }
+
        cprintf("%d Ok", CIT_OK);
        if (deleted)
                cprintf(" (%s deleted)", requested_user);