Class: Net::SSH::Locate::Scanner
- Inherits:
-
Object
- Object
- Net::SSH::Locate::Scanner
- Defined in:
- lib/net/ssh/locate.rb
Instance Attribute Summary collapse
-
#agentPID ⇒ Object
readonly
Returns the value of attribute agentPID.
-
#agentSocket ⇒ Object
readonly
Returns the value of attribute agentSocket.
-
#found ⇒ Object
readonly
Returns the value of attribute found.
Instance Method Summary collapse
Instance Attribute Details
#agentPID ⇒ Object (readonly)
Returns the value of attribute agentPID.
81 82 83 |
# File 'lib/net/ssh/locate.rb', line 81 def agentPID @agentPID end |
#agentSocket ⇒ Object (readonly)
Returns the value of attribute agentSocket.
81 82 83 |
# File 'lib/net/ssh/locate.rb', line 81 def agentSocket @agentSocket end |
#found ⇒ Object (readonly)
Returns the value of attribute found.
81 82 83 |
# File 'lib/net/ssh/locate.rb', line 81 def found @found end |
Instance Method Details
#found? ⇒ Boolean
101 102 103 |
# File 'lib/net/ssh/locate.rb', line 101 def found? @found end |
#scan ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/net/ssh/locate.rb', line 83 def scan @found = false procs = Sys::ProcTable.ps(smaps: false, cgroup: false).select do |p| res = p.cmdline =~ /ssh-agent/ && p.cmdline !~ /--session=ubuntu/ && p.state != 'Z' res end return if procs.empty? p = procs.first p.cmdline =~ /ssh-agent\s-a ([-.a-zA-Z0-9_\/]+)/ return unless $LAST_MATCH_INFO @found = true @agentSocket = $LAST_MATCH_INFO[1] @agentPID = p.pid end |