Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 868024 - dev-db/postgresql-14.5 init script prompts for a password when run as a user
Summary: dev-db/postgresql-14.5 init script prompts for a password when run as a user
Status: UNCONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: Normal normal
Assignee: PgSQL Bugs
URL:
Whiteboard:
Keywords: PullRequest
Depends on:
Blocks:
 
Reported: 2022-09-02 16:41 UTC by Hypoon
Modified: 2023-02-11 20:56 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hypoon 2022-09-02 16:41:24 UTC
Calling "rc-service postgresql-14 status" as a user (without sudo) causes it to prompt for a password. Presumably, this is coming from this section of the init script:

status() {
    ebegin "Checking PostgreSQL 14 status"
    su - postgres -c "${PG_CTL} status -D ${DATA_DIR}"
    eend $?
}

The password prompt implies that it's asking for the user's password, or maybe the root password. In this case, it shouldn't be asking for any password at all, since the "postgres" user doesn't have a password set (on my machine, at least). 

One possible solution might be to check whether the current user will be able to "su - postgres" without a password BEFORE actually trying to switch users. Is UID 0 the only time when "su - foo" doesn't need a password? If so, adding a simple UID check could resolve the issue.

The "su - postgres" line appears several times in the init script. There are probably several places where this should be fixed.

Reproducible: Always

Steps to Reproduce:
1. Set up postgressql
2. As a standard logged-in (non root) user, run "rc-service status postgressql-14"
Actual Results:  
The script asks for a password.

Expected Results:  
The init script should fail with an error condition.