mirror of
https://github.com/znc/znc.git
synced 2026-08-11 19:32:46 +02:00
CUser::Clone(): Handle modules after all other user settings
Thanks to tylerdu who reported that cloning an admin user who got admin-only modules (e.g. listsockets) loaded skips those modules. This is fixed by handling modules last in CUser::Clone(). Other stuff like e.g. the Admin flag are now handled before the modules are and thus loading listsockets doesn't fail with "You must be admin to use this module". git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1628 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
@@ -354,39 +354,6 @@ bool CUser::Clone(const CUser& User, CString& sErrorRet, bool bCloneChans) {
|
|||||||
|
|
||||||
// !Allowed Hosts
|
// !Allowed Hosts
|
||||||
|
|
||||||
#ifdef _MODULES
|
|
||||||
// Modules
|
|
||||||
set<CString> ssUnloadMods;
|
|
||||||
CModules& vCurMods = GetModules();
|
|
||||||
const CModules& vNewMods = User.GetModules();
|
|
||||||
|
|
||||||
for (a = 0; a < vNewMods.size(); a++) {
|
|
||||||
CString sModRet;
|
|
||||||
CModule* pNewMod = vNewMods[a];
|
|
||||||
CModule* pCurMod = vCurMods.FindModule(pNewMod->GetModName());
|
|
||||||
|
|
||||||
if (!pCurMod) {
|
|
||||||
vCurMods.LoadModule(pNewMod->GetModName(), pNewMod->GetArgs(), this, sModRet);
|
|
||||||
} else if (pNewMod->GetArgs() != pCurMod->GetArgs()) {
|
|
||||||
vCurMods.ReloadModule(pNewMod->GetModName(), pNewMod->GetArgs(), this, sModRet);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (a = 0; a < vCurMods.size(); a++) {
|
|
||||||
CModule* pCurMod = vCurMods[a];
|
|
||||||
CModule* pNewMod = vNewMods.FindModule(pCurMod->GetModName());
|
|
||||||
|
|
||||||
if (!pNewMod) {
|
|
||||||
ssUnloadMods.insert(pCurMod->GetModName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (set<CString>::iterator it = ssUnloadMods.begin(); it != ssUnloadMods.end(); it++) {
|
|
||||||
vCurMods.UnloadModule(*it);
|
|
||||||
}
|
|
||||||
// !Modules
|
|
||||||
#endif // !_MODULES
|
|
||||||
|
|
||||||
// Servers
|
// Servers
|
||||||
const vector<CServer*>& vServers = User.GetServers();
|
const vector<CServer*>& vServers = User.GetServers();
|
||||||
CString sServer;
|
CString sServer;
|
||||||
@@ -469,6 +436,39 @@ bool CUser::Clone(const CUser& User, CString& sErrorRet, bool bCloneChans) {
|
|||||||
SetTimezoneOffset(User.GetTimezoneOffset());
|
SetTimezoneOffset(User.GetTimezoneOffset());
|
||||||
// !Flags
|
// !Flags
|
||||||
|
|
||||||
|
#ifdef _MODULES
|
||||||
|
// Modules
|
||||||
|
set<CString> ssUnloadMods;
|
||||||
|
CModules& vCurMods = GetModules();
|
||||||
|
const CModules& vNewMods = User.GetModules();
|
||||||
|
|
||||||
|
for (a = 0; a < vNewMods.size(); a++) {
|
||||||
|
CString sModRet;
|
||||||
|
CModule* pNewMod = vNewMods[a];
|
||||||
|
CModule* pCurMod = vCurMods.FindModule(pNewMod->GetModName());
|
||||||
|
|
||||||
|
if (!pCurMod) {
|
||||||
|
vCurMods.LoadModule(pNewMod->GetModName(), pNewMod->GetArgs(), this, sModRet);
|
||||||
|
} else if (pNewMod->GetArgs() != pCurMod->GetArgs()) {
|
||||||
|
vCurMods.ReloadModule(pNewMod->GetModName(), pNewMod->GetArgs(), this, sModRet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (a = 0; a < vCurMods.size(); a++) {
|
||||||
|
CModule* pCurMod = vCurMods[a];
|
||||||
|
CModule* pNewMod = vNewMods.FindModule(pCurMod->GetModName());
|
||||||
|
|
||||||
|
if (!pNewMod) {
|
||||||
|
ssUnloadMods.insert(pCurMod->GetModName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (set<CString>::iterator it = ssUnloadMods.begin(); it != ssUnloadMods.end(); it++) {
|
||||||
|
vCurMods.UnloadModule(*it);
|
||||||
|
}
|
||||||
|
// !Modules
|
||||||
|
#endif // !_MODULES
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user