X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=ircd%2Fm_stats.c;h=a68d0d7f804f527093a313202f54db496048843b;hb=refs%2Fheads%2Fupstream;hp=aeb99958e8600ecd2542d365037eb87adbcbc741;hpb=5ba09703da9f8f21f3278dc0222cd6fe077cfe31;p=ircu2.10.12-pk.git diff --git a/ircd/m_stats.c b/ircd/m_stats.c index aeb9995..a68d0d7 100644 --- a/ircd/m_stats.c +++ b/ircd/m_stats.c @@ -84,6 +84,7 @@ #include "client.h" #include "ircd.h" #include "ircd_features.h" +#include "ircd_log.h" #include "ircd_reply.h" #include "ircd_string.h" #include "msg.h" @@ -93,7 +94,7 @@ #include "send.h" #include "struct.h" -#include +/* #include -- Now using assert in ircd_log.h */ #include #include @@ -117,15 +118,12 @@ int m_stats(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) { - unsigned char stat = parc > 1 ? parv[1][0] : '\0'; - struct StatDesc *sd; - char *param = 0; + const struct StatDesc *sd; + char *param; - /* If we didn't find a descriptor and this is my client, send them help */ - if (!(sd = statsmap[(int)stat])) { - stat = '*'; - sd = statsmap[(int)stat]; - } + /* If we didn't find a descriptor, send them help */ + if ((parc < 2) || !(sd = stats_find(parv[1]))) + parv[1] = "*", sd = stats_find("*"); assert(sd != 0); @@ -133,15 +131,20 @@ m_stats(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) * not privileged (server or an operator), then the STAT_FLAG_OPERONLY * flag must not be set, and if the STAT_FLAG_OPERFEAT flag is set, * then the feature given by sd->sd_control must be off. + * + * This checks cptr rather than sptr so that a local oper may send + * /stats queries to other servers. */ if (!IsPrivileged(cptr) && ((sd->sd_flags & STAT_FLAG_OPERONLY) || ((sd->sd_flags & STAT_FLAG_OPERFEAT) && feature_bool(sd->sd_control)))) - return send_reply(cptr, ERR_NOPRIVILEGES); + return send_reply(sptr, ERR_NOPRIVILEGES); /* Check for extra parameter */ if ((sd->sd_flags & STAT_FLAG_VARPARAM) && parc > 3 && !EmptyString(parv[3])) param = parv[3]; + else + param = NULL; /* Ok, track down who's supposed to get this... */ if (hunt_server_cmd(sptr, CMD_STATS, cptr, feature_int(FEAT_HIS_REMOTE), @@ -149,11 +152,15 @@ m_stats(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) HUNTED_ISME) return 0; /* Someone else--cool :) */ + /* Check if they are a local user */ + if ((sd->sd_flags & STAT_FLAG_LOCONLY) && !MyUser(sptr)) + return send_reply(sptr, ERR_NOPRIVILEGES); + assert(sd->sd_func != 0); /* Ok, dispatch the stats function */ - (*sd->sd_func)(sptr, sd, stat, param); + (*sd->sd_func)(sptr, sd, param); /* Done sending them the stats */ - return send_reply(sptr, RPL_ENDOFSTATS, stat); + return send_reply(sptr, RPL_ENDOFSTATS, parv[1]); }