]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - modules/core/m_ban.c
Allow /ojoin !#channel/%#channel, if admin/halfop are enabled.
[irc/rqf/shadowircd.git] / modules / core / m_ban.c
index 8d4f2690d1fe33973014463d5f51c6db0b5bdd9e..d966edd4a0d3897b6101ff6623b0c1acbe1849d5 100644 (file)
 
 #include "stdinc.h"
 #include "send.h"
+#include "channel.h"
 #include "client.h"
 #include "common.h"
 #include "config.h"
 #include "ircd.h"
 #include "match.h"
 #include "s_conf.h"
+#include "s_newconf.h"
 #include "msg.h"
 #include "modules.h"
 #include "hash.h"
@@ -74,6 +76,7 @@ ms_ban(struct Client *client_p, struct Client *source_p, int parc, const char *p
        time_t created, hold, lifetime;
        char *p;
        int act;
+       int valid;
 
        if (strlen(parv[1]) != 1)
        {
@@ -88,6 +91,15 @@ ms_ban(struct Client *client_p, struct Client *source_p, int parc, const char *p
                        ntype = CONF_KILL;
                        stype = "K-Line";
                        break;
+               case 'X':
+                       ntype = CONF_XLINE;
+                       stype = "X-Line";
+                       break;
+               case 'R':
+                       ntype = IsChannelName(parv[3]) ? CONF_RESV_CHANNEL :
+                               CONF_RESV_NICK;
+                       stype = "RESV";
+                       break;
                default:
                        sendto_realops_snomask(SNO_GENERAL, L_NETWIDE,
                                        "Unknown BAN type %s from %s",
@@ -152,21 +164,53 @@ ms_ban(struct Client *client_p, struct Client *source_p, int parc, const char *p
        aconf->info.oper = operhash_add(oper);
        aconf->created = created;
        aconf->hold = hold;
-       p = strchr(parv[parc - 1], '|');
-       if (p == NULL)
+       if (ntype != CONF_KILL || (p = strchr(parv[parc - 1], '|')) == NULL)
                aconf->passwd = rb_strdup(parv[parc - 1]);
        else
        {
                aconf->passwd = rb_strndup(parv[parc - 1], p - parv[parc - 1] + 1);
                aconf->spasswd = rb_strdup(p + 1);
        }
-       if (act && hold != created)
+       switch (ntype)
+       {
+               case CONF_KILL:
+                       valid = valid_wild_card(aconf->user, aconf->host);
+                       break;
+               case CONF_RESV_CHANNEL:
+                       valid = 1;
+                       break;
+               default:
+                       valid = valid_wild_card_simple(aconf->host);
+                       break;
+       }
+       if (act && hold != created && !valid)
+       {
+               sendto_realops_snomask(SNO_GENERAL, L_ALL,
+                                      "Ignoring global %d min. %s from %s%s%s for [%s%s%s]: too few non-wildcard characters",
+                                      (int)((hold - rb_current_time()) / 60),
+                                      stype,
+                                      IsServer(source_p) ? source_p->name : get_oper_name(source_p),
+                                      strcmp(parv[7], "*") ? " on behalf of " : "",
+                                      strcmp(parv[7], "*") ? parv[7] : "",
+                                      aconf->user ? aconf->user : "",
+                                      aconf->user ? "@" : "",
+                                      aconf->host);
+               if(IsPerson(source_p))
+                       sendto_one_notice(source_p,
+                                       ":Your %s [%s%s%s] has too few non-wildcard characters",
+                                       stype,
+                                       aconf->user ? aconf->user : "",
+                                       aconf->user ? "@" : "",
+                                       aconf->host);
+               /* Propagate it, but do not apply it locally. */
+       }
+       else if (act && hold != created)
        {
                /* Keep the notices in sync with modules/m_kline.c etc. */
                sendto_realops_snomask(SNO_GENERAL, L_ALL,
                                       "%s added global %d min. %s%s%s for [%s%s%s] [%s]",
                                       IsServer(source_p) ? source_p->name : get_oper_name(source_p),
-                                      (hold - rb_current_time()) / 60,
+                                      (int)((hold - rb_current_time()) / 60),
                                       stype,
                                       strcmp(parv[7], "*") ? " from " : "",
                                       strcmp(parv[7], "*") ? parv[7] : "",
@@ -174,10 +218,12 @@ ms_ban(struct Client *client_p, struct Client *source_p, int parc, const char *p
                                       aconf->user ? "@" : "",
                                       aconf->host,
                                       parv[parc - 1]);
-               ilog(L_KLINE, "%s %s %d %s %s %s", parv[1],
+               ilog(L_KLINE, "%s %s %d %s%s%s %s", parv[1],
                                IsServer(source_p) ? source_p->name : get_oper_name(source_p),
-                               (hold - rb_current_time()) / 60,
-                               aconf->user, aconf->host,
+                               (int)((hold - rb_current_time()) / 60),
+                               aconf->user ? aconf->user : "",
+                               aconf->user ? " " : "",
+                               aconf->host,
                                parv[parc - 1]);
                aconf->status &= ~CONF_ILLEGAL;
        }
@@ -192,9 +238,11 @@ ms_ban(struct Client *client_p, struct Client *source_p, int parc, const char *p
                                aconf->host,
                                strcmp(parv[7], "*") ? " on behalf of " : "",
                                strcmp(parv[7], "*") ? parv[7] : "");
-               ilog(L_KLINE, "U%s %s %s %s", parv[1],
+               ilog(L_KLINE, "U%s %s %s%s %s", parv[1],
                                IsServer(source_p) ? source_p->name : get_oper_name(source_p),
-                               aconf->user, aconf->host);
+                               aconf->user ? aconf->user : "",
+                               aconf->user ? " " : "",
+                               aconf->host);
        }
        switch (ntype)
        {
@@ -219,6 +267,26 @@ ms_ban(struct Client *client_p, struct Client *source_p, int parc, const char *p
                                        check_klines();
                        }
                        break;
+               case CONF_XLINE:
+                       if (aconf->status & CONF_ILLEGAL)
+                               remove_reject_mask(aconf->host, NULL);
+                       else
+                       {
+                               rb_dlinkAddAlloc(aconf, &xline_conf_list);
+                               check_xlines();
+                       }
+                       break;
+               case CONF_RESV_CHANNEL:
+                       if (!(aconf->status & CONF_ILLEGAL))
+                       {
+                               add_to_resv_hash(aconf->host, aconf);
+                               resv_chan_forcepart(aconf->host, aconf->passwd, hold - rb_current_time());
+                       }
+                       break;
+               case CONF_RESV_NICK:
+                       if (!(aconf->status & CONF_ILLEGAL))
+                               rb_dlinkAddAlloc(aconf, &resv_conf_list);
+                       break;
        }
        sendto_server(client_p, NULL, CAP_BAN|CAP_TS6, NOCAPS,
                        ":%s BAN %s %s %s %s %s %s %s :%s",