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

Support for overriding variables inside the container at runtime #424

Closed
wants to merge 11 commits into from

Conversation

jtriley
Copy link
Contributor

@jtriley jtriley commented Dec 21, 2016

Fixes #411

This allows users to explicitly override environment variables within the container via SENV_ prefixed environment variables. This prefix gets stripped and the result gets set within the containers's environment. This is especially useful for proxying unsecure variables stripped by ld for suid/sgid executables to the container:

$ whoami
test
$ export LD_LIBRARY_PATH=/test/path
$ singularity exec cuda75.img env | grep LD_LIBRARY_PATH
$ export SENV_LD_LIBRARY_PATH=/test/path
$ singularity exec cuda75.img env | grep LD_LIBRARY_PATH
LD_LIBRARY_PATH=/test/path
  • adds a singularity_env_override method to src/lib/action/action.c called by singularity_action_init that looks for env variables that start with prefix, strips the prefix, and sets the resulting key/value inside the container.

@singularityware-admin

@gmkurtzer
Copy link
Contributor

Hi @jtriley, just wanted to check to see if this is ready for a review.

Thanks!

@jtriley
Copy link
Contributor Author

jtriley commented Dec 21, 2016

@gmkurtzer yup this is ready, thanks!

...removes the strstr call but requires caller to make sure prefix ends
with '_' if desired.
@jtriley
Copy link
Contributor Author

jtriley commented Dec 29, 2016

@gmkurtzer I reworked this using strcmp and strtok_r as discussed. Ready for a review.

@boegel
Copy link

boegel commented Jan 11, 2017

Any progress on this? Incl. ETA for a released version with this included?

@gmkurtzer
Copy link
Contributor

@jtriley Can you take a look at the lib-refactor branch and rebase to that? It is gonna be a bit messy I know as things will have to move, but I would prefer you get these changes into that rather then have me respin this into that branch.

Check out https://github.com/singularityware/singularity/blob/lib-refactor/src/lib/runtime/environment/environment.c for a starting point, and you should see I used your code as a template.

Let me know if you have any questions, thanks!

@jtriley
Copy link
Contributor Author

jtriley commented Jan 20, 2017

@gmkurtzer will do

@gmkurtzer gmkurtzer added this to the 2.3 Release milestone Mar 25, 2017
@gmkurtzer
Copy link
Contributor

This has been implemented in the development branch by using the environment variable syntax SINGULARITYENV_ where everything post string will be transposed into the container. To unset a variable simply make it equal a zero length string.

@gmkurtzer gmkurtzer closed this May 24, 2017
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.

None yet

3 participants