Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-1209

Exec provider should support environment variables with empty values

    XMLWordPrintable

Details

    • Bug Fix
    • Exec provider now supports empty environment variables. Even if an environment variable is set on the system, if it is set at empty, Puppet temporarily overwrites it during execution.

    Description

      The exec provider takes an environment parameter that takes either a string or an array of variables. Each variable is expressed as a pair, like "KEY=value" for example. The problem is that the code that parses this string requires a value whereas this is not strictly necessary, like "KEY=" should be perfectly acceptable. The code in Puppet::Provider::Exec.run looks like this:

      if setting =~ /^(\w+)=((.|\n)+)$/
       env_name = $1
       value = $2
      

      Simply changing the regular expression to use "*" instread of "+" for the value should work just fine:

      irb(main):001:0> setting = 'KEY='
       => "KEY="
       irb(main):002:0> setting =~ /^(\w+)=((.|\n)+)$/
       => nil
       irb(main):003:0> setting =~ /^(\w+)=((.|\n)*)$/
       => 0
       irb(main):004:0> $1
       => "KEY"
       irb(main):005:0> $2
       => "" 
      

      So, the value of empty string is exactly what was requested.

      Attachments

        Activity

          People

            melissa Melissa Stone
            redmine.exporter redmine.exporter
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Zendesk Support