conf.DEFINE('HAVE_ROBUST_MUTEXES', 1)
conf.CHECK_FUNCS_IN('crypt', 'crypt', checklibc=True)
+ conf.CHECK_FUNCS_IN('crypt_r', 'crypt', checklibc=True)
conf.CHECK_VARIABLE('rl_event_hook', define='HAVE_DECL_RL_EVENT_HOOK', always=True,
headers='readline.h readline/readline.h readline/history.h')
const char *salt = NULL; /* Randomly generated salt */
const char *cmd = NULL; /* command passed to crypt */
const char *hash = NULL; /* password hash generated by crypt */
- struct crypt_data crypt_data; /* working storage used by crypt */
int algorithm = 0; /* crypt hash algorithm number */
int rounds = 0; /* The number of hash rounds */
DATA_BLOB *hash_blob = NULL;
TALLOC_CTX *frame = talloc_stackframe();
+#ifdef HAVE_CRYPT_R
+ struct crypt_data crypt_data; /* working storage used by crypt */
+#endif
/* Genrate a random password salt */
salt = generate_random_str_list(frame,
* Relies on the assertion that cleartext_utf8->data is a zero
* terminated UTF-8 string
*/
+#ifdef HAVE_CRYPT_R
hash = crypt_r((char *)io->n.cleartext_utf8->data, cmd, &crypt_data);
+#else
+ /*
+ * No crypt_r falling back to crypt, which is NOT thread safe
+ * Thread safety MT-Unsafe race:crypt
+ */
+ hash = crypt((char *)io->n.cleartext_utf8->data, cmd);
+#endif
if (hash == NULL) {
char buf[1024];
ldb_asprintf_errstring(