Bug #11170
foreman-rake: setting complex parameters (arrays, hashes) broken?
Description
Trying to set complex Foreman parameters (i.e. arrays or hashes) using foreman-rake results in various errors, i.e.
[root@foreman ~]# foreman-rake -- config -k trusted_puppetmaster_hosts -v '[ "foo.bar.com", "foo.baz.org" ]' rake aborted! A JSON text must at least contain two octets! Tasks: TOP => config (See full trace by running task with --trace)
Another variant:
[root@foreman ~]# foreman-rake -- config -k trusted_puppetmaster_hosts -v '["foo.bar.com", "foo.baz.org"]' rake aborted! 387: unexpected token at 'foo.bar.com,' Tasks: TOP => config (See full trace by running task with --trace)
Related issues
Associated revisions
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.
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)
History
#1
Updated by Dominic Cleal almost 8 years ago
This works on a dev installation, so I'm pretty sure it's a combination of foreman-rake and ruby193-rake, which both use double quoted strings with su etc to pass commands through.
#2
Updated by The Foreman Bot almost 8 years ago
- Status changed from New to Ready For Testing
- Pull request https://github.com/theforeman/foreman/pull/2562 added
- Pull request deleted (
)
#3
Updated by Robert Rauch almost 8 years ago
I have provided a PR, which should fix it, as far as the foreman-rake wrapper is concerned. The same issue applies to the ruby193-rake wrapper, which apperently is in use on some Systems (like Centos7). I guess the ruby193-rake wrapper is not controlled by the Foreman guys, so this should probably get fixed upstream.
#4
Updated by Dominic Cleal almost 8 years ago
We actually adopted the ruby193 wrappers as they were removed from SCLs, so the source is over here now: https://github.com/theforeman/foreman-packaging/tree/rpm/develop/ruby-wrapper
I happened to fix this in an unmerged refactoring (https://github.com/theforeman/foreman-packaging/pull/249/files#diff-2092b3ff9c37e1fddb7536cd9beec494R161), so I can reapply my fix to the current version so we have both instances working.
#5
Updated by Dominic Cleal almost 8 years ago
There's a further issue affecting SCL OSes in scl-utils itself: https://bugzilla.redhat.com/show_bug.cgi?id=1248418, so this will only fix it completely for the others. Once that's fixed we'll also need the fix to the ruby193-esque wrappers.
#6
Updated by Dominic Cleal almost 8 years ago
- Related to Bug #11275: hammer ... list --search with spaces in arg fails on SCL OS added
#7
Updated by Dominic Cleal almost 8 years ago
- Status changed from Ready For Testing to Closed
- % Done changed from 0 to 100
Applied in changeset e28614c06bf6ca27e5518e8fae667b9ade3f46b2.
#8
Updated by Dominic Cleal almost 8 years ago
- Assignee set to Dominic Cleal
- Legacy Backlogs Release (now unused) set to 72
- Pull request https://github.com/theforeman/foreman/pull/2586 added
- Pull request deleted (
https://github.com/theforeman/foreman/pull/2562)
fixes #11275, #11170 - pass spaces/quotes in args through SCL wrappers
Changes the ruby193/SCL wrappers to create a temporary file containing
all original arguments from the ruby193-* command and then executes it
via "scl enable". This fixes two quoting-related bugs with these
wrappers.
1. #11170: the "scl enable" command has a bug (RHBZ#1248418) where it
internally uses temporary shell scripts and doesn't escape double
quotes, so JSON strings can't be passed through as arguments.
2. #11275: the ruby-wrappers passed through arguments word-by-word,
causing arguments containing spaces to be split up. It should have
used the special quoted "$@" variable.