1
0
mirror of https://github.com/postgres/postgres.git synced 2025-05-18 17:41:14 +03:00
Tom Lane 4ea2d2ddbe Remove code to match IPv4 pg_hba.conf entries to IPv4-in-IPv6 addresses.
In investigating yesterday's crash report from Hugo Osvaldo Barrera, I only
looked back as far as commit f3aec2c7f51904e7 where the breakage occurred
(which is why I thought the IPv4-in-IPv6 business was undocumented).  But
actually the logic dates back to commit 3c9bb8886df7d56a and was simply
broken by erroneous refactoring in the later commit.  A bit of archives
excavation shows that we added the whole business in response to a report
that some 2003-era Linux kernels would report IPv4 connections as having
IPv4-in-IPv6 addresses.  The fact that we've had no complaints since 9.0
seems to be sufficient confirmation that no modern kernels do that, so
let's just rip it all out rather than trying to fix it.

Do this in the back branches too, thus essentially deciding that our
effective behavior since 9.0 is correct.  If there are any platforms on
which the kernel reports IPv4-in-IPv6 addresses as such, yesterday's fix
would have made for a subtle and potentially security-sensitive change in
the effective meaning of IPv4 pg_hba.conf entries, which does not seem like
a good thing to do in minor releases.  So let's let the post-9.0 behavior
stand, and change the documentation to match it.

In passing, I failed to resist the temptation to wordsmith the description
of pg_hba.conf IPv4 and IPv6 address entries a bit.  A lot of this text
hasn't been touched since we were IPv4-only.
2015-02-17 12:49:18 -05:00

52 lines
1.5 KiB
C

/*-------------------------------------------------------------------------
*
* 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-2013, PostgreSQL Global Development Group
*
* src/include/libpq/ip.h
*
*-------------------------------------------------------------------------
*/
#ifndef IP_H
#define IP_H
#include "getaddrinfo.h" /* pgrminclude ignore */
#include "libpq/pqcomm.h" /* pgrminclude ignore */
#ifdef HAVE_UNIX_SOCKETS
#define IS_AF_UNIX(fam) ((fam) == AF_UNIX)
#else
#define IS_AF_UNIX(fam) (0)
#endif
typedef void (*PgIfAddrCallback) (struct sockaddr * addr,
struct sockaddr * netmask,
void *cb_data);
extern int pg_getaddrinfo_all(const char *hostname, const char *servname,
const struct addrinfo * hintp,
struct addrinfo ** result);
extern void pg_freeaddrinfo_all(int hint_ai_family, struct addrinfo * ai);
extern int pg_getnameinfo_all(const struct sockaddr_storage * addr, int salen,
char *node, int nodelen,
char *service, int servicelen,
int flags);
extern int pg_range_sockaddr(const struct sockaddr_storage * addr,
const struct sockaddr_storage * netaddr,
const struct sockaddr_storage * netmask);
extern int pg_sockaddr_cidr_mask(struct sockaddr_storage * mask,
char *numbits, int family);
extern int pg_foreach_ifaddr(PgIfAddrCallback callback, void *cb_data);
#endif /* IP_H */