Give the user contained within masterCC a name.
authorDave West <davew@uncensored.citadel.org>
Sun, 6 Apr 2008 21:14:34 +0000 (21:14 +0000)
committerDave West <davew@uncensored.citadel.org>
Sun, 6 Apr 2008 21:14:34 +0000 (21:14 +0000)
Its not a real user but it is stored in the DB and does contain info
like how many messages the system has created.
We call it Citadel.
This make "citadel" an illegal user name.
Now this user has a name we need to make sure the auto purger doesn't
purge it and make sure no one can login by that name.

citadel/modules/expire/serv_expire.c
citadel/server_main.c
citadel/sysdep.c
citadel/user_ops.c

index 33d9508e43d009f2b933610746d2444cf71c8ea5..ac5debf2ce388456e7ade160810d915834681ce5 100644 (file)
@@ -445,6 +445,9 @@ void do_user_purge(struct ctdluser *us, void *data) {
         */
        if (us->usernum < 0L) purge = 1;
        
+       /** Don't purge user 0. That user is there for the system */
+       if (us->usernum == 0) purge = 0;
+       
        /* If the user has no full name entry then we can't purge them
         * since the actual purge can't find them.
         * This shouldn't happen but does somehow.
index 4bf86ee85868610646b1871687344da29dd8b67c..37c77ddcd4fa8068ba0b16436d089f3d5d21900d 100644 (file)
@@ -71,6 +71,9 @@ const char *CitadelServiceUDS="citadel-UDS";
 const char *CitadelServiceTCP="citadel-TCP";
 
 
+extern struct CitContext masterCC;
+
+
 void go_threading(void);
 
 /*
@@ -244,6 +247,20 @@ int main(int argc, char **argv)
        CtdlLogPrintf(CTDL_INFO, "Acquiring control record\n");
        get_control();
 
+       
+/**
+ * Initialise the user 0 to have a name. It would be nice to do it in InitializeMasterCC
+ * since it is contained within the MasterCC but we can't because the DB isn't available
+ * at that time so we do it seperate.
+ */
+       /** Give user 0 a name and create them if necessary */
+       if (getuser(&masterCC.user, "Citadel"))
+       {
+               getuserbynumber(&masterCC.user, 0);
+               strcpy (masterCC.user.fullname, "Citadel");
+               putuser(&masterCC.user);
+       }
+       
        /*
         * Bind the server to a Unix-domain socket.
         */
index d634c5496a01a21dfac30edc6be95564ef9fd9ef..265f879e7838eff771687237610a320512a7b961 100644 (file)
@@ -1051,8 +1051,6 @@ void InitializeMasterCC(void) {
 
 
 
-
-
 /*
  * Bind a thread to a context.  (It's inline merely to speed things up.)
  */
index e7331e8d246f3f2ff5668202ffbde190ece92a57..e376c9d32d0ab4de22d6c5daf855ed74d0026926 100644 (file)
@@ -187,12 +187,17 @@ int rename_user(char *oldname, char *newname) {
                }
 
                else {          /* Sanity checks succeeded.  Now rename the user. */
-
-                       CtdlLogPrintf(CTDL_DEBUG, "Renaming <%s> to <%s>\n", oldname, newname);
-                       cdb_delete(CDB_USERS, oldnamekey, strlen(oldnamekey));
-                       safestrncpy(usbuf.fullname, newname, sizeof usbuf.fullname);
-                       putuser(&usbuf);
-                       retcode = RENAMEUSER_OK;
+                       if (usbuf.usernum == 0)
+                       {
+                               CtdlLogPrintf (CTDL_DEBUG, "Can not rename user \"Citadel\".\n");
+                               retcode = RENAMEUSER_NOT_FOUND;
+                       } else {
+                               CtdlLogPrintf(CTDL_DEBUG, "Renaming <%s> to <%s>\n", oldname, newname);
+                               cdb_delete(CDB_USERS, oldnamekey, strlen(oldnamekey));
+                               safestrncpy(usbuf.fullname, newname, sizeof usbuf.fullname);
+                               putuser(&usbuf);
+                               retcode = RENAMEUSER_OK;
+                       }
                }
        
        }
@@ -421,6 +426,12 @@ int CtdlLoginExistingUser(char *authname, char *trythisname)
        }
 
        if (trythisname == NULL) return login_not_found;
+       
+       if (!strcasecmp(trythisname, "Citadel"))
+       {
+               CtdlLogPrintf(CTDL_DEBUG, "System user \"Citadel\" is not allowed to log in.\n");
+               return login_not_found;
+       }
 
        /* If a "master user" is defined, handle its authentication if specified */
        CC->is_master = 0;