]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modes/cmode_k.cpp
Fix the remote +k-k stuff
[user/henk/code/inspircd.git] / src / modes / cmode_k.cpp
index 2f06ba55c91514df72c9ab76c3e88edff521a9e8..5e55ce972fe751af9d3d2cf8d445548b462bdb56 100644 (file)
@@ -23,31 +23,34 @@ std::pair<bool,std::string> ModeChannelKey::ModeSet(userrec* source, userrec* de
 
 ModeAction ModeChannelKey::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
 {
-       if (channel->modes[CM_KEY] != adding)
+       if ((channel->modes[CM_KEY] != adding) || (!IS_LOCAL(source)))
        {
-               if ((channel->modes[CM_KEY]) && (strcasecmp(parameter.c_str(),channel->key)))
+               if (((channel->modes[CM_KEY]) && (strcasecmp(parameter.c_str(),channel->key))) && (IS_LOCAL(source)))
                {
                        /* Key is currently set and the correct key wasnt given */
+                       log(DEBUG,"Key Cond 2");
                        return MODEACTION_DENY;
                }
-               else if (!channel->modes[CM_KEY])
+               else if ((!channel->modes[CM_KEY]) || ((adding) && (!IS_LOCAL(source))))
                {
                        /* Key isnt currently set */
                        strlcpy(channel->key,parameter.c_str(),32);
                        channel->modes[CM_KEY] = adding;
                        return MODEACTION_ALLOW;
                }
-               else if ((channel->modes[CM_KEY]) && (!strcasecmp(parameter.c_str(),channel->key)))
+               else if (((channel->modes[CM_KEY]) && (!strcasecmp(parameter.c_str(),channel->key))) || ((!adding) && (!IS_LOCAL(source))))
                {
                        /* Key is currently set, and correct key was given */
                        *channel->key = 0;
                        channel->modes[CM_KEY] = adding;
                        return MODEACTION_ALLOW;
                }
+               log(DEBUG,"Key Cond three");
                return MODEACTION_DENY;
        }
        else
        {
+               log(DEBUG,"Key Condition one");
                return MODEACTION_DENY;
        }
 }