From 3a177354690a81bad08eda5d6ae6986e5d1cfe66 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Sun, 18 Jan 2009 01:35:24 +0100 Subject: [PATCH] Change /stats O to show privset blocks (oper only). To show operator blocks, only /stats o (lowercase) now works. --- doc/sgml/oper-guide/commands.sgml | 6 ++++++ help/opers/stats | 1 + include/privilege.h | 1 + modules/m_stats.c | 8 +++++++- src/privilege.c | 18 ++++++++++++++++++ 5 files changed, 33 insertions(+), 1 deletion(-) diff --git a/doc/sgml/oper-guide/commands.sgml b/doc/sgml/oper-guide/commands.sgml index 6654cd23..871ee2d9 100644 --- a/doc/sgml/oper-guide/commands.sgml +++ b/doc/sgml/oper-guide/commands.sgml @@ -1014,6 +1014,12 @@ Show operator blocks + + O + + Show privset blocks + + p diff --git a/help/opers/stats b/help/opers/stats index e6b27d9a..3017eb31 100644 --- a/help/opers/stats +++ b/help/opers/stats @@ -24,6 +24,7 @@ X f - Shows File Descriptors l - Shows hostname and generic info about [nick] m - Shows commands and their usage n - Shows DNS blacklists +* O - Shows privset blocks ^ o - Shows operator blocks (Old O: lines) ^ P - Shows configured ports p - Shows online opers diff --git a/include/privilege.h b/include/privilege.h index 2af53f3e..46d5cd93 100644 --- a/include/privilege.h +++ b/include/privilege.h @@ -47,5 +47,6 @@ struct PrivilegeSet *privilegeset_ref(struct PrivilegeSet *set); void privilegeset_unref(struct PrivilegeSet *set); void privilegeset_mark_all_illegal(void); void privilegeset_delete_all_illegal(void); +void privilegeset_report(struct Client *source_p); #endif diff --git a/modules/m_stats.c b/modules/m_stats.c index 3b08b5d3..dd678a31 100644 --- a/modules/m_stats.c +++ b/modules/m_stats.c @@ -101,6 +101,7 @@ static void stats_klines(struct Client *); static void stats_messages(struct Client *); static void stats_dnsbl(struct Client *); static void stats_oper(struct Client *); +static void stats_privset(struct Client *); static void stats_operedup(struct Client *); static void stats_ports(struct Client *); static void stats_tresv(struct Client *); @@ -148,7 +149,7 @@ static struct StatsStruct stats_cmd_table[] = { {'M', stats_messages, 0, 0, }, {'n', stats_dnsbl, 0, 0, }, {'o', stats_oper, 0, 0, }, - {'O', stats_oper, 0, 0, }, + {'O', stats_privset, 1, 0, }, {'p', stats_operedup, 0, 0, }, {'P', stats_ports, 0, 0, }, {'q', stats_tresv, 1, 0, }, @@ -678,6 +679,11 @@ stats_oper(struct Client *source_p) } } +static void +stats_privset(struct Client *source_p) +{ + privilegeset_report(source_p); +} /* stats_operedup() * diff --git a/src/privilege.c b/src/privilege.c index 09f5ea0d..e1f25076 100644 --- a/src/privilege.c +++ b/src/privilege.c @@ -24,6 +24,7 @@ #include #include "s_conf.h" #include "privilege.h" +#include "numeric.h" static rb_dlink_list privilegeset_list = {}; @@ -189,3 +190,20 @@ privilegeset_delete_all_illegal(void) privilegeset_unref(set); } } + +void +privilegeset_report(struct Client *source_p) +{ + rb_dlink_node *ptr; + + RB_DLINK_FOREACH(ptr, privilegeset_list.head) + { + struct PrivilegeSet *set = ptr->data; + + /* use RPL_STATSDEBUG for now -- jilles */ + sendto_one_numeric(source_p, RPL_STATSDEBUG, + "O :%s %s", + set->name, + set->privs); + } +}