diff --git a/doc/devel/unit-tests.dox b/doc/devel/unit-tests.dox index 27799c1fcb..a87b56c9ce 100644 --- a/doc/devel/unit-tests.dox +++ b/doc/devel/unit-tests.dox @@ -290,25 +290,21 @@ keatest=> @endverbatim If instead of seeing keatest=> prompt, your login is refused with an error - code about failed peer or indent authentication, it means that PostgreSQL is - configured to check unix username and reject login attempts if PostgreSQL names - are different. To alter that, the PostgreSQL configuration must be changed - - the /etc/postgresql/9.1/main/pg_hba.conf config file - has to be altered. (It may be in a different location in your system.) The following - lines: + code about failed peer or + Ident authentication failed for user "keatest", it means that + PostgreSQL is configured to check unix username and reject login attempts if + PostgreSQL names are different. To alter that, the PostgreSQL pg_hba.conf + configuration file must be changed. It usually resides at + /var/lib/postgresql/data/pg_hba.conf or at + /etc/postgresql/${version}/main/pg_hba.conf, but you can find out + for sure by running + printf 'SHOW hba_file' | sudo -u postgres psql -t postgres. Make sure + that all the authentication methods are changed to "md5" like this: @verbatim -local all all peer +local all all md5 host all all 127.0.0.1/32 md5 host all all ::1/128 md5 -@endverbatim - -need to be replaced with: - -@verbatim -local all all password -host all all 127.0.0.1/32 password -host all all ::1/128 password @endverbatim Another possible problem is that you get no password prompt. This is diff --git a/hammer.py b/hammer.py index d4bf2e172f..fbb3a204df 100755 --- a/hammer.py +++ b/hammer.py @@ -1163,8 +1163,18 @@ def _restart_postgresql(system): execute('sudo systemctl restart postgresql.service') +def _change_postgresql_auth_method(connection_type, auth_method, hba_file): + execute("sudo sed -i.bak 's/^{}\(.*\) [a-z0-9]*$/{}\\1 {}/g' '{}'".format( + connection_type, connection_type, auth_method, hba_file), cwd='/tmp') + + def _configure_pgsql(system, features): """ Configure PostgreSQL DB """ + + # execute() calls will set cwd='/tmp' when switching user to postgres to + # avoid the error: + # could not change as postgres user directory to "/home/jenkins": Permission denied + if system in ['fedora', 'centos']: # https://fedoraproject.org/wiki/PostgreSQL exitcode = execute('sudo ls /var/lib/pgsql/data/postgresql.conf', raise_error=False) @@ -1183,15 +1193,6 @@ def _configure_pgsql(system, features): _enable_postgresql(system) _restart_postgresql(system) - # Change auth-method to 'trust' on local connections. - cmd = "printf 'SHOW hba_file' | sudo -u postgres psql -t postgres | xargs" - _, output = execute(cmd, capture=True, cwd='/tmp') # CWD to avoid: could not change as postgres user directory to "/home/jenkins": Permission denied - hba_file = output.rstrip() - cmd = "sudo sed -i.bak 's/^local\(.*\) [a-z0-9]*$/local\\1 trust/g' '{}'".format(hba_file) - execute(cmd, cwd='/tmp') # CWD to avoid: could not change as postgres user directory to "/home/jenkins": Permission denied - - _restart_postgresql(system) - cmd = """bash -c \"cat <