看板Maple
标 题Re: [M3] ㄏみ者戈挟l^存的bug.
发信站明月水轩BBS (Fri May 16 09:04:31 2003)
转信站Ptt!news.cs.nthu!news.neu.edu.cn!hightman
※ 引述《[email protected] (Query M3)》之铭言:
> 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);
这样似乎不够,要写回的应该还包括:
tuser.numlogins = cuser.numlogins;
tuser.ufo = cuser.ufo;
tuser.tcheck = cuser.tcheck;
tuser.tvalid = cuser.tvalid;
> + lseek(fd, (off_t) 0, SEEK_SET);
> + write(fd, &tuser, sizeof(ACCT));
> + }
> + close(fd);
--
※ Origin: 明月水轩 <bbs.hightman.net>
◆ From: 192.168.3.1