summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/proto.h2
-rw-r--r--mbbsd/register.c12
-rw-r--r--mbbsd/user.c40
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);