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

Commit36d1087

Browse files
committed
Rename PQsetSSLKeyPassHook and friends
4dc6355 provided a way for libraries and clients to modify how libpqhandles client certificate passphrases, by installing a hook. However,these routines are quite specific to how OpenSSL works, so it'smisleading and not future-proof to have these names not refer to OpenSSL.Change all the names to add "_OpenSSL" after "Hook", and fix the docsaccordingly.Author: Daniel GustafssonDiscussion:https://postgr.es/m/981DE552-E399-45C2-9F60-3F0E3770CC61@yesql.se
1 parent1cbc143 commit36d1087

File tree

4 files changed

+21
-21
lines changed

4 files changed

+21
-21
lines changed

‎doc/src/sgml/libpq.sgml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -777,30 +777,30 @@ PGPing PQping(const char *conninfo);
777777
</varlistentry>
778778

779779
<varlistentry id="libpq-pqsetsslkeypasshook">
780-
<term><function>PQsetSSLKeyPassHook</function><indexterm><primary>PQsetSSLKeyPassHook</primary></indexterm></term>
780+
<term><function>PQsetSSLKeyPassHook_OpenSSL</function><indexterm><primary>PQsetSSLKeyPassHook_OpenSSL</primary></indexterm></term>
781781
<listitem>
782782
<para>
783-
<function>PQsetSSLKeyPassHook</function> lets an application override
783+
<function>PQsetSSLKeyPassHook_OpenSSL</function> lets an application override
784784
<literal>libpq</literal>'s <link linkend="libpq-ssl-clientcert">default
785785
handling of encrypted client certificate key files</link> using
786786
<xref linkend="libpq-connect-sslpassword"/> or interactive prompting.
787787

788788
<synopsis>
789-
voidPQsetSSLKeyPassHook(PQsslKeyPassHook_type hook);
789+
voidPQsetSSLKeyPassHook_OpenSSL(PQsslKeyPassHook_OpenSSL_type hook);
790790
</synopsis>
791791

792792
The application passes a pointer to a callback function with signature:
793793
<programlisting>
794794
int callback_fn(char *buf, int size, PGconn *conn);
795795
</programlisting>
796796
which <literal>libpq</literal> will then call <emphasis>instead of</emphasis>
797-
its default <function>PQdefaultSSLKeyPassHook</function> handler. The callback
797+
its default <function>PQdefaultSSLKeyPassHook_OpenSSL</function> handler. The callback
798798
should determine the password for the key and copy it to result-buffer
799799
<literal>buf</literal> of size <literal>size</literal>. The string in <literal>
800800
buf</literal> must be null-terminated. The callback must return the length of
801801
the password stored in <literal>buf</literal> excluding the null terminator.
802802
On failure, the callback should set <literal>buf[0] = '\0'</literal> and return 0.
803-
See <function>PQdefaultSSLKeyPassHook</function> in <literal>libpq</literal>'s
803+
See <function>PQdefaultSSLKeyPassHook_OpenSSL</function> in <literal>libpq</literal>'s
804804
source code for an example.
805805
</para>
806806

@@ -814,7 +814,7 @@ int callback_fn(char *buf, int size, PGconn *conn);
814814

815815
<para>
816816
The app callback may choose to delegate unhandled cases to
817-
<function>PQdefaultSSLKeyPassHook</function>,
817+
<function>PQdefaultSSLKeyPassHook_OpenSSL</function>,
818818
or call it first and try something else if it returns 0, or completely override it.
819819
</para>
820820

@@ -835,7 +835,7 @@ int callback_fn(char *buf, int size, PGconn *conn);
835835
if none has been set.
836836

837837
<synopsis>
838-
PQsslKeyPassHook_type PQgetSSLKeyPassHook(void);
838+
PQsslKeyPassHook_OpenSSL_type PQgetSSLKeyPassHook(void);
839839
</synopsis>
840840
</para>
841841

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ static long win32_ssl_create_mutex = 0;
9595
#endif
9696
#endif/* ENABLE_THREAD_SAFETY */
9797

98-
staticPQsslKeyPassHook_typePQsslKeyPassHook=NULL;
98+
staticPQsslKeyPassHook_OpenSSL_typePQsslKeyPassHook=NULL;
9999
staticintssl_protocol_version_to_openssl(constchar*protocol);
100100

101101
/* ------------------------------------------------------------ */
@@ -1669,7 +1669,7 @@ my_SSL_set_fd(PGconn *conn, int fd)
16691669
* prevent openssl from ever prompting on stdin.
16701670
*/
16711671
int
1672-
PQdefaultSSLKeyPassHook(char*buf,intsize,PGconn*conn)
1672+
PQdefaultSSLKeyPassHook_OpenSSL(char*buf,intsize,PGconn*conn)
16731673
{
16741674
if (conn->sslpassword)
16751675
{
@@ -1686,14 +1686,14 @@ PQdefaultSSLKeyPassHook(char *buf, int size, PGconn *conn)
16861686
}
16871687
}
16881688

1689-
PQsslKeyPassHook_type
1689+
PQsslKeyPassHook_OpenSSL_type
16901690
PQgetSSLKeyPassHook(void)
16911691
{
16921692
returnPQsslKeyPassHook;
16931693
}
16941694

16951695
void
1696-
PQsetSSLKeyPassHook(PQsslKeyPassHook_typehook)
1696+
PQsetSSLKeyPassHook_OpenSSL(PQsslKeyPassHook_OpenSSL_typehook)
16971697
{
16981698
PQsslKeyPassHook=hook;
16991699
}
@@ -1711,7 +1711,7 @@ PQssl_passwd_cb(char *buf, int size, int rwflag, void *userdata)
17111711
if (PQsslKeyPassHook)
17121712
returnPQsslKeyPassHook(buf,size,conn);
17131713
else
1714-
returnPQdefaultSSLKeyPassHook(buf,size,conn);
1714+
returnPQdefaultSSLKeyPassHook_OpenSSL(buf,size,conn);
17151715
}
17161716

17171717
/*

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -431,20 +431,20 @@ PQsslAttributeNames(PGconn *conn)
431431
returnresult;
432432
}
433433

434-
PQsslKeyPassHook_type
435-
PQgetSSLKeyPassHook(void)
434+
PQsslKeyPassHook_OpenSSL_type
435+
PQgetSSLKeyPassHook_OpenSSL(void)
436436
{
437437
returnNULL;
438438
}
439439

440440
void
441-
PQsetSSLKeyPassHook(PQsslKeyPassHook_typehook)
441+
PQsetSSLKeyPassHook_OpenSSL(PQsslKeyPassHook_OpenSSL_typehook)
442442
{
443443
return;
444444
}
445445

446446
int
447-
PQdefaultSSLKeyPassHook(char*buf,intsize,PGconn*conn)
447+
PQdefaultSSLKeyPassHook_OpenSSL(char*buf,intsize,PGconn*conn)
448448
{
449449
return0;
450450
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -617,13 +617,13 @@ extern intpg_char_to_encoding(const char *name);
617617
externconstchar*pg_encoding_to_char(intencoding);
618618
externintpg_valid_server_encoding_id(intencoding);
619619

620-
/* == in fe-secure-openssl.c === */
620+
/* === in fe-secure-openssl.c === */
621621

622622
/* Support for overriding sslpassword handling with a callback. */
623-
typedefint (*PQsslKeyPassHook_type) (char*buf,intsize,PGconn*conn);
624-
externPQsslKeyPassHook_typePQgetSSLKeyPassHook(void);
625-
externvoidPQsetSSLKeyPassHook(PQsslKeyPassHook_typehook);
626-
externintPQdefaultSSLKeyPassHook(char*buf,intsize,PGconn*conn);
623+
typedefint (*PQsslKeyPassHook_OpenSSL_type) (char*buf,intsize,PGconn*conn);
624+
externPQsslKeyPassHook_OpenSSL_typePQgetSSLKeyPassHook(void);
625+
externvoidPQsetSSLKeyPassHook_OpenSSL(PQsslKeyPassHook_OpenSSL_typehook);
626+
externintPQdefaultSSLKeyPassHook_OpenSSL(char*buf,intsize,PGconn*conn);
627627

628628
#ifdef__cplusplus
629629
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp