Skip to content

Commit f1f59ae

Browse files
committed
Refactor how libssp-0.dll is installed into primary ruby's bin
We compile ruby 3.2 with strong stack protection. This causes ruby to be linked against libssp-0, which must be redistributed with the runtime: $ objdump -p ruby.exe | grep libssp DLL Name: libssp-0.dll Windows doesn't have an RPATH equivalent, so the dll must be copied into the same directory as ruby. This was partially addressed in commmit ba4c955, however, the _base-ruby component is already responsible for installing Windows specific library dependencies when the main bin dir is different than ruby's bin dir, so move that logic there.
1 parent 944f15c commit f1f59ae

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

configs/components/_base-ruby.rb

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,28 @@
114114
[ "#{platform[:make]} -j$(shell expr $(shell #{platform[:num_cores]}) + 1) install" ]
115115
end
116116

117+
# For the pdk runtime, the ruby bin directory is different then the main bin
118+
# directory. In order to run ruby *outside* of the normal pdk.bat then we need
119+
# to copy all dlls that ruby depends on from the main bin directory to ruby's
120+
# bin directory. This is because the main bin directory is not in our system
121+
# PATH and Windows doesn't support RPATH. However, as mentioned in
122+
# https://learn.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order,
123+
# Windows searches for DLLs in "The folder the calling process was loaded from
124+
# (the executable's folder)."
125+
#
126+
# The agent runtime used to have the same issue prior to puppet 6, for example
127+
# RE-7593. However, Windows paths were changed to match *nix in puppet 6, see
128+
# commit 4b9d126dd5b. So only the pdk has this issue.
117129
if platform.is_windows? && settings[:bindir] != ruby_bindir
118-
# As things stand right now, ssl should build under [INSTALLDIR]\Puppet\puppet on
119-
# windows. However, if things need to run *outside* of the normal batch file runs
120-
# (puppet.bat ,mco.bat etcc) the location of openssl away from where ruby is
121-
# installed will cause a failure. Specifically this is meant to help services like
122-
# mco that require openssl but don't have access to environment.bat. Refer to
123-
# https://tickets.puppetlabs.com/browse/RE-7593 for details on why this causes
124-
# failures and why these copies fix that.
125-
# -Sean P. McDonald 07/01/2016
130+
# Ruby 3+
131+
if Gem::Version.new(pkg.get_version) >= Gem::Version.new('3.0')
132+
pkg.install do
133+
[
134+
"cp #{settings[:gcc_bindir]}/libssp-0.dll #{ruby_bindir}",
135+
]
136+
end
137+
end
138+
126139
if platform.architecture == "x64"
127140
gcc_postfix = 'seh'
128141
ssl_postfix = '-x64'
@@ -131,6 +144,7 @@
131144
ssl_postfix = ''
132145
end
133146

147+
# OpenSSL
134148
if Gem::Version.new(settings[:openssl_version]) >= Gem::Version.new('3.0')
135149
ssl_lib = "libssl-3#{ssl_postfix}.dll"
136150
crypto_lib = "libcrypto-3#{ssl_postfix}.dll"

configs/projects/_pdk-components.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,6 @@
2525
proj.component 'libxslt' unless platform.is_windows?
2626
proj.component "ruby-#{proj.ruby_version}"
2727

28-
# After installing ruby, we need to copy libssp to the ruby bindir on windows
29-
if platform.is_windows?
30-
ruby_component = @project.get_component "ruby-#{proj.ruby_version}"
31-
ruby_component.install.push "cp '#{settings[:bindir]}/libssp-0.dll' '#{settings[:ruby_bindir]}/libssp-0.dll'"
32-
end
33-
3428
proj.component 'ruby-augeas' unless platform.is_windows?
3529
proj.component 'ruby-selinux' if platform.is_el? || platform.is_fedora?
3630
proj.component 'ruby-stomp'

0 commit comments

Comments
 (0)