aboutsummaryrefslogtreecommitdiff
path: root/libshouldbeinlibc
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2019-09-01 17:25:49 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2019-09-01 18:04:32 +0200
commit670a1ff8f97962efd6b27436b50fc51b62683c25 (patch)
tree11139ff0e3aa9eb48bc9af2aa48afaa05ad03b0b /libshouldbeinlibc
parent1186cf1d97d62105aa0f63cd3fce49f124e4e4c4 (diff)
downloadhurd-670a1ff8f97962efd6b27436b50fc51b62683c25.tar.gz
hurd-670a1ff8f97962efd6b27436b50fc51b62683c25.tar.bz2
hurd-670a1ff8f97962efd6b27436b50fc51b62683c25.zip
Fix password checking with as-needed linking
Newer gcc toolchains tend to enable as-needed by default, so runtime detection of libcrypt will fail. We can just explicitly link against libcrypt anyway. * configure.ac: Check for `crypt()' in libcrypt. * config.make.in: Substitute HAVE_LIBCRYPT. * libshouldbeinlibc/idvec-verify.c: Include <crypt.h> only when libcrypt is available. Replace weak reference with explicit call and fallback macro. * utils/x.c: Likewise. * libshouldbeinlibc/Makefile (LDLIBS): Add -lcrypt when libcrypt is available.
Diffstat (limited to 'libshouldbeinlibc')
-rw-r--r--libshouldbeinlibc/Makefile2
-rw-r--r--libshouldbeinlibc/idvec-verify.c15
2 files changed, 9 insertions, 8 deletions
diff --git a/libshouldbeinlibc/Makefile b/libshouldbeinlibc/Makefile
index 04c085bb..2edf15f4 100644
--- a/libshouldbeinlibc/Makefile
+++ b/libshouldbeinlibc/Makefile
@@ -38,6 +38,8 @@ installhdrs = idvec.h timefmt.h maptime.h \
installhdrsubdir = .
+LDLIBS += $(and $(HAVE_LIBCRYPT),-lcrypt)
+
OBJS = $(SRCS:.c=.o)
include ../Makeconf
diff --git a/libshouldbeinlibc/idvec-verify.c b/libshouldbeinlibc/idvec-verify.c
index a7d95761..1c4bc494 100644
--- a/libshouldbeinlibc/idvec-verify.c
+++ b/libshouldbeinlibc/idvec-verify.c
@@ -27,12 +27,15 @@
#include <grp.h>
#include <pwd.h>
#include <shadow.h>
+#ifdef HAVE_LIBCRYPT
#include <crypt.h>
+#else
+#warning "No crypt on this system! Using plain-text passwords."
+#define crypt(password, encrypted) password
+#endif
#define SHADOW_PASSWORD_STRING "x" /* pw_passwd contents for shadow passwd */
-#pragma weak crypt
-
static error_t verify_id (); /* FWD */
/* Get a password from the user, returning it in malloced storage. */
@@ -71,12 +74,8 @@ verify_passwd (const char *password,
if (sys_encrypted[0] == '\0')
return 0; /* No password. */
- if (crypt)
- /* Encrypt the password entered by the user (SYS_ENCRYPTED is the salt). */
- encrypted = crypt (password, sys_encrypted);
- else
- /* No crypt on this system! Use plain-text passwords. */
- encrypted = password;
+ /* Encrypt the password entered by the user (SYS_ENCRYPTED is the salt). */
+ encrypted = crypt (password, sys_encrypted);
if (! encrypted)
/* Crypt failed. */