Issue #18031 has been reported by Oliver Schad.

----------------------------------------
Bug #18031: puppet/util/suidmanager.rb and value for combine/interface for 
combine
https://projects.puppetlabs.com/issues/18031

Author: Oliver Schad
Status: Unreviewed
Priority: Normal
Assignee: 
Category: provider
Target version: 
Affected Puppet version: 3.0.1
Keywords: 
Branch: 


Heyho,

we ran into an error in the puppetlabs postgresql module: we wanted to create a 
simple db with the postgresql::db define. That leads to an error, because the 
output of the command psql with run_and_capture() leads to an output to stderr 
which is mixed up with stdout.

This output then is analyzed in the postgresql module if it contains something 
greater zero, but rubys to_i can't handle this error message of course, mixed 
up with the regular output.

So we took a look at the method run_and_capture() and found that in the 
suidmanager.rb the parameter "combine" is not offered to the outer world and 
that is set to "true" which means always is the stdout mixed with stderr and 
you can't influence it from outside. So the call from the postgresql module has 
to fail.

Puppet::Util::Execution.execute(command, :failonfail => false, :combine => 
true, ...)

I've added this combine parameter to the default parameters and changed the 
call to:

Puppet::Util::Execution.execute(command, :failonfail => false, :combine => 
options[:combine]

That offered an interface to this parameter to the outer world.

On the postgresql module I've used this parameter to split stdout and stderr so 
it worked. But my question is if it useful if the combine parameter is per 
defulat set to "true". I've found only one user for that call in puppet itself, 
it's the exec provider.

However you should offer the combine parameter to the outer world, the default 
value is another topic.

The whole method looks now like this:

====================== snip ===============

  def run_and_capture(command, new_uid=nil, new_gid=nil, options = {})

    # specifying these here rather than in the method signature to allow 
callers to pass in a partial
    # set of overrides without affecting the default values for options that 
they don't pass in
    default_options = {
        :override_locale => true,
        :custom_environment => {},
        :combine => true,
    }

    options = default_options.merge(options)

    output = Puppet::Util::Execution.execute(command, :failonfail => false, 
:combine => options[:combine],
                                  :uid => new_uid, :gid => new_gid,
                                  :override_locale => options[:override_locale],
                                  :custom_environment => 
options[:custom_environment])
    [output, $CHILD_STATUS.dup]
  end

================== snap =======================

Regards
Oli


-- 
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 puppet-bugs@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-bugs+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-bugs?hl=en.

Reply via email to