diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2001-09-21 20:31:49 +0000 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2001-09-21 20:31:49 +0000 |
| commit | c1c888a9de0c062182552e66ca766b252ca140bc (patch) | |
| tree | 627829c42bcbcc8e84e563fe685158fcb4404a04 /src/backend/libpq | |
| parent | 4e77b4a5487c074e3e9882feef816f87e3a03a18 (diff) | |
| download | postgresql-c1c888a9de0c062182552e66ca766b252ca140bc.tar.gz | |
Code review for MD5 authorization patch. Clean up some breakage
(salts were always zero!?), add much missing documentation.
Diffstat (limited to 'src/backend/libpq')
| -rw-r--r-- | src/backend/libpq/auth.c | 12 | ||||
| -rw-r--r-- | src/backend/libpq/crypt.c | 6 | ||||
| -rw-r--r-- | src/backend/libpq/hba.c | 12 | ||||
| -rw-r--r-- | src/backend/libpq/md5.c | 13 |
4 files changed, 15 insertions, 28 deletions
diff --git a/src/backend/libpq/auth.c b/src/backend/libpq/auth.c index e3c2a04a9b..96bb8f0c57 100644 --- a/src/backend/libpq/auth.c +++ b/src/backend/libpq/auth.c @@ -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); diff --git a/src/backend/libpq/crypt.c b/src/backend/libpq/crypt.c index 8f2a1f9243..1d6b80a264 100644 --- a/src/backend/libpq/crypt.c +++ b/src/backend/libpq/crypt.c @@ -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 diff --git a/src/backend/libpq/hba.c b/src/backend/libpq/hba.c index 1fa235bd2a..891fcb4317 100644 --- a/src/backend/libpq/hba.c +++ b/src/backend/libpq/hba.c @@ -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; diff --git a/src/backend/libpq/md5.c b/src/backend/libpq/md5.c index 16a0ed5817..ad5b4c91ec 100644 --- a/src/backend/libpq/md5.c +++ b/src/backend/libpq/md5.c @@ -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 |
