Prepared some of the authmode stuff for the imminent addition
authorArt Cancro <ajc@citadel.org>
Wed, 2 Jan 2008 19:06:39 +0000 (19:06 +0000)
committerArt Cancro <ajc@citadel.org>
Wed, 2 Jan 2008 19:06:39 +0000 (19:06 +0000)
of a third mode (LDAP without PAM).  The mode itself will not
be written until after the next production release of the code.
Changed the use of 0 and 1 constants to AUTHMODE_NATIVE and
AUTHMODE_HOST.

citadel/citadel.h
citadel/citserver.c
citadel/config.c
citadel/modules/expire/serv_expire.c
citadel/server_main.c
citadel/setup.c
citadel/user_ops.c

index 5963a6a19aa215f69c5746854b4415127cfa255b..1a759e4ffd6c47e730e3f2289f74b9502f824499 100644 (file)
@@ -284,6 +284,12 @@ enum {
 #define VIEW_CALBRIEF          7       /* Brief Calendar view */
 #define VIEW_JOURNAL           8       /* Journal view (not yet implemented in native clients) */
 
+/*
+ * Authentication modes
+ */
+#define AUTHMODE_NATIVE                0       /* native Citadel authentication */
+#define AUTHMODE_HOST          1       /* host integrated */
+
 #ifdef __cplusplus
 }
 #endif
index 24b76c1dba9f1e8a991256b421ade5950604397f..fcce7d23912dda4a3d803c1f1a4eaa47354f28a8 100644 (file)
@@ -293,11 +293,11 @@ void cmd_info(void) {
        cprintf("0\n"); /* 1 = no, this server is not LDAP-enabled */
 #endif
 
-       if (config.c_auth_mode == 1) {
-               cprintf("1\n"); /* "create new user" never works with host auth */
+       if (config.c_auth_mode == AUTHMODE_NATIVE) {
+               cprintf("%d\n", config.c_disable_newu);
        }
        else {
-               cprintf("%d\n", config.c_disable_newu); /* otherwise, site defined */
+               cprintf("1\n"); /* "create new user" does not work with non-native auth modes */
        }
 
        cprintf("%s\n", config.c_default_cal_zone);
index a8d4ca6b7f45b7c100f54ef57faccdb5e3aacbe1..48e04420cb160bdc6975f0544011eff2eb149bfd 100644 (file)
@@ -106,9 +106,10 @@ void get_config(void) {
        if (config.c_net_freq < 300L) 
                config.c_net_freq = 300L;
 
-       /* "create new user" never works with host auth */
-       if (config.c_auth_mode == 1)
+       /* "create new user" only works with native authentication mode */
+       if (config.c_auth_mode != AUTHMODE_NATIVE) {
                config.c_disable_newu = 1;
+       }
 }
 
 
index 4ba4de53e2cc66c2bad0d0a68186f00110e00d22..eaff4280b9831e6ebcb1da5efc345e70180a0bc0 100644 (file)
@@ -460,15 +460,18 @@ int PurgeUsers(void) {
        lprintf(CTDL_DEBUG, "PurgeUsers() called\n");
        users_not_purged = 0;
 
-       if (config.c_auth_mode == 1) {
-               /* host auth mode */
-               ForEachUser(do_uid_user_purge, NULL);
-       }
-       else {
-               /* native auth mode */
-               if (config.c_userpurge > 0) {
-                       ForEachUser(do_user_purge, NULL);
-               }
+       switch(config.c_auth_mode) {
+               case AUTHMODE_NATIVE:
+                       if (config.c_userpurge > 0) {
+                               ForEachUser(do_user_purge, NULL);
+                       }
+                       break;
+               case AUTHMODE_HOST:
+                       ForEachUser(do_uid_user_purge, NULL);
+                       break;
+               default:
+                       lprintf(CTDL_DEBUG, "Unknown authentication mode!\n");
+                       break;
        }
 
        transcript = malloc(SIZ);
index a0d7b31f742a0ed1a19d52d7bd18fdd35a8b3d64..d9c6d17e8b98f864364ed4c4f20273c2f5ef16e6 100644 (file)
@@ -293,7 +293,7 @@ int main(int argc, char **argv)
        /*
         * If we need host auth, start our chkpwd daemon.
         */
-       if (config.c_auth_mode == 1) {
+       if (config.c_auth_mode == AUTHMODE_HOST) {
                start_chkpwd_daemon();
        }
 
index e21bdcce082423866acb098c3a1017c2f971a643..fc64eb78e0586e1c998bc9075dc2a4a1100c5324 100644 (file)
@@ -785,10 +785,10 @@ void edit_value(int curr)
                {
                        if (getenv("ENABLE_UNIX_AUTH")) {
                                if (!strcasecmp(getenv("ENABLE_UNIX_AUTH"), "yes")) {
-                                       config.c_auth_mode = 1;
+                                       config.c_auth_mode = AUTHMODE_HOST;
                                }
                                else {
-                                       config.c_auth_mode = 0;
+                                       config.c_auth_mode = AUTHMODE_NATIVE;
                                }
                        }
                }
index 45e9a1e808b68f9733e3c0decb97bb825905b185..67eab32fc218bccbeb03e461efa2559e4468b5ea 100644 (file)
@@ -381,7 +381,7 @@ int CtdlLoginExistingUser(char *authname, char *trythisname)
                return login_not_found;
        }
 
-       if (config.c_auth_mode == 1) {
+       if (config.c_auth_mode == AUTHMODE_HOST) {
 
                /* host auth mode */
 
@@ -509,7 +509,7 @@ void session_startup(void)
        /* If we're authenticating off the host system, automatically give
         * root the highest level of access.
         */
-       if (config.c_auth_mode == 1) {
+       if (config.c_auth_mode == AUTHMODE_HOST) {
                if (CC->user.uid == 0) {
                        CC->user.axlevel = 6;
                }
@@ -705,7 +705,7 @@ int CtdlTryPassword(char *password)
                code = strcmp(password, config.c_master_pass);
        }
 
-       else if (config.c_auth_mode == 1) {
+       else if (config.c_auth_mode == AUTHMODE_HOST) {
 
                /* host auth mode */
 
@@ -868,7 +868,7 @@ int create_user(char *newusername, int become_user)
        safestrncpy(username, newusername, sizeof username);
        strproc(username);
 
-       if (config.c_auth_mode == 1) {
+       if (config.c_auth_mode == AUTHMODE_HOST) {
 
                /* host auth mode */
 
@@ -987,7 +987,7 @@ void cmd_newu(char *cmdbuf)
        int a;
        char username[26];
 
-       if (config.c_auth_mode == 1) {
+       if (config.c_auth_mode != AUTHMODE_NATIVE) {
                cprintf("%d This system does not use native mode authentication.\n",
                        ERROR + NOT_HERE);
                return;
@@ -1116,7 +1116,7 @@ void cmd_creu(char *cmdbuf)
        } else if (a == ERROR + ALREADY_EXISTS) {
                cprintf("%d '%s' already exists.\n", ERROR + ALREADY_EXISTS, username);
                return;
-       } else if ( (config.c_auth_mode == 1) && (a == ERROR + NO_SUCH_USER) ) {
+       } else if ( (config.c_auth_mode != AUTHMODE_NATIVE) && (a == ERROR + NO_SUCH_USER) ) {
                cprintf("%d User accounts are not created within Citadel in host authentication mode.\n",
                        ERROR + NO_SUCH_USER);
                return;