mirror of
https://github.com/znc/znc.git
synced 2026-05-03 03:52:33 +02:00
Fix unloading of /bin/rm'd modules
The old code first tried to dlopen() the module again to find out if it's a global or a user module. This could have lots of weird effects. Now we just unload the user module and if that fails retry with the global module (if the user got the appropriate privileges). This removes and fixes the #warning added in the last commit. P.S.: Oh and this is less LOCs now! git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1597 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
@@ -676,32 +676,19 @@ void CClient::UserCommand(CString& sLine) {
|
||||
return;
|
||||
}
|
||||
#ifdef _MODULES
|
||||
CModInfo ModInfo;
|
||||
CString sRetMsg;
|
||||
#warning If a module is removed while it is loaded, one can no longer unload it?
|
||||
if (!CZNC::Get().GetModules().GetModInfo(ModInfo, sMod, sRetMsg)) {
|
||||
PutStatus("Unable to find modinfo for [" + sMod + "]");
|
||||
return;
|
||||
}
|
||||
|
||||
bool bGlobal = ModInfo.IsGlobal();
|
||||
|
||||
if (bGlobal && !m_pUser->IsAdmin()) {
|
||||
PutStatus("Unable to unload global module [" + sMod + "] Access Denied.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (sMod.empty()) {
|
||||
PutStatus("Usage: UnloadMod <module>");
|
||||
return;
|
||||
}
|
||||
|
||||
CString sModRet;
|
||||
bool b;
|
||||
|
||||
if (bGlobal) {
|
||||
CZNC::Get().GetModules().UnloadModule(sMod, sModRet);
|
||||
} else {
|
||||
m_pUser->GetModules().UnloadModule(sMod, sModRet);
|
||||
// First, try to unload the user module
|
||||
b = m_pUser->GetModules().UnloadModule(sMod, sModRet);
|
||||
if (!b && m_pUser->IsAdmin()) {
|
||||
// If that failed and the user is an admin, try to unload a global module
|
||||
b = CZNC::Get().GetModules().UnloadModule(sMod, sModRet);
|
||||
}
|
||||
|
||||
PutStatus(sModRet);
|
||||
|
||||
Reference in New Issue
Block a user