Patches from solar to add symlink support to mod dirs and prevent caching of broken modules

git-svn-id: file:///home/svn/framework3/trunk@4384 4d416f70-5f16-0410-b530-b9f4589650da
unstable
HD Moore 2007-02-15 05:32:48 +00:00
parent 2473071564
commit a1c6dda462
2 changed files with 51 additions and 8 deletions

View File

@ -1,4 +1,3 @@
require 'find'
require 'msf/core'
module Msf
@ -745,7 +744,7 @@ protected
ks = true
# Try to load modules from all the files in the supplied path
Find.find(path) { |file|
Rex::Find.find(path) { |file|
# Skip unit test files
next if (file =~ /rb\.ut\.rb$/)
@ -861,12 +860,6 @@ protected
return false
end
# Synchronize the modification time for this file.
update_module_cache_info(nil, {
'paths' => [ path ],
'files' => [ file ],
'type' => type}) if (!using_cache)
# Get the module and grab the current number of constants
old_constants = mod.constants
@ -927,6 +920,12 @@ protected
elog("Exception caught during is_usable check: #{$!}")
end
# Synchronize the modification time for this file.
update_module_cache_info(nil, {
'paths' => [ path ],
'files' => [ file ],
'type' => type}) if (!using_cache)
if (usable == false)
ilog("Skipping module in #{file} because is_usable returned false.",
'core', LEV_1)

View File

@ -1,3 +1,5 @@
require 'Find'
module Rex
###
@ -30,4 +32,46 @@ module FileUtils
end
module Find
#
# Identical to Find.find from Ruby, but follows symlinks to directories.
# See http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/68671
#
def self.find(*paths)
paths.collect!{|d| d.dup}
while file = paths.shift
catch(:prune) do
yield file.dup.taint
next unless File.exist? file
begin
if File.stat(file).directory? then
d = Dir.open(file)
begin
for f in d
next if f == "." or f == ".."
if File::ALT_SEPARATOR and file =~ /^(?:[\/\\]|[A-Za-z]:[\/\\]?)$/ then
f = file + f
elsif file == "/" then
f = "/" + f
else
f = File.join(file, f)
end
paths.unshift f.untaint
end
ensure
d.close
end
end
rescue Errno::ENOENT, Errno::EACCES
end
end
end
end
def self.prune
throw :prune
end
end
end