aws-vault icon indicating copy to clipboard operation
aws-vault copied to clipboard

AWS-Vault clear does not clear `AWS_VAULT` environmental variable

Open hunttom opened this issue 2 years ago • 0 comments

  • [ x] I am using the latest release of AWS Vault
  • [N] I have provided my .aws/config (redacted if necessary)
  • [N] I have provided the debug output using aws-vault --debug (redacted if necessary)

Running aws-vault clear does not clear out the AWS_VAULT environmental variable.

Steps to reproduce:

  1. Run aws-vault exec <PROFILE> --ecs-server
  2. Run echo $AWS_VAULT to see <PROFILE>
  3. Run aws-vault clear
  4. Run echo $AWS_VAULT (<PROFILE> is still set)
  5. Validate profile is still set by running aws-vault exec <PROFILE> --ecs-server
  6. Still get warning: aws-vault: error: exec: aws-vault sessions should be nested with care, unset AWS_VAULT to force

Recommend adding to the clear function:

	if os.Getenv("AWS_VAULT") != "" {
		err = os.Unsetenv("AWS_VAULT")
		if err != nil {
			return fmt.Errorf("Unable to unset environmental variable: 'AWS_VAULT'")
		}
	}

hunttom avatar Mar 30 '22 18:03 hunttom