Issue #10885 has been updated by Jacob Helwig.
Status changed from In Topic Branch Pending Review to Merged - Pending Release
Target version changed from 1.6.x to 1.6.4
This was merged into 1.6.x in commit:bdbb2dad7d875ec20824854a0f41981b7fb3aa73
(#10885) Malformed facter.bat when ruby dir contains backreferences
Previously, we were substituting occurrences of <ruby> and <command>
in the Windows batch wrapper scripts with the corresponding
paths. However,the gsub replacement string was not escaped, so if a
path contained something that looked like a backreference,
e.g. C:\ruby\187, the gsub would try to replace the backreference with
the corresponding capture group. Since there aren't any capture
groups, the backreference was stripped from resulting facter.bat,
resulting in an invalid path, C:\ruby87\bin\facter.
This commit eliminates the need for gsub, since paths can contain
other characters that have special meaning in a regexp, e.g. '.'.
It also writes the bat file in 'text' mode so that the resulting file
has '\r\n' line endings.
----------------------------------------
Bug #10885: Malformed facter.bat when ruby path contains regexp
backreference-like sequences on Windows
https://projects.puppetlabs.com/issues/10885
Author: Josh Cooper
Status: Merged - Pending Release
Priority: Normal
Assignee: Josh Cooper
Category:
Target version: 1.6.4
Keywords: windows
Branch: https://github.com/puppetlabs/facter/pull/100
Affected Facter version: 1.6.0
If your ruby's install dir happens to contain a numeric value following a
backslash, e.g. `c:\ruby\1.8.7`, the install.rb script mistakes that for a
regexp backreference and corrupts the resulting facter.bat.
In install.rb, the values of `ruby` and `cwn` are used as replacement strings
in calls to gsub.
<pre>
cwv = CMD_WRAPPER.gsub('<ruby>', ruby.gsub(%r{/}) { "\\"
}).gsub!('<command>', cwn.gsub(%r{/}) { "\\" } )
</pre>
But since potential 'backreferences', i.e. \1, are not escaped, the calls to
gsub attempt to replace them with the corresponding capture group, but since
there are none, the 'backreference' is stripped, corrupting the batch file.
<pre>
@echo off
if "%OS%"=="Windows_NT" goto WinNT
c:\ruby.8.7\bin\ruby -x "c:\ruby.8.7\bin\facter" %1 %2 %3 %4 %5 %6 %7 %8 %9
goto done
:WinNT
c:\ruby.8.7\bin\ruby -x "c:\ruby.8.7\bin\facter" %*
goto done
:done
</pre>
This is the same issue that commit:d9a693dc4431430fcfdc3ae15bee8b4a0985868f
attempted to fix for puppet, but resulted in #10799
--
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.