mirror of
https://github.com/znc/znc.git
synced 2026-08-07 09:22:55 +02:00
Make webadmin generate salted passwords, too
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1139 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
@@ -189,8 +189,9 @@ CString CUtils::GetHashPass() {
|
||||
return "";
|
||||
}
|
||||
|
||||
CString CUtils::GetSaltedHashPass(CString& sSalt, unsigned int uiSaltLength) {
|
||||
sSalt = CString::RandomString(uiSaltLength);
|
||||
CString CUtils::GetSaltedHashPass(CString& sSalt) {
|
||||
sSalt = GetSalt();
|
||||
unsigned int uiSaltLength = sSalt.length();
|
||||
const char *pSalt = sSalt.c_str();
|
||||
|
||||
while (true) {
|
||||
@@ -232,6 +233,10 @@ CString CUtils::GetSaltedHashPass(CString& sSalt, unsigned int uiSaltLength) {
|
||||
return "";
|
||||
}
|
||||
|
||||
CString CUtils::GetSalt() {
|
||||
return CString::RandomString(20);
|
||||
}
|
||||
|
||||
char* CUtils::GetPass(const CString& sPrompt) {
|
||||
PrintPrompt(sPrompt);
|
||||
return getpass("");
|
||||
|
||||
@@ -52,7 +52,8 @@ public:
|
||||
static void PrintAction(const CString& sMessage);
|
||||
static void PrintStatus(bool bSuccess, const CString& sMessage = "");
|
||||
static CString GetHashPass();
|
||||
static CString GetSaltedHashPass(CString& sSalt, unsigned int uiSaltLength = 20);
|
||||
static CString GetSaltedHashPass(CString& sSalt);
|
||||
static CString GetSalt();
|
||||
static char* GetPass(const CString& sPrompt);
|
||||
static bool GetInput(const CString& sPrompt, CString& sRet, const CString& sDefault = "", const CString& sHint = "");
|
||||
static bool GetBoolInput(const CString& sPrompt, bool bDefault);
|
||||
|
||||
@@ -1023,7 +1023,9 @@ CUser* CWebAdminSock::GetNewUser(CString& sPageRet, CUser* pUser) {
|
||||
}
|
||||
|
||||
if (!sArg.empty()) {
|
||||
pNewUser->SetPass(sArg.MD5(), true);
|
||||
CString sSalt = CUtils::GetSalt();
|
||||
CString sSaltedPass = sArg + sSalt;
|
||||
pNewUser->SetPass(sSaltedPass.MD5(), true, sSalt);
|
||||
}
|
||||
|
||||
VCString vsArgs;
|
||||
|
||||
Reference in New Issue
Block a user