]> jfr.im git - irc/freenode/solanum.git/commitdiff
Use opernames not servernames for remote opers
authorEd Kellett <redacted>
Fri, 13 Nov 2020 22:47:09 +0000 (22:47 +0000)
committerEd Kellett <redacted>
Fri, 13 Nov 2020 23:30:04 +0000 (23:30 +0000)
include/s_conf.h
ircd/s_conf.c
ircd/s_serv.c

index b31db9101bc266cba103e765b3a174b7e6c89d57..a689bf31159f5bb9260285cc1216115f626e4f97 100644 (file)
@@ -397,7 +397,7 @@ extern void conf_add_class(struct ConfItem *, int);
 extern void conf_add_d_conf(struct ConfItem *);
 extern void flush_expired_ips(void *);
 
-extern char *get_oper_name(struct Client *client_p);
+extern const char *get_oper_name(struct Client *client_p);
 
 extern int yylex(void);
 
index f35d4123b4925c0aa7865911ac63c9d06a02d3a5..1262dccac4afe364358408d463d1013ea395f279 100644 (file)
@@ -1288,26 +1288,22 @@ reorganise_temp_kd(void *list)
 /* const char* get_oper_name(struct Client *client_p)
  * Input: A client to find the active oper{} name for.
  * Output: The nick!user@host{oper} of the oper.
- *         "oper" is server name for remote opers
+ *         "oper" is server name for unknown opers
  * Side effects: None.
  */
-char *
+const char *
 get_oper_name(struct Client *client_p)
 {
        /* +5 for !,@,{,} and null */
-       static char buffer[NAMELEN + USERLEN + HOSTLEN + HOSTLEN + 5];
+       static char buffer[NAMELEN + USERLEN + HOSTLEN + MAX(HOSTLEN, OPERNICKLEN) + 5];
 
-       if(MyOper(client_p))
-       {
-               snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}",
-                               client_p->name, client_p->username,
-                               client_p->host, client_p->user->opername);
-               return buffer;
-       }
+       const char *opername = EmptyString(client_p->user->opername)
+                       ? client_p->servptr->name
+                       : client_p->user->opername;
 
-       snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}",
-                  client_p->name, client_p->username,
-                  client_p->host, client_p->servptr->name);
+       snprintf(buffer, sizeof buffer, "%s!%s@%s{%s}",
+                       client_p->name, client_p->username,
+                       client_p->host, opername);
        return buffer;
 }
 
index 0ab96ec7e88af175cc0fa42164cc6e0ec0ccabb7..210ed8b1b029b1fc374a0d2aac2e8f6633b190d3 100644 (file)
@@ -474,13 +474,8 @@ burst_ban(struct Client *client_p)
 {
        rb_dlink_node *ptr;
        struct ConfItem *aconf;
-       const char *type, *oper;
-       /* +5 for !,@,{,} and null */
-       char operbuf[NICKLEN + USERLEN + HOSTLEN + HOSTLEN + 5];
-       char *p;
-       size_t melen;
+       const char *type;
 
-       melen = strlen(me.name);
        RB_DLINK_FOREACH(ptr, prop_bans.head)
        {
                aconf = ptr->data;
@@ -498,24 +493,6 @@ burst_ban(struct Client *client_p)
                        default:
                                continue;
                }
-               oper = aconf->info.oper;
-               if(aconf->flags & CONF_FLAGS_MYOPER)
-               {
-                       /* Our operator{} names may not be meaningful
-                        * to other servers, so rewrite to our server
-                        * name.
-                        */
-                       rb_strlcpy(operbuf, aconf->info.oper, sizeof operbuf);
-                       p = strrchr(operbuf, '{');
-                       if (p != NULL &&
-                                       operbuf + sizeof operbuf - p > (ptrdiff_t)(melen + 2))
-                       {
-                               memcpy(p + 1, me.name, melen);
-                               p[melen + 1] = '}';
-                               p[melen + 2] = '\0';
-                               oper = operbuf;
-                       }
-               }
                sendto_one(client_p, ":%s BAN %s %s %s %lu %d %d %s :%s%s%s",
                                me.id,
                                type,
@@ -523,7 +500,7 @@ burst_ban(struct Client *client_p)
                                (unsigned long)aconf->created,
                                (int)(aconf->hold - aconf->created),
                                (int)(aconf->lifetime - aconf->created),
-                               oper,
+                               aconf->info.oper,
                                aconf->passwd,
                                aconf->spasswd ? "|" : "",
                                aconf->spasswd ? aconf->spasswd : "");