Skip to content

Commit

Permalink
Add description parameter to auth blocks (#327)
Browse files Browse the repository at this point in the history
  • Loading branch information
glguy authored Apr 14, 2022
1 parent b2fa28d commit 48a06ae
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 12 deletions.
5 changes: 5 additions & 0 deletions doc/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion include/messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion include/s_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) */
Expand Down Expand Up @@ -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 **);
Expand Down
6 changes: 3 additions & 3 deletions ircd/hostmask.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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);
}
}

11 changes: 11 additions & 0 deletions ircd/newconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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 }
};

Expand Down
5 changes: 4 additions & 1 deletion ircd/s_conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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[] = "<NULL>";
static char zero[] = "default";
Expand All @@ -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;
}

Expand Down
10 changes: 5 additions & 5 deletions modules/m_stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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),
Expand Down Expand Up @@ -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;

Expand All @@ -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 */
Expand Down
3 changes: 2 additions & 1 deletion modules/m_testline.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) ? "<NULL>" : 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;
}

Expand Down

0 comments on commit 48a06ae

Please sign in to comment.