Issue #3023 has been updated by James Turnbull.

Status changed from Tests Insufficient to Accepted


----------------------------------------
Bug #3023: Tests needed to show that "exec"ed scripts don't get parents 
stdin/stdout/stderr
http://projects.puppetlabs.com/issues/3023

Author: Alan Harder
Status: Accepted
Priority: Normal
Assigned to: Markus Roberts
Category: exec
Target version: 0.25.5
Affected version: 0.25.2
Keywords: exec stdin
Branch: 


Here's how I found this odd behavior (in a version with the patch from #2731).. 
I had a script that runs Oracle sqlplus like this:
<pre>sqlplus {login-info} @file.sql</pre>
I have now learned that if file.sql doesn't end in a "quit;" command, sqlplus 
proceeds to read stdin for more commands, and terminates at EOF of stdin.  
Admittedly, our sql script should end in "quit;" or the script could explicitly 
have < /dev/null for the sqlplus call.. but it worked fine in Puppet 0.24.8 so 
we didn't notice the lack of proper termination.

Here is my test case for odd stdin in Puppet 0.25.2:
<pre>
  file { '/tmp/test.sh':
    mode => 755,
    content => '#!/bin/sh

echo "GO: one two three"
cat
echo "2 one two three"
echo "3 one two three"
echo "4 one two three"
echo "5 one two three"
echo "6 one two three"
'
  }
  exec { '/tmp/test.sh':
    logoutput => true
  }
</pre>

On Solaris 10 with ruby 1.8.7 this results in:
<pre>
debug: //Node[<nodename>]/File[/tmp/test.sh]/checksum: Initializing checksum 
hash
debug: //Node[<nodename>]/File[/tmp/test.sh]: Changing content,mode
debug: //Node[<nodename>]/File[/tmp/test.sh]: 2 change(s)
debug: //Node[<nodename>]/File[/tmp/test.sh]: Creating checksum 
{md5}5398f341fec9305eadf46d300c29261d
notice: //Node[<nodename>]/File[/tmp/test.sh]/content: defined content as 
'unknown checksum'
notice: //Node[<nodename>]/File[/tmp/test.sh]/mode: defined 'mode' as '755'
debug: //Node[<nodename>]/Exec[/tmp/test.sh]: Changing returns
debug: //Node[<nodename>]/Exec[/tmp/test.sh]: 1 change(s)
debug: //Node[<nodename>]/Exec[/tmp/test.sh]: Executing '/tmp/test.sh'
debug: Executing '/tmp/test.sh'
notice: //Node[<nodename>]/Exec[/tmp/test.sh]/returns: GO: one two three
notice: //Node[<nodename>]/Exec[/tmp/test.sh]/returns: ee"
notice: //Node[<nodename>]/Exec[/tmp/test.sh]/returns: echo "6 one two three"
notice: //Node[<nodename>]/Exec[/tmp/test.sh]/returns: 2 one two three
notice: //Node[<nodename>]/Exec[/tmp/test.sh]/returns: 3 one two three
notice: //Node[<nodename>]/Exec[/tmp/test.sh]/returns: 4 one two three
notice: //Node[<nodename>]/Exec[/tmp/test.sh]/returns: 5 one two thr
notice: //Node[<nodename>]/Exec[/tmp/test.sh]/returns: executed successfully
debug: Finishing transaction 8649396 with 3 changes
debug: Storing state
debug: Stored state in 1.16 seconds
warning: Value of 'preferred_serialization_format' (pson) is invalid for 
report, using default (yaml)
debug: report supports formats: b64_zlib_yaml marshal raw yaml; using yaml
notice: Finished catalog run in 2.60 seconds
</pre>

You can see that the "cat" command read the script itself, from "ee" on the "5" 
line and all of the last line.  Control then returned to /bin/sh and it ran the 
remaining commands up to the truncated "5" line.  I suppose stdin for the 
exec'ed script should be /dev/null or something that won't cause this odd 
behavior if the script reads stdin.



-- 
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