Fixes #434. Always use Timeout.timeout() -- on Ruby 1.9 this results in the Timeout::TimeoutError exception vs RuntimeError
git-svn-id: file:///home/svn/framework3/trunk@7323 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
80a262f991
commit
075b8c5fa4
|
@ -30,10 +30,11 @@ def run
|
|||
secs = datastore['RUNTIME']
|
||||
print_status("Running module for #{secs} seconds...")
|
||||
begin
|
||||
timeout(secs) { self.run_timed }
|
||||
Timeout.timeout(secs) { self.run_timed }
|
||||
rescue Timeout::Error
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -194,3 +194,4 @@ module Exploit::Remote::FtpServer
|
|||
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@ module Stream
|
|||
#
|
||||
def timed_write(buf, wait = def_write_timeout, opts = {})
|
||||
if (wait and wait > 0)
|
||||
timeout(wait) {
|
||||
Timeout.timeout(wait) {
|
||||
return write(buf, opts)
|
||||
}
|
||||
else
|
||||
|
@ -133,7 +133,7 @@ module Stream
|
|||
#
|
||||
def timed_read(length = nil, wait = def_read_timeout, opts = {})
|
||||
if (wait and wait > 0)
|
||||
timeout(wait) {
|
||||
Timeout.timeout(wait) {
|
||||
return read(length, opts)
|
||||
}
|
||||
else
|
||||
|
@ -296,3 +296,4 @@ protected
|
|||
end
|
||||
|
||||
end end
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ class PacketResponseWaiter
|
|||
#
|
||||
def wait(interval)
|
||||
begin
|
||||
timeout(interval) {
|
||||
Timeout.timeout(interval) {
|
||||
while(not self.done)
|
||||
select(nil, nil, nil, 0.1)
|
||||
end
|
||||
|
@ -74,3 +74,4 @@ class PacketResponseWaiter
|
|||
end
|
||||
|
||||
end; end; end
|
||||
|
||||
|
|
|
@ -249,7 +249,7 @@ class Rex::Proto::DCERPC::Client::UnitTest < Test::Unit::TestCase
|
|||
setup_test(read, write)
|
||||
require 'rex/proto/smb/simpleclient'
|
||||
begin
|
||||
timeout($_REX_TEST_TIMEOUT) {
|
||||
Timeout.timeout($_REX_TEST_TIMEOUT) {
|
||||
s = Rex::Socket.create_tcp( 'PeerHost' => $_REX_TEST_SMB_HOST, 'PeerPort' => 445)
|
||||
|
||||
smb = Rex::Proto::SMB::SimpleClient.new(s, true)
|
||||
|
@ -285,7 +285,7 @@ class Rex::Proto::DCERPC::Client::UnitTest < Test::Unit::TestCase
|
|||
]
|
||||
setup_test(read, write)
|
||||
begin
|
||||
timeout($_REX_TEST_TIMEOUT) {
|
||||
Timeout.timeout($_REX_TEST_TIMEOUT) {
|
||||
s = Rex::Socket.create_tcp('PeerHost' => $_REX_TEST_SMB_HOST, 'PeerPort' => 135)
|
||||
handle = Rex::Proto::DCERPC::Handle.new(['E1AF8308-5D1F-11C9-91A4-08002B14A0FA', '3.0'], 'ncacn_ip_tcp', $_REX_TEST_SMB_HOST, [135])
|
||||
assert_instance_of(Rex::Proto::DCERPC::Handle, handle, 'handle')
|
||||
|
@ -312,7 +312,7 @@ class Rex::Proto::DCERPC::Client::UnitTest < Test::Unit::TestCase
|
|||
]
|
||||
setup_test(read, write)
|
||||
begin
|
||||
timeout($_REX_TEST_TIMEOUT) {
|
||||
Timeout.timeout($_REX_TEST_TIMEOUT) {
|
||||
s = Rex::Socket.create_tcp('PeerHost' => $_REX_TEST_SMB_HOST, 'PeerPort' => 135)
|
||||
handle = Rex::Proto::DCERPC::Handle.new(['E1AF8308-5D1F-11C9-91A4-08002B14A0FA', '3.0'], 'ncacn_ip_tcp', $_REX_TEST_SMB_HOST, [135])
|
||||
assert_instance_of(Rex::Proto::DCERPC::Handle, handle, 'handle')
|
||||
|
@ -338,7 +338,7 @@ class Rex::Proto::DCERPC::Client::UnitTest < Test::Unit::TestCase
|
|||
]
|
||||
setup_test(read, write)
|
||||
begin
|
||||
timeout($_REX_TEST_TIMEOUT) {
|
||||
Timeout.timeout($_REX_TEST_TIMEOUT) {
|
||||
s = Rex::Socket.create_tcp('PeerHost' => $_REX_TEST_SMB_HOST, 'PeerPort' => 135)
|
||||
handle = Rex::Proto::DCERPC::Handle.new(['E1AF8308-5D1F-11C9-91A4-08002B14A0FA', '3.0'], 'ncacn_ip_tcp', $_REX_TEST_SMB_HOST, [135])
|
||||
assert_instance_of(Rex::Proto::DCERPC::Handle, handle, 'handle')
|
||||
|
@ -363,7 +363,7 @@ class Rex::Proto::DCERPC::Client::UnitTest < Test::Unit::TestCase
|
|||
write = ["\005\000\v\003\020\000\000\000H\000\000\000\000\000\000\000\320\026\320\026\000\000\000\000\001\000\000\000\000\000\001\000\010\203\257\341\037]\311\021\221\244\010\000+\024\240\372\003\000\000\000\004]\210\212\353\034\311\021\237\350\010\000+\020H`\002\000\000\000"]
|
||||
setup_test(read, write)
|
||||
begin
|
||||
timeout($_REX_TEST_TIMEOUT) {
|
||||
Timeout.timeout($_REX_TEST_TIMEOUT) {
|
||||
handle = Rex::Proto::DCERPC::Handle.new(['E1AF8308-5D1F-11C9-91A4-08002B14A0FA', '3.0'], 'ncacn_ip_tcp', $_REX_TEST_SMB_HOST, [135])
|
||||
assert_instance_of(Rex::Proto::DCERPC::Handle, handle, 'handle')
|
||||
dcerpc = Rex::Proto::DCERPC::Client.new(handle, nil)
|
||||
|
@ -402,7 +402,7 @@ class Rex::Proto::DCERPC::Client::UnitTest < Test::Unit::TestCase
|
|||
]
|
||||
setup_test(read, write)
|
||||
begin
|
||||
timeout($_REX_TEST_TIMEOUT) {
|
||||
Timeout.timeout($_REX_TEST_TIMEOUT) {
|
||||
s = Rex::Socket.create_tcp('PeerHost' => $_REX_TEST_SMB_HOST, 'PeerPort' => 139)
|
||||
|
||||
handle = Rex::Proto::DCERPC::Handle.new(['4b324fc8-1670-01d3-1278-5a47bf6ee188', '3.0'], 'ncacn_np', $_REX_TEST_SMB_HOST, ['\BROWSER'])
|
||||
|
@ -449,7 +449,7 @@ read = [
|
|||
]
|
||||
setup_test(read, write)
|
||||
|
||||
timeout($_REX_TEST_TIMEOUT) {
|
||||
Timeout.timeout($_REX_TEST_TIMEOUT) {
|
||||
handle = Rex::Proto::DCERPC::Handle.new(['4b324fc8-1670-01d3-1278-5a47bf6ee188', '3.0'], 'ncacn_np', $_REX_TEST_SMB_HOST, ['\BROWSER'])
|
||||
dcerpc = Rex::Proto::DCERPC::Client.new(handle, nil)
|
||||
assert_instance_of(Rex::Proto::DCERPC::Client, dcerpc, 'bind')
|
||||
|
@ -488,3 +488,4 @@ end
|
|||
|
||||
rescue LoadError
|
||||
end
|
||||
|
||||
|
|
|
@ -323,7 +323,7 @@ class Client
|
|||
# do this if t was specified as a negative value indicating an infinite
|
||||
# wait cycle. If t were specified as nil it would indicate that no
|
||||
# response parsing is required.
|
||||
timeout((t < 0) ? nil : t) {
|
||||
Timeout.timeout((t < 0) ? nil : t) {
|
||||
# Now, read in the response until we're good to go.
|
||||
begin
|
||||
if self.junk_pipeline
|
||||
|
@ -785,3 +785,4 @@ end
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ class Rex::Proto::SMB::Client::UnitTest < Test::Unit::TestCase
|
|||
filename = 'smb_test.txt'
|
||||
|
||||
begin
|
||||
timeout($_REX_TEST_TIMEOUT) {
|
||||
Timeout.timeout($_REX_TEST_TIMEOUT) {
|
||||
s = Rex::Socket.create_tcp(
|
||||
'PeerHost' => $_REX_TEST_SMB_HOST,
|
||||
'PeerPort' => 139
|
||||
|
@ -149,7 +149,7 @@ class Rex::Proto::SMB::Client::UnitTest < Test::Unit::TestCase
|
|||
|
||||
def test_smb_session_request
|
||||
begin
|
||||
timeout($_REX_TEST_TIMEOUT) {
|
||||
Timeout.timeout($_REX_TEST_TIMEOUT) {
|
||||
s = Rex::Socket.create_tcp(
|
||||
'PeerHost' => $_REX_TEST_SMB_HOST,
|
||||
'PeerPort' => 139
|
||||
|
@ -220,3 +220,4 @@ class Rex::Proto::SMB::Client::UnitTest < Test::Unit::TestCase
|
|||
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ class Rex::Proto::SMB::SimpleClient::UnitTest < Test::Unit::TestCase
|
|||
write_data = ('A' * (1024 * 8))
|
||||
filename = 'smb_tester.txt'
|
||||
begin
|
||||
timeout($_REX_TEST_TIMEOUT) {
|
||||
Timeout.timeout($_REX_TEST_TIMEOUT) {
|
||||
s = Rex::Socket.create_tcp(
|
||||
'PeerHost' => $_REX_TEST_SMB_HOST,
|
||||
'PeerPort' => 445
|
||||
|
@ -67,7 +67,7 @@ class Rex::Proto::SMB::SimpleClient::UnitTest < Test::Unit::TestCase
|
|||
|
||||
def test_smb_dcerpc
|
||||
begin
|
||||
timeout($_REX_TEST_TIMEOUT) {
|
||||
Timeout.timeout($_REX_TEST_TIMEOUT) {
|
||||
s = Rex::Socket.create_tcp(
|
||||
'PeerHost' => $_REX_TEST_SMB_HOST,
|
||||
'PeerPort' => 445
|
||||
|
@ -125,3 +125,4 @@ class Rex::Proto::SMB::SimpleClient::UnitTest < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -182,7 +182,7 @@ class Rex::Socket::Comm::Local
|
|||
end
|
||||
|
||||
begin
|
||||
timeout(param.timeout) do
|
||||
Timeout.timeout(param.timeout) do
|
||||
sock.connect(Rex::Socket.to_sockaddr(ip, port))
|
||||
end
|
||||
rescue ::Timeout::Error
|
||||
|
@ -353,3 +353,4 @@ class Rex::Socket::Comm::Local
|
|||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ class Event
|
|||
self.mutex.synchronize {
|
||||
ctx.call if (self.state == true)
|
||||
|
||||
timeout(t) {
|
||||
Timeout.timeout(t) {
|
||||
self.cond.wait(self.mutex)
|
||||
}
|
||||
}
|
||||
|
@ -91,3 +91,4 @@ end
|
|||
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -496,7 +496,7 @@ class Manager
|
|||
(@retries.to_i + 1).times do |n|
|
||||
send_request(request, community, host, port)
|
||||
begin
|
||||
timeout(@timeout) do
|
||||
Timeout.timeout(@timeout) do
|
||||
return get_response(request)
|
||||
end
|
||||
rescue Timeout::Error
|
||||
|
@ -715,3 +715,4 @@ class TrapListener
|
|||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue