Class: Straycall::Prompt
- Inherits:
-
Object
- Object
- Straycall::Prompt
- Defined in:
- lib/straycall/prompt.rb
Instance Method Summary collapse
- #allow?(syscall, target) ⇒ Boolean
-
#initialize(io = nil) ⇒ Prompt
constructor
A new instance of Prompt.
Constructor Details
#initialize(io = nil) ⇒ Prompt
Returns a new instance of Prompt.
5 6 7 8 |
# File 'lib/straycall/prompt.rb', line 5 def initialize(io = nil) @io = io @mutex = Mutex.new end |
Instance Method Details
#allow?(syscall, target) ⇒ Boolean
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/straycall/prompt.rb', line 10 def allow?(syscall, target) io = nil @mutex.synchronize do io = @io || File.open("/dev/tty", "r+") io.print("straycall: allow #{syscall}(2) → #{target}? [y/N] ") io.flush %w[y yes].include?(io.gets.to_s.strip.downcase) end rescue IOError, SystemCallError false ensure io&.close if !@io && io && !io.closed? end |