]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - modules/m_xline.c
Allow /ojoin !#channel/%#channel, if admin/halfop are enabled.
[irc/rqf/shadowircd.git] / modules / m_xline.c
index 1c7913df6ae9b9ecc31eec76756ed8fe3fd788dd..d1975ecdb8436b98745023364e83e3354d482958 100644 (file)
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  *
- * $Id: m_xline.c 3161 2007-01-25 07:23:01Z nenolod $
+ * $Id$
  */
 
 #include "stdinc.h"
-#include "tools.h"
 #include "send.h"
 #include "channel.h"
 #include "client.h"
 #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"
-#include "sprintf_irc.h"
+#include "match.h"
 #include "hash.h"
 #include "msg.h"
 #include "parse.h"
 #include "modules.h"
 #include "s_conf.h"
 #include "s_newconf.h"
+#include "reject.h"
+#include "bandbi.h"
+#include "operhash.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[]);
 static int me_xline(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
-static int mo_unxline(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
-static int ms_unxline(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
-static int me_unxline(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
+static int mo_unxline(struct Client *client_p, struct Client *source_p, int parc,
+                     const char *parv[]);
+static int ms_unxline(struct Client *client_p, struct Client *source_p, int parc,
+                     const char *parv[]);
+static int me_unxline(struct Client *client_p, struct Client *source_p, int parc,
+                     const char *parv[]);
 
 struct Message xline_msgtab = {
        "XLINE", 0, 0, 0, MFLG_SLOW,
        {mg_unreg, mg_not_oper, {ms_xline, 5}, {ms_xline, 5}, {me_xline, 5}, {mo_xline, 3}}
 };
+
 struct Message unxline_msgtab = {
        "UNXLINE", 0, 0, 0, MFLG_SLOW,
        {mg_unreg, mg_not_oper, {ms_unxline, 3}, {ms_unxline, 3}, {me_unxline, 2}, {mo_unxline, 2}}
 };
 
-mapi_clist_av1 xline_clist[] =  { &xline_msgtab, &unxline_msgtab, NULL };
-DECLARE_MODULE_AV1(xline, NULL, NULL, xline_clist, NULL, NULL, "$Revision: 3161 $");
+mapi_clist_av1 xline_clist[] = { &xline_msgtab, &unxline_msgtab, NULL };
+
+DECLARE_MODULE_AV1(xline, NULL, NULL, xline_clist, NULL, NULL, "$Revision$");
 
 static int valid_xline(struct Client *, const char *, const char *);
-static void apply_xline(struct Client *client_p, const char *name, 
-                       const char *reason, int temp_time);
-static void write_xline(struct Client *source_p, struct ConfItem *aconf);
+static void apply_xline(struct Client *client_p, const char *name,
+                       const char *reason, int temp_time, int propagated);
 static void propagate_xline(struct Client *source_p, const char *target,
-                       int temp_time, const char *name, 
-                       const char *type, const char *reason);
+                           int temp_time, const char *name, const char *type, const char *reason);
 static void cluster_xline(struct Client *source_p, int temp_time,
-                       const char *name, const char *reason);
+                         const char *name, const char *reason);
 
 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,
+                        int propagated);
 
 
 /* m_xline()
@@ -105,11 +108,11 @@ mo_xline(struct Client *client_p, struct Client *source_p, int parc, const char
        const char *target_server = NULL;
        int temp_time;
        int loc = 1;
+       int propagated = ConfigFileEntry.use_propagated_bans;
 
        if(!IsOperXline(source_p))
        {
-               sendto_one(source_p, form_str(ERR_NOPRIVS),
-                          me.name, source_p->name, "xline");
+               sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "xline");
                return 0;
        }
 
@@ -123,23 +126,23 @@ mo_xline(struct Client *client_p, struct Client *source_p, int parc, const char
        loc++;
 
        /* XLINE <gecos> ON <server> :<reason> */
-       if(parc >= loc+2 && !irccmp(parv[loc], "ON"))
+       if(parc >= loc + 2 && !irccmp(parv[loc], "ON"))
        {
                if(!IsOperRemoteBan(source_p))
                {
                        sendto_one(source_p, form_str(ERR_NOPRIVS),
-                               me.name, source_p->name, "remoteban");
+                                  me.name, source_p->name, "remoteban");
                        return 0;
                }
 
-               target_server = parv[loc+1];
+               target_server = parv[loc + 1];
                loc += 2;
        }
 
        if(parc <= loc || EmptyString(parv[loc]))
        {
                sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
-                               me.name, source_p->name, "XLINE");
+                          me.name, source_p->name, "XLINE");
                return 0;
        }
 
@@ -147,26 +150,34 @@ mo_xline(struct Client *client_p, struct Client *source_p, int parc, const char
 
        if(target_server != NULL)
        {
-               propagate_xline(source_p, target_server, temp_time,
-                               name, "2", reason);
+               propagate_xline(source_p, target_server, temp_time, name, "2", reason);
 
                if(!match(target_server, me.name))
                        return 0;
+
+               /* Set as local-only. */
+               propagated = 0;
        }
-       else if(dlink_list_length(&cluster_conf_list) > 0)
+       else if(!propagated && 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->host, aconf->passwd);
                return 0;
        }
 
        if(!valid_xline(source_p, name, reason))
                return 0;
 
-       apply_xline(source_p, name, reason, temp_time);
+       if(propagated && temp_time == 0)
+       {
+               sendto_one_notice(source_p, ":Cannot set a permanent global ban");
+               return 0;
+       }
+
+       apply_xline(source_p, name, reason, temp_time, propagated);
 
        return 0;
 }
@@ -206,14 +217,13 @@ me_xline(struct Client *client_p, struct Client *source_p, int parc, const char
 }
 
 static void
-handle_remote_xline(struct Client *source_p, int temp_time,
-                       const char *name, const char *reason)
+handle_remote_xline(struct Client *source_p, int temp_time, const char *name, const char *reason)
 {
        struct ConfItem *aconf;
 
        if(!find_shared_conf(source_p->username, source_p->host,
-                               source_p->servptr->name,
-                               (temp_time > 0) ? SHARED_TXLINE : SHARED_PXLINE))
+                            source_p->servptr->name,
+                            (temp_time > 0) ? SHARED_TXLINE : SHARED_PXLINE))
                return;
 
        if(!valid_xline(source_p, name, reason))
@@ -222,11 +232,12 @@ handle_remote_xline(struct Client *source_p, int temp_time,
        /* already xlined */
        if((aconf = find_xline_mask(name)) != NULL)
        {
-               sendto_one_notice(source_p, ":[%s] already X-Lined by [%s] - %s", name, aconf->name, aconf->passwd);
+               sendto_one_notice(source_p, ":[%s] already X-Lined by [%s] - %s", name, aconf->host,
+                                 aconf->passwd);
                return;
        }
 
-       apply_xline(source_p, name, reason, temp_time);
+       apply_xline(source_p, name, reason, temp_time, 0);
 }
 
 /* valid_xline()
@@ -236,28 +247,24 @@ handle_remote_xline(struct Client *source_p, int temp_time,
  * side effects - checks the xline for validity, erroring if needed
  */
 static int
-valid_xline(struct Client *source_p, const char *gecos,
-           const char *reason)
+valid_xline(struct Client *source_p, const char *gecos, const char *reason)
 {
        if(EmptyString(reason))
        {
                sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
-                          get_id(&me, source_p), 
-                          get_id(source_p, source_p), "XLINE");
+                          get_id(&me, source_p), get_id(source_p, source_p), "XLINE");
                return 0;
        }
 
        if(strchr(reason, ':') != NULL)
        {
-               sendto_one_notice(source_p,
-                                 ":Invalid character ':' in comment");
+               sendto_one_notice(source_p, ":Invalid character ':' in comment");
                return 0;
        }
 
        if(strchr(reason, '"'))
        {
-               sendto_one_notice(source_p,
-                               ":Invalid character '\"' in comment");
+               sendto_one_notice(source_p, ":Invalid character '\"' in comment");
                return 0;
        }
 
@@ -274,152 +281,96 @@ valid_xline(struct Client *source_p, const char *gecos,
 }
 
 void
-apply_xline(struct Client *source_p, const char *name, const char *reason,
-               int temp_time)
+apply_xline(struct Client *source_p, const char *name, const char *reason, int temp_time, int propagated)
 {
        struct ConfItem *aconf;
 
        aconf = make_conf();
        aconf->status = CONF_XLINE;
+       aconf->created = rb_current_time();
+       aconf->host = rb_strdup(name);
+       aconf->passwd = rb_strdup(reason);
+       collapse(aconf->host);
 
-       if(strstr(name, "\\s"))
+       aconf->info.oper = operhash_add(get_oper_name(source_p));
+
+       if(propagated)
        {
-               char *tmp = LOCAL_COPY(name);
-               char *orig = tmp;
-               char *new = tmp;
+               aconf->flags |= CONF_FLAGS_MYOPER | CONF_FLAGS_TEMPORARY;
+               aconf->hold = rb_current_time() + temp_time;
+               aconf->lifetime = aconf->hold;
 
-               while(*orig)
-               {
-                       if(*orig == '\\' && *(orig + 1) != '\0')
-                       {
-                               if(*(orig + 1) == 's')
-                               {
-                                       *new++ = ' ';
-                                       orig += 2;
-                               }
-                               /* otherwise skip that and the escaped
-                                * character after it, so we dont mistake
-                                * \\s as \s --fl
-                                */
-                               else
-                               {
-                                       *new++ = *orig++;
-                                       *new++ = *orig++;
-                               }
-                       }
-                       else
-                               *new++ = *orig++;
-               }
+               replace_old_ban(aconf);
+               rb_dlinkAddAlloc(aconf, &prop_bans);
 
-               *new = '\0';
-               DupString(aconf->name, tmp);
+               sendto_realops_snomask(SNO_GENERAL, L_ALL,
+                                      "%s added global %d min. X-Line for [%s] [%s]",
+                                      get_oper_name(source_p), temp_time / 60,
+                                      aconf->host, reason);
+               ilog(L_KLINE, "X %s %d %s %s",
+                    get_oper_name(source_p), temp_time / 60, name, reason);
+               sendto_one_notice(source_p, ":Added global %d min. X-Line [%s]",
+                                 temp_time / 60, aconf->host);
+               sendto_server(NULL, NULL, CAP_BAN|CAP_TS6, NOCAPS,
+                               ":%s BAN X * %s %lu %d %d * :%s",
+                               source_p->id, aconf->host,
+                               (unsigned long)aconf->created,
+                               (int)(aconf->hold - aconf->created),
+                               (int)(aconf->lifetime - aconf->created),
+                               reason);
        }
-       else
-               DupString(aconf->name, name);
-
-       DupString(aconf->passwd, reason);
-       collapse(aconf->name);
-
-       if(temp_time > 0)
+       else 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]",
-                            get_oper_name(source_p), temp_time / 60,
-                            aconf->name, reason);
+                                      "%s added temporary %d min. X-Line for [%s] [%s]",
+                                      get_oper_name(source_p), temp_time / 60,
+                                      aconf->host, reason);
                ilog(L_KLINE, "X %s %d %s %s",
-                       get_oper_name(source_p), temp_time / 60,
-                       name, reason);
+                    get_oper_name(source_p), temp_time / 60, name, reason);
                sendto_one_notice(source_p, ":Added temporary %d min. X-Line [%s]",
-                               temp_time / 60, aconf->name);
+                                 temp_time / 60, aconf->host);
        }
        else
        {
                sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s added X-Line for [%s] [%s]",
-                               get_oper_name(source_p), 
-                               aconf->name, aconf->passwd);
+                                      get_oper_name(source_p), aconf->host, aconf->passwd);
                sendto_one_notice(source_p, ":Added X-Line for [%s] [%s]",
-                                       aconf->name, aconf->passwd);
-               write_xline(source_p, aconf);
-               ilog(L_KLINE, "X %s 0 %s %s",
-                       get_oper_name(source_p), name, reason);
+                                 aconf->host, aconf->passwd);
+
+               bandb_add(BANDB_XLINE, source_p, aconf->host, NULL, aconf->passwd, NULL, 0);
+               ilog(L_KLINE, "X %s 0 %s %s", get_oper_name(source_p), name, aconf->passwd);
        }
 
-       dlinkAddAlloc(aconf, &xline_conf_list);
+       rb_dlinkAddAlloc(aconf, &xline_conf_list);
        check_xlines();
 }
 
-/* write_xline()
- *
- * inputs      - gecos, reason, xline type
- * outputs     - writes an xline to the config
- * side effects - 
- */
 static void
-write_xline(struct Client *source_p, struct ConfItem *aconf)
-{
-       char buffer[BUFSIZE * 2];
-       FILE *out;
-       const char *filename;
-
-       filename = ConfigFileEntry.xlinefile;
-
-       if((out = fopen(filename, "a")) == NULL)
-       {
-               sendto_realops_snomask(SNO_GENERAL, L_ALL, "*** Problem opening %s ", filename);
-               sendto_one_notice(source_p, ":*** Problem opening file, xline added temporarily only");
-               return;
-       }
-
-       ircsprintf(buffer, "\"%s\",\"0\",\"%s\",\"%s\",%ld\n",
-                  aconf->name, aconf->passwd,
-                  get_oper_name(source_p), CurrentTime);
-
-       if(fputs(buffer, out) == -1)
-       {
-               sendto_realops_snomask(SNO_GENERAL, L_ALL, "*** Problem writing to %s", filename);
-               sendto_one_notice(source_p, ":*** Problem writing to file, xline added temporarily only");
-               fclose(out);
-               return;
-       }
-
-       if(fclose(out))
-       {
-               sendto_realops_snomask(SNO_GENERAL, L_ALL, "*** Problem writing to %s", filename);
-               sendto_one_notice(source_p, ":*** Problem writing to file, xline added temporarily only");
-               return;
-       }
-}
-
-static void 
 propagate_xline(struct Client *source_p, const char *target,
-               int temp_time, const char *name, const char *type,
-               const char *reason)
+               int temp_time, const char *name, const char *type, const char *reason)
 {
        if(!temp_time)
        {
                sendto_match_servs(source_p, target, CAP_CLUSTER, NOCAPS,
-                                       "XLINE %s %s %s :%s",
-                                       target, name, type, reason);
+                                  "XLINE %s %s %s :%s", target, name, type, reason);
                sendto_match_servs(source_p, target, CAP_ENCAP, CAP_CLUSTER,
-                               "ENCAP %s XLINE %d %s 2 :%s",
-                               target, temp_time, name, reason);
+                                  "ENCAP %s XLINE %d %s 2 :%s", target, temp_time, name, reason);
        }
        else
                sendto_match_servs(source_p, target, CAP_ENCAP, NOCAPS,
-                               "ENCAP %s XLINE %d %s %s :%s",
-                               target, temp_time, name, type, reason);
+                                  "ENCAP %s XLINE %d %s %s :%s",
+                                  target, temp_time, name, type, reason);
 }
-                       
+
 static void
-cluster_xline(struct Client *source_p, int temp_time, const char *name,
-               const char *reason)
+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;
 
@@ -432,16 +383,15 @@ cluster_xline(struct Client *source_p, int temp_time, const char *name,
                                continue;
 
                        sendto_match_servs(source_p, shared_p->server, CAP_CLUSTER, NOCAPS,
-                                       "XLINE %s %s 2 :%s",
-                                       shared_p->server, name, reason);
+                                          "XLINE %s %s 2 :%s", shared_p->server, name, reason);
                        sendto_match_servs(source_p, shared_p->server, CAP_ENCAP, CAP_CLUSTER,
-                                       "ENCAP %s XLINE 0 %s 2 :%s",
-                                       shared_p->server, name, reason);
+                                          "ENCAP %s XLINE 0 %s 2 :%s",
+                                          shared_p->server, name, reason);
                }
                else if(shared_p->flags & SHARED_TXLINE)
                        sendto_match_servs(source_p, shared_p->server, CAP_ENCAP, NOCAPS,
-                                       "ENCAP %s XLINE %d %s 2 :%s",
-                                       shared_p->server, temp_time, name, reason);
+                                          "ENCAP %s XLINE %d %s 2 :%s",
+                                          shared_p->server, temp_time, name, reason);
        }
 }
 
@@ -452,10 +402,11 @@ cluster_xline(struct Client *source_p, int temp_time, const char *name,
 static int
 mo_unxline(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
+       int propagated = 1;
+
        if(!IsOperXline(source_p))
        {
-               sendto_one(source_p, form_str(ERR_NOPRIVS),
-                          me.name, source_p->name, "xline");
+               sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "xline");
                return 0;
        }
 
@@ -464,24 +415,20 @@ mo_unxline(struct Client *client_p, struct Client *source_p, int parc, const cha
                if(!IsOperRemoteBan(source_p))
                {
                        sendto_one(source_p, form_str(ERR_NOPRIVS),
-                               me.name, source_p->name, "remoteban");
+                                  me.name, source_p->name, "remoteban");
                        return 0;
                }
 
-               propagate_generic(source_p, "UNXLINE", parv[3], CAP_CLUSTER,
-                               "%s", parv[1]);
+               propagate_generic(source_p, "UNXLINE", parv[3], CAP_CLUSTER, "%s", parv[1]);
 
                if(match(parv[3], me.name) == 0)
                        return 0;
-       }
-       else if(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;
+               propagated = 0;
+       }
+       /* cluster{} moved to remove_xline */
 
-       remove_xline(source_p, parv[1]);
+       remove_xline(source_p, parv[1], propagated);
 
        return 0;
 }
@@ -496,8 +443,7 @@ ms_unxline(struct Client *client_p, struct Client *source_p, int parc, const cha
        /* parv[0]  parv[1]        parv[2]
         * oper     target server  gecos
         */
-       propagate_generic(source_p, "UNXLINE", parv[1], CAP_CLUSTER,
-                       "%s", parv[2]);
+       propagate_generic(source_p, "UNXLINE", parv[1], CAP_CLUSTER, "%s", parv[2]);
 
        if(!match(parv[1], me.name))
                return 0;
@@ -524,156 +470,91 @@ static void
 handle_remote_unxline(struct Client *source_p, const char *name)
 {
        if(!find_shared_conf(source_p->username, source_p->host,
-                               source_p->servptr->name, SHARED_UNXLINE))
-               return;
-
-       if(remove_temp_xline(source_p, name))
+                            source_p->servptr->name, SHARED_UNXLINE))
                return;
 
-       remove_xline(source_p, name);
+       remove_xline(source_p, name, 0);
 
        return;
 }
 
-static int
-remove_temp_xline(struct Client *source_p, const char *name)
+static void
+remove_xline(struct Client *source_p, const char *name, int propagated)
 {
        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))
+               if(!irccmp(aconf->host, 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);
-                       dlinkDestroy(ptr, &xline_conf_list);
-                       return 1;
-               }
-       }
-
-       return 0;
-}
-
-/* remove_xline()
- *
- * inputs      - gecos to remove
- * outputs     - 
- * side effects - removes xline from conf, if exists
- */
-static void
-remove_xline(struct Client *source_p, const char *huntgecos)
-{
-       FILE *in, *out;
-       char buf[BUFSIZE];
-       char buff[BUFSIZE];
-       char temppath[BUFSIZE];
-       const char *filename;
-       const char *gecos;
-       mode_t oldumask;
-       char *p;
-       int error_on_write = 0;
-       int found_xline = 0;
-
-       filename = ConfigFileEntry.xlinefile;
-       ircsnprintf(temppath, sizeof(temppath),
-                "%s.tmp", ConfigFileEntry.xlinefile);
-
-       if((in = fopen(filename, "r")) == NULL)
-       {
-               sendto_one_notice(source_p, ":Cannot open %s", filename);
-               return;
-       }
-
-       oldumask = umask(0);
-
-       if((out = fopen(temppath, "w")) == NULL)
-       {
-               sendto_one_notice(source_p, ":Cannot open %s", temppath);
-               fclose(in);
-               umask(oldumask);
-               return;
-       }
-
-       umask(oldumask);
-
-       while (fgets(buf, sizeof(buf), in))
-       {
-               if(error_on_write)
-               {
-                       if(temppath != NULL)
-                               (void) unlink(temppath);
-
-                       break;
-               }
-
-               strlcpy(buff, buf, sizeof(buff));
-
-               if((p = strchr(buff, '\n')) != NULL)
-                       *p = '\0';
+                       if(aconf->lifetime)
+                       {
+                               if(!propagated)
+                               {
+                                       sendto_one_notice(source_p, ":Cannot remove global X-Line %s on specific servers", name);
+                                       return;
+                               }
+                               ptr = rb_dlinkFind(aconf, &prop_bans);
+                               if(ptr == NULL)
+                                       return;
+                               sendto_one_notice(source_p, ":X-Line for [%s] is removed", name);
+                               sendto_realops_snomask(SNO_GENERAL, L_ALL,
+                                                      "%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();
+                               else
+                                       aconf->created++;
+                               aconf->hold = aconf->created;
+                               operhash_delete(aconf->info.oper);
+                               aconf->info.oper = operhash_add(get_oper_name(source_p));
+                               aconf->flags |= CONF_FLAGS_MYOPER | CONF_FLAGS_TEMPORARY;
+                               sendto_server(NULL, NULL, CAP_BAN|CAP_TS6, NOCAPS,
+                                               ":%s BAN X * %s %lu %d %d * :*",
+                                               source_p->id, aconf->host,
+                                               (unsigned long)aconf->created,
+                                               0,
+                                               (int)(aconf->lifetime - aconf->created));
+                               remove_reject_mask(aconf->host, NULL);
+                               deactivate_conf(aconf, ptr);
+                               return;
+                       }
+                       else if(propagated && rb_dlink_list_length(&cluster_conf_list))
+                               cluster_generic(source_p, "UNXLINE", SHARED_UNXLINE, CAP_CLUSTER, "%s", name);
+                       if(!aconf->hold)
+                       {
+                               bandb_del(BANDB_XLINE, aconf->host, NULL);
 
-               if((*buff == '\0') || (*buff == '#'))
-               {
-                       error_on_write = (fputs(buf, out) < 0) ? YES : NO;
-                       continue;
-               }
+                               sendto_one_notice(source_p, ":X-Line for [%s] is removed", aconf->host);
+                               sendto_realops_snomask(SNO_GENERAL, L_ALL,
+                                                      "%s has removed the X-Line for: [%s]",
+                                                      get_oper_name(source_p), aconf->host);
+                               ilog(L_KLINE, "UX %s %s", get_oper_name(source_p), aconf->host);
+                       }
+                       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);
+                       }
 
-               if((gecos = getfield(buff)) == NULL)
-               {
-                       error_on_write = (fputs(buf, out) < 0) ? YES : NO;
-                       continue;
+                       remove_reject_mask(aconf->host, NULL);
+                       free_conf(aconf);
+                       rb_dlinkDestroy(ptr, &xline_conf_list);
+                       return;
                }
-
-               /* matching.. */
-               if(irccmp(gecos, huntgecos) == 0)
-                       found_xline++;
-               else
-                       error_on_write = (fputs(buf, out) < 0) ? YES : NO;
        }
 
-       fclose(in);
-       if (fclose(out))
-               error_on_write = YES;
+       if(propagated && rb_dlink_list_length(&cluster_conf_list))
+               cluster_generic(source_p, "UNXLINE", SHARED_UNXLINE, CAP_CLUSTER, "%s", name);
 
-       if(error_on_write)
-       {
-               sendto_one_notice(source_p,
-                                 ":Couldn't write temp xline file, aborted");
-               return;
-       }
-       else if(found_xline == 0)
-       {
-               sendto_one_notice(source_p, ":No X-Line for %s", huntgecos);
+       sendto_one_notice(source_p, ":No X-Line for %s", name);
 
-               if(temppath != NULL)
-                       (void) unlink(temppath);
-               return;
-       }
-
-       if (rename(temppath, filename))
-       {
-               sendto_one_notice(source_p, ":Couldn't rename temp file, aborted");
-               return;
-       }
-       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;
 }