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 f78ff5f9 authored by rswindell's avatar rswindell

Don't add .sig file to messages posted or emailed anonymously (duh!).

writemsg() now handles the anonymous name in the drop files (using WM_ANON
for the first time?).
A little mixed-case NETMAIL.MSG paranoia (for case-sensitive file systems).
More use of SAFEPRINTF().
More use of removecase().
More attribute flags represented (with a single character) in the 'A' column
of mail and sub-board message listings.
parent 836e8888
......@@ -48,6 +48,7 @@ bool sbbs_t::bulkmail(uchar *ar)
int i,j,x;
long msgs=0;
long length;
long wm_mode=WM_EMAIL;
FILE* fp;
smb_t smb;
smbmsg_t msg;
......@@ -60,12 +61,14 @@ bool sbbs_t::bulkmail(uchar *ar)
nodesync();
if(cfg.sys_misc&SM_ANON_EM && useron.exempt&FLAG('A')
&& !noyes(text[AnonymousQ]))
&& !noyes(text[AnonymousQ])) {
msg.hdr.attr|=MSG_ANONYMOUS;
wm_mode|=WM_ANON;
}
msg_tmp_fname(useron.xedit, msgpath, sizeof(msgpath));
if(!writemsg(msgpath,nulstr,title,WM_EMAIL,INVALID_SUB,"Bulk Mailing"
,/* From: */msg.hdr.attr&MSG_ANONYMOUS ? text[Anonymous] : useron.alias
if(!writemsg(msgpath,nulstr,title,wm_mode,INVALID_SUB,"Bulk Mailing"
,/* From: */useron.alias
,&editor)) {
bputs(text[Aborted]);
return(false);
......
......@@ -107,8 +107,10 @@ bool sbbs_t::email(int usernumber, const char *top, const char *subj, long mode)
}
if(cfg.sys_misc&SM_ANON_EM && useron.exempt&FLAG('A')
&& !noyes(text[AnonymousQ]))
&& !noyes(text[AnonymousQ])) {
msgattr|=MSG_ANONYMOUS;
mode|=WM_ANON;
}
if(cfg.sys_misc&SM_DELREADM)
msgattr|=MSG_KILLREAD;
......
......@@ -213,7 +213,7 @@ bool sbbs_t::netmail(const char *into, const char *title, long mode)
if(cfg.netmail_misc&NMAIL_KILL) hdr.attr|=FIDO_KILLSENT;
if(mode&WM_FILE) hdr.attr|=FIDO_FILE;
sprintf(str,"%sNETMAIL.MSG", cfg.node_dir);
SAFEPRINTF(str,"%snetmail.msg", cfg.node_dir);
removecase(str); /* Just incase it's already there */
// mode&=~WM_FILE;
if(!writemsg(str,nulstr,subj,WM_NETMAIL|mode,INVALID_SUB,into,hdr.from)) {
......@@ -298,7 +298,8 @@ bool sbbs_t::netmail(const char *into, const char *title, long mode)
SAFECOPY(hdr.subj,p);
sprintf(str,"%sNETMAIL.MSG", cfg.node_dir);
SAFEPRINTF(str,"%snetmail.msg", cfg.node_dir);
fexistcase(str);
if((file=nopen(str,O_RDONLY))==-1) {
errormsg(WHERE,ERR_OPEN,str,O_RDONLY);
return(false);
......
......@@ -96,10 +96,8 @@ bool sbbs_t::inetmail(const char *into, const char *subj, long mode)
action=NODE_SMAL;
nodesync();
sprintf(msgpath,"%snetmail.msg",cfg.node_dir);
if(!writemsg(msgpath,nulstr,title,mode,INVALID_SUB,into
,/* from: */cfg.inetmail_misc&NMAIL_ALIAS ? useron.alias : useron.name
,&editor)) {
SAFEPRINTF(msgpath,"%snetmail.msg",cfg.node_dir);
if(!writemsg(msgpath,nulstr,title,mode,INVALID_SUB,into,/* from: */your_addr,&editor)) {
bputs(text[Aborted]);
return(false);
}
......@@ -352,7 +350,7 @@ bool sbbs_t::qnetmail(const char *into, const char *subj, long mode)
action=NODE_SMAL;
nodesync();
sprintf(msgpath,"%snetmail.msg",cfg.node_dir);
SAFEPRINTF(msgpath,"%snetmail.msg",cfg.node_dir);
if(!writemsg(msgpath,nulstr,title,mode|WM_QWKNET,INVALID_SUB,to,/* from: */useron.alias,&editor)) {
bputs(text[Aborted]);
return(false);
......
......@@ -214,8 +214,10 @@ bool sbbs_t::postmsg(uint subnum, smbmsg_t *remsg, long wm_mode)
if(cfg.sub[subnum]->misc&SUB_AONLY
|| (cfg.sub[subnum]->misc&SUB_ANON && useron.exempt&FLAG('A')
&& !noyes(text[AnonymousQ])))
&& !noyes(text[AnonymousQ]))) {
msgattr|=MSG_ANONYMOUS;
wm_mode|=WM_ANON;
}
if(cfg.sub[subnum]->mod_ar[0] && chk_ar(cfg.sub[subnum]->mod_ar,&useron,&client))
msgattr|=MSG_MODERATED;
......@@ -233,7 +235,7 @@ bool sbbs_t::postmsg(uint subnum, smbmsg_t *remsg, long wm_mode)
msg_tmp_fname(useron.xedit, str, sizeof(str));
if(!writemsg(str,top,title,wm_mode,subnum,touser
,/* from: */msgattr&MSG_ANONYMOUS ? text[Anonymous] : cfg.sub[subnum]->misc&SUB_NAME ? useron.name : useron.alias
,/* from: */cfg.sub[subnum]->misc&SUB_NAME ? useron.name : useron.alias
,&editor)
|| (length=(long)flength(str))<1) { /* Bugfix Aug-20-2003: Reject negative length */
bputs(text[Aborted]);
......
......@@ -37,6 +37,20 @@
#include "sbbs.h"
static char mail_listing_flag(smbmsg_t* msg)
{
if(msg->hdr.attr&MSG_DELETE) return '-';
if(msg->hdr.attr&MSG_REPLIED) return 'R';
if(msg->hdr.attr&MSG_READ) return ' ';
if(msg->hdr.attr&MSG_PERMANENT) return 'p';
if(msg->hdr.attr&MSG_LOCKED) return 'L';
if(msg->hdr.attr&MSG_KILLREAD) return 'K';
if(msg->hdr.attr&MSG_NOREPLY) return '#';
if(msg->from_net.type || msg->to_net.type) return 'N';
if(msg->hdr.attr&MSG_ANONYMOUS) return 'A';
return '*';
}
/****************************************************************************/
/* Reads mail waiting for usernumber. */
/****************************************************************************/
......@@ -134,9 +148,7 @@ void sbbs_t::readmail(uint usernumber, int which)
,which==MAIL_SENT ? msg.to
: (msg.hdr.attr&MSG_ANONYMOUS) && !SYSOP ? text[Anonymous]
: msg.from
,msg.hdr.attr&MSG_DELETE ? '-' : msg.hdr.attr&MSG_REPLIED ? 'R'
: msg.hdr.attr&MSG_READ ? ' '
: msg.from_net.type || msg.to_net.type ? 'N':'*'
,mail_listing_flag(&msg)
,msg.subj);
smb_freemsgmem(&msg);
msg.total_hfields=0;
......@@ -543,18 +555,14 @@ void sbbs_t::readmail(uint usernumber, int which)
if(which==MAIL_ALL)
bprintf(text[MailOnSystemLstFmt]
,u+1,msg.from,msg.to
,msg.hdr.attr&MSG_DELETE ? '-' : msg.hdr.attr&MSG_REPLIED ? 'R'
: msg.hdr.attr&MSG_READ ? ' '
: msg.from_net.type || msg.to_net.type ? 'N':'*'
,mail_listing_flag(&msg)
,msg.subj);
else
bprintf(text[MailWaitingLstFmt],u+1
,which==MAIL_SENT ? msg.to
: (msg.hdr.attr&MSG_ANONYMOUS) && !SYSOP
? text[Anonymous] : msg.from
,msg.hdr.attr&MSG_DELETE ? '-' : msg.hdr.attr&MSG_REPLIED ? 'R'
: msg.hdr.attr&MSG_READ ? ' '
: msg.from_net.type || msg.to_net.type ? 'N':'*'
,mail_listing_flag(&msg)
,msg.subj);
smb_freemsgmem(&msg);
msg.total_hfields=0;
......@@ -716,18 +724,14 @@ void sbbs_t::readmail(uint usernumber, int which)
if(which==MAIL_ALL)
bprintf(text[MailOnSystemLstFmt]
,u+1,msg.from,msg.to
,msg.hdr.attr&MSG_DELETE ? '-' : msg.hdr.attr&MSG_REPLIED ? 'R'
: msg.hdr.attr&MSG_READ ? ' '
: msg.from_net.type || msg.to_net.type ? 'N':'*'
,mail_listing_flag(&msg)
,msg.subj);
else
bprintf(text[MailWaitingLstFmt],u+1
,which==MAIL_SENT ? msg.to
: (msg.hdr.attr&MSG_ANONYMOUS) && !SYSOP
? text[Anonymous] : msg.from
,msg.hdr.attr&MSG_DELETE ? '-' : msg.hdr.attr&MSG_REPLIED ? 'R'
: msg.hdr.attr&MSG_READ ? ' '
: msg.from_net.type || msg.to_net.type ? 'N':'*'
,mail_listing_flag(&msg)
,msg.subj);
smb_freemsgmem(&msg);
msg.total_hfields=0;
......
......@@ -42,10 +42,23 @@ int sbbs_t::sub_op(uint subnum)
return(is_user_subop(&cfg, subnum, &useron, &client));
}
char sbbs_t::msg_listing_flag(uint subnum, smbmsg_t* msg)
{
if(msg->hdr.attr&MSG_DELETE) return '-';
if((stricmp(msg->to,useron.alias)==0 || stricmp(msg->to,useron.name)==0)
&& !(msg->hdr.attr&MSG_READ)) return '!';
if(msg->hdr.attr&MSG_PERMANENT) return 'p';
if(msg->hdr.attr&MSG_LOCKED) return 'L';
if(msg->hdr.attr&MSG_KILLREAD) return 'K';
if(msg->hdr.attr&MSG_NOREPLY) return 'r';
if(msg->hdr.number > subscan[subnum].ptr) return '*';
if(msg->hdr.attr&MSG_PRIVATE) return 'P';
if(sub_op(subnum) && msg->hdr.attr&MSG_ANONYMOUS) return 'A';
return ' ';
}
long sbbs_t::listmsgs(uint subnum, long mode, post_t *post, long i, long posts)
{
char ch;
smbmsg_t msg;
long listed=0;
......@@ -58,20 +71,11 @@ long sbbs_t::listmsgs(uint subnum, long mode, post_t *post, long i, long posts)
smb_unlockmsghdr(&smb,&msg);
if(listed==0)
bputs(text[MailOnSystemLstHdr]);
if(msg.hdr.attr&MSG_DELETE)
ch='-';
else if((!stricmp(msg.to,useron.alias) || !stricmp(msg.to,useron.name))
&& !(msg.hdr.attr&MSG_READ))
ch='!';
else if(msg.hdr.number>subscan[subnum].ptr)
ch='*';
else
ch=' ';
bprintf(text[SubMsgLstFmt],post[i].num
,msg.hdr.attr&MSG_ANONYMOUS && !sub_op(subnum)
? text[Anonymous] : msg.from
,msg.to
,ch
,msg_listing_flag(subnum, &msg)
,msg.subj);
smb_freemsgmem(&msg);
msg.total_hfields=0;
......@@ -974,12 +978,12 @@ int sbbs_t::scanposts(uint subnum, long mode, const char *find)
break;
case 'Y': /* Your messages */
domsg=0;
if(!showposts_toyou(post,0,smb.msgs))
if(!showposts_toyou(subnum, post,0,smb.msgs))
bputs(text[NoMessagesFound]);
break;
case 'U': /* Your unread messages */
domsg=0;
if(!showposts_toyou(post,0,smb.msgs, SCAN_UNREAD))
if(!showposts_toyou(subnum, post,0,smb.msgs, SCAN_UNREAD))
bputs(text[NoMessagesFound]);
break;
case '-':
......@@ -1295,7 +1299,7 @@ long sbbs_t::listsub(uint subnum, long mode, long start, const char* search)
long sbbs_t::searchposts(uint subnum, post_t *post, long start, long posts
, const char *search)
{
char* buf,ch;
char* buf;
char subj[128];
long l,found=0;
smbmsg_t msg;
......@@ -1318,20 +1322,11 @@ long sbbs_t::searchposts(uint subnum, post_t *post, long start, long posts
if(strstr(buf,search) || strstr(subj,search)) {
if(!found)
CRLF;
if(msg.hdr.attr&MSG_DELETE)
ch='-';
else if((!stricmp(msg.to,useron.alias) || !stricmp(msg.to,useron.name))
&& !(msg.hdr.attr&MSG_READ))
ch='!';
else if(msg.hdr.number>subscan[subnum].ptr)
ch='*';
else
ch=' ';
bprintf(text[SubMsgLstFmt],l+1
,(msg.hdr.attr&MSG_ANONYMOUS) && !sub_op(subnum) ? text[Anonymous]
: msg.from
,msg.to
,ch
,msg_listing_flag(subnum, &msg)
,msg.subj);
found++;
}
......@@ -1346,7 +1341,7 @@ long sbbs_t::searchposts(uint subnum, post_t *post, long start, long posts
/* Will search the messages pointed to by 'msg' for message to the user on */
/* Returns number of messages found. */
/****************************************************************************/
long sbbs_t::showposts_toyou(post_t *post, ulong start, long posts, long mode)
long sbbs_t::showposts_toyou(uint subnum, post_t *post, ulong start, long posts, long mode)
{
char str[128];
ushort namecrc,aliascrc,sysop;
......@@ -1386,7 +1381,7 @@ long sbbs_t::showposts_toyou(post_t *post, ulong start, long posts, long mode)
,(msg.hdr.attr&MSG_ANONYMOUS) && !SYSOP
? text[Anonymous] : msg.from
,msg.to
,msg.hdr.attr&MSG_DELETE ? '-' : msg.hdr.attr&MSG_READ ? ' ' : '*'
,msg_listing_flag(subnum, &msg)
,msg.subj);
}
}
......
......@@ -754,8 +754,9 @@ public:
long listsub(uint subnum, long mode, long start, const char* search);
long listmsgs(uint subnum, long mode, post_t* post, long start, long posts);
long searchposts(uint subnum, post_t* post, long start, long msgs, const char* find);
long showposts_toyou(post_t* post, ulong start, long posts, long mode=0);
long showposts_toyou(uint subnum, post_t* post, ulong start, long posts, long mode=0);
void msghdr(smbmsg_t* msg);
char msg_listing_flag(uint subnum, smbmsg_t*);
/* chat.cpp */
void chatsection(void);
......
......@@ -251,7 +251,7 @@ bool sbbs_t::writemsg(const char *fname, const char *top, char *subj, long mode,
free(buf);
return(false);
}
removecase(msgtmp);
if((file=nopen(msgtmp,O_WRONLY|O_CREAT|O_TRUNC))==-1) {
errormsg(WHERE,ERR_OPEN,msgtmp,O_WRONLY|O_CREAT|O_TRUNC);
free(buf);
......@@ -466,7 +466,7 @@ bool sbbs_t::writemsg(const char *fname, const char *top, char *subj, long mode,
editor_inf(useron_xedit,to,from,subj,mode,subnum,tagfile);
if(cfg.xedit[useron_xedit-1]->type) {
gettimeleft();
xtrndat(from,cfg.node_dir,cfg.xedit[useron_xedit-1]->type
xtrndat(mode&WM_ANON ? text[Anonymous]:from,cfg.node_dir,cfg.xedit[useron_xedit-1]->type
,timeleft,cfg.xedit[useron_xedit-1]->misc);
}
......@@ -552,6 +552,7 @@ bool sbbs_t::writemsg(const char *fname, const char *top, char *subj, long mode,
now=time(NULL);
bputs(text[Saving]);
removecase(fname);
if((stream=fnopen(NULL,fname,O_WRONLY|O_CREAT|O_TRUNC))==NULL) {
errormsg(WHERE,ERR_OPEN,fname,O_WRONLY|O_CREAT|O_TRUNC);
free(buf);
......@@ -559,13 +560,13 @@ bool sbbs_t::writemsg(const char *fname, const char *top, char *subj, long mode,
}
l=process_edited_text(buf,stream,mode,&lines,cfg.level_linespermsg[useron_level]);
if(!(mode&WM_EXTDESC)) {
if(!(mode&(WM_EXTDESC|WM_ANON))) {
/* Signature file */
if((subnum==INVALID_SUB && cfg.msg_misc&MM_EMAILSIG)
|| (subnum!=INVALID_SUB && !(cfg.sub[subnum]->misc&SUB_NOUSERSIG))) {
SAFEPRINTF2(str,"%suser/%04u.sig",cfg.data_dir,useron.number);
FILE* sig;
if(fexist(str) && (sig=fopen(str,"r"))!=NULL) {
if(fexistcase(str) && (sig=fopen(str,"r"))!=NULL) {
while(!feof(sig)) {
if(!fgets(str,sizeof(str),sig))
break;
......@@ -613,22 +614,19 @@ void sbbs_t::editor_inf(int xeditnum, const char *to, const char* from, const ch
,uint subnum, const char* tagfile)
{
char path[MAX_PATH+1];
char fname[32];
FILE* fp;
xeditnum--;
if(cfg.xedit[xeditnum]->misc&QUICKBBS) {
strcpy(fname,"MSGINF");
if(cfg.xedit[xeditnum]->misc&XTRN_LWRCASE)
strlwr(fname);
SAFEPRINTF2(path,"%s%s",cfg.node_dir,fname);
SAFEPRINTF2(path,"%s%s",cfg.node_dir, cfg.xedit[xeditnum]->misc&XTRN_LWRCASE ? "msginf":"MSGINF");
removecase(path);
if((fp=fopen(path,"wb"))==NULL) {
errormsg(WHERE,ERR_OPEN,path,O_WRONLY|O_CREAT|O_TRUNC);
return;
}
fprintf(fp,"%s\r\n%s\r\n%s\r\n%u\r\n%s\r\n%s\r\n"
,from,to,subj,1
,mode&WM_ANON ? text[Anonymous]:from,to,subj,1
,mode&WM_NETMAIL ? "NetMail"
:mode&WM_EMAIL ? "Electronic Mail"
:subnum==INVALID_SUB ? nulstr
......@@ -641,12 +639,10 @@ void sbbs_t::editor_inf(int xeditnum, const char *to, const char* from, const ch
fclose(fp);
}
else {
SAFEPRINTF(path,"%sRESULT.ED",cfg.node_dir);
SAFEPRINTF(path,"%sresult.ed",cfg.node_dir);
removecase(path);
SAFEPRINTF2(path,"%s%s",cfg.node_dir,cfg.xedit[xeditnum]->misc&XTRN_LWRCASE ? "editor.inf" : "EDITOR.INF");
removecase(path);
strcpy(fname,"EDITOR.INF");
if(cfg.xedit[xeditnum]->misc&XTRN_LWRCASE)
strlwr(fname);
SAFEPRINTF2(path,"%s%s",cfg.node_dir,fname);
if((fp=fopen(path,"wb"))==NULL) {
errormsg(WHERE,ERR_OPEN,path,O_WRONLY|O_CREAT|O_TRUNC);
return;
......@@ -655,7 +651,7 @@ void sbbs_t::editor_inf(int xeditnum, const char *to, const char* from, const ch
,subj
,to
,useron.number
,from
,mode&WM_ANON ? text[Anonymous]:from
,useron.name
,useron.level);
fclose(fp);
......@@ -1051,7 +1047,7 @@ bool sbbs_t::editfile(char *fname, bool msg)
fcopy(path, msgtmp);
}
editor_inf(useron_xedit,/* to: */fname,/* from: */nulstr,/* subj: */nulstr,0,INVALID_SUB,/* tagfile: */NULL);
editor_inf(useron_xedit,/* to: */fname,/* from: */nulstr,/* subj: */nulstr,/* mode: */0,INVALID_SUB,/* tagfile: */NULL);
if(cfg.xedit[useron_xedit-1]->misc&XTRN_NATIVE)
mode|=EX_NATIVE;
if(cfg.xedit[useron_xedit-1]->misc&XTRN_SH)
......
......@@ -1704,14 +1704,11 @@ bool sbbs_t::exec_xtrn(uint xtrnnum)
sprintf(str,"%sINTRSBBS.DAT"
,cfg.xtrn[xtrnnum]->path[0] ? cfg.xtrn[xtrnnum]->path : cfg.node_dir);
if(fexistcase(str))
remove(str);
removecase(str);
sprintf(str,"%shangup.now",cfg.node_dir);
if(fexistcase(str))
remove(str);
removecase(str);
sprintf(str,"%sfile/%04u.dwn",cfg.data_dir,useron.number);
if(fexistcase(str))
remove(str);
removecase(str);
mode=0;
if(cfg.xtrn[xtrnnum]->misc&XTRN_SH)
......@@ -1722,8 +1719,8 @@ bool sbbs_t::exec_xtrn(uint xtrnnum)
mode|=EX_CONIO;
mode|=(cfg.xtrn[xtrnnum]->misc&(XTRN_CHKTIME|XTRN_NATIVE|XTRN_NOECHO|WWIVCOLOR));
if(cfg.xtrn[xtrnnum]->misc&MODUSERDAT) { /* Delete MODUSER.DAT */
sprintf(str,"%sMODUSER.DAT",dropdir); /* if for some weird */
remove(str); /* reason it's there */
SAFEPRINTF(str,"%sMODUSER.DAT",dropdir); /* if for some weird */
removecase(str); /* reason it's there */
}
start=time(NULL);
......@@ -1753,7 +1750,7 @@ bool sbbs_t::exec_xtrn(uint xtrnnum)
if(fexistcase(str)) {
lprintf(LOG_NOTICE,"Node %d External program requested hangup (%s signaled)"
,cfg.node_num, str);
remove(str);
removecase(str);
hangup();
}
else if(!online) {
......
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