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

os: add Unsetenv #6423

Closed
gopherbot opened this issue Sep 19, 2013 · 13 comments
Closed

os: add Unsetenv #6423

gopherbot opened this issue Sep 19, 2013 · 13 comments
Assignees
Milestone

Comments

@gopherbot
Copy link

@gopherbot gopherbot commented Sep 19, 2013

by rks@google.com:

AFAICT, there is no easy way to remove entirely an variable from the environment
(besides clear the env and repopulating it with a filtered set of variables, which leaks
side effects to other callers). os.Setenv(key, "") leaves an empty entry in
the environment.
@cznic

This comment has been minimized.

Copy link
Contributor

@cznic cznic commented Sep 19, 2013

Comment 1:

Which problem does the proposed solution solves? (Assuming ENVVAR="" is not a problem.
Or is it?)
@gopherbot

This comment has been minimized.

Copy link
Author

@gopherbot gopherbot commented Sep 19, 2013

Comment 2 by rks@google.com:

Well, that's application specific. ENVVAR="" is distinct from ENVVAR not existing, and
some applications could not to discriminate between the two. Not to mention, it's nice
to be able to clean up the environment.
For a specific example, we have an application that passes information from one process
to another via the environment. The child process reads the environment, and then (wants
to) clear the key from the environment so that any further children do not have this env
key leaked to them. The best we can do now is set the key to "".
@bradfitz

This comment has been minimized.

Copy link
Contributor

@bradfitz bradfitz commented Sep 19, 2013

Comment 3:

> For a specific example, we have an application that passes information from one
process to another
> via the environment.
You can filter out environment variables however you'd like with the os/exec API.  Just
set the Cmd.Env as desired.  The default is to inherit your existing process's
environment, but you don't have to do that.
So this bug is only about unsetting an environment variable in the existing process,
which is much less interesting, since the environment isn't a typical way to communicate
within the lifetime of a program.  Typically you just look at the environment once at
start-up.
@gopherbot

This comment has been minimized.

Copy link
Author

@gopherbot gopherbot commented Sep 20, 2013

Comment 4 by rks@google.com:

That assumes that the code that launches the new process is aware of the variable to
remove. But that's not necessarily the case if the code consuming the var is a library.
In our (admittedly uncommon) case, what we have is a library that initializes one of its
packages vars from the environment, and then wants to clear it. The application using
the library may or may not ever do the exec, but our library has no input into this.
What we do now is set it to "", but then the env key leaks to the child processes. We
could clear the env and repopulate it in our library, but then other code looking at the
environment at the same time might see the partially reconstructed environment.
@rsc

This comment has been minimized.

Copy link
Contributor

@rsc rsc commented Sep 23, 2013

Comment 5:

Labels changed: added priority-later, go1.3, removed priority-triage.

Status changed to Accepted.

@rsc

This comment has been minimized.

Copy link
Contributor

@rsc rsc commented Dec 4, 2013

Comment 6:

Labels changed: added release-go1.3.

@rsc

This comment has been minimized.

Copy link
Contributor

@rsc rsc commented Dec 4, 2013

Comment 7:

Labels changed: removed go1.3.

@rsc

This comment has been minimized.

Copy link
Contributor

@rsc rsc commented Dec 4, 2013

Comment 8:

Labels changed: added repo-main.

@gopherbot

This comment has been minimized.

Copy link
Author

@gopherbot gopherbot commented Apr 9, 2014

Comment 9:

CL https://golang.org/cl/82040044 references this issue.
@bradfitz

This comment has been minimized.

Copy link
Contributor

@bradfitz bradfitz commented Apr 14, 2014

Comment 10:

Labels changed: added release-go1.4, removed release-go1.3.

@bradfitz

This comment has been minimized.

Copy link
Contributor

@bradfitz bradfitz commented Sep 30, 2014

Comment 11:

https://golang.org/cl/148370043

Owner changed to @bradfitz.

Status changed to Started.

@gopherbot

This comment has been minimized.

Copy link
Author

@gopherbot gopherbot commented Sep 30, 2014

Comment 12:

CL https://golang.org/cl/148370043 mentions this issue.
@bradfitz

This comment has been minimized.

Copy link
Contributor

@bradfitz bradfitz commented Oct 1, 2014

Comment 13:

This issue was closed by revision 85cdc49.

Status changed to Fixed.

@gopherbot gopherbot added fixed labels Oct 1, 2014
@rsc rsc added this to the Go1.4 milestone Apr 14, 2015
@rsc rsc removed the release-go1.4 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
wheatman added a commit to wheatman/go-akaros that referenced this issue Jun 25, 2018
Also address a TODO, making Clearenv pass through to cgo.

Based largely on Minux's earlier https://golang.org/cl/82040044

Fixes golang#6423

LGTM=iant, alex.brainman, r, rsc
R=rsc, iant, r, alex.brainman
CC=golang-codereviews
https://golang.org/cl/148370043
wheatman added a commit to wheatman/go-akaros that referenced this issue Jun 26, 2018
Also address a TODO, making Clearenv pass through to cgo.

Based largely on Minux's earlier https://golang.org/cl/82040044

Fixes golang#6423

LGTM=iant, alex.brainman, r, rsc
R=rsc, iant, r, alex.brainman
CC=golang-codereviews
https://golang.org/cl/148370043
wheatman added a commit to wheatman/go-akaros that referenced this issue Jul 9, 2018
Also address a TODO, making Clearenv pass through to cgo.

Based largely on Minux's earlier https://golang.org/cl/82040044

Fixes golang#6423

LGTM=iant, alex.brainman, r, rsc
R=rsc, iant, r, alex.brainman
CC=golang-codereviews
https://golang.org/cl/148370043
wheatman added a commit to wheatman/go-akaros that referenced this issue Jul 30, 2018
Also address a TODO, making Clearenv pass through to cgo.

Based largely on Minux's earlier https://golang.org/cl/82040044

Fixes golang#6423

LGTM=iant, alex.brainman, r, rsc
R=rsc, iant, r, alex.brainman
CC=golang-codereviews
https://golang.org/cl/148370043
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.