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

RFC: Implement a sandbox for environment variables and files #2391

Open
wants to merge 2 commits into
base: master
from

Conversation

Projects
None yet
7 participants
@jsgf
Copy link

jsgf commented Apr 5, 2018

Allow rustc to be invoked with constraints on which environment variables may
be queried, and which files may be included.

Rendered

Companion PR: rust-lang/rust#49387

@jsgf jsgf changed the title Initial draft of env-sandboxing RFC env-sandboxing RFC Apr 5, 2018

@jsgf jsgf changed the title env-sandboxing RFC RFC: Implement a sandbox for environment variables and files Apr 5, 2018

These are processed in the order:
1. `--env-clear`
2. `--env-allow NAME`
3. `--env-set NAME=VAL`

This comment has been minimized.

@fbstj

fbstj Apr 6, 2018

what's the benefit of this (rustc --env-set NAME=value) over NAME=value rustc --env-allow NAME other than brevity? is it specifically to stop propagation into sub-processes?

This comment has been minimized.

@jsgf

jsgf Apr 6, 2018

Author

Several reasons:

  • You can use it to override the value of things that rustc (or the linker) itself uses, like PATH or LD_LIBRARY_PATH (among others)
  • You can just change rustc's command-line args, whereas manipulating the environment might need deeper changes to whatever's invoking rustc (possibly system-dependent changes)
  • Non-propagation isn't something that had occurred to me, but it is related to my first point

This comment has been minimized.

@fbstj

fbstj Apr 6, 2018

my question was more that my understanding is that running > NAME=value rustc --env-allow NAME is only overriding the value for that instantiation of rustc, so I don't understand what your first point is specifying? are you meaning that some point before/around your 'sandboxed' area is able to access the environment but then the majority is going to use the --env-allow value?

your option may also be more sensible for any shells/clients which don't support 'instantiation-local environment variables', but I think the RFC could do with more discussion of these points.

thanks!

This comment has been minimized.

@jsgf

jsgf Apr 9, 2018

Author

I mean that when rustc itself is - say - invoking the linker, it may use $PATH to find the executable. If we want env!("PATH") to work at all, but not necessarily return the PATH that's been set up for rustc to be able to find its linker, then we need some way of allowing env!("PATH") and rustc's own runtime call to std::env::var("PATH") to be able to return distinct values.

process environment variable to be logically pasted into the source as a string
(or `Option` string).

`Rustc` has the following command-line options to allow the access to

This comment has been minimized.

@fbstj

fbstj Apr 6, 2018

nit: capitalised rustc

@sfackler

This comment has been minimized.

Copy link
Member

sfackler commented Apr 6, 2018

rust-lang/cargo#3676 is sort of related.

@jsgf

This comment has been minimized.

Copy link
Author

jsgf commented Apr 6, 2018

@sfackler There seems to be a few use-cases in controlling the environment visible to build scripts.

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Apr 11, 2018

cc @rust-lang/dev-tools -- I'm never sure who owns this sort of thing, but it's not clearly T-compiler. =)

@Centril

This comment has been minimized.

Copy link
Contributor

Centril commented Apr 11, 2018

@nikomatsakis so my reasoning for T-compiler was: "well, it makes changes to rustc" but that's not the best argument ever =P

@Manishearth

This comment has been minimized.

Copy link
Member

Manishearth commented Apr 11, 2018

I think it's fine under devtools.

(I also like this RFC and do think we (the devtools team) should eventually think about sandboxing build processes in general)

@est31

This comment has been minimized.

Copy link
Contributor

est31 commented Apr 12, 2018

I also like this RFC and do think we (the devtools team) should eventually think about sandboxing build processes in general

ohhh that would be awesome ❤️ ❤️ ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.