summaryrefslogtreecommitdiffstats
path: root/mbbsd/mbbsd.c
diff options
context:
space:
mode:
Diffstat (limited to 'mbbsd/mbbsd.c')
-rw-r--r--mbbsd/mbbsd.c115
1 files changed, 17 insertions, 98 deletions
diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c
index 7782c5ed..99394c0b 100644
--- a/mbbsd/mbbsd.c
+++ b/mbbsd/mbbsd.c
@@ -190,15 +190,6 @@ log_usies(const char *mode, const char *mesg)
}
-static void
-setflags(int mask, int value)
-{
- if (value)
- cuser.uflag |= mask;
- else
- cuser.uflag &= ~mask;
-}
-
void
u_exit(const char *mode)
{
@@ -210,27 +201,15 @@ u_exit(const char *mode)
// verify if utmp is valid. only flush data if utmp is correct.
assert(strncmp(currutmp->userid,cuser.userid, IDLEN)==0);
- if(strncmp(currutmp->userid,cuser.userid, IDLEN)!=0)
+ if(strncmp(currutmp->userid, cuser.userid, IDLEN)!=0)
return;
auto_backup();
save_brdbuf();
brc_finalize();
- /*
- cuser.goodpost = currutmp->goodpost;
- cuser.badpost = currutmp->badpost;
- */
- // no need because in later passwd_sync_update will reload money from SHM.
- // reload_money();
-
- setflags(PAGER_FLAG, currutmp->pager != PAGER_ON);
- setflags(CLOAK_FLAG, currutmp->invisible);
-
- cuser.invisible = currutmp->invisible;
- cuser.withme = currutmp->withme;
- cuser.pager = currutmp->pager;
- memcpy(cuser.mind, currutmp->mind, 4);
+ // XXX TOTO for guests, skip the save process?
+ pwcuExitSave();
setutmpbid(0);
if (!SHM->GV2.e.shutdown) {
@@ -239,11 +218,6 @@ u_exit(const char *mode)
do_aloha("<<下站通知>> -- 我走囉!");
}
- // 小於 60 秒不計 login 次數
- if (time(0) - login_start_time < 60 && cuser.numlogins > 0)
- --cuser.numlogins;
-
- passwd_sync_update(usernum, &cuser);
purge_utmp(currutmp);
log_usies(mode, NULL);
}
@@ -739,13 +713,7 @@ load_current_user(const char *uid)
if (strcasecmp(uid, STR_GUEST) == 0)
{
if (initcuser(STR_GUEST)< 1) exit (0) ;
- cuser.userlevel = 0;
- cuser.uflag = PAGER_FLAG | BRDSORT_FLAG | MOVIE_FLAG;
- cuser.uflag2= 0; // we don't need FAVNEW_FLAG or anything else.
-
-# ifdef GUEST_DEFAULT_DBCS_NOINTRESC
- cuser.uflag |= DBCS_NOINTRESC;
-# endif
+ pwcuInitGuestPerm();
// can we prevent mkuserdir() here?
mkuserdir(cuser.userid);
} else
@@ -763,11 +731,7 @@ load_current_user(const char *uid)
exit(0);
#else /* 自動加上各個主要權限 */
// TODO only allow in local connection?
- cuser.userlevel = PERM_BASIC | PERM_CHAT | PERM_PAGE |
- PERM_POST | PERM_LOGINOK | PERM_MAILLIMIT |
- PERM_CLOAK | PERM_SEECLOAK | PERM_XEMPT |
- PERM_SYSOPHIDE | PERM_BM | PERM_ACCOUNTS |
- PERM_CHATROOM | PERM_BOARD | PERM_SYSOP | PERM_BBSADM;
+ pwcuInitAdminPerm();
#endif
}
/* 早該有 home 了, 不知道為何有的帳號會沒有, 被砍掉了? */
@@ -1022,14 +986,15 @@ where(const char *from)
static void
check_BM(void)
{
- /* XXX: -_- */
- int i;
+ int i;
- cuser.userlevel &= ~PERM_BM;
+ assert(HasUserPerm(PERM_BM));
for( i = 0 ; i < numboards ; ++i )
if( is_BM_cache(i + 1) ) /* XXXbid */
return;
- //for (i = 0, bhdr = bcache; i < numboards && !is_BM(bhdr->BM); i++, bhdr++);
+
+ // disable BM permission
+ pwcuBitUnsetLevel(PERM_BM);
}
static void
@@ -1067,10 +1032,10 @@ setup_utmp(int mode)
uinfo.go_tie = cuser.go_tie;
uinfo.invisible = cuser.invisible % 2;
uinfo.pager = cuser.pager % PAGER_MODES;
+ uinfo.withme = cuser.withme & ~WITHME_ALLFLAG;
if(cuser.withme & (cuser.withme<<1) & (WITHME_ALLFLAG<<1))
- cuser.withme = 0; /* unset all if contradict */
- uinfo.withme = cuser.withme & ~WITHME_ALLFLAG;
+ uinfo.withme = 0;
getnewutmpent(&uinfo);
@@ -1161,11 +1126,6 @@ inline static void birthday_make_a_wish(const struct tm *ptime, const struct tm
}
}
-inline static void record_lasthost(const char *fromhost)
-{
- strlcpy(cuser.lasthost, fromhost, sizeof(cuser.lasthost));
-}
-
inline static void check_mailbox_quota(void)
{
if (chkmailbox())
@@ -1174,31 +1134,7 @@ inline static void check_mailbox_quota(void)
static void init_guest_info(void)
{
- int i;
- char *nick[13] = {
- "椰子", "貝殼", "內衣", "寶特瓶", "翻車魚",
- "樹葉", "浮萍", "鞋子", "潛水艇", "魔王",
- "鐵罐", "考卷", "大美女"
- };
- char *name[13] = {
- "大王椰子", "鸚鵡螺", "比基尼", "可口可樂", "仰泳的魚",
- "憶", "高岡屋", "AIR Jordon", "紅色十月號", "批踢踢",
- "SASAYA椰奶", "鴨蛋", "布魯克鱈魚香絲"
- };
- char *addr[13] = {
- "天堂樂園", "大海", "綠島小夜曲", "美國", "綠色珊瑚礁",
- "遠方", "原本海", "NIKE", "蘇聯", "男八618室",
- "愛之味", "天上", "藍色珊瑚礁"
- };
- i = login_start_time % 13;
- snprintf(cuser.nickname, sizeof(cuser.nickname),
- "海邊漂來的%s", nick[(int)i]);
- strlcpy(currutmp->nickname, cuser.nickname,
- sizeof(currutmp->nickname));
- strlcpy(cuser.realname, name[(int)i], sizeof(cuser.realname));
- strlcpy(cuser.address, addr[(int)i], sizeof(cuser.address));
- memset(cuser.mind, 0, sizeof(cuser.mind));
- cuser.sex = i % 8;
+ pwcuInitGuestInfo();
currutmp->pager = PAGER_DISABLE;
}
@@ -1209,7 +1145,7 @@ inline static void foreign_warning(void){
mail_muser(cuser, "[出入境管理局]", "etc/foreign_expired_warn");
}
else if (login_start_time - cuser.firstlogin > FOREIGN_REG_DAY * 24 * 3600){
- cuser.userlevel &= ~(PERM_LOGINOK | PERM_POST);
+ pwcuBitUnsetLevel(PERM_LOGINOK | PERM_POST);
vmsg("警告:請至出入境管理局申請永久居留");
}
}
@@ -1231,8 +1167,6 @@ user_login(void)
/* 初始化 uinfo、flag、mode */
setup_utmp(LOGIN);
- if (cuser.userlevel)
- ++cuser.numlogins;
/* log usies */
log_usies("ENTER", fromhost);
@@ -1306,7 +1240,7 @@ user_login(void)
check_mailbox_quota();
check_birthday();
check_register();
- record_lasthost(fromhost);
+ pwcuLoginSave();
restore_backup();
} else if (strcmp(cuser.userid, STR_GUEST) == 0) { /* guest */
@@ -1334,34 +1268,19 @@ user_login(void)
/* If you wanna do incremental upgrade
* (like, added a function/flag that wants user to confirm againe)
* put it here.
+ * But you must use 'lasttime' because cuser.lastlogin
+ * is already changed.
*/
-#if defined(DBCSAWARE) && defined(DBCSAWARE_UPGRADE_STARTTIME)
- // define the real time you upgraded in your pttbbs.conf
- if(cuser.lastlogin < DBCSAWARE_UPGRADE_STARTTIME)
- {
- if (u_detectDBCSAwareEvilClient())
- cuser.uflag &= ~DBCSAWARE_FLAG;
- else
- cuser.uflag |= DBCSAWARE_FLAG;
- }
-#endif
/* login time update */
-
if(ptime.tm_yday!=lasttime.tm_yday)
STATINC(STAT_TODAYLOGIN_MIN);
-
-
- cuser.lastlogin = login_start_time;
-
}
#if FOREIGN_REG_DAY > 0
foreign_warning();
#endif
- passwd_sync_update(usernum, &cuser);
-
if(cuser.uflag2 & FAVNEW_FLAG) {
fav_load();
if (get_fav_root() != NULL) {