/* 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;
}
{
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;
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,
(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 : "");