AC_CHECK_LIB(crypt, crypt, [LUTIL_LIBS="$LUTIL_LIBS -lcrypt"
have_crypt=yes], [have_crypt=no])])
+ LIBS="$TLS_LIBS $LIBS"
+ AC_CHECK_LIB(crypt, crypt_r, [have_crypt_r=yes], [have_crypt_r=no])
+
LIBS="$save_LIBS"
if test $have_crypt = yes ; then
AC_DEFINE(HAVE_CRYPT,1, [define if crypt(3) is available])
+ if test $have_crypt_r = yes ; then
+ AC_DEFINE(HAVE_CRYPT_R, 1, [define if crypt_r() is also available])
+ fi
else
AC_MSG_WARN([could not find crypt])
if test $ol_enable_crypt = yes ; then
/* define if crypt(3) is available */
#undef HAVE_CRYPT
+/* define if crypt_r(3) is available */
+#undef HAVE_CRYPT_R
+
/* Define to 1 if you have the <crypt.h> header file. */
#undef HAVE_CRYPT_H
#include <ac/unistd.h>
#ifdef SLAPD_CRYPT
+#ifdef HAVE_CRYPT_R
+#define __USE_GNU
+#endif /* HAVE_CRYPT_R */
#include <ac/crypt.h>
-#endif
+#endif /* SLAPD_CRYPT */
#include "slap.h"
static ldap_pvt_thread_mutex_t passwd_mutex;
static lutil_cryptfunc slapd_crypt;
+#ifdef HAVE_CRYPT_R
+static int slapd_crypt( const char *key, const char *salt, char **hash )
+{
+ char *cr;
+ int rc;
+ struct crypt_data data;
+
+ data.initialized = 0;
+ cr = crypt_r( key, salt, &data );
+ if ( cr == NULL || cr[0] == '\0' ) {
+ /* salt must have been invalid */
+ rc = LUTIL_PASSWD_ERR;
+ } else {
+ if ( hash ) {
+ *hash = ber_strdup( cr );
+ rc = LUTIL_PASSWD_OK;
+ } else {
+ rc = strcmp( salt, cr ) ? LUTIL_PASSWD_ERR : LUTIL_PASSWD_OK;
+ }
+ }
+
+ return rc;
+}
+#else
static int slapd_crypt( const char *key, const char *salt, char **hash )
{
char *cr;
ldap_pvt_thread_mutex_unlock( &passwd_mutex );
return rc;
}
+#endif /* HAVE_CRYPT_R */
+
#endif /* SLAPD_CRYPT */
void slap_passwd_init()