]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
simplify and fix postgres user handling
authorPeter van Dijk <peter.van.dijk@powerdns.com>
Wed, 17 Feb 2021 16:14:40 +0000 (17:14 +0100)
committermind04 <mind04@monshouwer.org>
Wed, 17 Feb 2021 19:34:59 +0000 (20:34 +0100)
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.

regression-tests.api/runtests.py
regression-tests.api/test_helper.py

index e2fa8bbbfd252a798a911512d8710a63b9b2b09f..ae3c39d545faea74dfef089ad856ad20aeefe33e 100755 (executable)
@@ -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),
index 92fff44767d487bddcacc74e04ee043a7c949ae8..1faff3844f4b88f7c3e9b216c0be208c7cfe7cb3 100644 (file)
@@ -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), "?"