Skip to content

Commit ccc9073

Browse files
committed
Make psql report "SSL connection (unknown cipher)" when libpq has set
up a SSL connection, but psql is compiled without support for it. Not a really realistic use-case, but the patch also cuts down on the number of places with #ifdef's...
1 parent cad3a26 commit ccc9073

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/bin/psql/command.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2008, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.196 2008/09/15 12:18:00 petere Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.197 2008/11/11 15:01:53 mha Exp $
77
*/
88
#include "postgres_fe.h"
99
#include "command.h"
@@ -64,9 +64,7 @@ static bool lookup_function_oid(PGconn *conn, const char *desc, Oid *foid);
6464
static bool get_create_function_cmd(PGconn *conn, Oid oid, PQExpBuffer buf);
6565
static void minimal_error_message(PGresult *res);
6666

67-
#ifdef USE_SSL
6867
static void printSSLInfo(void);
69-
#endif
7068

7169
#ifdef WIN32
7270
static void checkWin32Codepage(void);
@@ -1327,9 +1325,7 @@ connection_warnings(void)
13271325
#ifdef WIN32
13281326
checkWin32Codepage();
13291327
#endif
1330-
#ifdef USE_SSL
13311328
printSSLInfo();
1332-
#endif
13331329
}
13341330
}
13351331

@@ -1339,10 +1335,10 @@ connection_warnings(void)
13391335
*
13401336
* Prints information about the current SSL connection, if SSL is in use
13411337
*/
1342-
#ifdef USE_SSL
13431338
static void
13441339
printSSLInfo(void)
13451340
{
1341+
#ifdef USE_SSL
13461342
int sslbits = -1;
13471343
SSL *ssl;
13481344

@@ -1353,8 +1349,16 @@ printSSLInfo(void)
13531349
SSL_get_cipher_bits(ssl, &sslbits);
13541350
printf(_("SSL connection (cipher: %s, bits: %i)\n"),
13551351
SSL_get_cipher(ssl), sslbits);
1356-
}
1352+
#else
1353+
/*
1354+
* If psql is compiled without SSL but is using a libpq with SSL,
1355+
* we cannot figure out the specifics about the connection. But
1356+
* we know it's SSL secured.
1357+
*/
1358+
if (PQgetssl(pset.db))
1359+
printf(_("SSL connection (unknown cipher)\n"));
13571360
#endif
1361+
}
13581362

13591363

13601364
/*

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy