- 主题:怎么样限制SYSOP只从本机登陆??
我自己写了一段代码在main.c中
if((strcmp(uid,"SYSOP")==0) || (strcmp(uid,"sysop")==0))
{
if ((strcmp(uinfo.from,"127.0.0.1")==0)||(strcmp(uinfo.from,"localhost"))==0)
break;
else
{
prints(" %c[1;33;41m警告:本站SYSOP只能从主机登陆,如果你真是SYSOP,
请从主机登陆!%c[m \n",27,27);
oflush();
sleep( 1 );
exit( 1 );
}
}
问题有二,1.好像逻辑不太严密,对于用户输入sYsOP就可以绕过,但是如果排列
组合下来,SYSOP有10种可能?怎么样写比较简洁囊括或者有好的办法检测大小写?
2.好像这几行代码并没有实现我想要得功能,不管是否从主机登陆,只要输入的是
SYSOP或者sysop就必定退出.
uinfo.from这个结构体成员变量我是自己猜得,没有具体看定义,不知道怎么用
哪位能够指教一下?
--
FROM data.huawei.com
1. strcasecmp
2. uinfo.from可能还没有被初始化,用fromhost
【 在 HCNE.bbs@bbs.whnet.edu.cn (华为-3Com网络工程师) 的大作中提到: 】
: 我自己写了一段代码在main.c中
: if((strcmp(uid,"SYSOP")==0) || (strcmp(uid,"sysop")==0))
: {
: ...................
--
FROM 219.224.133.*
谢谢楼上这位,搞定
【 在 HCNE (华为-3Com网络工程师) 的大作中提到: 】
: 我自己写了一段代码在main.c中
: if((strcmp(uid,"SYSOP")==0) || (strcmp(uid,"sysop")==0))
: {
: if ((strcmp(uinfo.from,"127.0.0.1")==0)||(strcmp(uinfo.from,"localhost"))==0)
: break;
: else
: {
: prints(" %c[1;33;41m警告:本站SYSOP只能从主机登陆,如果你真是SYSOP,
: 请从主机登陆!%c[m \n",27,27);
: oflush();
: .................(以下省略)
--
FROM data.huawei.com
fb2k自带就有了吧?
【 在 HCNE.bbs@bbs.whnet.edu.cn (华为-3Com网络工程师) 的大作中提到: 】
: 我自己写了一段代码在main.c中
: if((strcmp(uid,"SYSOP")==0) || (strcmp(uid,"sysop")==0))
: {
: if ((strcmp(uinfo.from,"127.0.0.1")==0)||(strcmp(uinfo.from,"localhost"))==0)
: break;
: else
: {
: prints(" %c[1;33;41m警告:本站SYSOP只能从主机登陆,如果你真是SYSOP,
: 请从主机登陆!%c[m \n",27,27);
: oflush();
: .................(以下省略)
--
fbnt3.4里没有
我是这样写的
//main.c
if((strcasecmp(uid,"SYSOP")==0)&& (strcmp(fromhost,"127.0.0.1")!=0))
{
prints("\n");
prints(" %c[1;33;41m警告:本站SYSOP只能从主机登陆,如果你真是SYSOP,请从主
机登陆!%c[m \n",27,27);
prints(" %c[1;33;41m登陆主机以后使用 telnet localhost 23 登陆SYSOP
%c[m \n",27,27);
oflush();
sleep(1);
exit(1);
}
另外,我还修改了防止任何非sysop自身以外的用户修改SYSOP密码
if((strcasecmp(genbuf,"SYSOP")==0)
&& (strcasecmp(currentuser.userid,"SYSOP")!=0))
{
prints("\n");
prints("警告:本站出于安全防范SYSOP受保护,SYSOP资料非SYSOP自身不能修改!!!"
clrtoeol() ;
pressreturn() ;
clear() ;
return -1;
}
【 在 AM@TaoLiBBS.3322.ORG ( 冰蚀) 的大作中提到: 】
: fb2k 自带
就有了吧?: 【 在 HCNE.bbs@bbs.whnet.edu.cn (华为-3Com网络工程师) 的大作中提到:
】 : : 我自己写了一段代码在main.c中
: : if((strcmp(uid,"SYSOP")==0) || (strcmp(uid,"sysop")==0))
: : {
: : if ((strcmp(uinfo.from,"127.0.0.1")==0)||(strcmp(uinfo.from,"localhost"))==0)
: : break;
: : else
: : {
: : prints(" %c[1;33;41m警告:本站SYSOP只能从主机登陆,如果你真是SYSOP,
: .................(以下省略)
--
FROM data.huawei.com