Skip to content

Commit 47a37ae

Browse files
committed
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.
1 parent eaf8f31 commit 47a37ae

File tree

10 files changed

+47
-28
lines changed

10 files changed

+47
-28
lines changed

src/backend/commands/user.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $PostgreSQL: pgsql/src/backend/commands/user.c,v 1.171 2006/05/04 16:07:29 tgl Exp $
9+
* $PostgreSQL: pgsql/src/backend/commands/user.c,v 1.172 2006/06/20 19:56:52 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -20,7 +20,7 @@
2020
#include "catalog/pg_authid.h"
2121
#include "commands/comment.h"
2222
#include "commands/user.h"
23-
#include "libpq/crypt.h"
23+
#include "libpq/md5.h"
2424
#include "miscadmin.h"
2525
#include "utils/acl.h"
2626
#include "utils/builtins.h"

src/backend/libpq/crypt.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
1010
* Portions Copyright (c) 1994, Regents of the University of California
1111
*
12-
* $PostgreSQL: pgsql/src/backend/libpq/crypt.c,v 1.68 2006/03/05 15:58:27 momjian Exp $
12+
* $PostgreSQL: pgsql/src/backend/libpq/crypt.c,v 1.69 2006/06/20 19:56:52 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -22,6 +22,7 @@
2222

2323
#include "libpq/crypt.h"
2424
#include "libpq/libpq.h"
25+
#include "libpq/md5.h"
2526
#include "miscadmin.h"
2627
#include "storage/fd.h"
2728
#include "nodes/pg_list.h"

src/backend/libpq/hba.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.151 2006/03/06 17:41:43 momjian Exp $
13+
* $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.152 2006/06/20 19:56:52 tgl Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -29,7 +29,6 @@
2929
#include <arpa/inet.h>
3030
#include <unistd.h>
3131

32-
#include "libpq/crypt.h"
3332
#include "libpq/libpq.h"
3433
#include "miscadmin.h"
3534
#include "nodes/pg_list.h"

src/backend/libpq/ip.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/libpq/ip.c,v 1.35 2006/06/07 22:24:43 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/libpq/ip.c,v 1.36 2006/06/20 19:56:52 tgl Exp $
1212
*
1313
* This file and the IPV6 implementation were initially provided by
1414
* Nigel Kukard <nkukard@lbsd.net>, Linux Based Systems Design
@@ -20,7 +20,6 @@
2020
/* This is intended to be used in both frontend and backend, so use c.h */
2121
#include "c.h"
2222

23-
#include <errno.h>
2423
#include <unistd.h>
2524
#include <sys/types.h>
2625
#include <sys/stat.h>

src/backend/libpq/md5.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
* Portions Copyright (c) 1994, Regents of the University of California
1515
*
1616
* IDENTIFICATION
17-
* $PostgreSQL: pgsql/src/backend/libpq/md5.c,v 1.32 2006/03/05 15:58:27 momjian Exp $
17+
* $PostgreSQL: pgsql/src/backend/libpq/md5.c,v 1.33 2006/06/20 19:56:52 tgl Exp $
1818
*/
1919

2020
/* This is intended to be used in both frontend and backend, so use c.h */
2121
#include "c.h"
2222

23-
#include "libpq/crypt.h"
23+
#include "libpq/md5.h"
2424

2525

2626
/*
@@ -265,7 +265,7 @@ bytesToHex(uint8 b[16], char *s)
265265
*
266266
* Calculates the MD5 sum of the bytes in a buffer.
267267
*
268-
* SYNOPSIS #include "crypt.h"
268+
* SYNOPSIS #include "md5.h"
269269
* int pg_md5_hash(const void *buff, size_t len, char *hexsum)
270270
*
271271
* INPUT buff the buffer containing the bytes that you want

src/backend/utils/adt/varlena.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.147 2006/05/21 20:05:19 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.148 2006/06/20 19:56:52 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -19,7 +19,7 @@
1919
#include "access/tuptoaster.h"
2020
#include "catalog/pg_type.h"
2121
#include "lib/stringinfo.h"
22-
#include "libpq/crypt.h"
22+
#include "libpq/md5.h"
2323
#include "libpq/pqformat.h"
2424
#include "mb/pg_wchar.h"
2525
#include "miscadmin.h"

src/include/libpq/crypt.h

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $PostgreSQL: pgsql/src/include/libpq/crypt.h,v 1.34 2006/03/05 15:58:56 momjian Exp $
9+
* $PostgreSQL: pgsql/src/include/libpq/crypt.h,v 1.35 2006/06/20 19:56:52 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -15,19 +15,7 @@
1515

1616
#include "libpq/libpq-be.h"
1717

18-
#define MD5_PASSWD_LEN 35
19-
20-
#define isMD5(passwd) (strncmp(passwd, "md5", 3) == 0 && \
21-
strlen(passwd) == MD5_PASSWD_LEN)
22-
23-
24-
/* in crypt.c */
2518
extern int md5_crypt_verify(const Port *port, const char *user,
2619
char *client_pass);
2720

28-
/* in md5.c --- these are also present in frontend libpq */
29-
extern bool pg_md5_hash(const void *buff, size_t len, char *hexsum);
30-
extern bool pg_md5_encrypt(const char *passwd, const char *salt,
31-
size_t salt_len, char *buf);
32-
3321
#endif

src/include/libpq/ip.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
* ip.h
44
* Definitions for IPv6-aware network access.
55
*
6+
* These definitions are used by both frontend and backend code. Be careful
7+
* what you include here!
8+
*
69
* Copyright (c) 2003-2006, PostgreSQL Global Development Group
710
*
8-
* $PostgreSQL: pgsql/src/include/libpq/ip.h,v 1.17 2006/03/05 15:58:56 momjian Exp $
11+
* $PostgreSQL: pgsql/src/include/libpq/ip.h,v 1.18 2006/06/20 19:56:52 tgl Exp $
912
*
1013
*-------------------------------------------------------------------------
1114
*/

src/include/libpq/md5.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*-------------------------------------------------------------------------
2+
*
3+
* md5.h
4+
* Interface to libpq/md5.c
5+
*
6+
* These definitions are needed by both frontend and backend code to work
7+
* with MD5-encrypted passwords.
8+
*
9+
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
10+
* Portions Copyright (c) 1994, Regents of the University of California
11+
*
12+
* $PostgreSQL: pgsql/src/include/libpq/md5.h,v 1.3 2006/06/20 19:56:52 tgl Exp $
13+
*
14+
*-------------------------------------------------------------------------
15+
*/
16+
#ifndef PG_MD5_H
17+
#define PG_MD5_H
18+
19+
#define MD5_PASSWD_LEN 35
20+
21+
#define isMD5(passwd) (strncmp(passwd, "md5", 3) == 0 && \
22+
strlen(passwd) == MD5_PASSWD_LEN)
23+
24+
25+
extern bool pg_md5_hash(const void *buff, size_t len, char *hexsum);
26+
extern bool pg_md5_encrypt(const char *passwd, const char *salt,
27+
size_t salt_len, char *buf);
28+
29+
#endif

src/interfaces/libpq/fe-auth.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes).
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.c,v 1.114 2006/03/06 17:59:30 momjian Exp $
13+
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.c,v 1.115 2006/06/20 19:56:52 tgl Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -50,7 +50,7 @@
5050
#include "libpq-fe.h"
5151
#include "libpq-int.h"
5252
#include "fe-auth.h"
53-
#include "libpq/crypt.h"
53+
#include "libpq/md5.h"
5454

5555

5656
#ifdef KRB5

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy