]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - src/s_conf.c
Do not allow a topic change if a user may not send to the channel
[irc/rqf/shadowircd.git] / src / s_conf.c
index 55a9728fa51d84bc9cd4be978d94490d74df6943..b03a1305e2d94463f3a4a40796bad09f3f89c6a3 100644 (file)
@@ -674,6 +674,8 @@ set_default_conf(void)
        ServerInfo.description = NULL;
        ServerInfo.network_name = rb_strdup(NETWORK_NAME_DEFAULT);
        ServerInfo.network_desc = rb_strdup(NETWORK_DESC_DEFAULT);
+       ServerInfo.helpchan = rb_strdup("");
+       ServerInfo.helpurl = rb_strdup("");
 
        memset(&ServerInfo.ip, 0, sizeof(ServerInfo.ip));
        ServerInfo.specific_ipv4_vhost = 0;
@@ -749,6 +751,7 @@ set_default_conf(void)
        ConfigFileEntry.collision_fnc = YES;
        ConfigFileEntry.global_snotices = YES;
        ConfigFileEntry.operspy_dont_care_user_info = NO;
+       ConfigFileEntry.use_propagated_bans = YES;
        ConfigFileEntry.secret_channels_in_whois = NO;
 
 #ifdef HAVE_LIBZ
@@ -803,6 +806,7 @@ set_default_conf(void)
        ConfigFileEntry.min_nonwildcard = 4;
        ConfigFileEntry.min_nonwildcard_simple = 3;
        ConfigFileEntry.default_floodcount = 8;
+       ConfigFileEntry.default_ident_timeout = 5;
        ConfigFileEntry.client_flood = CLIENT_FLOOD_DEFAULT;
        ConfigFileEntry.tkline_expire_notices = 0;
 
@@ -891,7 +895,7 @@ validate_conf(void)
                splitchecking = 0;
        }
 
-       if(!valid_hostname(ConfigFileEntry.default_operhost))
+       if(!valid_hostname(ConfigFileEntry.default_operhost) && !EmptyString(ConfigFileEntry.default_operhost))
        {
                conf_report_error("Warning -- invalid default_operhost specified, ignoring.");
                ConfigFileEntry.default_operhost = rb_strdup("");
@@ -1007,6 +1011,62 @@ add_temp_dline(struct ConfItem *aconf)
        add_conf_by_address(aconf->host, CONF_DLINE, aconf->user, NULL, aconf);
 }
 
+/* valid_wild_card()
+ * 
+ * input        - user buffer, host buffer
+ * output       - 0 if invalid, 1 if valid
+ * side effects -
+ */
+int
+valid_wild_card(const char *luser, const char *lhost)
+{
+       const char *p;
+       char tmpch;
+       int nonwild = 0;
+       int bitlen;
+
+       /* user has no wildcards, always accept -- jilles */
+       if(!strchr(luser, '?') && !strchr(luser, '*'))
+               return 1;
+
+       /* check there are enough non wildcard chars */
+       p = luser;
+       while((tmpch = *p++))
+       {
+               if(!IsKWildChar(tmpch))
+               {
+                       /* found enough chars, return */
+                       if(++nonwild >= ConfigFileEntry.min_nonwildcard)
+                               return 1;
+               }
+       }
+
+       /* try host, as user didnt contain enough */
+       /* special case for cidr masks -- jilles */
+       if((p = strrchr(lhost, '/')) != NULL && IsDigit(p[1]))
+       {
+               bitlen = atoi(p + 1);
+               /* much like non-cidr for ipv6, rather arbitrary for ipv4 */
+               if(bitlen > 0
+                  && bitlen >=
+                  (strchr(lhost, ':') ? 4 * (ConfigFileEntry.min_nonwildcard - nonwild) : 6 -
+                   2 * nonwild))
+                       return 1;
+       }
+       else
+       {
+               p = lhost;
+               while((tmpch = *p++))
+               {
+                       if(!IsKWildChar(tmpch))
+                               if(++nonwild >= ConfigFileEntry.min_nonwildcard)
+                                       return 1;
+               }
+       }
+
+       return 0;
+}
+
 rb_dlink_node *
 find_prop_ban(unsigned int status, const char *user, const char *host)
 {
@@ -1076,6 +1136,36 @@ deactivate_conf(struct ConfItem *aconf, rb_dlink_node *ptr)
        }
 }
 
+/* Given a new ban ConfItem, look for any matching ban, update the lifetime
+ * from it and delete it.
+ */
+void
+replace_old_ban(struct ConfItem *aconf)
+{
+       rb_dlink_node *ptr;
+       struct ConfItem *oldconf;
+
+       ptr = find_prop_ban(aconf->status, aconf->user, aconf->host);
+       if(ptr != NULL)
+       {
+               oldconf = ptr->data;
+               /* Remember at least as long as the old one. */
+               if(oldconf->lifetime > aconf->lifetime)
+                       aconf->lifetime = oldconf->lifetime;
+               /* Force creation time to increase. */
+               if(oldconf->created >= aconf->created)
+                       aconf->created = oldconf->created + 1;
+               /* Leave at least one second of validity. */
+               if(aconf->hold <= aconf->created)
+                       aconf->hold = aconf->created + 1;
+               if(aconf->lifetime < aconf->hold)
+                       aconf->lifetime = aconf->hold;
+               /* Tell deactivate_conf() to destroy it. */
+               oldconf->lifetime = rb_current_time();
+               deactivate_conf(oldconf, ptr);
+       }
+}
+
 static void
 expire_prop_bans(void *list)
 {
@@ -1243,7 +1333,7 @@ get_user_ban_reason(struct ConfItem *aconf)
                rb_snprintf(reasonbuf, sizeof reasonbuf,
                                "Temporary %c-line %d min. - ",
                                aconf->status == CONF_DLINE ? 'D' : 'K',
-                               (aconf->hold - aconf->created) / 60);
+                               (int)((aconf->hold - aconf->created) / 60));
        else
                reasonbuf[0] = '\0';
        if (aconf->passwd)
@@ -1266,15 +1356,22 @@ get_printable_kline(struct Client *source_p, struct ConfItem *aconf,
                    char **user, char **oper_reason)
 {
        static char null[] = "<NULL>";
+       static char operreasonbuf[BUFSIZE];
 
        *host = EmptyString(aconf->host) ? null : aconf->host;
        *user = EmptyString(aconf->user) ? null : aconf->user;
        *reason = get_user_ban_reason(aconf);
 
-       if(EmptyString(aconf->spasswd) || !IsOper(source_p))
+       if(!IsOper(source_p))
                *oper_reason = NULL;
        else
-               *oper_reason = aconf->spasswd;
+       {
+               rb_snprintf(operreasonbuf, sizeof operreasonbuf, "%s%s(%s)",
+                               EmptyString(aconf->spasswd) ? "" : aconf->spasswd,
+                               EmptyString(aconf->spasswd) ? "" : " ",
+                               aconf->info.oper);
+               *oper_reason = operreasonbuf;
+       }
 }
 
 /*
@@ -1379,6 +1476,10 @@ clear_out_old_conf(void)
        ServerInfo.network_name = NULL;
        rb_free(ServerInfo.network_desc);
        ServerInfo.network_desc = NULL;
+       rb_free(ServerInfo.helpchan);
+       ServerInfo.helpchan = NULL;
+       rb_free(ServerInfo.helpurl);
+       ServerInfo.helpurl = NULL;
 
        ServerInfo.ssld_count = 1;