Skip to content

manullay transmit env variables to selenium user in *debug*#131

Merged
1 commit merged intoSeleniumHQ:masterfrom
GroupeRocherDev:fix-env-for-debug
Dec 9, 2015
Merged

manullay transmit env variables to selenium user in *debug*#131
1 commit merged intoSeleniumHQ:masterfrom
GroupeRocherDev:fix-env-for-debug

Conversation

@mathieu-pousse
Copy link
Contributor

the debug images are using the sudo -E -i -u seluser to start the selenium stuffs and browser with the appropriated seluser.

Unfortunatly, as described in the sudoers documentation:

As a special case, if sudo's -i option (initial login) is specified, sudoers will initialize the environment regardless of the value of env_reset.

That means the env variables from the docker client won't be transmitted to the browser with -i

As the -i is mandatory to initiate the browser stuffs and -E is useless, I have added a trick to extract env variables from the root users and pass them to the seluser.

This is definitly needed to make the debug images working

@ghost
Copy link

ghost commented Dec 7, 2015

I have never run into this before so I can't really provide any good feedback on this. Is the reason for the change because we drop some values? Anybody else please?

@mathieu-pousse
Copy link
Contributor Author

Yes, I must provide the http_proxy and https_proxy in my environment and those variables are lost in "debug mode"

The way to reproduce it in a similar env is the following:

# start a container with environment variable ANYTHING
$ docker run -it -e ANYTHING=123 ubuntu:14.04 bash

# it is available
root@f29746d3ae3d:/# env | grep ANYTHING
ANYTHING=123

# create a user seluser as in docker-selenium images
root@f29746d3ae3d:/# adduser seluser
Adding user 'seluser' ...

# sudo w/o any option: ANYTHING is not propagated
root@f29746d3ae3d:/# sudo -u seluser env | grep ANYTHING

# sudo w -E option (to preserve the current environment variables in the child bash): ANYTHING is propagated
root@f29746d3ae3d:/# sudo -E -u seluser env | grep ANYTHING
ANYTHING=123

# sudo w -E -i option (to preserve the current environment variables in the child bash but also run .bashrc (needed to start a browser)): ANYTHING is not propagated
root@f29746d3ae3d:/# sudo -E -i -u seluser env | grep ANYTHING

The -i option drop all the env variables from the parent, regardless of other options as -E

The only way I found to make it work is here in my commit

HIH

@ghost
Copy link

ghost commented Dec 8, 2015

Thanks for the explanation. 2 things.

  1. Can you rebase this on master and resolve conflicts (not ready to merge yet)
  2. Have you signed the CLA please according to this https://github.com/SeleniumHQ/docker-selenium/blob/master/CONTRIBUTING.md ? Please indicate here. Thanks.

Signed-off-by: Mathieu POUSSE <m.mathieu.pousse@gmail.com>
@mathieu-pousse
Copy link
Contributor Author

here we are, yes i've signed the CLA

thx

ghost pushed a commit that referenced this pull request Dec 9, 2015
manullay transmit env variables to selenium user in *debug*
@ghost ghost merged commit 53a87e3 into SeleniumHQ:master Dec 9, 2015
@mathieu-pousse
Copy link
Contributor Author

Well done! Could you tell me if the CI does push the new docker images on the docker hub every time there is a commit on the master?

This is to know when I could rely on official images instead of using the one from our fork.

Thanks in advance for the response and for what you do with OSS !

M.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant