Skip to content

Commit

Permalink
fix env var from host truncated at equal sign
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasten committed Apr 24, 2024
1 parent 4638e77 commit 11d00b6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ego/premain/core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func PreMain(payload string, mounter Mounter, fs afero.Fs, hostEnviron []string)
// Convert host environment string array to key-value map
hostEnvironMap := make(map[string]string, len(hostEnviron))
for _, envVar := range hostEnviron {
splitString := strings.Split(envVar, "=")
splitString := strings.SplitN(envVar, "=", 2)
hostEnvironMap[splitString[0]] = splitString[1]
}

Expand Down
3 changes: 2 additions & 1 deletion ego/premain/core/core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestPremain(t *testing.T) {
assert := assert.New(t)
require := require.New(t)

hostEnviron := []string{"EDG_CWD=/host"}
hostEnviron := []string{"EDG_CWD=/host", "EDG_CONTAINS_EQUAL_SIGN=foo=bar"}
fs := afero.NewMemMapFs()

// sane default values
Expand All @@ -51,6 +51,7 @@ func TestPremain(t *testing.T) {
// Supply valid payload, no Marble
mounter := assertionMounter{assert: assert, expectedMounts: conf.Mounts, usedTargets: make(map[string]bool), remountAsHostFS: false}
assert.NoError(PreMain("", &mounter, fs, hostEnviron))
assert.Equal("foo=bar", os.Getenv("EDG_CONTAINS_EQUAL_SIGN"))

// Supply valid payload, no Marble
payload, err := json.Marshal(conf)
Expand Down

0 comments on commit 11d00b6

Please sign in to comment.