Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 868024

Summary: dev-db/postgresql-14.5 init script prompts for a password when run as a user
Product: Gentoo Linux Reporter: Hypoon <futurehypoon>
Component: Current packagesAssignee: PgSQL Bugs <pgsql-bugs>
Status: UNCONFIRMED ---    
Severity: normal CC: gentoo
Priority: Normal Keywords: PullRequest
Version: unspecified   
Hardware: AMD64   
OS: Linux   
See Also: https://github.com/gentoo/gentoo/pull/29550
Whiteboard:
Package list:
Runtime testing required: ---

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.