diff svr-authpasswd.c @ 306:5d5bbca82aba ucc-axis-hack

Use password file, add serial option
author Matt Johnston <matt@ucc.asn.au>
date Sat, 25 Mar 2006 17:12:50 +0000
parents 740e782679be
children
line wrap: on
line diff
--- a/svr-authpasswd.c	Sat Mar 25 17:10:27 2006 +0000
+++ b/svr-authpasswd.c	Sat Mar 25 17:12:50 2006 +0000
@@ -46,6 +46,10 @@
 
 	unsigned int changepw;
 
+    buffer * pw_buf;
+    char * newline = NULL;
+    unsigned int match = 0;
+
 #if 0
 	passwdcrypt = ses.authstate.pw->pw_passwd;
 #ifdef HAVE_SHADOW_H
@@ -89,7 +93,32 @@
 	testcrypt = crypt((char*)password, passwdcrypt);
 #endif
 
-	if (strcmp(password, "fishfish") == 0) {
+    pw_buf = buf_new(100);
+    if (buf_readfile(pw_buf, RAW_PASSWORD_FILE) != DROPBEAR_SUCCESS) {
+        dropbear_exit("Failed to read %s", RAW_PASSWORD_FILE);
+    }
+
+    /* Blah, only one line. */
+    buf_putbyte(pw_buf, '\0');
+    newline = strchr(pw_buf->data, '\n');
+    if (newline) {
+        *newline = '\0';
+    }
+    
+
+    if (strcmp(password, pw_buf->data) == 0) {
+        match = 1;
+    } else {
+        match = 0;
+    }
+
+	m_burn(password, passwordlen);
+	m_free(password);
+    buf_burn(pw_buf);
+    buf_free(pw_buf);
+    pw_buf = NULL;
+    
+    if (match) {
 		/* successful authentication */
 		dropbear_log(LOG_NOTICE, 
 				"password auth succeeded for '%s' from %s",
@@ -103,9 +132,6 @@
 				svr_ses.addrstring);
 		send_msg_userauth_failure(0, 1);
 	}
-	m_burn(password, passwordlen);
-	m_free(password);
-
 }
 
 #endif