diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2003-06-08 17:43:00 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2003-06-08 17:43:00 +0000 |
commit | 6bdb7aa4db5571c83c87f5f761d4af4bc73e166e (patch) | |
tree | bf819a9fe25640b32f9899d0bf41b218df8d2d98 /src/interfaces/libpq/fe-auth.c | |
parent | 152ce7a4909aec35771e925fd7fa97bae1103763 (diff) | |
download | postgresql-6bdb7aa4db5571c83c87f5f761d4af4bc73e166e.tar.gz postgresql-6bdb7aa4db5571c83c87f5f761d4af4bc73e166e.zip |
libpq can now talk to either 3.0 or 2.0 protocol servers. It first tries
protocol 3, then falls back to 2 if postmaster rejects the startup packet
with an old-format error message. A side benefit of the rewrite is that
SSL-encrypted connections can now be made without blocking. (I think,
anyway, but do not have a good way to test.)
Diffstat (limited to 'src/interfaces/libpq/fe-auth.c')
-rw-r--r-- | src/interfaces/libpq/fe-auth.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/interfaces/libpq/fe-auth.c b/src/interfaces/libpq/fe-auth.c index 93fd5ca5810..d31ec6ff881 100644 --- a/src/interfaces/libpq/fe-auth.c +++ b/src/interfaces/libpq/fe-auth.c @@ -10,7 +10,7 @@ * exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes). * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.78 2003/05/16 04:58:03 tgl Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.79 2003/06/08 17:43:00 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -559,7 +559,11 @@ pg_password_sendauth(PGconn *conn, const char *password, AuthRequest areq) default: return STATUS_ERROR; } - ret = pqPacketSend(conn, 'p', crypt_pwd, strlen(crypt_pwd) + 1); + /* Packet has a message type as of protocol 3.0 */ + if (PG_PROTOCOL_MAJOR(conn->pversion) >= 3) + ret = pqPacketSend(conn, 'p', crypt_pwd, strlen(crypt_pwd) + 1); + else + ret = pqPacketSend(conn, 0, crypt_pwd, strlen(crypt_pwd) + 1); if (areq == AUTH_REQ_MD5) free(crypt_pwd); return ret; |