Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit ab2fcd47 authored by rswindell's avatar rswindell

Add optional log_level argument to sbbs_t::logline() function.

parent 6a2ff049
......@@ -126,7 +126,7 @@ bool sbbs_t::answer()
else
sprintf(str,"(%04u) %-25s FAILED Password attempt"
,0,useron.alias);
logline("+!",str);
logline(LOG_NOTICE,"+!",str);
bputs(text[PasswordPrompt]);
console|=CON_R_ECHOX;
getstr(tmp,LEN_PASS*2,K_UPPER|K_LOWPRIO|K_TAB);
......@@ -155,7 +155,7 @@ bool sbbs_t::answer()
else
sprintf(str,"(%04u) %-25s FAILED Password attempt"
,0,useron.alias);
logline("+!",str);
logline(LOG_NOTICE,"+!",str);
}
lprintf(LOG_WARNING,"Node %d !CLIENT IP NOT LISTED in %s"
,cfg.node_num,path);
......@@ -208,7 +208,7 @@ bool sbbs_t::answer()
else
sprintf(str,"(%04u) %-25s FAILED Password attempt"
,0,useron.alias);
logline("+!",str);
logline(LOG_NOTICE,"+!",str);
bputs(text[PasswordPrompt]);
console|=CON_R_ECHOX;
getstr(tmp,LEN_PASS*2,K_UPPER|K_LOWPRIO|K_TAB);
......@@ -237,7 +237,7 @@ bool sbbs_t::answer()
else
sprintf(str,"(%04u) %-25s FAILED Password attempt"
,0,useron.alias);
logline("+!",str);
logline(LOG_NOTICE,"+!",str);
}
useron.number=0;
hangup();
......
......@@ -107,7 +107,7 @@ bool sbbs_t::chksyspass()
int orgcon=console;
if(online==ON_REMOTE && !(cfg.sys_misc&SM_R_SYSOP)) {
logline("S!","Remote sysop access disabled");
logline(LOG_NOTICE,"S!","Remote sysop access disabled");
return(false);
}
bputs(text[SystemPassword]);
......@@ -120,7 +120,7 @@ bool sbbs_t::chksyspass()
else
SAFEPRINTF2(str2,"%s #%u System password verification failure"
,useron.alias,useron.number);
logline("S!",str2);
logline(LOG_NOTICE,"S!",str2);
return(false);
}
return(true);
......
......@@ -244,7 +244,7 @@ ulong sbbs_t::gettimeleft(bool handle_out_of_time)
gettimeleft_inside=1;
if(!timeleft && !SYSOP && !(sys_status&SS_LCHAT)) {
logline(nulstr,"Ran out of time");
logline(LOG_NOTICE,nulstr,"Ran out of time");
SAVELINE;
if(sys_status&SS_EVENT)
bprintf(text[ReducedTime],timestr(event_time));
......
......@@ -247,7 +247,7 @@ int sbbs_t::protocol(prot_t* prot, enum XFER_TYPE type
if(!fgets(protlog,sizeof(protlog),stream))
break;
truncsp(protlog);
logline(nulstr,protlog);
logline(LOG_DEBUG,nulstr,protlog);
}
fclose(stream);
}
......@@ -397,7 +397,7 @@ bool sbbs_t::checkprotresult(prot_t* prot, int error, file_t* f)
else if(f->dir==cfg.total_dirs+1)
sprintf(str,"%s attempted to download attached file: %s"
,useron.alias,f->name);
logline("D!",str);
logline(LOG_NOTICE,"D!",str);
return(false);
}
return(true);
......
......@@ -278,7 +278,7 @@ char sbbs_t::getkey(long mode)
console&=~CON_R_ECHOX;
}
bputs(text[CallBackWhenYoureThere]);
logline(nulstr,"Inactive");
logline(LOG_NOTICE,nulstr,"Inactive");
hangup();
return(0);
}
......
......@@ -96,7 +96,7 @@ int sbbs_t::getnodedat(uint number, node_t *node, bool lockit)
if(count>(LOOP_NODEDAB/2)) {
sprintf(str,"NODE.DAB (node %d) COLLISION - Count: %d"
,number+1, count);
logline("!!",str);
logline(LOG_WARNING,"!!",str);
}
return(0);
......@@ -165,7 +165,7 @@ void sbbs_t::nodesync()
if(thisnode.misc&NODE_INTR) {
bputs(text[NodeLocked]);
logline(nulstr,"Interrupted");
logline(LOG_NOTICE,nulstr,"Interrupted");
hangup();
nodesync_inside=0;
return;
......
......@@ -182,15 +182,23 @@ bool sbbs_t::syslog(const char* code, const char *entry)
}
/****************************************************************************/
/* Writes 'str' on it's own line in node.log */
/* Writes 'str' on it's own line in node.log (using LOG_INFO level) */
/****************************************************************************/
void sbbs_t::logline(const char *code, const char *str)
{
logline(LOG_INFO, code, str);
}
/****************************************************************************/
/* Writes 'str' on it's own line in node.log */
/****************************************************************************/
void sbbs_t::logline(int level, const char *code, const char *str)
{
if(strchr(str,'\n')==NULL) { // Keep the console log pretty
if(online==ON_LOCAL)
eprintf(LOG_INFO,"%s",str);
eprintf(level,"%s",str);
else
lprintf(LOG_INFO,"Node %d %s", cfg.node_num, str);
lprintf(level,"Node %d %s", cfg.node_num, str);
}
if(logfile_fp==NULL || (online==ON_LOCAL && strcmp(code,"!!"))) return;
if(logcol!=1)
......
......@@ -91,11 +91,11 @@ int sbbs_t::login(char *username, char *pw)
else
sprintf(tmp,"(%04u) %-25s FAILED Password attempt"
,0,useron.alias);
logline("+!",tmp);
logline(LOG_NOTICE,"+!",tmp);
} else {
bputs(text[UnknownUser]);
sprintf(tmp,"Unknown User '%s'",str);
logline("+!",tmp);
logline(LOG_NOTICE,"+!",tmp);
}
useron.misc=useron_misc;
return(LOGIC_FALSE);
......@@ -123,7 +123,7 @@ int sbbs_t::login(char *username, char *pw)
else
sprintf(tmp,"(%04u) %-25s FAILED Password attempt"
,useron.number,useron.alias);
logline("+!",tmp);
logline(LOG_NOTICE,"+!",tmp);
useron.number=0;
useron.misc=useron_misc;
return(LOGIC_FALSE);
......
......@@ -102,7 +102,7 @@ bool sbbs_t::logon()
bputs(text[NoNodeAccess]);
sprintf(str,"(%04u) %-25s Insufficient node access"
,useron.number,useron.alias);
logline("+!",str);
logline(LOG_NOTICE,"+!",str);
return(false);
}
......@@ -113,7 +113,7 @@ bool sbbs_t::logon()
bputs(text[NodeLocked]);
sprintf(str,"(%04u) %-25s Locked node logon attempt"
,useron.number,useron.alias);
logline("+!",str);
logline(LOG_NOTICE,"+!",str);
return(false);
}
if(yesno(text[RemoveNodeLockQ])) {
......@@ -277,7 +277,7 @@ bool sbbs_t::logon()
bputs(text[NoMoreLogons]);
sprintf(str,"(%04u) %-25s Out of logons"
,useron.number,useron.alias);
logline("+!",str);
logline(LOG_NOTICE,"+!",str);
hangup();
return(false);
}
......@@ -285,7 +285,7 @@ bool sbbs_t::logon()
bputs(text[R_Logons]);
sprintf(str,"(%04u) %-25s Out of logons"
,useron.number,useron.alias);
logline("+!",str);
logline(LOG_NOTICE,"+!",str);
hangup();
return(false);
}
......@@ -390,7 +390,7 @@ bool sbbs_t::logon()
if(!online) {
sprintf(str,"(%04u) %-25s Unsuccessful logon"
,useron.number,useron.alias);
logline("+!",str);
logline(LOG_NOTICE,"+!",str);
return(false);
}
SAFECOPY(useron.modem,connection);
......@@ -490,7 +490,7 @@ bool sbbs_t::logon()
strcpy(tmp,"On two nodes at the same time");
sprintf(str,"(%04u) %-25s %s"
,useron.number,useron.alias,tmp);
logline("+!",str);
logline(LOG_NOTICE,"+!",str);
errorlog(tmp);
bputs(text[UserOnTwoNodes]);
hangup();
......
......@@ -2442,7 +2442,7 @@ void event_thread(void* arg)
if(rename(str,newname)==0) {
char logmsg[MAX_PATH*3];
SAFEPRINTF2(logmsg,"%s renamed to %s",str,newname);
sbbs->logline("Q!",logmsg);
sbbs->logline(LOG_NOTICE,"Q!",logmsg);
}
}
delfiles(sbbs->cfg.temp_dir,ALLFILES);
......@@ -3053,7 +3053,7 @@ bool sbbs_t::init()
,hhmmtostr(&cfg,&tm,tmp)
,wday[tm.tm_wday]
,mon[tm.tm_mon],tm.tm_mday,tm.tm_year+1900);
logline("L!",str);
logline(LOG_NOTICE,"L!",str);
log(crlf);
catsyslog(1);
}
......@@ -3388,12 +3388,12 @@ int sbbs_t::nopen(char *str, int access)
if(count>(LOOP_NOPEN/2) && count<=LOOP_NOPEN) {
SAFEPRINTF2(logstr,"NOPEN COLLISION - File: \"%s\" Count: %d"
,str,count);
logline("!!",logstr);
logline(LOG_WARNING,"!!",logstr);
}
if(file==-1 && (errno==EACCES || errno==EAGAIN)) {
SAFEPRINTF2(logstr,"NOPEN ACCESS DENIED - File: \"%s\" errno: %d"
,str,errno);
logline("!!",logstr);
logline(LOG_WARNING,"!!",logstr);
bputs("\7\r\nNOPEN: ACCESS DENIED\r\n\7");
}
return(file);
......
......@@ -68,7 +68,7 @@ BOOL sbbs_t::newuser()
getnodedat(cfg.node_num,&thisnode,0);
if(thisnode.misc&NODE_LOCK) {
bputs(text[NodeLocked]);
logline("N!","New user locked node logon attempt");
logline(LOG_WARNING,"N!","New user locked node logon attempt");
hangup();
return(FALSE);
}
......@@ -91,7 +91,7 @@ BOOL sbbs_t::newuser()
if(!strcmp(str,cfg.new_pass))
break;
sprintf(tmp,"NUP Attempted: '%s'",str);
logline("N!",tmp);
logline(LOG_NOTICE,"N!",tmp);
}
if(c==4) {
sprintf(str,"%snupguess.msg",cfg.text_dir);
......@@ -118,7 +118,7 @@ BOOL sbbs_t::newuser()
if((i=userdatdupe(0,U_NOTE,LEN_NOTE,cid,true))!=0) { /* Duplicate IP address */
sprintf(useron.comment,"Warning: same IP address as user #%d %s"
,i,username(&cfg,i,str));
logline("N!",useron.comment);
logline(LOG_NOTICE,"N!",useron.comment);
}
SAFECOPY(useron.alias,"New"); /* just for status line */
......@@ -408,9 +408,9 @@ BOOL sbbs_t::newuser()
else
sprintf(tmp,"%s FAILED Password verification"
,useron.alias);
logline(nulstr,tmp);
logline(LOG_NOTICE,nulstr,tmp);
if(++c==4) {
logline("N!","Couldn't figure out password.");
logline(LOG_NOTICE,"N!","Couldn't figure out password.");
hangup();
}
bputs(text[IncorrectPassword]);
......@@ -466,7 +466,7 @@ BOOL sbbs_t::newuser()
} /* give 'em a 2nd try */
if(!useron.fbacks && !useron.emails) {
bprintf(text[NoFeedbackWarning],username(&cfg,cfg.node_valuser,tmp));
logline("N!","Aborted feedback");
logline(LOG_NOTICE,"N!","Aborted feedback");
hangup();
putuserrec(&cfg,useron.number,U_COMMENT,60,"Didn't leave feedback");
putuserrec(&cfg,useron.number,U_MISC,8
......
......@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2005 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 2009 Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
......@@ -149,7 +149,7 @@ int sbbs_t::putnodeext(uint number, char *ext)
if(count>(LOOP_NODEDAB/2) && count!=LOOP_NODEDAB) {
sprintf(str,"NODE.EXB (node %d) COLLISION - Count: %d"
,number+1, count);
logline("!!",str);
logline(LOG_NOTICE,"!!",str);
}
if(count==LOOP_NODEDAB) {
errormsg(WHERE,ERR_WRITE,"NODE.EXB",number+1);
......
......@@ -856,7 +856,7 @@ void sbbs_t::qwkcfgline(char *buf,uint subnum)
if(x>=usrgrps || y>=usrsubs[x]) {
bprintf(text[QWKInvalidConferenceN],l);
sprintf(str,"Invalid conference number %lu",l);
logline("Q!",str);
logline(LOG_NOTICE,"Q!",str);
}
else
subscan[usrsub[x][y]].cfg&=~SUB_CFG_NSCAN;
......
......@@ -499,14 +499,14 @@ bool sbbs_t::qwk_import_msg(FILE *qwk_fp, char *hdrblk, ulong blocks
if(!fromhub) {
if(subnum==INVALID_SUB) {
SAFEPRINTF2(str,"%s duplicate e-mail attempt (%s)",useron.alias,smb.last_error);
logline("E!",str);
logline(LOG_NOTICE,"E!",str);
} else {
SAFEPRINTF4(str,"%s duplicate message attempt in %s %s (%s)"
,useron.alias
,cfg.grp[cfg.sub[subnum]->grp]->sname
,cfg.sub[subnum]->lname
,smb.last_error);
logline("P!",str);
logline(LOG_NOTICE,"P!",str);
}
}
}
......
......@@ -709,7 +709,8 @@ public:
void logentry(const char *code,const char *entry);
void log(char *str); /* Writes 'str' to node log */
void logch(char ch, bool comma); /* Writes 'ch' to node log */
void logline(const char *code,const char *str); /* Writes 'str' on it's own line in log */
void logline(const char *code,const char *str); /* Writes 'str' on it's own line in log (LOG_INFO level) */
void logline(int level, const char *code,const char *str);
void logofflist(void); /* List of users logon activity */
bool syslog(const char* code, const char *entry);
void errorlog(const char *text); /* Logs errors to ERROR.LOG and NODE.LOG */
......
......@@ -153,7 +153,7 @@ bool sbbs_t::unpack_qwk(char *packet,uint hubnum)
eprintf(LOG_NOTICE,"!Filtering QWK message from %s due to age: %u days"
,msg.from
,(now-msg.hdr.when_written.time)/(24*60*60));
logline("P!",str);
logline(LOG_NOTICE,"P!",str);
continue;
}
......
......@@ -79,8 +79,8 @@ bool sbbs_t::unpack_rep(char* repfile)
SAFEPRINTF2(rep_fname,"%s%s.rep",cfg.temp_dir,cfg.sys_id);
if(!fexistcase(rep_fname)) {
bputs(text[QWKReplyNotReceived]);
logline("U!",AttemptedToUploadREPpacket);
logline(nulstr,"REP file not received");
logline(LOG_NOTICE,"U!",AttemptedToUploadREPpacket);
logline(LOG_NOTICE,nulstr,"REP file not received");
return(false);
}
for(k=0;k<cfg.total_fextrs;k++)
......@@ -94,15 +94,15 @@ bool sbbs_t::unpack_rep(char* repfile)
i=external(cmdstr(cfg.fextr[k]->cmd,rep_fname,ALLFILES,NULL),ex);
if(i) {
bputs(text[QWKExtractionFailed]);
logline("U!",AttemptedToUploadREPpacket);
logline(nulstr,"Extraction failed");
logline(LOG_NOTICE,"U!",AttemptedToUploadREPpacket);
logline(LOG_NOTICE,nulstr,"Extraction failed");
return(false);
}
SAFEPRINTF2(msg_fname,"%s%s.msg",cfg.temp_dir,cfg.sys_id);
if(!fexistcase(msg_fname)) {
bputs(text[QWKReplyNotReceived]);
logline("U!",AttemptedToUploadREPpacket);
logline(nulstr,"MSG file not received");
logline(LOG_NOTICE,"U!",AttemptedToUploadREPpacket);
logline(LOG_NOTICE,nulstr,"MSG file not received");
return(false);
}
if((rep=fnopen(&file,msg_fname,O_RDONLY))==NULL) {
......@@ -130,8 +130,8 @@ bool sbbs_t::unpack_rep(char* repfile)
iniFreeStringList(headers);
fclose(rep);
bputs(text[QWKReplyNotReceived]);
logline("U!",AttemptedToUploadREPpacket);
logline(nulstr,"Incorrect QWK BBS ID");
logline(LOG_NOTICE,"U!",AttemptedToUploadREPpacket);
logline(LOG_NOTICE,nulstr,"Incorrect QWK BBS ID");
return(false);
}
logline("U+","Uploaded REP packet");
......@@ -181,7 +181,7 @@ bool sbbs_t::unpack_rep(char* repfile)
SAFEPRINTF2(str,"!Filtering QWK message from %s due to age: %u days"
,msg.from
,(now-msg.hdr.when_written.time)/(24*60*60));
logline("P!",str);
logline(LOG_NOTICE,"P!",str);
continue;
}
......@@ -189,7 +189,7 @@ bool sbbs_t::unpack_rep(char* repfile)
SAFEPRINTF2(str,"!Filtering QWK message from %s due to blocked IP: %s"
,msg.from
,msg.from_ip);
logline("P!",str);
logline(LOG_NOTICE,"P!",str);
continue;
}
......@@ -198,7 +198,7 @@ bool sbbs_t::unpack_rep(char* repfile)
SAFEPRINTF2(str,"!Filtering QWK message from %s due to blocked hostname: %s"
,msg.from
,hostname);
logline("P!",str);
logline(LOG_NOTICE,"P!",str);
continue;
}
......@@ -206,7 +206,7 @@ bool sbbs_t::unpack_rep(char* repfile)
SAFEPRINTF2(str,"!Filtering QWK message from %s due to filtered subject: %s"
,msg.from
,msg.subj);
logline("P!",str);
logline(LOG_NOTICE,"P!",str);
continue;
}
......@@ -370,7 +370,7 @@ bool sbbs_t::unpack_rep(char* repfile)
if(j>=usrgrps || k>=usrsubs[j] || cfg.sub[usrsub[j][k]]->qwkconf) {
bprintf(text[QWKInvalidConferenceN],n);
SAFEPRINTF2(str,"%s: Invalid QWK conference number %lu",useron.alias,n);
logline("P!",str);
logline(LOG_NOTICE,"P!",str);
continue;
}
}
......@@ -401,13 +401,13 @@ bool sbbs_t::unpack_rep(char* repfile)
if(useron.rest&FLAG('Q') && !(cfg.sub[n]->misc&SUB_QNET)) {
bputs(text[CantPostOnSub]);
logline("P!","Attempted to post QWK message on non-QWKnet sub");
logline(LOG_NOTICE,"P!","Attempted to post QWK message on non-QWKnet sub");
continue;
}
if(useron.rest&FLAG('P')) {
bputs(text[R_Post]);
logline("P!","QWK Post attempted");
logline(LOG_NOTICE,"P!","QWK Post attempted");
continue;
}
......@@ -420,20 +420,20 @@ bool sbbs_t::unpack_rep(char* repfile)
if(useron.rest&FLAG('N')
&& cfg.sub[n]->misc&(SUB_FIDO|SUB_PNET|SUB_QNET|SUB_INET)) {
bputs(text[CantPostOnSub]);
logline("P!","QWK Networked post attempted");
logline(LOG_NOTICE,"P!","QWK Networked post attempted");
continue;
}
if(!chk_ar(cfg.sub[n]->post_ar,&useron,&client)) {
bputs(text[CantPostOnSub]);
logline("P!","QWK Post attempted");
logline(LOG_NOTICE,"P!","QWK Post attempted");
continue;
}
if((block[0]=='*' || block[0]=='+')
&& !(cfg.sub[n]->misc&SUB_PRIV)) {
bputs(text[PrivatePostsNotAllowed]);
logline("P!","QWK Private post attempt");
logline(LOG_NOTICE,"P!","QWK Private post attempt");
continue;
}
......@@ -462,7 +462,7 @@ bool sbbs_t::unpack_rep(char* repfile)
,msg.from
,msg.to
,cfg.grp[cfg.sub[n]->grp]->sname,cfg.sub[n]->lname);
logline("P!",str);
logline(LOG_NOTICE,"P!",str);
continue;
}
......
......@@ -73,7 +73,7 @@ bool sbbs_t::uploadfile(file_t *f)
,useron.alias
,f->name
,cfg.lib[cfg.dir[f->dir]->lib]->sname,cfg.dir[f->dir]->sname);
logline("U!",str);
logline(LOG_NOTICE,"U!",str);
return(0);
}
strcpy(tmp,f->name);
......@@ -104,7 +104,7 @@ bool sbbs_t::uploadfile(file_t *f)
,useron.alias
,f->name
,cfg.lib[cfg.dir[f->dir]->lib]->sname,cfg.dir[f->dir]->sname,cfg.ftest[i]->ext);
logline("U!",str);
logline(LOG_NOTICE,"U!",str);
#if 0
sprintf(str,"Failed test: %s", cmdstr(cfg.ftest[i]->cmd,path,f->desc,NULL));
logline(" ",str);
......@@ -146,7 +146,7 @@ bool sbbs_t::uploadfile(file_t *f)
,useron.alias
,f->name
,cfg.lib[cfg.dir[f->dir]->lib]->sname,cfg.dir[f->dir]->sname);
logline("U!",str);
logline(LOG_NOTICE,"U!",str);
return(0);
}
if(cfg.dir[f->dir]->misc&DIR_DIZ) {
......
......@@ -1039,7 +1039,7 @@ void sbbs_t::maindflts(user_t* user)
putuserrec(&cfg,user->number,U_PWMOD,8,ultoa(now,tmp,16));
bputs(text[PasswordChanged]);
SAFEPRINTF(str,"%s changed password",useron.alias);
logline(nulstr,str);
logline(LOG_NOTICE,nulstr,str);
}
SAFEPRINTF2(str,"%suser/%04u.sig",cfg.data_dir,user->number);
if(fexist(str) && yesno(text[ViewSignatureQ]))
......
......@@ -1003,7 +1003,7 @@ bool sbbs_t::editfile(char *fname)
if(l>0) {
SAFEPRINTF4(str,"%s created or edited file: %s (%u bytes, %u lines)"
,useron.alias, path, l, lines);
logline(nulstr,str);
logline(LOG_NOTICE,nulstr,str);
}
rioctl(IOSM|PAUSE|ABORT);
return true;
......
......@@ -789,7 +789,7 @@ int sbbs_t::external(const char* cmdline, long mode, const char* startup_dir)
if(!online && !(mode&EX_OFFLINE)) { // Tell VXD/VDD and external that user hung-up
if(was_online) {
sprintf(str,"%s hung-up in external program",useron.alias);
logline("X!",str);
logline(LOG_NOTICE,"X!",str);
hungup=time(NULL);
if(!native) {
if(nt)
......@@ -1809,7 +1809,7 @@ int sbbs_t::external(const char* cmdline, long mode, const char* startup_dir)
if(!online && !(mode&EX_OFFLINE)) {
sprintf(str,"%s hung-up in external program",useron.alias);
logline("X!",str);
logline(LOG_NOTICE,"X!",str);
break;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment