Simplify code related to compilation of SSL and OpenSSL
authorMichael Paquier <michael@paquier.xyz>
Wed, 10 Feb 2021 06:28:19 +0000 (15:28 +0900)
committerMichael Paquier <michael@paquier.xyz>
Wed, 10 Feb 2021 06:28:19 +0000 (15:28 +0900)
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

src/backend/libpq/hba.c
src/include/libpq/libpq-be.h
src/include/pg_config_manual.h
src/interfaces/libpq/fe-secure.c
src/interfaces/libpq/libpq-fe.h

index 20bf1461cef28c2a3d2aae2ca02e6c9543b92076..9a04c093d5f6389ffcbfb45463cde2df108939d4 100644 (file)
@@ -1041,7 +1041,7 @@ parse_hba_line(TokenizedLine *tok_line, int elevel)
            ereport(elevel,
                    (errcode(ERRCODE_CONFIG_FILE_ERROR),
                     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\"",
                                line_num, HbaFileName)));
            *err_msg = "hostssl record cannot match because SSL is not supported by this build";
index 66a8673d93948df19f3ecccfd27d6c5968310b57..7be1a67d692f895a9e9900303cc5158ec986ef62 100644 (file)
@@ -194,7 +194,7 @@ typedef struct Port
 
    /*
     * 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
    SSL        *ssl;
index d27c8601fa7f0e985b8911c3b6057daed673e6ed..2a12071badcc223c6e1ec53917fadf234e27bc43 100644 (file)
 
 /*
  * USE_SSL code should be compiled only when compiling with an SSL
- * implementation.  (Currently, only OpenSSL is supported, but we might add
- * more implementations in the future.)
+ * implementation.
  */
 #ifdef USE_OPENSSL
 #define USE_SSL
index 00b87bdc96d7ea999a827129261016946b8e910d..c601071838141112965fdbb1e5b6f94a2baff967 100644 (file)
@@ -421,6 +421,13 @@ PQsslAttributeNames(PGconn *conn)
 
    return result;
 }
+#endif                         /* USE_SSL */
+
+/*
+ * Dummy versions of OpenSSL key password hook functions, when built without
+ * OpenSSL.
+ */
+#ifndef USE_OPENSSL
 
 PQsslKeyPassHook_OpenSSL_type
 PQgetSSLKeyPassHook_OpenSSL(void)
@@ -439,7 +446,7 @@ PQdefaultSSLKeyPassHook_OpenSSL(char *buf, int size, PGconn *conn)
 {
    return 0;
 }
-#endif                         /* USE_SSL */
+#endif                         /* USE_OPENSSL */
 
 /* Dummy version of GSSAPI information functions, when built without GSS support */
 #ifndef ENABLE_GSS
index c266ad5b138447d1e9580bdc5b02aa8b922c1222..effe0ccf8566b1554c5c053fe927ff9d55d7c613 100644 (file)
@@ -619,7 +619,7 @@ extern int  pg_valid_server_encoding_id(int encoding);
 
 /* === 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);
 extern PQsslKeyPassHook_OpenSSL_type PQgetSSLKeyPassHook_OpenSSL(void);
 extern void PQsetSSLKeyPassHook_OpenSSL(PQsslKeyPassHook_OpenSSL_type hook);