Use a temporary file for the glade.xml
git-svn-id: file:///home/svn/framework3/trunk@5936 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
d630d63e05
commit
652100cb54
|
@ -63,10 +63,12 @@ module Ui
|
|||
class MyGlade
|
||||
include Msf::Ui::Gtk2::MyControls
|
||||
|
||||
|
||||
def initialize(root)
|
||||
# Give the glade file and instance the glade object
|
||||
file_glade = File.join(driver.resource_directory, 'msfgui.glade')
|
||||
glade = GladeXML.new(file_glade, root) { |handler|method(handler) }
|
||||
file_glade = ::Rex::Compat.temp_copy(File.join(driver.resource_directory, 'msfgui.glade'))
|
||||
|
||||
glade = GladeXML.new(file_glade.path, root) { |handler| method(handler) }
|
||||
|
||||
# For all widget names, instance a variable
|
||||
glade.widget_names.each do |name|
|
||||
|
@ -75,6 +77,8 @@ module Ui
|
|||
rescue
|
||||
end
|
||||
end
|
||||
|
||||
::Rex::Compat.temp_delete(file_glade)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -337,4 +341,4 @@ module Ui
|
|||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -30,8 +30,11 @@ ENABLE_PROCESSED_INPUT = 1
|
|||
#
|
||||
|
||||
@@is_windows = @@is_macosx = @@is_linux = @@is_bsdi = @@is_freebsd = @@is_netbsd = @@is_openbsd = @@is_java = false
|
||||
@@loaded_win32api = false
|
||||
@@loaded_dl = false
|
||||
@@loaded_win32api = false
|
||||
@@loaded_dl = false
|
||||
@@loaded_tempfile = false
|
||||
@@loaded_fileutils = false
|
||||
|
||||
|
||||
def self.is_windows
|
||||
return @@is_windows if @@is_windows
|
||||
|
@ -301,6 +304,32 @@ def self.pipe
|
|||
return [pipe1, pipe2]
|
||||
end
|
||||
|
||||
#
|
||||
# Copy a file to a temporary path
|
||||
#
|
||||
|
||||
def self.temp_copy(path)
|
||||
raise RuntimeError,"missing Tempfile" if not @@loaded_tempfile
|
||||
fd = File.open(path, "rb")
|
||||
tp = Tempfile.new("msftemp")
|
||||
tp.write(fd.read(File.size(path)))
|
||||
tp.close
|
||||
fd.close
|
||||
tp
|
||||
end
|
||||
|
||||
#
|
||||
# Delete an opened temporary file
|
||||
#
|
||||
|
||||
def self.temp_delete(tp)
|
||||
raise RuntimeError,"missing FileUtils" if not @@loaded_fileutils
|
||||
begin
|
||||
FileUtils.rm(tp.path)
|
||||
rescue
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
#
|
||||
# Initialization
|
||||
|
@ -321,7 +350,17 @@ begin
|
|||
rescue ::Exception
|
||||
end
|
||||
|
||||
begin
|
||||
require "tempfile"
|
||||
@@loaded_tempfile = true
|
||||
rescue ::Exception
|
||||
end
|
||||
|
||||
begin
|
||||
require "fileutils"
|
||||
@@loaded_fileutils = true
|
||||
rescue ::Exception
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue