greenbone / gvmd

Greenbone Vulnerability Manager - The database backend for the Greenbone Community Edition
GNU Affero General Public License v3.0
281 stars 153 forks source link

Docker: Unable to update gvmd admin user password #1850

Closed fahrenhe1t closed 2 years ago

fahrenhe1t commented 2 years ago

Expected behavior

When rolling out Greenbone Community Edition with greenbone/gvmd:oldstable or greenbone/gvmd:stable, it is suggested to change the console admin password with a derivative of: docker exec -it gvmd gvmd --user=admin --new-password=<password>

Actual behavior

The shell command outputs an error: role "root" does not exist

GVM versions

gsa: greenbone/gsa:stable gvm: greenbone/gvmd:stable openvas-scanner: greenbone/ospd-openvas:oldstable postgres: greenbone/pg-gvm:stable

Environment

Operating system:

Linux server 5.15.0-41-generic #44-Ubuntu SMP Wed Jun 22 14:20:53 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux DISTRIB_ID=Ubuntu DISTRIB_RELEASE=22.04 DISTRIB_CODENAME=jammy DISTRIB_DESCRIPTION="Ubuntu 22.04 LTS"

Logfiles

gvmd log:

md   main:MESSAGE:2022-07-27 18h01.29 utc:163:    Greenbone Vulnerability Manager version 21.4.6~dev1 (DB revision 242)
md manage:   INFO:2022-07-27 18h01.29 utc:163:    Modifying user password.
md manage:WARNING:2022-07-27 18h01.29 utc:163: sql_open: PQconnectPoll failed
md manage:WARNING:2022-07-27 18h01.29 utc:163: sql_open: PQerrorMessage (conn): FATAL:  role "root" does not exist
md manage:WARNING:2022-07-27 18h01.29 utc:163: init_manage_open_db: sql_open failed

pg-gvm log:

2022-07-27 18:01:29.776 UTC [214] root@gvmd FATAL:  role "root" does not exist

WORKAROUND

I found I can add the root role in PostgreSQL manually, then changing the password works:

docker exec -it pg-gvm psql -U postgres -c "create role root with superuser login in role dba;"
docker exec -it gvmd gvmd --user=admin --new-password=<password>
bjoernricks commented 2 years ago

You need to run gvmd with the dedicated user and not root. See https://greenbone.github.io/docs/latest/22.4/container/index.html#setting-up-an-admin-user

bjoernricks commented 2 years ago
> docker exec greenbone-community-edition_gvmd_1 id
uid=0(root) gid=0(root) groups=0(root)
> docker exec -u gvmd greenbone-community-edition_gvmd_1 id
uid=1001(gvmd) gid=1001(gvmd) groups=1001(gvmd)