Annotation of sbbs/sbbs3/login.cpp, revision 1.1.1.2

1.1       root        1: /* login.cpp */
                      2: 
                      3: /* Synchronet user login routine */
                      4: 
1.1.1.2 ! root        5: /* $Id: login.cpp,v 1.12 2004/05/30 06:47:52 deuce Exp $ */
1.1       root        6: 
                      7: /****************************************************************************
                      8:  * @format.tab-size 4          (Plain Text/Source Code File Header)                    *
                      9:  * @format.use-tabs true       (see http://www.synchro.net/ptsc_hdr.html)              *
                     10:  *                                                                                                                                                     *
                     11:  * Copyright 2000 Rob Swindell - http://www.synchro.net/copyright.html         *
                     12:  *                                                                                                                                                     *
                     13:  * This program is free software; you can redistribute it and/or                       *
                     14:  * modify it under the terms of the GNU General Public License                         *
                     15:  * as published by the Free Software Foundation; either version 2                      *
                     16:  * of the License, or (at your option) any later version.                                      *
                     17:  * See the GNU General Public License for more details: gpl.txt or                     *
                     18:  * http://www.fsf.org/copyleft/gpl.html                                                                                *
                     19:  *                                                                                                                                                     *
                     20:  * Anonymous FTP access to the most recent released source is available at     *
                     21:  * ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net     *
                     22:  *                                                                                                                                                     *
                     23:  * Anonymous CVS access to the development source and modification history     *
                     24:  * is available at cvs.synchro.net:/cvsroot/sbbs, example:                                     *
                     25:  * cvs -d :pserver:[email protected]:/cvsroot/sbbs login                       *
                     26:  *     (just hit return, no password is necessary)                                                     *
                     27:  * cvs -d :pserver:[email protected]:/cvsroot/sbbs checkout src                *
                     28:  *                                                                                                                                                     *
                     29:  * For Synchronet coding style and modification guidelines, see                                *
                     30:  * http://www.synchro.net/source.html                                                                          *
                     31:  *                                                                                                                                                     *
                     32:  * You are encouraged to submit any modifications (preferably in Unix diff     *
                     33:  * format) via e-mail to [email protected]                                                                      *
                     34:  *                                                                                                                                                     *
                     35:  * Note: If this box doesn't appear square, then you need to fix your tabs.    *
                     36:  ****************************************************************************/
                     37: 
                     38: #include "sbbs.h"
                     39: #include "cmdshell.h"
                     40: 
1.1.1.2 ! root       41: int sbbs_t::login(char *username, char *pw)
1.1       root       42: {
1.1.1.2 ! root       43:        char    str[128];
1.1       root       44:        char    tmp[512];
                     45:        long    useron_misc=useron.misc;
                     46: 
                     47:        useron.number=0;
                     48:        if(cfg.node_dollars_per_call && noyes(text[AreYouSureQ]))
                     49:                return(LOGIC_FALSE);
                     50: 
1.1.1.2 ! root       51:        SAFECOPY(str,username);
        !            52: 
1.1       root       53:        if(str[0]=='*') {
                     54:                memmove(str,str+1,strlen(str));
                     55:                qwklogon=1; }
                     56:        else
                     57:                qwklogon=0;
                     58: 
                     59:        if(!(cfg.node_misc&NM_NO_NUM) && isdigit(str[0])) {
                     60:                useron.number=atoi(str);
                     61:                getuserdat(&cfg,&useron);
                     62:                if(useron.number && useron.misc&(DELETED|INACTIVE))
                     63:                        useron.number=0; }
                     64: 
                     65:        if(!useron.number) {
1.1.1.2 ! root       66:                useron.number=matchuser(&cfg,str,FALSE);
1.1       root       67:                if(!useron.number && (uchar)str[0]<0x7f && str[1]
1.1.1.2 ! root       68:                        && isalpha(str[0]) && strchr(str,' ') && cfg.node_misc&NM_LOGON_R)
1.1       root       69:                        useron.number=userdatdupe(0,U_NAME,LEN_NAME,str,0);
                     70:                if(useron.number) {
                     71:                        getuserdat(&cfg,&useron);
                     72:                        if(useron.number && useron.misc&(DELETED|INACTIVE))
                     73:                                useron.number=0; } }
                     74: 
                     75:        if(!useron.number) {
                     76:                if(cfg.node_misc&NM_LOGON_P) {
                     77:                        strcpy(useron.alias,str);
                     78:                        bputs(pw);
                     79:                        console|=CON_R_ECHOX;
                     80:                        if(!(cfg.sys_misc&SM_ECHO_PW))
                     81:                                console|=CON_L_ECHOX;
1.1.1.2 ! root       82:                        getstr(str,LEN_PASS*2,K_UPPER|K_LOWPRIO|K_TAB);
1.1       root       83:                        console&=~(CON_R_ECHOX|CON_L_ECHOX);
1.1.1.2 ! root       84:                        bputs(text[InvalidLogon]);      /* why does this always fail? */
        !            85:                        if(cfg.sys_misc&SM_ECHO_PW) 
        !            86:                                sprintf(tmp,"(%04u)  %-25s  FAILED Password attempt: '%s'"
        !            87:                                        ,0,useron.alias,str);
        !            88:                        else
        !            89:                                sprintf(tmp,"(%04u)  %-25s  FAILED Password attempt"
        !            90:                                        ,0,useron.alias);
        !            91:                        logline("+!",tmp); 
        !            92:                } else {
1.1       root       93:                        bputs(text[UnknownUser]);
                     94:                        sprintf(tmp,"Unknown User '%s'",str);
                     95:                        logline("+!",tmp); }
                     96:                useron.misc=useron_misc;
                     97:                return(LOGIC_FALSE); }
                     98: 
                     99:        if(!online) {
                    100:                useron.number=0;
                    101:                return(LOGIC_FALSE); }
                    102: 
1.1.1.2 ! root      103:        if(useron.pass[0] || REALSYSOP) {
1.1       root      104:                bputs(pw);
                    105:                console|=CON_R_ECHOX;
                    106:                if(!(cfg.sys_misc&SM_ECHO_PW))
                    107:                        console|=CON_L_ECHOX;
1.1.1.2 ! root      108:                getstr(str,LEN_PASS*2,K_UPPER|K_LOWPRIO|K_TAB);
1.1       root      109:                console&=~(CON_R_ECHOX|CON_L_ECHOX);
                    110:                if(!online) {
                    111:                        useron.number=0;
                    112:                        return(LOGIC_FALSE); }
                    113:                if(stricmp(useron.pass,str)) {
                    114:                        bputs(text[InvalidLogon]);
1.1.1.2 ! root      115:                        if(cfg.sys_misc&SM_ECHO_PW) 
        !           116:                                sprintf(tmp,"(%04u)  %-25s  FAILED Password: '%s' Attempt: '%s'"
        !           117:                                        ,useron.number,useron.alias,useron.pass,str);
        !           118:                        else
        !           119:                                sprintf(tmp,"(%04u)  %-25s  FAILED Password attempt"
        !           120:                                        ,useron.number,useron.alias);
1.1       root      121:                        logline("+!",tmp);
                    122:                        useron.number=0;
                    123:                        useron.misc=useron_misc;
                    124:                        return(LOGIC_FALSE); }
1.1.1.2 ! root      125:                if(REALSYSOP && !chksyspass()) {
1.1       root      126:                        bputs(text[InvalidLogon]);
                    127:                        useron.number=0;
                    128:                        useron.misc=useron_misc;
                    129:                        return(LOGIC_FALSE); } }
                    130: 
                    131:        return(LOGIC_TRUE);
                    132: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.