]> jfr.im git - solanum.git/blobdiff - src/s_conf.c
Track who set a dline/kline/xline/resv as in ratbox3.
[solanum.git] / src / s_conf.c
index 74eecc5b6ea329c2b6c46c8168f9b7ba0b548f41..ff87a309c04efa9bbfeb56f32f656231762ebc69 100644 (file)
@@ -50,6 +50,7 @@
 #include "privilege.h"
 #include "sslproc.h"
 #include "bandbi.h"
+#include "operhash.h"
 
 struct config_server_hide ConfigServerHide;
 
@@ -142,11 +143,15 @@ free_conf(struct ConfItem *aconf)
 
        rb_free(aconf->passwd);
        rb_free(aconf->spasswd);
-       rb_free(aconf->name);
        rb_free(aconf->className);
        rb_free(aconf->user);
        rb_free(aconf->host);
 
+       if(IsConfBan(aconf))
+               operhash_delete(aconf->info.oper);
+       else
+               rb_free(aconf->info.name);
+
        rb_bh_free(confitem_heap, aconf);
 }
 
@@ -333,7 +338,7 @@ verify_access(struct Client *client_p, const char *username)
                if(aconf->flags & CONF_FLAGS_REDIR)
                {
                        sendto_one_numeric(client_p, RPL_REDIR, form_str(RPL_REDIR),
-                                       aconf->name ? aconf->name : "", aconf->port);
+                                       aconf->info.name ? aconf->info.name : "", aconf->port);
                        return (NOT_AUTHORISED);
                }
 
@@ -350,35 +355,34 @@ verify_access(struct Client *client_p, const char *username)
                                sendto_realops_snomask(SNO_GENERAL, L_ALL,
                                                "%s spoofing: %s as %s",
                                                client_p->name,
-                                               show_ip(NULL, client_p) ? client_p->host : aconf->name,
-                                               aconf->name);
+                                               show_ip(NULL, client_p) ? client_p->host : aconf->info.name,
+                                               aconf->info.name);
                        }
 
                        /* user@host spoof */
-                       if((p = strchr(aconf->name, '@')) != NULL)
+                       if((p = strchr(aconf->info.name, '@')) != NULL)
                        {
                                char *host = p+1;
                                *p = '\0';
 
-                               rb_strlcpy(client_p->username, aconf->name,
+                               rb_strlcpy(client_p->username, aconf->info.name,
                                        sizeof(client_p->username));
                                rb_strlcpy(client_p->host, host,
                                        sizeof(client_p->host));
                                *p = '@';
                        }
                        else
-                               rb_strlcpy(client_p->host, aconf->name, sizeof(client_p->host));
+                               rb_strlcpy(client_p->host, aconf->info.name, sizeof(client_p->host));
                }
                return (attach_iline(client_p, aconf));
        }
        else if(aconf->status & CONF_KILL)
        {
                if(ConfigFileEntry.kline_with_reason)
-               {
                        sendto_one(client_p,
                                        form_str(ERR_YOUREBANNEDCREEP),
-                                       me.name, client_p->name, aconf->passwd);
-               }
+                                       me.name, client_p->name,
+                                       get_user_ban_reason(aconf));
                add_reject(client_p, aconf->user, aconf->host);
                return (BANNED_CLIENT);
        }
@@ -1047,7 +1051,7 @@ get_printable_conf(struct ConfItem *aconf, char **name, char **host,
        static char null[] = "<NULL>";
        static char zero[] = "default";
 
-       *name = EmptyString(aconf->name) ? null : aconf->name;
+       *name = EmptyString(aconf->info.name) ? null : aconf->info.name;
        *host = EmptyString(aconf->host) ? null : aconf->host;
        *pass = EmptyString(aconf->passwd) ? null : aconf->passwd;
        *user = EmptyString(aconf->user) ? null : aconf->user;
@@ -1055,6 +1059,33 @@ get_printable_conf(struct ConfItem *aconf, char **name, char **host,
        *port = (int) aconf->port;
 }
 
+char *
+get_user_ban_reason(struct ConfItem *aconf)
+{
+       static char reasonbuf[BUFSIZE];
+
+       if (aconf->flags & CONF_FLAGS_TEMPORARY &&
+                       (aconf->status == CONF_KILL || aconf->status == CONF_DLINE))
+               rb_snprintf(reasonbuf, sizeof reasonbuf,
+                               "Temporary %c-line %d min. - ",
+                               aconf->status == CONF_DLINE ? 'D' : 'K',
+                               (aconf->hold - aconf->created) / 60);
+       else
+               reasonbuf[0] = '\0';
+       if (aconf->passwd)
+               rb_strlcat(reasonbuf, aconf->passwd, sizeof reasonbuf);
+       else
+               rb_strlcat(reasonbuf, "No Reason", sizeof reasonbuf);
+       if (aconf->created)
+       {
+               rb_strlcat(reasonbuf, " (", sizeof reasonbuf);
+               rb_strlcat(reasonbuf, smalldate(aconf->created),
+                               sizeof reasonbuf);
+               rb_strlcat(reasonbuf, ")", sizeof reasonbuf);
+       }
+       return reasonbuf;
+}
+
 void
 get_printable_kline(struct Client *source_p, struct ConfItem *aconf, 
                    char **host, char **reason,
@@ -1063,8 +1094,8 @@ get_printable_kline(struct Client *source_p, struct ConfItem *aconf,
        static char null[] = "<NULL>";
 
        *host = EmptyString(aconf->host) ? null : aconf->host;
-       *reason = EmptyString(aconf->passwd) ? null : aconf->passwd;
        *user = EmptyString(aconf->user) ? null : aconf->user;
+       *reason = get_user_ban_reason(aconf);
 
        if(EmptyString(aconf->spasswd) || !IsOper(source_p))
                *oper_reason = NULL;