Bug 250186 - sysutils/py-salt Postgres using hardcoded unknown user
Summary: sysutils/py-salt Postgres using hardcoded unknown user
Status: New
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-ports-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-10-07 17:43 UTC by Danny McGrath
Modified: 2020-11-10 16:08 UTC (History)
2 users (show)

See Also:
bugzilla: maintainer-feedback? (christer.edwards)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Danny McGrath 2020-10-07 17:43:11 UTC
Hi,

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
https://github.com/saltstack/salt/pull/58915