From: Peter van Dijk Date: Wed, 17 Feb 2021 16:14:40 +0000 (+0100) Subject: simplify and fix postgres user handling X-Git-Tag: dnsdist-1.6.0-alpha2~23^2~7 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5a8b492c67d26eef0b7fe4c29a31e21c71033a06;p=thirdparty%2Fpdns.git simplify and fix postgres user handling Before this, a few spots were missing (and one had a typo). With all of that taken out, we can simply set PGUSER and libpq will do the right thing for us. --- diff --git a/regression-tests.api/runtests.py b/regression-tests.api/runtests.py index e2fa8bbbfd..ae3c39d545 100755 --- a/regression-tests.api/runtests.py +++ b/regression-tests.api/runtests.py @@ -4,7 +4,6 @@ from __future__ import print_function import os -import getpass import requests import shutil import subprocess @@ -23,7 +22,6 @@ MYSQL_HOST=os.environ.get('MYSQL_HOST', 'localhost') MYSQL_PASSWD='' PGSQL_DB='pdnsapi' -PGSQL_USER=getpass.getuser() SQLITE_DB = 'pdns.sqlite3' @@ -53,7 +51,6 @@ AUTH_PGSQL_TPL = """ launch=gpgsql gpgsql-dnssec=on gpgsql-dbname="""+PGSQL_DB+""" -gpgsql-user="""+PGSQL_USER+""" # on conflict is available in pg 9.5 and up gpgsql-set-tsig-key-query=insert into tsigkeys (name,algorithm,secret) values($1,$2,$3) on conflict(name, algorithm) do update set secret=Excluded.secret """ @@ -175,12 +172,12 @@ if daemon == 'authoritative': # Prepare pgsql DB with some zones. elif backend == 'gpgsql': - subprocess.call(["dropdb", "--user="+PGSQL_USER, PGSQL_DB]) + subprocess.call(["dropdb", PGSQL_DB]) - subprocess.check_call(["createdb", "--user="+PGSQL_USER, PGSQL_DB]) + subprocess.check_call(["createdb", PGSQL_DB]) with open('../modules/gpgsqlbackend/schema.pgsql.sql', 'r') as schema_file: - subprocess.check_call(["psql", "--user="+PGSQL_USER, PGSQL_DB], stdin=schema_file) + subprocess.check_call(["psql", PGSQL_DB], stdin=schema_file) with open('pdns.conf', 'w') as pdns_conf: pdns_conf.write(AUTH_PGSQL_TPL + AUTH_COMMON_TPL) @@ -263,7 +260,6 @@ test_env.update({ 'MYSQL_HOST': MYSQL_HOST, 'MYSQL_PASSWD': MYSQL_PASSWD, 'PGSQL_DB': PGSQL_DB, - 'PGSQL_USER': PGSQL_USER, 'SQLITE_DB': SQLITE_DB, 'LMDB_DB': LMDB_DB, 'PDNSUTIL_CMD': ' '.join(PDNSUTIL_CMD), diff --git a/regression-tests.api/test_helper.py b/regression-tests.api/test_helper.py index 92fff44767..1faff3844f 100644 --- a/regression-tests.api/test_helper.py +++ b/regression-tests.api/test_helper.py @@ -23,7 +23,6 @@ MYSQL_USER = os.environ.get('MYSQL_USER', 'root') MYSQL_HOST = os.environ.get('MYSQL_HOST', 'localhost') MYSQL_PASSWD = os.environ.get('MYSQL_PASWORD', '') PGSQL_DB = os.environ.get('PGSQL_DB', 'pdnsapi') -PGSQL_USER = os.environ.get('PGSQ_USER', getpass.getuser()) SQLITE_DB = os.environ.get('SQLITE_DB', 'pdns.sqlite3') LMDB_DB = os.environ.get('SQLITE_DB', 'pdns.lmdb') SDIG = os.environ.get('SDIG', 'sdig') @@ -83,7 +82,7 @@ def get_auth_db(): if BACKEND == 'gmysql': return mysql.connector.connect(database=MYSQL_DB, user=MYSQL_USER, host=MYSQL_HOST, password=MYSQL_PASSWD), "%s" elif BACKEND == 'gpgsql': - return psycopg2.connect(database=PGSQL_DB, user=PGSQL_USER), "%s" + return psycopg2.connect(database=PGSQL_DB), "%s" else: return sqlite3.Connection(SQLITE_DB), "?"