diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2009-08-19 21:47:41 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2009-08-19 21:47:41 +0800 |
commit | 07a3f1656ee0471d07138865feace636163d422a (patch) | |
tree | e9da02b2e5cb52d03474b6c2e02ed6c377de7f77 /mbbsd/register.c | |
parent | 07d2f9e8f641a93977a34f60d9ee187ab0268a1a (diff) | |
download | pttbbs-07a3f1656ee0471d07138865feace636163d422a.tar pttbbs-07a3f1656ee0471d07138865feace636163d422a.tar.gz pttbbs-07a3f1656ee0471d07138865feace636163d422a.tar.bz2 pttbbs-07a3f1656ee0471d07138865feace636163d422a.tar.lz pttbbs-07a3f1656ee0471d07138865feace636163d422a.tar.xz pttbbs-07a3f1656ee0471d07138865feace636163d422a.tar.zst pttbbs-07a3f1656ee0471d07138865feace636163d422a.zip |
* move ambiguous id check into (emaildb/regcheckd) daemon
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4755 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/register.c')
-rw-r--r-- | mbbsd/register.c | 68 |
1 files changed, 2 insertions, 66 deletions
diff --git a/mbbsd/register.c b/mbbsd/register.c index 207325f4..2f4bffcc 100644 --- a/mbbsd/register.c +++ b/mbbsd/register.c @@ -632,70 +632,6 @@ setupnewuser(const userec_t *user) return uid; } -void -build_unambiguous_userid(char *uid) -{ - int i = 0; - const char *ambtbl[] = { - "0Oo", - "1Il", - NULL - }; - - for (i = 0; ambtbl[i]; ) - { - size_t pos = strcspn(uid, ambtbl[i]); - if (!uid[pos]) - { - i++; - continue; - } - uid[pos] = ambtbl[i][0]; - uid += (pos+1); // skip the processed character - } -} - -int -find_ambiguous_userid(const char *userid) -{ - const char *ambchars = "0Oo1Il"; - size_t uidlen = 0, iamb; - char ambuid[IDLEN+1], shmuid[IDLEN+1]; - int i; - - assert(userid && *userid); - - // if NULL, found nothing. - iamb = strcspn(userid, ambchars); - if (!userid[iamb]) - return 0; - - // build un-ambiguous uid - uidlen = strlcpy(ambuid, userid, sizeof(ambuid)); - build_unambiguous_userid(ambuid); - - for (i = 0; i < MAX_USERS; i++) - { - const char *ruid = SHM->userid[i]; - - // quick test: same non-amb prefix, and remote uid has amb characters - if (iamb > 0 && tolower(*ruid) != tolower(*ambuid)) - continue; - if (!ruid[strcspn(ruid, ambchars)]) - continue; - - // copy and check remote uid length - if (strlcpy(shmuid, ruid, sizeof(shmuid)) != uidlen) - continue; - - build_unambiguous_userid(shmuid); - if (strcasecmp(shmuid, ambuid) == 0) - return 1; - } - - return 0; -} - ///////////////////////////////////////////////////////////////////////////// // New Registration (Phase 1: Create Account) ///////////////////////////////////////////////////////////////////////////// @@ -769,8 +705,8 @@ new_register(void) } else if (reserved_user_id(passbuf)) outs("此代號已由系統保留,請使用別的代號\n"); -#ifndef NO_CHECK_AMBIGUOUS_USERID - else if (find_ambiguous_userid(passbuf)) +#if !defined(NO_CHECK_AMBIGUOUS_USERID) && defined(USE_REGCHECKD) + else if (check_ambiguous_userid_exist(passbuf) > 0) // ignore if error occurs outs("此代號過於近似它人帳號,請改用別的代號。\n"); #endif else // success |