mirror of
https://github.com/postgres/postgres.git
synced 2025-11-19 13:42:17 +03:00
Fix dblink_connect() so that it verifies that a password is supplied in the
conninfo string *before* trying to connect to the remote server, not after. As pointed out by Marko Kreen, in certain not-very-plausible situations this could result in sending a password from the postgres user's .pgpass file, or other places that non-superusers shouldn't have access to, to an untrustworthy remote server. The cleanest fix seems to be to expose libpq's conninfo-string-parsing code so that dblink can check for a password option without duplicating the parsing logic. Joe Conway, with a little cleanup by Tom Lane
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/interfaces/libpq/libpq-fe.h,v 1.143 2008/09/17 04:31:08 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/interfaces/libpq/libpq-fe.h,v 1.144 2008/09/22 13:55:14 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -164,6 +164,7 @@ typedef struct _PQprintOpt
|
||||
|
||||
/* ----------------
|
||||
* Structure for the conninfo parameter definitions returned by PQconndefaults
|
||||
* or PQconninfoParse.
|
||||
*
|
||||
* All fields except "val" point at static strings which must not be altered.
|
||||
* "val" is either NULL or a malloc'd current-value string. PQconninfoFree()
|
||||
@@ -177,7 +178,7 @@ typedef struct _PQconninfoOption
|
||||
char *compiled; /* Fallback compiled in default value */
|
||||
char *val; /* Option's current value, or NULL */
|
||||
char *label; /* Label for field in connect dialog */
|
||||
char *dispchar; /* Character to display for this field in a
|
||||
char *dispchar; /* Indicates how to display this field in a
|
||||
* connect dialog. Values are: "" Display
|
||||
* entered value as is "*" Password field -
|
||||
* hide value "D" Debug option - don't show
|
||||
@@ -243,7 +244,10 @@ extern void PQfinish(PGconn *conn);
|
||||
/* get info about connection options known to PQconnectdb */
|
||||
extern PQconninfoOption *PQconndefaults(void);
|
||||
|
||||
/* free the data structure returned by PQconndefaults() */
|
||||
/* parse connection options in same way as PQconnectdb */
|
||||
extern PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg);
|
||||
|
||||
/* free the data structure returned by PQconndefaults() or PQconninfoParse() */
|
||||
extern void PQconninfoFree(PQconninfoOption *connOptions);
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user