[srvx-commits] CVS: services/src proto.h,1.70,1.71 proto-p10.c,1.58,1.59 proto-bahamut.c,1.34,1.35 o
Brought to you by:
entrope
Update of /cvsroot/srvx/services/src
In directory sc8-pr-cvs1:/tmp/cvs-serv11371/src
Modified Files:
proto.h proto-p10.c proto-bahamut.c opserv.c nickserv.c
modcmd.c main.c helpserv.c hash.h hash.c
Log Message:
change uNode->nick from char[NICKLEN+1] to char*
change second arg of nick_change callbacks from new_nick to old_nick
bump MAXBANS to 45 to match new ircu defaults
make MODCMD_REQUIRE_JOINABLE apply to +s channels
check dict sanity at end of replays
Index: proto.h
===================================================================
RCS file: /cvsroot/srvx/services/src/proto.h,v
retrieving revision 1.70
retrieving revision 1.71
diff -C2 -r1.70 -r1.71
*** proto.h 10 Jan 2003 03:36:26 -0000 1.70
--- proto.h 21 Jan 2003 00:56:19 -0000 1.71
***************
*** 121,125 ****
void irc_server(struct server *srv);
void irc_user(struct userNode *user);
! void irc_nick(struct userNode *user, const char *new_nick);
void irc_introduce(const char *passwd);
void irc_ping(const char *something);
--- 121,125 ----
void irc_server(struct server *srv);
void irc_user(struct userNode *user);
! void irc_nick(struct userNode *user, const char *old_nick);
void irc_introduce(const char *passwd);
void irc_ping(const char *something);
Index: proto-p10.c
===================================================================
RCS file: /cvsroot/srvx/services/src/proto-p10.c,v
retrieving revision 1.58
retrieving revision 1.59
diff -C2 -r1.58 -r1.59
*** proto-p10.c 10 Jan 2003 03:36:26 -0000 1.58
--- proto-p10.c 21 Jan 2003 00:56:19 -0000 1.59
***************
*** 415,421 ****
void
! irc_nick(struct userNode *user, const char *new_nick)
{
! putsock("%s " P10_NICK " %s "FMT_TIME_T, user->numeric, new_nick, now);
}
--- 415,422 ----
void
! irc_nick(struct userNode *user, const char *old_nick)
{
! (void)old_nick;
! putsock("%s " P10_NICK " %s "FMT_TIME_T, user->numeric, user->nick, now);
}
***************
*** 728,732 ****
for (nn=0; nn<=self->num_mask; nn++) {
if (!(user = self->users[nn])) continue;
! strncpy(new_nick, user->nick, sizeof(new_nick));
new_nick[nicklen] = 0;
NickChange(user, new_nick, 1);
--- 729,733 ----
for (nn=0; nn<=self->num_mask; nn++) {
if (!(user = self->users[nn])) continue;
! safestrncpy(new_nick, user->nick, sizeof(new_nick));
new_nick[nicklen] = 0;
NickChange(user, new_nick, 1);
***************
*** 857,860 ****
--- 858,868 ----
static void
+ join_helper(struct chanNode *chan, void *data)
+ {
+ struct create_desc *cd = data;
+ AddChannelUser(cd->user, chan);
+ }
+
+ static void
create_helper(char *name, void *data)
{
***************
*** 868,871 ****
--- 876,890 ----
}
+ static void
+ join_0_helper(char *name, void *data)
+ {
+ struct create_desc *cd = data;
+ if (!strcmp(name, "0")) {
+ while (cd->user->channels.used>0) {
+ DelChannelUser(cd->user, cd->user->channels.list[cd->user->channels.used-1]->channel, 0, 0);
+ }
+ }
+ }
+
static CMD_FUNC(cmd_create)
{
***************
*** 874,887 ****
if (argc < 3) return 0;
! user = GetUserH(origin);
! if(!user) {
! /* The CREATE from this user probably crossed a KILL
! for the very same user. Bail. */
! return 0;
! }
!
cd.user = user;
cd.when = atoi(argv[2]);
! parse_foreach(argv[1], NULL, create_helper, NULL, NULL, &cd);
return 1;
}
--- 893,915 ----
if (argc < 3) return 0;
! if (!(user = GetUserH(origin))) return 0;
cd.user = user;
cd.when = atoi(argv[2]);
! parse_foreach(argv[1], join_helper, create_helper, NULL, NULL, &cd);
! return 1;
! }
!
! static CMD_FUNC(cmd_join)
! {
! struct create_desc cd;
!
! if (argc < 3) {
! if (argc < 2) return 0;
! cd.when = now;
! } else {
! cd.when = atoi(argv[2]);
! }
! if (!(cd.user = GetUserH(origin))) return 0;
! parse_foreach(argv[1], join_helper, create_helper, NULL, join_0_helper, &cd);
return 1;
}
***************
*** 949,952 ****
--- 977,981 ----
long mode;
char *user, *end, sep;
+ time_t in_timestamp;
(void)origin;
***************
*** 970,979 ****
}
! if (self->burst && (cNode = GetChannel(argv[1])) && dict_find(unbursted_channels, cNode->name, NULL)) {
! cNode->timestamp = atoi(argv[2]);
dict_remove(unbursted_channels, cNode->name);
irc_burst(cNode);
}
! cNode = AddChannel(argv[1], (time_t)atoi(argv[2]), modes, banlist);
/* Burst channel members in now. */
--- 999,1011 ----
}
! in_timestamp = atoi(argv[2]);
! if (self->burst
! && dict_find(unbursted_channels, argv[1], NULL)
! && (cNode = GetChannel(argv[1]))) {
! cNode->timestamp = in_timestamp;
dict_remove(unbursted_channels, cNode->name);
irc_burst(cNode);
}
! cNode = AddChannel(argv[1], in_timestamp, modes, banlist);
/* Burst channel members in now. */
***************
*** 1184,1229 ****
}
- static CMD_FUNC(cmd_join)
- {
- struct userNode *user;
- char old, *j, *target_list;
- int failed;
- struct chanNode *cn;
-
- if (argc < 2) return 0;
- if (!(user = GetUserH(origin))) {
- log(MAIN_LOG, LOG_ERROR, "Unable to find user %s joining a channel\n", origin);
- return 0;
- }
- target_list = argv[1];
- failed = 0;
- do {
- j = target_list;
- while (*j != 0 && *j != ',') j++;
- old = *j;
- *j = 0;
- if (IsChannelName(target_list)) {
- if ((cn = GetChannel(target_list))) {
- AddChannelUser(user, cn);
- } else if ((cn = AddChannel(target_list, 0, NULL, NULL))) {
- struct modeNode *mn = AddChannelUser(user, cn);
- if (mn) mn->modes = MODE_CHANOP;
- } else {
- log(MAIN_LOG, LOG_ERROR, "Unable to find or create join target %s\n", target_list);
- failed = 1;
- }
- } else if (!strcmp(target_list, "0")) {
- while (user->channels.used > 0) {
- DelChannelUser(user, user->channels.list[user->channels.used-1]->channel, false, 0);
- }
- } else {
- log(MAIN_LOG, LOG_ERROR, "Bad join target %s\n", target_list);
- failed = 1;
- }
- target_list = j+1;
- } while (old == ',');
- return !failed;
- }
-
static CMD_FUNC(cmd_part)
{
--- 1216,1219 ----
***************
*** 1799,1803 ****
/* create new usernode and set all values */
uNode = calloc(1, sizeof(*uNode));
! safestrncpy(uNode->nick, nick, sizeof(uNode->nick));
safestrncpy(uNode->ident, ident, sizeof(uNode->ident));
safestrncpy(uNode->info, userinfo, sizeof(uNode->info));
--- 1789,1793 ----
/* create new usernode and set all values */
uNode = calloc(1, sizeof(*uNode));
! uNode->nick = strdup(nick);
safestrncpy(uNode->ident, ident, sizeof(uNode->ident));
safestrncpy(uNode->info, userinfo, sizeof(uNode->info));
Index: proto-bahamut.c
===================================================================
RCS file: /cvsroot/srvx/services/src/proto-bahamut.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -r1.34 -r1.35
*** proto-bahamut.c 16 Jan 2003 23:06:49 -0000 1.34
--- proto-bahamut.c 21 Jan 2003 00:56:20 -0000 1.35
***************
*** 145,149 ****
uNode = calloc(1, sizeof(*uNode));
! safestrncpy(uNode->nick, nick, sizeof(uNode->nick));
safestrncpy(uNode->ident, ident, sizeof(uNode->ident));
safestrncpy(uNode->info, userinfo, sizeof(uNode->info));
--- 145,149 ----
uNode = calloc(1, sizeof(*uNode));
! uNode->nick = strdup(nick);
safestrncpy(uNode->ident, ident, sizeof(uNode->ident));
safestrncpy(uNode->info, userinfo, sizeof(uNode->info));
***************
*** 269,282 ****
void
! irc_nick(struct userNode *user, const char *new_nick) {
if (user->uplink == self) {
/* update entries in PRIVMSG/NOTICE handlers (if they exist) */
struct service_message_info *smi = dict_find(service_msginfo_dict, user->nick, NULL);
if (smi) {
! dict_remove2(service_msginfo_dict, user->nick, 1);
! dict_insert(service_msginfo_dict, new_nick, smi);
}
}
! putsock(":%s NICK %s :"FMT_TIME_T, user->nick, new_nick, user->timestamp);
}
--- 269,282 ----
void
! irc_nick(struct userNode *user, const char *old_nick) {
if (user->uplink == self) {
/* update entries in PRIVMSG/NOTICE handlers (if they exist) */
struct service_message_info *smi = dict_find(service_msginfo_dict, user->nick, NULL);
if (smi) {
! dict_remove2(service_msginfo_dict, old_nick, 1);
! dict_insert(service_msginfo_dict, user->nick, smi);
}
}
! putsock(":%s NICK %s :"FMT_TIME_T, old_nick, user->nick, user->timestamp);
}
Index: opserv.c
===================================================================
RCS file: /cvsroot/srvx/services/src/opserv.c,v
retrieving revision 1.305
retrieving revision 1.306
diff -C2 -r1.305 -r1.306
*** opserv.c 7 Jan 2003 05:02:08 -0000 1.305
--- opserv.c 21 Jan 2003 00:56:24 -0000 1.306
***************
*** 3622,3632 ****
static void
! opserv_alert_check_nick(struct userNode *user, const char *new_nick)
{
! char old_nick[NICKLEN+1];
! strcpy(old_nick, user->nick);
! strcpy(user->nick, new_nick);
dict_foreach(opserv_nick_based_alerts, alert_check_user, user);
- strcpy(user->nick, old_nick);
}
--- 3622,3629 ----
static void
! opserv_alert_check_nick(struct userNode *user, const char *old_nick)
{
! (void)old_nick;
dict_foreach(opserv_nick_based_alerts, alert_check_user, user);
}
Index: nickserv.c
===================================================================
RCS file: /cvsroot/srvx/services/src/nickserv.c,v
retrieving revision 1.228
retrieving revision 1.229
diff -C2 -r1.228 -r1.229
*** nickserv.c 16 Jan 2003 23:09:47 -0000 1.228
--- nickserv.c 21 Jan 2003 00:56:27 -0000 1.229
***************
*** 3210,3229 ****
static int
! check_user_nick(struct userNode *user, const char *nick) {
struct nick_info *ni;
user->modes &= ~FLAGS_REGNICK;
! if (!(ni = get_nick_info(nick))) return 0;
if (user->handle_info == ni->owner) {
user->modes |= FLAGS_REGNICK;
! /* Yes, I want a pointer compare. Compare handle_new_user()
! * to handle_nick_change(). */
! if (nick != user->nick) {
! /* Note to self: Use garbage collected pointers next time. Asshat. */
! char old_nick[NICKLEN+1];
! strcpy(old_nick, user->nick);
! strcpy(user->nick, nick);
! irc_regnick(user);
! strcpy(user->nick, nick);
! }
return 0;
}
--- 3210,3220 ----
static int
! check_user_nick(struct userNode *user) {
struct nick_info *ni;
user->modes &= ~FLAGS_REGNICK;
! if (!(ni = get_nick_info(user->nick))) return 0;
if (user->handle_info == ni->owner) {
user->modes |= FLAGS_REGNICK;
! irc_regnick(user);
return 0;
}
***************
*** 3243,3247 ****
handle_new_user(struct userNode *user)
{
! return check_user_nick(user, user->nick);
}
--- 3234,3238 ----
handle_new_user(struct userNode *user)
{
! return check_user_nick(user);
}
***************
*** 3268,3289 ****
void
! handle_nick_change(struct userNode *user, const char *new_nick)
{
struct handle_info *hi;
! if ((hi = dict_find(nickserv_allow_auth_dict, user->nick, 0))) {
! char old_nick[NICKLEN+1];
! /* Need to update allow_auth_dict. However, new_nick may be a
! * temporary pointer. The dict stores the key pointer. Make
! * sure it knows about the change but still points to
! * user->nick. */
! dict_remove(nickserv_allow_auth_dict, user->nick);
! strcpy(old_nick, user->nick);
! strcpy(user->nick, new_nick);
dict_insert(nickserv_allow_auth_dict, user->nick, hi);
- strcpy(user->nick, old_nick);
}
timeq_del(0, nickserv_reclaim_p, user, TIMEQ_IGNORE_WHEN);
! check_user_nick(user, new_nick);
}
--- 3259,3272 ----
void
! handle_nick_change(struct userNode *user, const char *old_nick)
{
struct handle_info *hi;
! if ((hi = dict_find(nickserv_allow_auth_dict, old_nick, 0))) {
! dict_remove(nickserv_allow_auth_dict, old_nick);
dict_insert(nickserv_allow_auth_dict, user->nick, hi);
}
timeq_del(0, nickserv_reclaim_p, user, TIMEQ_IGNORE_WHEN);
! check_user_nick(user);
}
Index: modcmd.c
===================================================================
RCS file: /cvsroot/srvx/services/src/modcmd.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -C2 -r1.48 -r1.49
*** modcmd.c 8 Jan 2003 23:51:41 -0000 1.48
--- modcmd.c 21 Jan 2003 00:56:27 -0000 1.49
***************
*** 472,476 ****
if (flags & MODCMD_REQUIRE_JOINABLE) {
if (!uData_checked) uData = _GetChannelUser(channel->channel_info, user->handle_info, 1, 0), uData_checked = 1;
! if ((channel->modes & (MODE_INVITEONLY|MODE_KEY))
&& (!channel->channel_info || !uData)
&& !IsService(user)
--- 472,476 ----
if (flags & MODCMD_REQUIRE_JOINABLE) {
if (!uData_checked) uData = _GetChannelUser(channel->channel_info, user->handle_info, 1, 0), uData_checked = 1;
! if ((channel->modes & (MODE_INVITEONLY|MODE_KEY|MODE_SECRET))
&& (!channel->channel_info || !uData)
&& !IsService(user)
***************
*** 1587,1599 ****
void
! modcmd_nick_change(struct userNode *user, const char *new_nick) {
! char old_nick[NICKLEN+1];
struct service *svc;
! if (!(svc = dict_find(services, user->nick, NULL))) return;
! dict_remove2(services, user->nick, 1);
! safestrncpy(old_nick, user->nick, sizeof(old_nick));
! safestrncpy(user->nick, new_nick, sizeof(user->nick));
dict_insert(services, user->nick, svc);
- safestrncpy(user->nick, old_nick, sizeof(user->nick));
}
--- 1587,1595 ----
void
! modcmd_nick_change(struct userNode *user, const char *old_nick) {
struct service *svc;
! if (!(svc = dict_find(services, old_nick, NULL))) return;
! dict_remove2(services, old_nick, 1);
dict_insert(services, user->nick, svc);
}
Index: main.c
===================================================================
RCS file: /cvsroot/srvx/services/src/main.c,v
retrieving revision 1.144
retrieving revision 1.145
diff -C2 -r1.144 -r1.145
*** main.c 9 Nov 2002 01:29:55 -0000 1.144
--- main.c 21 Jan 2003 00:56:27 -0000 1.145
***************
*** 794,800 ****
--- 794,813 ----
reg_exit_func(saxdb_write_all);
if (replay_file) {
+ char *msg;
log(MAIN_LOG, LOG_INFO, "Beginning replay...\n");
srand(now);
replay_event_loop();
+ if ((msg = dict_sanity_check(clients))) {
+ log(MAIN_LOG, LOG_ERROR, "Clients insanity: %s\n", msg);
+ free(msg);
+ }
+ if ((msg = dict_sanity_check(channels))) {
+ log(MAIN_LOG, LOG_ERROR, "Channels insanity: %s\n", msg);
+ free(msg);
+ }
+ if ((msg = dict_sanity_check(servers))) {
+ log(MAIN_LOG, LOG_ERROR, "Servers insanity: %s\n", msg);
+ free(msg);
+ }
} else {
srand(time(&now));
Index: helpserv.c
===================================================================
RCS file: /cvsroot/srvx/services/src/helpserv.c,v
retrieving revision 1.62
retrieving revision 1.63
diff -C2 -r1.62 -r1.63
*** helpserv.c 16 Jan 2003 23:18:11 -0000 1.62
--- helpserv.c 21 Jan 2003 00:56:27 -0000 1.63
***************
*** 3610,3636 ****
/* Update helpserv_reqs_bynick_dict upon nick change */
! static void handle_nickchange(struct userNode *user, const char *new_nick) {
! char old_nick[NICKLEN+1];
struct helpserv_reqlist *reqlist;
unsigned int i;
! if (!(reqlist = dict_find(helpserv_reqs_bynick_dict, user->nick, NULL))) {
return;
}
! /* Don't free the list */
! dict_remove2(helpserv_reqs_bynick_dict, user->nick, 1);
!
! /* new_nick may be a temporary pointer. The dict stores the key pointer.
! * Make sure it knows about the change but still points to user->nick. */
! strcpy(old_nick, user->nick);
! strcpy(user->nick, new_nick);
dict_insert(helpserv_reqs_bynick_dict, user->nick, reqlist);
- strcpy(user->nick, old_nick);
for (i=0; i < reqlist->used; i++) {
struct helpserv_request *req=reqlist->list[i];
! if (req->helper && (req->hs->notify >= NOTIFY_USER)) helpserv_notify(req->helper, HSMSG_NOTIFY_USER_NICK, req->id, user->nick, new_nick);
}
}
--- 3610,3629 ----
/* Update helpserv_reqs_bynick_dict upon nick change */
! static void handle_nickchange(struct userNode *user, const char *old_nick) {
struct helpserv_reqlist *reqlist;
unsigned int i;
! if (!(reqlist = dict_find(helpserv_reqs_bynick_dict, old_nick, NULL))) {
return;
}
! /* Don't free the list when we switch it over to the new nick. */
! dict_remove2(helpserv_reqs_bynick_dict, old_nick, 1);
dict_insert(helpserv_reqs_bynick_dict, user->nick, reqlist);
for (i=0; i < reqlist->used; i++) {
struct helpserv_request *req=reqlist->list[i];
! if (req->helper && (req->hs->notify >= NOTIFY_USER)) helpserv_notify(req->helper, HSMSG_NOTIFY_USER_NICK, req->id, old_nick, user->nick);
}
}
Index: hash.h
===================================================================
RCS file: /cvsroot/srvx/services/src/hash.h,v
retrieving revision 1.99
retrieving revision 1.100
diff -C2 -r1.99 -r1.100
*** hash.h 10 Jan 2003 03:36:26 -0000 1.99
--- hash.h 21 Jan 2003 00:56:27 -0000 1.100
***************
*** 81,85 ****
#define MAXMODEPARAMS 6
! #define MAXBANS 30
/* IDLEN is 6 because it takes 5.33 Base64 digits to store 32 bytes. */
--- 81,85 ----
#define MAXMODEPARAMS 6
! #define MAXBANS 45
/* IDLEN is 6 because it takes 5.33 Base64 digits to store 32 bytes. */
***************
*** 93,97 ****
struct userNode {
! char nick[NICKLEN + 1]; /* Unique name of the client, nick or host */
char ident[USERLEN + 1]; /* Per-host identification for user */
char info[REALLEN + 1]; /* Free form additional client information */
--- 93,97 ----
struct userNode {
! char *nick; /* Unique name of the client, nick or host */
char ident[USERLEN + 1]; /* Per-host identification for user */
char info[REALLEN + 1]; /* Free form additional client information */
***************
*** 198,202 ****
void unreg_del_user_func(del_user_func_t handler);
void ReintroduceUser(struct userNode* user);
! typedef void (*nick_change_func_t)(struct userNode *user, const char *new_nick);
void reg_nick_change_func(nick_change_func_t handler);
void NickChange(struct userNode* user, const char *new_nick, int no_announce);
--- 198,202 ----
void unreg_del_user_func(del_user_func_t handler);
void ReintroduceUser(struct userNode* user);
! typedef void (*nick_change_func_t)(struct userNode *user, const char *old_nick);
void reg_nick_change_func(nick_change_func_t handler);
void NickChange(struct userNode* user, const char *new_nick, int no_announce);
Index: hash.c
===================================================================
RCS file: /cvsroot/srvx/services/src/hash.c,v
retrieving revision 1.171
retrieving revision 1.172
diff -C2 -r1.171 -r1.172
*** hash.c 7 Jan 2003 04:23:12 -0000 1.171
--- hash.c 21 Jan 2003 00:56:29 -0000 1.172
***************
*** 166,198 ****
NickChange(struct userNode* user, const char *new_nick, int no_announce)
{
unsigned int nn;
/* don't do anything if there's no change */
! if (!strncmp(new_nick, user->nick, NICKLEN)) return;
/* remove old entry from clients dictionary */
! dict_remove(clients, user->nick);
#if !defined(WITH_PROTOCOL_P10)
/* Remove from uplink's clients dict */
! dict_remove(user->uplink->users, user->nick);
#endif
! /* Make callbacks for nick changes.
! * This needs to be done with the old nick still in place, else
! * dict lookups based on user->nick will miss the user.
*/
for (nn=0; nn<ncf2_used; nn++) {
! ncf2_list[nn](user, new_nick);
}
-
user->timestamp = now;
! if (IsLocal(user) && !no_announce) irc_nick(user, new_nick);
! /* Copy new nick into user structure */
! safestrncpy(user->nick, new_nick, sizeof(user->nick));
! /* Reinsert into dicts with the new nick */
! dict_insert(clients, user->nick, user);
! #if !defined(WITH_PROTOCOL_P10)
! dict_insert(user->uplink->users, user->nick, user);
! #endif
}
--- 166,198 ----
NickChange(struct userNode* user, const char *new_nick, int no_announce)
{
+ char *old_nick;
unsigned int nn;
/* don't do anything if there's no change */
! old_nick = user->nick;
! if (!strncmp(new_nick, old_nick, NICKLEN)) return;
/* remove old entry from clients dictionary */
! dict_remove(clients, old_nick);
#if !defined(WITH_PROTOCOL_P10)
/* Remove from uplink's clients dict */
! dict_remove(user->uplink->users, old_nick);
! #endif
! /* and reinsert */
! user->nick = strdup(new_nick);
! dict_insert(clients, user->nick, user);
! #if !defined(WITH_PROTOCOL_P10)
! dict_insert(user->uplink->users, user->nick, user);
#endif
! /* Make callbacks for nick changes. Do this with new nick in
! * place because that is slightly more useful.
*/
for (nn=0; nn<ncf2_used; nn++) {
! ncf2_list[nn](user, old_nick);
}
user->timestamp = now;
! if (IsLocal(user) && !no_announce) irc_nick(user, old_nick);
! free(old_nick);
}
|