From: openKylin Developers <packaging@lists.openkylin.top>
Date: Tue, 30 Apr 2024 15:49:33 +0800
Subject: no_crypt_hack

The udeb package does not have crypt(3).
This patch makes authentication always fail, since it is not needed anyway
for dialout.
---
 pppd/Makefile.linux | 4 ++++
 pppd/auth.c         | 2 ++
 pppd/session.c      | 2 ++
 3 files changed, 8 insertions(+)

diff --git a/pppd/Makefile.linux b/pppd/Makefile.linux
index 22837c5..e517d5d 100644
--- a/pppd/Makefile.linux
+++ b/pppd/Makefile.linux
@@ -143,10 +143,14 @@ CFLAGS   += -DHAS_SHADOW
 #LIBS     += -lshadow $(LIBS)
 endif
 
+ifdef NO_CRYPT_HACK
+CFLAGS += -DNO_CRYPT_HACK
+else
 ifeq ($(shell echo '\#include <crypt.h>' | $(CC) -E - >/dev/null 2>&1 && echo yes),yes)
 CFLAGS  += -DHAVE_CRYPT_H=1
 LIBS	+= -lcrypt
 endif
+endif
 
 ifdef USE_LIBUTIL
 CFLAGS	+= -DHAVE_LOGWTMP=1
diff --git a/pppd/auth.c b/pppd/auth.c
index b1271c4..4fb404e 100644
--- a/pppd/auth.c
+++ b/pppd/auth.c
@@ -1509,8 +1509,10 @@ check_passwd(int unit,
 	    if (secret[0] != 0 && !login_secret) {
 		/* password given in pap-secrets - must match */
 		if (cryptpap || strcmp(passwd, secret) != 0) {
+#ifndef NO_CRYPT_HACK
 		    char *cbuf = crypt(passwd, secret);
 		    if (!cbuf || strcmp(cbuf, secret) != 0)
+#endif
 			ret = UPAP_AUTHNAK;
 		}
 	    }
diff --git a/pppd/session.c b/pppd/session.c
index 2f1c83e..57c42d5 100644
--- a/pppd/session.c
+++ b/pppd/session.c
@@ -343,8 +343,10 @@ session_start(const int flags, const char *user, const char *passwd, const char
 	 */
         if (pw->pw_passwd == NULL || strlen(pw->pw_passwd) < 2)
             return SESSION_FAILED;
+#ifndef NO_CRYPT_HACK
 	cbuf = crypt(passwd, pw->pw_passwd);
 	if (!cbuf || strcmp(cbuf, pw->pw_passwd) != 0)
+#endif
             return SESSION_FAILED;
     }
 
