Fix password code to deal with new quoting code.
This commit is contained in:
parent
39e77dd365
commit
6cdba03d38
|
@ -9,7 +9,7 @@
|
||||||
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $Header: /cvsroot/pgsql/src/backend/libpq/crypt.c,v 1.45 2002/04/04 04:25:47 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/libpq/crypt.c,v 1.46 2002/04/25 00:56:36 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -31,18 +31,26 @@
|
||||||
int
|
int
|
||||||
md5_crypt_verify(const Port *port, const char *user, const char *pgpass)
|
md5_crypt_verify(const Port *port, const char *user, const char *pgpass)
|
||||||
{
|
{
|
||||||
char *passwd,
|
char *passwd = NULL,
|
||||||
*valuntil,
|
*valuntil = NULL,
|
||||||
*crypt_pwd;
|
*crypt_pwd;
|
||||||
int retval = STATUS_ERROR;
|
int retval = STATUS_ERROR;
|
||||||
List **line;
|
List **line;
|
||||||
|
List *token;
|
||||||
|
|
||||||
if ((line = get_user_line(user)) == NULL)
|
if ((line = get_user_line(user)) == NULL)
|
||||||
return STATUS_ERROR;
|
return STATUS_ERROR;
|
||||||
|
|
||||||
passwd = lfirst(lnext(lnext(*line)));
|
/* Skip over line number and username */
|
||||||
valuntil = lfirst(lnext(lnext(lnext(*line))));
|
token = lnext(lnext(*line));
|
||||||
|
if (token)
|
||||||
|
{
|
||||||
|
passwd = lfirst(token);
|
||||||
|
token = lnext(token);
|
||||||
|
if (token)
|
||||||
|
valuntil = lfirst(token);
|
||||||
|
}
|
||||||
|
|
||||||
if (passwd == NULL || *passwd == '\0')
|
if (passwd == NULL || *passwd == '\0')
|
||||||
{
|
{
|
||||||
if (passwd)
|
if (passwd)
|
||||||
|
@ -120,7 +128,7 @@ md5_crypt_verify(const Port *port, const char *user, const char *pgpass)
|
||||||
AbsoluteTime vuntil,
|
AbsoluteTime vuntil,
|
||||||
current;
|
current;
|
||||||
|
|
||||||
if (!valuntil || strcmp(valuntil, "\\N") == 0)
|
if (!valuntil)
|
||||||
vuntil = INVALID_ABSTIME;
|
vuntil = INVALID_ABSTIME;
|
||||||
else
|
else
|
||||||
vuntil = DatumGetAbsoluteTime(DirectFunctionCall1(nabstimein,
|
vuntil = DatumGetAbsoluteTime(DirectFunctionCall1(nabstimein,
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.81 2002/04/04 04:25:47 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.82 2002/04/25 00:56:36 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -109,9 +109,6 @@ next_token(FILE *fp, char *buf, const int bufsz)
|
||||||
while (c != EOF && c != '\n' &&
|
while (c != EOF && c != '\n' &&
|
||||||
(!isblank(c) || in_quote == true))
|
(!isblank(c) || in_quote == true))
|
||||||
{
|
{
|
||||||
if (c == '"')
|
|
||||||
in_quote = !in_quote;
|
|
||||||
|
|
||||||
/* skip comments to EOL */
|
/* skip comments to EOL */
|
||||||
if (c == '#' && !in_quote)
|
if (c == '#' && !in_quote)
|
||||||
{
|
{
|
||||||
|
@ -138,11 +135,14 @@ next_token(FILE *fp, char *buf, const int bufsz)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Literal double-quote is two double-quotes */
|
/* Literal double-quote is two double-quotes */
|
||||||
if (c == '"')
|
if (in_quote && c == '"')
|
||||||
was_quote = !was_quote;
|
was_quote = !was_quote;
|
||||||
else
|
else
|
||||||
was_quote = false;
|
was_quote = false;
|
||||||
|
|
||||||
|
if (c == '"')
|
||||||
|
in_quote = !in_quote;
|
||||||
|
|
||||||
c = getc(fp);
|
c = getc(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue