diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2010-11-07 23:46:20 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2010-11-07 23:46:20 +0800 |
commit | 38423e2c8c0b1e25f11bb642447e17913b0660a9 (patch) | |
tree | b689a1d5c3f42278ea425175878be79a2e92e946 | |
parent | 30cf6d7fa18687f8bbb6823522e297df011f33da (diff) | |
download | pttbbs-38423e2c8c0b1e25f11bb642447e17913b0660a9.tar pttbbs-38423e2c8c0b1e25f11bb642447e17913b0660a9.tar.gz pttbbs-38423e2c8c0b1e25f11bb642447e17913b0660a9.tar.bz2 pttbbs-38423e2c8c0b1e25f11bb642447e17913b0660a9.tar.lz pttbbs-38423e2c8c0b1e25f11bb642447e17913b0660a9.tar.xz pttbbs-38423e2c8c0b1e25f11bb642447e17913b0660a9.tar.zst pttbbs-38423e2c8c0b1e25f11bb642447e17913b0660a9.zip |
change most perm to always check PERM_BASIC.
In the legacy code, it has an assumption that "when you have PERM_LOGINOK, you
should have PERM_BASIC". By that design, many checks in menu and the function
(eg, 'mail' in menu v.s. ctrl-u r) are checking different perms.
Unfortunately, admins decide to keep PERM_LOGINOK but remove PERM_BASIC for
violation accounts recently because they want to prevent the account being
deleted/renewed.
Although the best way to do that would be "change the password, or set 'never
expire' permission", we can improve the permission checks so it will work better
git-svn-id: http://opensvn.csie.org/pttbbs/trunk@5228 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | pttbbs/include/perm.h | 1 | ||||
-rw-r--r-- | pttbbs/mbbsd/announce.c | 2 | ||||
-rw-r--r-- | pttbbs/mbbsd/bbs.c | 8 | ||||
-rw-r--r-- | pttbbs/mbbsd/edit.c | 2 | ||||
-rw-r--r-- | pttbbs/mbbsd/mail.c | 10 | ||||
-rw-r--r-- | pttbbs/mbbsd/menu.c | 2 | ||||
-rw-r--r-- | pttbbs/mbbsd/talk.c | 34 | ||||
-rw-r--r-- | pttbbs/mbbsd/user.c | 2 | ||||
-rw-r--r-- | pttbbs/mbbsd/vote.c | 2 |
9 files changed, 33 insertions, 30 deletions
diff --git a/pttbbs/include/perm.h b/pttbbs/include/perm.h index e66df594..c620df9f 100644 --- a/pttbbs/include/perm.h +++ b/pttbbs/include/perm.h @@ -56,6 +56,7 @@ #define PERM_INTERNET (PERM_LOGINOK) /* 身份認證過關的才能寄信到 Internet */ #define HasUserPerm(x) ((cuser.userlevel & (x)) != 0) +#define HasBasicUserPerm(x) (HasUserPerm(PERM_BASIC) && HasUserPerm(x)) #define PERM_HIDE(u) (u && (u)->userlevel & PERM_SYSOPHIDE) #define IS_BOARD(bptr) ((bptr)->brdname[0] && \ diff --git a/pttbbs/mbbsd/announce.c b/pttbbs/mbbsd/announce.c index 6b0aec0b..7648e863 100644 --- a/pttbbs/mbbsd/announce.c +++ b/pttbbs/mbbsd/announce.c @@ -1582,7 +1582,7 @@ a_menu_rec(const char *maintitle, const char *path, break; snprintf(fname, sizeof(fname), "%s/%s", path, fhdr->filename); - if (HasUserPerm(PERM_LOGINOK) && dashf(fname)) { + if (HasBasicUserPerm(PERM_LOGINOK) && dashf(fname)) { a_forward(path, fhdr, ch /* == 'U' */ ); /* By CharlieL */ } else diff --git a/pttbbs/mbbsd/bbs.c b/pttbbs/mbbsd/bbs.c index 2e22c40f..a3554988 100644 --- a/pttbbs/mbbsd/bbs.c +++ b/pttbbs/mbbsd/bbs.c @@ -628,7 +628,7 @@ readdoent(int num, fileheader_t * ent) } // tag should override everything - if ((currmode & MODE_BOARD) || HasUserPerm(PERM_LOGINOK)) + if ((currmode & MODE_BOARD) || HasBasicUserPerm(PERM_LOGINOK)) { if (TagNum && !Tagger(atoi(ent->filename + 2), 0, TAG_NIN)) type = 'D'; @@ -1144,7 +1144,7 @@ do_general(int garbage) setutmpmode(POSTING); /* 未具備 Internet 權限者,只能在站內發表文章 */ /* 板主預設站內存檔 */ - if (HasUserPerm(PERM_INTERNET) && !(bp->brdattr & BRD_LOCALSAVE)) + if (HasBasicUserPerm(PERM_INTERNET) && !(bp->brdattr & BRD_LOCALSAVE)) local_article = 0; else local_article = 1; @@ -1215,7 +1215,7 @@ do_general(int garbage) // drop money & numposts for free boards, or user without login information // (they may post on free boards like SYSOP) // including: special boards (e.g. TEST, ALLPOST), bad boards, no BM boards - if (!HasUserPerm(PERM_LOGINOK) || + if (!HasBasicUserPerm(PERM_LOGINOK) || IsFreeBoardName(currboard) || (currbrdattr&BRD_BAD) || bp->BM[0] < ' ') // XXX note: BM may contain some (chinese) text that is not userid @@ -2354,7 +2354,7 @@ stop_gamble(void) static int join_gamble(int ent, const fileheader_t * fhdr, const char *direct) { - if (!HasUserPerm(PERM_LOGINOK)) + if (!HasBasicUserPerm(PERM_LOGINOK)) return DONOTHING; if (stop_gamble()) { vmsg("目前未舉辦賭盤或賭盤已開獎"); diff --git a/pttbbs/mbbsd/edit.c b/pttbbs/mbbsd/edit.c index d95e80db..e48ad456 100644 --- a/pttbbs/mbbsd/edit.c +++ b/pttbbs/mbbsd/edit.c @@ -1925,7 +1925,7 @@ write_file(const char *fpath, int saveheader, int *islocal, char mytitle[STRLEN] strlcpy(mytitle, ans, STRLEN); return KEEP_EDITING; case 's': - if (!HasUserPerm(PERM_LOGINOK)) { + if (!HasBasicUserPerm(PERM_LOGINOK)) { local_article = 1; // only report if local can be set. if (islocal) diff --git a/pttbbs/mbbsd/mail.c b/pttbbs/mbbsd/mail.c index e263054b..7338f9bd 100644 --- a/pttbbs/mbbsd/mail.c +++ b/pttbbs/mbbsd/mail.c @@ -28,7 +28,7 @@ setforward(void) int flIdiotSent2Self = 0; int oidlen = strlen(cuser.userid); - if (!HasUserPerm(PERM_LOGINOK)) + if (!HasBasicUserPerm(PERM_LOGINOK)) return DONOTHING; vs_hdr("設定自動轉寄"); @@ -308,7 +308,7 @@ setupmailusage(void) } else if (HasUserPerm(PERM_BM)) { mailsumlimit = 500; max_keepmail = 300; - } else if (HasUserPerm(PERM_LOGINOK)) + } else if (HasBasicUserPerm(PERM_LOGINOK)) mailsumlimit = 200; else mailsumlimit = 50; @@ -559,7 +559,7 @@ m_send(void) // in-site mail char uident[IDLEN+1]; - if (!HasUserPerm(PERM_LOGINOK)) + if (!HasBasicUserPerm(PERM_LOGINOK)) return DONOTHING; vs_hdr("站內寄信"); @@ -833,7 +833,7 @@ multi_reply(int ent, fileheader_t * fhdr, const char *direct) int mail_list(void) { - if (!HasUserPerm(PERM_LOGINOK)) + if (!HasBasicUserPerm(PERM_LOGINOK)) return DONOTHING; vs_hdr("群組作業"); @@ -937,7 +937,7 @@ m_forward(int ent GCC_UNUSED, fileheader_t * fhdr, const char *direct GCC_UNUSED char uid[STRLEN]; char save_title[STRLEN]; - if (!HasUserPerm(PERM_LOGINOK)) + if (!HasBasicUserPerm(PERM_LOGINOK)) return DONOTHING; vs_hdr("轉達信件"); diff --git a/pttbbs/mbbsd/menu.c b/pttbbs/mbbsd/menu.c index 19f07a0a..35d5205c 100644 --- a/pttbbs/mbbsd/menu.c +++ b/pttbbs/mbbsd/menu.c @@ -414,6 +414,8 @@ domenu(int menu_index, const char *cmdtitle, int cmd, const commands_t cmdtable[ i = -1; switch (cmd) { case Ctrl('Z'): + if (!HasUserPerm(PERM_BASIC)) + break; ZA_Select(); // we'll have za loop later. refscreen = YEA; i = lastcmdptr; diff --git a/pttbbs/mbbsd/talk.c b/pttbbs/mbbsd/talk.c index 62f7eff1..536599a5 100644 --- a/pttbbs/mbbsd/talk.c +++ b/pttbbs/mbbsd/talk.c @@ -47,7 +47,7 @@ iswritable_stat(const userinfo_t * uentp, int fri_stat) if (HasUserPerm(PERM_SYSOP)) return 1; - if (!HasUserPerm(PERM_LOGINOK) || HasUserPerm(PERM_VIOLATELAW)) + if (!HasBasicUserPerm(PERM_LOGINOK) || HasUserPerm(PERM_VIOLATELAW)) return 0; return (uentp->pager != PAGER_ANTIWB && @@ -2482,7 +2482,7 @@ userlist(void) break; case 'i': - if (HasUserPerm(PERM_BASIC|PERM_LOGINOK)) + if (HasBasicUserPerm(PERM_LOGINOK)) u_set_mind(); redrawall = redraw = 1; break; @@ -2493,7 +2493,7 @@ userlist(void) case KEY_RIGHT: case KEY_ENTER: case 't': - if (HasUserPerm(PERM_LOGINOK)) { + if (HasBasicUserPerm(PERM_LOGINOK)) { if (uentp->pid != currpid && strcmp(uentp->userid, cuser.userid) != 0) { move(1, 0); @@ -2515,7 +2515,7 @@ userlist(void) redrawall = redraw = 1; break; case 'a': - if (HasUserPerm(PERM_LOGINOK) && !(fri_stat & IFH)) { + if (HasBasicUserPerm(PERM_LOGINOK) && !(fri_stat & IFH)) { if (vans("確定要加入好友嗎 [N/y]") == 'y') { friend_add(uentp->userid, FRIEND_OVERRIDE,uentp->nickname); friend_load(FRIEND_OVERRIDE, 0); @@ -2525,7 +2525,7 @@ userlist(void) break; case 'd': - if (HasUserPerm(PERM_LOGINOK) && (fri_stat & IFH)) { + if (HasBasicUserPerm(PERM_LOGINOK) && (fri_stat & IFH)) { if (vans("確定要刪除好友嗎 [N/y]") == 'y') { friend_delete(uentp->userid, FRIEND_OVERRIDE); friend_load(FRIEND_OVERRIDE, 0); @@ -2535,14 +2535,14 @@ userlist(void) break; case 'o': - if (HasUserPerm(PERM_LOGINOK)) { + if (HasBasicUserPerm(PERM_LOGINOK)) { t_override(); redrawall = redraw = 1; } break; case 'f': - if (HasUserPerm(PERM_LOGINOK)) { + if (HasBasicUserPerm(PERM_LOGINOK)) { pwcuToggleFriendList(); redrawall = redraw = 1; } @@ -2550,7 +2550,7 @@ userlist(void) /* case 'G': - if (HasUserPerm(PERM_LOGINOK)) { + if (HasBasicUserPerm(PERM_LOGINOK)) { p_give(); // give_money_ui(NULL); redrawall = redraw = 1; @@ -2559,14 +2559,14 @@ userlist(void) */ case 'g': - if (HasUserPerm(PERM_LOGINOK) && cuser.money) { + if (HasBasicUserPerm(PERM_LOGINOK) && cuser.money) { give_money_ui(uentp->userid); redrawall = redraw = 1; } break; case 'm': - if (HasUserPerm(PERM_LOGINOK)) { + if (HasBasicUserPerm(PERM_LOGINOK)) { char userid[IDLEN + 1]; strlcpy(userid, uentp->userid, sizeof(userid)); vs_hdr("寄 信"); @@ -2591,14 +2591,14 @@ userlist(void) break; case 'c': - if (HasUserPerm(PERM_LOGINOK)) { + if (HasBasicUserPerm(PERM_LOGINOK)) { chicken_query(uentp->userid); redrawall = redraw = 1; } break; case 'l': - if (HasUserPerm(PERM_LOGINOK)) { + if (HasBasicUserPerm(PERM_LOGINOK)) { t_display(); redrawall = redraw = 1; } @@ -2618,7 +2618,7 @@ userlist(void) #ifdef PLAY_ANGEL case Ctrl('P'): - if (HasUserPerm(PERM_ANGEL) && currutmp) { + if (HasBasicUserPerm(PERM_ANGEL) && currutmp) { /* static const char *msgs[ANGELPAUSE_MODES] = { " 接受所有小主人發問 [●] ", @@ -2634,7 +2634,7 @@ userlist(void) #endif // PLAY_ANGLE case Ctrl('W'): - if (HasUserPerm(PERM_LOGINOK)) { + if (HasBasicUserPerm(PERM_LOGINOK)) { static const char *wm[PAGER_UI_TYPES] = {"一般", "進階", "未來"}; pwcuSetPagerUIType((cuser.pager_ui_type +1) % PAGER_UI_TYPES_USER); @@ -2650,7 +2650,7 @@ userlist(void) break; case 'r': - if (HasUserPerm(PERM_LOGINOK)) { + if (HasBasicUserPerm(PERM_LOGINOK)) { if (curredit & EDIT_MAIL) { /* deny reentrance, which may cause many problems */ vmsg("你進入使用者列表前就已經在閱\讀信件了"); @@ -2665,7 +2665,7 @@ userlist(void) break; case 'N': - if (HasUserPerm(PERM_LOGINOK)) { + if (HasBasicUserPerm(PERM_LOGINOK)) { char tmp_nick[sizeof(cuser.nickname)]; if (getdata_str(1, 0, "新的暱稱: ", tmp_nick, sizeof(tmp_nick), DOECHO, cuser.nickname) > 0) @@ -3008,7 +3008,7 @@ t_chat(void) static time4_t lastEnter = 0; int fd; - if (!HasUserPerm(PERM_CHAT)) { + if (!HasBasicUserPerm(PERM_CHAT)) { vmsg("權限不足,無法進入聊天室。"); return -1; } diff --git a/pttbbs/mbbsd/user.c b/pttbbs/mbbsd/user.c index 1f0c3244..e32c5aa0 100644 --- a/pttbbs/mbbsd/user.c +++ b/pttbbs/mbbsd/user.c @@ -536,7 +536,7 @@ void Customize(void) } continue; case 1: - if (HasUserPerm(PERM_BASIC|PERM_LOGINOK) && u_set_mind()) + if (HasBasicUserPerm(PERM_LOGINOK) && u_set_mind()) dirty = 1; continue; } diff --git a/pttbbs/mbbsd/vote.c b/pttbbs/mbbsd/vote.c index d53cb4ca..7603210b 100644 --- a/pttbbs/mbbsd/vote.c +++ b/pttbbs/mbbsd/vote.c @@ -1000,7 +1000,7 @@ user_vote(const char *bname) vmsg("目前並沒有任何投票舉行。"); return FULLUPDATE; } - if (!HasUserPerm(PERM_LOGINOK)) { + if (!HasBasicUserPerm(PERM_LOGINOK)) { vmsg("對不起! 您未完成註冊程序, 還沒有投票權喔!"); return FULLUPDATE; } |