From 0c97e3ad8c0bf3fa0398e9d6318063b0dd4244eb Mon Sep 17 00:00:00 2001 From: Daniel Gustafsson Date: Sat, 16 May 2020 09:09:53 +0200 Subject: [PATCH] Rename OpenSSL specific password hook --- doc/src/sgml/libpq.sgml | 14 +++++++------- src/interfaces/libpq/fe-secure-openssl.c | 10 +++++----- src/interfaces/libpq/fe-secure.c | 8 ++++---- src/interfaces/libpq/libpq-fe.h | 10 +++++----- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml index 5bc54b2044..ca9aa623a2 100644 --- a/doc/src/sgml/libpq.sgml +++ b/doc/src/sgml/libpq.sgml @@ -777,16 +777,16 @@ PGPing PQping(const char *conninfo); - PQsetSSLKeyPassHookPQsetSSLKeyPassHook + PQsetSSLKeyPassHook_OpenSSLPQsetSSLKeyPassHook_OpenSSL - PQsetSSLKeyPassHook lets an application override + PQsetSSLKeyPassHook_OpenSSL lets an application override libpq's default handling of encrypted client certificate key files using or interactive prompting. -void PQsetSSLKeyPassHook(PQsslKeyPassHook_type hook); +void PQsetSSLKeyPassHook_OpenSSL(PQsslKeyPassHook_OpenSSL_type hook); The application passes a pointer to a callback function with signature: @@ -794,13 +794,13 @@ void PQsetSSLKeyPassHook(PQsslKeyPassHook_type hook); int callback_fn(char *buf, int size, PGconn *conn); which libpq will then call instead of - its default PQdefaultSSLKeyPassHook handler. The callback + its default PQdefaultSSLKeyPassHook_OpenSSL handler. The callback should determine the password for the key and copy it to result-buffer buf of size size. The string in buf must be null-terminated. The callback must return the length of the password stored in buf excluding the null terminator. On failure, the callback should set buf[0] = '\0' and return 0. - See PQdefaultSSLKeyPassHook in libpq's + See PQdefaultSSLKeyPassHook_OpenSSL in libpq's source code for an example. @@ -814,7 +814,7 @@ int callback_fn(char *buf, int size, PGconn *conn); The app callback may choose to delegate unhandled cases to - PQdefaultSSLKeyPassHook, + PQdefaultSSLKeyPassHook_OpenSSL, or call it first and try something else if it returns 0, or completely override it. @@ -835,7 +835,7 @@ int callback_fn(char *buf, int size, PGconn *conn); if none has been set. -PQsslKeyPassHook_type PQgetSSLKeyPassHook(void); +PQsslKeyPassHook_OpenSSL_type PQgetSSLKeyPassHook(void); diff --git a/src/interfaces/libpq/fe-secure-openssl.c b/src/interfaces/libpq/fe-secure-openssl.c index df1ac209f9..fb66546b8b 100644 --- a/src/interfaces/libpq/fe-secure-openssl.c +++ b/src/interfaces/libpq/fe-secure-openssl.c @@ -95,7 +95,7 @@ static long win32_ssl_create_mutex = 0; #endif #endif /* ENABLE_THREAD_SAFETY */ -static PQsslKeyPassHook_type PQsslKeyPassHook = NULL; +static PQsslKeyPassHook_OpenSSL_type PQsslKeyPassHook = NULL; static int ssl_protocol_version_to_openssl(const char *protocol); /* ------------------------------------------------------------ */ @@ -1669,7 +1669,7 @@ err: * prevent openssl from ever prompting on stdin. */ int -PQdefaultSSLKeyPassHook(char *buf, int size, PGconn *conn) +PQdefaultSSLKeyPassHook_OpenSSL(char *buf, int size, PGconn *conn) { if (conn->sslpassword) { @@ -1686,14 +1686,14 @@ PQdefaultSSLKeyPassHook(char *buf, int size, PGconn *conn) } } -PQsslKeyPassHook_type +PQsslKeyPassHook_OpenSSL_type PQgetSSLKeyPassHook(void) { return PQsslKeyPassHook; } void -PQsetSSLKeyPassHook(PQsslKeyPassHook_type hook) +PQsetSSLKeyPassHook_OpenSSL(PQsslKeyPassHook_OpenSSL_type hook) { PQsslKeyPassHook = hook; } @@ -1711,7 +1711,7 @@ PQssl_passwd_cb(char *buf, int size, int rwflag, void *userdata) if (PQsslKeyPassHook) return PQsslKeyPassHook(buf, size, conn); else - return PQdefaultSSLKeyPassHook(buf, size, conn); + return PQdefaultSSLKeyPassHook_OpenSSL(buf, size, conn); } /* diff --git a/src/interfaces/libpq/fe-secure.c b/src/interfaces/libpq/fe-secure.c index b455b45e96..3311fd7a5b 100644 --- a/src/interfaces/libpq/fe-secure.c +++ b/src/interfaces/libpq/fe-secure.c @@ -431,20 +431,20 @@ PQsslAttributeNames(PGconn *conn) return result; } -PQsslKeyPassHook_type -PQgetSSLKeyPassHook(void) +PQsslKeyPassHook_OpenSSL_type +PQgetSSLKeyPassHook_OpenSSL(void) { return NULL; } void -PQsetSSLKeyPassHook(PQsslKeyPassHook_type hook) +PQsetSSLKeyPassHook_OpenSSL(PQsslKeyPassHook_OpenSSL_type hook) { return; } int -PQdefaultSSLKeyPassHook(char *buf, int size, PGconn *conn) +PQdefaultSSLKeyPassHook_OpenSSL(char *buf, int size, PGconn *conn) { return 0; } diff --git a/src/interfaces/libpq/libpq-fe.h b/src/interfaces/libpq/libpq-fe.h index ea13f5afb8..f104bbfa4a 100644 --- a/src/interfaces/libpq/libpq-fe.h +++ b/src/interfaces/libpq/libpq-fe.h @@ -617,13 +617,13 @@ extern int pg_char_to_encoding(const char *name); extern const char *pg_encoding_to_char(int encoding); extern int pg_valid_server_encoding_id(int encoding); -/* == in fe-secure-openssl.c === */ +/* === in fe-secure-openssl.c === */ /* Support for overriding sslpassword handling with a callback. */ -typedef int (*PQsslKeyPassHook_type) (char *buf, int size, PGconn *conn); -extern PQsslKeyPassHook_type PQgetSSLKeyPassHook(void); -extern void PQsetSSLKeyPassHook(PQsslKeyPassHook_type hook); -extern int PQdefaultSSLKeyPassHook(char *buf, int size, PGconn *conn); +typedef int (*PQsslKeyPassHook_OpenSSL_type) (char *buf, int size, PGconn *conn); +extern PQsslKeyPassHook_OpenSSL_type PQgetSSLKeyPassHook(void); +extern void PQsetSSLKeyPassHook_OpenSSL(PQsslKeyPassHook_OpenSSL_type hook); +extern int PQdefaultSSLKeyPassHook_OpenSSL(char *buf, int size, PGconn *conn); #ifdef __cplusplus } -- 2.21.1 (Apple Git-122.3)