[srvx-commits] CVS: services/src chanserv.c,1.379,1.380 helpserv.c,1.79,1.80 messages.h,1.37,1.38 mo
Brought to you by:
entrope
From: Entrope <en...@us...> - 2003-09-09 16:40:35
|
Update of /cvsroot/srvx/services/src In directory sc8-pr-cvs1:/tmp/cvs-serv24777/src Modified Files: chanserv.c helpserv.c messages.h mod-memoserv.c nickserv.c nickserv.h Log Message: convert handle_info->handle from char[] to char* slightly related code reorganization to improve coverage testing Index: chanserv.c =================================================================== RCS file: /cvsroot/srvx/services/src/chanserv.c,v retrieving revision 1.379 retrieving revision 1.380 diff -C2 -r1.379 -r1.380 *** chanserv.c 22 Aug 2003 04:07:51 -0000 1.379 --- chanserv.c 9 Sep 2003 16:40:28 -0000 1.380 *************** *** 841,845 **** struct note_type *ntype; unsigned int arg = 1, existed = 0, max_length; - extern char *accessNames[]; if ((ntype = dict_find(note_types, argv[1], NULL))) { --- 841,844 ---- *************** *** 853,866 **** ntype->set_access.min_opserv = strtoul(argv[arg], NULL, 0); } else if (!irccasecmp(argv[arg], "channel")) { ! enum userLevel ulvl; ! arg++; ! ntype->set_access_type = NOTE_SET_CHANNEL_ACCESS; ! for (ulvl = ulPeon; ulvl < ulHelper; ulvl++) { ! if (!(irccasecmp(argv[arg], accessNames[ulvl]))) break; ! } ! if (ulvl == ulHelper) { send_message(user, cmd->parent->bot, CSMSG_INVALID_ACCESS, argv[arg]); goto fail; } ntype->set_access.min_ulevel = ulvl; } else if (!irccasecmp(argv[arg], "setter")) { --- 852,861 ---- ntype->set_access.min_opserv = strtoul(argv[arg], NULL, 0); } else if (!irccasecmp(argv[arg], "channel")) { ! enum userLevel ulvl = user_level_from_name(argv[++arg]); ! if (ulvl == ulNone) { send_message(user, cmd->parent->bot, CSMSG_INVALID_ACCESS, argv[arg]); goto fail; } + ntype->set_access_type = NOTE_SET_CHANNEL_ACCESS; ntype->set_access.min_ulevel = ulvl; } else if (!irccasecmp(argv[arg], "setter")) { *************** *** 1111,1115 **** off = channel->channel_info->mode_off; ! if((on & (channel->modes ^ on)) || (channel->modes & off)) { return 1; --- 1106,1110 ---- off = channel->channel_info->mode_off; ! if((on & ~channel->modes) || (channel->modes & off)) { return 1; *************** *** 1356,1368 **** del_channel_ban(struct banData *ban) { - if(!ban) return; - ban->channel->banCount--; banCount--; ! if(ban->prev) ban->prev->next = ban->next; ! else ban->channel->bans = ban->next; ! if(ban->next) ban->next->prev = ban->prev; if(ban->expires) --- 1351,1370 ---- del_channel_ban(struct banData *ban) { ban->channel->banCount--; banCount--; ! if(ban->prev) ! { ! ban->prev->next = ban->next; ! } ! else ! { ! ban->channel->bans = ban->next; ! } ! if(ban->next) ! { ! ban->next->prev = ban->prev; ! } if(ban->expires) *************** *** 1371,1375 **** } ! if(ban->reason) free(ban->reason); free(ban); --- 1373,1380 ---- } ! if(ban->reason) ! { ! free(ban->reason); ! } free(ban); *************** *** 1393,1397 **** bd->expires = 0; del_channel_ban(bd); - return; } --- 1398,1401 ---- *************** *** 1487,1491 **** if(channel->notes) dict_delete(channel->notes); sprintf(msgbuf, "%s %s", channel->channel->name, reason); ! if(!IsSuspended(channel)) DelChannelUser(chanserv, channel->channel, msgbuf, 0); global_message(MESSAGE_RECIPIENT_OPERS | MESSAGE_RECIPIENT_HELPERS, msgbuf); free(channel); --- 1491,1498 ---- if(channel->notes) dict_delete(channel->notes); sprintf(msgbuf, "%s %s", channel->channel->name, reason); ! if(!IsSuspended(channel)) ! { ! DelChannelUser(chanserv, channel->channel, msgbuf, 0); ! } global_message(MESSAGE_RECIPIENT_OPERS | MESSAGE_RECIPIENT_HELPERS, msgbuf); free(channel); *************** *** 1760,1781 **** static CHANSERV_FUNC(cmd_allowregister) { ! const char *chan_name = NULL; ! int arg = 1; - if(argc > 1) - { - chan_name = argv[1]; - arg = 2; - } - else if(channel) - { - chan_name = channel->name; - } - if(!chan_name) - { - chanserv_notice(user, MSG_MISSING_PARAMS, argv[0]); - CHANSERV_SYNTAX(); - return 0; - } if((chan_name[0] == '*') && dict_find(handle_dnrs, chan_name+1, NULL)) { --- 1767,1772 ---- static CHANSERV_FUNC(cmd_allowregister) { ! const char *chan_name = argv[1]; if((chan_name[0] == '*') && dict_find(handle_dnrs, chan_name+1, NULL)) { *************** *** 2012,2016 **** struct modeNode *mn; struct userData *uData; - int new_channel = 0, force = 0; char reason[MAXLEN]; struct do_not_register *dnr; --- 2003,2006 ---- *************** *** 2024,2077 **** } ! force = (argc > 2) && !irccasecmp(argv[2], "force") && IsHelping(user); ! if((target = GetChannel(argv[1]))) { ! ! if(!force && (dnr = chanserv_is_dnr(target->name, NULL))) ! { ! if(IsHelping(user)) ! { ! chanserv_notice(user, CSMSG_DNR_INFO, dnr->chan_name, dnr->setter, dnr->reason); ! } ! else ! { ! chanserv_notice(user, CSMSG_DNR_CHANNEL_MOVE, argv[1]); ! } ! return 0; ! } } - else - { - if(!IsCSChannelName(argv[1])) - { - chanserv_notice(user, MSG_NOT_CHANNEL_NAME); - return 0; - } ! if(opserv_bad_channel(argv[1])) ! { ! chanserv_notice(user, CSMSG_ILLEGAL_CHANNEL, argv[1]); ! return 0; ! } ! if (!force) { ! for(uData = channel->channel_info->users; uData; uData = uData->next) ! { ! if((uData->access == ulOwner) && (dnr = chanserv_is_dnr(NULL, uData->handle))) ! { ! if(IsHelping(user)) ! { ! chanserv_notice(user, CSMSG_DNR_INFO, dnr->chan_name, dnr->setter, dnr->reason); ! } ! else ! { ! chanserv_notice(user, CSMSG_DNR_CHANNEL_MOVE, argv[1]); ! } ! return 0; ! } ! } ! ! if((dnr = chanserv_is_dnr(argv[1], NULL))) { if(IsHelping(user)) --- 2014,2034 ---- } ! if(!IsCSChannelName(argv[1])) { ! chanserv_notice(user, MSG_NOT_CHANNEL_NAME); ! return 0; } ! if(opserv_bad_channel(argv[1])) ! { ! chanserv_notice(user, CSMSG_ILLEGAL_CHANNEL, argv[1]); ! return 0; ! } ! if (!IsHelping(user) || (argc < 3) || irccasecmp(argv[2], "force")) ! { ! for(uData = channel->channel_info->users; uData; uData = uData->next) { ! if((uData->access == ulOwner) && (dnr = chanserv_is_dnr(argv[1], uData->handle))) { if(IsHelping(user)) *************** *** 2086,2105 **** } } target = AddChannel(argv[1], now, NULL, NULL); ! AddChannelUser(chanserv, target); ! new_channel = 1; } ! ! if(target->channel_info) { chanserv_notice(user, CSMSG_ALREADY_REGGED, target->name); return 0; } ! ! if(!new_channel && (!(mn = GetUserMode(target, user)) || !(mn->modes && MODE_CHANOP)) && !IsHelping(user)) { ! chanserv_notice(user, CSMSG_MUST_BE_OPPED, target->name); ! return 0; } --- 2043,2072 ---- } } + } + if (!(target = GetChannel(argv[1]))) + { target = AddChannel(argv[1], now, NULL, NULL); ! LockChannel(target); ! if(!IsSuspended(channel->channel_info)) ! { ! AddChannelUser(chanserv, target); ! } } ! else if(target->channel_info) { chanserv_notice(user, CSMSG_ALREADY_REGGED, target->name); return 0; } ! else if((!(mn = GetUserMode(target, user)) || !(mn->modes && MODE_CHANOP)) ! && !IsHelping(user)) { ! chanserv_notice(user, CSMSG_MUST_BE_OPPED, target->name); ! return 0; ! } ! else if(!IsSuspended(channel->channel_info)) ! { ! AddChannelUser(chanserv, target); ! AddChannelOp(1, &chanserv, target, chanserv, 1); } *************** *** 2111,2120 **** channel->channel_info = NULL; - if(!IsSuspended(target->channel_info)) - { - if(!new_channel) AddChannelUser(chanserv, target); - AddChannelOp(1, &chanserv, target, chanserv, 1); - } - chanserv_notice(user, CSMSG_MOVE_SUCCESS, target->name); --- 2078,2081 ---- *************** *** 5875,5879 **** static void ! chanserv_refresh_topics(void *data) { unsigned int refresh_num = (now - self->link) / chanserv_conf.refresh_period; --- 5836,5840 ---- static void ! chanserv_refresh_topics(UNUSED_ARG(void *data)) { unsigned int refresh_num = (now - self->link) / chanserv_conf.refresh_period; *************** *** 5890,5894 **** cData->last_refresh = refresh_num; } ! timeq_add(now + chanserv_conf.refresh_period, chanserv_refresh_topics, data); } --- 5851,5855 ---- cData->last_refresh = refresh_num; } ! timeq_add(now + chanserv_conf.refresh_period, chanserv_refresh_topics, NULL); } *************** *** 6434,6438 **** } ! static void handle_rename(struct handle_info *handle, const char *new_handle) { struct do_not_register *dnr = dict_find(handle_dnrs, handle->handle, NULL); --- 6395,6399 ---- } ! static void handle_rename(struct handle_info *handle, const char *old_handle) { struct do_not_register *dnr = dict_find(handle_dnrs, handle->handle, NULL); *************** *** 6440,6445 **** if(dnr) { ! dict_remove2(handle_dnrs, handle->handle, 1); ! safestrncpy(dnr->chan_name + 1, new_handle, sizeof(dnr->chan_name) - 1); dict_insert(handle_dnrs, dnr->chan_name + 1, dnr); } --- 6401,6406 ---- if(dnr) { ! dict_remove2(handle_dnrs, old_handle, 1); ! safestrncpy(dnr->chan_name + 1, handle->handle, sizeof(dnr->chan_name) - 1); dict_insert(handle_dnrs, dnr->chan_name + 1, dnr); } *************** *** 6472,6476 **** for(cData = channelList; cData; cData = cData->next) { ! if(!IsSuspended(cData)) cData->may_opchan = 1; } } --- 6433,6440 ---- for(cData = channelList; cData; cData = cData->next) { ! if(!IsSuspended(cData)) ! { ! cData->may_opchan = 1; ! } } } Index: helpserv.c =================================================================== RCS file: /cvsroot/srvx/services/src/helpserv.c,v retrieving revision 1.79 retrieving revision 1.80 diff -C2 -r1.79 -r1.80 *** helpserv.c 1 Sep 2003 14:44:52 -0000 1.79 --- helpserv.c 9 Sep 2003 16:40:29 -0000 1.80 *************** *** 3648,3653 **** /* Also update helpserv_reqs_byhand_dict upon handle rename */ ! static void handle_nickserv_rename(struct handle_info *handle, const char *new_handle) { ! char old_handle[NICKSERV_HANDLE_LEN+1]; struct helpserv_reqlist *reqlist; struct helpserv_userlist *userlist; --- 3648,3652 ---- /* Also update helpserv_reqs_byhand_dict upon handle rename */ ! static void handle_nickserv_rename(struct handle_info *handle, const char *old_handle) { struct helpserv_reqlist *reqlist; struct helpserv_userlist *userlist; *************** *** 3655,3688 **** /* First, rename the handle in the requests dict */ ! if ((reqlist = dict_find(helpserv_reqs_byhand_dict, handle->handle, NULL))) { /* Don't free the list */ ! dict_remove2(helpserv_reqs_byhand_dict, handle->handle, 1); ! ! /* new_handle may be a temporary pointer. The dict stores the key pointer. ! * Make sure it knows about the change but still points to handle->handle, ! * as handle->handle will soon store the new name. */ ! strcpy(old_handle, handle->handle); ! strcpy(handle->handle, new_handle); dict_insert(helpserv_reqs_byhand_dict, handle->handle, reqlist); - strcpy(handle->handle, old_handle); } /* Second, rename the handle in the users dict */ ! if ((userlist = dict_find(helpserv_users_byhand_dict, handle->handle, NULL))) { ! dict_remove2(helpserv_users_byhand_dict, handle->handle, 1); for (i=0; i < userlist->used; i++) { ! dict_remove2(userlist->list[i]->hs->users, handle->handle, 1); } - strcpy(old_handle, handle->handle); - strcpy(handle->handle, new_handle); - dict_insert(helpserv_users_byhand_dict, handle->handle, userlist); for (i=0; i < userlist->used; i++) { dict_insert(userlist->list[i]->hs->users, handle->handle, userlist->list[i]); } - - strcpy(handle->handle, old_handle); } --- 3654,3675 ---- /* First, rename the handle in the requests dict */ ! if ((reqlist = dict_find(helpserv_reqs_byhand_dict, old_handle, NULL))) { /* Don't free the list */ ! dict_remove2(helpserv_reqs_byhand_dict, old_handle, 1); dict_insert(helpserv_reqs_byhand_dict, handle->handle, reqlist); } /* Second, rename the handle in the users dict */ ! if ((userlist = dict_find(helpserv_users_byhand_dict, old_handle, NULL))) { ! dict_remove2(helpserv_users_byhand_dict, old_handle, 1); for (i=0; i < userlist->used; i++) { ! dict_remove2(userlist->list[i]->hs->users, old_handle, 1); } dict_insert(helpserv_users_byhand_dict, handle->handle, userlist); for (i=0; i < userlist->used; i++) { dict_insert(userlist->list[i]->hs->users, handle->handle, userlist->list[i]); } } *************** *** 3691,3695 **** struct helpserv_request *req=reqlist->list[i]; ! if (req->helper && (req->hs->notify >= NOTIFY_HANDLE)) helpserv_notify(req->helper, HSMSG_NOTIFY_HAND_RENAME, req->id, handle->handle, new_handle); } } --- 3678,3684 ---- struct helpserv_request *req=reqlist->list[i]; ! if (req->helper && (req->hs->notify >= NOTIFY_HANDLE)) { ! helpserv_notify(req->helper, HSMSG_NOTIFY_HAND_RENAME, req->id, old_handle, handle->handle); ! } } } Index: messages.h =================================================================== RCS file: /cvsroot/srvx/services/src/messages.h,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -r1.37 -r1.38 *** messages.h 2 Aug 2003 23:13:22 -0000 1.37 --- messages.h 9 Sep 2003 16:40:29 -0000 1.38 *************** *** 82,85 **** --- 82,87 ---- #define MSG_INVALID_BINARY "$b%s$b is an invalid binary value." + #define MSG_INTERNAL_FAILURE "Your command could not be processed due to an internal failure." + #define IDENT_FORMAT "%s [%s@%s/%s]" #define IDENT_DATA(user) user->nick, user->ident, user->hostname, inet_ntoa(user->ip) Index: mod-memoserv.c =================================================================== RCS file: /cvsroot/srvx/services/src/mod-memoserv.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** mod-memoserv.c 5 Sep 2003 13:41:26 -0000 1.6 --- mod-memoserv.c 9 Sep 2003 16:40:29 -0000 1.7 *************** *** 44,47 **** --- 44,48 ---- * "MemoServ"), and bind the commands to it: * /msg opserv bind memoserv * *memoserv.* + * /msg opserv bind memoserv set *modcmd.joiner */ *************** *** 121,129 **** { struct memo_account *ma; ! if (!hi) return NULL; ma = dict_find(memos, hi->handle, NULL); ! if (ma) return ma; ma = calloc(1, sizeof(*ma)); ! if (!ma) return ma; ma->handle = hi; ma->flags = MEMO_NOTIFY_NEW | MEMO_NOTIFY_LOGIN; --- 122,133 ---- { struct memo_account *ma; ! if (!hi) ! return NULL; ma = dict_find(memos, hi->handle, NULL); ! if (ma) ! return ma; ma = calloc(1, sizeof(*ma)); ! if (!ma) ! return ma; ma->handle = hi; ma->flags = MEMO_NOTIFY_NEW | MEMO_NOTIFY_LOGIN; *************** *** 146,155 **** struct memo_account *ma = data; ! while (ma->recvd.used) { delete_memo(ma->recvd.list[0]); ! } ! while (ma->sent.used) { delete_memo(ma->sent.list[0]); - } memoList_clean(&ma->recvd); memoList_clean(&ma->sent); --- 150,157 ---- struct memo_account *ma = data; ! while (ma->recvd.used) delete_memo(ma->recvd.list[0]); ! while (ma->sent.used) delete_memo(ma->sent.list[0]); memoList_clean(&ma->recvd); memoList_clean(&ma->sent); *************** *** 190,201 **** memo = calloc(1, sizeof(*memo)); ! if (!memo) return NULL; - memo->sent = sent; memo->recipient = recipient; - memo->sender = sender; - memo->message = strdup(message); memoList_append(&recipient->recvd, memo); memoList_append(&sender->sent, memo); memosSent++; return memo; --- 192,204 ---- memo = calloc(1, sizeof(*memo)); ! if (!memo) ! return NULL; memo->recipient = recipient; memoList_append(&recipient->recvd, memo); + memo->sender = sender; memoList_append(&sender->sent, memo); + memo->sent = sent; + memo->message = strdup(message); memosSent++; return memo; *************** *** 208,218 **** struct userData *dest; ! if (!user->handle_info) return 0; ! if (!(acct->flags & MEMO_DENY_NONCHANNEL)) return 1; ! for (dest = acct->handle->channels; dest; dest = dest->u_next) { ! if (_GetChannelUser(dest->channel, user->handle_info, 1, 0)) { return 1; - } - } send_message(user, bot, MSMSG_CANNOT_SEND, acct->handle->handle); return 0; --- 211,221 ---- struct userData *dest; ! if (!user->handle_info) ! return 0; ! if (!(acct->flags & MEMO_DENY_NONCHANNEL)) ! return 1; ! for (dest = acct->handle->channels; dest; dest = dest->u_next) ! if (_GetChannelUser(dest->channel, user->handle_info, 1, 0)) return 1; send_message(user, bot, MSMSG_CANNOT_SEND, acct->handle->handle); return 0; *************** *** 225,239 **** struct memo_account *ma, *sender; ! if (!(hi = modcmd_get_handle_info(user, argv[1]))) return 0; ! if (!(ma = memoserv_get_account(hi))) return 0; ! if (!(memoserv_can_send(cmd->parent->bot, user, ma))) return 0; ! if (!(sender = memoserv_get_account(user->handle_info))) return 0; message = unsplit_string(argv + 2, argc - 2, NULL); add_memo(now, ma, sender, message); if (ma->flags & MEMO_NOTIFY_NEW) { struct userNode *other; ! for (other = ma->handle->users; other; other = other->next_authed) { send_message(other, cmd->parent->bot, MSMSG_NEW_MESSAGE, user->nick); - } } reply(MSMSG_MEMO_SENT, ma->handle->handle); --- 228,246 ---- struct memo_account *ma, *sender; ! if (!(hi = modcmd_get_handle_info(user, argv[1]))) ! return 0; ! if (!(sender = memoserv_get_account(user->handle_info)) ! || !(ma = memoserv_get_account(hi))) { ! reply(MSG_INTERNAL_FAILURE); ! return 0; ! } ! if (!(memoserv_can_send(cmd->parent->bot, user, ma))) ! return 0; message = unsplit_string(argv + 2, argc - 2, NULL); add_memo(now, ma, sender, message); if (ma->flags & MEMO_NOTIFY_NEW) { struct userNode *other; ! for (other = ma->handle->users; other; other = other->next_authed) send_message(other, cmd->parent->bot, MSMSG_NEW_MESSAGE, user->nick); } reply(MSMSG_MEMO_SENT, ma->handle->handle); *************** *** 249,253 **** struct tm tm; ! if (!(ma = memoserv_get_account(user->handle_info))) return 0; reply(MSMSG_LIST_HEAD); for (ii = 0; (ii < ma->recvd.used) && (ii < 15); ++ii) { --- 256,261 ---- struct tm tm; ! if (!(ma = memoserv_get_account(user->handle_info))) ! return 0; reply(MSMSG_LIST_HEAD); for (ii = 0; (ii < ma->recvd.used) && (ii < 15); ++ii) { *************** *** 257,263 **** reply(MSMSG_LIST_FORMAT, ii, memo->sender->handle->handle, posted); } ! if (ii == 0) reply("$bNone.$b"); ! else if (ii == 15) reply(MSMSG_CLEAN_INBOX, ii); ! else reply(MSMSG_MEMOS_FOUND, ii); return 1; } --- 265,274 ---- reply(MSMSG_LIST_FORMAT, ii, memo->sender->handle->handle, posted); } ! if (ii == 0) ! reply("$bNone.$b"); ! else if (ii == 15) ! reply(MSMSG_CLEAN_INBOX, ii); ! else ! reply(MSMSG_MEMOS_FOUND, ii); return 1; } *************** *** 271,275 **** struct tm tm; ! if (!(ma = memoserv_get_account(user->handle_info))) return 0; memoid = atoi(argv[1]); if (memoid >= ma->recvd.used) { --- 282,287 ---- struct tm tm; ! if (!(ma = memoserv_get_account(user->handle_info))) ! return 0; memoid = atoi(argv[1]); if (memoid >= ma->recvd.used) { *************** *** 289,295 **** struct memo_account *ma; unsigned int memoid; - struct memo *memo; ! if (!(ma = memoserv_get_account(user->handle_info))) return 0; if (!irccasecmp(argv[1], "*") || !irccasecmp(argv[1], "all")) { if ((argc < 3) || irccasecmp(argv[2], "confirm")) { --- 301,307 ---- struct memo_account *ma; unsigned int memoid; ! if (!(ma = memoserv_get_account(user->handle_info))) ! return 0; if (!irccasecmp(argv[1], "*") || !irccasecmp(argv[1], "all")) { if ((argc < 3) || irccasecmp(argv[2], "confirm")) { *************** *** 297,303 **** return 0; } ! while (ma->recvd.used) { delete_memo(ma->recvd.list[0]); - } reply(MSMSG_DELETED_ALL); return 1; --- 309,314 ---- return 0; } ! while (ma->recvd.used) delete_memo(ma->recvd.list[0]); reply(MSMSG_DELETED_ALL); return 1; *************** *** 309,314 **** return 0; } ! memo = ma->recvd.list[memoid]; ! delete_memo(memo); reply(MSMSG_MEMO_DELETED, memoid); return 1; --- 320,324 ---- return 0; } ! delete_memo(ma->recvd.list[memoid]); reply(MSMSG_MEMO_DELETED, memoid); return 1; *************** *** 342,346 **** char *choice; ! if (!(ma = memoserv_get_account(user->handle_info))) return 0; if (argc > 1) { choice = argv[1]; --- 352,357 ---- char *choice; ! if (!(ma = memoserv_get_account(user->handle_info))) ! return 0; if (argc > 1) { choice = argv[1]; *************** *** 365,369 **** char *choice; ! if (!(ma = memoserv_get_account(user->handle_info))) return 0; if (argc > 1) { choice = argv[1]; --- 376,381 ---- char *choice; ! if (!(ma = memoserv_get_account(user->handle_info))) ! return 0; if (argc > 1) { choice = argv[1]; *************** *** 388,392 **** char *choice; ! if (!(ma = memoserv_get_account(user->handle_info))) return 0; if (argc > 1) { choice = argv[1]; --- 400,405 ---- char *choice; ! if (!(ma = memoserv_get_account(user->handle_info))) ! return 0; if (argc > 1) { choice = argv[1]; *************** *** 522,543 **** struct memo *memo; ! if (!(ma = memoserv_get_account(user->handle_info))) return; ! if (!(ma->flags & MEMO_NOTIFY_LOGIN)) return; for (ii = unseen = 0; ii < ma->recvd.used; ++ii) { memo = ma->recvd.list[ii]; ! if (!memo->is_read) unseen++; } ! if (ii && memoserv_conf.bot) { send_message(user, memoserv_conf.bot, MSMSG_MEMOS_INBOX, unseen, ii); - } } static void ! memoserv_rename_account(struct handle_info *hi, const char *new_handle) { struct memo_account *ma; ! if (!(ma = dict_find(memos, hi->handle, NULL))) return; ! dict_remove2(memos, hi->handle, 1); ! dict_insert(memos, new_handle, ma); } --- 535,558 ---- struct memo *memo; ! if (!(ma = memoserv_get_account(user->handle_info)) ! || !(ma->flags & MEMO_NOTIFY_LOGIN)) ! return; for (ii = unseen = 0; ii < ma->recvd.used; ++ii) { memo = ma->recvd.list[ii]; ! if (!memo->is_read) ! unseen++; } ! if (ii && memoserv_conf.bot) send_message(user, memoserv_conf.bot, MSMSG_MEMOS_INBOX, unseen, ii); } static void ! memoserv_rename_account(struct handle_info *hi, const char *old_handle) { struct memo_account *ma; ! if (!(ma = dict_find(memos, old_handle, NULL))) ! return; ! dict_remove2(memos, old_handle, 1); ! dict_insert(memos, hi->handle, ma); } *************** *** 592,596 **** str = database_get_data(conf_node, "bot", RECDB_QSTRING); ! if (str) memoserv_conf.bot = GetUserH(str); return 1; } --- 607,612 ---- str = database_get_data(conf_node, "bot", RECDB_QSTRING); ! if (str) ! memoserv_conf.bot = GetUserH(str); return 1; } Index: nickserv.c =================================================================== RCS file: /cvsroot/srvx/services/src/nickserv.c,v retrieving revision 1.257 retrieving revision 1.258 diff -C2 -r1.257 -r1.258 *** nickserv.c 22 Aug 2003 00:24:14 -0000 1.257 --- nickserv.c 9 Sep 2003 16:40:29 -0000 1.258 *************** *** 364,368 **** hi->userlist_style = HI_DEFAULT_STYLE; hi->announcements = '?'; ! safestrncpy(hi->handle, handle, sizeof(hi->handle)); safestrncpy(hi->passwd, passwd, sizeof(hi->passwd)); hi->infoline = NULL; --- 364,368 ---- hi->userlist_style = HI_DEFAULT_STYLE; hi->announcements = '?'; ! hi->handle = strdup(handle); safestrncpy(hi->passwd, passwd, sizeof(hi->passwd)); hi->infoline = NULL; *************** *** 451,455 **** free_handle_info(void *vhi) { - struct userNode *un, *next; struct handle_info *hi = vhi; --- 451,454 ---- *************** *** 462,474 **** free_string_list(hi->masks); ! for (un = hi->users; un; un = next) { ! next = un->next_authed; ! un->handle_info = NULL; ! un->next_authed = NULL; ! } ! while (hi->nicks) delete_nick(hi->nicks); ! if (hi->infoline) free(hi->infoline); ! if (hi->epithet) free(hi->epithet); if (hi->cookie) { timeq_del(hi->cookie->expires, nickserv_free_cookie, hi->cookie, 0); --- 461,470 ---- free_string_list(hi->masks); ! assert(!hi->users); ! while (hi->nicks) ! delete_nick(hi->nicks); ! free(hi->infoline); ! free(hi->epithet); if (hi->cookie) { timeq_del(hi->cookie->expires, nickserv_free_cookie, hi->cookie, 0); *************** *** 478,482 **** struct handle_info_list *hil = dict_find(nickserv_email_dict, hi->email_addr, NULL); handle_info_list_remove(hil, hi); ! if (!hil->used) dict_remove(nickserv_email_dict, hi->email_addr); } free(hi); --- 474,479 ---- struct handle_info_list *hil = dict_find(nickserv_email_dict, hi->email_addr, NULL); handle_info_list_remove(hil, hi); ! if (!hil->used) ! dict_remove(nickserv_email_dict, hi->email_addr); } free(hi); *************** *** 526,531 **** for (nn=0; nn<channel->members.used; ++nn) { mn = channel->members.list[nn]; ! if (mn->user == except) continue; ! if (mn->user->handle_info == handle) return mn; } return NULL; --- 523,530 ---- for (nn=0; nn<channel->members.used; ++nn) { mn = channel->members.list[nn]; ! if (mn->user == except) ! continue; ! if (mn->user->handle_info == handle) ! return mn; } return NULL; *************** *** 686,706 **** valid_user_for(struct userNode *user, struct handle_info *hi) { ! unsigned int i; ! int res = 0; ! if (hi->masks->used) { ! for (i=0; !res && i<hi->masks->used; i++) { ! /* Maybe it'd just be simpler to require the *! at the ! * start of the hostmask. For future thought, anyway. */ ! if (user_matches_glob(user, hi->masks->list[i], 0)) res = 1; ! } ! } else { ! /* if they have no masks, let them pass */ ! res = 1; ! } ! if (!res && (dict_find(nickserv_allow_auth_dict, user->nick, NULL) == hi)) { dict_remove(nickserv_allow_auth_dict, user->nick); ! res = 2; } ! return res; } --- 685,704 ---- valid_user_for(struct userNode *user, struct handle_info *hi) { ! unsigned int ii; ! ! /* If no hostmasks on the account, allow it. */ ! if (!hi->masks->used) ! return 1; ! /* If any hostmask matches, allow it. */ ! for (ii=0; ii<hi->masks->used; ii++) ! if (user_matches_glob(user, hi->masks->list[ii], 0)) ! return 1; ! /* If they are allowauthed to this account, allow it (removing the aa). */ ! if (dict_find(nickserv_allow_auth_dict, user->nick, NULL) == hi) { dict_remove(nickserv_allow_auth_dict, user->nick); ! return 2; } ! /* The user is not allowed to use this account. */ ! return 0; } *************** *** 783,796 **** * they re-auth to their current handle (which is silly, but users * are like that). */ ! if (user->handle_info == hi) { return; - } if (user->handle_info) { struct userNode *other; ! if (IsHelper(user)) { userList_remove(&curr_helpers, user); - } /* remove from next_authed linked list */ --- 781,792 ---- * they re-auth to their current handle (which is silly, but users * are like that). */ ! if (user->handle_info == hi) return; if (user->handle_info) { struct userNode *other; ! if (IsHelper(user)) userList_remove(&curr_helpers, user); /* remove from next_authed linked list */ *************** *** 804,808 **** } /* if nobody left on old handle, and they're not an oper, remove !god */ ! if (!user->handle_info->users && !user->handle_info->opserv_level) HANDLE_CLEAR_FLAG(user->handle_info, HELPING); /* record them as being last seen at this time */ user->handle_info->lastseen = now; --- 800,805 ---- } /* if nobody left on old handle, and they're not an oper, remove !god */ ! if (!user->handle_info->users && !user->handle_info->opserv_level) ! HANDLE_CLEAR_FLAG(user->handle_info, HELPING); /* record them as being last seen at this time */ user->handle_info->lastseen = now; *************** *** 812,817 **** old_info = user->handle_info; user->handle_info = hi; ! if (hi && !hi->users && !hi->opserv_level) HANDLE_CLEAR_FLAG(hi, HELPING); ! for (n=0; n<auth_func_used; n++) auth_func_list[n](user, old_info); if (hi) { struct nick_info *ni; --- 809,816 ---- old_info = user->handle_info; user->handle_info = hi; ! if (hi && !hi->users && !hi->opserv_level) ! HANDLE_CLEAR_FLAG(hi, HELPING); ! for (n=0; n<auth_func_used; n++) ! auth_func_list[n](user, old_info); if (hi) { struct nick_info *ni; *************** *** 827,831 **** hi->users = user; hi->lastseen = now; ! if (IsHelper(user)) userList_append(&curr_helpers, user); if (stamp) { --- 826,831 ---- hi->users = user; hi->lastseen = now; ! if (IsHelper(user)) ! userList_append(&curr_helpers, user); if (stamp) { *************** *** 852,858 **** } ! 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. */ --- 852,857 ---- } ! 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. */ *************** *** 877,881 **** } ! if (!is_secure_password(handle, passwd, user)) return 0; cryptpass(passwd, crypted); --- 876,881 ---- } ! if (!is_secure_password(handle, passwd, user)) ! return 0; cryptpass(passwd, crypted); *************** *** 901,907 **** } } ! if (settee && (user != settee)) { nickserv_notice(settee, NSMSG_OREGISTER_VICTIM, user->nick, hi->handle); - } return hi; } --- 901,906 ---- } } ! if (settee && (user != settee)) nickserv_notice(settee, NSMSG_OREGISTER_VICTIM, user->nick, hi->handle); return hi; } *************** *** 1094,1124 **** password = argv[2]; argv[2] = "****"; ! if ((hi = nickserv_register(user, user, argv[1], password, no_auth))) { ! /* Add any masks they should get. */ ! if (nickserv_conf.default_hostmask) { ! string_list_append(hi->masks, strdup("*@*")); ! } else { ! string_list_append(hi->masks, generate_hostmask(user, GENMASK_OMITNICK|GENMASK_NO_HIDING|GENMASK_ANY_IDENT)); ! if (user->ip.s_addr) { ! string_list_append(hi->masks, generate_hostmask(user, GENMASK_OMITNICK|GENMASK_BYIP|GENMASK_NO_HIDING|GENMASK_ANY_IDENT)); ! } ! } ! /* If they're the first to register, give them level 1000. */ ! if (dict_size(nickserv_handle_dict) == 1) { ! hi->opserv_level = 1000; ! nickserv_notice(user, NSMSG_ROOT_HANDLE, argv[1]); ! } ! /* Set their email address. */ ! if (email_addr) nickserv_set_email_addr(hi, email_addr); ! /* If they need to do email verification, tell them. */ ! if (no_auth) nickserv_make_cookie(user, hi, ACTIVATION, hi->passwd); ! return 1; ! } else { ! return 0; ! } } --- 1093,1122 ---- password = argv[2]; argv[2] = "****"; ! if (!(hi = nickserv_register(user, user, argv[1], password, no_auth))) ! return 0; ! /* Add any masks they should get. */ ! if (nickserv_conf.default_hostmask) { ! string_list_append(hi->masks, strdup("*@*")); ! } else { ! string_list_append(hi->masks, generate_hostmask(user, GENMASK_OMITNICK|GENMASK_NO_HIDING|GENMASK_ANY_IDENT)); ! if (user->ip.s_addr) ! string_list_append(hi->masks, generate_hostmask(user, GENMASK_OMITNICK|GENMASK_BYIP|GENMASK_NO_HIDING|GENMASK_ANY_IDENT)); ! } ! /* If they're the first to register, give them level 1000. */ ! if (dict_size(nickserv_handle_dict) == 1) { ! hi->opserv_level = 1000; ! nickserv_notice(user, NSMSG_ROOT_HANDLE, argv[1]); ! } ! /* Set their email address. */ ! if (email_addr) ! nickserv_set_email_addr(hi, email_addr); ! /* If they need to do email verification, tell them. */ ! if (no_auth) ! nickserv_make_cookie(user, hi, ACTIVATION, hi->passwd); ! return 1; } *************** *** 1148,1152 **** } } else if ((settee = GetUserH(argv[3]))) { ! if (settee->handle_info && !oper_outranks(user, settee->handle_info)) return 0; mask = generate_hostmask(settee, GENMASK_OMITNICK|GENMASK_NO_HIDING|GENMASK_ANY_IDENT); } else { --- 1146,1151 ---- } } else if ((settee = GetUserH(argv[3]))) { ! if (settee->handle_info && !oper_outranks(user, settee->handle_info)) ! return 0; mask = generate_hostmask(settee, GENMASK_OMITNICK|GENMASK_NO_HIDING|GENMASK_ANY_IDENT); } else { *************** *** 1155,1164 **** } ! if ((hi = nickserv_register(user, settee, argv[1], argv[2], 0))) { ! string_list_append(hi->masks, mask); ! return 1; ! } else { ! return 0; ! } } --- 1154,1161 ---- } ! if (!(hi = nickserv_register(user, settee, argv[1], argv[2], 0))) ! return 0; ! string_list_append(hi->masks, mask); ! return 1; } *************** *** 1193,1207 **** nickserv_notice(user, NSMSG_HANDLEINFO_INFOLINE, (hi->infoline ? hi->infoline : NSMSG_NONE)); ! if (HANDLE_FLAGGED(hi, FROZEN)) nickserv_notice(user, NSMSG_HANDLEINFO_VACATION); ! if (hi != user->handle_info) { ! if (!is_valid_oper(user, 0, 1)) return 1; ! /* Normally, since we check for is_valid_oper, we'd want to log this ! * separately. But we've already logged it above. */ ! } ! if (nickserv_conf.email_enabled) { nickserv_notice(user, NSMSG_HANDLEINFO_EMAIL_ADDR, visible_email_addr(user, hi)); - } if (hi->cookie) { --- 1190,1201 ---- nickserv_notice(user, NSMSG_HANDLEINFO_INFOLINE, (hi->infoline ? hi->infoline : NSMSG_NONE)); ! if (HANDLE_FLAGGED(hi, FROZEN)) ! nickserv_notice(user, NSMSG_HANDLEINFO_VACATION); ! if ((hi != user->handle_info) && (!is_valid_oper(user, 0, 1))) ! return 1; ! if (nickserv_conf.email_enabled) nickserv_notice(user, NSMSG_HANDLEINFO_EMAIL_ADDR, visible_email_addr(user, hi)); if (hi->cookie) { *************** *** 1221,1227 **** char flags[34]; /* 32 bits possible plus '+' and '\0' */ flags[0] = '+'; ! for (i=0, flen=1; handle_flags[i]; i++) { ! if (hi->flags & 1 << i) flags[flen++] = handle_flags[i]; ! } flags[flen] = 0; nickserv_notice(user, NSMSG_HANDLEINFO_FLAGS, flags); --- 1215,1221 ---- char flags[34]; /* 32 bits possible plus '+' and '\0' */ flags[0] = '+'; ! for (i=0, flen=1; handle_flags[i]; i++) ! if (hi->flags & 1 << i) ! flags[flen++] = handle_flags[i]; flags[flen] = 0; nickserv_notice(user, NSMSG_HANDLEINFO_FLAGS, flags); *************** *** 1236,1244 **** } ! if (hi->last_quit_host[0]) { nickserv_notice(user, NSMSG_HANDLEINFO_LAST_HOST, hi->last_quit_host); ! } else { nickserv_notice(user, NSMSG_HANDLEINFO_LAST_HOST, NSMSG_UNKNOWN); - } if (nickserv_conf.disable_nicks) { --- 1230,1237 ---- } ! if (hi->last_quit_host[0]) nickserv_notice(user, NSMSG_HANDLEINFO_LAST_HOST, hi->last_quit_host); ! else nickserv_notice(user, NSMSG_HANDLEINFO_LAST_HOST, NSMSG_UNKNOWN); if (nickserv_conf.disable_nicks) { *************** *** 1271,1275 **** herelen = strlen(hi->masks->list[i]); if (pos + herelen + 1 > ArrayLength(buff)) { ! i--; goto print_mask_buff; } memcpy(buff+pos, hi->masks->list[i], herelen); --- 1264,1269 ---- herelen = strlen(hi->masks->list[i]); if (pos + herelen + 1 > ArrayLength(buff)) { ! i--; ! goto print_mask_buff; } memcpy(buff+pos, hi->masks->list[i], herelen); *************** *** 1296,1300 **** herelen = strlen(name); if (pos + herelen + 3 > ArrayLength(buff)) { ! next = channel; goto print_chans_buff; } if (IsUserSuspended(channel)) buff[pos++] = '-'; --- 1290,1295 ---- herelen = strlen(name); if (pos + herelen + 3 > ArrayLength(buff)) { ! next = channel; ! goto print_chans_buff; } if (IsUserSuspended(channel)) buff[pos++] = '-'; *************** *** 1330,1333 **** --- 1325,1329 ---- } } + return 1; } *************** *** 1366,1369 **** --- 1362,1366 ---- { struct handle_info *hi; + char *old_handle; unsigned int nn; *************** *** 1378,1387 **** return 0; } ! for (nn=0; nn<rf_list_used; nn++) { ! rf_list[nn](hi, argv[2]); ! } ! dict_remove2(nickserv_handle_dict, hi->handle, 1); ! safestrncpy(hi->handle, argv[2], sizeof(hi->handle)); dict_insert(nickserv_handle_dict, hi->handle, hi); if (argv[1][0] == '*') { nickserv_notice(user, NSMSG_HANDLE_CHANGED, argv[1]+1, argv[2]); --- 1375,1386 ---- return 0; } ! ! dict_remove2(nickserv_handle_dict, old_handle = hi->handle, 1); ! hi->handle = strdup(argv[2]); dict_insert(nickserv_handle_dict, hi->handle, hi); + for (nn=0; nn<rf_list_used; nn++) + rf_list[nn](hi, old_handle); + free(old_handle); + if (argv[1][0] == '*') { nickserv_notice(user, NSMSG_HANDLE_CHANGED, argv[1]+1, argv[2]); *************** *** 1412,1416 **** static NICKSERV_FUNC(cmd_auth) { ! int res, pw_arg; struct handle_info *hi; const char *passwd; --- 1411,1415 ---- static NICKSERV_FUNC(cmd_auth) { ! int pw_arg; struct handle_info *hi; const char *passwd; *************** *** 1457,1462 **** } passwd = argv[pw_arg]; ! res = valid_user_for(user, hi); ! if (!res) { if (hi->email_addr && nickserv_conf.email_enabled) { reply(NSMSG_USE_AUTHCOOKIE, hi->handle, hi->handle); --- 1456,1460 ---- } passwd = argv[pw_arg]; ! if (!valid_user_for(user, hi)) { if (hi->email_addr && nickserv_conf.email_enabled) { reply(NSMSG_USE_AUTHCOOKIE, hi->handle, hi->handle); *************** *** 3471,3474 **** --- 3469,3473 ---- nickserv_handle_dict = dict_new(); + dict_set_free_keys(nickserv_handle_dict, free); dict_set_free_data(nickserv_handle_dict, free_handle_info); Index: nickserv.h =================================================================== RCS file: /cvsroot/srvx/services/src/nickserv.h,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -r1.45 -r1.46 *** nickserv.h 5 Aug 2003 01:31:16 -0000 1.45 --- nickserv.h 9 Sep 2003 16:40:29 -0000 1.46 *************** *** 89,93 **** unsigned int table_width; time_t registered, lastseen; ! char handle[NICKSERV_HANDLE_LEN+1]; char passwd[MD5_CRYPT_LENGTH+1]; char last_quit_host[USERLEN+HOSTLEN+2]; --- 89,93 ---- unsigned int table_width; time_t registered, lastseen; ! char *handle; char passwd[MD5_CRYPT_LENGTH+1]; char last_quit_host[USERLEN+HOSTLEN+2]; |