Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Traffic Ops db/admin tool depends on passwordless DB connection as root user #7202

Open
zrhoffman opened this issue Nov 17, 2022 · 9 comments
Labels
database relating to setup/installation/structure of the Traffic Ops database dev-ciab Related to CDN in a Box for Developers improvement The functionality exists but it could be improved in some way. tools related to tools outside of main components, e.g. 'compare' Traffic Ops related to Traffic Ops

Comments

@zrhoffman
Copy link
Member

zrhoffman commented Nov 17, 2022

This Improvement request (usability, performance, tech debt, etc.) affects these Traffic Control components:

  • Traffic Ops

Current behavior:

The Traffic Ops db/admin tool relies on the postgres user requiring no password when connecting as root.

userExistsCmd := exec.Command("psql", "-h", hostIP, "-U", dbSuperUser, "-p", hostPort, "-tAc", "SELECT 1 FROM pg_roles WHERE rolname='"+dbUser+"'")

#7142, which made Traffic Ops run as a non-root user, set PGPASSWORD for the entire binary, which worked for Dev CDN in a Box because the password in dbconf.yml, which this strategy set PGPASSWORD to,

open: host=db port=5432 user=traffic_ops password=twelve12 dbname=traffic_ops_development sslmode=disable

happened to be "twelve12", the same password set for the postgres user of the Postgres server.

- POSTGRES_PASSWORD=twelve12

However, once #7142 was merged, the Cache Config integration tests started failing, because its postgres user password

POSTGRES_PASSWORD=secretrootpass

is different than its traffic_ops password (which ends up in dbconf.yml).

DB_USER=traffic_ops
DB_USER_PASS=twelve

open: host=$DB_SERVER port=$DB_PORT user=$DB_USER password=$DB_USER_PASS dbname=$DB_NAME sslmode=disable

We reverted the change to db/admin from #7142 in #7198 to make the Cache Config integration tests pass again without knowing, at the time, why that change made them fail.

As a side note, finding the reason the Cache Config integration tests were failing was not straightforward because the errors go only to a file that is not printed to the to_server container's output anywhere.

cd /opt/traffic_ops/app && db/admin --env=production reset >> /var/log/traffic_ops/to_admin.log 2>&1
cd /opt/traffic_ops/app && db/admin --trafficvault --env=production reset >> /var/log/traffic_ops/tv_admin.log 2>&1

New behavior:

  • db/admin should not depend on the postgres user requiring no password when the connecting client is the root user locally.
  • In CDN in a Box for Developers, the postgres password should not be the same as the traffic_ops password, because that potentially hides issues like this one.
@zrhoffman zrhoffman added Traffic Ops related to Traffic Ops database relating to setup/installation/structure of the Traffic Ops database improvement The functionality exists but it could be improved in some way. dev-ciab Related to CDN in a Box for Developers tools related to tools outside of main components, e.g. 'compare' labels Nov 17, 2022
@ocket8888
Copy link
Contributor

Is

Traffic Ops db/admin tool depends on passwordless DB connection as root user

strictly true, or is it the case that db/admin depends on the calling user to be the root user?

@zrhoffman
Copy link
Member Author

Not sure what the difference between strictly true and db/admin depends on the calling user to be the root user is, but they both seem true to me.

Notice how no password is set for the psql command (and PGPASSWORD is not set).

userExistsCmd := exec.Command("psql", "-h", hostIP, "-U", dbSuperUser, "-p", hostPort, "-tAc", "SELECT 1 FROM pg_roles WHERE rolname='"+dbUser+"'")

@ocket8888
Copy link
Contributor

If the title is strictly true, then the tool doesn't depend on passwordless DB connections when not run as the root user

@zrhoffman
Copy link
Member Author

It sounds like you know what I mean, feel free to change the title to whatever you feel is accurate

@ocket8888
Copy link
Contributor

I do not. If it's true that db/admin requires you to run it as the root user, that's also an issue IMO.

@zrhoffman
Copy link
Member Author

zrhoffman commented Nov 17, 2022

If the title is strictly true, then the tool doesn't depend on passwordless DB connections when not run as the root user

The tool didn't depend on passwordless DB connections before the revert in #7198 was merged.

If it's true that db/admin requires you to run it as the root user, that's also an issue IMO.

That's not also an issue, it's the issue

@ocket8888
Copy link
Contributor

idk the way I see it there are two issues

  • admin should not depend on passwordless authentication for its database connections
  • admin should not require that it be run as any particular user

@zrhoffman
Copy link
Member Author

Got it. I'm not sure how to describe one of those 2 points without describing the other, since both cases are related to Postgres default installations, but if you think they should be separated into 2 2 issues, I'll create another one.

@ocket8888
Copy link
Contributor

The number of issues isn't important to me, just want to be sure both are fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
database relating to setup/installation/structure of the Traffic Ops database dev-ciab Related to CDN in a Box for Developers improvement The functionality exists but it could be improved in some way. tools related to tools outside of main components, e.g. 'compare' Traffic Ops related to Traffic Ops
Projects
None yet
Development

No branches or pull requests

2 participants