summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2013-02-26 20:03:59 +0800
committerpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2013-02-26 20:03:59 +0800
commit60dfd46d67969eee43abc9747292bd9047d0f54a (patch)
treed5ea53a0f3e418fcaf336052ac906192e571de4d
parente1c0548a8a7fb2c936755faa465fb08eec3db768 (diff)
downloadpttbbs-60dfd46d67969eee43abc9747292bd9047d0f54a.tar
pttbbs-60dfd46d67969eee43abc9747292bd9047d0f54a.tar.gz
pttbbs-60dfd46d67969eee43abc9747292bd9047d0f54a.tar.bz2
pttbbs-60dfd46d67969eee43abc9747292bd9047d0f54a.tar.lz
pttbbs-60dfd46d67969eee43abc9747292bd9047d0f54a.tar.xz
pttbbs-60dfd46d67969eee43abc9747292bd9047d0f54a.tar.zst
pttbbs-60dfd46d67969eee43abc9747292bd9047d0f54a.zip
xchatd: reject changing nick to use other people's id.
Note: using id in login time is not limited - let's see if that will be a problem. git-svn-id: http://opensvn.csie.org/pttbbs/trunk@5795 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--pttbbs/util/xchatd.c39
1 files changed, 24 insertions, 15 deletions
diff --git a/pttbbs/util/xchatd.c b/pttbbs/util/xchatd.c
index a97828c9..131150ea 100644
--- a/pttbbs/util/xchatd.c
+++ b/pttbbs/util/xchatd.c
@@ -12,6 +12,8 @@
#define MONITOR
#endif
+#define REJECT_NICK_BY_USERID
+
/* self-test:
* random test, �H�����ͦU�� client input, �ت�������� server
* crash �����p, �]�� client �å����� server �ǹL�Ӫ� data.
@@ -840,6 +842,16 @@ chat_nick(ChatUser *cu, char *msg)
return;
}
+#ifdef REJECT_NICK_BY_USERID
+ // Having chatid same as other's real id may be confusing.
+ if (is_validuserid(chatid) && searchuser(chatid, NULL) > 0 &&
+ strcasecmp(chatid, cu->userid) != 0) {
+ send_to_user(cu, "�� ���N���P�����䥦�ϥΪ� ID ���ơA"
+ "���קK��ij��ij���n�ϥ�", 0, MSG_MESSAGE);
+ return;
+ }
+#endif
+
snprintf(chatbuf, sizeof(chatbuf), "�� %s �N��ѥN���אּ " ANSI_COLOR(1;33) "%s" ANSI_RESET, cu->chatid, chatid);
if (!CLOAK(cu)) /* Thor: ��ѫ������N */
send_to_room(cu->room, chatbuf, cu->userno, MSG_MESSAGE);
@@ -1506,6 +1518,18 @@ login_user(ChatUser *cu, char *msg)
return 0;
}
+#ifdef REJECT_NICK_BY_USERID
+ // Currently some user may choose random names (that is probably not trying
+ // to fake accounts) like "apple" when entering xchatd. Let's relax about
+ // the "first login" case.
+#if 0
+ if (searchuser(chatid, NULL) && strcasecmp(chatid, userid) != 0) {
+ send_to_user(cu, CHAT_LOGIN_INVALID, 0, 0);
+ return 0;
+ }
+#endif
+#endif
+
if (cuser_by_chatid(chatid) != NULL)
{
/* chatid in use */
@@ -1529,21 +1553,6 @@ login_user(ChatUser *cu, char *msg)
cu->numlogindays = acct.numlogindays;
strlcpy(cu->lasthost, acct.lasthost, sizeof(cu->lasthost));
- // deprecated: let's use BBS lasthost
-#if 0
- /* Xshadow: ���o client ���ӷ� */
- fromlen = sizeof(from);
- if (!getpeername(cu->sock, (struct sockaddr *) & from, &fromlen))
- {
- if ((hp = gethostbyaddr((char *) &from.sin_addr, sizeof(struct in_addr), from.sin_family)))
- strlcpy(cu->lasthost, hp->h_name, sizeof(cu->lasthost));
- else
- strlcpy(cu->lasthost, (char *) inet_ntoa(from.sin_addr), sizeof(cu->lasthost));
- }
- else
- strcpy(cu->lasthost, "[�~�Ӫ�]");
-#endif
-
send_to_user(cu, CHAT_LOGIN_OK, 0, 0);
arrive_room(cu, &mainroom);