Module: Specinfra::Configuration

Defined in:
lib/itamae/backend.rb

Class Method Summary collapse

Class Method Details

.sudo_passwordObject



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/itamae/backend.rb', line 10

def self.sudo_password
  return ENV['SUDO_PASSWORD'] if ENV['SUDO_PASSWORD']
  return @sudo_password if defined?(@sudo_password)

  # TODO: Fix this dirty hack
  return nil unless caller.any? {|call| call.include?('channel_data') }

  print "sudo password: "
  @sudo_password = STDIN.noecho(&:gets).strip
  print "\n"
  @sudo_password
end