/* nickserv.c - Nick/authentication service
- * Copyright 2000-2006 srvx Development Team
+ * Copyright 2000-2008 srvx Development Team
*
* This file is part of srvx.
*
user->handle_info = hi;
if (hi && !hi->users && !hi->opserv_level)
HANDLE_CLEAR_FLAG(hi, HELPING);
- for (n=0; n<auth_func_used; n++)
+ for (n=0; (n<auth_func_used) && !user->dead; n++)
auth_func_list[n](user, old_info);
if (hi) {
struct nick_info *ni;
if (stamp) {
if (!nickserv_conf.disable_nicks) {
- struct nick_info *ni;
- for (ni = hi->nicks; ni; ni = ni->next) {
- if (!irccasecmp(user->nick, ni->nick)) {
+ struct nick_info *ni2;
+ for (ni2 = hi->nicks; ni2; ni2 = ni2->next) {
+ if (!irccasecmp(user->nick, ni2->nick)) {
user->modes |= FLAGS_REGNICK;
break;
}
}
if (hi->channels) {
- struct userData *channel, *next;
+ struct userData *chan, *next;
char *name;
- for (channel = hi->channels; channel; channel = next) {
- next = channel->u_next;
- name = channel->channel->channel->name;
+ for (chan = hi->channels; chan; chan = next) {
+ next = chan->u_next;
+ name = chan->channel->channel->name;
herelen = strlen(name);
if (pos + herelen + 7 > ArrayLength(buff)) {
- next = channel;
+ next = chan;
goto print_chans_buff;
}
- if (IsUserSuspended(channel))
+ if (IsUserSuspended(chan))
buff[pos++] = '-';
- pos += sprintf(buff+pos, "%d:%s ", channel->access, name);
+ pos += sprintf(buff+pos, "%d:%s ", chan->access, name);
if (next == NULL) {
print_chans_buff:
buff[pos-1] = 0;
struct channelList *schannels;
unsigned int ii;
schannels = chanserv_support_channels();
- for (uNode = hi->users; uNode; uNode = uNode->next_authed) {
- for (ii = 0; ii < schannels->used; ++ii)
- if (GetUserMode(schannels->list[ii], uNode))
- break;
- if (ii < schannels->used)
+ for (ii = 0; ii < schannels->used; ++ii)
+ if (find_handle_in_channel(schannels->list[ii], hi, NULL))
break;
- }
- if (!uNode)
+ if (ii == schannels->used)
HANDLE_CLEAR_FLAG(hi, HELPING);
}
NICKSERV_MIN_PARMS(3);
if (!(hi = modcmd_get_handle_info(user, argv[1]))) {
- reply("MSG_HANDLE_UNKNOWN", argv[1]);
return 0;
}
if (!hi->email_addr)
struct string_list *masks, *slist;
struct handle_info *hi;
struct userNode *authed_users;
- struct userData *channels;
+ struct userData *channel_list;
unsigned long id;
unsigned int ii;
dict_t subdb;
}
if ((hi = get_handle_info(handle))) {
authed_users = hi->users;
- channels = hi->channels;
+ channel_list = hi->channels;
hi->users = NULL;
hi->channels = NULL;
dict_remove(nickserv_handle_dict, hi->handle);
} else {
authed_users = NULL;
- channels = NULL;
+ channel_list = NULL;
}
hi = register_handle(handle, str, id);
if (authed_users) {
authed_users = authed_users->next_authed;
}
}
- hi->channels = channels;
+ hi->channels = channel_list;
masks = database_get_data(obj, KEY_MASKS, RECDB_STRING_LIST);
hi->masks = masks ? string_list_copy(masks) : alloc_string_list(1);
str = database_get_data(obj, KEY_MAXLOGINS, RECDB_QSTRING);
const char *setter;
const char *text;
const char *set;
- const char *id;
+ const char *note_id;
dict_t notedb;
- id = iter_key(it);
+ note_id = iter_key(it);
notedb = GET_RECORD_OBJECT((struct record_data*)iter_data(it));
if (!notedb) {
- log_module(NS_LOG, LOG_ERROR, "Malformed note %s for account %s; ignoring note.", id, hi->handle);
+ log_module(NS_LOG, LOG_ERROR, "Malformed note %s for account %s; ignoring note.", note_id, hi->handle);
continue;
}
expires = database_get_data(notedb, KEY_NOTE_EXPIRES, RECDB_QSTRING);
text = database_get_data(notedb, KEY_NOTE_NOTE, RECDB_QSTRING);
set = database_get_data(notedb, KEY_NOTE_SET, RECDB_QSTRING);
if (!setter || !text || !set) {
- log_module(NS_LOG, LOG_ERROR, "Missing field(s) from note %s for account %s; ignoring note.", id, hi->handle);
+ log_module(NS_LOG, LOG_ERROR, "Missing field(s) from note %s for account %s; ignoring note.", note_id, hi->handle);
continue;
}
note = calloc(1, sizeof(*note) + strlen(text));
note->next = NULL;
note->expires = expires ? strtoul(expires, NULL, 10) : 0;
note->set = strtoul(set, NULL, 10);
- note->id = strtoul(id, NULL, 10);
+ note->id = strtoul(note_id, NULL, 10);
safestrncpy(note->setter, setter, sizeof(note->setter));
strcpy(note->note, text);
if (last_note)
log_module(NS_LOG, LOG_ERROR, "Unable to open dictionary file %s: %s", fname, strerror(errno));
return;
}
- while (!feof(file)) {
- fgets(line, sizeof(line), file);
+ while (fgets(line, sizeof(line), file)) {
if (!line[0])
continue;
if (line[strlen(line)-1] == '\n')
nickserv_reclaim(user, ni, nickserv_conf.auto_reclaim_action);
}
-static int
+static void
check_user_nick(struct userNode *user) {
struct nick_info *ni;
user->modes &= ~FLAGS_REGNICK;
if (!(ni = get_nick_info(user->nick)))
- return 0;
+ return;
if (user->handle_info == ni->owner) {
user->modes |= FLAGS_REGNICK;
irc_regnick(user);
- return 0;
+ return;
}
if (nickserv_conf.warn_nick_owned)
send_message(user, nickserv, "NSMSG_RECLAIM_WARN", ni->nick, ni->owner->handle);
if (nickserv_conf.auto_reclaim_action == RECLAIM_NONE)
- return 0;
+ return;
if (nickserv_conf.auto_reclaim_delay)
timeq_add(now + nickserv_conf.auto_reclaim_delay, nickserv_reclaim_p, user);
else
nickserv_reclaim(user, ni, nickserv_conf.auto_reclaim_action);
- return 0;
-}
-
-int
-handle_new_user(struct userNode *user)
-{
- return check_user_nick(user);
}
void
{
unsigned int i;
NS_LOG = log_register_type("NickServ", "file:nickserv.log");
- reg_new_user_func(handle_new_user);
+ reg_new_user_func(check_user_nick);
reg_nick_change_func(handle_nick_change);
reg_del_user_func(nickserv_remove_user);
reg_account_func(handle_account);