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: 0ee53d10c25c7bb73cf7ec8bb3d7f8fc3dcbea957cc4ccde0652ce37c5aa9660
4
- data.tar.gz: 7bde63d3680ca55eedf00df46f800b08d0858c3934b995585ee515cb5e408d66
3
+ metadata.gz: 160c6a49a4ece0bace60fb2a2476a912190d2311e9e51adeb12378d0301c3269
4
+ data.tar.gz: 58c205f21be5be1637b0fd0aa6ee7491598eaaa0aef733d46f8da5c56eeacb42
5
5
  SHA512:
6
- metadata.gz: 7794300b03933db3ffa7438863ea2e98c10b9a13608109f567deef76911afe9741e6e755df11d8b6068c7773c3c72a714764e82e8be1d4f41217071dcee5c67c
7
- data.tar.gz: a394bf2a667af20930679c72875164f684cdc2b8116d972de7e73153d58cf0bfb36ff0d000a4ac873d809e6502939fbec02e79f5828d94d17e568bc9c7c7ea10
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 system(commad)
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(commad)
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
@@ -1,5 +1,5 @@
1
1
  module HammerCLIForemanVirtWhoConfigure
2
2
  def self.version
3
- @version ||= Gem::Version.new '0.0.5'
3
+ @version ||= Gem::Version.new '0.0.6'
4
4
  end
5
5
  end
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.5
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: 2019-11-27 00:00:00.000000000 Z
11
+ date: 2020-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hammer_cli