X-Git-Url: https://jfr.im/git/irc/evilnet/x3.git/blobdiff_plain/a32da4c70ca85b879f8162469ae37ffeca500b99..9b2d838a3f6c15287a36caed1c8e10ff8d74613d:/src/nickserv.c?ds=sidebyside diff --git a/src/nickserv.c b/src/nickserv.c index e776634..593e112 100644 --- a/src/nickserv.c +++ b/src/nickserv.c @@ -429,13 +429,6 @@ register_nick(const char *nick, struct handle_info *owner) dict_insert(nickserv_nick_dict, ni->nick, ni); } -static void -free_nick_info(void *vni) -{ - struct nick_info *ni = vni; - free(ni); -} - static void delete_nick(struct nick_info *ni) { @@ -938,7 +931,7 @@ set_user_handle_info(struct userNode *user, struct handle_info *hi, int stamp) } } } - StampUser(user, id); + StampUser(user, id, hi->registered); } if ((ni = get_nick_info(user->nick)) && (ni->owner == hi)) @@ -1535,6 +1528,57 @@ reg_failpw_func(failpw_func_t func) failpw_func_list[failpw_func_used++] = func; } +/* + * Return hi if the handle/pass pair matches, NULL if it doesnt. + * + * called by nefariouses enhanced AC login-on-connect code + * + */ +struct handle_info *loc_auth(char *handle, char *password) +{ + int pw_arg, used, maxlogins; + unsigned int ii; + int wildmask = 0; + struct handle_info *hi; + struct userNode *other; + + hi = dict_find(nickserv_handle_dict, handle, NULL); + pw_arg = 2; + if (!hi) { + return NULL; + } + + /* We don't know the users hostname, or anything because they + * havn't registered yet. So we can only allow LOC if your + * account has *@* as a hostmask. + */ + for (ii=0; iimasks->used; ii++) + { + if (!strcmp(hi->masks->list[ii], "*@*")) + { + wildmask++; + break; + } + } + if(wildmask < 1) + return NULL; + + /* Responses from here on look up the language used by the handle they asked about. */ + if (!checkpass(password, hi->passwd)) { + return NULL; + } + if (HANDLE_FLAGGED(hi, SUSPENDED)) { + return NULL; + } + maxlogins = hi->maxlogins ? hi->maxlogins : nickserv_conf.default_maxlogins; + for (used = 0, other = hi->users; other; other = other->next_authed) { + if (++used >= maxlogins) { + return NULL; + } + } + return hi; +} + static NICKSERV_FUNC(cmd_auth) { int pw_arg, used, maxlogins; @@ -3655,11 +3699,26 @@ void handle_account(struct userNode *user, const char *stamp) { struct handle_info *hi; + char *colon; #ifdef WITH_PROTOCOL_P10 + time_t timestamp = 0; + + colon = strchr(stamp, ':'); + if(colon && colon[1]) + { + *colon = 0; + timestamp = atoi(colon+1); + } hi = dict_find(nickserv_handle_dict, stamp, NULL); + if(hi && timestamp && hi->registered != timestamp) + { + log_module(MAIN_LOG, LOG_WARNING, "%s using account %s but timestamp does not match %lu is not %lu.", user->nick, stamp, timestamp, hi->registered); + return; + } #else hi = dict_find(nickserv_id_dict, stamp, NULL); + log_module(MAIN_LOG, LOG_WARNING, "Using non-P10 code in accounts, not tested at all!"); #endif if (hi) { @@ -3842,7 +3901,7 @@ init_nickserv(const char *nick) dict_set_free_keys(nickserv_id_dict, free); nickserv_nick_dict = dict_new(); - dict_set_free_data(nickserv_nick_dict, free_nick_info); + dict_set_free_data(nickserv_nick_dict, free); nickserv_allow_auth_dict = dict_new();