Commit 092b785f authored by Michael Paquier's avatar Michael Paquier

Simplify code related to compilation of SSL and OpenSSL

This commit makes more generic some comments and code related to the
compilation with OpenSSL and SSL in general to ease the addition of more
SSL implementations in the future.  In libpq, some OpenSSL-only code is
moved under USE_OPENSSL and not USE_SSL.

While on it, make a comment more consistent in libpq-fe.h.

Author: Daniel Gustafsson
Discussion: https://postgr.es/m/5382CB4A-9CF3-4145-BA46-C802615935E0@yesql.se
parent bd120809
...@@ -1041,7 +1041,7 @@ parse_hba_line(TokenizedLine *tok_line, int elevel) ...@@ -1041,7 +1041,7 @@ parse_hba_line(TokenizedLine *tok_line, int elevel)
ereport(elevel, ereport(elevel,
(errcode(ERRCODE_CONFIG_FILE_ERROR), (errcode(ERRCODE_CONFIG_FILE_ERROR),
errmsg("hostssl record cannot match because SSL is not supported by this build"), errmsg("hostssl record cannot match because SSL is not supported by this build"),
errhint("Compile with --with-ssl=openssl to use SSL connections."), errhint("Compile with --with-ssl to use SSL connections."),
errcontext("line %d of configuration file \"%s\"", errcontext("line %d of configuration file \"%s\"",
line_num, HbaFileName))); line_num, HbaFileName)));
*err_msg = "hostssl record cannot match because SSL is not supported by this build"; *err_msg = "hostssl record cannot match because SSL is not supported by this build";
......
...@@ -194,7 +194,7 @@ typedef struct Port ...@@ -194,7 +194,7 @@ typedef struct Port
/* /*
* OpenSSL structures. (Keep these last so that the locations of other * OpenSSL structures. (Keep these last so that the locations of other
* fields are the same whether or not you build with OpenSSL.) * fields are the same whether or not you build with SSL enabled.)
*/ */
#ifdef USE_OPENSSL #ifdef USE_OPENSSL
SSL *ssl; SSL *ssl;
......
...@@ -176,8 +176,7 @@ ...@@ -176,8 +176,7 @@
/* /*
* USE_SSL code should be compiled only when compiling with an SSL * USE_SSL code should be compiled only when compiling with an SSL
* implementation. (Currently, only OpenSSL is supported, but we might add * implementation.
* more implementations in the future.)
*/ */
#ifdef USE_OPENSSL #ifdef USE_OPENSSL
#define USE_SSL #define USE_SSL
......
...@@ -421,6 +421,13 @@ PQsslAttributeNames(PGconn *conn) ...@@ -421,6 +421,13 @@ PQsslAttributeNames(PGconn *conn)
return result; return result;
} }
#endif /* USE_SSL */
/*
* Dummy versions of OpenSSL key password hook functions, when built without
* OpenSSL.
*/
#ifndef USE_OPENSSL
PQsslKeyPassHook_OpenSSL_type PQsslKeyPassHook_OpenSSL_type
PQgetSSLKeyPassHook_OpenSSL(void) PQgetSSLKeyPassHook_OpenSSL(void)
...@@ -439,7 +446,7 @@ PQdefaultSSLKeyPassHook_OpenSSL(char *buf, int size, PGconn *conn) ...@@ -439,7 +446,7 @@ PQdefaultSSLKeyPassHook_OpenSSL(char *buf, int size, PGconn *conn)
{ {
return 0; return 0;
} }
#endif /* USE_SSL */ #endif /* USE_OPENSSL */
/* Dummy version of GSSAPI information functions, when built without GSS support */ /* Dummy version of GSSAPI information functions, when built without GSS support */
#ifndef ENABLE_GSS #ifndef ENABLE_GSS
......
...@@ -619,7 +619,7 @@ extern int pg_valid_server_encoding_id(int encoding); ...@@ -619,7 +619,7 @@ 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. */ /* Support for overriding sslpassword handling with a callback */
typedef int (*PQsslKeyPassHook_OpenSSL_type) (char *buf, int size, PGconn *conn); typedef int (*PQsslKeyPassHook_OpenSSL_type) (char *buf, int size, PGconn *conn);
extern PQsslKeyPassHook_OpenSSL_type PQgetSSLKeyPassHook_OpenSSL(void); extern PQsslKeyPassHook_OpenSSL_type PQgetSSLKeyPassHook_OpenSSL(void);
extern void PQsetSSLKeyPassHook_OpenSSL(PQsslKeyPassHook_OpenSSL_type hook); extern void PQsetSSLKeyPassHook_OpenSSL(PQsslKeyPassHook_OpenSSL_type hook);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment