Skip to content

Commit 69a4a32

Browse files
committed
Add begin-rescue blocks that prevent individual hosts from bailing out a threaded multi-host execution
1 parent e139a1e commit 69a4a32

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

modules/auxiliary/admin/smb/psexec_command.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,11 @@ def get_output(file)
136136

137137
# check if our process is done using these files
138138
def exclusive_access(*files)
139+
begin
139140
simple.connect("\\\\#{@ip}\\#{@smbshare}")
141+
rescue
142+
return false
143+
end
140144
files.each do |file|
141145
begin
142146
print_status("checking if the file is unlocked")
@@ -154,7 +158,12 @@ def exclusive_access(*files)
154158

155159
# Removes files created during execution.
156160
def cleanup_after(*files)
157-
simple.connect("\\\\#{@ip}\\#{@smbshare}")
161+
begin
162+
simple.connect("\\\\#{@ip}\\#{@smbshare}")
163+
rescue
164+
print_error("Unable to connect for cleanup. Maybe you'll need to manually remove #{left.join(", ")} from the target.")
165+
return
166+
end
158167
print_status("Executing cleanup...")
159168
files.each do |file|
160169
begin

0 commit comments

Comments
 (0)