From b35a990762235eed48028d81d6f8818b714aa54f Mon Sep 17 00:00:00 2001 From: Rob Swindell <rob@synchro.net> Date: Fri, 4 Feb 2022 22:29:00 -0800 Subject: [PATCH] O-restriction forces sent netmail to come from user's alias too Users with the 'O' restriction (automatically set if a new user has the same "real name" as another account, and that's allowed by the sysop) will send netmail from their alias and not their real name to prevent impersonation of another user. --- src/sbbs3/atcodes.cpp | 2 +- src/sbbs3/js_user.c | 2 +- src/sbbs3/netmail.cpp | 10 +++++----- src/sbbs3/newuser.cpp | 2 +- src/sbbs3/scfg/scfgnet.c | 6 ++++++ 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/sbbs3/atcodes.cpp b/src/sbbs3/atcodes.cpp index bbef715a31..e986ea7e95 100644 --- a/src/sbbs3/atcodes.cpp +++ b/src/sbbs3/atcodes.cpp @@ -536,7 +536,7 @@ const char* sbbs_t::atcode(char* sp, char* str, size_t maxlen, long* pmode, bool if(!strcmp(sp,"EMAILADDR")) return(usermailaddr(&cfg, str - ,cfg.inetmail_misc&NMAIL_ALIAS ? useron.alias : useron.name)); + ,(cfg.inetmail_misc&NMAIL_ALIAS) || (useron.rest&FLAG('O')) ? useron.alias : useron.name)); if(strcmp(sp, "NETMAIL") == 0) return useron.netmail; diff --git a/src/sbbs3/js_user.c b/src/sbbs3/js_user.c index fc3ab8c314..4ad482bd10 100644 --- a/src/sbbs3/js_user.c +++ b/src/sbbs3/js_user.c @@ -181,7 +181,7 @@ static JSBool js_user_get(JSContext *cx, JSObject *obj, jsid id, jsval *vp) break; case USER_PROP_EMAIL: s=usermailaddr(scfg, tmp - ,scfg->inetmail_misc&NMAIL_ALIAS ? p->user->alias : p->user->name); + ,(scfg->inetmail_misc&NMAIL_ALIAS) || (p->user->rest&FLAG('O')) ? p->user->alias : p->user->name); break; case USER_PROP_ADDRESS: s=p->user->address; diff --git a/src/sbbs3/netmail.cpp b/src/sbbs3/netmail.cpp index dfd4ca7ae5..095c7bf26e 100644 --- a/src/sbbs3/netmail.cpp +++ b/src/sbbs3/netmail.cpp @@ -154,7 +154,7 @@ bool sbbs_t::netmail(const char *into, const char *title, long mode, smb_t* resm truncsp(to); /* Truncate off space */ - SAFECOPY(from, cfg.netmail_misc&NMAIL_ALIAS ? useron.alias : useron.name); + SAFECOPY(from, (cfg.netmail_misc&NMAIL_ALIAS) || (useron.rest&FLAG('O')) ? useron.alias : useron.name); /* Look-up in nodelist? */ @@ -620,7 +620,7 @@ void sbbs_t::qwktonetmail(FILE *rep, char *block, char *into, uchar fromhub) smb_hfield(&msg,RECIPIENTNETADDR,strlen(to),to); bprintf(text[NetMailing],name,to - ,cfg.inetmail_misc&NMAIL_ALIAS ? useron.alias : useron.name + ,(cfg.inetmail_misc&NMAIL_ALIAS) || (useron.rest&FLAG('O')) ? useron.alias : useron.name ,cfg.sys_inetaddr); } @@ -770,7 +770,7 @@ void sbbs_t::qwktonetmail(FILE *rep, char *block, char *into, uchar fromhub) strcat(str,tmp); } else - SAFECOPY(str,cfg.netmail_misc&NMAIL_ALIAS ? useron.alias : useron.name); + SAFECOPY(str,(cfg.netmail_misc&NMAIL_ALIAS) || (useron.rest&FLAG('O')) ? useron.alias : useron.name); SAFECOPY(hdr.from,str); SAFECOPY(hdr.to,to); @@ -992,7 +992,7 @@ bool sbbs_t::inetmail(const char *into, const char *subj, long mode, smb_t* resm /* Get this user's Internet mailing address */ usermailaddr(&cfg,your_addr - ,cfg.inetmail_misc&NMAIL_ALIAS ? useron.alias : useron.name); + ,(cfg.inetmail_misc&NMAIL_ALIAS) || (useron.rest&FLAG('O')) ? useron.alias : useron.name); if(rcpt_count > 1) { /* remove "self" from reply-all list */ int found = strListFind(rcpt_list, your_addr, /* case_sensitive */FALSE); @@ -1141,7 +1141,7 @@ bool sbbs_t::inetmail(const char *into, const char *subj, long mode, smb_t* resm if(rcpt_count > 1) smb_hfield_str(&msg, RECIPIENTLIST, to_list); - smb_hfield_str(&msg,SENDER,cfg.inetmail_misc&NMAIL_ALIAS ? useron.alias : useron.name); + smb_hfield_str(&msg,SENDER,(cfg.inetmail_misc&NMAIL_ALIAS) || (useron.rest&FLAG('O')) ? useron.alias : useron.name); SAFEPRINTF(str,"%u",useron.number); smb_hfield_str(&msg,SENDEREXT,str); diff --git a/src/sbbs3/newuser.cpp b/src/sbbs3/newuser.cpp index b0518765fb..9b4c60ecbd 100644 --- a/src/sbbs3/newuser.cpp +++ b/src/sbbs3/newuser.cpp @@ -236,7 +236,7 @@ BOOL sbbs_t::newuser() if(!useron.name[0]) SAFECOPY(useron.name,useron.alias); else if(!(cfg.uq&UQ_DUPREAL) && userdatdupe(useron.number,U_NAME,LEN_NAME,useron.name) > 0) - useron.rest |= FLAG('O'); // Can't post using real name (it's a duplicate) + useron.rest |= FLAG('O'); // Can't post or send netmail using real name (it's a duplicate) if(!online) return(FALSE); if(!useron.handle[0]) SAFECOPY(useron.handle,useron.alias); diff --git a/src/sbbs3/scfg/scfgnet.c b/src/sbbs3/scfg/scfgnet.c index 149ed46205..53d4eaa13a 100644 --- a/src/sbbs3/scfg/scfgnet.c +++ b/src/sbbs3/scfg/scfgnet.c @@ -506,6 +506,9 @@ void net_cfg() "contain their alias as the `From User`, set this option to `Yes`. If you\n" "want all NetMail to be sent using users' real names, set this option to\n" "`No`.\n" + "\n" + "Users with the '`O`' restriction flag will always send netmail using\n" + "their alias (their real name is a duplicate of another user account)." ; i=uifc.list(WIN_MID|WIN_SAV,0,0,0,&i,0 ,"Use Aliases in NetMail",uifcYesNoOpts); @@ -752,6 +755,9 @@ void net_cfg() "Internet E-mail contain their alias as the `From User`, set this option to\n" "`Yes`. If you want all E-mail to be sent using users' real names, set this\n" "option to `No`.\n" + "\n" + "Users with the '`O`' restriction flag will always send netmail using\n" + "their alias (their real name is a duplicate of another user account)." ; i=uifc.list(WIN_MID|WIN_SAV,0,0,0,&i,0 ,"Use Aliases in Internet E-mail",uifcYesNoOpts); -- GitLab