diff options
author | Tom Lane | 2006-06-20 19:56:52 +0000 |
---|---|---|
committer | Tom Lane | 2006-06-20 19:56:52 +0000 |
commit | 03cdfe8ac628444c387187ac7c36511be67f6013 (patch) | |
tree | e93b2d57fd65ff1b72ab1714f5f0e29188d3cbe8 | |
parent | b3185bed98b593ada527950aeef5e2b7f292e8fb (diff) |
Split definitions for md5.c out of crypt.h and into their own header
libpq/md5.h, so that there's a clear separation between backend-only
definitions and shared frontend/backend definitions. (Turns out this
is reversing a bad decision from some years ago...) Fix up references
to crypt.h as needed. I looked into moving the code into src/port, but
the headers in src/include/libpq are sufficiently intertwined that it
seems more work than it's worth to do that.
-rw-r--r-- | src/backend/commands/user.c | 2 | ||||
-rw-r--r-- | src/backend/libpq/crypt.c | 1 | ||||
-rw-r--r-- | src/backend/libpq/hba.c | 1 | ||||
-rw-r--r-- | src/backend/libpq/ip.c | 1 | ||||
-rw-r--r-- | src/backend/libpq/md5.c | 4 | ||||
-rw-r--r-- | src/backend/utils/adt/varlena.c | 2 | ||||
-rw-r--r-- | src/include/libpq/crypt.h | 12 | ||||
-rw-r--r-- | src/include/libpq/ip.h | 3 | ||||
-rw-r--r-- | src/include/libpq/md5.h | 29 | ||||
-rw-r--r-- | src/interfaces/libpq/fe-auth.c | 2 |
10 files changed, 38 insertions, 19 deletions
diff --git a/src/backend/commands/user.c b/src/backend/commands/user.c index b30bdf7d9e..c4080c7a88 100644 --- a/src/backend/commands/user.c +++ b/src/backend/commands/user.c @@ -20,7 +20,7 @@ #include "catalog/pg_authid.h" #include "commands/comment.h" #include "commands/user.h" -#include "libpq/crypt.h" +#include "libpq/md5.h" #include "miscadmin.h" #include "utils/acl.h" #include "utils/builtins.h" diff --git a/src/backend/libpq/crypt.c b/src/backend/libpq/crypt.c index 6d1b55feb5..b72b9bd196 100644 --- a/src/backend/libpq/crypt.c +++ b/src/backend/libpq/crypt.c @@ -22,6 +22,7 @@ #include "libpq/crypt.h" #include "libpq/libpq.h" +#include "libpq/md5.h" #include "miscadmin.h" #include "storage/fd.h" #include "nodes/pg_list.h" diff --git a/src/backend/libpq/hba.c b/src/backend/libpq/hba.c index 2e06758f95..e6d14881f2 100644 --- a/src/backend/libpq/hba.c +++ b/src/backend/libpq/hba.c @@ -29,7 +29,6 @@ #include <arpa/inet.h> #include <unistd.h> -#include "libpq/crypt.h" #include "libpq/libpq.h" #include "miscadmin.h" #include "nodes/pg_list.h" diff --git a/src/backend/libpq/ip.c b/src/backend/libpq/ip.c index 3c07fa5d02..50a1d7fe32 100644 --- a/src/backend/libpq/ip.c +++ b/src/backend/libpq/ip.c @@ -20,7 +20,6 @@ /* This is intended to be used in both frontend and backend, so use c.h */ #include "c.h" -#include <errno.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> diff --git a/src/backend/libpq/md5.c b/src/backend/libpq/md5.c index 6fc418b3cd..86739a5a9a 100644 --- a/src/backend/libpq/md5.c +++ b/src/backend/libpq/md5.c @@ -20,7 +20,7 @@ /* This is intended to be used in both frontend and backend, so use c.h */ #include "c.h" -#include "libpq/crypt.h" +#include "libpq/md5.h" /* @@ -265,7 +265,7 @@ bytesToHex(uint8 b[16], char *s) * * Calculates the MD5 sum of the bytes in a buffer. * - * SYNOPSIS #include "crypt.h" + * SYNOPSIS #include "md5.h" * int pg_md5_hash(const void *buff, size_t len, char *hexsum) * * INPUT buff the buffer containing the bytes that you want diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c index b28c3d8bb8..54f24d14cd 100644 --- a/src/backend/utils/adt/varlena.c +++ b/src/backend/utils/adt/varlena.c @@ -19,7 +19,7 @@ #include "access/tuptoaster.h" #include "catalog/pg_type.h" #include "lib/stringinfo.h" -#include "libpq/crypt.h" +#include "libpq/md5.h" #include "libpq/pqformat.h" #include "mb/pg_wchar.h" #include "miscadmin.h" diff --git a/src/include/libpq/crypt.h b/src/include/libpq/crypt.h index ad6acdb21f..64c0ffe042 100644 --- a/src/include/libpq/crypt.h +++ b/src/include/libpq/crypt.h @@ -15,19 +15,7 @@ #include "libpq/libpq-be.h" -#define MD5_PASSWD_LEN 35 - -#define isMD5(passwd) (strncmp(passwd, "md5", 3) == 0 && \ - strlen(passwd) == MD5_PASSWD_LEN) - - -/* in crypt.c */ extern int md5_crypt_verify(const Port *port, const char *user, char *client_pass); -/* in md5.c --- these are also present in frontend libpq */ -extern bool pg_md5_hash(const void *buff, size_t len, char *hexsum); -extern bool pg_md5_encrypt(const char *passwd, const char *salt, - size_t salt_len, char *buf); - #endif diff --git a/src/include/libpq/ip.h b/src/include/libpq/ip.h index 7ba5070e16..aa705cbb34 100644 --- a/src/include/libpq/ip.h +++ b/src/include/libpq/ip.h @@ -3,6 +3,9 @@ * ip.h * Definitions for IPv6-aware network access. * + * These definitions are used by both frontend and backend code. Be careful + * what you include here! + * * Copyright (c) 2003-2006, PostgreSQL Global Development Group * * $PostgreSQL$ diff --git a/src/include/libpq/md5.h b/src/include/libpq/md5.h new file mode 100644 index 0000000000..c726bdce25 --- /dev/null +++ b/src/include/libpq/md5.h @@ -0,0 +1,29 @@ +/*------------------------------------------------------------------------- + * + * md5.h + * Interface to libpq/md5.c + * + * These definitions are needed by both frontend and backend code to work + * with MD5-encrypted passwords. + * + * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * $PostgreSQL$ + * + *------------------------------------------------------------------------- + */ +#ifndef PG_MD5_H +#define PG_MD5_H + +#define MD5_PASSWD_LEN 35 + +#define isMD5(passwd) (strncmp(passwd, "md5", 3) == 0 && \ + strlen(passwd) == MD5_PASSWD_LEN) + + +extern bool pg_md5_hash(const void *buff, size_t len, char *hexsum); +extern bool pg_md5_encrypt(const char *passwd, const char *salt, + size_t salt_len, char *buf); + +#endif diff --git a/src/interfaces/libpq/fe-auth.c b/src/interfaces/libpq/fe-auth.c index 269234e330..f5454a642b 100644 --- a/src/interfaces/libpq/fe-auth.c +++ b/src/interfaces/libpq/fe-auth.c @@ -50,7 +50,7 @@ #include "libpq-fe.h" #include "libpq-int.h" #include "fe-auth.h" -#include "libpq/crypt.h" +#include "libpq/md5.h" #ifdef KRB5 |