mirror of
git://git.gnu.org.ua/pam-modules.git
synced 2025-04-28 17:39:52 +03:00
* 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:
parent
80aafa9dcf
commit
06aaf68ec3
5 changed files with 51 additions and 19 deletions
|
@ -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
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue