OSDN Git Service

Remove support for version-0 FE/BE protocol, per pghackers discussion.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 29 Aug 2002 03:22:01 +0000 (03:22 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 29 Aug 2002 03:22:01 +0000 (03:22 +0000)
This breaks support for 6.2 or older client libraries.

doc/src/sgml/release.sgml
src/backend/libpq/auth.c
src/backend/libpq/pqformat.c
src/include/libpq/libpq-be.h
src/include/libpq/pqcomm.h
src/interfaces/libpq/fe-auth.c

index 60c78d0..50df580 100644 (file)
@@ -1,5 +1,5 @@
 <!--
-$Header: /cvsroot/pgsql/doc/src/sgml/release.sgml,v 1.153 2002/08/29 00:17:01 tgl Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/release.sgml,v 1.154 2002/08/29 03:22:00 tgl Exp $
 -->
 
 <appendix id="release">
@@ -24,6 +24,7 @@ CDATA means the content is "SGML-free", so you can write without
 worries about funny characters.
 -->
 <literallayout><![CDATA[
+Client libraries older than 6.3 no longer supported (version 0 protocol removed)
 PREPARE statement allows caching query plans for interactive statements
 Type OPAQUE is now deprecated in favor of pseudo-types cstring, trigger, etc
 Standalone composite types can now be created with CREATE TYPE
index edca733..97c928d 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.85 2002/08/27 16:21:50 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.86 2002/08/29 03:22:01 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
 
 
 static void sendAuthRequest(Port *port, AuthRequest areq);
-static int     old_be_recvauth(Port *port);
-static int     map_old_to_new(Port *port, UserAuth old, int status);
 static void auth_failed(Port *port, int status);
 static int     recv_and_check_password_packet(Port *port);
-static int     recv_and_check_passwordv0(Port *port);
 
 char      *pg_krb_server_keyfile;
 
@@ -319,86 +316,6 @@ pg_krb5_recvauth(Port *port)
 
 
 /*
- * Handle a v0 password packet.
- */
-static int
-recv_and_check_passwordv0(Port *port)
-{
-       int32           len;
-       char       *buf;
-       PasswordPacketV0 *pp;
-       char       *user,
-                          *password,
-                          *cp,
-                          *start;
-       int                     status;
-
-       if (pq_getint(&len, 4) == EOF)
-               return STATUS_EOF;
-       len -= 4;
-       buf = palloc(len);
-       if (pq_getbytes(buf, len) == EOF)
-       {
-               pfree(buf);
-               return STATUS_EOF;
-       }
-
-       pp = (PasswordPacketV0 *) buf;
-
-       /*
-        * The packet is supposed to comprise the user name and the password
-        * as C strings.  Be careful to check that this is the case.
-        */
-       user = password = NULL;
-
-       len -= sizeof(pp->unused);
-
-       cp = start = pp->data;
-
-       while (len-- > 0)
-               if (*cp++ == '\0')
-               {
-                       if (user == NULL)
-                               user = start;
-                       else
-                       {
-                               password = start;
-                               break;
-                       }
-
-                       start = cp;
-               }
-
-       if (user == NULL || password == NULL)
-       {
-               elog(LOG, "pg_password_recvauth: badly formed password packet");
-               status = STATUS_ERROR;
-       }
-       else
-       {
-               UserAuth        saved;
-
-               /* Check the password. */
-
-               saved = port->auth_method;
-               port->auth_method = uaPassword;
-
-               status = md5_crypt_verify(port, user, password);
-
-               port->auth_method = saved;
-
-               /* Adjust the result if necessary. */
-               if (map_old_to_new(port, uaPassword, status) != STATUS_OK)
-                       status = STATUS_ERROR;
-       }
-
-       pfree(buf);
-
-       return status;
-}
-
-
-/*
  * Tell the user the authentication failed, but not (much about) why.
  *
  * There is a tradeoff here between security concerns and making life
@@ -481,16 +398,6 @@ ClientAuthentication(Port *port)
        if (hba_getauthmethod(port) != STATUS_OK)
                elog(FATAL, "Missing or erroneous pg_hba.conf file, see postmaster log for details");
 
-       /* Handle old style authentication. */
-       if (PG_PROTOCOL_MAJOR(port->proto) == 0)
-       {
-               status = old_be_recvauth(port);
-               if (status != STATUS_OK)
-                       auth_failed(port, status);
-               return;
-       }
-
-       /* Handle new style authentication. */
        switch (port->auth_method)
        {
                case uaReject:
@@ -828,90 +735,3 @@ recv_and_check_password_packet(Port *port)
        pfree(buf.data);
        return result;
 }
-
-
-/*
- * Server demux routine for incoming authentication information for protocol
- * version 0.
- */
-static int
-old_be_recvauth(Port *port)
-{
-       int                     status;
-       MsgType         msgtype = (MsgType) port->proto;
-
-       /* Handle the authentication that's offered. */
-       switch (msgtype)
-       {
-               case STARTUP_KRB4_MSG:
-                       status = map_old_to_new(port, uaKrb4, pg_krb4_recvauth(port));
-                       break;
-
-               case STARTUP_KRB5_MSG:
-                       status = map_old_to_new(port, uaKrb5, pg_krb5_recvauth(port));
-                       break;
-
-               case STARTUP_MSG:
-                       status = map_old_to_new(port, uaTrust, STATUS_OK);
-                       break;
-
-               case STARTUP_PASSWORD_MSG:
-                       status = recv_and_check_passwordv0(port);
-                       break;
-
-               default:
-                       elog(LOG, "Invalid startup message type: %u", msgtype);
-
-                       return STATUS_ERROR;
-       }
-
-       return status;
-}
-
-
-/*
- * The old style authentication has been done. Modify the result of this (eg.
- * allow the connection anyway, disallow it anyway, or use the result)
- * depending on what authentication we really want to use.
- */
-static int
-map_old_to_new(Port *port, UserAuth old, int status)
-{
-       switch (port->auth_method)
-       {
-               case uaMD5:
-               case uaCrypt:
-               case uaReject:
-#ifdef USE_PAM
-               case uaPAM:
-#endif   /* USE_PAM */
-                       status = STATUS_ERROR;
-                       break;
-
-               case uaKrb4:
-                       if (old != uaKrb4)
-                               status = STATUS_ERROR;
-                       break;
-
-               case uaKrb5:
-                       if (old != uaKrb5)
-                               status = STATUS_ERROR;
-                       break;
-
-               case uaTrust:
-                       status = STATUS_OK;
-                       break;
-
-               case uaIdent:
-                       status = authident(port);
-                       break;
-
-               case uaPassword:
-                       if (old != uaPassword)
-                               status = STATUS_ERROR;
-
-                       break;
-       }
-
-       return status;
-}
index 91c3669..01f8914 100644 (file)
@@ -16,7 +16,7 @@
  * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- *     $Id: pqformat.c,v 1.22 2002/08/08 06:32:26 ishii Exp $
+ *     $Id: pqformat.c,v 1.23 2002/08/29 03:22:01 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
 #include <endian.h>
 #endif
 
-#ifndef BYTE_ORDER
-#error BYTE_ORDER must be defined as LITTLE_ENDIAN, BIG_ENDIAN or PDP_ENDIAN
-#endif
-
-#if BYTE_ORDER == LITTLE_ENDIAN
-
-#define ntoh_s(n)      n
-#define ntoh_l(n)      n
-#define hton_s(n)      n
-#define hton_l(n)      n
-
-#else
-#if BYTE_ORDER == BIG_ENDIAN
-
-#define ntoh_s(n)      (uint16)((((uint16)n & 0x00ff) <<  8) | \
-                                (((uint16)n & 0xff00) >>  8))
-#define ntoh_l(n)      (uint32)((((uint32)n & 0x000000ff) << 24) | \
-                                (((uint32)n & 0x0000ff00) <<  8) | \
-                                (((uint32)n & 0x00ff0000) >>  8) | \
-                                (((uint32)n & 0xff000000) >> 24))
-#define hton_s(n)      (ntoh_s(n))
-#define hton_l(n)      (ntoh_l(n))
-
-#else
-#if BYTE_ORDER == PDP_ENDIAN
-
-#error PDP_ENDIAN macros not written yet
-
-#else
-
-#error BYTE_ORDER not defined as anything understood
-#endif
-#endif
-#endif
-
 
 /* --------------------------------
  *             pq_sendbyte             - append a raw byte to a StringInfo buffer
@@ -183,11 +148,11 @@ pq_sendint(StringInfo buf, int i, int b)
                        appendBinaryStringInfo(buf, (char *) &n8, 1);
                        break;
                case 2:
-                       n16 = ((PG_PROTOCOL_MAJOR(FrontendProtocol) == 0) ? hton_s(i) : htons((uint16) i));
+                       n16 = htons((uint16) i);
                        appendBinaryStringInfo(buf, (char *) &n16, 2);
                        break;
                case 4:
-                       n32 = ((PG_PROTOCOL_MAJOR(FrontendProtocol) == 0) ? hton_l(i) : htonl((uint32) i));
+                       n32 = htonl((uint32) i);
                        appendBinaryStringInfo(buf, (char *) &n32, 4);
                        break;
                default:
@@ -261,13 +226,11 @@ pq_getint(int *result, int b)
                        break;
                case 2:
                        status = pq_getbytes((char *) &n16, 2);
-                       *result = (int) ((PG_PROTOCOL_MAJOR(FrontendProtocol) == 0) ?
-                                                        ntoh_s(n16) : ntohs(n16));
+                       *result = (int) (ntohs(n16));
                        break;
                case 4:
                        status = pq_getbytes((char *) &n32, 4);
-                       *result = (int) ((PG_PROTOCOL_MAJOR(FrontendProtocol) == 0) ?
-                                                        ntoh_l(n32) : ntohl(n32));
+                       *result = (int) (ntohl(n32));
                        break;
                default:
 
index 1a23820..e9d906d 100644 (file)
@@ -11,7 +11,7 @@
  * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: libpq-be.h,v 1.33 2002/08/18 03:03:26 momjian Exp $
+ * $Id: libpq-be.h,v 1.34 2002/08/29 03:22:01 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
 #endif
 
 
-/* Protocol v0 password packet. */
-
-typedef struct PasswordPacketV0
-{
-       uint32          unused;
-       char            data[288];              /* User and password as strings. */
-} PasswordPacketV0;
-
-
 /*
- * This is used by the postmaster in its communication with frontends. It is
+ * This is used by the postmaster in its communication with frontends. It
  * contains all state information needed during this communication before the
  * backend is run.
  */
index a2b6961..2bd0d37 100644 (file)
@@ -9,7 +9,7 @@
  * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: pqcomm.h,v 1.68 2002/08/27 16:21:51 momjian Exp $
+ * $Id: pqcomm.h,v 1.69 2002/08/29 03:22:01 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -93,7 +93,7 @@ typedef union SockAddr
 
 /* The earliest and latest frontend/backend protocol version supported. */
 
-#define PG_PROTOCOL_EARLIEST   PG_PROTOCOL(0,0)
+#define PG_PROTOCOL_EARLIEST   PG_PROTOCOL(1,0)
 #define PG_PROTOCOL_LATEST     PG_PROTOCOL(2,0)
 
 /*
@@ -127,6 +127,9 @@ typedef uint32 PacketLen;
 
 typedef uint32 ProtocolVersion; /* Fe/Be protocol version number */
 
+typedef ProtocolVersion MsgType;
+
+
 typedef struct StartupPacket
 {
        ProtocolVersion protoVersion;           /* Protocol version */
@@ -153,16 +156,6 @@ extern bool Db_user_namespace;
 typedef uint32 AuthRequest;
 
 
-/* This next section is to maintain compatibility with protocol v0.0. */
-
-#define STARTUP_MSG            7               /* Initialise a connection */
-#define STARTUP_KRB4_MSG       10      /* krb4 session follows */
-#define STARTUP_KRB5_MSG       11      /* krb5 session follows */
-#define STARTUP_PASSWORD_MSG   14              /* Password follows */
-
-typedef ProtocolVersion MsgType;
-
-
 /* A client can also send a cancel-current-operation request to the postmaster.
  * This is uglier than sending it directly to the client's backend, but it
  * avoids depending on out-of-band communication facilities.
index cd5cd7d..317cf77 100644 (file)
@@ -10,7 +10,7 @@
  * exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes).
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.68 2002/07/20 05:43:31 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.69 2002/08/29 03:22:01 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
  * common definitions for generic fe/be routines
  */
 
+#define STARTUP_MSG            7               /* Initialise a connection */
+#define STARTUP_KRB4_MSG       10      /* krb4 session follows */
+#define STARTUP_KRB5_MSG       11      /* krb5 session follows */
+#define STARTUP_PASSWORD_MSG   14              /* Password follows */
+
 struct authsvc
 {
        const char *name;                       /* service nickname (for command line) */