Fixes #193. Add a unicode-capable workaround for windows, patch code to go through the compat lib
git-svn-id: file:///home/svn/framework3/trunk@5873 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
6dd840e4b3
commit
8628a9d2c1
|
@ -21,9 +21,10 @@ class Config < Hash
|
|||
def self.get_config_root
|
||||
|
||||
# Windows-specific environment variables
|
||||
['LOCALAPPDATA', 'APPDATA', 'USERPROFILE'].each do |dir|
|
||||
if (ENV[dir] and File.directory?(ENV[dir]))
|
||||
return File.join(ENV[dir], ".msf3")
|
||||
['LOCALAPPDATA', 'APPDATA', 'USERPROFILE', 'HOME'].each do |dir|
|
||||
val = Rex::Compat.getenv(dir)
|
||||
if (val and File.directory?(val))
|
||||
return File.join(val, ".msf3")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ ENABLE_PROCESSED_INPUT = 1
|
|||
#
|
||||
|
||||
@@is_windows = @@is_macosx = @@is_linux = @@is_bsdi = @@is_freebsd = @@is_netbsd = @@is_openbsd = false
|
||||
@@loaded_win32api = false
|
||||
|
||||
def self.is_windows
|
||||
return @@is_windows if @@is_windows
|
||||
|
@ -93,6 +94,27 @@ def self.open_email(addr)
|
|||
end
|
||||
end
|
||||
|
||||
def self.getenv(var)
|
||||
if (is_windows and @@loaded_win32api)
|
||||
f = Win32API.new("kernel32", "GetEnvironmentVariable", ["P", "P", "I"], "I")
|
||||
buff = "\x00" * 65536
|
||||
sz = f.call(var, buff, buff.length)
|
||||
return nil if sz == 0
|
||||
buff[0,sz]
|
||||
else
|
||||
ENV[var]
|
||||
end
|
||||
end
|
||||
|
||||
def self.setenv(var,val)
|
||||
if (is_windows and @@loaded_win32api)
|
||||
f = Win32API.new("kernel32", "SetEnvironmentVariable", ["P", "P"], "I")
|
||||
f.call(var, val + "\x00")
|
||||
else
|
||||
ENV[var]= val
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
# Change the Windows console to non-blocking mode
|
||||
#
|
||||
|
@ -275,5 +297,18 @@ def self.pipe
|
|||
end
|
||||
|
||||
|
||||
#
|
||||
# Initialization
|
||||
#
|
||||
|
||||
if(is_windows)
|
||||
begin
|
||||
require "Win32API"
|
||||
@@loaded_win32api = true
|
||||
rescue ::Exception
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
|
@ -15,8 +15,9 @@ module FileUtils
|
|||
# a fully qualified path to the supplied file name.
|
||||
#
|
||||
def self.find_full_path(file_name)
|
||||
if (ENV['PATH'])
|
||||
ENV['PATH'].split(::File::PATH_SEPARATOR).each { |base|
|
||||
path = Rex::Compat.getenv('PATH')
|
||||
if (path)
|
||||
path.split(::File::PATH_SEPARATOR).each { |base|
|
||||
begin
|
||||
path = base + ::File::SEPARATOR + file_name
|
||||
if (::File::Stat.new(path))
|
||||
|
|
|
@ -183,7 +183,7 @@ class Console::CommandDispatcher::Stdapi::Fs
|
|||
end
|
||||
|
||||
# Spawn the editor
|
||||
editor = ENV['EDITOR'] || 'vi'
|
||||
editor = Rex::Compat.getenv('EDITOR') || vi
|
||||
|
||||
# If it succeeds, upload it to the remote side.
|
||||
if (system("#{editor} #{temp_path}") == true)
|
||||
|
|
|
@ -186,11 +186,8 @@ module Shell
|
|||
# Color is disabled until we resolve some bugs
|
||||
return false
|
||||
|
||||
begin
|
||||
(ENV['TERM'].match(/(?:vt10[03]|xterm(?:-color)?|linux|screen)/i) != nil)
|
||||
rescue
|
||||
false
|
||||
end
|
||||
term = Rex::Compat.getenv('TERM')
|
||||
(term and term.match(/(?:vt10[03]|xterm(?:-color)?|linux|screen)/i) != nil)
|
||||
end
|
||||
|
||||
#
|
||||
|
|
Loading…
Reference in New Issue