看板Maple
标 题[M3] 粮淊艇溹超祟皇p酊杠ug(非根治)
发信站明月水轩BBS (Sat May 24 00:10:55 2003)
转信站Ptt!news.cs.nthu!news.neu.edu.cn!hightman
这段时间,小站上又出现了不少超级隐身,感觉真的很奇怪。
想来想去,只有可能一个地方出问题,即 utmp_free() 弄错了。
具体原因尚不清楚,暂提供以下解决办法,欢迎指正:
1.
:: src/maple/cache.c ::
中的 utmp_free() 函数:
if (!uentp || !uentp->pid)
return;
#ifdef HAVE_SEM
sem_lock(BSEM_ENTER);
#endif
+ /* hightman.030522: 超隐会不会是这里 free 错了? :-p */
+ if (uentp->pid != currpid) {
+ UTMP *uceil;
+ uentp = ushm->uslot;
+ uceil = (void *) uentp + ushm->offset;
+ do {
+ /* 找到了? 如果没找到那会到哪去了呢? */
+ if (uentp->pid == currpid)
+ break;
+ } while (++uentp <= uceil);
+ }
+ if (uentp->pid == currpid) {
uentp->pid = uentp->userno = 0;
ushm->count--;
+ }
#ifdef HAVE_SEM
sem_lock(BSEM_LEAVE);
#endif
...
2. 为用户提供 utmp_restore() ,在utmp_free() 函数后增加以下函数
/* hightman.030522: 简易解决超级隐身 */
void utmp_restore()
{
if (cutmp->pid == currpid) return;
if (!str_cmp(cuser.userid, cutmp->userid)) { /* 还没被人占用 :p */
cutmp->pid = currpid;
cutmp->userno = cuser.userno;
} else {
/* 被占用了, 只好 utmp_new 一个 */
UTMP utmp;
utmp.pid = currpid;
utmp.userno = cuser.userno;
utmp.mode = bbsmode;
//utmp.in_addr = tn_addr;
utmp.ufo = cuser.ufo;
strcpy(utmp.userid, cuser.userid);
strcpy(utmp.username, cuser.username);
str_ncpy(utmp.from, fromhost, sizeof(utmp.from) - 1);
cutmp = NULL;
if (!utmp_new(&utmp)) {
move(b_lines, 0);
outs("非常不幸,您必须断线!");
abort_bbs();
return;
}
}
ushm->count++;
return;
}
3.
不过我想,如果 utmp_free() 按照上文改法作过修改后应当不需要再用
utmp_restore()了,也放上去的话保险一点。:)
在 visio.c 中的 igetch() 函数中增加以下字句:
...
data = vi_pool;
nfds = 0;
+ /* hightman.030522: 临时解决超隐问题 */
+ if (cutmp != NULL && cutmp->pid != currpid)
+ {
+ utmp_restore();
+ }
...
--
※ Origin: 明月水轩 <bbs.hightman.net>
◆ From: 192.168.3.1