Add supports for salted hashes to znc.conf

These changes the format of the 'Pass' config option. The old format is
still accepted. The new format is:

  Pass = plain#<plain text password>
  Pass = md5#<password hash>
  Pass = md5#<hash of password with salt appended>#<salt>#

This also makes ZNC only write configs in the new format.

znc --makeconf and znc --makepass now always generate salted hashes.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1127 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
psychon
2008-07-13 15:32:27 +00:00
parent ac2caa0f22
commit bf2bd39769
6 changed files with 87 additions and 9 deletions
+17 -3
View File
@@ -565,7 +565,15 @@ bool CUser::PrintLine(CFile& File, const CString& sName, const CString& sValue)
bool CUser::WriteConfig(CFile& File) {
File.Write("<User " + GetUserName() + ">\n");
PrintLine(File, "Pass", GetPass() + ((IsPassHashed()) ? " -" : ""));
if (IsPassHashed()) {
if (m_sPassSalt.empty()) {
PrintLine(File, "Pass", "md5#" + GetPass());
} else {
PrintLine(File, "Pass", "md5#" + GetPass() + "#" + m_sPassSalt + "#");
}
} else {
PrintLine(File, "Pass", "plain#" + GetPass());
}
PrintLine(File, "Nick", GetNick());
PrintLine(File, "AltNick", GetAltNick());
PrintLine(File, "Ident", GetIdent());
@@ -808,7 +816,9 @@ bool CUser::CheckPass(const CString& sPass) {
return (sPass == m_sPass);
}
return (m_sPass.CaseCmp(sPass.MD5()) == 0);
CString sSaltedPass = sPass + m_sPassSalt;
return (m_sPass.CaseCmp(sSaltedPass.MD5()) == 0);
}
/*CClient* CUser::GetClient() {
@@ -1023,7 +1033,11 @@ void CUser::SetAltNick(const CString& s) { m_sAltNick = s; }
void CUser::SetIdent(const CString& s) { m_sIdent = s; }
void CUser::SetRealName(const CString& s) { m_sRealName = s; }
void CUser::SetVHost(const CString& s) { m_sVHost = s; }
void CUser::SetPass(const CString& s, bool bHashed) { m_sPass = s; m_bPassHashed = bHashed; }
void CUser::SetPass(const CString& s, bool bHashed, const CString& sSalt) {
m_sPass = s;
m_bPassHashed = bHashed;
m_sPassSalt = sSalt;
}
void CUser::SetMultiClients(bool b) { m_bMultiClients = b; }
void CUser::SetBounceDCCs(bool b) { m_bBounceDCCs = b; }
void CUser::SetUseClientIP(bool b) { m_bUseClientIP = b; }