mirror of
https://github.com/znc/znc.git
synced 2026-05-06 05:22:26 +02:00
Fix logging in with PASS after USER
First, we set m_sUser to the argument of USER. Later, when the PASS came in, the
username which was specified here (user/network:pass) was ignored, because
m_sUser was already set ("if (m_sUser.empty() &&" in ParseAuthLine).
The fix is to ignore if m_sUser was already set when parsing "PASS". Since this
means that the handling of PASS and USER becomes even more different, this
commit removes CClient::ParseAuthLine() again.
(The check for m_sUser.empty() can't just be dropped, because if USER comes in
after PASS, we should use the user name from PASS and ignore the USER one)
Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
44
Client.cpp
44
Client.cpp
@@ -69,25 +69,6 @@ CClient::~CClient() {
|
||||
}
|
||||
}
|
||||
|
||||
void CClient::ParseAuthLine(CString sLine, bool bPassword) {
|
||||
// bPassword ? [user[/network]:]password : user[/network]
|
||||
|
||||
if (bPassword) {
|
||||
if (sLine.find(":") == CString::npos) {
|
||||
m_sPass = sLine;
|
||||
sLine = "";
|
||||
} else {
|
||||
m_sPass = sLine.Token(1, true, ":");
|
||||
sLine = sLine.Token(0, false, ":");
|
||||
}
|
||||
}
|
||||
|
||||
if (m_sUser.empty() && !sLine.empty()) {
|
||||
m_sUser = sLine.Token(0, false, "/");
|
||||
m_sNetwork = sLine.Token(1, true, "/");
|
||||
}
|
||||
}
|
||||
|
||||
void CClient::ReadLine(const CString& sData) {
|
||||
CString sLine = sData;
|
||||
|
||||
@@ -118,7 +99,20 @@ void CClient::ReadLine(const CString& sData) {
|
||||
sAuthLine.LeftChomp();
|
||||
}
|
||||
|
||||
ParseAuthLine(sAuthLine, true);
|
||||
// [user[/network]:]password
|
||||
if (sAuthLine.find(":") == CString::npos) {
|
||||
m_sPass = sAuthLine;
|
||||
sAuthLine = "";
|
||||
} else {
|
||||
m_sPass = sAuthLine.Token(1, true, ":");
|
||||
sAuthLine = sAuthLine.Token(0, false, ":");
|
||||
}
|
||||
|
||||
if (!sAuthLine.empty()) {
|
||||
m_sUser = sAuthLine.Token(0, false, "/");
|
||||
m_sNetwork = sAuthLine.Token(1, true, "/");
|
||||
}
|
||||
|
||||
AuthUser();
|
||||
return; // Don't forward this msg. ZNC has already registered us.
|
||||
}
|
||||
@@ -137,9 +131,15 @@ void CClient::ReadLine(const CString& sData) {
|
||||
}
|
||||
} else if (sCommand.Equals("USER")) {
|
||||
if (!IsAttached()) {
|
||||
ParseAuthLine(sLine.Token(1));
|
||||
m_bGotUser = true;
|
||||
// user[/network]
|
||||
CString sAuthLine = sLine.Token(1);
|
||||
|
||||
if (m_sUser.empty() && !sAuthLine.empty()) {
|
||||
m_sUser = sAuthLine.Token(0, false, "/");
|
||||
m_sNetwork = sAuthLine.Token(1, true, "/");
|
||||
}
|
||||
|
||||
m_bGotUser = true;
|
||||
if (m_bGotPass) {
|
||||
AuthUser();
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user