Issue #4288 has been updated by Alan Harder.

The 1-line patch from #4233#note-9 didn't change the behavior here.

We have written execs basically assuming the "command" text is given to the 
shell, so we have some that start with "if", others that redirect input like: 
"(echo yes; echo '') | some_command" (starting with "(echo" also gets this 
error).  Another one starts with variable assignment, command => "i=`expr ...`"

The workaround I found is to just put "true; " at the front of these commands.. 
this matches /usr/bin/true so there is no error reported, and everything after 
this is given to the shell as before.

James told me: "we're explictly not allowing yu to call a bash subcmd due to 
another issue - can you add that to the ticket and we'll do a design discussion 
internally about how to address this?"

It was a lot more convenient to put short shell scripts right in the command.. 
even with this "check" you can put arbitrary script after the first command.  I 
guess you need to decide whether to open this back up (any script) or really 
lock it down (keep this check and limit the command to a _single_ command..)
Thanks!
----------------------------------------
Bug #4288: Error if exec command starts with shell built-in like "if"
http://projects.puppetlabs.com/issues/4288

Author: Alan Harder
Status: Needs design decision
Priority: Normal
Assigned to: 
Category: exec
Target version: 2.6.1
Affected version: 2.6.0rc4
Keywords: 
Branch: 


<pre>exec { 'foo':
  command => 'if [ "abc" != "def" ]; then echo "this is a test"; fi',
  logoutput => true
}</pre>

With the above test case on 2.6.0rc4 (on Solaris 10 with ruby 1.8.7) I get:
<pre>err: /Stage[main]//Node[...]/Exec[foo]/returns: change from notrun to 0 
failed: Could not find executable 'no if in /usr/bin /usr/sbin'</pre>

A command like this worked in 0.25.5.. is the behavior change intentional, or 
is this a bug?

Side node: if I add whitespace at the front (command => ' if [ .....') then the 
error says *Could not find command ''*


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-bugs?hl=en.

Reply via email to