From b9fa7e9b1f104259c677c620fd7a1859f10f98f7 Mon Sep 17 00:00:00 2001 From: piaip Date: Fri, 3 Feb 2012 09:53:13 +0000 Subject: add admin port detection git-svn-id: http://opensvn.csie.org/pttbbs/trunk@5549 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- pttbbs/mbbsd/mbbsd.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/pttbbs/mbbsd/mbbsd.c b/pttbbs/mbbsd/mbbsd.c index 443261ee..805176ea 100644 --- a/pttbbs/mbbsd/mbbsd.c +++ b/pttbbs/mbbsd/mbbsd.c @@ -689,12 +689,18 @@ static int load_current_user(const char *uid) { // userid should be already normalized. + int is_admin_only = 0; + +#ifdef ADMIN_PORT + // ----------------------------------------------------- PORT TESTING + // XXX currently this does not work if we're using tunnel. + is_admin_only = (listen_port == ADMIN_PORT); +#endif // ----------------------------------------------------- NEW ACCOUNT #ifdef STR_REGNEW - if (strcasecmp(uid, STR_REGNEW) == 0) - { + if (!is_admin_only && strcasecmp(uid, STR_REGNEW) == 0) { # ifndef LOGINASNEW assert(false); @@ -710,8 +716,7 @@ load_current_user(const char *uid) // --------------------------------------------------- GUEST ACCOUNT #ifdef STR_GUEST - if (strcasecmp(uid, STR_GUEST) == 0) - { + if (!is_admin_only && strcasecmp(uid, STR_GUEST) == 0) { if (initcuser(STR_GUEST)< 1) exit (0) ; pwcuInitGuestPerm(); // can we prevent mkuserdir() here? @@ -721,7 +726,17 @@ load_current_user(const char *uid) // ---------------------------------------------------- USER ACCOUNT { - if (!cuser.userid[0] && initcuser(uid) < 1) exit(0); + if (!cuser.userid[0] && initcuser(uid) < 1) + exit(0); + + if (is_admin_only) { + if (!HasUserPerm(PERM_SYSOP | PERM_BBSADM | PERM_BOARD | + PERM_ACCOUNTS | PERM_CHATROOM | + PERM_VIEWSYSOP | PERM_PRG)) { + puts("\r\n權限不足,請換其它 port 連線。\r\n"); + exit(0); + } + } #ifdef LOCAL_LOGIN_MOD LOCAL_LOGIN_MOD(); -- cgit v1.2.3