diff options
author | victor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-08-13 13:26:05 +0800 |
---|---|---|
committer | victor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-08-13 13:26:05 +0800 |
commit | a74e3e0cccde3c0b82dce01236f4acfd6088eaba (patch) | |
tree | 9c2dc37bafcd08df3129b0ca0d6392a234aceb45 | |
parent | c6ce13457f0f714877bf0d3c0b6fcb59260c5092 (diff) | |
download | pttbbs-a74e3e0cccde3c0b82dce01236f4acfd6088eaba.tar pttbbs-a74e3e0cccde3c0b82dce01236f4acfd6088eaba.tar.gz pttbbs-a74e3e0cccde3c0b82dce01236f4acfd6088eaba.tar.bz2 pttbbs-a74e3e0cccde3c0b82dce01236f4acfd6088eaba.tar.lz pttbbs-a74e3e0cccde3c0b82dce01236f4acfd6088eaba.tar.xz pttbbs-a74e3e0cccde3c0b82dce01236f4acfd6088eaba.tar.zst pttbbs-a74e3e0cccde3c0b82dce01236f4acfd6088eaba.zip |
integrate kill-user's code
bug killed: somethings a new user will be alohaed by friends of previous
owner of the same id.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3032 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | include/proto.h | 2 | ||||
-rw-r--r-- | mbbsd/register.c | 12 | ||||
-rw-r--r-- | mbbsd/user.c | 40 |
3 files changed, 22 insertions, 32 deletions
diff --git a/include/proto.h b/include/proto.h index 3c52ee35..329736a9 100644 --- a/include/proto.h +++ b/include/proto.h @@ -700,7 +700,7 @@ void sortsong(void); int topsong(void); /* user */ -int kill_user(int num); +int kill_user(int num, const char *userid); int u_editcalendar(void); void user_display(const userec_t *u, int real); void uinfo_query(userec_t *u, int real, int unum); diff --git a/mbbsd/register.c b/mbbsd/register.c index 50959cd0..9ccc68a3 100644 --- a/mbbsd/register.c +++ b/mbbsd/register.c @@ -107,7 +107,7 @@ compute_user_value(const userec_t * urec, time4_t clock) int check_and_expire_account(int uid, const userec_t * urec) { - char genbuf[200], genbuf2[200]; + char genbuf[200]; int val; if ((val = compute_user_value(urec, now)) < 0) { snprintf(genbuf, sizeof(genbuf), "#%d %-12s %15.15s %d %d %d", @@ -115,15 +115,7 @@ check_and_expire_account(int uid, const userec_t * urec) urec->numlogins, urec->numposts, val); if (val > -1 * 60 * 24 * 365) { log_usies("CLEAN", genbuf); - sethomepath(genbuf, urec->userid); - snprintf(genbuf2, sizeof(genbuf2), "tmp/%s", urec->userid); - if (dashd(genbuf) && Rename(genbuf, genbuf2)) { - snprintf(genbuf, sizeof(genbuf), - "/bin/rm -fr home/%c/%s >/dev/null 2>&1", - urec->userid[0], urec->userid); - system(genbuf); - } - kill_user(uid); + kill_user(uid, urec->userid); } else { val = 0; log_usies("DATED", genbuf); diff --git a/mbbsd/user.c b/mbbsd/user.c index 7424537c..6f836a78 100644 --- a/mbbsd/user.c +++ b/mbbsd/user.c @@ -16,14 +16,24 @@ static const char * const chess_type[2] = { #endif int -kill_user(int num) +kill_user(int num, const char *userid) { - userec_t u; - memset(&u, 0, sizeof(userec_t)); - log_usies("KILL", getuserid(num)); - setuserid(num, ""); - passwd_update(num, &u); - return 0; + userec_t u; + char src[256], dst[256]; + + sethomepath(src, userid); + snprintf(dst, sizeof(dst), "tmp/%s", userid); + friend_delete_all(userid, FRIEND_ALOHA); + if (dashd(src) && Rename(src, dst) == 0) { + snprintf(src, sizeof(src), "/bin/rm -fr home/%c/%s >/dev/null 2>&1", userid[0], userid); + system(src); + } + + memset(&u, 0, sizeof(userec_t)); + log_usies("KILL", getuserid(num)); + setuserid(num, ""); + passwd_update(num, &u); + return 0; } int u_loginview(void) @@ -245,14 +255,8 @@ violate_law(userec_t * u, int unum) if (*ans2 != 'y') return; if (ans[0] == '9') { - char src[STRLEN], dst[STRLEN]; - sethomepath(src, u->userid); - snprintf(dst, sizeof(dst), "tmp/%s", u->userid); - friend_delete_all(u->userid, FRIEND_ALOHA); - Rename(src, dst); + kill_user(unum, u->userid); post_violatelaw(u->userid, cuser.userid, reason, "¬å°£ ID"); - kill_user(unum); - } else { kick_all(u->userid); u->userlevel |= PERM_VIOLATELAW; @@ -932,13 +936,7 @@ uinfo_query(userec_t *u, int adminmode, int unum) } memcpy(u, &x, sizeof(x)); if (i == QUIT) { - char src[STRLEN], dst[STRLEN]; - - sethomepath(src, x.userid); - snprintf(dst, sizeof(dst), "tmp/%s", x.userid); - friend_delete_all(x.userid, FRIEND_ALOHA); - Rename(src, dst); /* do not remove user home */ - kill_user(unum); + kill_user(unum, x.userid); return; } else log_usies("SetUser", x.userid); |