summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2012-02-03 17:53:13 +0800
committerpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2012-02-03 17:53:13 +0800
commitb9fa7e9b1f104259c677c620fd7a1859f10f98f7 (patch)
treebc5aa6cdb5c2ede71ee96499290fc7f1caa978ac
parentcc1077e74a71ebd4935bb1f6686305391c718a76 (diff)
downloadpttbbs-b9fa7e9b1f104259c677c620fd7a1859f10f98f7.tar
pttbbs-b9fa7e9b1f104259c677c620fd7a1859f10f98f7.tar.gz
pttbbs-b9fa7e9b1f104259c677c620fd7a1859f10f98f7.tar.bz2
pttbbs-b9fa7e9b1f104259c677c620fd7a1859f10f98f7.tar.lz
pttbbs-b9fa7e9b1f104259c677c620fd7a1859f10f98f7.tar.xz
pttbbs-b9fa7e9b1f104259c677c620fd7a1859f10f98f7.tar.zst
pttbbs-b9fa7e9b1f104259c677c620fd7a1859f10f98f7.zip
add admin port detection
git-svn-id: http://opensvn.csie.org/pttbbs/trunk@5549 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--pttbbs/mbbsd/mbbsd.c25
1 files 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();