diff options
author | Bhavesh Davda <bhavesh.davda@oracle.com> | 2021-03-24 14:32:44 -0700 |
---|---|---|
committer | Bhavesh Davda <bhavesh.davda@oracle.com> | 2021-03-25 08:54:53 -0700 |
commit | 479ec9919b0ad4a4c9c9c6b9b5ec0bbac938fb12 (patch) | |
tree | 93295561f69c934ed7f89f71a6e506b95a8c359b /lib/ohai | |
parent | 74bde1d4b0fafb6192d1e1b135c13a37a80b2fb6 (diff) | |
download | ohai-479ec9919b0ad4a4c9c9c6b9b5ec0bbac938fb12.tar.gz |
Ohai: Change C language plugin for glibc version detection
It's not safe to directly execute "libc.so.6" to determine glibc version.
This can lead to segfaults when other shared libraries are preloaded using
LD_PRELOAD or /etc/ld.so.preload due to circular relocation dependencies.
Replace this version detection with "ldd --version" as "ldd" is a core part
of glibc and reports the same version.
Signed-off-by: Bhavesh Davda <bhavesh.davda@oracle.com>
Diffstat (limited to 'lib/ohai')
-rw-r--r-- | lib/ohai/plugins/c.rb | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/ohai/plugins/c.rb b/lib/ohai/plugins/c.rb index 80cccaca..414d1d18 100644 --- a/lib/ohai/plugins/c.rb +++ b/lib/ohai/plugins/c.rb @@ -85,14 +85,12 @@ Ohai.plugin(:C) do def collect_glibc # glibc - ["/lib/libc.so.6", "/lib64/libc.so.6"].each do |glibc| - collect( Ohai.abs_path( glibc )) do |so| - description = so.stdout.split($/).first - if description =~ /(\d+\.\d+\.?\d*)/ - @c[:glibc] = Mash.new - @c[:glibc][:version] = $1 - @c[:glibc][:description] = description - end + collect("ldd --version") do |so| + description = so.stdout.split($/).first + if description =~ /(\d+\.\d+\.?\d*)/ + @c[:glibc] = Mash.new + @c[:glibc][:version] = $1 + @c[:glibc][:description] = description end end end |