@@ -9,6 +9,7 @@ while File.symlink?(msfbase)
9
9
msfbase = File . expand_path ( File . readlink ( msfbase ) , File . dirname ( msfbase ) )
10
10
end
11
11
12
+ @args = ARGV . dup
12
13
13
14
Dir . chdir ( File . dirname ( msfbase ) )
14
15
@@ -22,22 +23,24 @@ if not (Process.uid == 0 or File.stat(msfbase).owned?)
22
23
$stderr. puts "Please run msfupdate as the same user who installed metasploit."
23
24
end
24
25
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
31
37
end
32
38
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
39
41
40
- ARGV . push ( "--non-interactive" )
42
+ @args . push ( "--non-interactive" )
43
+ @args . push ( "--config-dir=#{ @configdir } " ) if @configdir_index
41
44
42
45
res = system ( "svn" , "cleanup" )
43
46
if res . nil?
@@ -48,10 +51,10 @@ if res.nil?
48
51
$stderr. puts "[-] to ensure a proper environment."
49
52
else
50
53
# Cleanup worked, go ahead and update
51
- system ( "svn" , "update" , *ARGV )
54
+ system ( "svn" , "update" , *@args )
52
55
end
53
56
54
- if wait
57
+ if @wait_index
55
58
$stderr. puts ""
56
59
$stderr. puts "[*] Please hit enter to exit"
57
60
$stderr. puts ""
0 commit comments