Skip to content

Commit

Permalink
preserve all C8Y_SETTINGS env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
reubenmiller committed Jun 18, 2024
1 parent 89e5b87 commit 3efe05f
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions pkg/cmd/sessions/set/set.manual.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,18 +126,16 @@ func (n *CmdSet) RunE(cmd *cobra.Command, args []string) error {
// But this has a side effect that you can't control the profile handing via environment variables when using the interact session selection
allowedEnvValues := []string{
"C8Y_SETTINGS_SESSION_HIDE",
// Also preserve encryption settings
// Preserve encryption settings
"C8Y_PASSPHRASE",
"C8Y_PASSPHRASE_TEXT",
"C8Y_SETTINGS_ENCRYPTION_ENABLED",
"C8Y_SETTINGS_ENCRYPTION_CACHEPASSPHRASE",
}
env_prefix := strings.ToUpper(config.EnvSettingsPrefix)
for _, env := range os.Environ() {
if strings.HasPrefix(env, env_prefix) && !strings.HasPrefix(env, config.EnvPassphrase) && !strings.HasPrefix(env, config.EnvSessionHome) {
parts := strings.SplitN(env, "=", 2)
if len(parts) == 2 {
if !slices.Contains(allowedEnvValues, parts[0]) {
if !slices.Contains(allowedEnvValues, parts[0]) && !strings.HasPrefix("C8Y_SETTINGS_", parts[0]) {
os.Unsetenv(parts[0])
}
}
Expand Down

0 comments on commit 3efe05f

Please sign in to comment.