Speed up /unxline similarly.

This commit is contained in:
Jilles Tjoelker 2007-11-30 14:10:24 +01:00
parent 6f3a09ff67
commit 5408b484da

View file

@ -86,8 +86,8 @@ static void handle_remote_xline(struct Client *source_p, int temp_time,
const char *name, const char *reason); const char *name, const char *reason);
static void handle_remote_unxline(struct Client *source_p, const char *name); static void handle_remote_unxline(struct Client *source_p, const char *name);
static int remove_temp_xline(struct Client *source_p, const char *name); static int remove_xline(struct Client *source_p, const char *name);
static void remove_xline(struct Client *source_p, const char *gecos); static int remove_xline_from_file(struct Client *source_p, const char *gecos);
/* m_xline() /* m_xline()
@ -478,9 +478,6 @@ mo_unxline(struct Client *client_p, struct Client *source_p, int parc, const cha
cluster_generic(source_p, "UNXLINE", SHARED_UNXLINE, CAP_CLUSTER, cluster_generic(source_p, "UNXLINE", SHARED_UNXLINE, CAP_CLUSTER,
"%s", parv[1]); "%s", parv[1]);
if(remove_temp_xline(source_p, parv[1]))
return 0;
remove_xline(source_p, parv[1]); remove_xline(source_p, parv[1]);
return 0; return 0;
@ -527,16 +524,13 @@ handle_remote_unxline(struct Client *source_p, const char *name)
source_p->servptr->name, SHARED_UNXLINE)) source_p->servptr->name, SHARED_UNXLINE))
return; return;
if(remove_temp_xline(source_p, name))
return;
remove_xline(source_p, name); remove_xline(source_p, name);
return; return;
} }
static int static int
remove_temp_xline(struct Client *source_p, const char *name) remove_xline(struct Client *source_p, const char *name)
{ {
struct ConfItem *aconf; struct ConfItem *aconf;
dlink_node *ptr; dlink_node *ptr;
@ -545,20 +539,24 @@ remove_temp_xline(struct Client *source_p, const char *name)
{ {
aconf = ptr->data; aconf = ptr->data;
/* only want to check temp ones! */
if(!aconf->hold)
continue;
if(!irccmp(aconf->name, name)) if(!irccmp(aconf->name, name))
{ {
sendto_one_notice(source_p, if (!aconf->hold)
":X-Line for [%s] is removed", {
name); if (!remove_xline_from_file(source_p, name))
sendto_realops_snomask(SNO_GENERAL, L_ALL, return 0;
"%s has removed the temporary X-Line for: [%s]", }
get_oper_name(source_p), name); else
ilog(L_KLINE, "UX %s %s", {
get_oper_name(source_p), name); sendto_one_notice(source_p,
":X-Line for [%s] is removed",
name);
sendto_realops_snomask(SNO_GENERAL, L_ALL,
"%s has removed the temporary X-Line for: [%s]",
get_oper_name(source_p), name);
ilog(L_KLINE, "UX %s %s",
get_oper_name(source_p), name);
}
free_conf(aconf); free_conf(aconf);
dlinkDestroy(ptr, &xline_conf_list); dlinkDestroy(ptr, &xline_conf_list);
@ -566,6 +564,8 @@ remove_temp_xline(struct Client *source_p, const char *name)
} }
} }
sendto_one_notice(source_p, ":No X-Line for %s", name);
return 0; return 0;
} }
@ -574,9 +574,10 @@ remove_temp_xline(struct Client *source_p, const char *name)
* inputs - gecos to remove * inputs - gecos to remove
* outputs - * outputs -
* side effects - removes xline from conf, if exists * side effects - removes xline from conf, if exists
* - does not touch xline_conf_list
*/ */
static void static int
remove_xline(struct Client *source_p, const char *huntgecos) remove_xline_from_file(struct Client *source_p, const char *huntgecos)
{ {
FILE *in, *out; FILE *in, *out;
char buf[BUFSIZE]; char buf[BUFSIZE];
@ -596,7 +597,7 @@ remove_xline(struct Client *source_p, const char *huntgecos)
if((in = fopen(filename, "r")) == NULL) if((in = fopen(filename, "r")) == NULL)
{ {
sendto_one_notice(source_p, ":Cannot open %s", filename); sendto_one_notice(source_p, ":Cannot open %s", filename);
return; return 0;
} }
oldumask = umask(0); oldumask = umask(0);
@ -606,7 +607,7 @@ remove_xline(struct Client *source_p, const char *huntgecos)
sendto_one_notice(source_p, ":Cannot open %s", temppath); sendto_one_notice(source_p, ":Cannot open %s", temppath);
fclose(in); fclose(in);
umask(oldumask); umask(oldumask);
return; return 0;
} }
umask(oldumask); umask(oldumask);
@ -653,27 +654,28 @@ remove_xline(struct Client *source_p, const char *huntgecos)
{ {
sendto_one_notice(source_p, sendto_one_notice(source_p,
":Couldn't write temp xline file, aborted"); ":Couldn't write temp xline file, aborted");
return; return 0;
} }
else if(found_xline == 0) else if(found_xline == 0)
{ {
sendto_one_notice(source_p, ":No X-Line for %s", huntgecos); sendto_one_notice(source_p, ":Cannot find X-Line for %s in file", huntgecos);
if(temppath != NULL) if(temppath != NULL)
(void) unlink(temppath); (void) unlink(temppath);
return; return 0;
} }
if (rename(temppath, filename)) if (rename(temppath, filename))
{ {
sendto_one_notice(source_p, ":Couldn't rename temp file, aborted"); sendto_one_notice(source_p, ":Couldn't rename temp file, aborted");
return; return 0;
} }
rehash_bans(0);
sendto_one_notice(source_p, ":X-Line for [%s] is removed", huntgecos); sendto_one_notice(source_p, ":X-Line for [%s] is removed", huntgecos);
sendto_realops_snomask(SNO_GENERAL, L_ALL, sendto_realops_snomask(SNO_GENERAL, L_ALL,
"%s has removed the X-Line for: [%s]", "%s has removed the X-Line for: [%s]",
get_oper_name(source_p), huntgecos); get_oper_name(source_p), huntgecos);
ilog(L_KLINE, "UX %s %s", get_oper_name(source_p), huntgecos); ilog(L_KLINE, "UX %s %s", get_oper_name(source_p), huntgecos);
return 1;
} }