Misc small fixes to the new host auth mode.
authorArt Cancro <ajc@citadel.org>
Wed, 18 Jan 2006 03:24:00 +0000 (03:24 +0000)
committerArt Cancro <ajc@citadel.org>
Wed, 18 Jan 2006 03:24:00 +0000 (03:24 +0000)
citadel/ChangeLog
citadel/user_ops.c

index 8f24e1d87cf298889ea7d7ab0958dcfb921933cf..d3823cd83b2cf9175c05dabd5de04c1978d85cdf 100644 (file)
@@ -1,5 +1,8 @@
 $Id$
 
+Tue Jan 17 22:23:19 EST 2006 ajc
+* Misc small fixes to the new host auth mode.
+
 Tue Jan 17 17:07:02 EST 2006 ajc
 * REMOVED MIXED MODE AUTHENTICATION.
   "autologin mode" is now system accounts ONLY.
index 4312657dabcb5a71c5ee0677cbe0a63ce24b3c42..49c0c10f1dde1b0e9429d2cf9ec28ea9dd374e23 100644 (file)
@@ -369,7 +369,7 @@ int CtdlLoginExistingUser(char *trythisname)
        if (tempPwdPtr == NULL) {
                return login_not_found;
        }
-       lprintf(CTDL_DEBUG, "found it! uid=%d\n", pd.pw_uid);
+       lprintf(CTDL_DEBUG, "found it! uid=%d, gecos=%s\n", pd.pw_uid, pd.pw_gecos);
 
        /* Locate the associated Citadel account.
         * If not found, make one attempt to create it.
@@ -474,6 +474,16 @@ void session_startup(void)
        if (!strcasecmp(CC->user.fullname, config.c_sysadm)) {
                CC->user.axlevel = 6;
        }
+
+#ifdef ENABLE_AUTOLOGIN
+       /* If we're authenticating off the host system, automatically give
+        * root the highest level of access.
+        */
+       if (CC->user.uid == 0) {
+               CC->user.axlevel = 6;
+       }
+#endif
+
        lputuser(&CC->user);
 
        /*
@@ -792,26 +802,24 @@ int create_user(char *newusername, int become_user)
        struct ctdlroom qrbuf;
        char username[256];
        char mailboxname[ROOMNAMELEN];
-       uid_t uid;
+       uid_t uid = (-1);
 
        safestrncpy(username, newusername, sizeof username);
        strproc(username);
 
 #ifdef ENABLE_AUTOLOGIN
+       struct passwd pd;
+       struct passwd *tempPwdPtr;
+       char pwdbuffer[256];
 
-       struct passwd *p = (struct passwd *) getpwnam(username);
-
-       if (p != NULL) {
-               extract_token(username, p->pw_gecos, 0, ',', sizeof username);
-               uid = p->pw_uid;
-       else {
-               uid = (-1);
+       getpwnam_r(username, &pd, pwdbuffer, sizeof pwdbuffer, &tempPwdPtr);
+       if (tempPwdPtr != NULL) {
+               extract_token(username, pd.pw_gecos, 0, ',', sizeof username);
+               uid = pd.pw_uid;
+       }
+       else {
+               return (ERROR + NO_SUCH_USER);
        }
-
-#else
-
-       uid = (-1);
-
 #endif
 
        if (!getuser(&usbuf, username)) {