mirror of
https://github.com/termux/termux-packages.git
synced 2025-01-06 02:26:34 +00:00
56 lines
1.6 KiB
Diff
56 lines
1.6 KiB
Diff
+++ ./src/svr-authpasswd.c
|
|
@@ -30,28 +30,14 @@
|
|
#include "dbutil.h"
|
|
#include "auth.h"
|
|
#include "runopts.h"
|
|
+#include <termux-auth.h>
|
|
|
|
#if DROPBEAR_SVR_PASSWORD_AUTH
|
|
|
|
-/* not constant time when strings are differing lengths.
|
|
- string content isn't leaked, and crypt hashes are predictable length. */
|
|
-static int constant_time_strcmp(const char* a, const char* b) {
|
|
- size_t la = strlen(a);
|
|
- size_t lb = strlen(b);
|
|
-
|
|
- if (la != lb) {
|
|
- return 1;
|
|
- }
|
|
-
|
|
- return constant_time_memcmp(a, b, la);
|
|
-}
|
|
-
|
|
/* Process a password auth request, sending success or failure messages as
|
|
* appropriate */
|
|
void svr_auth_password(int valid_user) {
|
|
|
|
- char * passwdcrypt = NULL; /* the crypt from /etc/passwd or /etc/shadow */
|
|
- char * testcrypt = NULL; /* crypt generated from the user's password sent */
|
|
char * password = NULL;
|
|
unsigned int passwordlen;
|
|
unsigned int changepw;
|
|
@@ -65,6 +51,7 @@
|
|
}
|
|
|
|
password = buf_getstring(ses.payload, &passwordlen);
|
|
+#if 0
|
|
if (valid_user && passwordlen <= DROPBEAR_MAX_PASSWORD_LEN) {
|
|
/* the first bytes of passwdcrypt are the salt */
|
|
passwdcrypt = ses.authstate.pw_passwd;
|
|
@@ -106,6 +93,15 @@
|
|
}
|
|
|
|
if (constant_time_strcmp(testcrypt, passwdcrypt) == 0) {
|
|
+#else
|
|
+ /* check if password is valid */
|
|
+ if (termux_auth(ses.authstate.pw_name, password)) {
|
|
+ if (!ses.authstate.pw_name) {
|
|
+ dropbear_log(LOG_WARNING, "Login name is NULL");
|
|
+ send_msg_userauth_failure(0, 1);
|
|
+ return;
|
|
+ }
|
|
+#endif
|
|
if (svr_opts.multiauthmethod && (ses.authstate.authtypes & ~AUTH_TYPE_PASSWORD)) {
|
|
/* successful password authentication, but extra auth required */
|
|
dropbear_log(LOG_NOTICE,
|