Commit d3b05466 authored by rswindell's avatar rswindell
Browse files

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