MXS-1662: Move mxs_crypt into utils

Moved the mxs_crypt function into utils and renamed to mxs::crypt (no C
code used it).
This commit is contained in:
Markus Mäkelä
2018-09-10 15:19:18 +03:00
parent d2f31aab0a
commit 40d73948a9
3 changed files with 26 additions and 17 deletions

View File

@ -421,23 +421,6 @@ bool admin_linux_account_enabled(const char* uname)
return rv;
}
#define MXS_CRYPT_SIZE 60
void mxs_crypt(const char* password, const char* salt, char* output)
{
#if HAVE_GLIBC
struct crypt_data cdata;
cdata.initialized = 0;
char* pw = crypt_r(password, salt, &cdata);
snprintf(output, MXS_CRYPT_SIZE, "%s", pw);
#else
static std::mutex mxs_crypt_lock;
std::lock_guard<std::mutex> guard(mxs_crypt_lock);
char* pw = crypt(password, salt);
snprintf(output, MXS_CRYPT_SIZE, "%s", pw);
#endif
}
/**
* Add insecure remote (network) basic user.
*