--- authlib/authmysql.c.orig Mon Jul 16 12:19:16 2001 +++ authlib/authmysql.c Mon Jul 16 12:24:18 2001 @@ -46,17 +46,27 @@ return (0); } - if (authinfo->cryptpw) + if (!strncasecmp(authinfo->pw, "Crypt-Password", 15)) { - if (authcheckpassword(pass,authinfo->cryptpw)) + if (authcheckpassword(pass,authinfo->pw)) { errno=EPERM; return (0); /* User/Password not found. */ } } - else if (authinfo->clearpw) + else if (!strncasecmp(authinfo->pwtype, "Password", 9)) { - if (strcmp(pass, authinfo->clearpw)) + if (strcmp(pass, authinfo->pw)) + { + errno=EPERM; + return (0); + } + } + else if (!strncasecmp(authinfo->pwtype, "MySQL-Password", 15)) + { + char hashed[17]; + make_scrambled_password(&hashed, pass); + if (strncmp(hashed, authinfo->pw, 17)) { errno=EPERM; return (0); --- authlib/authmysql.h.orig Mon Jul 16 12:17:04 2001 +++ authlib/authmysql.h Mon Jul 16 12:17:16 2001 @@ -10,8 +10,8 @@ struct authmysqluserinfo { char *username; - char *cryptpw; - char *clearpw; + char *pw; + char *pwtype; char *home; char *maildir; char *quota; --- authlib/authmysqllib.c.orig Mon Jul 16 12:11:37 2001 +++ authlib/authmysqllib.c Mon Jul 16 12:25:36 2001 @@ -188,7 +188,7 @@ MYSQL_ROW row; MYSQL_RES *result; -const char *crypt_field, *clear_field, *maildir_field, *home_field, +const char *pw_field, *pwtype_field, *maildir_field, *home_field, *login_field, *uid_field, *gid_field, *quota_field, *where_clause; static const char query[]= @@ -198,10 +198,10 @@ if (ui.username) free(ui.username); - if (ui.cryptpw) - free(ui.cryptpw); - if (ui.clearpw) - free(ui.clearpw); + if (ui.pw) + free(ui.pw); + if (ui.pwtype) + free(ui.pwtype); if (ui.home) free(ui.home); if (ui.maildir) @@ -221,18 +221,16 @@ return (0); } - crypt_field=read_env("MYSQL_CRYPT_PWFIELD"); - clear_field=read_env("MYSQL_CLEAR_PWFIELD"); + pw_field=read_env("MYSQL_PWFIELD"); + pwtype_field=read_env("MYSQL_PWTYPEFIELD"); - if (!crypt_field && !clear_field) + if (!pw_field && !pwtype_field) { fprintf(stderr, - "authmysql: MYSQL_CRYPT_PWFIELD and " - "MYSQL_CLEAR_PWFIELD not set in " AUTHMYSQLRC ".\n"); + "authmysql: MYSQL_PWFIELD and " + "MYSQL_PWTYPEFIELD not set in " AUTHMYSQLRC ".\n"); return (0); } - if (!crypt_field) crypt_field="\"\""; - if (!clear_field) clear_field="\"\""; uid_field = read_env("MYSQL_UID_FIELD"); if (!uid_field) uid_field = "uid"; @@ -258,7 +256,7 @@ if (!defdomain) defdomain=""; querybuf=malloc(sizeof(query) + 100 + strlen(user_table) + strlen(defdomain) - + strlen(crypt_field) + strlen(clear_field) + strlen(maildir_field) + + strlen(pw_field) + strlen(pwtype_field) + strlen(maildir_field) + strlen(uid_field) + strlen(gid_field) + 2 * strlen(login_field) + strlen(home_field) + strlen(quota_field) + strlen(where_clause)); if (!querybuf) @@ -267,7 +265,7 @@ return (0); } - sprintf(querybuf, query, login_field, crypt_field, clear_field, + sprintf(querybuf, query, login_field, pw_field, pwtype_field, uid_field, gid_field, home_field, maildir_field, quota_field, user_table, login_field); p=querybuf+strlen(querybuf); @@ -314,14 +312,14 @@ { row = mysql_fetch_row (result); ui.username=strdup(row[0]); - ui.cryptpw=strdup(row[1]); - ui.clearpw=strdup(row[2]); + ui.pw=strdup(row[1]); + ui.pwtype=strdup(row[2]); ui.uid=atol(row[3]); ui.gid=atol(row[4]); ui.home=strdup(row[5]); ui.maildir=strdup(row[6]); ui.quota=strdup(row[7]); - if (!ui.username || !ui.cryptpw || + if (!ui.username || !ui.pw || !ui.pwtype || !ui.home || !ui.maildir || !ui.quota) { @@ -329,17 +327,6 @@ return (0); } - if (!ui.cryptpw[0]) - { - free(ui.cryptpw); - ui.cryptpw=0; - } - - if (!ui.clearpw[0]) - { - free(ui.clearpw); - ui.clearpw=0; - } } mysql_free_result(result); } --- authlib/preauthmysql.c.orig Mon Jul 16 12:24:32 2001 +++ authlib/preauthmysql.c Mon Jul 16 12:25:23 2001 @@ -46,8 +46,9 @@ aa.maildir=authinfo->maildir && authinfo->maildir[0] ? authinfo->maildir:0; aa.address=authinfo->username; - aa.passwd=authinfo->cryptpw; - aa.clearpasswd=authinfo->clearpw; + /* Iain: what do we do with these? */ + aa.passwd=authinfo->pw; + aa.clearpasswd=authinfo->pwtype; aa.quota=authinfo->quota && authinfo->quota[0] ? authinfo->quota:0; return ((*callback)(&aa, arg));