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

Do not inherit HOME and USER env vars from pebble daemon environment #262

Merged
merged 5 commits into from
Aug 8, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion internals/overlord/cmdstate/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,14 @@ func Exec(st *state.State, args *ExecArgs) (*state.Task, ExecMetadata, error) {
return nil, ExecMetadata{}, errors.New("cannot use interactive mode without a terminal")
}

// Inherit the pebble daemon environment.
// Inherit the pebble daemon environment (except HOME and USER env vars)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's worth expanding this comment, explaining why it was necessary. Also, if HOME and USER aren't present in args.Environment, they are set up below based on the username and home directory of the provided user ID (or the current user if not specified).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed in 88a02c5

environment := osutil.Environ()
for _, k := range []string{"HOME", "USER"} {
if _, ok := environment[k]; ok {
delete(environment, k)
benhoyt marked this conversation as resolved.
Show resolved Hide resolved
}
}

for k, v := range args.Environment {
// Requested environment takes precedence.
environment[k] = v
Expand Down
Loading