Fix use of Tempfile

git-svn-id: file:///home/svn/framework3/trunk@5246 4d416f70-5f16-0410-b530-b9f4589650da
This commit is contained in:
HD Moore 2007-12-31 08:20:48 +00:00
parent 5131e4b747
commit d6e5b0a25d
3 changed files with 13 additions and 4 deletions

View File

@ -395,6 +395,8 @@ module Db
fd.close
File.unlink(x.path)
load_nmap_xml(data)
end

View File

@ -60,6 +60,7 @@ class Nasm
# Remove temporary files
File.unlink(opath)
File.unlink(tpath)
tmp.close
rv

View File

@ -107,12 +107,18 @@ class Plugin::DBSQLite3 < Msf::Plugin
return
end
IO.popen("#{sqlite3} \"#{opts['dbfile']}\" < \"#{sql}\"") do |io|
io.each_line do |line|
print_line("OUTPUT: " + line.strip)
end
tmp = Tempfile.new("sqlXXXXXXX")
system("#{sqlite3} \"#{opts['dbfile']}\" < \"#{sql}\" >\"#{tmp.path}\" 2>&1")
tmp.read.each_line do |line|
print_status("OUTPUT: #{line.strip}")
end
tmp.close
File.unlink(tmp.path)
if (not framework.db.connect(opts))
raise PluginLoadError.new("Failed to connect to the database")
end