Commit cb7fb3ca authored by Tom Lane's avatar Tom Lane

First phase of FE/BE protocol modifications: new StartupPacket layout

with variable-width fields.  No more truncation of long user names.
Also, libpq can now send its environment-variable-driven SET commands
as part of the startup packet, saving round trips to server.
parent 76fd678c
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/libpq.sgml,v 1.117 2003/03/25 16:15:37 petere Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/libpq.sgml,v 1.118 2003/04/17 22:26:00 tgl Exp $
--> -->
<chapter id="libpq"> <chapter id="libpq">
...@@ -193,7 +193,7 @@ PGconn *PQconnectdb(const char *conninfo); ...@@ -193,7 +193,7 @@ PGconn *PQconnectdb(const char *conninfo);
<term><literal>tty</literal></term> <term><literal>tty</literal></term>
<listitem> <listitem>
<para> <para>
A file or <acronym>TTY</acronym> for optional debug output from the server. Ignored (formerly, this specified where to send server debug output).
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -669,6 +669,9 @@ char *PQport(const PGconn *conn); ...@@ -669,6 +669,9 @@ char *PQport(const PGconn *conn);
<listitem> <listitem>
<para> <para>
Returns the debug <acronym>TTY</acronym> of the connection. Returns the debug <acronym>TTY</acronym> of the connection.
(This is obsolete, since the server no longer pays attention
to the <acronym>TTY</acronym> setting, but the function remains
for backwards compatibility.)
<synopsis> <synopsis>
char *PQtty(const PGconn *conn); char *PQtty(const PGconn *conn);
</synopsis> </synopsis>
...@@ -2365,12 +2368,6 @@ the <productname>PostgreSQL</productname> server. ...@@ -2365,12 +2368,6 @@ the <productname>PostgreSQL</productname> server.
</listitem> </listitem>
<listitem> <listitem>
<para> <para>
<envar>PGTTY</envar> sets the file or <acronym>TTY</> on which debugging
messages from the server are displayed.
</para>
</listitem>
<listitem>
<para>
<envar>PGREQUIRESSL</envar> sets whether or not the connection must be <envar>PGREQUIRESSL</envar> sets whether or not the connection must be
made over <acronym>SSL</acronym>. If set to made over <acronym>SSL</acronym>. If set to
<quote>1</quote>, <application>libpq</> <quote>1</quote>, <application>libpq</>
...@@ -2678,7 +2675,7 @@ main() ...@@ -2678,7 +2675,7 @@ main()
pgport = NULL; /* port of the backend server */ pgport = NULL; /* port of the backend server */
pgoptions = NULL; /* special options to start up the backend pgoptions = NULL; /* special options to start up the backend
* server */ * server */
pgtty = NULL; /* debugging tty for the backend server */ pgtty = NULL; /* unused */
dbName = "template1"; dbName = "template1";
/* make a connection to the database */ /* make a connection to the database */
...@@ -2826,7 +2823,7 @@ main() ...@@ -2826,7 +2823,7 @@ main()
pgport = NULL; /* port of the backend server */ pgport = NULL; /* port of the backend server */
pgoptions = NULL; /* special options to start up the backend pgoptions = NULL; /* special options to start up the backend
* server */ * server */
pgtty = NULL; /* debugging tty for the backend server */ pgtty = NULL; /* unused */
dbName = getenv("USER"); /* change this to the name of your test dbName = getenv("USER"); /* change this to the name of your test
* database */ * database */
...@@ -2950,7 +2947,7 @@ main() ...@@ -2950,7 +2947,7 @@ main()
pgport = NULL; /* port of the backend server */ pgport = NULL; /* port of the backend server */
pgoptions = NULL; /* special options to start up the backend pgoptions = NULL; /* special options to start up the backend
* server */ * server */
pgtty = NULL; /* debugging tty for the backend server */ pgtty = NULL; /* unused */
dbName = getenv("USER"); /* change this to the name of your test dbName = getenv("USER"); /* change this to the name of your test
* database */ * database */
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.97 2003/02/14 14:05:00 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.98 2003/04/17 22:26:01 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
#include "libpq/crypt.h" #include "libpq/crypt.h"
#include "libpq/hba.h" #include "libpq/hba.h"
#include "libpq/libpq.h" #include "libpq/libpq.h"
#include "libpq/password.h"
#include "libpq/pqcomm.h" #include "libpq/pqcomm.h"
#include "libpq/pqformat.h" #include "libpq/pqformat.h"
#include "miscadmin.h" #include "miscadmin.h"
...@@ -378,7 +377,7 @@ auth_failed(Port *port, int status) ...@@ -378,7 +377,7 @@ auth_failed(Port *port, int status)
} }
elog(FATAL, "%s authentication failed for user \"%s\"", elog(FATAL, "%s authentication failed for user \"%s\"",
authmethod, port->user); authmethod, port->user_name);
/* doesn't return */ /* doesn't return */
} }
...@@ -427,7 +426,7 @@ ClientAuthentication(Port *port) ...@@ -427,7 +426,7 @@ ClientAuthentication(Port *port)
elog(FATAL, elog(FATAL,
"No pg_hba.conf entry for host %s, user %s, database %s", "No pg_hba.conf entry for host %s, user %s, database %s",
hostinfo, port->user, port->database); hostinfo, port->user_name, port->database_name);
break; break;
} }
...@@ -638,10 +637,12 @@ CheckPAMAuth(Port *port, char *user, char *password) ...@@ -638,10 +637,12 @@ CheckPAMAuth(Port *port, char *user, char *password)
* not allocated */ * not allocated */
/* Optionally, one can set the service name in pg_hba.conf */ /* Optionally, one can set the service name in pg_hba.conf */
if (port->auth_arg[0] == '\0') if (port->auth_arg && port->auth_arg[0] != '\0')
retval = pam_start(PGSQL_PAM_SERVICE, "pgsql@", &pam_passw_conv, &pamh); retval = pam_start(port->auth_arg, "pgsql@",
&pam_passw_conv, &pamh);
else else
retval = pam_start(port->auth_arg, "pgsql@", &pam_passw_conv, &pamh); retval = pam_start(PGSQL_PAM_SERVICE, "pgsql@",
&pam_passw_conv, &pamh);
if (retval != PAM_SUCCESS) if (retval != PAM_SUCCESS)
{ {
...@@ -741,7 +742,7 @@ recv_and_check_password_packet(Port *port) ...@@ -741,7 +742,7 @@ recv_and_check_password_packet(Port *port)
/* Do not echo password to logs, for security. */ /* Do not echo password to logs, for security. */
elog(DEBUG5, "received password packet"); elog(DEBUG5, "received password packet");
result = md5_crypt_verify(port, port->user, buf.data); result = md5_crypt_verify(port, port->user_name, buf.data);
pfree(buf.data); pfree(buf.data);
return result; return result;
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Header: /cvsroot/pgsql/src/backend/libpq/crypt.c,v 1.51 2002/12/05 18:52:42 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/libpq/crypt.c,v 1.52 2003/04/17 22:26:01 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -87,15 +87,19 @@ md5_crypt_verify(const Port *port, const char *user, char *client_pass) ...@@ -87,15 +87,19 @@ md5_crypt_verify(const Port *port, const char *user, char *client_pass)
/* pg_shadow plain, double-encrypt */ /* pg_shadow plain, double-encrypt */
char *crypt_pwd2 = palloc(MD5_PASSWD_LEN + 1); char *crypt_pwd2 = palloc(MD5_PASSWD_LEN + 1);
if (!EncryptMD5(shadow_pass, port->user, strlen(port->user), if (!EncryptMD5(shadow_pass,
port->user_name,
strlen(port->user_name),
crypt_pwd2)) crypt_pwd2))
{ {
pfree(crypt_pwd); pfree(crypt_pwd);
pfree(crypt_pwd2); pfree(crypt_pwd2);
return STATUS_ERROR; return STATUS_ERROR;
} }
if (!EncryptMD5(crypt_pwd2 + strlen("md5"), port->md5Salt, if (!EncryptMD5(crypt_pwd2 + strlen("md5"),
sizeof(port->md5Salt), crypt_pwd)) port->md5Salt,
sizeof(port->md5Salt),
crypt_pwd))
{ {
pfree(crypt_pwd); pfree(crypt_pwd);
pfree(crypt_pwd2); pfree(crypt_pwd2);
...@@ -117,7 +121,9 @@ md5_crypt_verify(const Port *port, const char *user, char *client_pass) ...@@ -117,7 +121,9 @@ md5_crypt_verify(const Port *port, const char *user, char *client_pass)
{ {
/* Encrypt user-supplied password to match MD5 in pg_shadow */ /* Encrypt user-supplied password to match MD5 in pg_shadow */
crypt_client_pass = palloc(MD5_PASSWD_LEN + 1); crypt_client_pass = palloc(MD5_PASSWD_LEN + 1);
if (!EncryptMD5(client_pass, port->user, strlen(port->user), if (!EncryptMD5(client_pass,
port->user_name,
strlen(port->user_name),
crypt_client_pass)) crypt_client_pass))
{ {
pfree(crypt_client_pass); pfree(crypt_client_pass);
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.98 2003/04/13 04:07:17 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.99 2003/04/17 22:26:01 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -471,15 +471,17 @@ check_db(char *dbname, char *user, char *param_str) ...@@ -471,15 +471,17 @@ check_db(char *dbname, char *user, char *param_str)
/* /*
* Scan the rest of a host record (after the mask field) * Scan the rest of a host record (after the mask field)
* and return the interpretation of it as *userauth_p, auth_arg, and * and return the interpretation of it as *userauth_p, *auth_arg_p, and
* *error_p. line points to the next token of the line. * *error_p. line points to the next token of the line.
*/ */
static void static void
parse_hba_auth(List *line, UserAuth *userauth_p, char *auth_arg, parse_hba_auth(List *line, UserAuth *userauth_p, char **auth_arg_p,
bool *error_p) bool *error_p)
{ {
char *token; char *token;
*auth_arg_p = NULL;
if (!line) if (!line)
*error_p = true; *error_p = true;
else else
...@@ -514,11 +516,10 @@ parse_hba_auth(List *line, UserAuth *userauth_p, char *auth_arg, ...@@ -514,11 +516,10 @@ parse_hba_auth(List *line, UserAuth *userauth_p, char *auth_arg,
if (!*error_p) if (!*error_p)
{ {
/* Get the authentication argument token, if any */ /* Get the authentication argument token, if any */
if (!line) if (line)
auth_arg[0] = '\0';
else
{ {
StrNCpy(auth_arg, lfirst(line), MAX_AUTH_ARG - 1); token = lfirst(line);
*auth_arg_p = pstrdup(token);
/* If there is more on the line, it is an error */ /* If there is more on the line, it is an error */
if (lnext(line)) if (lnext(line))
*error_p = true; *error_p = true;
...@@ -570,7 +571,7 @@ parse_hba(List *line, hbaPort *port, bool *found_p, bool *error_p) ...@@ -570,7 +571,7 @@ parse_hba(List *line, hbaPort *port, bool *found_p, bool *error_p)
goto hba_syntax; goto hba_syntax;
/* Read the rest of the line. */ /* Read the rest of the line. */
parse_hba_auth(line, &port->auth_method, port->auth_arg, error_p); parse_hba_auth(line, &port->auth_method, &port->auth_arg, error_p);
if (*error_p) if (*error_p)
goto hba_syntax; goto hba_syntax;
...@@ -642,7 +643,7 @@ parse_hba(List *line, hbaPort *port, bool *found_p, bool *error_p) ...@@ -642,7 +643,7 @@ parse_hba(List *line, hbaPort *port, bool *found_p, bool *error_p)
line = lnext(line); line = lnext(line);
if (!line) if (!line)
goto hba_syntax; goto hba_syntax;
parse_hba_auth(line, &port->auth_method, port->auth_arg, error_p); parse_hba_auth(line, &port->auth_method, &port->auth_arg, error_p);
if (*error_p) if (*error_p)
goto hba_syntax; goto hba_syntax;
...@@ -654,9 +655,9 @@ parse_hba(List *line, hbaPort *port, bool *found_p, bool *error_p) ...@@ -654,9 +655,9 @@ parse_hba(List *line, hbaPort *port, bool *found_p, bool *error_p)
else else
goto hba_syntax; goto hba_syntax;
if (!check_db(port->database, port->user, db)) if (!check_db(port->database_name, port->user_name, db))
return; return;
if (!check_user(port->user, user)) if (!check_user(port->user_name, user))
return; return;
/* Success */ /* Success */
...@@ -946,7 +947,7 @@ check_ident_usermap(const char *usermap_name, ...@@ -946,7 +947,7 @@ check_ident_usermap(const char *usermap_name,
bool found_entry = false, bool found_entry = false,
error = false; error = false;
if (usermap_name[0] == '\0') if (usermap_name == NULL || usermap_name[0] == '\0')
{ {
elog(LOG, "check_ident_usermap: hba configuration file does not " elog(LOG, "check_ident_usermap: hba configuration file does not "
"have the usermap field filled in in the entry that pertains " "have the usermap field filled in in the entry that pertains "
...@@ -1387,7 +1388,7 @@ authident(hbaPort *port) ...@@ -1387,7 +1388,7 @@ authident(hbaPort *port)
return STATUS_ERROR; return STATUS_ERROR;
} }
if (check_ident_usermap(port->auth_arg, port->user, ident_user)) if (check_ident_usermap(port->auth_arg, port->user_name, ident_user))
return STATUS_OK; return STATUS_OK;
else else
return STATUS_ERROR; return STATUS_ERROR;
......
This diff is collapsed.
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.320 2003/03/24 18:33:52 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.321 2003/04/17 22:26:01 tgl Exp $
* *
* NOTES * NOTES
* this is the "main" module of the postgres backend and * this is the "main" module of the postgres backend and
...@@ -1611,6 +1611,26 @@ PostgresMain(int argc, char *argv[], const char *username) ...@@ -1611,6 +1611,26 @@ PostgresMain(int argc, char *argv[], const char *username)
if (debug_flag >= 5) if (debug_flag >= 5)
SetConfigOption("debug_print_rewritten", "true", ctx, gucsource); SetConfigOption("debug_print_rewritten", "true", ctx, gucsource);
/*
* Process any additional GUC variable settings passed in startup packet.
*/
if (MyProcPort != NULL)
{
List *gucopts = MyProcPort->guc_options;
while (gucopts)
{
char *name,
*value;
name = lfirst(gucopts);
gucopts = lnext(gucopts);
value = lfirst(gucopts);
gucopts = lnext(gucopts);
SetConfigOption(name, value, PGC_BACKEND, PGC_S_CLIENT);
}
}
/* /*
* Post-processing for command line options. * Post-processing for command line options.
*/ */
...@@ -1795,7 +1815,7 @@ PostgresMain(int argc, char *argv[], const char *username) ...@@ -1795,7 +1815,7 @@ PostgresMain(int argc, char *argv[], const char *username)
if (!IsUnderPostmaster) if (!IsUnderPostmaster)
{ {
puts("\nPOSTGRES backend interactive interface "); puts("\nPOSTGRES backend interactive interface ");
puts("$Revision: 1.320 $ $Date: 2003/03/24 18:33:52 $\n"); puts("$Revision: 1.321 $ $Date: 2003/04/17 22:26:01 $\n");
} }
/* /*
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: auth.h,v 1.21 2002/06/20 20:29:49 momjian Exp $ * $Id: auth.h,v 1.22 2003/04/17 22:26:01 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
*---------------------------------------------------------------- *----------------------------------------------------------------
*/ */
void ClientAuthentication(Port *port); extern void ClientAuthentication(Port *port);
#define PG_KRB4_VERSION "PGVER4.1" /* at most KRB_SENDAUTH_VLEN chars */ #define PG_KRB4_VERSION "PGVER4.1" /* at most KRB_SENDAUTH_VLEN chars */
#define PG_KRB5_VERSION "PGVER5.1" #define PG_KRB5_VERSION "PGVER5.1"
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* Interface to hba.c * Interface to hba.c
* *
* *
* $Id: hba.h,v 1.32 2002/04/04 04:25:54 momjian Exp $ * $Id: hba.h,v 1.33 2003/04/17 22:26:01 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -26,8 +26,6 @@ ...@@ -26,8 +26,6 @@
#define IDENT_PORT 113 #define IDENT_PORT 113
/* Standard TCP port number for Ident service. Assigned by IANA */ /* Standard TCP port number for Ident service. Assigned by IANA */
#define MAX_AUTH_ARG 80 /* Max size of an authentication arg */
typedef enum UserAuth typedef enum UserAuth
{ {
uaReject, uaReject,
......
...@@ -11,15 +11,13 @@ ...@@ -11,15 +11,13 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: libpq-be.h,v 1.34 2002/08/29 03:22:01 tgl Exp $ * $Id: libpq-be.h,v 1.35 2003/04/17 22:26:01 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
#ifndef LIBPQ_BE_H #ifndef LIBPQ_BE_H
#define LIBPQ_BE_H #define LIBPQ_BE_H
#include <sys/types.h>
#include "libpq/hba.h" #include "libpq/hba.h"
#include "libpq/pqcomm.h" #include "libpq/pqcomm.h"
...@@ -32,29 +30,36 @@ ...@@ -32,29 +30,36 @@
/* /*
* This is used by the postmaster in its communication with frontends. It * This is used by the postmaster in its communication with frontends. It
* contains all state information needed during this communication before the * contains all state information needed during this communication before the
* backend is run. * backend is run. The Port structure is kept in malloc'd memory and is
* still available when a backend is running (see MyProcPort). The data
* it points to must also be malloc'd, or else palloc'd in TopMemoryContext,
* so that it survives into PostgresMain execution!
*/ */
typedef struct Port typedef struct Port
{ {
int sock; /* File descriptor */ int sock; /* File descriptor */
ProtocolVersion proto; /* FE/BE protocol version */
SockAddr laddr; /* local addr (postmaster) */ SockAddr laddr; /* local addr (postmaster) */
SockAddr raddr; /* remote addr (client) */ SockAddr raddr; /* remote addr (client) */
char md5Salt[4]; /* Password salt */
char cryptSalt[2]; /* Password salt */
/* /*
* Information that needs to be held during the fe/be authentication * Information that needs to be saved from the startup packet and passed
* handshake. * into backend execution. "char *" fields are NULL if not set.
* guc_options points to a List of alternating option names and values.
*/ */
char *database_name;
char *user_name;
char *cmdline_options;
List *guc_options;
ProtocolVersion proto; /*
char database[SM_DATABASE + 1]; * Information that needs to be held during the authentication cycle.
char user[SM_DATABASE_USER + 1]; */
char options[SM_OPTIONS + 1];
char tty[SM_TTY + 1];
char auth_arg[MAX_AUTH_ARG];
UserAuth auth_method; UserAuth auth_method;
char *auth_arg;
char md5Salt[4]; /* Password salt */
char cryptSalt[2]; /* Password salt */
/* /*
* SSL structures * SSL structures
......
#ifndef PASSWORD_H
#define PASSWORD_H
int verify_password(const Port *port, const char *user, const char *password);
#endif
...@@ -9,14 +9,13 @@ ...@@ -9,14 +9,13 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: pqcomm.h,v 1.75 2003/01/06 09:58:36 petere Exp $ * $Id: pqcomm.h,v 1.76 2003/04/17 22:26:01 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
#ifndef PQCOMM_H #ifndef PQCOMM_H
#define PQCOMM_H #define PQCOMM_H
#include <sys/types.h>
#ifdef WIN32 #ifdef WIN32
#include <winsock.h> #include <winsock.h>
/* workaround for clashing defines of "ERROR" */ /* workaround for clashing defines of "ERROR" */
...@@ -93,7 +92,7 @@ typedef union SockAddr ...@@ -93,7 +92,7 @@ typedef union SockAddr
* functionality). * functionality).
* *
* If a backend supports version m.n of the protocol it must actually support * If a backend supports version m.n of the protocol it must actually support
* versions m.0..n]. Backend support for version m-1 can be dropped after a * versions m.[0..n]. Backend support for version m-1 can be dropped after a
* `reasonable' length of time. * `reasonable' length of time.
* *
* A frontend isn't required to support anything other than the current * A frontend isn't required to support anything other than the current
...@@ -107,27 +106,26 @@ typedef union SockAddr ...@@ -107,27 +106,26 @@ typedef union SockAddr
/* The earliest and latest frontend/backend protocol version supported. */ /* The earliest and latest frontend/backend protocol version supported. */
#define PG_PROTOCOL_EARLIEST PG_PROTOCOL(1,0) #define PG_PROTOCOL_EARLIEST PG_PROTOCOL(1,0)
#define PG_PROTOCOL_LATEST PG_PROTOCOL(2,0) #define PG_PROTOCOL_LATEST PG_PROTOCOL(3,100) /* XXX temporary value */
/* typedef uint32 ProtocolVersion; /* FE/BE protocol version number */
* All packets sent to the postmaster start with the length. This is omitted
* from the different packet definitions specified below.
*/
typedef uint32 PacketLen; typedef ProtocolVersion MsgType;
/* /*
* Startup message parameters sizes. These must not be changed without changing * Packet lengths are 4 bytes in network byte order.
* the protocol version. These are all strings that are '\0' terminated only if *
* there is room. * The initial length is omitted from the packet layouts appearing below.
*/ */
typedef uint32 PacketLen;
/* /*
* FIXME: remove the fixed size limitations on the database name, user * Old-style startup packet layout with fixed-width fields. This is used in
* name, and options fields and use a variable length field instead. The * protocol 1.0 and 2.0, but not in later versions. Note that the fields
* actual limits on database & user name will then be NAMEDATALEN, which * in this layout are '\0' terminated only if there is room.
* can be changed without changing the FE/BE protocol. -neilc,2002/08/27
*/ */
#define SM_DATABASE 64 #define SM_DATABASE 64
...@@ -138,11 +136,6 @@ typedef uint32 PacketLen; ...@@ -138,11 +136,6 @@ typedef uint32 PacketLen;
#define SM_UNUSED 64 #define SM_UNUSED 64
#define SM_TTY 64 #define SM_TTY 64
typedef uint32 ProtocolVersion; /* Fe/Be protocol version number */
typedef ProtocolVersion MsgType;
typedef struct StartupPacket typedef struct StartupPacket
{ {
ProtocolVersion protoVersion; /* Protocol version */ ProtocolVersion protoVersion; /* Protocol version */
...@@ -156,7 +149,16 @@ typedef struct StartupPacket ...@@ -156,7 +149,16 @@ typedef struct StartupPacket
extern bool Db_user_namespace; extern bool Db_user_namespace;
/* These are the authentication requests sent by the backend. */ /*
* In protocol 3.0 and later, the startup packet length is not fixed, but
* we set an arbitrary limit on it anyway. This is just to prevent simple
* denial-of-service attacks via sending enough data to run the server
* out of memory.
*/
#define MAX_STARTUP_PACKET_LENGTH 10000
/* These are the authentication request codes sent by the backend. */
#define AUTH_REQ_OK 0 /* User is authenticated */ #define AUTH_REQ_OK 0 /* User is authenticated */
#define AUTH_REQ_KRB4 1 /* Kerberos V4 */ #define AUTH_REQ_KRB4 1 /* Kerberos V4 */
...@@ -169,12 +171,12 @@ extern bool Db_user_namespace; ...@@ -169,12 +171,12 @@ extern bool Db_user_namespace;
typedef uint32 AuthRequest; typedef uint32 AuthRequest;
/* A client can also send a cancel-current-operation request to the postmaster. /*
* 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 * This is uglier than sending it directly to the client's backend, but it
* avoids depending on out-of-band communication facilities. * avoids depending on out-of-band communication facilities.
*/ *
* The cancel request code must not match any protocol version number
/* The cancel request code must not match any protocol version number
* we're ever likely to use. This random choice should do. * we're ever likely to use. This random choice should do.
*/ */
#define CANCEL_REQUEST_CODE PG_PROTOCOL(1234,5678) #define CANCEL_REQUEST_CODE PG_PROTOCOL(1234,5678)
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes). * exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes).
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.74 2003/03/10 22:28:21 tgl Exp $ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.75 2003/04/17 22:26:01 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -559,7 +559,7 @@ pg_password_sendauth(PGconn *conn, const char *password, AuthRequest areq) ...@@ -559,7 +559,7 @@ pg_password_sendauth(PGconn *conn, const char *password, AuthRequest areq)
default: default:
return STATUS_ERROR; return STATUS_ERROR;
} }
ret = pqPacketSend(conn, crypt_pwd, strlen(crypt_pwd) + 1); ret = pqPacketSend(conn, 0, crypt_pwd, strlen(crypt_pwd) + 1);
if (areq == AUTH_REQ_MD5) if (areq == AUTH_REQ_MD5)
free(crypt_pwd); free(crypt_pwd);
return ret; return ret;
......
This diff is collapsed.
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: libpq-int.h,v 1.60 2002/10/16 02:55:30 momjian Exp $ * $Id: libpq-int.h,v 1.61 2003/04/17 22:26:02 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -56,7 +56,7 @@ typedef int ssize_t; /* ssize_t doesn't exist in VC (atleast ...@@ -56,7 +56,7 @@ typedef int ssize_t; /* ssize_t doesn't exist in VC (atleast
* pqcomm.h describe what the backend knows, not what libpq knows. * pqcomm.h describe what the backend knows, not what libpq knows.
*/ */
#define PG_PROTOCOL_LIBPQ PG_PROTOCOL(2,0) #define PG_PROTOCOL_LIBPQ PG_PROTOCOL(3,100) /* XXX temporary value */
/* /*
* POSTGRES backend dependent Constants. * POSTGRES backend dependent Constants.
...@@ -181,8 +181,6 @@ typedef enum ...@@ -181,8 +181,6 @@ typedef enum
/* PGSetenvStatusType defines the state of the PQSetenv state machine */ /* PGSetenvStatusType defines the state of the PQSetenv state machine */
typedef enum typedef enum
{ {
SETENV_STATE_OPTION_SEND, /* About to send an Environment Option */
SETENV_STATE_OPTION_WAIT, /* Waiting for above send to complete */
SETENV_STATE_ENCODINGS_SEND, /* About to send an "encodings" query */ SETENV_STATE_ENCODINGS_SEND, /* About to send an "encodings" query */
SETENV_STATE_ENCODINGS_WAIT, /* Waiting for query to complete */ SETENV_STATE_ENCODINGS_WAIT, /* Waiting for query to complete */
SETENV_STATE_IDLE SETENV_STATE_IDLE
...@@ -274,7 +272,6 @@ struct pg_conn ...@@ -274,7 +272,6 @@ struct pg_conn
/* Status for sending environment info. Used during PQSetenv only. */ /* Status for sending environment info. Used during PQSetenv only. */
PGSetenvStatusType setenv_state; PGSetenvStatusType setenv_state;
const struct EnvironmentOptions *next_eo;
#ifdef USE_SSL #ifdef USE_SSL
bool allow_ssl_try; /* Allowed to try SSL negotiation */ bool allow_ssl_try; /* Allowed to try SSL negotiation */
...@@ -312,7 +309,8 @@ extern char *const pgresStatus[]; ...@@ -312,7 +309,8 @@ extern char *const pgresStatus[];
/* === in fe-connect.c === */ /* === in fe-connect.c === */
extern int pqPacketSend(PGconn *conn, const char *buf, size_t len); extern int pqPacketSend(PGconn *conn, char pack_type,
const void *buf, size_t buf_len);
/* === in fe-exec.c === */ /* === in fe-exec.c === */
......
-- --
-- INTERVAL -- INTERVAL
-- --
SET DATESTYLE = DEFAULT; SET DATESTYLE = 'ISO';
-- check acceptance of "time zone style" -- check acceptance of "time zone style"
SELECT INTERVAL '01:00' AS "One hour"; SELECT INTERVAL '01:00' AS "One hour";
One hour One hour
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
-- INTERVAL -- INTERVAL
-- --
SET DATESTYLE = DEFAULT; SET DATESTYLE = 'ISO';
-- check acceptance of "time zone style" -- check acceptance of "time zone style"
SELECT INTERVAL '01:00' AS "One hour"; SELECT INTERVAL '01:00' AS "One hour";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment