Skip to content

Commit 44d7ab8

Browse files
committed
Merge branch 'todb-r7-fix-msfupdate' into rapid7
[Closes rapid7#847]
2 parents 114b788 + 7dbe512 commit 44d7ab8

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

msfupdate

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ while File.symlink?(msfbase)
99
msfbase = File.expand_path(File.readlink(msfbase), File.dirname(msfbase))
1010
end
1111

12+
@args = ARGV.dup
1213

1314
Dir.chdir(File.dirname(msfbase))
1415

@@ -22,22 +23,24 @@ if not (Process.uid == 0 or File.stat(msfbase).owned?)
2223
$stderr.puts "Please run msfupdate as the same user who installed metasploit."
2324
end
2425

25-
wait = (ARGV.shift.to_s == "wait")
26-
27-
have_configdir = false
28-
ARGV.each do |arg|
29-
next unless arg =~ /--config-dir/
30-
have_configdir = true
26+
@args.each_with_index do |arg,i|
27+
case arg
28+
when "wait"
29+
@wait_index = i
30+
when /--config-dir/
31+
# Spaces in the directory should be fine since this whole thing is passed
32+
# as a single argument via the multi-arg syntax for system() below.
33+
# TODO: Test this spaces business. I don't buy it. -todb
34+
@configdir_index = i
35+
@configdir = File.join(File.dirname(msfbase), "data", "svn")
36+
end
3137
end
3238

33-
unless have_configdir
34-
configdir = File.join(File.dirname(msfbase), "data", "svn")
35-
# Spaces in the directory should be fine since this whole thing is passed
36-
# as a single argument via the multi-arg syntax for system() below.
37-
ARGV.push("--config-dir=#{configdir}")
38-
end
39+
@args.delete_at @wait_index if @wait_index
40+
@args.delete_at @configdir_index if @configdir_index
3941

40-
ARGV.push("--non-interactive")
42+
@args.push("--non-interactive")
43+
@args.push("--config-dir=#{@configdir}") if @configdir_index
4144

4245
res = system("svn", "cleanup")
4346
if res.nil?
@@ -48,10 +51,10 @@ if res.nil?
4851
$stderr.puts "[-] to ensure a proper environment."
4952
else
5053
# Cleanup worked, go ahead and update
51-
system("svn", "update", *ARGV)
54+
system("svn", "update", *@args)
5255
end
5356

54-
if wait
57+
if @wait_index
5558
$stderr.puts ""
5659
$stderr.puts "[*] Please hit enter to exit"
5760
$stderr.puts ""

0 commit comments

Comments
 (0)