Converted user_ops.o to new config format
authorArt Cancro <ajc@uncensored.citadel.org>
Wed, 29 Apr 2015 14:56:43 +0000 (10:56 -0400)
committerArt Cancro <ajc@uncensored.citadel.org>
Wed, 29 Apr 2015 14:56:43 +0000 (10:56 -0400)
citadel/event_client.c
citadel/server_main.c
citadel/user_ops.c

index 999c9e4546c1b989efc6fb93c6f6ab8df8394b8f..d47333e3c22dd11c23ae9dbb163d70b3e04df4e2 100644 (file)
@@ -27,6 +27,7 @@
 #include "ctdl_module.h"
 #include "event_client.h"
 #include "citserver.h"
+#include "config.h"
 
 ConstStr IOStates[] = {
        {HKEY("DB Queue")},
@@ -1059,8 +1060,8 @@ eNextState EvConnectSock(AsyncIO *IO,
        
                memset(&egress_sin, 0, sizeof(egress_sin));
                egress_sin.sin_family = AF_INET;
-               if (!IsEmptyStr(config.c_ip_addr)) {
-                       egress_sin.sin_addr.s_addr = inet_addr(config.c_ip_addr);
+               if (!IsEmptyStr(CtdlGetConfigStr("c_ip_addr"))) {
+                       egress_sin.sin_addr.s_addr = inet_addr(CtdlGetConfigStr("c_ip_addr"));
                        if (egress_sin.sin_addr.s_addr == !INADDR_ANY) {
                                egress_sin.sin_addr.s_addr = INADDR_ANY;
                        }
index bcb55cb7044bcedb40ed1f6faec2420f6a4ad55a..a8e272978d4f2904fa8f4447513b0bbc0618cc69 100644 (file)
@@ -284,7 +284,7 @@ int main(int argc, char **argv)
        /*
         * Bind the server to our favorite TCP port (usually 504).
         */
-       CtdlRegisterServiceHook(config.c_port_number,
+       CtdlRegisterServiceHook(CtdlGetConfigInt("c_port_number"),
                                NULL,
                                citproto_begin_session,
                                do_command_loop,
@@ -307,7 +307,7 @@ int main(int argc, char **argv)
        /*
         * If we need host auth, start our chkpwd daemon.
         */
-       if (config.c_auth_mode == AUTHMODE_HOST) {
+       if (CtdlGetConfigInt("c_auth_mode") == AUTHMODE_HOST) {
                start_chkpwd_daemon();
        }
 
index a8004ed0f6070a3e3febd79476195c4aa03bfc00..4ae077862c857a8e0ef58770a017bacc205de25b 100644 (file)
@@ -19,6 +19,7 @@
 #include "control.h"
 #include "support.h"
 #include "citserver.h"
+#include "config.h"
 #include "citadel_ldap.h"
 #include "ctdl_module.h"
 #include "user_ops.h"
@@ -314,7 +315,7 @@ int CtdlCheckInternetMailPermission(struct ctdluser *who) {
        if (who->axlevel <= AxProbU) return(0);
 
        /* Globally enabled? */
-       if (config.c_restrict == 0) return(1);
+       if (CtdlGetConfigInt("c_restrict") == 0) return(1);
 
        /* User flagged ok? */
        if (who->flags & US_INTERNET) return(2);
@@ -338,7 +339,7 @@ int CtdlAccessCheck(int required_level)
                return(-1);
        }
 
-       if ((required_level >= ac_logged_in_or_guest) && (CC->logged_in == 0) && (!config.c_guest_logins)) {
+       if ((required_level >= ac_logged_in_or_guest) && (CC->logged_in == 0) && (CtdlGetConfigInt("c_guest_logins") == 0)) {
                cprintf("%d Not logged in.\n", ERROR + NOT_LOGGED_IN);
                return(-1);
        }
@@ -528,10 +529,10 @@ int CtdlLoginExistingUser(char *authname, const char *trythisname)
 
        /* If a "master user" is defined, handle its authentication if specified */
        CC->is_master = 0;
-       if (    (strlen(config.c_master_user) > 0) && 
-               (strlen(config.c_master_pass) > 0) &&
+       if (    (strlen(CtdlGetConfigStr("c_master_user")) > 0) && 
+               (strlen(CtdlGetConfigStr("c_master_pass")) > 0) &&
                (authname != NULL) &&
-               (!strcasecmp(authname, config.c_master_user)) )
+               (!strcasecmp(authname, CtdlGetConfigStr("c_master_user"))) )
        {
                CC->is_master = 1;
        }
@@ -545,7 +546,7 @@ int CtdlLoginExistingUser(char *authname, const char *trythisname)
                return login_not_found;
        }
 
-       if (config.c_auth_mode == AUTHMODE_HOST) {
+       if (CtdlGetConfigInt("c_auth_mode") == AUTHMODE_HOST) {
 
                /* host auth mode */
 
@@ -586,7 +587,7 @@ int CtdlLoginExistingUser(char *authname, const char *trythisname)
        }
 
 #ifdef HAVE_LDAP
-       else if ((config.c_auth_mode == AUTHMODE_LDAP) || (config.c_auth_mode == AUTHMODE_LDAP_AD)) {
+       else if ((CtdlGetConfigInt("c_auth_mode") == AUTHMODE_LDAP) || (CtdlGetConfigInt("c_auth_mode") == AUTHMODE_LDAP_AD)) {
        
                /* LDAP auth mode */
 
@@ -670,14 +671,14 @@ void do_login(void)
        /* If this user's name is the name of the system administrator
         * (as specified in setup), automatically assign access level 6.
         */
-       if (!strcasecmp(CCC->user.fullname, config.c_sysadm)) {
+       if (!strcasecmp(CCC->user.fullname, CtdlGetConfigStr("c_sysadm"))) {
                CCC->user.axlevel = AxAideU;
        }
 
        /* If we're authenticating off the host system, automatically give
         * root the highest level of access.
         */
-       if (config.c_auth_mode == AUTHMODE_HOST) {
+       if (CtdlGetConfigInt("c_auth_mode") == AUTHMODE_HOST) {
                if (CCC->user.uid == 0) {
                        CCC->user.axlevel = AxAideU;
                }
@@ -691,7 +692,7 @@ void do_login(void)
         * the vCard module's login hook runs.
         */
        snprintf(CCC->cs_inet_email, sizeof CCC->cs_inet_email, "%s@%s",
-               CCC->user.fullname, config.c_fqdn);
+               CCC->user.fullname, CtdlGetConfigStr("c_fqdn"));
        convert_spaces_to_underscores(CCC->cs_inet_email);
 
        /* Create any personal rooms required by the system.
@@ -706,7 +707,7 @@ void do_login(void)
        PerformSessionHooks(EVT_LOGIN);
 
        /* Enter the lobby */
-       CtdlUserGoto(config.c_baseroom, 0, 0, NULL, NULL, NULL, NULL);
+       CtdlUserGoto(CtdlGetConfigStr("c_baseroom"), 0, 0, NULL, NULL, NULL, NULL);
 }
 
 
@@ -877,10 +878,10 @@ int CtdlTryPassword(const char *password, long len)
        }
 
        if (CCC->is_master) {
-               code = strcmp(password, config.c_master_pass);
+               code = strcmp(password, CtdlGetConfigStr("c_master_pass"));
        }
 
-       else if (config.c_auth_mode == AUTHMODE_HOST) {
+       else if (CtdlGetConfigInt("c_auth_mode") == AUTHMODE_HOST) {
 
                /* host auth mode */
 
@@ -910,7 +911,7 @@ int CtdlTryPassword(const char *password, long len)
        }
 
 #ifdef HAVE_LDAP
-       else if ((config.c_auth_mode == AUTHMODE_LDAP) || (config.c_auth_mode == AUTHMODE_LDAP_AD)) {
+       else if ((CtdlGetConfigInt("c_auth_mode") == AUTHMODE_LDAP) || (CtdlGetConfigInt("c_auth_mode") == AUTHMODE_LDAP_AD)) {
 
                /* LDAP auth mode */
 
@@ -1052,7 +1053,7 @@ int internal_create_user (const char *username, long len, struct ctdluser *usbuf
 
        usbuf->timescalled = 0;
        usbuf->posted = 0;
-       usbuf->axlevel = config.c_initax;
+       usbuf->axlevel = CtdlGetConfigInt("c_initax");
        usbuf->lastcall = time(NULL);
 
        /* fetch a new user number */
@@ -1089,7 +1090,7 @@ int create_user(const char *newusername, long len, int become_user)
        strproc(username);
 
        
-       if (config.c_auth_mode == AUTHMODE_HOST) {
+       if (CtdlGetConfigInt("c_auth_mode") == AUTHMODE_HOST) {
 
                /* host auth mode */
 
@@ -1121,7 +1122,7 @@ int create_user(const char *newusername, long len, int become_user)
        }
 
 #ifdef HAVE_LDAP
-       if ((config.c_auth_mode == AUTHMODE_LDAP) || (config.c_auth_mode == AUTHMODE_LDAP_AD)) {
+       if ((CtdlGetConfigInt("c_auth_mode") == AUTHMODE_LDAP) || (CtdlGetConfigInt("c_auth_mode") == AUTHMODE_LDAP_AD)) {
                if (CtdlTryUserLDAP(username, NULL, 0, username, sizeof username, &uid, 0) != 0) {
                        return(ERROR + NO_SUCH_USER);
                }
@@ -1239,7 +1240,7 @@ int CtdlForgetThisRoom(void) {
        visit vbuf;
 
        /* On some systems, Admins are not allowed to forget rooms */
-       if (is_aide() && (config.c_aide_zap == 0)
+       if (is_aide() && (CtdlGetConfigInt("c_aide_zap") == 0)
           && ((CC->room.QRflags & QR_MAILBOX) == 0)  ) {
                return(1);
        }
@@ -1254,7 +1255,7 @@ int CtdlForgetThisRoom(void) {
        CtdlPutUserLock(&CC->user);
 
        /* Return to the Lobby, so we don't end up in an undefined room */
-       CtdlUserGoto(config.c_baseroom, 0, 0, NULL, NULL, NULL, NULL);
+       CtdlUserGoto(CtdlGetConfigStr("c_baseroom"), 0, 0, NULL, NULL, NULL, NULL);
        return(0);
 
 }