Possibly bug in Puppetlabs/Registry module

91 views
Skip to first unread message

Mark Wolek

unread,
Apr 23, 2015, 10:45:04 PM4/23/15
to puppet...@googlegroups.com
Go figure, the very first thing I try to do in Puppet may be a bug!

Attempting to create a registry value of type array does not work properly when a "-" is in one of the strings being added.

registry_value { 'HKLM\Software\Microsoft\Rpc\Internet\Ports':
ensure => present,
type => array,
data => ['6500-7000']
}



Results in this:

PS C:\Users\Administrator> Get-ItemProperty 'HKLM:\Software\microsoft\Rpc\Internet'

Ports                  : {6500-7000, ?}


Using the GUI to look at the registry, results in a bunch of random words and characters being appended to the end.

Simply opening the registry value in the GUi and clicking OK without actually changing anything resolves this.

I've tested this quite a bit trying to troubleshoot, and it seems specifically related to the dash / hyphen character being in the string.

Mark Wolek

unread,
Apr 24, 2015, 6:52:17 PM4/24/15
to puppet...@googlegroups.com
We believe this has something to do with puppet inserting strings that are not null terminated, but I've had no luck at all adding termination to the string...  have tried single and double quoting it.  \x0 \00 \000 so many types of termination tried but nothing seems to do the trick...

jcbollinger

unread,
Apr 27, 2015, 2:06:31 PM4/27/15
to puppet...@googlegroups.com


On Friday, April 24, 2015 at 1:52:17 PM UTC-5, Mark Wolek wrote:
We believe this has something to do with puppet inserting strings that are not null terminated, but I've had no luck at all adding termination to the string...  have tried single and double quoting it.  \x0 \00 \000 so many types of termination tried but nothing seems to do the trick...



Having examined the source of the latest version of this module, I can tell you that Puppet relies on registry support from the Ruby standard library to handle the low-level details of registry manipulation.  As far as I can tell, Puppet's own code does not do any parsing or processing of registry values that would be sensitive to a hyphen character in the string.  Were you speculating about that being related to the problem, or do you in fact see different results when the array elements do not contain hyphens?

I am anyway inclined to think that the problem is NOT wrong string termination, at least of the values you specify in your manifest, because Get-ItemProperty is giving you an array value in which the first element appears completely correct.  The problem could, however, be related to incorrectly specifying the size of the array to Windows, or failing to provide an array terminator (I'm not much of a registry tinkerer, so I'm not sure which would actually be applicable).

I encourage you to file a ticket against the module.  I am uncertain whether the issue is there or in the Ruby standard library because the docs of the relevant library class suffer from the vagueness typical of Ruby docs, but the module maintainers are best positioned to evaluate that.  Even if the problem turns out to be in the underlying Ruby library, it does not appear that the module's tests include any that exercise setting or retrieving values of type "array", and a ticket against the module should result at least in addition of such tests.


John

Mark Wolek

unread,
Apr 27, 2015, 4:28:17 PM4/27/15
to puppet...@googlegroups.com
Thanks John! It appears to open a ticket I do so on the GitHub site by logging in, is this correct?  

The reason for suspecting the lack of string termination is due to what we see in the Registry GUI, which is random characters and words after the string, then you hit Refresh on the page, the random characters and strings change.

It does seem specific to a hyphen being in the string, but I will test again to be certain.

Thanks!
Mark

Rob Reynolds

unread,
Apr 28, 2015, 5:38:23 PM4/28/15
to puppet...@googlegroups.com
On Mon, Apr 27, 2015 at 11:28 AM, Mark Wolek <mark...@gmail.com> wrote:
Thanks John! It appears to open a ticket I do so on the GitHub site by logging in, is this correct?  

The reason for suspecting the lack of string termination is due to what we see in the Registry GUI, which is random characters and words after the string, then you hit Refresh on the page, the random characters and strings change.

It does seem specific to a hyphen being in the string, but I will test again to be certain.

Hi Mark,
 What version of the registry module are you using? What version of the Puppet agent are you on? The issues you stated above were known issues that we believe we have corrected in newer versions of Puppet.  

We also vendor Ruby into the Puppet Installer for Windows (and we've done this almost since the first release supporting Windows), so we can usually rule out Ruby compatibilities in some respects, but not always with modules. 

 

Thanks!
Mark


On Monday, April 27, 2015 at 9:06:31 AM UTC-5, jcbollinger wrote:


On Friday, April 24, 2015 at 1:52:17 PM UTC-5, Mark Wolek wrote:
We believe this has something to do with puppet inserting strings that are not null terminated, but I've had no luck at all adding termination to the string...  have tried single and double quoting it.  \x0 \00 \000 so many types of termination tried but nothing seems to do the trick...



Having examined the source of the latest version of this module, I can tell you that Puppet relies on registry support from the Ruby standard library to handle the low-level details of registry manipulation.  As far as I can tell, Puppet's own code does not do any parsing or processing of registry values that would be sensitive to a hyphen character in the string.  Were you speculating about that being related to the problem, or do you in fact see different results when the array elements do not contain hyphens?

I am anyway inclined to think that the problem is NOT wrong string termination, at least of the values you specify in your manifest, because Get-ItemProperty is giving you an array value in which the first element appears completely correct.  The problem could, however, be related to incorrectly specifying the size of the array to Windows, or failing to provide an array terminator (I'm not much of a registry tinkerer, so I'm not sure which would actually be applicable).

I encourage you to file a ticket against the module.  I am uncertain whether the issue is there or in the Ruby standard library because the docs of the relevant library class suffer from the vagueness typical of Ruby docs, but the module maintainers are best positioned to evaluate that.  Even if the problem turns out to be in the underlying Ruby library, it does not appear that the module's tests include any that exercise setting or retrieving values of type "array", and a ticket against the module should result at least in addition of such tests.


John

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/c0503ad5-5d72-48ed-868f-522491f93e78%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Rob Reynolds
Developer, Puppet Labs

PuppetConf 2015 is coming to Portland, Oregon! Join us October 5-9.
Register now to take advantage of the Early Adopter discount save $349!

Rob Reynolds

unread,
Apr 28, 2015, 5:46:15 PM4/28/15
to puppet...@googlegroups.com
On Tue, Apr 28, 2015 at 12:37 PM, Rob Reynolds <r...@puppetlabs.com> wrote:


On Mon, Apr 27, 2015 at 11:28 AM, Mark Wolek <mark...@gmail.com> wrote:
Thanks John! It appears to open a ticket I do so on the GitHub site by logging in, is this correct?  

The reason for suspecting the lack of string termination is due to what we see in the Registry GUI, which is random characters and words after the string, then you hit Refresh on the page, the random characters and strings change.

It does seem specific to a hyphen being in the string, but I will test again to be certain.

Hi Mark,
 What version of the registry module are you using? What version of the Puppet agent are you on? The issues you stated above were known issues that we believe we have corrected in newer versions of Puppet.  


For reference, in Puppet it was PUP-1389[1] where we fixed the issue (Puppet v3.4.3+). In the Registry module we've recently applied similar changes[2], but mostly due to compatibility with Ruby 2.1.x.

Mark Wolek

unread,
May 1, 2015, 5:59:19 PM5/1/15
to puppet...@googlegroups.com
C:\Users\Administrator>puppet apply --version
3.7.5

C:/ProgramData/PuppetLabs/puppet/etc/modules
└─┬ puppetlabs-registry (v1.1.0)
  └── puppetlabs-stdlib (v4.6.0)


No puppetmaster server is involved.

Thanks!

Rob Reynolds

unread,
May 1, 2015, 7:58:51 PM5/1/15
to puppet...@googlegroups.com
On Fri, May 1, 2015 at 12:59 PM, Mark Wolek <mark...@gmail.com> wrote:
C:\Users\Administrator>puppet apply --version
3.7.5

C:/ProgramData/PuppetLabs/puppet/etc/modules
└─┬ puppetlabs-registry (v1.1.0)
  └── puppetlabs-stdlib (v4.6.0)


No puppetmaster server is involved.

Thanks!

It's possible we may have a bug. I created MODULES-2005[1] to follow up. Thanks!

 

For more options, visit https://groups.google.com/d/optout.

Rob Reynolds

unread,
Jul 22, 2015, 8:02:17 PM7/22/15
to puppet...@googlegroups.com
Given we've discovered a bug in 3.7.5 and have recalled it for an incorrect version of Ruby[1], it's possible this issue was limited to just Puppet 3.7.5. Registry could be one thing that would likely have a large effect given the amount of changes we put in to make registry work again on Ruby 2.1.x.

Register now to take advantage of the Early Bird discount save $249!

Josh Cooper

unread,
Aug 19, 2015, 5:15:08 AM8/19/15
to puppet...@googlegroups.com
Hi Mark,

On Wed, Jul 22, 2015 at 1:01 PM, Rob Reynolds <r...@puppetlabs.com> wrote:
Given we've discovered a bug in 3.7.5 and have recalled it for an incorrect version of Ruby[1], it's possible this issue was limited to just Puppet 3.7.5. Registry could be one thing that would likely have a large effect given the amount of changes we put in to make registry work again on Ruby 2.1.x.


On Fri, May 1, 2015 at 2:58 PM, Rob Reynolds <r...@puppetlabs.com> wrote:


On Fri, May 1, 2015 at 12:59 PM, Mark Wolek <mark...@gmail.com> wrote:
C:\Users\Administrator>puppet apply --version
3.7.5

C:/ProgramData/PuppetLabs/puppet/etc/modules
└─┬ puppetlabs-registry (v1.1.0)
  └── puppetlabs-stdlib (v4.6.0)


No puppetmaster server is involved.

Thanks!

It's possible we may have a bug. I created MODULES-2005[1] to follow up. Thanks!

 


On Tuesday, April 28, 2015 at 12:38:23 PM UTC-5, Rob Reynolds wrote:


On Mon, Apr 27, 2015 at 11:28 AM, Mark Wolek <mark...@gmail.com> wrote:
Thanks John! It appears to open a ticket I do so on the GitHub site by logging in, is this correct?  

The reason for suspecting the lack of string termination is due to what we see in the Registry GUI, which is random characters and words after the string, then you hit Refresh on the page, the random characters and strings change.

It does seem specific to a hyphen being in the string, but I will test again to be certain.

We recently discovered that the ruby APIs for managing REG_MULTI_SZ registry values do not properly terminate wide strings. The Win32 API requires two wide NULL characters, which ruby was not doing. The ruby API would sometimes work depending on what value was in memory following the single wide NULL terminator.

The puppetlabs ticket is https://tickets.puppetlabs.com/browse/MODULES-1921 and the upstream ruby bug is https://bugs.ruby-lang.org/issues/11439, which it looks like they are in the process of fixing and backporting.

We've worked around the ruby issue and released a new version of the puppetlabs-registry module. You'll want version 1.1.2.
 

For more options, visit https://groups.google.com/d/optout.

Josh

--
Josh Cooper
Developer, Puppet Labs

PuppetConf 2015 is coming to Portland, Oregon! Join us October 5-9.
Register now to take advantage of the Final Countdown discount save $149!
Reply all
Reply to author
Forward
0 new messages