[nginx] Core: fix build without libcrypt.

noreply at nginx.com noreply at nginx.com
Tue Feb 18 13:19:02 UTC 2025


details:   https://github.com/nginx/nginx/commit/9a4090f02ab438c47178b3b5a4c15a3c769d5027
branches:  master
commit:    9a4090f02ab438c47178b3b5a4c15a3c769d5027
user:      Piotr Sikora <piotr at aviatrix.com>
date:      Wed, 12 Feb 2025 10:40:58 +0200
description:
Core: fix build without libcrypt.

libcrypt is no longer part of glibc, so it might not be available.

Signed-off-by: Piotr Sikora <piotr at aviatrix.com>

---
 auto/unix                      |  4 ++--
 src/os/unix/ngx_linux_config.h |  6 +++++-
 src/os/unix/ngx_user.c         | 10 +++++++++-
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/auto/unix b/auto/unix
index f29e69c61..8bd1b1370 100644
--- a/auto/unix
+++ b/auto/unix
@@ -150,7 +150,7 @@ fi
 
 
 ngx_feature="crypt()"
-ngx_feature_name=
+ngx_feature_name="NGX_HAVE_CRYPT"
 ngx_feature_run=no
 ngx_feature_incs=
 ngx_feature_path=
@@ -162,7 +162,7 @@ ngx_feature_test="crypt(\"test\", \"salt\");"
 if [ $ngx_found = no ]; then
 
     ngx_feature="crypt() in libcrypt"
-    ngx_feature_name=
+    ngx_feature_name="NGX_HAVE_CRYPT"
     ngx_feature_run=no
     ngx_feature_incs=
     ngx_feature_path=
diff --git a/src/os/unix/ngx_linux_config.h b/src/os/unix/ngx_linux_config.h
index 88fef47ce..d99358c93 100644
--- a/src/os/unix/ngx_linux_config.h
+++ b/src/os/unix/ngx_linux_config.h
@@ -52,7 +52,6 @@
 #include <malloc.h>             /* memalign() */
 #include <limits.h>             /* IOV_MAX */
 #include <sys/ioctl.h>
-#include <crypt.h>
 #include <sys/utsname.h>        /* uname() */
 
 #include <dlfcn.h>
@@ -61,6 +60,11 @@
 #include <ngx_auto_config.h>
 
 
+#if (NGX_HAVE_CRYPT_H)
+#include <crypt.h>
+#endif
+
+
 #if (NGX_HAVE_POSIX_SEM)
 #include <semaphore.h>
 #endif
diff --git a/src/os/unix/ngx_user.c b/src/os/unix/ngx_user.c
index b3d81d07b..8c769ed93 100644
--- a/src/os/unix/ngx_user.c
+++ b/src/os/unix/ngx_user.c
@@ -41,7 +41,7 @@ ngx_libc_crypt(ngx_pool_t *pool, u_char *key, u_char *salt, u_char **encrypted)
     return NGX_ERROR;
 }
 
-#else
+#elif (NGX_HAVE_CRYPT)
 
 ngx_int_t
 ngx_libc_crypt(ngx_pool_t *pool, u_char *key, u_char *salt, u_char **encrypted)
@@ -71,6 +71,14 @@ ngx_libc_crypt(ngx_pool_t *pool, u_char *key, u_char *salt, u_char **encrypted)
     return NGX_ERROR;
 }
 
+#else
+
+ngx_int_t
+ngx_libc_crypt(ngx_pool_t *pool, u_char *key, u_char *salt, u_char **encrypted)
+{
+    return NGX_ERROR;
+}
+
 #endif
 
 #endif /* NGX_CRYPT */


More information about the nginx-devel mailing list