Commit d3b05466 authored by rswindell's avatar rswindell

Eliminated sbbs_t::errorlog(), as it didn't actually write to the error.log any

longer (use lprintf(LOG_ERR,...) instead, which does).
Added sbbs_t::hacklog() for convenience.
parent ba07b9b9
......@@ -165,9 +165,8 @@ void sbbs_t::notdownloaded(ulong size, time_t start, time_t end)
if(cfg.leech_pct && cur_cps /* leech detection */
&& end-start>=cfg.leech_sec
&& end-start>=(double)(size/cur_cps)*(double)cfg.leech_pct/100.0) {
sprintf(str,"Possible use of leech protocol (leech=%u downloads=%u)"
,useron.leech+1,useron.dls);
errorlog(str);
lprintf(LOG_ERR, "Node %d Possible use of leech protocol (leech=%u downloads=%u)"
,cfg.node_num, useron.leech+1,useron.dls);
useron.leech=(uchar)adjustuserrec(&cfg,useron.number,U_LEECH,2,1);
}
}
......
......@@ -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 2010 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 2011 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 *
......@@ -276,13 +276,12 @@ extern "C" BOOL filematch(const char *filename, const char *filespec)
/*****************************************************************************/
bool sbbs_t::checkfname(char *fname)
{
char str[256];
int c=0,d;
if(fname[0]=='-'
|| strcspn(fname,ILLEGAL_FILENAME_CHARS)!=strlen(fname)) {
SAFEPRINTF(str,"Suspicious filename attempt: '%s'",fname);
errorlog(str);
lprintf(LOG_WARNING,"Suspicious filename attempt: '%s'",fname);
hacklog("Filename", fname);
return(false);
}
if(strstr(fname,".."))
......
......@@ -132,7 +132,7 @@ void sbbs_t::nodesync()
if(sys_status&SS_USERON) {
if(thisnode.status==NODE_WFC) {
errorlog("NODE STATUS FIXUP");
lprintf(LOG_ERR, "Node %d NODE STATUS FIXUP", cfg.node_num);
if(getnodedat(cfg.node_num,&thisnode,true)==0) {
thisnode.status=NODE_INUSE;
putnodedat(cfg.node_num,&thisnode);
......
......@@ -67,6 +67,11 @@ extern "C" BOOL DLLCALL hacklog(scfg_t* cfg, char* prot, char* user, char* text,
return(TRUE);
}
BOOL sbbs_t::hacklog(char* prot, char* text)
{
return ::hacklog(&cfg, prot, useron.alias, text, client_name, &client_addr);
}
extern "C" BOOL DLLCALL spamlog(scfg_t* cfg, char* prot, char* action
,char* reason, char* host, char* ip_addr
,char* to, char* from)
......@@ -282,18 +287,6 @@ void sbbs_t::errormsg(int line, const char *source, const char* action, const ch
CRLF;
}
safe_snprintf(str,sizeof(str),"ERROR %s %s", action, object);
errorlog(str);
errormsg_inside=false;
}
/*****************************************************************************/
/* Error logging to NODE.LOG and DATA\ERROR.LOG function */
/*****************************************************************************/
void sbbs_t::errorlog(const char *text)
{
if(errorlog_inside) /* let's not go recursive on this puppy */
return;
errorlog_inside=1;
if(cfg.node_num>0) {
getnodedat(cfg.node_num,&thisnode,1);
if(thisnode.errors<UCHAR_MAX)
......@@ -306,10 +299,10 @@ void sbbs_t::errorlog(const char *text)
if(logfile_fp!=NULL) {
if(logcol!=1)
fprintf(logfile_fp,"\r\n");
fprintf(logfile_fp,"%!! %s\r\n",text);
fprintf(logfile_fp,"!! %s\r\n",str);
logcol=1;
fflush(logfile_fp);
}
errorlog_inside=0;
}
errormsg_inside=false;
}
......@@ -483,11 +483,9 @@ bool sbbs_t::logon()
}
if(node.status==NODE_INUSE && i!=cfg.node_num && node.useron==useron.number
&& !SYSOP && !(useron.exempt&FLAG('G'))) {
strcpy(tmp,"On two nodes at the same time");
sprintf(str,"(%04u) %-25s %s"
,useron.number,useron.alias,tmp);
SAFEPRINTF2(str,"(%04u) %-25s On two nodes at the same time"
,useron.number,useron.alias);
logline(LOG_NOTICE,"+!",str);
errorlog(tmp);
bputs(text[UserOnTwoNodes]);
hangup();
return(false);
......
......@@ -2894,7 +2894,6 @@ sbbs_t::sbbs_t(ushort node_num, SOCKADDR_IN addr, const char* name, SOCKET sd,
event_time = 0;
event_code = nulstr;
nodesync_inside = false;
errorlog_inside = false;
errormsg_inside = false;
gettimeleft_inside = false;
timeleft = 60*10; /* just incase this is being used for calling gettimeleft() */
......
......@@ -728,7 +728,7 @@ bool sbbs_t::pack_qwk(char *packet, ulong *msgcnt, bool prepack)
if(i)
errormsg(WHERE,ERR_EXEC,cmdstr(temp_cmd(),packet,tmp2,NULL),i);
else
errorlog("Couldn't compress QWK packet");
lprintf(LOG_ERR, "Couldn't compress QWK packet");
return(false);
}
......
......@@ -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 2009 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 2011 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 *
......@@ -269,7 +269,7 @@ bool sbbs_t::pack_rep(uint hubnum)
if(i)
errormsg(WHERE,ERR_EXEC,cmdstr(cfg.qhub[hubnum]->pack,str,tmp2,NULL),i);
else
errorlog("Couldn't compress REP packet");
lprintf(LOG_ERR, "Couldn't compress REP packet");
return(false);
}
SAFEPRINTF2(str,"%sqnet/%s.out/",cfg.data_dir,hubid_lower);
......
......@@ -769,7 +769,7 @@ void sbbs_t::qwk_sec()
break;
if(k>=cfg.total_fextrs) {
bputs(text[QWKExtractionFailed]);
errorlog("Couldn't extract REP packet - configuration error");
lprintf(LOG_ERR, "Couldn't extract REP packet - configuration error");
continue;
}
......
......@@ -388,9 +388,8 @@ bool sbbs_t::qwk_import_msg(FILE *qwk_fp, char *hdrblk, ulong blocks
set_qwk_flag(QWK_VIA);
if(route_circ(p,cfg.sys_id)) {
bprintf("\r\nCircular message path: %s\r\n",p);
SAFEPRINTF2(str,"Circular message path: %s from %s"
lprintf(LOG_ERR,"Circular message path: %s from %s"
,p,fromhub ? cfg.qhub[fromhub-1]->id:useron.alias);
errorlog(str);
strListFree(&kludges);
free(body);
free(tail);
......
......@@ -724,11 +724,10 @@ public:
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 */
bool errorlog_inside;
bool errormsg_inside;
void errormsg(int line, const char *file, const char* action, const char *object
,ulong access, const char *extinfo=NULL);
BOOL hacklog(char* prot, char* text);
/* qwk.cpp */
bool qwklogon;
......
......@@ -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 2010 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 2011 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 *
......@@ -111,17 +111,15 @@ void sbbs_t::temp_xfer()
case 'A': /* add to temp file */
if(!isdir(cfg.temp_dir)) {
bprintf(text[DirectoryDoesNotExist], cfg.temp_dir);
SAFEPRINTF(str,"Temp directory does not exist: %s", cfg.temp_dir);
errorlog(str);
lprintf(LOG_ERR,"Temp directory does not exist: %s", cfg.temp_dir);
break;
}
/* free disk space */
space=getfreediskspace(cfg.temp_dir,1024);
if(space<(ulong)cfg.min_dspace) {
bputs(text[LowDiskSpace]);
SAFEPRINTF2(str,"Diskspace is low: %s (%lu kilobytes)"
lprintf(LOG_ERR,"Diskspace is low: %s (%lu kilobytes)"
,cfg.temp_dir,space);
errorlog(str);
if(!dir_op(dirnum))
break;
}
......@@ -303,8 +301,7 @@ void sbbs_t::extract(uint dirnum)
if(!isdir(cfg.temp_dir)) {
bprintf(text[DirectoryDoesNotExist], cfg.temp_dir);
SAFEPRINTF(str,"Temp directory does not exist: %s", cfg.temp_dir);
errorlog(str);
lprintf(LOG_ERR,"Temp directory does not exist: %s", cfg.temp_dir);
return;
}
......@@ -312,8 +309,7 @@ void sbbs_t::extract(uint dirnum)
space=getfreediskspace(cfg.temp_dir,1024);
if(space<(ulong)cfg.min_dspace) {
bputs(text[LowDiskSpace]);
SAFEPRINTF2(str,"Diskspace is low: %s (%lu kilobytes)",cfg.temp_dir,space);
errorlog(str);
lprintf(LOG_ERR,"Diskspace is low: %s (%lu kilobytes)",cfg.temp_dir,space);
if(!dir_op(dirnum))
return;
}
......
......@@ -84,8 +84,7 @@ bool sbbs_t::unpack_qwk(char *packet,uint hubnum)
}
SAFEPRINTF(str,"%sMESSAGES.DAT",cfg.temp_dir);
if(!fexistcase(str)) {
SAFEPRINTF2(tmp,"%s doesn't contain MESSAGES.DAT (%s)",packet,str);
errorlog(tmp);
lprintf(LOG_WARNING,"%s doesn't contain MESSAGES.DAT (%s)",packet,str);
return(false);
}
if((qwk=fnopen(&file,str,O_RDONLY))==NULL) {
......
......@@ -287,8 +287,7 @@ bool sbbs_t::upload(uint dirnum)
if(!isdir(path)) {
bprintf(text[DirectoryDoesNotExist], path);
SAFEPRINTF(str,"File directory does not exist: %s", path);
errorlog(str);
lprintf(LOG_ERR,"File directory does not exist: %s", path);
return(false);
}
......@@ -296,8 +295,7 @@ bool sbbs_t::upload(uint dirnum)
space=getfreediskspace(path,1024);
if(space<(ulong)cfg.min_dspace) {
bputs(text[LowDiskSpace]);
sprintf(str,"Diskspace is low: %s (%lu kilobytes)",path,space);
errorlog(str);
lprintf(LOG_ERR,"Diskspace is low: %s (%lu kilobytes)",path,space);
if(!dir_op(dirnum))
return(false);
}
......
......@@ -907,16 +907,16 @@ int sbbs_t::external(const char* cmdline, long mode, const char* startup_dir)
if(mode&EX_WWIV) {
bp=wwiv_expand(buf, rd, wwiv_buf, rd, useron.misc, wwiv_flag);
if(rd>sizeof(wwiv_buf))
errorlog("WWIV_BUF OVERRUN");
lprintf(LOG_ERR,"WWIV_BUF OVERRUN");
} else if(telnet_mode&TELNET_MODE_OFF) {
bp=buf;
} else {
bp=telnet_expand(buf, rd, telnet_buf, rd);
if(rd>sizeof(telnet_buf))
errorlog("TELNET_BUF OVERRUN");
lprintf(LOG_ERR,"TELNET_BUF OVERRUN");
}
if(rd>RingBufFree(&outbuf)) {
errorlog("output buffer overflow");
lprintf(LOG_ERR,"output buffer overflow");
rd=RingBufFree(&outbuf);
}
RingBufWrite(&outbuf, bp, rd);
......@@ -974,16 +974,16 @@ int sbbs_t::external(const char* cmdline, long mode, const char* startup_dir)
if(mode&EX_WWIV) {
bp=wwiv_expand(buf, rd, wwiv_buf, rd, useron.misc, wwiv_flag);
if(rd>sizeof(wwiv_buf))
errorlog("WWIV_BUF OVERRUN");
lprintf(LOG_ERR,"WWIV_BUF OVERRUN");
} else if(telnet_mode&TELNET_MODE_OFF) {
bp=buf;
} else {
bp=telnet_expand(buf, rd, telnet_buf, rd);
if(rd>sizeof(telnet_buf))
errorlog("TELNET_BUF OVERRUN");
lprintf(LOG_ERR,"TELNET_BUF OVERRUN");
}
if(rd>RingBufFree(&outbuf)) {
errorlog("output buffer overflow");
lprintf(LOG_ERR,"output buffer overflow");
rd=RingBufFree(&outbuf);
}
RingBufWrite(&outbuf, bp, rd);
......@@ -1781,8 +1781,7 @@ int sbbs_t::external(const char* cmdline, long mode, const char* startup_dir)
#endif
execvp(argv[0],argv);
sprintf(str,"!ERROR %d executing %s",errno,argv[0]);
errorlog(str);
lprintf(LOG_ERR,"Node %d !ERROR %d executing %s",cfg.node_num,errno,argv[0]);
_exit(-1); /* should never get here */
}
......@@ -1907,13 +1906,13 @@ int sbbs_t::external(const char* cmdline, long mode, const char* startup_dir)
/* Did expansion overrun the output buffer? */
if(output_len>sizeof(output_buf)) {
errorlog("OUTPUT_BUF OVERRUN");
lprintf(LOG_ERR,"OUTPUT_BUF OVERRUN");
output_len=sizeof(output_buf);
}
/* Does expanded size fit in the ring buffer? */
if(output_len>RingBufFree(&outbuf)) {
errorlog("output buffer overflow");
lprintf(LOG_ERR,"output buffer overflow");
output_len=RingBufFree(&outbuf);
}
......
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