From 75926b442e32bbc210316dc112f438668e9d4c39 Mon Sep 17 00:00:00 2001 From: Alexander Kukushkin Date: Tue, 11 Jun 2019 15:14:57 +0200 Subject: [PATCH] Open trust in pg_hba.conf during bootstrap to localhost (#1075) previously it was open by mistake to unix_socket only Fixes https://github.com/zalando/patroni/issues/1072 --- patroni/postgresql/config.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/patroni/postgresql/config.py b/patroni/postgresql/config.py index 27b048fb..21d563fd 100644 --- a/patroni/postgresql/config.py +++ b/patroni/postgresql/config.py @@ -152,10 +152,10 @@ class ConfigHandler(object): # and in order to be able to change it, we are opening trust access from a certain address if self._postgresql.bootstrap.running_custom_bootstrap: addresses = {'': 'local'} - if 'host' in self._local_address and not self._local_address['host'].startswith('/'): - for _, _, _, _, sa in socket.getaddrinfo(self._local_address['host'], self._local_address['port'], - 0, socket.SOCK_STREAM, socket.IPPROTO_TCP): - addresses[sa[0] + '/32'] = 'host' + if 'host' in self.local_replication_address and not self.local_replication_address['host'].startswith('/'): + addresses.update({sa[0] + '/32': 'host' for _, _, _, _, sa in socket.getaddrinfo( + self.local_replication_address['host'], self.local_replication_address['port'], + 0, socket.SOCK_STREAM, socket.IPPROTO_TCP)}) with open(self._pg_hba_conf, 'w') as f: f.write(self._CONFIG_WARNING_HEADER)