Remove ident spoof from znc core

This commit is contained in:
Kyle Fuller
2011-03-29 22:12:55 +01:00
parent 7162b01111
commit 703f2cd5bb
6 changed files with 0 additions and 126 deletions
-8
View File
@@ -19,7 +19,6 @@ const unsigned int CIRCSock::m_uCTCPFloodCount = 5;
CIRCSock::CIRCSock(CUser* pUser) : CZNCSock() {
m_pUser = pUser;
m_bISpoofReleased = false;
m_bAuthed = false;
m_bNamesx = false;
m_bUHNames = false;
@@ -66,10 +65,6 @@ CIRCSock::~CIRCSock() {
delete a->second;
}
if (!m_bISpoofReleased) {
CZNC::Get().ReleaseISpoof();
}
Quit();
m_msChans.clear();
GetUser()->AddBytesRead(GetBytesRead());
@@ -158,9 +153,6 @@ void CIRCSock::ReadLine(const CString& sData) {
m_pUser->ClearRawBuffer();
m_pUser->AddRawBuffer(":" + sServer + " " + sCmd + " ", " " + sRest);
CZNC::Get().ReleaseISpoof();
m_bISpoofReleased = true;
break;
}
case 5:
-1
View File
@@ -101,7 +101,6 @@ private:
void SendAltNick(const CString& sBadNick);
void SendNextCap();
protected:
bool m_bISpoofReleased;
bool m_bAuthed;
bool m_bNamesx;
bool m_bUHNames;
-12
View File
@@ -66,18 +66,6 @@
</div>
<div style="clear: both;"></div>
<div class="subsection half">
<div class="inputlabel">ISpoofFile:</div>
<div><input type="text" name="ispooffile" value="<? VAR ISpoofFile ?>" /></div>
<br /><span class="info">Example: ~/.oidentd.conf</span>
</div>
<div class="subsection half">
<div class="inputlabel">ISpoofFormat:</div>
<div><input type="text" name="ispoofformat" value="<? VAR ISpoofFormat ?>" /></div>
</div>
<div style="clear: both;"></div>
<div class="subsection half">
<div class="inputlabel">Maximum Buffer Size:</div>
<div><input type="text" name="maxbufsize" value="<? VAR MaxBufferSize ?>" /></div>
-4
View File
@@ -967,8 +967,6 @@ public:
Tmpl["Action"] = "settings";
Tmpl["Title"] = "Settings";
Tmpl["StatusPrefix"] = CZNC::Get().GetStatusPrefix();
Tmpl["ISpoofFile"] = CZNC::Get().GetISpoofFile();
Tmpl["ISpoofFormat"] = CZNC::Get().GetISpoofFormat();
Tmpl["MaxBufferSize"] = CString(CZNC::Get().GetMaxBufferSize());
Tmpl["ConnectDelay"] = CString(CZNC::Get().GetConnectDelay());
Tmpl["ServerThrottle"] = CString(CZNC::Get().GetServerThrottle());
@@ -1059,8 +1057,6 @@ public:
CString sArg;
sArg = WebSock.GetParam("statusprefix"); CZNC::Get().SetStatusPrefix(sArg);
sArg = WebSock.GetParam("ispooffile"); CZNC::Get().SetISpoofFile(sArg);
sArg = WebSock.GetParam("ispoofformat"); CZNC::Get().SetISpoofFormat(sArg);
sArg = WebSock.GetParam("maxbufsize"); CZNC::Get().SetMaxBufferSize(sArg.ToUInt());
sArg = WebSock.GetParam("connectdelay"); CZNC::Get().SetConnectDelay(sArg.ToUInt());
sArg = WebSock.GetParam("serverthrottle"); CZNC::Get().SetServerThrottle(sArg.ToUInt());
-90
View File
@@ -37,10 +37,8 @@ CZNC::CZNC() {
}
m_pModules = new CGlobalModules();
m_pISpoofLockFile = NULL;
m_uiConnectDelay = 5;
m_uiAnonIPLimit = 10;
SetISpoofFormat(""); // Set ISpoofFormat to default
m_uBytesRead = 0;
m_uBytesWritten = 0;
m_uiMaxBufferSize = 500;
@@ -51,9 +49,6 @@ CZNC::CZNC() {
}
CZNC::~CZNC() {
if (m_pISpoofLockFile)
ReleaseISpoof();
m_pModules->UnloadAll();
for (map<CString,CUser*>::iterator a = m_msUsers.begin(); a != m_msUsers.end(); ++a) {
@@ -117,10 +112,6 @@ bool CZNC::ConnectUser(CUser *pUser) {
CString sSockName = "IRC::" + pUser->GetUserName();
CIRCSock* pIRCSock = pUser->GetIRCSock();
if (m_pISpoofLockFile != NULL) {
return false;
}
if (!pUser->GetIRCConnectEnabled())
return false;
@@ -135,12 +126,6 @@ bool CZNC::ConnectUser(CUser *pUser) {
if (m_sConnectThrottle.GetItem(pServer->GetName()))
return false;
if (!WriteISpoof(pUser)) {
DEBUG("ISpoof [" + m_sISpoofFile + "] could not be written");
pUser->PutStatus("ISpoof [" + m_sISpoofFile + "] could not be written, retrying...");
return true;
}
m_sConnectThrottle.AddItem(pServer->GetName());
DEBUG("User [" << pUser->GetUserName() << "] is connecting to [" << pServer->GetString(false) << "] ...");
@@ -159,13 +144,11 @@ bool CZNC::ConnectUser(CUser *pUser) {
MODULECALL(OnIRCConnecting(pIRCSock), pUser, NULL,
DEBUG("Some module aborted the connection attempt");
pUser->PutStatus("Some module aborted the connection attempt");
ReleaseISpoof();
delete pIRCSock;
return false;
);
if (!m_Manager.Connect(pServer->GetName(), pServer->GetPort(), sSockName, 120, bSSL, pUser->GetBindHost(), pIRCSock)) {
ReleaseISpoof();
pUser->PutStatus("Unable to connect. (Bad host?)");
}
@@ -250,61 +233,6 @@ void CZNC::Loop() {
}
}
bool CZNC::WriteISpoof(CUser* pUser) {
if (m_pISpoofLockFile != NULL)
return false;
if (!GetISpoofFile().empty()) {
m_pISpoofLockFile = new CFile;
if (!m_pISpoofLockFile->TryExLock(GetISpoofFile(), O_RDWR | O_CREAT)) {
DEBUG("Couldn't open and lock ISpoofFile: " << strerror(errno));
delete m_pISpoofLockFile;
m_pISpoofLockFile = NULL;
return false;
}
char buf[1024];
memset((char*) buf, 0, 1024);
m_pISpoofLockFile->Read(buf, 1023);
m_sOrigISpoof = buf;
if (!m_pISpoofLockFile->Seek(0) || !m_pISpoofLockFile->Truncate()) {
DEBUG("Couldn't truncate the ISpoofFile: " << strerror(errno));
delete m_pISpoofLockFile;
m_pISpoofLockFile = NULL;
return false;
}
CString sData = pUser->ExpandString(m_sISpoofFormat);
// If the format doesn't contain anything expandable, we'll
// assume this is an "old"-style format string.
if (sData == m_sISpoofFormat) {
sData.Replace("%", pUser->GetIdent());
}
DEBUG("Writing [" + sData + "] to ISpoofFile [" + m_pISpoofLockFile->GetLongName() + "]");
m_pISpoofLockFile->Write(sData + "\n");
}
return true;
}
void CZNC::ReleaseISpoof() {
if (m_pISpoofLockFile == NULL)
return;
if (m_pISpoofLockFile->Seek(0) && m_pISpoofLockFile->Truncate()) {
DEBUG("Writing [" + m_sOrigISpoof + "] to ISpoofFile [" + m_pISpoofLockFile->GetLongName() + "]");
m_pISpoofLockFile->Write(m_sOrigISpoof);
} else {
DEBUG("Error while restoring ISpoof: " << strerror(errno));
}
m_sOrigISpoof = "";
delete m_pISpoofLockFile;
m_pISpoofLockFile = NULL;
}
CFile* CZNC::InitPidFile() {
if (!m_sPidFile.empty()) {
CString sFile;
@@ -547,13 +475,6 @@ bool CZNC::WriteConfig() {
m_LockFile.Write("ConnectDelay = " + CString(m_uiConnectDelay) + "\n");
m_LockFile.Write("ServerThrottle = " + CString(m_sConnectThrottle.GetTTL()/1000) + "\n");
if (!m_sISpoofFile.empty()) {
m_LockFile.Write("ISpoofFile = " + m_sISpoofFile.FirstLine() + "\n");
if (!m_sISpoofFormat.empty()) {
m_LockFile.Write("ISpoofFormat = " + m_sISpoofFormat.FirstLine() + "\n");
}
}
if (!m_sPidFile.empty()) {
m_LockFile.Write("PidFile = " + m_sPidFile.FirstLine() + "\n");
}
@@ -1620,12 +1541,6 @@ bool CZNC::DoRehash(CString& sError)
msModules[sModName] = sArgs;
continue;
} else if (sName.Equals("ISpoofFormat")) {
m_sISpoofFormat = sValue;
continue;
} else if (sName.Equals("ISpoofFile")) {
m_sISpoofFile = sValue;
continue;
} else if (sName.Equals("MOTD")) {
AddMotd(sValue);
continue;
@@ -1989,11 +1904,6 @@ protected:
const map<CString,CUser*>& mUsers = CZNC::Get().GetUserMap();
map<CString,CUser*>::const_iterator it = mUsers.begin();
if (CZNC::Get().IsISpoofLocked()) {
// Meh, gotta retry later
return;
}
uiUserCount = CZNC::Get().GetUserMap().size();
if (m_uiPosNextUser >= uiUserCount) {
-11
View File
@@ -35,9 +35,6 @@ public:
void DeleteUsers();
void Loop();
bool WriteISpoof(CUser* pUser);
void ReleaseISpoof();
bool IsISpoofLocked() { return m_pISpoofLockFile != NULL; }
bool WritePidFile(int iPid);
bool DeletePidFile();
bool WaitForChildLock();
@@ -83,8 +80,6 @@ public:
void SetConfigState(enum ConfigState e) { m_eConfigState = e; }
void SetSkinName(const CString& s) { m_sSkinName = s; }
void SetStatusPrefix(const CString& s) { m_sStatusPrefix = (s.empty()) ? "*" : s; }
void SetISpoofFile(const CString& s) { m_sISpoofFile = s; }
void SetISpoofFormat(const CString& s) { m_sISpoofFormat = (s.empty()) ? "global { reply \"%\" }" : s; }
void SetMaxBufferSize(unsigned int i) { m_uiMaxBufferSize = i; }
void SetAnonIPLimit(unsigned int i) { m_uiAnonIPLimit = i; }
void SetServerThrottle(unsigned int i) { m_sConnectThrottle.SetTTL(i*1000); }
@@ -108,8 +103,6 @@ public:
CString GetPemLocation() const { return CDir::ChangeDir("", m_sSSLCertFile); }
const CString& GetConfigFile() const { return m_sConfigFile; }
bool WritePemFile();
const CString& GetISpoofFile() const { return m_sISpoofFile; }
const CString& GetISpoofFormat() const { return m_sISpoofFormat; }
const VCString& GetBindHosts() const { return m_vsBindHosts; }
const vector<CListener*>& GetListeners() const { return m_vpListeners; }
time_t TimeStarted() const { return m_TimeStarted; }
@@ -171,15 +164,11 @@ protected:
CString m_sConfigFile;
CString m_sSkinName;
CString m_sStatusPrefix;
CString m_sISpoofFile;
CString m_sOrigISpoof;
CString m_sISpoofFormat;
CString m_sPidFile;
CString m_sSSLCertFile;
VCString m_vsBindHosts;
VCString m_vsMotd;
CFile m_LockFile;
CFile* m_pISpoofLockFile;
unsigned int m_uiConnectDelay;
unsigned int m_uiAnonIPLimit;
unsigned int m_uiMaxBufferSize;