--- auth.c.orig	Thu Feb 17 16:41:59 2000
+++ auth.c	Thu Feb 17 16:55:19 2000
@@ -20,6 +20,10 @@
 #include	<errno.h>
 #include	<sys/wait.h>
 
+#ifdef USEMYSQL
+#include	<mysql/mysql.h>
+#endif
+
 #if !defined(NOSHADOW)
 #include	<shadow.h>
 #endif /* !NOSHADOW */
@@ -261,6 +265,9 @@
 	int		strip_username;
 	int		result;
 	char		*ptr;
+#ifdef USEMYSQL
+	char scramble[16];
+#endif
 	/*
 	 *	cjd 19980706 --
 	 *	pampair contains the pair of PAM_AUTH_ATTR
@@ -316,6 +323,8 @@
 	 */
 	if ((password_pair = pairfind(check_item, PW_CRYPT_PASSWORD)) != NULL)
 		auth_type = PW_AUTHTYPE_CRYPT;
+	else if ((password_pair = pairfind(check_item, PW_MYSQL_PASSWORD)) != NULL)
+		auth_type = PW_AUTHTYPE_MYSQLHASH;
 	else
 		password_pair = pairfind(check_item, PW_PASSWORD);
 
@@ -408,6 +417,16 @@
 			}
 			if (strcmp(password_pair->strvalue,
 			    crypt(string, password_pair->strvalue)) != 0)
+					result = -1;
+			break;
+		case PW_AUTHTYPE_MYSQLHASH:
+			DEBUG2("  auth: MySQL");
+			if (password_pair == NULL) {
+				result = string[0] ? -1 : 0;
+				break;
+			}
+			make_scrambled_password(scramble, string);
+			if (strcmp(password_pair->strvalue, scramble) != 0)
 					result = -1;
 			break;
 		case PW_AUTHTYPE_LOCAL:
--- files.c.orig	Thu Feb 17 16:42:48 2000
+++ files.c	Thu Feb 17 16:47:41 2000
@@ -131,6 +131,9 @@
 #ifdef PAM
 		    i->attribute == PAM_AUTH_ATTR ||
 #endif
+#ifdef USEMYSQL
+		    i->attribute == PW_MYSQL_PASSWORD ||
+#endif
 		    i->attribute == PW_CRYPT_PASSWORD)
 			has_password = 1;
 		tailto = i;
@@ -451,6 +454,7 @@
 			case PW_LOGIN_TIME:
 			case PW_PASSWORD:
 			case PW_CRYPT_PASSWORD:
+			case PW_MYSQL_PASSWORD:
 			case PW_AUTHTYPE:
 #ifdef PAM /* cjd 19980706 */
                         case PAM_AUTH_ATTR:
@@ -763,6 +767,10 @@
 		if (vp->attribute == PW_CRYPT_PASSWORD) {
 			c = vp;
 			n = PW_AUTHTYPE_CRYPT;
+		}
+		if (vp->attribute == PW_MYSQL_PASSWORD) {
+			c = vp;
+			n = PW_AUTHTYPE_MYSQLHASH;
 		}
 	}
 
--- radius.h.orig	Thu Feb 17 16:42:36 2000
+++ radius.h	Thu Feb 17 16:44:49 2000
@@ -140,6 +140,7 @@
 #define PW_LOGIN_TIME			1042
 #define PW_RADIUS_OPERATOR		2000
 #define PW_MAX_HOURS			2001
+#define PW_MYSQL_PASSWORD		2002
 
 /*
  *	INTEGER TRANSLATIONS
@@ -182,6 +183,7 @@
 #define PW_AUTHTYPE_SECURID		2
 #define PW_AUTHTYPE_CRYPT		3
 #define PW_AUTHTYPE_REJECT		4
+#define PW_AUTHTYPE_MYSQLHASH		251
 #define PW_AUTHTYPE_MYSQL		252
 #define PW_AUTHTYPE_PAM			253
 #define PW_AUTHTYPE_ACCEPT		254
--- auth.c.orig	Thu Feb 17 16:41:59 2000
+++ auth.c	Thu Feb 17 16:55:19 2000
@@ -20,6 +20,10 @@
 #include	<errno.h>
 #include	<sys/wait.h>
 
+#ifdef USEMYSQL
+#include	<mysql/mysql.h>
+#endif
+
 #if !defined(NOSHADOW)
 #include	<shadow.h>
 #endif /* !NOSHADOW */
@@ -261,6 +265,9 @@
 	int		strip_username;
 	int		result;
 	char		*ptr;
+#ifdef USEMYSQL
+	char scramble[16];
+#endif
 	/*
 	 *	cjd 19980706 --
 	 *	pampair contains the pair of PAM_AUTH_ATTR
@@ -316,6 +323,8 @@
 	 */
 	if ((password_pair = pairfind(check_item, PW_CRYPT_PASSWORD)) != NULL)
 		auth_type = PW_AUTHTYPE_CRYPT;
+	else if ((password_pair = pairfind(check_item, PW_MYSQL_PASSWORD)) != NULL)
+		auth_type = PW_AUTHTYPE_MYSQLHASH;
 	else
 		password_pair = pairfind(check_item, PW_PASSWORD);
 
@@ -408,6 +417,16 @@
 			}
 			if (strcmp(password_pair->strvalue,
 			    crypt(string, password_pair->strvalue)) != 0)
+					result = -1;
+			break;
+		case PW_AUTHTYPE_MYSQLHASH:
+			DEBUG2("  auth: MySQL");
+			if (password_pair == NULL) {
+				result = string[0] ? -1 : 0;
+				break;
+			}
+			make_scrambled_password(scramble, string);
+			if (strcmp(password_pair->strvalue, scramble) != 0)
 					result = -1;
 			break;
 		case PW_AUTHTYPE_LOCAL:
--- files.c.orig	Thu Feb 17 16:42:48 2000
+++ files.c	Thu Feb 17 16:47:41 2000
@@ -131,6 +131,9 @@
 #ifdef PAM
 		    i->attribute == PAM_AUTH_ATTR ||
 #endif
+#ifdef USEMYSQL
+		    i->attribute == PW_MYSQL_PASSWORD ||
+#endif
 		    i->attribute == PW_CRYPT_PASSWORD)
 			has_password = 1;
 		tailto = i;
@@ -451,6 +454,7 @@
 			case PW_LOGIN_TIME:
 			case PW_PASSWORD:
 			case PW_CRYPT_PASSWORD:
+			case PW_MYSQL_PASSWORD:
 			case PW_AUTHTYPE:
 #ifdef PAM /* cjd 19980706 */
                         case PAM_AUTH_ATTR:
@@ -763,6 +767,10 @@
 		if (vp->attribute == PW_CRYPT_PASSWORD) {
 			c = vp;
 			n = PW_AUTHTYPE_CRYPT;
+		}
+		if (vp->attribute == PW_MYSQL_PASSWORD) {
+			c = vp;
+			n = PW_AUTHTYPE_MYSQLHASH;
 		}
 	}
 
--- radius.h.orig	Thu Feb 17 16:42:36 2000
+++ radius.h	Thu Feb 17 17:03:41 2000
@@ -130,6 +130,7 @@
 #define PW_SUFFIX			1004
 #define PW_GROUP			1005
 #define PW_CRYPT_PASSWORD		1006
+#define PW_MYSQL_PASSWORD		2004
 #define PW_CONNECT_RATE			1007
 #define PW_USER_CATEGORY		1029
 #define PW_GROUP_NAME			1030
@@ -182,6 +183,7 @@
 #define PW_AUTHTYPE_SECURID		2
 #define PW_AUTHTYPE_CRYPT		3
 #define PW_AUTHTYPE_REJECT		4
+#define PW_AUTHTYPE_MYSQLHASH		251
 #define PW_AUTHTYPE_MYSQL		252
 #define PW_AUTHTYPE_PAM			253
 #define PW_AUTHTYPE_ACCEPT		254
