From 04b914b178179f76346b432b690a89610b3643ff Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Wed, 22 Jan 2003 03:53:24 +0000 Subject: [PATCH] * More reliablility hacks for autologin mode, and better quarantine of autologin code when it's disabled. --- citadel/ChangeLog | 5 +++++ citadel/user_ops.c | 34 ++++++++++++++++++++++++++-------- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 685f3d209..73d13cb0d 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,8 @@ $Log$ + Revision 601.123 2003/01/22 03:53:24 ajc + * More reliablility hacks for autologin mode, and better quarantine of + autologin code when it's disabled. + Revision 601.122 2003/01/21 04:42:12 ajc * Moved login-to-screenname code ... no longer part of CtdlTryExistingUser(), it's now part of getuser() so it always gets called, even when looking up @@ -4436,3 +4440,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import + diff --git a/citadel/user_ops.c b/citadel/user_ops.c index 195573fdb..793484236 100644 --- a/citadel/user_ops.c +++ b/citadel/user_ops.c @@ -63,14 +63,22 @@ int getuser(struct usersupp *usbuf, char name[]) { char lowercase_name[USERNAME_SIZE]; + char sysuser_name[USERNAME_SIZE]; int a; struct cdbdata *cdbus; + int using_sysuser = 0; memset(usbuf, 0, sizeof(struct usersupp)); - if (CtdlAssociateSystemUser(lowercase_name, name) == 0) { - for (a = 0; a <= strlen(lowercase_name); ++a) { - lowercase_name[a] = tolower(lowercase_name[a]); +#ifdef ENABLE_AUTOLOGIN + if (CtdlAssociateSystemUser(sysuser_name, name) == 0) { + ++using_sysuser; + } +#endif + + if (using_sysuser) { + for (a = 0; a <= strlen(sysuser_name); ++a) { + lowercase_name[a] = tolower(sysuser_name[a]); } } else { @@ -82,8 +90,8 @@ int getuser(struct usersupp *usbuf, char name[]) lowercase_name[sizeof(lowercase_name) - 1] = 0; cdbus = cdb_fetch(CDB_USERSUPP, lowercase_name, strlen(lowercase_name)); - if (cdbus == NULL) { - return (1); /* user not found */ + if (cdbus == NULL) { /* user not found */ + return(1); } memcpy(usbuf, cdbus->ptr, ((cdbus->len > sizeof(struct usersupp)) ? @@ -586,12 +594,14 @@ int CtdlTryPassword(char *password) return pass_wrong_password; } code = (-1); + + +#ifdef ENABLE_AUTOLOGIN if (CC->usersupp.uid == BBSUID) { strproc(password); strproc(CC->usersupp.password); code = strcasecmp(CC->usersupp.password, password); } -#ifdef ENABLE_AUTOLOGIN else { if (validpw(CC->usersupp.uid, password)) { code = 0; @@ -601,7 +611,13 @@ int CtdlTryPassword(char *password) lputuser(&CC->usersupp); } } -#endif + +#else /* ENABLE_AUTOLOGIN */ + strproc(password); + strproc(CC->usersupp.password); + code = strcasecmp(CC->usersupp.password, password); + +#endif /* ENABLE_AUTOLOGIN */ if (!code) { do_login(); @@ -724,13 +740,15 @@ int create_user(char *newusername, int become_user) #ifdef ENABLE_AUTOLOGIN p = (struct passwd *) getpwnam(username); -#endif if (p != NULL) { extract_token(username, p->pw_gecos, 0, ','); uid = p->pw_uid; } else { uid = BBSUID; } +#else + uid = BBSUID; +#endif if (!getuser(&usbuf, username)) { return (ERROR + ALREADY_EXISTS); -- 2.39.2