]> jfr.im git - solanum.git/blobdiff - modules/core/m_ban.c
Replace most checks for +o with oper:general
[solanum.git] / modules / core / m_ban.c
index 4ae6e066302a7bf021151e06a8c3df607808ba36..b1e738d3a77eb326f284fc4ee4893560b6cdcead 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * charybdis: An advanced ircd.
  * m_ban.c: Propagates network bans across servers.
- * 
+ *
  *  Copyright (C) 2010 Jilles Tjoelker
  *
  * Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,7 @@
 #include "send.h"
 #include "channel.h"
 #include "client.h"
-#include "common.h"
-#include "config.h"
+#include "defaults.h"
 #include "ircd.h"
 #include "match.h"
 #include "s_conf.h"
 #include "operhash.h"
 #include "reject.h"
 #include "hostmask.h"
+#include "logger.h"
+
+static const char ban_desc[] = "Provides the TS6 BAN command for propagating network-wide bans";
 
-static int ms_ban(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
+static void m_ban(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
+static void ms_ban(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
 
 struct Message ban_msgtab = {
-       "BAN", 0, 0, 0, MFLG_SLOW,
-       {mg_unreg, mg_ignore, {ms_ban, 9}, {ms_ban, 9}, mg_ignore, mg_ignore}
+       "BAN", 0, 0, 0, 0,
+       {mg_unreg, {m_ban, 0}, {ms_ban, 9}, {ms_ban, 9}, mg_ignore, {m_ban, 0}}
 };
 
 mapi_clist_av1 ban_clist[] =  { &ban_msgtab, NULL };
-DECLARE_MODULE_AV1(ban, NULL, NULL, ban_clist, NULL, NULL, "$Revision: 1349 $");
+
+DECLARE_MODULE_AV2(ban, NULL, NULL, ban_clist, NULL, NULL, NULL, NULL, ban_desc);
+
+static void
+m_ban(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
+{
+       sendto_one_notice(source_p, ":The BAN command is not user-accessible.");
+       sendto_one_notice(source_p, ":To ban a user from a channel, see /QUOTE HELP CMODE");
+       if (IsOperGeneral(source_p))
+               sendto_one_notice(source_p, ":To ban a user from a server or from the network, see /QUOTE HELP KLINE");
+}
 
 /* ms_ban()
  *
@@ -66,24 +79,25 @@ DECLARE_MODULE_AV1(ban, NULL, NULL, ban_clist, NULL, NULL, "$Revision: 1349 $");
  * parv[7] - oper or *
  * parv[8] - reason (possibly with |operreason)
  */
-static int
-ms_ban(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
+static void
+ms_ban(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
        rb_dlink_node *ptr;
        struct ConfItem *aconf;
        unsigned int ntype;
        const char *oper, *stype;
-       time_t created, hold, lifetime;
+       time_t now, created, hold, lifetime;
        char *p;
        int act;
        int valid;
 
+       now = rb_current_time();
        if (strlen(parv[1]) != 1)
        {
                sendto_realops_snomask(SNO_GENERAL, L_NETWIDE,
                                "Unknown BAN type %s from %s",
                                parv[1], source_p->name);
-               return 0;
+               return;
        }
        switch (parv[1][0])
        {
@@ -104,7 +118,7 @@ ms_ban(struct Client *client_p, struct Client *source_p, int parc, const char *p
                        sendto_realops_snomask(SNO_GENERAL, L_NETWIDE,
                                        "Unknown BAN type %s from %s",
                                        parv[1], source_p->name);
-                       return 0;
+                       return;
        }
        created = atol(parv[4]);
        hold = created + atoi(parv[5]);
@@ -129,7 +143,7 @@ ms_ban(struct Client *client_p, struct Client *source_p, int parc, const char *p
                                                aconf->user ? aconf->user : "",
                                                aconf->user ? "@" : "",
                                                aconf->host);
-                       return 0;
+                       return;
                }
                /* act indicates if something happened (from the oper's
                 * point of view). This is the case if the ban was
@@ -137,14 +151,14 @@ ms_ban(struct Client *client_p, struct Client *source_p, int parc, const char *p
                 * is not a removal and not already expired.
                 */
                act = !(aconf->status & CONF_ILLEGAL) || (hold != created &&
-                               hold > rb_current_time());
+                               hold > now);
                if (lifetime > aconf->lifetime)
                        aconf->lifetime = lifetime;
                /* already expired, hmm */
-               if (aconf->lifetime <= rb_current_time())
-                       return 0;
+               if (aconf->lifetime <= now)
+                       return;
                /* Deactivate, it will be reactivated later if appropriate. */
-               deactivate_conf(aconf, ptr);
+               deactivate_conf(aconf, ptr, now);
                rb_free(aconf->user);
                aconf->user = NULL;
                rb_free(aconf->host);
@@ -163,7 +177,7 @@ ms_ban(struct Client *client_p, struct Client *source_p, int parc, const char *p
                aconf->status = CONF_ILLEGAL | ntype;
                aconf->lifetime = lifetime;
                rb_dlinkAddAlloc(aconf, &prop_bans);
-               act = hold != created && hold > rb_current_time();
+               act = hold != created && hold > now;
        }
        aconf->flags &= ~CONF_FLAGS_MYOPER;
        aconf->flags |= CONF_FLAGS_TEMPORARY;
@@ -202,7 +216,7 @@ ms_ban(struct Client *client_p, struct Client *source_p, int parc, const char *p
        {
                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),
+                                      (int)((hold - now) / 60),
                                       stype,
                                       IsServer(source_p) ? source_p->name : get_oper_name(source_p),
                                       strcmp(parv[7], "*") ? " on behalf of " : "",
@@ -225,7 +239,7 @@ ms_ban(struct Client *client_p, struct Client *source_p, int parc, const char *p
                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),
-                                      (int)((hold - rb_current_time()) / 60),
+                                      (int)((hold - now) / 60),
                                       stype,
                                       strcmp(parv[7], "*") ? " from " : "",
                                       strcmp(parv[7], "*") ? parv[7] : "",
@@ -235,7 +249,7 @@ ms_ban(struct Client *client_p, struct Client *source_p, int parc, const char *p
                                       parv[parc - 1]);
                ilog(L_KLINE, "%s %s %d %s%s%s %s", parv[1],
                                IsServer(source_p) ? source_p->name : get_oper_name(source_p),
-                               (int)((hold - rb_current_time()) / 60),
+                               (int)((hold - now) / 60),
                                aconf->user ? aconf->user : "",
                                aconf->user ? " " : "",
                                aconf->host,
@@ -272,19 +286,7 @@ ms_ban(struct Client *client_p, struct Client *source_p, int parc, const char *p
                        else
                        {
                                add_conf_by_address(aconf->host, CONF_KILL, aconf->user, NULL, aconf);
-                               if(ConfigFileEntry.kline_delay ||
-                                               (IsServer(source_p) &&
-                                                !HasSentEob(source_p)))
-                               {
-                                       if(kline_queued == 0)
-                                       {
-                                               rb_event_addonce("check_klines", check_klines_event, NULL,
-                                                                ConfigFileEntry.kline_delay);
-                                               kline_queued = 1;
-                                       }
-                               }
-                               else
-                                       check_klines();
+                               check_one_kline(aconf);
                        }
                        break;
                case CONF_XLINE:
@@ -300,7 +302,7 @@ ms_ban(struct Client *client_p, struct Client *source_p, int parc, const char *p
                        if (!(aconf->status & CONF_ILLEGAL))
                        {
                                add_to_resv_hash(aconf->host, aconf);
-                               resv_chan_forcepart(aconf->host, aconf->passwd, hold - rb_current_time());
+                               resv_chan_forcepart(aconf->host, aconf->passwd, hold - now);
                        }
                        break;
                case CONF_RESV_NICK:
@@ -319,5 +321,4 @@ ms_ban(struct Client *client_p, struct Client *source_p, int parc, const char *p
                        parv[6],
                        parv[7],
                        parv[parc - 1]);
-       return 0;
 }