summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric G. Wolfe <eric.wolfe@gmail.com>2014-03-26 13:05:26 -0400
committeradamedx <adamed@opscode.com>2014-04-01 11:11:58 -0700
commit0db6606e65743626e406d10ca615dd82fd082830 (patch)
tree2496178daab3d25e64065821060261a32820d3a7
parent1c8af79d72458e1dac47333b2178f4bfd5d251c5 (diff)
downloadohai-0db6606e65743626e406d10ca615dd82fd082830.tar.gz
Use less greedy inverse set match.
Rather than using a greedy wildcard like so: * `%r{^\d+:.+:/(lxc|docker)/.+$}` Use a less greedy inverse set, which excludes literal colon: * `%r{^\d+:[^:]+:/(lxc|docker)/.+$}` Discussion, https://github.com/atomic-penguin/ohai/commit/02d1a30a9369b8266082ff2e29fb22ec38ecb999#diff-725858488c1235840f3a62b4eb7a575fR149
-rw-r--r--lib/ohai/plugins/linux/virtualization.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/ohai/plugins/linux/virtualization.rb b/lib/ohai/plugins/linux/virtualization.rb
index c28c8b7e..c50d440b 100644
--- a/lib/ohai/plugins/linux/virtualization.rb
+++ b/lib/ohai/plugins/linux/virtualization.rb
@@ -146,10 +146,10 @@ Ohai.plugin(:Virtualization) do
# Full notes, https://tickets.opscode.com/browse/OHAI-551
# Kernel docs, https://www.kernel.org/doc/Documentation/cgroups
if File.exists?("/proc/self/cgroup")
- if File.read("/proc/self/cgroup") =~ %r{^\d+:.+:/(lxc|docker)/.+$}
+ if File.read("/proc/self/cgroup") =~ %r{^\d+:[^:]+:/(lxc|docker)/.+$}
virtualization[:system] = "lxc"
virtualization[:role] = "guest"
- elsif File.read("/proc/self/cgroup") =~ %r{\d:.+:/$}
+ elsif File.read("/proc/self/cgroup") =~ %r{\d:[^:]+:/$}
virtualization[:system] = "lxc"
virtualization[:role] = "host"
end