lib/openwfe/util/safe.rb in openwferu-0.9.7 vs lib/openwfe/util/safe.rb in openwferu-0.9.8
- old
+ new
@@ -37,58 +37,50 @@
# "made in Japan"
#
# john.mettraux@openwfe.org
#
-require 'tmpdir'
+#require 'tmpdir'
require 'open-uri'
module OpenWFE
#
# Runs some remote code (uri) at a different $SAFE level.
#
- def OpenWFE.load_safely (uri, safe_level)
+ #def OpenWFE.load_safely (uri, safe_level)
+ # source = ""
+ # source << "#\n"
+ # source << "# loaded from #{uri}\n"
+ # source << "#\n"
+ # source << open(uri).read
+ # load_eval_safely(source, safe_level)
+ #end
- source = ""
-
- source << "#\n"
- source << "# loaded from #{uri}\n"
- source << "#\n"
-
- source << open(uri).read
-
- load_eval_safely(source, safe_level)
- end
-
#
# Makes sure that a piece of Ruby code is run at certain safe level.
# Saves in a temp file that is reloaded in its own anonymous namespace.
#
# (no binding passing allowed like in the basic Kernel.eval() method).
#
- def OpenWFE.load_eval_safely (code, safe_level)
-
- tmpfname =
- "#{Dir.tmpdir}/"+
- "owfe_#{code.object_id}_#{Time.new.to_f}.tmp.rb"
-
- File.open tmpfname, "w" do |file|
- file.print code
- end
-
- Thread.new do
- $SAFE = safe_level
- load(tmpfname, true)
- end.join
-
- begin
- File.delete tmpfname
- rescue Excpetion => e
- # ignore
- end
- end
+ #def OpenWFE.load_eval_safely (code, safe_level)
+ # tmpfname =
+ # "#{Dir.tmpdir}/"+
+ # "owfe_#{code.object_id}_#{Time.new.to_f}.tmp.rb"
+ # File.open tmpfname, "w" do |file|
+ # file.print code
+ # end
+ # Thread.new do
+ # $SAFE = safe_level
+ # load(tmpfname, true)
+ # end.join
+ # begin
+ # File.delete tmpfname
+ # rescue Excpetion => e
+ # # ignore
+ # end
+ #end
#
# Runs some code within an instance's realm at a certain safety level.
#
def OpenWFE.instance_eval_safely (instance, code, safe_level)