summaryrefslogtreecommitdiffstats
path: root/mbbsd
diff options
context:
space:
mode:
authorptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-03-30 15:27:50 +0800
committerptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-03-30 15:27:50 +0800
commitf7580a82e730f46435f9ed3b28ad3d64794123a2 (patch)
tree53d2b969285997ed8bf4b29fe4dded56037edc12 /mbbsd
parentd5b5abdff83a61cd1f824556e7cd7bfddde70956 (diff)
downloadpttbbs-f7580a82e730f46435f9ed3b28ad3d64794123a2.tar
pttbbs-f7580a82e730f46435f9ed3b28ad3d64794123a2.tar.gz
pttbbs-f7580a82e730f46435f9ed3b28ad3d64794123a2.tar.bz2
pttbbs-f7580a82e730f46435f9ed3b28ad3d64794123a2.tar.lz
pttbbs-f7580a82e730f46435f9ed3b28ad3d64794123a2.tar.xz
pttbbs-f7580a82e730f46435f9ed3b28ad3d64794123a2.tar.zst
pttbbs-f7580a82e730f46435f9ed3b28ad3d64794123a2.zip
passwd update debug
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1636 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r--mbbsd/passwd.c3
-rw-r--r--mbbsd/register.c14
-rw-r--r--mbbsd/user.c18
3 files changed, 17 insertions, 18 deletions
diff --git a/mbbsd/passwd.c b/mbbsd/passwd.c
index 5cafc88e..e9c3ccb8 100644
--- a/mbbsd/passwd.c
+++ b/mbbsd/passwd.c
@@ -97,7 +97,7 @@ passwd_update(int num, userec_t * buf)
int pwdfd;
char path[256];
- sethomefile(path, getuserid(num), ".passwd");
+ sethomefile(path, buf->userid, ".passwd");
buf->money = moneyof(num);
if ((pwdfd = open(path, O_WRONLY|O_CREAT, 0600)) < 0)
exit(1);
@@ -126,6 +126,7 @@ passwd_query(int num, userec_t * buf)
int pwdfd;
char path[256];
+
sethomefile(path, getuserid(num), ".passwd");
if((pwdfd = open(path, O_RDONLY)) < 0)
{ // copy from index // tempory code, will be removed
diff --git a/mbbsd/register.c b/mbbsd/register.c
index afbd3ea2..0580e485 100644
--- a/mbbsd/register.c
+++ b/mbbsd/register.c
@@ -107,7 +107,6 @@ compute_user_value(userec_t * urec, time_t clock)
int
check_and_expire_account(int uid, userec_t * urec)
{
- userec_t zerorec;
char genbuf[200], genbuf2[200];
int val;
if ((val = compute_user_value(urec, now)) < 0) {
@@ -115,7 +114,6 @@ check_and_expire_account(int uid, userec_t * urec)
uid, urec->userid, ctime(&(urec->lastlogin)) + 4,
urec->numlogins, urec->numposts, val);
if (val > -1 * 60 * 24 * 365) {
- memset(&zerorec, 0, sizeof(zerorec));
log_usies("CLEAN", genbuf);
snprintf(genbuf, sizeof(genbuf), "home/%c/%s", urec->userid[0],
urec->userid);
@@ -126,9 +124,7 @@ check_and_expire_account(int uid, userec_t * urec)
urec->userid[0], urec->userid);
system(genbuf);
}
- passwd_index_update(uid, &zerorec);
- remove_from_uhash(uid - 1);
- add_to_uhash(uid - 1, "");
+ kill_user(uid);
} else {
val = 0;
log_usies("DATED", genbuf);
@@ -143,12 +139,11 @@ getnewuserid()
{
char genbuf[50];
char *fn_fresh = ".fresh";
- userec_t utmp, zerorec;
+ userec_t utmp;
time_t clock;
struct stat st;
int fd, i;
- memset(&zerorec, 0, sizeof(zerorec));
clock = now;
/* Lazy method : 先找尋已經清除的過期帳號 */
@@ -185,10 +180,7 @@ getnewuserid()
snprintf(genbuf, sizeof(genbuf), "uid %d", i);
log_usies("APPLY", genbuf);
- strlcpy(zerorec.userid, str_new, sizeof(zerorec.userid));
- zerorec.lastlogin = clock;
- passwd_index_update(i, &zerorec);
- setuserid(i, zerorec.userid);
+ kill_user(i);
passwd_unlock();
return i;
}
diff --git a/mbbsd/user.c b/mbbsd/user.c
index a0be22e3..c5a501eb 100644
--- a/mbbsd/user.c
+++ b/mbbsd/user.c
@@ -5,7 +5,15 @@ static char *sex[8] = {
MSG_BIG_BOY, MSG_BIG_GIRL, MSG_LITTLE_BOY, MSG_LITTLE_GIRL,
MSG_MAN, MSG_WOMAN, MSG_PLANT, MSG_MIME
};
-
+int
+kill_user(int num)
+{
+ userec_t u;
+ memset(&u, 0, sizeof(u));
+ setuserid(num, "");
+ passwd_index_update(num, &u);
+ return 0;
+}
int
u_loginview()
{
@@ -192,9 +200,8 @@ violate_law(userec_t * u, int unum)
Rename(src, dst);
log_usies("KILL", u->userid);
post_violatelaw(u->userid, cuser.userid, reason, "砍除 ID");
- u->userid[0] = '\0';
- setuserid(unum, u->userid);
- passwd_index_update(unum, u);
+ kill_user(unum);
+
} else {
u->userlevel |= PERM_VIOLATELAW;
u->vl_count++;
@@ -604,8 +611,7 @@ uinfo_query(userec_t * u, int real, int unum)
snprintf(dst, sizeof(dst), "tmp/%s", x.userid);
Rename(src, dst); /* do not remove user home */
log_usies("KILL", x.userid);
- x.userid[0] = '\0';
- setuserid(unum, x.userid);
+ kill_user(unum);
} else
log_usies("SetUser", x.userid);
if (money_change)