[IRCServices Coding] akills

v13 at priest.com v13 at priest.com
Mon Dec 17 05:47:22 PST 2001


As of bahamut 1.4.29, s_serv.c -> m_akill() (in bahamut ircd sources)
has:

    /* whether or not we have a length, this is still a temporary akill */
    /* if the length is over a day, or nonexistant, we call this a 'forever'
     * akill and set ->hold to 0xFFFFFFFF to indicate such
     * this is a hack to prevent
     * forever akills from being removed unless by an explicit /rehash */
    if(length>86400 || !length)
        aconf->hold=0xFFFFFFFF;  
    else
        aconf->hold=timeset+length;

which means that akills whith expire time greater than a day, will never
expire, unless explicity removed. This way, netsplits may prevent akills
to be removed from servers, when services send the RAKILL. 

This can be bypassed, by forcing services to send AKILLs, with expire
time less than 86400 by 
changing (in operserv/akill.c send_akill() ):

call_callback_5(module, cb_send_akill,
		username, host, 
		akill->expires,
		akill->who,
		make_reason(AkillReason, akill));

to:

call_callback_5(module, cb_send_akill,
		username, host, 
		( (akill->expires - now) > 86399 ? now + 86399 : akill->expires),
		akill->who,
		make_reason(AkillReason, akill));

or better, change the callback in the bahamut protocol module:

static int do_send_akill(const char *username, const char *host,
                         time_t expires, const char *who, const char *reason)
{
    time_t now = time(NULL);

    send_cmd(ServerName, "AKILL %s %s %ld %s %ld :%s", host, username,
             (expires && expires > now) ? expires - now : 0,
             who ? who : "<unknown>", now, reason);
    return 1;
}

to:

static int do_send_akill(const char *username, const char *host,
                         time_t expires, const char *who, const char *reason)
{
	time_t now = time(NULL);

	if (expires>now)
	{
		expires-=now;
		if (expires>=86400)
			expires=86399;
	}

	send_cmd(ServerName, "AKILL %s %s %ld %s %ld :%s", host, username,
		expires, who ? who : "<unknown>", now, reason);
	return 1;
}

This way akills for 5 days, will be send up to 5 times on each server 
(Removed after 86399 seconds and send again when a matching user tries ti use 
the server). This should not add much overhead and non-expiring akills will 
not be affected.

<<V13>>