osctrl icon indicating copy to clipboard operation
osctrl copied to clipboard

osctrl-tls doesn't use the defined user in `db.json`

Open CptOfEvilMinions opened this issue 2 years ago • 3 comments

When osctrl-tls is started and passed a db.json config it doesn't use the username in the config (see error logs). I think the user postgres is hard coded.

db.json:

{
  "db": {
    "host": "127.0.0.1",
    "port": "5432",
    "name": "osctrl",
    "username": "osctrl",
    "password": "osctrl",
    "max_idle_conns": 20,
    "max_open_conns": 100,
    "conn_max_lifetime": 30
  }
}

Start osctrl-tls

/usr/local/bin/osctrl-tls --config --config-file /etc/osctrl/osctrl-tls/service.json --redis --redis-file /etc/osctrl/redis.json --db --db-file /etc/osctrl/db.json

Error output:

May 18 03:41:48 ubuntuvm osctrl-tls[6171]: main.go:124: Loading /etc/osctrl/osctrl-tls/service.json
May 18 03:41:48 ubuntuvm osctrl-tls[6171]: main.go:382: Initializing backend...
May 18 03:41:49 ubuntuvm osctrl-tls[6171]:
May 18 03:41:49 ubuntuvm osctrl-tls[6171]: 2022/05/18 03:41:49 /home/runner/work/osctrl/osctrl/backend/backend.go:64
May 18 03:41:49 ubuntuvm osctrl-tls[6171]: [error] failed to initialize database, got error failed to connect to `host=127.0.0.1 user=postgres database=osctrl`: failed SASL auth (FATAL: pass>
May 18 03:41:49 ubuntuvm osctrl-tls[6171]: main.go:391: Failed to connect to backend - Failed to get DB - failed to connect to `host=127.0.0.1 user=postgres database=osctrl`: failed SASL aut>
May 18 03:41:49 ubuntuvm systemd[1]: osctrl-tls.service: Main process exited, code=exited, status=1/FAILURE

CptOfEvilMinions avatar May 18 '22 03:05 CptOfEvilMinions

This was a false positive due to file perms.

CptOfEvilMinions avatar May 18 '22 03:05 CptOfEvilMinions

Re-opening this ticket to start a discussion. If a config is defined like --config-file /etc/osctrl/osctrl-tls/service.json and if osctrl-tls can't read it, shouldn't it exit?

Based on the output above, osctrl-tls attempts to connect to the database with default values.

CptOfEvilMinions avatar May 18 '22 03:05 CptOfEvilMinions

Good point, and yes I think if the file is specified, but for whatever reason the file is not accesible or format is incorrect... Then service should halt

javuto avatar Jun 08 '22 18:06 javuto

Should be fixed in https://github.com/jmpsec/osctrl/pull/383

javuto avatar Jan 01 '24 22:01 javuto