- Change find_exact_conf_by_address() to work for dlines also.
- Use find_exact_conf_by_address() to find the dline and
abort immediately if there is no such dline.
- When removing a permanent dline, remove the dline from
the data structures instead of rehashing bans.
- Convert alternative ways to write the same dline to the
one in the found dline. (This was changed in unkline too.)
static int valid_comment(char *comment);
static int flush_write(struct Client *, FILE *, char *, char *);
static int valid_comment(char *comment);
static int flush_write(struct Client *, FILE *, char *, char *);
-static int remove_temp_dline(const char *);
+static int remove_temp_dline(struct ConfItem *);
char buf[BUFSIZE], buff[BUFSIZE], temppath[BUFSIZE], *p;
const char *filename, *found_cidr;
const char *cidr;
char buf[BUFSIZE], buff[BUFSIZE], temppath[BUFSIZE], *p;
const char *filename, *found_cidr;
const char *cidr;
+ struct ConfItem *aconf;
int pairme = NO, error_on_write = NO;
mode_t oldumask;
int pairme = NO, error_on_write = NO;
mode_t oldumask;
- if(remove_temp_dline(cidr))
+ aconf = find_exact_conf_by_address(cidr, CONF_DLINE, NULL);
+ if(aconf == NULL)
+ {
+ sendto_one_notice(source_p, ":No D-Line for %s", cidr);
+ return 0;
+ }
+
+ strlcpy(buf, aconf->host, sizeof buf);
+ if(remove_temp_dline(aconf))
{
sendto_one(source_p,
":%s NOTICE %s :Un-dlined [%s] from temporary D-lines",
{
sendto_one(source_p,
":%s NOTICE %s :Un-dlined [%s] from temporary D-lines",
- me.name, parv[0], cidr);
+ me.name, parv[0], buf);
sendto_realops_snomask(SNO_GENERAL, L_ALL,
"%s has removed the temporary D-Line for: [%s]",
sendto_realops_snomask(SNO_GENERAL, L_ALL,
"%s has removed the temporary D-Line for: [%s]",
- get_oper_name(source_p), cidr);
- ilog(L_KLINE, "UD %s %s", get_oper_name(source_p), cidr);
+ get_oper_name(source_p), buf);
+ ilog(L_KLINE, "UD %s %s", get_oper_name(source_p), buf);
- if(irccmp(found_cidr, cidr) == 0)
+ if(irccmp(found_cidr, aconf->host) == 0)
- sendto_one(source_p, ":%s NOTICE %s :No D-Line for %s",
- me.name, parv[0], cidr);
+ sendto_one_notice(source_p, ":Cannot find D-Line for %s in file",
+ aconf->host);
if(temppath != NULL)
(void) unlink(temppath);
if(temppath != NULL)
(void) unlink(temppath);
sendto_one_notice(source_p, ":Couldn't rename temp file, aborted");
return 0;
}
sendto_one_notice(source_p, ":Couldn't rename temp file, aborted");
return 0;
}
- sendto_one(source_p, ":%s NOTICE %s :D-Line for [%s] is removed", me.name, parv[0], cidr);
+ sendto_one(source_p, ":%s NOTICE %s :D-Line for [%s] is removed", me.name, parv[0], aconf->host);
sendto_realops_snomask(SNO_GENERAL, L_ALL,
sendto_realops_snomask(SNO_GENERAL, L_ALL,
- "%s has removed the D-Line for: [%s]", get_oper_name(source_p), cidr);
- ilog(L_KLINE, "UD %s %s", get_oper_name(source_p), cidr);
+ "%s has removed the D-Line for: [%s]", get_oper_name(source_p), aconf->host);
+ ilog(L_KLINE, "UD %s %s", get_oper_name(source_p), aconf->host);
+
+ delete_one_address_conf(aconf->host, aconf);
- * inputs - hostname to undline
+ * inputs - confitem to undline
* outputs -
* side effects - tries to undline anything that matches
*/
static int
* outputs -
* side effects - tries to undline anything that matches
*/
static int
-remove_temp_dline(const char *host)
+remove_temp_dline(struct ConfItem *aconf)
- struct ConfItem *aconf;
- struct irc_sockaddr_storage addr, caddr;
- int bits, cbits;
- parse_netmask(host, (struct sockaddr *)&addr, &bits);
-
for (i = 0; i < LAST_TEMP_TYPE; i++)
{
DLINK_FOREACH(ptr, temp_dlines[i].head)
{
for (i = 0; i < LAST_TEMP_TYPE; i++)
{
DLINK_FOREACH(ptr, temp_dlines[i].head)
{
- aconf = ptr->data;
-
- parse_netmask(aconf->host, (struct sockaddr *)&caddr, &cbits);
-
- if(comp_with_mask_sock((struct sockaddr *)&addr, (struct sockaddr *)&caddr, bits) && bits == cbits)
+ if (aconf == ptr->data)
{
dlinkDestroy(ptr, &temp_dlines[i]);
delete_one_address_conf(aconf->host, aconf);
{
dlinkDestroy(ptr, &temp_dlines[i]);
delete_one_address_conf(aconf->host, aconf);
return find_conf_by_address(NULL, NULL, NULL, addr, CONF_DLINE | 1, aftype, NULL);
}
return find_conf_by_address(NULL, NULL, NULL, addr, CONF_DLINE | 1, aftype, NULL);
}
-/* void find_exact_conf_by_address(const char*, int, const char *,
- * struct ConfItem *aconf)
+/* void find_exact_conf_by_address(const char*, int, const char *)
* Input:
* Output: ConfItem if found
* Side-effects: None
* Input:
* Output: ConfItem if found
* Side-effects: None
{
if (arec->type == type &&
arec->masktype == masktype &&
{
if (arec->type == type &&
arec->masktype == masktype &&
- !irccmp(arec->username, username))
+ (arec->username == NULL || username == NULL ? arec->username == username : !irccmp(arec->username, username)))
{
if (masktype == HM_HOST)
{
{
if (masktype == HM_HOST)
{