X-Git-Url: https://jfr.im/git/irc/rqf/shadowircd.git/blobdiff_plain/0fdb2570901c40e19badddc9a17c82b66eac4487..3fe908250a691b033542815437696b2c29d9f1c0:/modules/m_xline.c diff --git a/modules/m_xline.c b/modules/m_xline.c index 1c7913d..fb615ad 100644 --- a/modules/m_xline.c +++ b/modules/m_xline.c @@ -31,7 +31,6 @@ */ #include "stdinc.h" -#include "tools.h" #include "send.h" #include "channel.h" #include "client.h" @@ -40,8 +39,7 @@ #include "class.h" #include "ircd.h" #include "numeric.h" -#include "memory.h" -#include "s_log.h" +#include "logger.h" #include "s_serv.h" #include "whowas.h" #include "irc_string.h" @@ -52,6 +50,7 @@ #include "modules.h" #include "s_conf.h" #include "s_newconf.h" +#include "reject.h" static int mo_xline(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]); static int ms_xline(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]); @@ -86,8 +85,8 @@ static void handle_remote_xline(struct Client *source_p, int temp_time, const char *name, const char *reason); 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 void remove_xline(struct Client *source_p, const char *gecos); +static void remove_xline(struct Client *source_p, const char *name); +static int remove_xline_from_file(struct Client *source_p, const char *gecos); /* m_xline() @@ -153,13 +152,13 @@ mo_xline(struct Client *client_p, struct Client *source_p, int parc, const char if(!match(target_server, me.name)) return 0; } - else if(dlink_list_length(&cluster_conf_list) > 0) + else if(rb_dlink_list_length(&cluster_conf_list) > 0) cluster_xline(source_p, temp_time, name, reason); if((aconf = find_xline_mask(name)) != NULL) { sendto_one(source_p, ":%s NOTICE %s :[%s] already X-Lined by [%s] - %s", - me.name, source_p->name, parv[1], aconf->name, aconf->passwd); + me.name, source_p->name, name, aconf->name, aconf->passwd); return 0; } @@ -312,17 +311,17 @@ apply_xline(struct Client *source_p, const char *name, const char *reason, } *new = '\0'; - DupString(aconf->name, tmp); + aconf->name = rb_strdup(tmp); } else - DupString(aconf->name, name); + aconf->name = rb_strdup(name); - DupString(aconf->passwd, reason); + aconf->passwd = rb_strdup(reason); collapse(aconf->name); if(temp_time > 0) { - aconf->hold = CurrentTime + temp_time; + aconf->hold = rb_current_time() + temp_time; sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s added temporary %d min. X-Line for [%s] [%s]", @@ -346,7 +345,7 @@ apply_xline(struct Client *source_p, const char *name, const char *reason, get_oper_name(source_p), name, reason); } - dlinkAddAlloc(aconf, &xline_conf_list); + rb_dlinkAddAlloc(aconf, &xline_conf_list); check_xlines(); } @@ -372,9 +371,9 @@ write_xline(struct Client *source_p, struct ConfItem *aconf) return; } - ircsprintf(buffer, "\"%s\",\"0\",\"%s\",\"%s\",%ld\n", + rb_sprintf(buffer, "\"%s\",\"0\",\"%s\",\"%s\",%ld\n", aconf->name, aconf->passwd, - get_oper_name(source_p), CurrentTime); + get_oper_name(source_p), (long) rb_current_time()); if(fputs(buffer, out) == -1) { @@ -417,9 +416,9 @@ cluster_xline(struct Client *source_p, int temp_time, const char *name, const char *reason) { struct remote_conf *shared_p; - dlink_node *ptr; + rb_dlink_node *ptr; - DLINK_FOREACH(ptr, cluster_conf_list.head) + RB_DLINK_FOREACH(ptr, cluster_conf_list.head) { shared_p = ptr->data; @@ -474,13 +473,10 @@ mo_unxline(struct Client *client_p, struct Client *source_p, int parc, const cha if(match(parv[3], me.name) == 0) return 0; } - else if(dlink_list_length(&cluster_conf_list)) + else if(rb_dlink_list_length(&cluster_conf_list)) cluster_generic(source_p, "UNXLINE", SHARED_UNXLINE, CAP_CLUSTER, "%s", parv[1]); - if(remove_temp_xline(source_p, parv[1])) - return 0; - remove_xline(source_p, parv[1]); return 0; @@ -527,56 +523,61 @@ handle_remote_unxline(struct Client *source_p, const char *name) source_p->servptr->name, SHARED_UNXLINE)) return; - if(remove_temp_xline(source_p, name)) - return; - remove_xline(source_p, name); return; } -static int -remove_temp_xline(struct Client *source_p, const char *name) +static void +remove_xline(struct Client *source_p, const char *name) { struct ConfItem *aconf; - dlink_node *ptr; + rb_dlink_node *ptr; - DLINK_FOREACH(ptr, xline_conf_list.head) + RB_DLINK_FOREACH(ptr, xline_conf_list.head) { aconf = ptr->data; - /* only want to check temp ones! */ - if(!aconf->hold) - continue; - if(!irccmp(aconf->name, 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); + if (!aconf->hold) + { + if (!remove_xline_from_file(source_p, name)) + return; + } + else + { + 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); + } + remove_reject_mask(aconf->name, NULL); free_conf(aconf); - dlinkDestroy(ptr, &xline_conf_list); - return 1; + rb_dlinkDestroy(ptr, &xline_conf_list); + return; } } - return 0; + sendto_one_notice(source_p, ":No X-Line for %s", name); + + return; } -/* remove_xline() +/* remove_xline_from_file() * * inputs - gecos to remove * outputs - * side effects - removes xline from conf, if exists + * - does not touch xline_conf_list */ -static void -remove_xline(struct Client *source_p, const char *huntgecos) +static int +remove_xline_from_file(struct Client *source_p, const char *huntgecos) { FILE *in, *out; char buf[BUFSIZE]; @@ -590,13 +591,13 @@ remove_xline(struct Client *source_p, const char *huntgecos) int found_xline = 0; filename = ConfigFileEntry.xlinefile; - ircsnprintf(temppath, sizeof(temppath), + rb_snprintf(temppath, sizeof(temppath), "%s.tmp", ConfigFileEntry.xlinefile); if((in = fopen(filename, "r")) == NULL) { sendto_one_notice(source_p, ":Cannot open %s", filename); - return; + return 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); fclose(in); umask(oldumask); - return; + return 0; } umask(oldumask); @@ -653,27 +654,28 @@ remove_xline(struct Client *source_p, const char *huntgecos) { sendto_one_notice(source_p, ":Couldn't write temp xline file, aborted"); - return; + return 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) (void) unlink(temppath); - return; + return 0; } if (rename(temppath, filename)) { 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_realops_snomask(SNO_GENERAL, L_ALL, "%s has removed the X-Line for: [%s]", get_oper_name(source_p), huntgecos); ilog(L_KLINE, "UX %s %s", get_oper_name(source_p), huntgecos); + + return 1; }