* Split cmd_user() and cmd_pass() into frontend/backend functions
[citadel.git] / citadel / sysdep.c
index b5ad3bc4475e5163c144546c15460f5c51cd568e..63b89bebf4680dea07d76ec05fea4d80a0c64a47 100644 (file)
@@ -763,37 +763,16 @@ int main(int argc, char **argv)
        get_config();
 
        /*
-        * Bind the server to our favourite port.
-        */
-       CtdlRegisterServiceHook(config.c_port_number,
-                               citproto_begin_session,
-                               do_command_loop);
-
-       /*
-        * Now that we've bound the socket, change to the BBS user id and its
-        * corresponding group ids
+        * Do non system dependent startup functions.
         */
-       if (drop_root_perms) {
-               if ((pw = getpwuid(BBSUID)) == NULL)
-                       lprintf(1, "WARNING: getpwuid(%d): %s\n"
-                                  "Group IDs will be incorrect.\n", BBSUID,
-                               strerror(errno));
-               else {
-                       initgroups(pw->pw_name, pw->pw_gid);
-                       if (setgid(pw->pw_gid))
-                               lprintf(3, "setgid(%d): %s\n", pw->pw_gid,
-                                       strerror(errno));
-               }
-               lprintf(7, "Changing uid to %d\n", BBSUID);
-               if (setuid(BBSUID) != 0) {
-                       lprintf(3, "setuid() failed: %s\n", strerror(errno));
-               }
-       }
+       master_startup();
 
        /*
-        * Do non system dependent startup functions.
+        * Bind the server to our favorite ports.
         */
-       master_startup();
+       CtdlRegisterServiceHook(config.c_port_number,
+                               citproto_begin_session,
+                               do_command_loop);
 
        /*
         * Load any server-side modules (plugins) available here.
@@ -857,6 +836,27 @@ int main(int argc, char **argv)
        }
 
 
+       /*
+        * Now that we've bound the sockets, change to the BBS user id and its
+        * corresponding group ids
+        */
+       if (drop_root_perms) {
+               if ((pw = getpwuid(BBSUID)) == NULL)
+                       lprintf(1, "WARNING: getpwuid(%d): %s\n"
+                                  "Group IDs will be incorrect.\n", BBSUID,
+                               strerror(errno));
+               else {
+                       initgroups(pw->pw_name, pw->pw_gid);
+                       if (setgid(pw->pw_gid))
+                               lprintf(3, "setgid(%d): %s\n", pw->pw_gid,
+                                       strerror(errno));
+               }
+               lprintf(7, "Changing uid to %d\n", BBSUID);
+               if (setuid(BBSUID) != 0) {
+                       lprintf(3, "setuid() failed: %s\n", strerror(errno));
+               }
+       }
+
        /*
         * Now create a bunch of worker threads.
         */