Explicitly pass the current time to deactivate_conf().

Some places depend on the ban not being destroyed.
This commit is contained in:
Jilles Tjoelker 2014-09-21 15:02:43 +02:00
parent 2196b1825d
commit 483987a464
5 changed files with 28 additions and 19 deletions

View file

@ -339,7 +339,7 @@ extern struct ConfItem *make_conf(void);
extern void free_conf(struct ConfItem *);
extern rb_dlink_node *find_prop_ban(unsigned int status, const char *user, const char *host);
extern void deactivate_conf(struct ConfItem *, rb_dlink_node *);
extern void deactivate_conf(struct ConfItem *, rb_dlink_node *, time_t);
extern void replace_old_ban(struct ConfItem *);
extern void read_conf_files(int cold);

View file

@ -834,6 +834,7 @@ static void
remove_prop_kline(struct Client *source_p, struct ConfItem *aconf)
{
rb_dlink_node *ptr;
time_t now;
ptr = rb_dlinkFind(aconf, &prop_bans);
if (!ptr)
@ -848,8 +849,9 @@ remove_prop_kline(struct Client *source_p, struct ConfItem *aconf)
ilog(L_KLINE, "UK %s %s %s",
get_oper_name(source_p), aconf->user, aconf->host);
if(aconf->created < rb_current_time())
aconf->created = rb_current_time();
now = rb_current_time();
if(aconf->created < now)
aconf->created = now;
else
aconf->created++;
aconf->hold = aconf->created;
@ -863,5 +865,5 @@ remove_prop_kline(struct Client *source_p, struct ConfItem *aconf)
0,
(int)(aconf->lifetime - aconf->created));
remove_reject_mask(aconf->user, aconf->host);
deactivate_conf(aconf, ptr);
deactivate_conf(aconf, ptr, now);
}

View file

@ -513,6 +513,7 @@ remove_resv(struct Client *source_p, const char *name, int propagated)
{
struct ConfItem *aconf = NULL;
rb_dlink_node *ptr;
time_t now;
if(IsChannelName(name))
{
@ -540,8 +541,9 @@ remove_resv(struct Client *source_p, const char *name, int propagated)
"%s has removed the global RESV for: [%s]",
get_oper_name(source_p), name);
ilog(L_KLINE, "UR %s %s", get_oper_name(source_p), name);
if(aconf->created < rb_current_time())
aconf->created = rb_current_time();
now = rb_current_time();
if(aconf->created < now)
aconf->created = now;
else
aconf->created++;
aconf->hold = aconf->created;
@ -554,7 +556,7 @@ remove_resv(struct Client *source_p, const char *name, int propagated)
(unsigned long)aconf->created,
0,
(int)(aconf->lifetime - aconf->created));
deactivate_conf(aconf, ptr);
deactivate_conf(aconf, ptr, now);
return;
}
else if(propagated && rb_dlink_list_length(&cluster_conf_list) > 0)
@ -613,8 +615,9 @@ remove_resv(struct Client *source_p, const char *name, int propagated)
"%s has removed the global RESV for: [%s]",
get_oper_name(source_p), name);
ilog(L_KLINE, "UR %s %s", get_oper_name(source_p), name);
if(aconf->created < rb_current_time())
aconf->created = rb_current_time();
now = rb_current_time();
if(aconf->created < now)
aconf->created = now;
else
aconf->created++;
aconf->hold = aconf->created;
@ -627,7 +630,7 @@ remove_resv(struct Client *source_p, const char *name, int propagated)
(unsigned long)aconf->created,
0,
(int)(aconf->lifetime - aconf->created));
deactivate_conf(aconf, ptr);
deactivate_conf(aconf, ptr, now);
return;
}
else if(propagated && rb_dlink_list_length(&cluster_conf_list) > 0)

View file

@ -471,6 +471,7 @@ remove_xline(struct Client *source_p, const char *name, int propagated)
{
struct ConfItem *aconf;
rb_dlink_node *ptr;
time_t now;
RB_DLINK_FOREACH(ptr, xline_conf_list.head)
{
@ -493,8 +494,9 @@ remove_xline(struct Client *source_p, const char *name, int propagated)
"%s has removed the global X-Line for: [%s]",
get_oper_name(source_p), name);
ilog(L_KLINE, "UX %s %s", get_oper_name(source_p), name);
if(aconf->created < rb_current_time())
aconf->created = rb_current_time();
now = rb_current_time();
if(aconf->created < now)
aconf->created = now;
else
aconf->created++;
aconf->hold = aconf->created;
@ -508,7 +510,7 @@ remove_xline(struct Client *source_p, const char *name, int propagated)
0,
(int)(aconf->lifetime - aconf->created));
remove_reject_mask(aconf->host, NULL);
deactivate_conf(aconf, ptr);
deactivate_conf(aconf, ptr, now);
return;
}
else if(propagated && rb_dlink_list_length(&cluster_conf_list))

View file

@ -1057,7 +1057,7 @@ find_prop_ban(unsigned int status, const char *user, const char *host)
}
void
deactivate_conf(struct ConfItem *aconf, rb_dlink_node *ptr)
deactivate_conf(struct ConfItem *aconf, rb_dlink_node *ptr, time_t now)
{
int i;
@ -1096,7 +1096,7 @@ deactivate_conf(struct ConfItem *aconf, rb_dlink_node *ptr)
del_from_resv_hash(aconf->host, aconf);
break;
}
if (aconf->lifetime != 0 && rb_current_time() < aconf->lifetime)
if (aconf->lifetime != 0 && now < aconf->lifetime)
aconf->status |= CONF_ILLEGAL;
else
{
@ -1132,7 +1132,7 @@ replace_old_ban(struct ConfItem *aconf)
aconf->lifetime = aconf->hold;
/* Tell deactivate_conf() to destroy it. */
oldconf->lifetime = rb_current_time();
deactivate_conf(oldconf, ptr);
deactivate_conf(oldconf, ptr, oldconf->lifetime);
}
}
@ -1142,13 +1142,15 @@ expire_prop_bans(void *list)
rb_dlink_node *ptr;
rb_dlink_node *next_ptr;
struct ConfItem *aconf;
time_t now;
now = rb_current_time();
RB_DLINK_FOREACH_SAFE(ptr, next_ptr, ((rb_dlink_list *) list)->head)
{
aconf = ptr->data;
if(aconf->lifetime <= rb_current_time() ||
(aconf->hold <= rb_current_time() &&
if(aconf->lifetime <= now ||
(aconf->hold <= now &&
!(aconf->status & CONF_ILLEGAL)))
{
/* Alert opers that a TKline expired - Hwy */
@ -1162,7 +1164,7 @@ expire_prop_bans(void *list)
aconf->host ? aconf->host : "*");
/* will destroy or mark illegal */
deactivate_conf(aconf, ptr);
deactivate_conf(aconf, ptr, now);
}
}
}