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

Commit4e4f7b9

Browse files
committed
Adjust PQsslAttributeNames() to match PQsslAttribute().
Currently, PQsslAttributeNames() returns the same list of attributenames regardless of its conn parameter. This patch changes it tohave behavior parallel to what80a0567 installed for PQsslAttribute:you get OpenSSL's attributes if conn is NULL or is an SSL-encryptedconnection, or an empty list if conn is a non-encrypted connection.The point of this is to have sensible connection-dependent behaviorin case we ever support multiple SSL libraries. The behavior forNULL can be defined as "the attributes for the default SSL library",parallel to what PQsslAttribute(NULL, "library") does.Since this is mostly just future-proofing, no back-patch.Discussion:https://postgr.es/m/17625-fc47c78b7d71b534@postgresql.org
1 parent69298db commit4e4f7b9

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

‎doc/src/sgml/libpq.sgml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2590,12 +2590,22 @@ const char *PQsslAttribute(const PGconn *conn, const char *attribute_name);
25902590
<term><function>PQsslAttributeNames</function><indexterm><primary>PQsslAttributeNames</primary></indexterm></term>
25912591
<listitem>
25922592
<para>
2593-
Returns an array of SSL attribute names available.
2593+
Returns an array of SSL attribute names that can be used
2594+
in <function>PQsslAttribute()</function>.
25942595
The array is terminated by a NULL pointer.
25952596
<synopsis>
25962597
const char * const * PQsslAttributeNames(const PGconn *conn);
25972598
</synopsis>
25982599
</para>
2600+
2601+
<para>
2602+
If <literal>conn</literal> is NULL, the attributes available for the
2603+
default SSL library are returned, or an empty list
2604+
if <application>libpq</application> was compiled without any SSL
2605+
support. If <literal>conn</literal> is not NULL, the attributes
2606+
available for the SSL library in use for the connection are returned,
2607+
or an empty list if the connection is not encrypted.
2608+
</para>
25992609
</listitem>
26002610
</varlistentry>
26012611

‎src/interfaces/libpq/fe-secure-openssl.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1730,16 +1730,27 @@ PQsslStruct(PGconn *conn, const char *struct_name)
17301730
constchar*const*
17311731
PQsslAttributeNames(PGconn*conn)
17321732
{
1733-
staticconstchar*constresult[]= {
1733+
staticconstchar*constopenssl_attrs[]= {
17341734
"library",
17351735
"key_bits",
17361736
"cipher",
17371737
"compression",
17381738
"protocol",
17391739
NULL
17401740
};
1741+
staticconstchar*constempty_attrs[]= {NULL};
17411742

1742-
returnresult;
1743+
if (!conn)
1744+
{
1745+
/* Return attributes of default SSL library */
1746+
returnopenssl_attrs;
1747+
}
1748+
1749+
/* No attrs for unencrypted connection */
1750+
if (conn->ssl==NULL)
1751+
returnempty_attrs;
1752+
1753+
returnopenssl_attrs;
17431754
}
17441755

17451756
constchar*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp