From 48a06ae3d7a2bbd88f43f9006e90fa4b58fdb197 Mon Sep 17 00:00:00 2001 From: Eric Mertens Date: Thu, 14 Apr 2022 14:39:45 -0700 Subject: [PATCH] Add description parameter to auth blocks (#327) --- doc/reference.conf | 5 +++++ include/messages.h | 2 +- include/s_conf.h | 3 ++- ircd/hostmask.c | 6 +++--- ircd/newconf.c | 11 +++++++++++ ircd/s_conf.c | 5 ++++- modules/m_stats.c | 10 +++++----- modules/m_testline.c | 3 ++- 8 files changed, 33 insertions(+), 12 deletions(-) diff --git a/doc/reference.conf b/doc/reference.conf index 368c5a70..35afb85a 100644 --- a/doc/reference.conf +++ b/doc/reference.conf @@ -344,6 +344,11 @@ listen { /* auth {}: allow users to connect to the ircd (OLD I:) */ auth { + /* description: descriptive text to help recognize this auth block in + * stats i output. + */ + description = "example oper"; + /* user: the user@host allowed to connect. Multiple IPv4/IPv6 user * lines are permitted per auth block. This is matched against the * hostname and IP address (using :: shortening for IPv6 and diff --git a/include/messages.h b/include/messages.h index c3c75e96..9a587096 100644 --- a/include/messages.h +++ b/include/messages.h @@ -49,7 +49,7 @@ #define NUMERIC_STR_209 "Class %s %d" #define NUMERIC_STR_212 "%s %u %lu :%u" #define NUMERIC_STR_213 "C %s %s %s %d %s %s" -#define NUMERIC_STR_215 "I %s %s %s@%s %d %s" +#define NUMERIC_STR_215 "I %s %s %s@%s %d %s :%s" #define NUMERIC_STR_216 "%c %s * %s :%s%s%s" #define NUMERIC_STR_217 "%c %d %s :%s" #define NUMERIC_STR_218 "Y %s %d %d %d %u %d.%d %d.%d %u" diff --git a/include/s_conf.h b/include/s_conf.h index b8bb1404..acc4f1b8 100644 --- a/include/s_conf.h +++ b/include/s_conf.h @@ -65,6 +65,7 @@ struct ConfItem char *passwd; /* doubles as kline reason *ugh* */ char *spasswd; /* Password to send. */ char *user; /* user part of user@host */ + char *desc; /* description */ int port; time_t hold; /* Hold action until this time (calendar time) */ time_t created; /* Creation time (for klines etc) */ @@ -384,7 +385,7 @@ extern int detach_conf(struct Client *); extern struct ConfItem *find_tkline(const char *, const char *, struct sockaddr *); extern char *show_iline_prefix(struct Client *, struct ConfItem *, char *); extern void get_printable_conf(struct ConfItem *, - char **, char **, const char **, char **, int *, char **); + char **, char **, const char **, char **, int *, char **, char **); extern char *get_user_ban_reason(struct ConfItem *aconf); extern void get_printable_kline(struct Client *, struct ConfItem *, char **, char **, char **, char **); diff --git a/ircd/hostmask.c b/ircd/hostmask.c index 6b50b5e5..6cedee04 100644 --- a/ircd/hostmask.c +++ b/ircd/hostmask.c @@ -723,7 +723,7 @@ show_iline_prefix(struct Client *sptr, struct ConfItem *aconf, char *name) void report_auth(struct Client *client_p) { - char *name, *host, *user, *classname; + char *name, *host, *user, *classname, *desc; const char *pass; struct AddressRec *arec; struct ConfItem *aconf; @@ -739,7 +739,7 @@ report_auth(struct Client *client_p) continue; get_printable_conf(aconf, &name, &host, &pass, &user, &port, - &classname); + &classname, &desc); if(!EmptyString(aconf->spasswd)) pass = aconf->spasswd; @@ -748,7 +748,7 @@ report_auth(struct Client *client_p) form_str(RPL_STATSILINE), name, pass, show_iline_prefix(client_p, aconf, user), show_ip_conf(aconf, client_p) ? host : "255.255.255.255", - port, classname); + port, classname, desc); } } diff --git a/ircd/newconf.c b/ircd/newconf.c index 101942f9..a160e29e 100644 --- a/ircd/newconf.c +++ b/ircd/newconf.c @@ -1037,6 +1037,9 @@ conf_end_auth(struct TopConf *tc) if(yy_aconf->className) yy_tmp->className = rb_strdup(yy_aconf->className); + if(yy_aconf->desc) + yy_tmp->desc = rb_strdup(yy_aconf->desc); + yy_tmp->flags = yy_aconf->flags; yy_tmp->port = yy_aconf->port; @@ -1172,6 +1175,13 @@ conf_set_auth_spoof(void *data) yy_aconf->flags |= CONF_FLAGS_SPOOF_IP; } +static void +conf_set_auth_desc(void *data) +{ + rb_free(yy_aconf->desc); + yy_aconf->desc = rb_strdup(data); +} + static void conf_set_auth_flags(void *data) { @@ -2640,6 +2650,7 @@ static struct ConfEntry conf_auth_table[] = { "redirport", CF_INT, conf_set_auth_redir_port, 0, NULL }, { "flags", CF_STRING | CF_FLIST, conf_set_auth_flags, 0, NULL }, { "umodes", CF_QSTRING, conf_set_auth_umodes, 0, NULL}, + { "description",CF_QSTRING, conf_set_auth_desc, 0, NULL}, { "\0", 0, NULL, 0, NULL } }; diff --git a/ircd/s_conf.c b/ircd/s_conf.c index 406e7103..cb86811f 100644 --- a/ircd/s_conf.c +++ b/ircd/s_conf.c @@ -154,6 +154,7 @@ free_conf(struct ConfItem *aconf) rb_free(aconf->className); rb_free(aconf->user); rb_free(aconf->host); + rb_free(aconf->desc); if(IsConfBan(aconf)) operhash_delete(aconf->info.oper); @@ -1346,7 +1347,8 @@ get_oper_name(struct Client *client_p) */ void get_printable_conf(struct ConfItem *aconf, char **name, char **host, - const char **pass, char **user, int *port, char **classname) + const char **pass, char **user, int *port, + char **classname, char **desc) { static char null[] = ""; static char zero[] = "default"; @@ -1356,6 +1358,7 @@ get_printable_conf(struct ConfItem *aconf, char **name, char **host, *pass = EmptyString(aconf->passwd) ? null : aconf->passwd; *user = EmptyString(aconf->user) ? null : aconf->user; *classname = EmptyString(aconf->className) ? zero : aconf->className; + *desc = CheckEmpty(aconf->desc); *port = (int) aconf->port; } diff --git a/modules/m_stats.c b/modules/m_stats.c index 8bdf851c..55489068 100644 --- a/modules/m_stats.c +++ b/modules/m_stats.c @@ -453,7 +453,7 @@ stats_deny (struct Client *source_p) static void stats_exempt(struct Client *source_p) { - char *name, *host, *user, *classname; + char *name, *host, *user, *classname, *desc; const char *pass; struct AddressRec *arec; struct ConfItem *aconf; @@ -474,7 +474,7 @@ stats_exempt(struct Client *source_p) { aconf = arec->aconf; get_printable_conf (aconf, &name, &host, &pass, - &user, &port, &classname); + &user, &port, &classname, &desc); sendto_one_numeric(source_p, RPL_STATSDLINE, form_str(RPL_STATSDLINE), @@ -533,7 +533,7 @@ stats_auth (struct Client *source_p) else if((ConfigFileEntry.stats_i_oper_only == 1) && !IsOperGeneral (source_p)) { struct ConfItem *aconf; - char *name, *host, *user, *classname; + char *name, *host, *user, *classname, *desc; const char *pass = "*"; int port; @@ -550,13 +550,13 @@ stats_auth (struct Client *source_p) if(aconf == NULL) return; - get_printable_conf (aconf, &name, &host, &pass, &user, &port, &classname); + get_printable_conf (aconf, &name, &host, &pass, &user, &port, &classname, &desc); if(!EmptyString(aconf->spasswd)) pass = aconf->spasswd; sendto_one_numeric(source_p, RPL_STATSILINE, form_str(RPL_STATSILINE), name, pass, show_iline_prefix(source_p, aconf, user), - host, port, classname); + host, port, classname, desc); } /* Theyre opered, or allowed to see all auth blocks */ diff --git a/modules/m_testline.c b/modules/m_testline.c index a55367f1..d8ec1347 100644 --- a/modules/m_testline.c +++ b/modules/m_testline.c @@ -235,7 +235,8 @@ mo_testline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sou sendto_one_numeric(source_p, RPL_STATSILINE, form_str(RPL_STATSILINE), aconf->info.name, EmptyString(aconf->spasswd) ? "" : aconf->spasswd, show_iline_prefix(source_p, aconf, aconf->user), - aconf->host, aconf->port, aconf->className); + aconf->host, aconf->port, aconf->className, + CheckEmpty(aconf->desc)); return; }