From 7366edfe14f85efcf020b40b0371ee92c4b203f0 Mon Sep 17 00:00:00 2001 From: Richard Schwab Date: Mon, 17 Mar 2014 14:32:31 +0100 Subject: [PATCH] Fix *controlpanel not checking whether the bindhost is in the whitelist (cherry picked from commit e77edb409eeaeea428342559d0d34a5a33894150) --- modules/controlpanel.cpp | 46 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/modules/controlpanel.cpp b/modules/controlpanel.cpp index 555a0458..816fc2ca 100644 --- a/modules/controlpanel.cpp +++ b/modules/controlpanel.cpp @@ -244,6 +244,29 @@ class CAdminMod : public CModule { } else if (sVar == "bindhost") { if(!pUser->DenySetBindHost() || m_pUser->IsAdmin()) { + if (sValue.Equals(m_pUser->GetBindHost())) { + PutModule("This bind host is already set!"); + return; + } + + const VCString& vsHosts = CZNC::Get().GetBindHosts(); + if (!m_pUser->IsAdmin() && !vsHosts.empty()) { + VCString::const_iterator it; + bool bFound = false; + + for (it = vsHosts.begin(); it != vsHosts.end(); ++it) { + if (sValue.Equals(*it)) { + bFound = true; + break; + } + } + + if (!bFound) { + PutModule("You may not use this bind host. See /msg " + m_pUser->GetStatusPrefix() + "status ListBindHosts for a list"); + return; + } + } + pUser->SetBindHost(sValue); PutModule("BindHost = " + sValue); } else { @@ -465,6 +488,29 @@ class CAdminMod : public CModule { PutModule("RealName = " + pNetwork->GetRealName()); } else if (sVar.Equals("bindhost")) { if(!pUser->DenySetBindHost() || m_pUser->IsAdmin()) { + if (sValue.Equals(pNetwork->GetBindHost())) { + PutModule("This bind host is already set!"); + return; + } + + const VCString& vsHosts = CZNC::Get().GetBindHosts(); + if (!m_pUser->IsAdmin() && !vsHosts.empty()) { + VCString::const_iterator it; + bool bFound = false; + + for (it = vsHosts.begin(); it != vsHosts.end(); ++it) { + if (sValue.Equals(*it)) { + bFound = true; + break; + } + } + + if (!bFound) { + PutModule("You may not use this bind host. See /msg " + m_pUser->GetStatusPrefix() + "status ListBindHosts for a list"); + return; + } + } + pNetwork->SetBindHost(sValue); PutModule("BindHost = " + sValue); } else {