Annotation of sbbs/src/sbbs3/login.cpp, revision 1.1.1.1

1.1       root        1: /* login.cpp */
                      2: 
                      3: /* Synchronet user login routine */
                      4: 
                      5: /* $Id: login.cpp,v 1.13 2006/05/03 00:26:52 rswindell Exp $ */
                      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 2006 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: 
                     41: int sbbs_t::login(char *username, char *pw)
                     42: {
                     43:        char    str[128];
                     44:        char    tmp[512];
                     45:        long    useron_misc=useron.misc;
                     46: 
                     47:        useron.number=0;
                     48: #if 0
                     49:        if(cfg.node_dollars_per_call && noyes(text[AreYouSureQ]))
                     50:                return(LOGIC_FALSE);
                     51: #endif
                     52: 
                     53:        SAFECOPY(str,username);
                     54: 
                     55:        if(str[0]=='*') {
                     56:                memmove(str,str+1,strlen(str));
                     57:                qwklogon=1; }
                     58:        else
                     59:                qwklogon=0;
                     60: 
                     61:        if(!(cfg.node_misc&NM_NO_NUM) && isdigit(str[0])) {
                     62:                useron.number=atoi(str);
                     63:                getuserdat(&cfg,&useron);
                     64:                if(useron.number && useron.misc&(DELETED|INACTIVE))
                     65:                        useron.number=0; }
                     66: 
                     67:        if(!useron.number) {
                     68:                useron.number=matchuser(&cfg,str,FALSE);
                     69:                if(!useron.number && (uchar)str[0]<0x7f && str[1]
                     70:                        && isalpha(str[0]) && strchr(str,' ') && cfg.node_misc&NM_LOGON_R)
                     71:                        useron.number=userdatdupe(0,U_NAME,LEN_NAME,str,0);
                     72:                if(useron.number) {
                     73:                        getuserdat(&cfg,&useron);
                     74:                        if(useron.number && useron.misc&(DELETED|INACTIVE))
                     75:                                useron.number=0; } }
                     76: 
                     77:        if(!useron.number) {
                     78:                if(cfg.node_misc&NM_LOGON_P) {
                     79:                        strcpy(useron.alias,str);
                     80:                        bputs(pw);
                     81:                        console|=CON_R_ECHOX;
                     82:                        getstr(str,LEN_PASS*2,K_UPPER|K_LOWPRIO|K_TAB);
                     83:                        console&=~(CON_R_ECHOX|CON_L_ECHOX);
                     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 {
                     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: 
                    103:        if(useron.pass[0] || REALSYSOP) {
                    104:                bputs(pw);
                    105:                console|=CON_R_ECHOX;
                    106:                getstr(str,LEN_PASS*2,K_UPPER|K_LOWPRIO|K_TAB);
                    107:                console&=~(CON_R_ECHOX|CON_L_ECHOX);
                    108:                if(!online) {
                    109:                        useron.number=0;
                    110:                        return(LOGIC_FALSE); }
                    111:                if(stricmp(useron.pass,str)) {
                    112:                        bputs(text[InvalidLogon]);
                    113:                        if(cfg.sys_misc&SM_ECHO_PW) 
                    114:                                sprintf(tmp,"(%04u)  %-25s  FAILED Password: '%s' Attempt: '%s'"
                    115:                                        ,useron.number,useron.alias,useron.pass,str);
                    116:                        else
                    117:                                sprintf(tmp,"(%04u)  %-25s  FAILED Password attempt"
                    118:                                        ,useron.number,useron.alias);
                    119:                        logline("+!",tmp);
                    120:                        useron.number=0;
                    121:                        useron.misc=useron_misc;
                    122:                        return(LOGIC_FALSE); }
                    123:                if(REALSYSOP && !chksyspass()) {
                    124:                        bputs(text[InvalidLogon]);
                    125:                        useron.number=0;
                    126:                        useron.misc=useron_misc;
                    127:                        return(LOGIC_FALSE); } }
                    128: 
                    129:        return(LOGIC_TRUE);
                    130: }

unix.superglobalmegacorp.com

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