Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite60b480

Browse files
committed
libpq should expose GSS-related parameters even when not implemented.
We realized years ago that it's better for libpq to accept allconnection parameters syntactically, even if some are ignored orrestricted due to lack of the feature in a particular build.However, that lesson from the SSL support was for some reason neverapplied to the GSSAPI support. This is causing various buildfarmmembers to have problems with a test case added by commit6136e94,and it's just a bad idea from a user-experience standpoint anyway,so fix it.While at it, fix some places where parameter-related infrastructurewas added with the aid of a dartboard, or perhaps with the aid ofthe anti-pattern "add new stuff at the end". It should be safeto rearrange the contents of struct pg_conn even in releasedbranches, since that's private to libpq (and we'd have to movesome fields in some builds to fix this, anyway).Back-patch to all supported branches.Discussion:https://postgr.es/m/11297.1576868677@sss.pgh.pa.us
1 parent77f416a commite60b480

File tree

5 files changed

+31
-48
lines changed

5 files changed

+31
-48
lines changed

‎contrib/postgres_fdw/expected/postgres_fdw.out

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ CREATE FOREIGN TABLE ft6 (
132132
-- ===================================================================
133133
-- tests for validator
134134
-- ===================================================================
135-
-- requiressl, krbsrvnameandgsslibare omitted because they depend on
136-
-- configure options
135+
-- requiresslandsome other parametersare omitted because
136+
--valid values for them depend onconfigure options
137137
ALTER SERVER testserver1 OPTIONS (
138138
use_remote_estimate 'false',
139139
updatable 'true',
@@ -158,10 +158,10 @@ ALTER SERVER testserver1 OPTIONS (
158158
sslcert 'value',
159159
sslkey 'value',
160160
sslrootcert 'value',
161-
sslcrl 'value'
161+
sslcrl 'value',
162162
--requirepeer 'value',
163-
--krbsrvname 'value',
164-
--gsslib 'value',
163+
krbsrvname 'value',
164+
gsslib 'value'
165165
--replication 'value'
166166
);
167167
-- Error, invalid list syntax
@@ -8855,7 +8855,7 @@ DO $d$
88558855
END;
88568856
$d$;
88578857
ERROR: invalid option "password"
8858-
HINT: Valid options in this context are: service, passfile, channel_binding, connect_timeout, dbname, host, hostaddr, port, options, application_name, keepalives, keepalives_idle, keepalives_interval, keepalives_count, tcp_user_timeout, sslmode, sslcompression, sslcert, sslkey, sslrootcert, sslcrl, requirepeer, gssencmode, krbsrvname, target_session_attrs, use_remote_estimate, fdw_startup_cost, fdw_tuple_cost, extensions, updatable, fetch_size
8858+
HINT: Valid options in this context are: service, passfile, channel_binding, connect_timeout, dbname, host, hostaddr, port, options, application_name, keepalives, keepalives_idle, keepalives_interval, keepalives_count, tcp_user_timeout, sslmode, sslcompression, sslcert, sslkey, sslrootcert, sslcrl, requirepeer, gssencmode, krbsrvname,gsslib,target_session_attrs, use_remote_estimate, fdw_startup_cost, fdw_tuple_cost, extensions, updatable, fetch_size
88598859
CONTEXT: SQL statement "ALTER SERVER loopback_nopw OPTIONS (ADD password 'dummypw')"
88608860
PL/pgSQL function inline_code_block line 3 at EXECUTE
88618861
-- If we add a password for our user mapping instead, we should get a different

‎contrib/postgres_fdw/sql/postgres_fdw.sql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ CREATE FOREIGN TABLE ft6 (
145145
-- ===================================================================
146146
-- tests for validator
147147
-- ===================================================================
148-
-- requiressl, krbsrvnameandgsslibare omitted because they depend on
149-
-- configure options
148+
-- requiresslandsome other parametersare omitted because
149+
--valid values for them depend onconfigure options
150150
ALTER SERVER testserver1 OPTIONS (
151151
use_remote_estimate'false',
152152
updatable'true',
@@ -171,10 +171,10 @@ ALTER SERVER testserver1 OPTIONS (
171171
sslcert'value',
172172
sslkey'value',
173173
sslrootcert'value',
174-
sslcrl'value'
174+
sslcrl'value',
175175
--requirepeer 'value',
176-
--krbsrvname 'value',
177-
--gsslib 'value',
176+
krbsrvname'value',
177+
gsslib'value'
178178
--replication 'value'
179179
);
180180

‎doc/src/sgml/libpq.sgml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1747,8 +1747,10 @@ postgresql://%2Fvar%2Flib%2Fpostgresql/dbname
17471747
<term><literal>gsslib</literal></term>
17481748
<listitem>
17491749
<para>
1750-
GSS library to use for GSSAPI authentication. Only used on Windows.
1751-
Set to <literal>gssapi</literal> to force libpq to use the GSSAPI
1750+
GSS library to use for GSSAPI authentication.
1751+
Currently this is disregarded except on Windows builds that include
1752+
both GSSAPI and SSPI support. In that case, set
1753+
this to <literal>gssapi</literal> to cause libpq to use the GSSAPI
17521754
library for authentication instead of the default SSPI.
17531755
</para>
17541756
</listitem>

‎src/interfaces/libpq/fe-connect.c

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,10 @@ static const internalPQconninfoOption PQconninfoOptions[] = {
304304
"SSL-Client-Key","",64,
305305
offsetof(structpg_conn,sslkey)},
306306

307+
{"sslpassword",NULL,NULL,NULL,
308+
"SSL-Client-Key-Password","*",20,
309+
offsetof(structpg_conn,sslpassword)},
310+
307311
{"sslrootcert","PGSSLROOTCERT",NULL,NULL,
308312
"SSL-Root-Certificate","",64,
309313
offsetof(structpg_conn,sslrootcert)},
@@ -317,30 +321,21 @@ static const internalPQconninfoOption PQconninfoOptions[] = {
317321
offsetof(structpg_conn,requirepeer)},
318322

319323
/*
320-
*Expose gssencmode similarly to sslmode - we can still handle "disable"
321-
*and "prefer".
324+
*As with SSL, all GSS options are exposed even in builds that don't have
325+
*support.
322326
*/
323327
{"gssencmode","PGGSSENCMODE",DefaultGSSMode,NULL,
324328
"GSSENC-Mode","",7,/* sizeof("disable") == 7 */
325329
offsetof(structpg_conn,gssencmode)},
326330

327-
#if defined(ENABLE_GSS)||defined(ENABLE_SSPI)
328331
/* Kerberos and GSSAPI authentication support specifying the service name */
329332
{"krbsrvname","PGKRBSRVNAME",PG_KRB_SRVNAM,NULL,
330333
"Kerberos-service-name","",20,
331334
offsetof(structpg_conn,krbsrvname)},
332-
#endif
333-
334-
#if defined(ENABLE_GSS)&&defined(ENABLE_SSPI)
335335

336-
/*
337-
* GSSAPI and SSPI both enabled, give a way to override which is used by
338-
* default
339-
*/
340336
{"gsslib","PGGSSLIB",NULL,NULL,
341337
"GSS-library","",7,/* sizeof("gssapi") = 7 */
342338
offsetof(structpg_conn,gsslib)},
343-
#endif
344339

345340
{"replication",NULL,NULL,NULL,
346341
"Replication","D",5,
@@ -351,10 +346,6 @@ static const internalPQconninfoOption PQconninfoOptions[] = {
351346
"Target-Session-Attrs","",11,/* sizeof("read-write") = 11 */
352347
offsetof(structpg_conn,target_session_attrs)},
353348

354-
{"sslpassword",NULL,NULL,NULL,
355-
"SSL-Client-Key-Password","*",20,
356-
offsetof(structpg_conn,sslpassword)},
357-
358349
/* Terminating entry --- MUST BE LAST */
359350
{NULL,NULL,NULL,NULL,
360351
NULL,NULL,0}
@@ -3983,6 +3974,8 @@ freePGconn(PGconn *conn)
39833974
free(conn->sslcert);
39843975
if (conn->sslkey)
39853976
free(conn->sslkey);
3977+
if (conn->sslpassword)
3978+
free(conn->sslpassword);
39863979
if (conn->sslrootcert)
39873980
free(conn->sslrootcert);
39883981
if (conn->sslcrl)
@@ -3991,14 +3984,14 @@ freePGconn(PGconn *conn)
39913984
free(conn->sslcompression);
39923985
if (conn->requirepeer)
39933986
free(conn->requirepeer);
3994-
if (conn->connip)
3995-
free(conn->connip);
39963987
if (conn->gssencmode)
39973988
free(conn->gssencmode);
3998-
#if defined(ENABLE_GSS)|| defined(ENABLE_SSPI)
39993989
if (conn->krbsrvname)
40003990
free(conn->krbsrvname);
4001-
#endif
3991+
if (conn->gsslib)
3992+
free(conn->gsslib);
3993+
if (conn->connip)
3994+
free(conn->connip);
40023995
#ifdefENABLE_GSS
40033996
if (conn->gcred!=GSS_C_NO_CREDENTIAL)
40043997
{
@@ -4014,10 +4007,6 @@ freePGconn(PGconn *conn)
40144007
gss_delete_sec_context(&minor,&conn->gctx,GSS_C_NO_BUFFER);
40154008
conn->gctx=NULL;
40164009
}
4017-
#endif
4018-
#if defined(ENABLE_GSS)&& defined(ENABLE_SSPI)
4019-
if (conn->gsslib)
4020-
free(conn->gsslib);
40214010
#endif
40224011
/* Note that conn->Pfdebug is not ours to close or free */
40234012
if (conn->last_query)
@@ -4034,8 +4023,6 @@ freePGconn(PGconn *conn)
40344023
free(conn->target_session_attrs);
40354024
termPQExpBuffer(&conn->errorMessage);
40364025
termPQExpBuffer(&conn->workBuffer);
4037-
if (conn->sslpassword)
4038-
free(conn->sslpassword);
40394026

40404027
free(conn);
40414028

‎src/interfaces/libpq/libpq-int.h

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -359,13 +359,14 @@ struct pg_conn
359359
char*sslcompression;/* SSL compression (0 or 1) */
360360
char*sslkey;/* client key filename */
361361
char*sslcert;/* client certificate filename */
362+
char*sslpassword;/* client key file password */
362363
char*sslrootcert;/* root certificate filename */
363364
char*sslcrl;/* certificate revocation list filename */
364365
char*requirepeer;/* required peer credentials for local sockets */
365-
366-
#if defined(ENABLE_GSS)|| defined(ENABLE_SSPI)
366+
char*gssencmode;/* GSS mode (require,prefer,disable) */
367367
char*krbsrvname;/* Kerberos service name */
368-
#endif
368+
char*gsslib;/* What GSS library to use ("gssapi" or
369+
* "sspi") */
369370

370371
/* Type of connection to make. Possible values: any, read-write. */
371372
char*target_session_attrs;
@@ -484,7 +485,6 @@ struct pg_conn
484485
#endif/* USE_OPENSSL */
485486
#endif/* USE_SSL */
486487

487-
char*gssencmode;/* GSS mode (require,prefer,disable) */
488488
#ifdefENABLE_GSS
489489
gss_ctx_id_tgctx;/* GSS context */
490490
gss_name_tgtarg_nam;/* GSS target name */
@@ -496,10 +496,6 @@ struct pg_conn
496496
#endif
497497

498498
#ifdefENABLE_SSPI
499-
#ifdefENABLE_GSS
500-
char*gsslib;/* What GSS library to use ("gssapi" or
501-
* "sspi") */
502-
#endif
503499
CredHandle*sspicred;/* SSPI credentials handle */
504500
CtxtHandle*sspictx;/* SSPI context */
505501
char*sspitarget;/* SSPI target name */
@@ -512,8 +508,6 @@ struct pg_conn
512508

513509
/* Buffer for receiving various parts of messages */
514510
PQExpBufferDataworkBuffer;/* expansible string */
515-
516-
char*sslpassword;/* client key file password */
517511
};
518512

519513
/* PGcancel stores all data necessary to cancel a connection. A copy of this

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp