看板Maple
标 题Re: [M3] 使用者资料回存的bug.
发信站清华资讯(枫桥驿站) (Sat Aug 31 16:21:54 2002)
转信站Ptt!news.cs.nthu!maple
※ 引述《[email protected] (轩水月明)》之铭言:
> 这个"bug"在各个M3版本中应该都是存在的,不过影响不大!
> 一般的, 用户登录进站时输入用户名、密码...然后是欢迎画面 ... 热门话题
> .. 主选单.
> 在录完密码后有 acct_load(&cuser, ...); 接下来检查一系列的权限,并把
> 上站次数加1,设定lasthost, ... 最后把资料回存到 .ACCT 档中,
> 然后进入主选单。
> 所以在资料回存到 .ACCT 档前的这小段时间若有用户登录多个窗口或被站长
> 强行改其资料则资料得不到保存。。:p
: bbsd.c:tn_login()
/* ------------------------------------------------- */
/* 将 .ACCT 写回 */
/* ------------------------------------------------- */
#if 1
/* Thor.990318: 为防止有大机率 有人在welcome画面回认证信, 故移至此 */
move(b_lines - 2, 0);
prints("欢迎您第 %d 度拜访本站,上次您来自 %s,\n我记得那天是 %s。",
cuser.numlogins, cuser.lasthost, Ctime(&cuser.lastlogin));
/* Thor.990321: 将vmsg移至後方, 防止有人在此时回认证信 */
#endif
cuser.lastlogin = start;
str_ncpy(cuser.lasthost, fromhost, sizeof(cuser.lasthost));
usr_fpath(fpath, cuser.userid, fn_acct);
- fd = open(fpath, O_WRONLY);
- write(fd, &cuser, sizeof(ACCT));
- close(fd);
+ if ((fd = open(fpath, O_RDWR)) >= 0)
+ {
+ ACCT tuser;
+ if (read(fd, &tuser, sizeof(ACCT)) == sizeof(ACCT))
+ {
/* itoc.010805.注解: 这次的写回 .ACCT 是为了让别人 Query 线上使用者时
出现的上站时间/来源正确,以及回存正确的 userlvel */
+ tuser.userlevel = cuser.userlevel;
+ tuser.lastlogin = start;
+ strcpy(tuser.lasthost, cuser.lasthost);
+ lseek(fd, (off_t) 0, SEEK_SET);
+ write(fd, &tuser, sizeof(ACCT));
+ }
+ close(fd);
+ }
#if 1
vmsg(NULL); /* Thor.990321: 将vmsg移至後方, 防止有人在此时回认证信 */
#endif
--
Maple 3.02 的话,会有停留在欢迎画面时改 userlevel 的问题
--
※ Origin: 枫桥驿站<bbs.cs.nthu.edu.tw> ◆ From: itoc.Dorm-GD2.NCTU.edu.tw