From 0c776f5d860e00bbf2a0cab2da930fc68e7ad27a Mon Sep 17 00:00:00 2001 From: Alexander Kukushkin Date: Wed, 6 May 2015 14:11:37 +0200 Subject: [PATCH] Small bugfixes --- helpers/postgresql.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/helpers/postgresql.py b/helpers/postgresql.py index 752659e0..429b1a5d 100644 --- a/helpers/postgresql.py +++ b/helpers/postgresql.py @@ -23,7 +23,6 @@ class Postgresql: def __init__(self, config): self.name = config['name'] - self.host, self.port = config['listen'].split(':') self.data_dir = config['data_dir'] self.replication = config['replication'] @@ -81,7 +80,7 @@ class Postgresql: pgpass = 'pgpass' with open(pgpass, 'w') as f: - os.fchmod(f.fileno(), 0644) + os.fchmod(f.fileno(), 0600) f.write('{hostname}:{port}:*:{username}:{password}\n'.format(**r)) return os.system('PGPASSFILE={pgpass} pg_basebackup -R -D {data_dir} --host={hostname} --port={port} -U {username}'.format( @@ -117,7 +116,8 @@ class Postgresql: return os.system('pg_ctl restart -w -m fast -D ' + self.data_dir) == 0 def server_options(self): - options = '-c listen_addresses={} -c port={}'.format(self.host, self.port) + host, port = self.config['listen'].split(':') + options = '-c listen_addresses={} -c port={}'.format(host, port) for setting, value in self.config['parameters'].iteritems(): options += ' -c "{}={}"'.format(setting, value) return options @@ -174,7 +174,7 @@ recovery_target_timeline = 'latest' def follow_the_leader(self, leader_hash): r = parseurl(leader_hash['address']) pattern = 'host={hostname} port={port}'.format(**r) - with open(os.path.join(self.data_dir, 'recovery.conf', 'r')) as f: + with open(os.path.join(self.data_dir, 'recovery.conf'), 'r') as f: for line in f: if pattern in line: return