* configure.ac: Check for pam libraries and header files.

* pam_sql/pam_mysql.c (mysql_setenv): Protect by #ifdef
HAVE_PAM_MISC_SETENV.  Prevent coredumps on NULL values.
* pam_sql/pam_pgsql.c (pgsql_setenv): Likewise.
* pam_sql/Makefile.am (pam_mysql_la_LDADD,pam_pgsql_la_LDADD): Add
@PAM_MISC@.
* pam_sql/pam_sql.c (read_config): Read lines of arbitrary length.




git-svn-id: file:///svnroot/pam-modules/trunk@90 56984be4-0537-0410-a56c-fcb268c96130
This commit is contained in:
Sergey Poznyakoff 2008-03-19 09:50:00 +00:00
parent 80aafa9dcf
commit 06aaf68ec3
5 changed files with 51 additions and 19 deletions

View file

@ -60,6 +60,7 @@ pgsql_do_query(PGconn **ppgconn, PGresult **pres, const char *query)
static int
pgsql_setenv(pam_handle_t *pamh, PGconn *pgconn, const char *query)
{
#ifdef HAVE_PAM_MISC_SETENV
int rc;
PGresult *res;
@ -71,20 +72,26 @@ pgsql_setenv(pam_handle_t *pamh, PGconn *pgconn, const char *query)
} else if (PQresultStatus(res) != PGRES_TUPLES_OK) {
_pam_log(LOG_ERR, "PQexec: query did not return tuples");
rc = PAM_SERVICE_ERR;
} else {
} else if (PQntuples(res) > 0) {
char *p;
int i, nf;
nf = PQnfields(res);
for (i = 0; i < nf; i++) {
p = PQgetvalue(res, 0, i);
chop(p);
pam_misc_setenv(pamh, PQfname(res, i), p, 0);
if (p) {
chop(p);
pam_misc_setenv(pamh, PQfname(res, i), p, 0);
}
}
rc = PAM_SUCCESS;
}
PQclear(res);
return rc;
#else
_pam_log(LOG_ERR, "MySQL: PAM setenv is not available.");
return PAM_SERVICE_ERR;
#endif
}