~ubuntu-branches/ubuntu/trusty/znc/trusty

« back to all changes in this revision

Viewing changes to src/Modules.cpp

  • Committer: Package Import Robot
  • Author(s): Patrick Matthäi
  • Date: 2013-11-08 13:13:58 UTC
  • mfrom: (34.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20131108131358-o90mlo1evvu27z8h
Tags: 1.2-1
* New upstream release.
  Closes: #728786
  - Remove merged patch 01-spelling-error.
  - Remove merged patch 02-CVE-2013-2130.
  - License has been changed to Apache-2.0.
  - Disable new tests, because they require an internet connection.
  - Add new znc-extra module modules_online.
  - Remove AUTHORS file.
* Bump Standards-Version to 3.9.5 (no changes needed).
* Don't explicitly request xz compression - dpkg 1.17 does this by default.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (C) 2004-2012  See the AUTHORS file for details.
3
 
 *
4
 
 * This program is free software; you can redistribute it and/or modify it
5
 
 * under the terms of the GNU General Public License version 2 as published
6
 
 * by the Free Software Foundation.
 
2
 * Copyright (C) 2004-2013 ZNC, see the NOTICE file for details.
 
3
 *
 
4
 * Licensed under the Apache License, Version 2.0 (the "License");
 
5
 * you may not use this file except in compliance with the License.
 
6
 * You may obtain a copy of the License at
 
7
 *
 
8
 *     http://www.apache.org/licenses/LICENSE-2.0
 
9
 *
 
10
 * Unless required by applicable law or agreed to in writing, software
 
11
 * distributed under the License is distributed on an "AS IS" BASIS,
 
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
13
 * See the License for the specific language governing permissions and
 
14
 * limitations under the License.
7
15
 */
8
16
 
9
17
#include <znc/Modules.h>
48
56
                        if (m_pNetwork)                              \
49
57
                                pMod->SetNetwork(pNetwork);              \
50
58
                        pMod->SetClient(pOldClient);                     \
51
 
                } catch (CModule::EModException e) {                     \
 
59
                } catch (const CModule::EModException& e) {                     \
52
60
                        if (e == CModule::UNLOAD) {                      \
53
61
                                UnloadModule((*this)[a]->GetModName());  \
54
62
                        }                                                \
88
96
                                bHaltCore = true;                        \
89
97
                                break;                                   \
90
98
                        }                                                \
91
 
                } catch (CModule::EModException e) {                     \
 
99
                } catch (const CModule::EModException& e) {                     \
92
100
                        if (e == CModule::UNLOAD) {                      \
93
101
                                UnloadModule((*this)[a]->GetModName());  \
94
102
                        }                                                \
155
163
void CModule::SetNetwork(CIRCNetwork* pNetwork) { m_pNetwork = pNetwork; }
156
164
void CModule::SetClient(CClient* pClient) { m_pClient = pClient; }
157
165
 
 
166
CString CModule::ExpandString(const CString& sStr) const {
 
167
        CString sRet;
 
168
        return ExpandString(sStr, sRet);
 
169
}
 
170
 
 
171
CString& CModule::ExpandString(const CString& sStr, CString& sRet) const {
 
172
        sRet = sStr;
 
173
 
 
174
        if (m_pNetwork) {
 
175
                return m_pNetwork->ExpandString(sRet, sRet);
 
176
        }
 
177
 
 
178
        if (m_pUser) {
 
179
                return m_pUser->ExpandString(sRet, sRet);
 
180
        }
 
181
 
 
182
        return sRet;
 
183
}
 
184
 
158
185
const CString& CModule::GetSavePath() const {
159
186
        if (!CFile::Exists(m_sSavePath)) {
160
187
                CDir::MakeDir(m_sSavePath);
573
600
CModule::EModRet CModule::OnChanNotice(CNick& Nick, CChan& Channel, CString& sMessage) { return CONTINUE; }
574
601
CModule::EModRet CModule::OnTopic(CNick& Nick, CChan& Channel, CString& sTopic) { return CONTINUE; }
575
602
CModule::EModRet CModule::OnTimerAutoJoin(CChan& Channel) { return CONTINUE; }
 
603
CModule::EModRet CModule::OnAddNetwork(CIRCNetwork& Network, CString& sErrorRet) { return CONTINUE; }
 
604
CModule::EModRet CModule::OnDeleteNetwork(CIRCNetwork& Network) { return CONTINUE; }
576
605
 
577
606
bool CModule::OnServerCapAvailable(const CString& sCap) { return false; }
578
607
void CModule::OnServerCapResult(const CString& sCap, bool bSuccess) {}
670
699
                        if (!(*this)[a]->OnBoot()) {
671
700
                                return true;
672
701
                        }
673
 
                } catch (CModule::EModException e) {
 
702
                } catch (const CModule::EModException& e) {
674
703
                        if (e == CModule::UNLOAD) {
675
704
                                UnloadModule((*this)[a]->GetModName());
676
705
                        }
731
760
bool CModules::OnChanNotice(CNick& Nick, CChan& Channel, CString& sMessage) { MODHALTCHK(OnChanNotice(Nick, Channel, sMessage)); }
732
761
bool CModules::OnTopic(CNick& Nick, CChan& Channel, CString& sTopic) { MODHALTCHK(OnTopic(Nick, Channel, sTopic)); }
733
762
bool CModules::OnTimerAutoJoin(CChan& Channel) { MODHALTCHK(OnTimerAutoJoin(Channel)); }
 
763
bool CModules::OnAddNetwork(CIRCNetwork& Network, CString& sErrorRet) { MODHALTCHK(OnAddNetwork(Network, sErrorRet)); }
 
764
bool CModules::OnDeleteNetwork(CIRCNetwork& Network) { MODHALTCHK(OnDeleteNetwork(Network)); }
734
765
bool CModules::OnStatusCommand(CString& sCommand) { MODHALTCHK(OnStatusCommand(sCommand)); }
735
766
bool CModules::OnModCommand(const CString& sCommand) { MODUNLOADCHK(OnModCommand(sCommand)); return false; }
736
767
bool CModules::OnModNotice(const CString& sMessage) { MODUNLOADCHK(OnModNotice(sMessage)); return false; }
754
785
                                bResult |= pMod->OnServerCapAvailable(sCap);
755
786
                        }
756
787
                        pMod->SetClient(pOldClient);
757
 
                } catch (CModule::EModException e) {
 
788
                } catch (const CModule::EModException& e) {
758
789
                        if (CModule::UNLOAD == e) {
759
790
                                UnloadModule((*this)[a]->GetModName());
760
791
                        }
817
848
                                bResult |= pMod->IsClientCapSupported(pClient, sCap, bState);
818
849
                        }
819
850
                        pMod->SetClient(pOldClient);
820
 
                } catch (CModule::EModException e) {
 
851
                } catch (const CModule::EModException& e) {
821
852
                        if (CModule::UNLOAD == e) {
822
853
                                UnloadModule((*this)[a]->GetModName());
823
854
                        }
923
954
        bool bLoaded;
924
955
        try {
925
956
                bLoaded = pModule->OnLoad(sArgs, sRetMsg);
926
 
        } catch (CModule::EModException) {
 
957
        } catch (const CModule::EModException&) {
927
958
                bLoaded = false;
928
959
                sRetMsg = "Caught an exception";
929
960
        }
1149
1180
        ModHandle p = dlopen((sModPath).c_str(), RTLD_NOW | RTLD_GLOBAL);
1150
1181
 
1151
1182
        if (!p) {
1152
 
                sRetMsg = "Unable to open module [" + sModule + "] [" + dlerror() + "]";
 
1183
                // dlerror() returns pointer to static buffer, which may be overwritten very soon with another dl call
 
1184
                // also it may just return null.
 
1185
                const char* cDlError = dlerror();
 
1186
                CString sDlError = cDlError ? cDlError : "Unknown error";
 
1187
                sRetMsg = "Unable to open module [" + sModule + "] [" + sDlError + "]";
1153
1188
                return NULL;
1154
1189
        }
1155
1190