]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - src/s_conf.c
Generate the "Temporary K-line %d min" part from aconf->hold - aconf->created.
[irc/rqf/shadowircd.git] / src / s_conf.c
index ae83d7aa8c7df7f869292d60e990d03df7b8f009..c3df6fd04d06b982d2acec9a8666cbc305fa97ea 100644 (file)
@@ -306,8 +306,6 @@ verify_access(struct Client *client_p, const char *username)
 {
        struct ConfItem *aconf;
        char non_ident[USERLEN + 1];
-       char reasonbuf[BUFSIZE];
-       char *reason;
 
        if(IsGotId(client_p))
        {
@@ -377,20 +375,10 @@ verify_access(struct Client *client_p, const char *username)
        else if(aconf->status & CONF_KILL)
        {
                if(ConfigFileEntry.kline_with_reason)
-               {
-                       if(aconf->created)
-                       {
-                               snprintf(reasonbuf, sizeof reasonbuf, "%s (%s)",
-                                               aconf->passwd,
-                                               smalldate(aconf->created));
-                               reason = reasonbuf;
-                       }
-                       else
-                               reason = aconf->passwd;
                        sendto_one(client_p,
                                        form_str(ERR_YOUREBANNEDCREEP),
-                                       me.name, client_p->name, reason);
-               }
+                                       me.name, client_p->name,
+                                       get_user_ban_reason(aconf));
                add_reject(client_p, aconf->user, aconf->host);
                return (BANNED_CLIENT);
        }
@@ -1135,24 +1123,43 @@ 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,
                    char **user, char **oper_reason)
 {
        static char null[] = "<NULL>";
-       static char reasonbuf[BUFSIZE];
 
        *host = EmptyString(aconf->host) ? null : aconf->host;
        *user = EmptyString(aconf->user) ? null : aconf->user;
-
-       *reason = EmptyString(aconf->passwd) ? null : aconf->passwd;
-       if(aconf->created)
-       {
-               rb_snprintf(reasonbuf, sizeof reasonbuf, "%s (%s)",
-                               *reason, smalldate(aconf->created));
-               *reason = reasonbuf;
-       }
+       *reason = get_user_ban_reason(aconf);
 
        if(EmptyString(aconf->spasswd) || !IsOper(source_p))
                *oper_reason = NULL;