Bug 250186

Summary: sysutils/py-salt Postgres using hardcoded unknown user
Product: Ports & Packages Reporter: Danny McGrath <danmcgrath.ca>
Component: Individual Port(s)Assignee: freebsd-ports-bugs (Nobody) <ports-bugs>
Status: New ---    
Severity: Affects Some People CC: christer.edwards, freebsd
Priority: --- Flags: bugzilla: maintainer-feedback? (christer.edwards)
Version: Latest   
Hardware: Any   
OS: Any   

Description Danny McGrath 2020-10-07 17:43:11 UTC

It would seem that when I tried to put some credentials for postgres into my /usr/local/etc/salt/minion.d/postgres.conf as follows:

  postgres.host: '/tmp'  # to use a socket
  postgres.port: '5432'
  postgres.user: 'postgres'
  postgres.pass: ''
  postgres.maintenance_db: 'postgres'

Trying to run a `salt-call postgres.db_list` (or anything) would fail, complaining that the user "pgsql" doesn't exist.

A quick check in the file /usr/local/lib/python3.7/site-packages/salt/modules/postgres.py around line 163 shows that there is a check for FreeBSD that sets the `runas = "pgsql"`, which a few lines below ultimately sets the `user = runas`.

If I change this to `runas = "postgres"` to match the system user id, the state modules run fine.

Seeing as how runas is a param for seemingly everything (see https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.postgres.html), I suppose it is less critical, but I am thinking this is indeed a bug as it totally ignores the config file values that I specified when called via salt-call on the minion, but I defer to the experts!

Thanks o/
Comment 1 Peter 2020-11-10 16:08:07 UTC
created pull request with saltstack