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

os/user: Current fails with "unknown userid" when it finds no entry about the user in "/etc/passwd" #38599

Closed
mrik974 opened this issue Apr 22, 2020 · 2 comments
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@mrik974
Copy link

mrik974 commented Apr 22, 2020

What version of Go are you using (go version)?

1.11

Does this issue reproduce with the latest release?

I don't know, I'm reporting a (not a) bug issue from a software I'm trying to use

What operating system and processor architecture are you using (go env)?

debian x64 on openshift

What did you do?

I'm not a go developer, but I was trying to use a software based on go v 1.11, named jobber, on my openshift infrastructure.
Openshift uses, for security purposes, a policy called "arbitrary user id" to run its containers. This means when a container starts, a user with a "random" id is used to run all the processes in that container. This user is not "added" the unix way, and has no entry in /etc/passwd.
It has no name, and no home, but it has an ID.
The software couldn't start because it was failing when calling the method user.Current, which returned unknown userid: 1000140000

What did you expect to see?

I think user.Current() on Unix/Linux, should still create a user object if it finds a userid, even though it has no other information about it, and not fail.
Feel free (of course) to close this issue if you think it fails by design.

@ianlancetaylor ianlancetaylor changed the title user.Current() fails with "unknown userid" when it finds no entry about the user in "/etc/passwd" os/user: Current fails with "unknown userid" when it finds no entry about the user in "/etc/passwd" Apr 22, 2020
@ianlancetaylor
Copy link
Contributor

In the normal case on a Unix system, user.Current is just returning what getpwuid_r returns. If you call getpwuid_r when there is no user ID, it will return NULL, and so user.Current returns a value of type user.UnknownUserIdError.

I guess the argument for doing something different would be that if the program is built with CGO_ENABLED=0, then user.Current tries to work out a user.User value based on the environment variables USER and HOME. If those environment variables are found, the function succeeds.

So, on the one hand, presumably C programs that rely on getpwuid_r also fail on Openshift. On the other hand, user.Current does try to work without additional information in some cases. I see an argument both ways.

Why is your Go program calling user.Current? Does Openshift provide USER and HOME environment variables?

@ianlancetaylor ianlancetaylor added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Apr 22, 2020
@mrik974
Copy link
Author

mrik974 commented Apr 22, 2020

There is a userid, it's just not set in the passwd file.
The software I'm actually using does not seem to do other than getting the username and home.
I'll try and compile it myself with CGO_ENABLED=0.
I'll also open an issue on Jobber's git page.
I'm closing the issue, as it is not a bug. Thank you @ianlancetaylor for pointing me to the right direction.
I also think programs that rely on getpwuid_r fail on Openshift infrastructure. But not every program is meant to run there, openshift is mostly for webservices and databases.
Jobber was kind of "good to run" too because it's a "cron like" program with better output.

@mrik974 mrik974 closed this as completed Apr 22, 2020
@golang golang locked and limited conversation to collaborators Apr 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

3 participants