--- pam_mysql.c.orig Sun Sep 15 10:28:58 2002 +++ pam_mysql.c Thu Feb 13 14:58:21 2003 @@ -23,6 +23,7 @@ #include #include #include +#include /* AFAIK, only FreeBSD has MD5Data() defined in md5.h @@ -54,7 +55,53 @@ #define DEBUG #include +#ifdef _OPENPAM +#include +#else #include +#endif + +#ifdef _OPENPAM +/* some macros not defined in OpenPAM */ + +/* Good policy to strike out passwords with some characters not just + free the memory */ + +#define _pam_overwrite(x) \ +do { \ + register char *__xx__; \ + if ((__xx__=(x))) \ + while (*__xx__) \ + *__xx__++ = '\0'; \ +} while (0) + +/* + * Don't just free it, forget it too. + */ + +#define _pam_drop(X) \ +do { \ + if (X) { \ + free(X); \ + X=NULL; \ + } \ +} while (0) + +#define _pam_drop_reply(/* struct pam_response * */ reply, /* int */ replies) \ +do { \ + int reply_i; \ + \ + for (reply_i=0; reply_iconv(nargs, (const struct pam_message **) message, response, conv->appdata_ptr); - if ((retval != PAM_SUCCESS) && (retval != PAM_CONV_AGAIN)) + if ((retval != PAM_SUCCESS) +#ifndef _OPENPAM + && (retval != PAM_CONV_AGAIN) +#endif + ) syslog(LOG_DEBUG, "pam_mysql: conversation failure [%s]", pam_strerror(pamh, retval)); } else { @@ -827,8 +878,12 @@ if (retval != PAM_SUCCESS) { if (resp != NULL) _pam_drop_reply(resp,i); +#ifndef _OPENPAM return ((retval == PAM_CONV_AGAIN) ? PAM_INCOMPLETE : PAM_AUTHINFO_UNAVAIL); +#else + return PAM_AUTHINFO_UNAVAIL; +#endif } /* we have a password so set AUTHTOK