diff options
-rwxr-xr-x | configure | 29 | ||||
-rw-r--r-- | sysif.c | 12 |
2 files changed, 39 insertions, 2 deletions
@@ -2619,6 +2619,35 @@ for try_lcrypt in "" "-lcrypt" "no" ; do fi done +printf "Checking for crypt_r ... " + +cat > conftest.c <<! +#include <crypt.h> + +int main(void) +{ + static struct crypt_data cd; + char *c = crypt_r("foo", "bar", &cd); + return 0; +} +! + +for try_lcrypt in "" "-lcrypt" "no" ; do + if [ "$try_lcrypt" = "no" ] ; then + printf "no\n" + break + fi + if conftest EXTRA_LDFLAGS=$try_lcrypt; then + printf "yes\n" + printf "#define HAVE_CRYPT_R 1\n" >> config.h + if [ -n "$try_lcrypt" ] ; then + conf_ldflags="${conf_ldflags:+"$conf_ldflags "}-lcrypt" + fi + break; + fi +done + + printf "Checking for alloca ... " for try_header in stdlib alloca malloc ; do @@ -76,6 +76,9 @@ #if HAVE_DLOPEN #include <dlfcn.h> #endif +#if HAVE_CRYPT_R +#include <crypt.h> +#endif #include "alloca.h" #include "lib.h" #include "stream.h" @@ -1446,7 +1449,7 @@ static val getgrnam_wrap(val wname) #endif -#if HAVE_CRYPT +#if HAVE_CRYPT || HAVE_CRYPT_R static val crypt_wrap(val wkey, val wsalt) { @@ -1454,7 +1457,12 @@ static val crypt_wrap(val wkey, val wsalt) const wchar_t *cwsalt = c_str(wsalt); char *key = utf8_dup_to(cwkey); char *salt = utf8_dup_to(cwsalt); +#if HAVE_CRYPT_R + struct crypt_data cd; + char *hash = (cd.initialized = 0, crypt_r(key, salt, &cd)); +#else char *hash = crypt(key, salt); +#endif val whash = string_utf8(hash); free(key); free(salt); @@ -2137,7 +2145,7 @@ void sysif_init(void) reg_fun(intern(lit("getgrnam"), user_package), func_n1(getgrnam_wrap)); #endif -#if HAVE_CRYPT +#if HAVE_CRYPT || HAVE_CRYPT_R reg_fun(intern(lit("crypt"), user_package), func_n2(crypt_wrap)); #endif |