Make +p expiry more robust

This commit is contained in:
JD Horelick 2010-03-02 20:49:51 -05:00
parent 9ace21a74d
commit 1332a0ef97
3 changed files with 20 additions and 3 deletions

View File

@ -281,6 +281,8 @@ struct LocalUser
struct ev_entry *event; /* used for associated events */
struct PrivilegeSet *privset; /* privset... */
struct rb_event_t *override_timeout_event;
};
struct PreClient

View File

@ -232,6 +232,12 @@ free_local_client(struct Client *client_p)
}
rb_free(client_p->localClient->auth_user);
if(client_p->localClient->override_timeout_event)
{
rb_event_delete(client_p->localClient->override_timeout_event);
}
rb_free(client_p->localClient->challenge);
rb_free(client_p->localClient->fullcaps);
rb_free(client_p->localClient->opername);

View File

@ -910,6 +910,7 @@ expire_umode_p(void *data)
{
struct Client *source_p = data;
char *parv[4] = {source_p->name, source_p->name, "-p", NULL};
source_p->localClient->override_timeout_event = NULL;
user_mode(source_p, source_p, 3, parv);
}
@ -987,9 +988,17 @@ user_mode(struct Client *client_p, struct Client *source_p, int parc, const char
sendto_one_numeric(source_p, RPL_SNOMASK, form_str(RPL_SNOMASK),
construct_snobuf(source_p->snomask));
/* If we're setting +p, expire it */
if(ConfigFileEntry.expire_override_time && (source_p->umodes & ~setflags) & UMODE_OVERRIDE)
rb_event_addonce("expire_override", expire_umode_p, source_p, ConfigFileEntry.expire_override_time);
/* If we're setting +p, expire it, but only from local clients */
if(ConfigFileEntry.expire_override_time && MyClient(source_p) && (source_p->umodes & ~setflags) & UMODE_OVERRIDE)
{
source_p->localClient->override_timeout_event =
rb_event_addonce("expire_override", expire_umode_p, source_p, ConfigFileEntry.expire_override_time);
}
else if(MyClient(source_p) && source_p->localClient->override_timeout_event && (setflags & ~source_p->umodes) & UMODE_OVERRIDE)
{
rb_event_delete(source_p->localClient->override_timeout_event);
source_p->localClient->override_timeout_event = NULL;
}
return 0;
}