From 7797c4999caa34843c2e633a7a60b6b8292a2bfd Mon Sep 17 00:00:00 2001 From: victor Date: Sat, 13 Aug 2005 05:48:08 +0000 Subject: fix bug: user's home will not be created after retrieving from backup git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3033 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/admin.c | 49 ++++++++++++++++++++++++++++++++----------------- mbbsd/mbbsd.c | 2 +- 2 files changed, 33 insertions(+), 18 deletions(-) (limited to 'mbbsd') diff --git a/mbbsd/admin.c b/mbbsd/admin.c index ecea3176..2d908e0d 100644 --- a/mbbsd/admin.c +++ b/mbbsd/admin.c @@ -52,6 +52,36 @@ m_user(void) return 0; } +static int retrieve_backup(userec_t *user) +{ + int uid; + char src[256], dst[256]; + + if ((uid = searchuser(user->userid, user->userid))) { + setumoney(uid, user->money); + passwd_update(uid, user); + return 0; + } + + src[0] = getans("目前的 PASSWD 檔沒有此 ID,新增嗎?[y/N]"); + + if (src[0] != 'y') { + vmsg("目前的 PASSWDS 檔沒有此 ID,請先新增此帳號"); + return -1; + } + + if (setupnewuser((const userec_t *)user) >= 0) { + sethomepath(dst, user->userid); + if (!dashd(dst)) { + snprintf(src, sizeof(src), "tmp/%s", user->userid); + if (!dashd(src) || !Rename(src, dst)) + mkuserdir(user->userid); + } + return 0; + } + return -1; +} + static int search_key_user(const char *passwdfile, int mode) { @@ -59,8 +89,7 @@ search_key_user(const char *passwdfile, int mode) int ch; int coun = 0; FILE *fp1 = fopen(passwdfile, "r"); - char friendfile[128]="", key[22], genbuf[8], - *keymatch; + char friendfile[128]="", key[22], *keymatch; assert(fp1); @@ -128,23 +157,9 @@ search_key_user(const char *passwdfile, int mode) return 0; } if (ch == 's' && !mode) { - if ((ch = searchuser(user.userid, user.userid))) { - setumoney(ch, user.money); - passwd_update(ch, &user); + if (retrieve_backup(&user) >= 0) { fclose(fp1); return 0; - } else { - getdata(0, 0, - "目前的 PASSWD 檔沒有此 ID,新增嗎?[y/N]", - genbuf, 3, LCECHO); - if (genbuf[0] != 'y') { - outs("目前的PASSWDS檔沒有此id " - "請先new一個這個id的帳號"); - } else { - setupnewuser(&user); - fclose(fp1); - return 0; - } } } } diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c index d1422dbc..d5693304 100644 --- a/mbbsd/mbbsd.c +++ b/mbbsd/mbbsd.c @@ -540,7 +540,7 @@ logattempt(const char *uid, char type) } } -inline static void mkuserdir(const char *userid) +void mkuserdir(const char *userid) { char genbuf[200]; sethomepath(genbuf, userid); -- cgit v1.2.3