From 19daa1a6209108302bbed83f6efe5958f0525f46 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Wed, 18 Jan 2006 03:24:00 +0000 Subject: [PATCH] Misc small fixes to the new host auth mode. --- citadel/ChangeLog | 3 +++ citadel/user_ops.c | 36 ++++++++++++++++++++++-------------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 8f24e1d87..d3823cd83 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -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. diff --git a/citadel/user_ops.c b/citadel/user_ops.c index 4312657da..49c0c10f1 100644 --- a/citadel/user_ops.c +++ b/citadel/user_ops.c @@ -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)) { -- 2.39.2