X-Git-Url: https://jfr.im/git/irc/evilnet/x3.git/blobdiff_plain/7827220c933cf2fd53437d1285b639a49b213508..c99dcaf6a0f9c7798580fc9f315d7b368c9f972c:/src/nickserv.c diff --git a/src/nickserv.c b/src/nickserv.c index 3cb6992..e189e77 100644 --- a/src/nickserv.c +++ b/src/nickserv.c @@ -889,11 +889,28 @@ reg_handle_rename_func(handle_rename_func_t func) static char * generate_fakehost(struct handle_info *handle) { + struct userNode *target; extern const char *hidden_host_suffix; static char buffer[HOSTLEN+1]; + char *data; + int style = 1; if (!handle->fakehost) { - snprintf(buffer, sizeof(buffer), "%s.%s", handle->handle, hidden_host_suffix); + data = conf_get_data("server/hidden_host_type", RECDB_QSTRING); + if (data) + style = atoi(data); + + if (style == 1) + snprintf(buffer, sizeof(buffer), "%s.%s", handle->handle, hidden_host_suffix); + else if (style == 2) { + /* Due to the way fakehost is coded theres no way i can + get the exact user, so for now ill just take the first + authed user. */ + for (target = handle->users; target; target = target->next_authed) + break; + + snprintf(buffer, sizeof(buffer), "%s", target->crypthost); + } return buffer; } else if (handle->fakehost[0] == '.') { /* A leading dot indicates the stored value is actually a title. */ @@ -967,10 +984,8 @@ set_user_handle_info(struct userNode *user, struct handle_info *hi, int stamp) if (hi && !hi->users && !hi->opserv_level) HANDLE_CLEAR_FLAG(hi, HELPING); - if (GetUserH(user->nick)) { - for (n=0; nnick)) user->loc = 1; if (hi) { @@ -983,12 +998,15 @@ set_user_handle_info(struct userNode *user, struct handle_info *hi, int stamp) send_message(other, nickserv, "NSMSG_CLONE_AUTH", user->nick, user->ident, user->hostname); } + /* Add this auth to users list of current auths */ user->next_authed = hi->users; hi->users = user; hi->lastseen = now; + /* Add to helpers list */ if (IsHelper(user)) userList_append(&curr_helpers, user); + /* Set the fakehost */ if (hi->fakehost || old_info) apply_fakehost(hi); @@ -999,6 +1017,9 @@ set_user_handle_info(struct userNode *user, struct handle_info *hi, int stamp) #else const char *id = "???"; #endif + /* Mark all the nicks registered to this + * account as registered nicks + * - Why not just this one? -rubin */ if (!nickserv_conf.disable_nicks) { struct nick_info *ni; for (ni = hi->nicks; ni; ni = ni->next) { @@ -1008,15 +1029,23 @@ set_user_handle_info(struct userNode *user, struct handle_info *hi, int stamp) } } } + /* send the account to the ircd */ StampUser(user, id, hi->registered); } + /* Stop trying to kick this user off their nick */ if ((ni = get_nick_info(user->nick)) && (ni->owner == hi)) timeq_del(0, nickserv_reclaim_p, user, TIMEQ_IGNORE_WHEN); } else { /* We cannot clear the user's account ID, unfortunately. */ user->next_authed = NULL; } + + /* Call auth handlers */ + if (GetUserH(user->nick)) { + for (n=0; ncookie->type) { + case ACTIVATION: + safestrncpy(hi->passwd, hi->cookie->data, sizeof(hi->passwd)); + if (nickserv_conf.sync_log) + SyncLog("ACCOUNTACC %s", hi->handle); + break; + case PASSWORD_CHANGE: + safestrncpy(hi->passwd, hi->cookie->data, sizeof(hi->passwd)); + if (nickserv_conf.sync_log) + SyncLog("PASSCHANGE %s %s", hi->handle, hi->passwd); + break; + case EMAIL_CHANGE: + if (!hi->email_addr && nickserv_conf.sync_log) { + if (nickserv_conf.sync_log) + SyncLog("REGISTER %s %s %s %s", hi->handle, hi->passwd, hi->cookie->data, user->info); + } + nickserv_set_email_addr(hi, hi->cookie->data); + if (nickserv_conf.sync_log) + SyncLog("EMAILCHANGE %s %s", hi->handle, hi->cookie->data); + break; + default: + reply("NSMSG_BAD_COOKIE_TYPE", hi->cookie->type); + log_module(NS_LOG, LOG_ERROR, "Bad cookie type %d for account %s.", hi->cookie->type, hi->handle); + break; + } + nickserv_eat_cookie(hi->cookie); reply("NSMSG_ATE_FOREIGN_COOKIE", hi->handle); @@ -2955,20 +3010,27 @@ static OPTION_FUNC(opt_title) title = hi->fakehost + 1; else { /* If theres no title set then the default title will therefore - be the first part of hidden_host in x3.conf.example, so for - consistency with opt_fakehost we will print this here */ + be the first part of hidden_host in x3.conf, so for + consistency with opt_fakehost we will print this here. + This isnt actually used in P10, its just handled to keep from crashing... */ char *hs, *hidden_suffix, *rest; hs = conf_get_data("server/hidden_host", RECDB_QSTRING); hidden_suffix = strdup(hs); /* Yes we do this twice */ - rest = strrchr(hidden_suffix, '.'); - *rest++ = '\0'; - rest = strrchr(hidden_suffix, '.'); - *rest++ = '\0'; + if((rest = strchr(hidden_suffix, '.'))) + { + *rest = '\0'; + title = hidden_suffix; + } + else + { + /* A lame default if someone configured hidden_host to something lame */ + title = strdup("users"); + free(hidden_suffix); + } - title = hidden_suffix; } if (!title)