hammer_cli_foreman_virt_who_configure 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 160c6a49a4ece0bace60fb2a2476a912190d2311e9e51adeb12378d0301c3269
|
4
|
+
data.tar.gz: 58c205f21be5be1637b0fd0aa6ee7491598eaaa0aef733d46f8da5c56eeacb42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b57c0415e725c1e583379195930b6421e9182619b0ffa2db7a85b4e4ebaa9a47167ad5e8f4c6d00eb48105cad80c01723e5fe983650f86d615a9ff4317703bd3
|
7
|
+
data.tar.gz: c1875d96d19cf876d87a9168abdd08ec09f6b108e2f8c97dea0d2306e999ed513414538d20dc9430175d22e075de7eb7818b0c3791cd9fcd52320c6c1858b93b
|
@@ -1,15 +1,27 @@
|
|
1
1
|
module HammerCLIForemanVirtWhoConfigure
|
2
2
|
class SystemCaller
|
3
|
+
WHITELISTED_VARS = %w[HOME USER LANG].freeze
|
4
|
+
|
3
5
|
def initialize(tempfile = nil)
|
4
6
|
@tempfile = tempfile || Tempfile.new('virt_who')
|
5
7
|
end
|
6
8
|
|
7
|
-
def
|
9
|
+
def clean_env_vars
|
10
|
+
# Cleaning ENV vars and keeping required vars only because,
|
11
|
+
# When using SCL it adds GEM_HOME and GEM_PATH ENV vars.
|
12
|
+
# These vars break foreman-maintain tool.
|
13
|
+
# This way we use system ruby to execute the bash script.
|
14
|
+
cleaned_env = ENV.select { |var| WHITELISTED_VARS.include?(var) || var.start_with?('LC_') }
|
15
|
+
cleaned_env['PATH'] = '/sbin:/bin:/usr/sbin:/usr/bin'
|
16
|
+
cleaned_env
|
17
|
+
end
|
18
|
+
|
19
|
+
def system(command)
|
8
20
|
result = nil
|
9
21
|
begin
|
10
|
-
@tempfile.write(
|
22
|
+
@tempfile.write(command)
|
11
23
|
@tempfile.flush # to make sure the command is complete
|
12
|
-
result = Kernel.system("/usr/bin/bash #{@tempfile.path}")
|
24
|
+
result = Kernel.system(clean_env_vars, "/usr/bin/bash #{@tempfile.path}", unsetenv_others: true)
|
13
25
|
ensure
|
14
26
|
@tempfile.close
|
15
27
|
@tempfile.unlink
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hammer_cli_foreman_virt_who_configure
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomáš Strachota
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hammer_cli
|