aws / opsworks-cookbooks

Chef Cookbooks for the AWS OpsWorks Service
Other
1.05k stars 1.23k forks source link

AWS Flow init script does not set $HOME or $USERNAME properly, leaves old junk in the environment #313

Closed redterror closed 6 years ago

redterror commented 9 years ago

The chroot call at here doesn't do anything to the environment, so there are leftover variables from the root env of the start script. Also there are leftovers littering the env.

Here's a snippit from one of my workers:

SUDO_GID=999
MAIL=/var/mail/root
USER=root
SHLVL=1
HOME=/root
OLDPWD=/
SUDO_UID=999
LOGNAME=root
_=/opt/aws/opsworks/current/bin/chef-client
TERM=
USERNAME=root
RACK_ENV=development
PATH=/home/deploy/.bundler/vantage_etl/ruby/1.9.1/bin:/usr/local/bin:/sbin:/usr/sbin:/bin:/usr/bin
BUNDLE_BIN_PATH=/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.5.3/bin/bundle
LANG=
SUDO_COMMAND=/opt/aws/opsworks/current/bin/chef_command_wrapper.sh -s /opt/aws/opsworks/current/bin/chef-client -j /var/lib/aws/opsworks/chef/2015-06-11-21-06-41-01.json -c /var/lib/aws/opsworks/client.stage2.rb -o deploy::default,opsworks_stack_state_sync,deploy::aws-flow-ruby,test_suite,opsworks_cleanup -L /var/lib/aws/opsworks/chef/2015-06-11-21-06-41-01.log -A  2>&1
SHELL=/bin/bash
SUDO_USER=aws
PWD=/srv/www/vantage_etl/current
LC_ALL=C
GEM_PATH=
GEM_HOME=/home/deploy/.bundler/vantage_etl/ruby/1.9.1
BUNDLE_GEMFILE=/srv/www/vantage_etl/releases/20150611210717/Gemfile
RUBYOPT=-rbundler/setup
RUBYLIB=/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.5.3/lib

The worker runs properly as the deploy user, but the env it inherits is wrong.