mirror of
https://github.com/postgres/postgres.git
synced 2025-08-24 09:27:52 +03:00
Code review for MD5 authorization patch. Clean up some breakage
(salts were always zero!?), add much missing documentation.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.66 2001/09/07 19:52:53 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.67 2001/09/21 20:31:45 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -594,15 +594,11 @@ sendAuthRequest(Port *port, AuthRequest areq)
|
||||
/* Add the salt for encrypted passwords. */
|
||||
if (areq == AUTH_REQ_MD5)
|
||||
{
|
||||
pq_sendint(&buf, port->md5Salt[0], 1);
|
||||
pq_sendint(&buf, port->md5Salt[1], 1);
|
||||
pq_sendint(&buf, port->md5Salt[2], 1);
|
||||
pq_sendint(&buf, port->md5Salt[3], 1);
|
||||
pq_sendbytes(&buf, port->md5Salt, 4);
|
||||
}
|
||||
if (areq == AUTH_REQ_CRYPT)
|
||||
else if (areq == AUTH_REQ_CRYPT)
|
||||
{
|
||||
pq_sendint(&buf, port->cryptSalt[0], 1);
|
||||
pq_sendint(&buf, port->cryptSalt[1], 1);
|
||||
pq_sendbytes(&buf, port->cryptSalt, 2);
|
||||
}
|
||||
|
||||
pq_endmessage(&buf);
|
||||
|
@@ -9,7 +9,7 @@
|
||||
* Dec 17, 1997 - Todd A. Brandys
|
||||
* Orignal Version Completed.
|
||||
*
|
||||
* $Id: crypt.c,v 1.37 2001/08/17 15:40:07 momjian Exp $
|
||||
* $Id: crypt.c,v 1.38 2001/09/21 20:31:45 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -282,7 +282,7 @@ md5_crypt_verify(const Port *port, const char *user, const char *pgpass)
|
||||
{
|
||||
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
|
||||
"Password is stored MD5 encrypted. "
|
||||
"Only pg_hba.conf's MD5 protocol can be used for this user.\n");
|
||||
"'password' and 'crypt' auth methods cannot be used.\n");
|
||||
fputs(PQerrormsg, stderr);
|
||||
pqdebug("%s", PQerrormsg);
|
||||
return STATUS_ERROR;
|
||||
@@ -339,7 +339,7 @@ md5_crypt_verify(const Port *port, const char *user, const char *pgpass)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!strcmp(pgpass, crypt_pwd))
|
||||
if (strcmp(pgpass, crypt_pwd) == 0)
|
||||
{
|
||||
/*
|
||||
* check here to be sure we are not past valuntil
|
||||
|
@@ -10,7 +10,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.71 2001/09/07 19:59:04 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.72 2001/09/21 20:31:46 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -208,8 +208,8 @@ free_lines(List **lines)
|
||||
* *error_p. line points to the next token of the line.
|
||||
*/
|
||||
static void
|
||||
parse_hba_auth(List *line, ProtocolVersion proto, UserAuth *userauth_p,
|
||||
char *auth_arg, bool *error_p)
|
||||
parse_hba_auth(List *line, UserAuth *userauth_p, char *auth_arg,
|
||||
bool *error_p)
|
||||
{
|
||||
char *token;
|
||||
|
||||
@@ -295,8 +295,7 @@ parse_hba(List *line, hbaPort *port, bool *found_p, bool *error_p)
|
||||
line = lnext(line);
|
||||
if (!line)
|
||||
goto hba_syntax;
|
||||
parse_hba_auth(line, port->proto, &port->auth_method,
|
||||
port->auth_arg, error_p);
|
||||
parse_hba_auth(line, &port->auth_method, port->auth_arg, error_p);
|
||||
if (*error_p)
|
||||
goto hba_syntax;
|
||||
|
||||
@@ -365,8 +364,7 @@ parse_hba(List *line, hbaPort *port, bool *found_p, bool *error_p)
|
||||
line = lnext(line);
|
||||
if (!line)
|
||||
goto hba_syntax;
|
||||
parse_hba_auth(line, port->proto, &port->auth_method,
|
||||
port->auth_arg, error_p);
|
||||
parse_hba_auth(line, &port->auth_method, port->auth_arg, error_p);
|
||||
if (*error_p)
|
||||
goto hba_syntax;
|
||||
|
||||
|
@@ -9,27 +9,20 @@
|
||||
* generating hashed passwords from limited input.
|
||||
*
|
||||
* Sverre H. Huseby <sverrehu@online.no>
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/backend/libpq/md5.c,v 1.6 2001/09/21 20:31:47 tgl Exp $
|
||||
*/
|
||||
|
||||
#include "postgres.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "postgres.h"
|
||||
#include "libpq/crypt.h"
|
||||
|
||||
/*
|
||||
* PRIVATE FUNCTIONS
|
||||
*/
|
||||
|
||||
#ifdef FRONTEND
|
||||
#undef palloc
|
||||
#define palloc malloc
|
||||
#undef pfree
|
||||
#define pfree free
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The returned array is allocated using malloc. the caller should free it
|
||||
|
Reference in New Issue
Block a user