From e5e814b3dba2cde3c99e62fc9cb5c425458c6f5f Mon Sep 17 00:00:00 2001 From: Ed Kellett Date: Fri, 13 Nov 2020 22:47:09 +0000 Subject: [PATCH] Use opernames not servernames for remote opers --- include/s_conf.h | 2 +- ircd/s_conf.c | 22 +++++++++------------- ircd/s_serv.c | 27 ++------------------------- 3 files changed, 12 insertions(+), 39 deletions(-) diff --git a/include/s_conf.h b/include/s_conf.h index b31db910..a689bf31 100644 --- a/include/s_conf.h +++ b/include/s_conf.h @@ -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); diff --git a/ircd/s_conf.c b/ircd/s_conf.c index f35d4123..1262dcca 100644 --- a/ircd/s_conf.c +++ b/ircd/s_conf.c @@ -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; } diff --git a/ircd/s_serv.c b/ircd/s_serv.c index 0ab96ec7..210ed8b1 100644 --- a/ircd/s_serv.c +++ b/ircd/s_serv.c @@ -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 : "");