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

Obtain user from OS #28

Open
allenap opened this issue Oct 26, 2023 · 0 comments
Open

Obtain user from OS #28

allenap opened this issue Oct 26, 2023 · 0 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@allenap
Copy link
Owner

allenap commented Oct 26, 2023

At present, the user name is obtained from the USER environment variable:

https://github.com/allenap/pgdo/blob/e9c001bec09f419fb75ebdfc96f1dc555613ad06/pgdo-lib/src/cluster.rs#L298C1-L307

But this isn't always set, especially in containers. We could obtain this more reliably from the OS directly, e.g.:

use nix::unistd::{getuid, User};
let user: Option<User> = User::from_uid(getuid());
let name: Option<String> = user.map(|user| user.name);
@allenap allenap added bug Something isn't working enhancement New feature or request labels Oct 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant