Project

General

Profile

« Previous | Next » 

Revision 56b4310f

Added by Dominic Cleal over 8 years ago

fixes #11170 - pass quoted args through foreman-rake

Use the special "$@" to correctly pass quoted arguments through
foreman-rake, through su and to the underlying rake command. Ensures
the JSON in this command is unharmed:

foreman-rake config -- -k trusted_puppetmaster_hosts -v '["foo.bar.com"]'

Also swallows the "--" which gets passed through on some versions of
rake.

(cherry picked from commit e28614c06bf6ca27e5518e8fae667b9ade3f46b2)

View differences:

lib/tasks/config.rake
end
def run(args)
args.shift if args.first == '--'
parser.parse!(args)
if @key && @key_values.any?
script/foreman-rake
cd ~foreman || die "Cannot change to foreman home directory"
[ -f Gemfile ] && BUNDLER_CMD="bundle exec"
CMD="$BUNDLER_CMD $RAKE_CMD $*"
CMD="$BUNDLER_CMD $RAKE_CMD"
if [ $USERNAME = foreman ]; then
RAILS_ENV=production $CMD
RAILS_ENV=production $CMD "$@"
else
su - foreman -s /bin/bash -c "RAILS_ENV=production $CMD"
su - foreman -s /bin/bash -c 'RAILS_ENV=production "$0" "$@"' -- $CMD "$@"
fi

Also available in: Unified diff