-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Remove CGO dependency for user lookup in allocdir #421
Conversation
os/user's user.Lookup requires that the artifact be compiled with CGO support enabled. This change instead reads /etc/passwd directly. The code was acquired from moby/moby#1096
Funny enough we actually have a much more comprehensive library to do this in a cross-platform way: https://github.com/mitchellh/go-homedir (this is used in almost every one of our other projects) Let's use that instead. Thanks for pointing it out! |
@mitchellh: The user lookup is done to determine the uid/gid of the "nobody" user. I think the library you linked is not intended for that. |
Ah, it isn't. Darn. I didn't look closely enough. |
I suppose this could be spun out as a separate package too =P Let me know what direction you want to take! |
Any updates on this one? |
Sorry been trying to get 0.2 and 0.2.1 out. I will test this PR soon. |
There is one other place we use it: nomad/client/driver/executor/exec_linux.go Line 127 in 6786367
So lets refactor it so it can be shared by both. |
Alright, I'll get on that. |
Also replaces user.Lookup in exec driver
@dadgar done, there's a small conflict in the exec driver's imports, probably cleaner git-wise to resolve on PR merge. |
@carlosdp: Thanks! |
hashicorp#421 removed the last piece of CGO dependant code. We we can stop building binaries with CGO enabled now.
I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions. |
os/user's user.Lookup requires that the artifact be compiled with CGO
support enabled. This change instead reads /etc/passwd directly.
The code was acquired from moby/moby#1096
I'm not 100% sure this is necessary. But I was having trouble compiling Nomad to linux/amd64 because I was getting
Lookup is not implmented for linux/amd64
, so I'm gunna throw it out here.This change was adopted by Docker, so it seems like a nice way to not have to mess with CGO when building Nomad.