]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/commands/cmd_userhost.cpp
cmd_userhost Fix +H hidden opers being shown as opers
[user/henk/code/inspircd.git] / src / commands / cmd_userhost.cpp
index af7d3ceca65ba34903dc6aef65a5ee98a7cc07a2..7e1efd6375de04c8c041c588f32580e03c91f6ee 100644 (file)
@@ -30,8 +30,8 @@ class CommandUserhost : public Command
  public:
        /** Constructor for userhost.
         */
-       CommandUserhost ( Module* parent) : Command(parent,"USERHOST", 1, 5) {
-               syntax = "<nick> {<nick>}";
+       CommandUserhost ( Module* parent) : Command(parent,"USERHOST", 1) {
+               syntax = "<nick> [<nick> ...]";
        }
        /** Handle command.
         * @param parameters The parameters to the comamnd
@@ -44,9 +44,14 @@ class CommandUserhost : public Command
 
 CmdResult CommandUserhost::Handle (const std::vector<std::string>& parameters, User *user)
 {
-       std::string retbuf = std::string("302 ") + user->nick + " :";
+       std::string retbuf = "302 " + user->nick + " :";
 
-       for (unsigned int i = 0; i < parameters.size(); i++)
+       unsigned int max = parameters.size();
+       if (max > 5)
+               max = 5;
+
+       bool has_privs = user->HasPrivPermission("users/auspex");
+       for (unsigned int i = 0; i < max; i++)
        {
                User *u = ServerInstance->FindNickOnly(parameters[i]);
 
@@ -55,7 +60,12 @@ CmdResult CommandUserhost::Handle (const std::vector<std::string>& parameters, U
                        retbuf = retbuf + u->nick;
 
                        if (IS_OPER(u))
-                               retbuf = retbuf + "*";
+                       {
+                               // XXX: +H hidden opers must not be shown as opers
+                               ModeHandler* mh = ServerInstance->Modes->FindMode('H', MODETYPE_USER);
+                               if ((u == user) || (has_privs) || (!mh) || (!u->IsModeSet('H')) || (mh->name != "hideoper"))
+                                       retbuf += '*';
+                       }
 
                        retbuf = retbuf + "=";
 
@@ -66,7 +76,7 @@ CmdResult CommandUserhost::Handle (const std::vector<std::string>& parameters, U
 
                        retbuf = retbuf + u->ident + "@";
 
-                       if (user->HasPrivPermission("users/auspex"))
+                       if (has_privs)
                        {
                                retbuf = retbuf + u->host;
                        }