[IRCServices Coding] [IRCServices] akick not setting channel ban

Aragon Gouveia aragon at phat.za.net
Tue Nov 25 03:52:53 PST 2008


Hi,

First of all, pardon my serious case of thread necro.  I decided to rather
resurrect this so that some history is at hand. :)

| By Andrew Church <achurch at achurch.org>
|                                          [ 2005-09-12 05:02 +0200 ]
> >I suspect that some of the irc servers in the network drop a ban
> >silently, resulting in services having this ban on their list, which
> >is desynched from the rest of the network in this case. I've seen
> >similar situations with old hybrid servers and other services, but who
> >knows..
> 
>      That's an interesting possibility.  To the original poster: try
> applying the following patch to Services, then recompiling and restarting
> in debug mode (ircservices -debug).  When you see the bug happening, check
> the logfile and see if the ban in question is listed.  (Also, if you could
> privately send me the full debug logfile for further analysis I'd
> appreciate it.)

I applied your patch (2 years ago), thank you.  However, it didn't help
locate the problem and I never really got the time to focus enough energy on
it again until recently.  Been living with this bug since then.

So it's been a while.  I extended your patch a bit by adding logging points
into do_cmode() to see when bans get set too.  The interesting bits:

case 'b':
if (add) {
    ARRAY_EXTEND(chan->bans);
    chan->bans[chan->bans_count-1] = sstrdup(av[0]);
    log("addban([%s],[%s],[%d])", chan->name,
        chan->bans[chan->bans_count-1], chan->bans_count-1);
} else {
    int i = find_ban(chan, av[0]);
    if (i >= 0) {
        log("find_ban() true, free([%s])", chan->bans[i]);
        free(chan->bans[i]);
        ARRAY_REMOVE(chan->bans, i);
    } else {


And when the last server relinked a few times:

[Nov 23 16:57:33 2008] find_ban([#5fm],[shand0ra*!*@*])
[Nov 23 16:57:33 2008] ... NOT found
[Nov 23 16:57:33 2008] addban([#5fm],[shand0ra*!*@*],[0])
[Nov 23 21:09:56 2008] addban([#5fm],[shand0ra*!*@*],[1])
[Nov 23 21:25:20 2008] addban([#5fm],[shand0ra*!*@*],[2])

And the next find_ban after that:

[Nov 24 10:55:01 2008] find_ban([#5fm],[killer!*@*])
[Nov 24 10:55:01 2008] ... checking [shand0ra*!*@*]
[Nov 24 10:55:01 2008] ... checking [shand0ra*!*@*]
[Nov 24 10:55:01 2008] ... checking [shand0ra*!*@*]
[Nov 24 10:55:01 2008] ... checking [killer!*@*]
[Nov 24 10:55:01 2008] ... found[1]!
[Nov 24 10:55:01 2008] find_ban() true, free([killer!*@*])


So I've changed do_cmode:

case 'b':
if (add) {
    int i = find_ban(chan, av[0]);
    if (i == -1) {
            ARRAY_EXTEND(chan->bans);
            chan->bans[chan->bans_count-1] = sstrdup(av[0]);
    }


Which I've tested with some oper assisted relinking and things look much
better now.  I believe 5.1's do_cmode will cause the same problems (it looks
the same as 5.0's).

Better late than never they say. :)


Regards,
Aragon


> 
> Index: channels.c
> ===================================================================
> RCS file: /var/local/cvsroot/ircservices/channels.c,v
> retrieving revision 2.43.2.1
> diff -u -r2.43.2.1 channels.c
> --- channels.c	6 Jan 2005 17:15:11 -0000	2.43.2.1
> +++ channels.c	12 Sep 2005 03:01:04 -0000
> @@ -192,22 +192,33 @@
>  
>      t = strchr(ban, '!');
>      i = 0;
> +    if (debug)
> +	log("find_ban([%s],[%s])", chan->name, ban);
>      ARRAY_FOREACH (i, chan->bans) {
> +	if (debug)
> +	    log("... checking [%s]", chan->bans[i]);
>  	s = strchr(chan->bans[i], '!');
>  	if (s && t) {
>  	    if (s-(chan->bans[i]) == t-ban
>  	     && irc_strnicmp(chan->bans[i], ban, s-(chan->bans[i])) == 0
>  	     && stricmp(s+1, t+1) == 0
>  	    ) {
> +		if (debug)
> +		    log("... found!");
>  		return i;
>  	    }
>  	} else if (!s && !t) {
>  	    /* Bans without '!' should be impossible; just
>  	     * do a case-insensitive compare */
> -	    if (stricmp(chan->bans[i], ban) == 0)
> +	    if (stricmp(chan->bans[i], ban) == 0) {
> +		if (debug)
> +		    log("... found!");
>  		return i;
> +	    }
>  	}
>      }
> +    if (debug)
> +	log("... NOT found");
>      return -1;
>  }