Commit 67a769c3 authored by rswindell's avatar rswindell
Browse files

matchuser() now optionally matches built-in sysop aliases.

parent ac770821
......@@ -71,7 +71,7 @@ void sbbs_t::downloadfile(file_t* f)
/**************************/
/* Update Uploader's Info */
/**************************/
i=matchuser(&cfg,f->uler);
i=matchuser(&cfg,f->uler,TRUE /*sysop_alias*/);
uploader.number=i;
getuserdat(&cfg,&uploader);
if(i && i!=useron.number && uploader.firston<f->dateuled) {
......
......@@ -1405,7 +1405,7 @@ int sbbs_t::exec(csi_t *csi)
case USER_STRING_ALIAS:
if(!isalpha(csi->str[0]) || trashcan(csi->str,"name"))
break;
i=matchuser(&cfg,csi->str);
i=matchuser(&cfg,csi->str,TRUE /*sysop_alias*/);
if(i && i!=useron.number)
break;
sprintf(useron.alias,"%.*s",LEN_ALIAS,csi->str);
......
......@@ -994,7 +994,7 @@ int sbbs_t::exec_misc(csi_t* csi, char *path)
csi->ip+=4;
if(lp) {
if(pp && *pp)
*lp=matchuser(&cfg, *pp);
*lp=matchuser(&cfg, *pp, TRUE /*sysop_alias*/);
else
*lp=0;
}
......
......@@ -518,6 +518,7 @@ js_matchuser(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
char* p;
JSString* js_str;
scfg_t* cfg;
BOOL sysop_alias=TRUE;
if((cfg=(scfg_t*)JS_GetPrivate(cx,obj))==NULL)
return(JS_FALSE);
......@@ -527,12 +528,15 @@ js_matchuser(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
return(JS_TRUE);
}
if(argc>1)
sysop_alias=JSVAL_TO_BOOLEAN(argv[1]);
if((p=JS_GetStringBytes(js_str))==NULL) {
*rval = INT_TO_JSVAL(0);
return(JS_TRUE);
}
*rval = INT_TO_JSVAL(matchuser(cfg,p));
*rval = INT_TO_JSVAL(matchuser(cfg,p,sysop_alias));
return(JS_TRUE);
}
......
......@@ -491,7 +491,7 @@ bool sbbs_t::removefcdt(file_t* f)
int u;
long cdt;
if((u=matchuser(&cfg,f->uler))==0) {
if((u=matchuser(&cfg,f->uler,TRUE /*sysop_alias*/))==0) {
bputs(text[UnknownUser]);
return(false); }
cdt=0L;
......@@ -1079,7 +1079,7 @@ int sbbs_t::listfileinfo(uint dirnum, char *filespec, long mode)
if(noyes(text[RemoveCreditsQ]))
/* Fall through */ break; }
case 'C': /* remove credits only */
if((i=matchuser(&cfg,f.uler))==0) {
if((i=matchuser(&cfg,f.uler,TRUE /*sysop_alias*/))==0) {
bputs(text[UnknownUser]);
break; }
if(dir_op(dirnum)) {
......
......@@ -60,7 +60,7 @@ int sbbs_t::login(char *str, char *pw)
useron.number=0; }
if(!useron.number) {
useron.number=matchuser(&cfg,str);
useron.number=matchuser(&cfg,str,FALSE);
if(!useron.number && (uchar)str[0]<0x7f && str[1]
&& isalpha(str[0]) && strchr(str,SP) && cfg.node_misc&NM_LOGON_R)
useron.number=userdatdupe(0,U_NAME,LEN_NAME,str,0);
......
......@@ -202,7 +202,7 @@ void sbbs_t::telluser(smbmsg_t* msg)
if(msg->from_ext)
usernumber=atoi(msg->from_ext);
else {
usernumber=matchuser(&cfg,msg->from);
usernumber=matchuser(&cfg,msg->from,TRUE /*sysop_alias*/);
if(!usernumber)
return; }
for(n=1;n<=cfg.sys_nodes;n++) { /* Tell user */
......
......@@ -180,7 +180,8 @@ void sbbs_t::newuser()
if(useron.alias[0]<=SP || !isalpha(useron.alias[0])
|| !stricmp(useron.alias,cfg.sys_id)
|| strchr(useron.alias,0xff)
|| matchuser(&cfg,useron.alias) || trashcan(useron.alias,"name")
|| matchuser(&cfg,useron.alias,TRUE /* sysop_alias */)
|| trashcan(useron.alias,"name")
|| (!(cfg.uq&UQ_ALIASES) && !strchr(useron.alias,SP))) {
bputs(text[YouCantUseThatName]);
continue; }
......
......@@ -87,14 +87,14 @@ int sbbs_t::qwk_route(char *inaddr, char *fulladdr)
sprintf(node,"%.8s",p); /* node = destination node */
truncsp(node);
for(i=0;i<cfg.total_qhubs;i++) /* Check if destination is our hub */
for(i=0;i<cfg.total_qhubs;i++) /* Check if destination is our hub */
if(!stricmp(cfg.qhub[i]->id,node))
break;
if(i<cfg.total_qhubs) {
strcpy(fulladdr,node);
return(0); }
i=matchuser(&cfg,node); /* Check if destination is a node */
i=matchuser(&cfg,node,FALSE); /* Check if destination is a node */
if(i) {
getuserrec(&cfg,i,U_REST,8,str);
if(ahtoul(str)&FLAG('Q')) {
......@@ -115,7 +115,7 @@ int sbbs_t::qwk_route(char *inaddr, char *fulladdr)
strcpy(fulladdr,inaddr);
return(0); }
i=matchuser(&cfg,node); /* Check if next hop is a node */
i=matchuser(&cfg,node,FALSE); /* Check if next hop is a node */
if(i) {
getuserrec(&cfg,i,U_REST,8,str);
if(ahtoul(str)&FLAG('Q')) {
......@@ -155,7 +155,7 @@ int sbbs_t::qwk_route(char *inaddr, char *fulladdr)
if(i<cfg.total_qhubs)
return(0);
i=matchuser(&cfg,node); /* Check if first hop is a node */
i=matchuser(&cfg,node,FALSE); /* Check if first hop is a node */
if(i) {
getuserrec(&cfg,i,U_REST,8,str);
if(ahtoul(str)&FLAG('Q'))
......
......@@ -684,7 +684,7 @@ int sbbs_t::scanposts(uint subnum, long mode, char *find)
if(cfg.sub[subnum]->misc&SUB_NAME)
i=userdatdupe(0,U_NAME,LEN_NAME,str,0);
else
i=matchuser(&cfg,str); }
i=matchuser(&cfg,str,TRUE /* sysop_alias */); }
email(i,str2,msg.subj,WM_EMAIL|WM_QUOTE); } }
// post=loadposts(&posts,subnum,0,lp);
break;
......@@ -747,7 +747,7 @@ int sbbs_t::scanposts(uint subnum, long mode, char *find)
case 'P': /* Purge user */
purgeuser(cfg.sub[subnum]->misc&SUB_NAME
? userdatdupe(0,U_NAME,LEN_NAME,msg.from,0)
: matchuser(&cfg,msg.from));
: matchuser(&cfg,msg.from,FALSE));
break;
case 'C': /* Change message attributes */
i=chmsgattr(msg.hdr.attr);
......@@ -810,7 +810,7 @@ int sbbs_t::scanposts(uint subnum, long mode, char *find)
case 'U': /* User edit */
useredit(cfg.sub[subnum]->misc&SUB_NAME
? userdatdupe(0,U_NAME,LEN_NAME,msg.from,0)
: matchuser(&cfg,msg.from));
: matchuser(&cfg,msg.from,TRUE /* sysop_alias */));
break;
case 'V': /* Validate message */
if(msg.total_hfields)
......
......@@ -311,7 +311,7 @@ js_login(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
if(isdigit(*p))
user.number=atoi(p);
else
user.number=matchuser(&scfg,p);
user.number=matchuser(&scfg,p,FALSE);
if(getuserdat(&scfg,&user)!=0) {
lprintf("%04d %s !USER NOT FOUND: '%s'"
......
......@@ -116,12 +116,8 @@ bool sbbs_t::unpack_qwk(char *packet,uint hubnum)
j=atoi(str);
if(j && j>lastuser(&cfg))
j=0;
if(!j && !stricmp(str,"SYSOP"))
j=1;
if(!j)
j=matchuser(&cfg,str);
if(!j && !stricmp(str,cfg.sys_id))
j=1;
j=matchuser(&cfg,str,TRUE /* sysop_alias */);
if(!j) {
lprintf("!NetMail from %s to UNKNOWN USER: %s", cfg.qhub[hubnum]->id, str);
continue;
......
......@@ -151,13 +151,8 @@ bool sbbs_t::unpack_rep(char* repfile)
j=atoi(str);
if(j && j>lastuser(&cfg))
j=0;
if(!j &&
(!stricmp(str,"SYSOP")
|| !stricmp(str,cfg.sys_id)
|| !stricmp(str,cfg.sys_op)))
j=1;
if(!j)
j=matchuser(&cfg,str);
j=matchuser(&cfg,str,TRUE /* sysop_alias */);
if(!j) {
bputs(text[UnknownUser]);
continue; }
......
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