Commit a2f5990b authored by Rob Swindell's avatar Rob Swindell 💬

Don't allow invalid netmail-forwarding addresses

Don't prompt a new user to forward email to their netmail address if they
provided an invalid netmail address (not supported by the system).

If a sysop has an invalid netmail address setup for forwarding, don't try to
forward email (or new user feedback) to that address.

Re-ordered the new user terminal questions a little bit (ask for the backspace
key first, to get earlier manual PETSCII detection). I'm not sure why I was
enabling AUTOTERM along with PETSCII before. Removed that as PETSCII cannot
be auto-detected.
parent 351cf95a
Pipeline #109 passed with stage
in 10 minutes and 33 seconds
......@@ -91,11 +91,15 @@ bool sbbs_t::email(int usernumber, const char *top, const char *subj, long mode,
bputs(text[UnknownUser]);
return(false);
}
if((l&NETMAIL) && (cfg.sys_misc&SM_FWDTONET) && !(mode & WM_NOFWD)) {
if((l&NETMAIL) && (cfg.sys_misc&SM_FWDTONET) && !(mode & WM_NOFWD) && !(useron.rest&FLAG('M'))) {
getuserrec(&cfg,usernumber,U_NETMAIL,LEN_NETMAIL,str);
bprintf(text[UserNetMail],str);
if((mode & WM_FORCEFWD) || text[ForwardMailQ][0]==0 || yesno(text[ForwardMailQ])) /* Forward to netmail address */
return(netmail(str, subj, mode, resmb, remsg));
if(is_supported_netmail_addr(&cfg, str)) {
bprintf(text[UserNetMail],str);
if((mode & WM_FORCEFWD) || yesno(text[ForwardMailQ])) /* Forward to netmail address */
return(netmail(str, subj, mode, resmb, remsg));
} else {
bprintf(text[InvalidNetMailAddr], str);
}
}
if(sys_status&SS_ABORT) {
bputs(text[Aborted]);
......
......@@ -1428,3 +1428,23 @@ bool sbbs_t::qnetmail(const char *into, const char *subj, long mode, smb_t* resm
logline("EN",str);
return(true);
}
extern "C" BOOL is_supported_netmail_addr(scfg_t* cfg, const char* addr)
{
switch (smb_netaddr_type(addr)) {
case NET_FIDO:
return INT_TO_BOOL(cfg->total_faddrs && (cfg->netmail_misc&NMAIL_ALLOW));
case NET_INTERNET:
return INT_TO_BOOL(cfg->inetmail_misc&NMAIL_ALLOW);
case NET_QWK:
{
char fulladdr[256] = "";
const char* p = strchr(addr, '@');
if(p == NULL)
return FALSE;
qwk_route(cfg, p + 1, fulladdr, sizeof(fulladdr)-1);
return fulladdr[0] != 0;
}
}
return FALSE;
}
......@@ -152,7 +152,26 @@ BOOL sbbs_t::newuser()
} else
useron.misc&=~AUTOTERM;
if(!(useron.misc&AUTOTERM)) {
while(text[HitYourBackspaceKey][0] && !(useron.misc&(PETSCII|SWAP_DELETE)) && online) {
bputs(text[HitYourBackspaceKey]);
uchar key = getkey(K_NONE);
bprintf(text[CharacterReceivedFmt], key, key);
if(key == '\b')
break;
if(key == DEL) {
if(text[SwapDeleteKeyQ][0] == 0 || yesno(text[SwapDeleteKeyQ]))
useron.misc |= SWAP_DELETE;
}
else if(key == PETSCII_DELETE)
useron.misc |= (PETSCII|COLOR);
else {
bprintf(text[InvalidBackspaceKeyFmt], key, key);
if(text[ContinueQ][0] && !yesno(text[ContinueQ]))
return FALSE;
}
}
if(!(useron.misc&(AUTOTERM|PETSCII))) {
if(text[AnsiTerminalQ][0] && yesno(text[AnsiTerminalQ]))
useron.misc|=ANSI;
else
......@@ -173,25 +192,6 @@ BOOL sbbs_t::newuser()
else
useron.rows = TERM_ROWS_DEFAULT;
while(text[HitYourBackspaceKey][0] && !(useron.misc&(PETSCII|SWAP_DELETE)) && online) {
bputs(text[HitYourBackspaceKey]);
uchar key = getkey(K_NONE);
bprintf(text[CharacterReceivedFmt], key, key);
if(key == '\b')
break;
if(key == DEL) {
if(text[SwapDeleteKeyQ][0] == 0 || yesno(text[SwapDeleteKeyQ]))
useron.misc |= SWAP_DELETE;
}
else if(key == PETSCII_DELETE)
useron.misc |= (AUTOTERM|PETSCII|COLOR);
else {
bprintf(text[InvalidBackspaceKeyFmt], key, key);
if(text[ContinueQ][0] && !yesno(text[ContinueQ]))
return FALSE;
}
}
if(useron.misc&PETSCII) {
autoterm |= PETSCII;
outcom(PETSCII_UPPERLOWER);
......@@ -328,10 +328,10 @@ BOOL sbbs_t::newuser()
&& !trashcan(useron.netmail,"email"))
break;
}
if(useron.netmail[0] && cfg.sys_misc&SM_FWDTONET && text[ForwardMailQ][0] && yesno(text[ForwardMailQ]))
useron.misc&=~NETMAIL;
if((cfg.sys_misc&SM_FWDTONET) && is_supported_netmail_addr(&cfg, useron.netmail) && yesno(text[ForwardMailQ]))
useron.misc|=NETMAIL;
else
useron.misc&=~NETMAIL;
if(text[UserInfoCorrectQ][0]==0 || yesno(text[UserInfoCorrectQ]))
break;
}
......
......@@ -1294,6 +1294,9 @@ extern "C" {
/* qwk.cpp */
DLLEXPORT int qwk_route(scfg_t*, const char *inaddr, char *fulladdr, size_t maxlen);
/* netmail.cpp */
DLLEXPORT BOOL is_supported_netmail_addr(scfg_t*, const char* addr);
/* con_out.cpp */
unsigned char cp437_to_petscii(unsigned char);
......
......@@ -1082,11 +1082,9 @@ void sbbs_t::maindflts(user_t* user)
if(sys_status&SS_ABORT)
break;
putuserrec(&cfg,user->number,U_NETMAIL,LEN_NETMAIL,user->netmail);
if(user->netmail[0] == 0 || noyes(text[ForwardMailQ]))
user->misc&=~NETMAIL;
else {
user->misc|=NETMAIL;
}
user->misc &= ~NETMAIL;
if(is_supported_netmail_addr(&cfg, user->netmail) && !noyes(text[ForwardMailQ]))
user->misc |= NETMAIL;
putuserrec(&cfg,user->number,U_MISC,8,ultoa(user->misc,str,16));
break;
case 'C':
......
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