Skip to content
This repository has been archived by the owner on Dec 13, 2018. It is now read-only.

Setup environment for processes with os.Environ() #418

Closed
wants to merge 4 commits into from

Conversation

dqminh
Copy link
Contributor

@dqminh dqminh commented Feb 27, 2015

  • genericError constructor should not panic when we pass in nil error, but we should not pass nil error actually. This fixes it.
  • Instead of taking the raw config.Env, we use os.Environ() when execve which works correctly because the environment has been setup properly with newContainerInit

currently genericError constructors require not-nil error to be able to read
its Error() message

Signed-off-by: Daniel, Dao Quang Minh <dqminh89@gmail.com>
if the error is nil, we do not populate generic error's message, but the
constructor will still return a valid error

Signed-off-by: Daniel, Dao Quang Minh <dqminh89@gmail.com>
@LK4D4
Copy link
Contributor

LK4D4 commented Feb 27, 2015

@dqminh Some error on jenkins. Looks like easy to fix.

@LK4D4
Copy link
Contributor

LK4D4 commented Feb 27, 2015

@dqminh Btw very good catch about genericError - panics all over code :)

dqminh added 2 commits March 1, 2015 09:51
instead of taking the raw config.Env, we use `os.Environ()` which works
correctly because the environment has been setup properly with
`newContainerInit`

Signed-off-by: Daniel, Dao Quang Minh <dqminh89@gmail.com>
instead of taking the raw config.Env, we use `os.Environ()` which works
correctly because the environment has been setup properly with
`newContainerInit`

Signed-off-by: Daniel, Dao Quang Minh <dqminh89@gmail.com>
@LK4D4
Copy link
Contributor

LK4D4 commented Mar 2, 2015

ping @jfrazelle
Pls take a look when you'll have time :)

@jessfraz
Copy link
Contributor

jessfraz commented Mar 2, 2015

I rebuilt ;)

@LK4D4
Copy link
Contributor

LK4D4 commented Mar 2, 2015

@jfrazelle Thank you very much!

@LK4D4
Copy link
Contributor

LK4D4 commented Mar 2, 2015

LGTM

1 similar comment
@rjnagal
Copy link
Contributor

rjnagal commented Mar 2, 2015

LGTM

@rjnagal
Copy link
Contributor

rjnagal commented Mar 2, 2015

@dqminh Can you squash some of the commits?

@dqminh
Copy link
Contributor Author

dqminh commented Mar 2, 2015

@rjnagal which commits do you want me to squash. The two commits that set os.Environ() for both setns and init process ?

@rjnagal
Copy link
Contributor

rjnagal commented Mar 2, 2015

yes, the last two.

@crosbymichael
Copy link
Contributor

Why do we need to do this? why is config.Env not enough?

@LK4D4
Copy link
Contributor

LK4D4 commented Mar 2, 2015

@crosbymichael There is no PATH and HOME. Tests in docker run and exec failing without this. Do you think that tests are wrong?

@crosbymichael
Copy link
Contributor

why is there no PATH and home? docker prepopulates both of these either in the image or there is a hard coded default for PATH

@LK4D4
Copy link
Contributor

LK4D4 commented Mar 2, 2015

@dqminh
Copy link
Contributor Author

dqminh commented Mar 3, 2015

@crosbymichael @LK4D4 i think the reason there's no PATH or HOME is because we set HOME / PATH with Setenv, but exec the process with config.Env which doesnt include everything. Also using os.Environ is better because it also removes the duplicated environment variables, you can see this in the test.

@crosbymichael
Copy link
Contributor

I really don't think we should do this because it will cause env vars to leak into the container. The config.Env should have everything that the container's process needs, if it does not, I think it's a bug.

I'm just scared by doing this we will get a custom PATH that the user specified overwritten.

@LK4D4
Copy link
Contributor

LK4D4 commented Mar 3, 2015

I'm not sure about PATH, but "HOME" we set indeed before Execv in setupUser by os.Setenv, should we pass append(l.config.Env, os.Getenv("HOME")?

@mrunalp
Copy link
Contributor

mrunalp commented Mar 3, 2015

I agree with @crosbymichael . We should be able to modify config.Env ourselves. @LK4D4 I think that should work.

@LK4D4
Copy link
Contributor

LK4D4 commented Mar 3, 2015

At least we need fix for genericError :)

@mrunalp
Copy link
Contributor

mrunalp commented Mar 3, 2015

@LK4D4 agree :) @dqminh Maybe split that off into a separate PR?

@dqminh
Copy link
Contributor Author

dqminh commented Mar 4, 2015

agreed. I will remove the os.Environ() commit and change this into genericError patch.

@dqminh dqminh closed this Mar 4, 2015
@dqminh
Copy link
Contributor Author

dqminh commented Mar 4, 2015

@LK4D4 @mrunalp the genericError patch is here #424

avagin pushed a commit to avagin/libcontainer that referenced this pull request Mar 6, 2015
Replacement of docker-archive#418

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants