Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 5241a62

Browse files
committed
Remove support for version-0 FE/BE protocol, per pghackers discussion.
This breaks support for 6.2 or older client libraries.
1 parent 8a24a55 commit 5241a62

File tree

6 files changed

+21
-248
lines changed

6 files changed

+21
-248
lines changed

doc/src/sgml/release.sgml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/release.sgml,v 1.153 2002/08/29 00:17:01 tgl Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/release.sgml,v 1.154 2002/08/29 03:22:00 tgl Exp $
33
-->
44

55
<appendix id="release">
@@ -24,6 +24,7 @@ CDATA means the content is "SGML-free", so you can write without
2424
worries about funny characters.
2525
-->
2626
<literallayout><![CDATA[
27+
Client libraries older than 6.3 no longer supported (version 0 protocol removed)
2728
PREPARE statement allows caching query plans for interactive statements
2829
Type OPAQUE is now deprecated in favor of pseudo-types cstring, trigger, etc
2930
Standalone composite types can now be created with CREATE TYPE

src/backend/libpq/auth.c

Lines changed: 1 addition & 181 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.85 2002/08/27 16:21:50 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.86 2002/08/29 03:22:01 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -37,11 +37,8 @@
3737

3838

3939
static void sendAuthRequest(Port *port, AuthRequest areq);
40-
static int old_be_recvauth(Port *port);
41-
static int map_old_to_new(Port *port, UserAuth old, int status);
4240
static void auth_failed(Port *port, int status);
4341
static int recv_and_check_password_packet(Port *port);
44-
static int recv_and_check_passwordv0(Port *port);
4542

4643
char *pg_krb_server_keyfile;
4744

@@ -318,86 +315,6 @@ pg_krb5_recvauth(Port *port)
318315
#endif /* KRB5 */
319316

320317

321-
/*
322-
* Handle a v0 password packet.
323-
*/
324-
static int
325-
recv_and_check_passwordv0(Port *port)
326-
{
327-
int32 len;
328-
char *buf;
329-
PasswordPacketV0 *pp;
330-
char *user,
331-
*password,
332-
*cp,
333-
*start;
334-
int status;
335-
336-
if (pq_getint(&len, 4) == EOF)
337-
return STATUS_EOF;
338-
len -= 4;
339-
buf = palloc(len);
340-
if (pq_getbytes(buf, len) == EOF)
341-
{
342-
pfree(buf);
343-
return STATUS_EOF;
344-
}
345-
346-
pp = (PasswordPacketV0 *) buf;
347-
348-
/*
349-
* The packet is supposed to comprise the user name and the password
350-
* as C strings. Be careful to check that this is the case.
351-
*/
352-
user = password = NULL;
353-
354-
len -= sizeof(pp->unused);
355-
356-
cp = start = pp->data;
357-
358-
while (len-- > 0)
359-
if (*cp++ == '\0')
360-
{
361-
if (user == NULL)
362-
user = start;
363-
else
364-
{
365-
password = start;
366-
break;
367-
}
368-
369-
start = cp;
370-
}
371-
372-
if (user == NULL || password == NULL)
373-
{
374-
elog(LOG, "pg_password_recvauth: badly formed password packet");
375-
status = STATUS_ERROR;
376-
}
377-
else
378-
{
379-
UserAuth saved;
380-
381-
/* Check the password. */
382-
383-
saved = port->auth_method;
384-
port->auth_method = uaPassword;
385-
386-
status = md5_crypt_verify(port, user, password);
387-
388-
port->auth_method = saved;
389-
390-
/* Adjust the result if necessary. */
391-
if (map_old_to_new(port, uaPassword, status) != STATUS_OK)
392-
status = STATUS_ERROR;
393-
}
394-
395-
pfree(buf);
396-
397-
return status;
398-
}
399-
400-
401318
/*
402319
* Tell the user the authentication failed, but not (much about) why.
403320
*
@@ -481,16 +398,6 @@ ClientAuthentication(Port *port)
481398
if (hba_getauthmethod(port) != STATUS_OK)
482399
elog(FATAL, "Missing or erroneous pg_hba.conf file, see postmaster log for details");
483400

484-
/* Handle old style authentication. */
485-
if (PG_PROTOCOL_MAJOR(port->proto) == 0)
486-
{
487-
status = old_be_recvauth(port);
488-
if (status != STATUS_OK)
489-
auth_failed(port, status);
490-
return;
491-
}
492-
493-
/* Handle new style authentication. */
494401
switch (port->auth_method)
495402
{
496403
case uaReject:
@@ -828,90 +735,3 @@ recv_and_check_password_packet(Port *port)
828735
pfree(buf.data);
829736
return result;
830737
}
831-
832-
833-
/*
834-
* Server demux routine for incoming authentication information for protocol
835-
* version 0.
836-
*/
837-
static int
838-
old_be_recvauth(Port *port)
839-
{
840-
int status;
841-
MsgType msgtype = (MsgType) port->proto;
842-
843-
/* Handle the authentication that's offered. */
844-
switch (msgtype)
845-
{
846-
case STARTUP_KRB4_MSG:
847-
status = map_old_to_new(port, uaKrb4, pg_krb4_recvauth(port));
848-
break;
849-
850-
case STARTUP_KRB5_MSG:
851-
status = map_old_to_new(port, uaKrb5, pg_krb5_recvauth(port));
852-
break;
853-
854-
case STARTUP_MSG:
855-
status = map_old_to_new(port, uaTrust, STATUS_OK);
856-
break;
857-
858-
case STARTUP_PASSWORD_MSG:
859-
status = recv_and_check_passwordv0(port);
860-
break;
861-
862-
default:
863-
elog(LOG, "Invalid startup message type: %u", msgtype);
864-
865-
return STATUS_ERROR;
866-
}
867-
868-
return status;
869-
}
870-
871-
872-
/*
873-
* The old style authentication has been done. Modify the result of this (eg.
874-
* allow the connection anyway, disallow it anyway, or use the result)
875-
* depending on what authentication we really want to use.
876-
*/
877-
static int
878-
map_old_to_new(Port *port, UserAuth old, int status)
879-
{
880-
switch (port->auth_method)
881-
{
882-
case uaMD5:
883-
case uaCrypt:
884-
case uaReject:
885-
#ifdef USE_PAM
886-
case uaPAM:
887-
#endif /* USE_PAM */
888-
status = STATUS_ERROR;
889-
break;
890-
891-
case uaKrb4:
892-
if (old != uaKrb4)
893-
status = STATUS_ERROR;
894-
break;
895-
896-
case uaKrb5:
897-
if (old != uaKrb5)
898-
status = STATUS_ERROR;
899-
break;
900-
901-
case uaTrust:
902-
status = STATUS_OK;
903-
break;
904-
905-
case uaIdent:
906-
status = authident(port);
907-
break;
908-
909-
case uaPassword:
910-
if (old != uaPassword)
911-
status = STATUS_ERROR;
912-
913-
break;
914-
}
915-
916-
return status;
917-
}

src/backend/libpq/pqformat.c

Lines changed: 5 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
1717
* Portions Copyright (c) 1994, Regents of the University of California
1818
*
19-
* $Id: pqformat.c,v 1.22 2002/08/08 06:32:26 ishii Exp $
19+
* $Id: pqformat.c,v 1.23 2002/08/29 03:22:01 tgl Exp $
2020
*
2121
*-------------------------------------------------------------------------
2222
*/
@@ -57,41 +57,6 @@
5757
#include <endian.h>
5858
#endif
5959

60-
#ifndef BYTE_ORDER
61-
#error BYTE_ORDER must be defined as LITTLE_ENDIAN, BIG_ENDIAN or PDP_ENDIAN
62-
#endif
63-
64-
#if BYTE_ORDER == LITTLE_ENDIAN
65-
66-
#define ntoh_s(n) n
67-
#define ntoh_l(n) n
68-
#define hton_s(n) n
69-
#define hton_l(n) n
70-
71-
#else
72-
#if BYTE_ORDER == BIG_ENDIAN
73-
74-
#define ntoh_s(n) (uint16)((((uint16)n & 0x00ff) << 8) | \
75-
(((uint16)n & 0xff00) >> 8))
76-
#define ntoh_l(n) (uint32)((((uint32)n & 0x000000ff) << 24) | \
77-
(((uint32)n & 0x0000ff00) << 8) | \
78-
(((uint32)n & 0x00ff0000) >> 8) | \
79-
(((uint32)n & 0xff000000) >> 24))
80-
#define hton_s(n) (ntoh_s(n))
81-
#define hton_l(n) (ntoh_l(n))
82-
83-
#else
84-
#if BYTE_ORDER == PDP_ENDIAN
85-
86-
#error PDP_ENDIAN macros not written yet
87-
88-
#else
89-
90-
#error BYTE_ORDER not defined as anything understood
91-
#endif
92-
#endif
93-
#endif
94-
9560

9661
/* --------------------------------
9762
* pq_sendbyte - append a raw byte to a StringInfo buffer
@@ -183,11 +148,11 @@ pq_sendint(StringInfo buf, int i, int b)
183148
appendBinaryStringInfo(buf, (char *) &n8, 1);
184149
break;
185150
case 2:
186-
n16 = ((PG_PROTOCOL_MAJOR(FrontendProtocol) == 0) ? hton_s(i) : htons((uint16) i));
151+
n16 = htons((uint16) i);
187152
appendBinaryStringInfo(buf, (char *) &n16, 2);
188153
break;
189154
case 4:
190-
n32 = ((PG_PROTOCOL_MAJOR(FrontendProtocol) == 0) ? hton_l(i) : htonl((uint32) i));
155+
n32 = htonl((uint32) i);
191156
appendBinaryStringInfo(buf, (char *) &n32, 4);
192157
break;
193158
default:
@@ -261,13 +226,11 @@ pq_getint(int *result, int b)
261226
break;
262227
case 2:
263228
status = pq_getbytes((char *) &n16, 2);
264-
*result = (int) ((PG_PROTOCOL_MAJOR(FrontendProtocol) == 0) ?
265-
ntoh_s(n16) : ntohs(n16));
229+
*result = (int) (ntohs(n16));
266230
break;
267231
case 4:
268232
status = pq_getbytes((char *) &n32, 4);
269-
*result = (int) ((PG_PROTOCOL_MAJOR(FrontendProtocol) == 0) ?
270-
ntoh_l(n32) : ntohl(n32));
233+
*result = (int) (ntohl(n32));
271234
break;
272235
default:
273236

src/include/libpq/libpq-be.h

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
1212
* Portions Copyright (c) 1994, Regents of the University of California
1313
*
14-
* $Id: libpq-be.h,v 1.33 2002/08/18 03:03:26 momjian Exp $
14+
* $Id: libpq-be.h,v 1.34 2002/08/29 03:22:01 tgl Exp $
1515
*
1616
*-------------------------------------------------------------------------
1717
*/
@@ -29,17 +29,8 @@
2929
#endif
3030

3131

32-
/* Protocol v0 password packet. */
33-
34-
typedef struct PasswordPacketV0
35-
{
36-
uint32 unused;
37-
char data[288]; /* User and password as strings. */
38-
} PasswordPacketV0;
39-
40-
4132
/*
42-
* This is used by the postmaster in its communication with frontends. It is
33+
* This is used by the postmaster in its communication with frontends. It
4334
* contains all state information needed during this communication before the
4435
* backend is run.
4536
*/

src/include/libpq/pqcomm.h

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
1010
* Portions Copyright (c) 1994, Regents of the University of California
1111
*
12-
* $Id: pqcomm.h,v 1.68 2002/08/27 16:21:51 momjian Exp $
12+
* $Id: pqcomm.h,v 1.69 2002/08/29 03:22:01 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -93,7 +93,7 @@ typedef union SockAddr
9393

9494
/* The earliest and latest frontend/backend protocol version supported. */
9595

96-
#define PG_PROTOCOL_EARLIEST PG_PROTOCOL(0,0)
96+
#define PG_PROTOCOL_EARLIEST PG_PROTOCOL(1,0)
9797
#define PG_PROTOCOL_LATEST PG_PROTOCOL(2,0)
9898

9999
/*
@@ -127,6 +127,9 @@ typedef uint32 PacketLen;
127127

128128
typedef uint32 ProtocolVersion; /* Fe/Be protocol version number */
129129

130+
typedef ProtocolVersion MsgType;
131+
132+
130133
typedef struct StartupPacket
131134
{
132135
ProtocolVersion protoVersion; /* Protocol version */
@@ -153,16 +156,6 @@ extern bool Db_user_namespace;
153156
typedef uint32 AuthRequest;
154157

155158

156-
/* This next section is to maintain compatibility with protocol v0.0. */
157-
158-
#define STARTUP_MSG 7 /* Initialise a connection */
159-
#define STARTUP_KRB4_MSG 10 /* krb4 session follows */
160-
#define STARTUP_KRB5_MSG 11 /* krb5 session follows */
161-
#define STARTUP_PASSWORD_MSG 14 /* Password follows */
162-
163-
typedef ProtocolVersion MsgType;
164-
165-
166159
/* A client can also send a cancel-current-operation request to the postmaster.
167160
* This is uglier than sending it directly to the client's backend, but it
168161
* avoids depending on out-of-band communication facilities.

0 commit comments

Comments
 (0)