summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-09-24 01:37:14 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-09-24 01:37:14 +0000
commitc97a6987b62726a20570fb06681c986cf7f60141 (patch)
tree9fa981874abb554182dc2c4ed5d759364b5f7a2c
parent61847a8279ae7ef57b1b9afff00eda76fe0a636c (diff)
ext/tk: remove $SAFE 2..4 code
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51925 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ext/tk/MANUAL_tcltklib.eng10
-rw-r--r--ext/tk/MANUAL_tcltklib.ja12
-rw-r--r--ext/tk/lib/multi-tk.rb24
-rw-r--r--ext/tk/lib/remote-tk.rb8
-rw-r--r--ext/tk/lib/tk.rb28
-rw-r--r--ext/tk/lib/tk/itemconfig.rb1
-rw-r--r--ext/tk/lib/tk/optiondb.rb6
-rw-r--r--ext/tk/lib/tk/timer.rb4
-rw-r--r--ext/tk/lib/tk/variable.rb3
-rwxr-xr-x[-rw-r--r--]ext/tk/sample/safe-tk.rb3
-rwxr-xr-x[-rw-r--r--]ext/tk/sample/tkoptdb-safeTk.rb2
11 files changed, 18 insertions, 83 deletions
diff --git a/ext/tk/MANUAL_tcltklib.eng b/ext/tk/MANUAL_tcltklib.eng
index 94b21950a6..bd124f7620 100644
--- a/ext/tk/MANUAL_tcltklib.eng
+++ b/ext/tk/MANUAL_tcltklib.eng
@@ -171,7 +171,7 @@ module TclTklib
: a target event.
: If set DONT_WAIT flag and no event for processing, returns
: false immediately.
- : If $SAFE >= 4, or $SAFE >= 1 and the flag is tainted,
+ : If $SAFE >= 1 and the flag is tainted,
: force to set DONT_WAIT flag.
set_eventloop_tick(timer_tick)
@@ -183,7 +183,6 @@ module TclTklib
: However, if the eventloop thread is the only thread,
: timer_tick cannot be set to 0. If 0, then is set to 100 ms
: automatically (see NO_THREAD_INTERRUPT_TIME on tcltklib.c).
- : On $SAFE >= 4, cannot call this method.
get_eventloop_tick
: Get current value of 'timer_tick'
@@ -194,7 +193,6 @@ module TclTklib
: Default value is 20 (ms).
: If the eventloop thread is the only thread, this value is
: invalid.
- : On $SAFE >= 4, cannot call this method.
get_no_event_wait
: Get current value of 'no_event_wait'.
@@ -207,7 +205,6 @@ module TclTklib
: when no event for processing (And then, the eventloop thread
: sleeps 'no_event_wait' mili-seconds).
: 'loop_max == 800' and 'no_event_tick == 10' are default.
- : On $SAFE >= 4, cannot call this method.
get_eventloop_weight
: Get current values of 'loop_max' and 'no_event_tick'.
@@ -223,7 +220,6 @@ module TclTklib
: interpreter kills the eventloop thread. Even if such
: situation, when abort_on_exception == false or nil,
: the eventloop ignores the exception and continue to working.
- : On $SAFE >= 4, cannot call this method.
mainloop_abort_on_exception
: Get current status of that.
@@ -294,7 +290,6 @@ class TclTkIp
: interpreter. Default is false. However, if the parent
: interpreter is a safe interpreter, the created interpreter is
: a safe interpreter (ignore 'safe' argument value).
- : If $SAFE >= 4, can create a safe interpreter only.
make_safe
: Make the interpreter to the safe interpreter, and returns
@@ -314,7 +309,7 @@ class TclTkIp
allow_ruby_exit=(mode)
: Change the mode of 'allow_ruby_exit?'.
- : If $SAFE >= 4 or the interpreter is a "safe" interpreter,
+ : If the interpreter is a "safe" interpreter,
: this is not permitted (raise an exception).
delete
@@ -335,7 +330,6 @@ class TclTkIp
: Restart Tk part of the interpreter.
: Use this when you need Tk functions after destroying the
: root widget.
- : On $SAFE >= 4, cannot call this method.
_eval(str)
_invoke(*args)
diff --git a/ext/tk/MANUAL_tcltklib.ja b/ext/tk/MANUAL_tcltklib.ja
index 1de1736f9f..8641909517 100644
--- a/ext/tk/MANUAL_tcltklib.ja
+++ b/ext/tk/MANUAL_tcltklib.ja
@@ -272,7 +272,7 @@ require "tcltklib" すると, 以下のモジュール, クラスが利用可能
: 象となっている種類のイベントが発生するまで待ち続ける.
: DONT_WAIT を指定していた場合,処理対象イベントがなくても
: すぐに終了し false を返す.
- : $SAFE >= 4 か,$SAFE >= 1 かつ flag が汚染されているならば
+ : $SAFE >= 1 かつ flag が汚染されているならば
: flag には DONT_WAIT が強制的に付けられる.
set_eventloop_tick(timer_tick)
@@ -288,7 +288,6 @@ require "tcltklib" すると, 以下のモジュール, クラスが利用可能
: 定される.
: 詳細な説明は略すが,これは CPU パワーを節約しつつ安全で
: 安定した動作を実現するために実装した仕様である.
- : $SAFE >= 4 では実行が禁止される.
get_eventloop_tick
: timer_tick の現在値を返す.
@@ -298,7 +297,6 @@ require "tcltklib" すると, 以下のモジュール, クラスが利用可能
: く存在しなかった際に sleep 状態に入る時間長を指定する.
: 稼働スレッドがイベントループだけの場合には意味をなさない.
: デフォルトの値は 20 (ms)
- : $SAFE >= 4 では実行が禁止される.
get_no_event_wait
: no_event_wait の現在値を返す.
@@ -316,7 +314,6 @@ require "tcltklib" すると, 以下のモジュール, クラスが利用可能
: が全く発生しないままに 80 回の処理待ちイベント検査が完了
: するとかでカウントが 800 以上になるとスレッドスイッチング
: が発生することになる.
- : $SAFE >= 4 では実行が禁止される.
get_eventloop_weight
: 現在の loop_max と no_event_tick との値を返す.
@@ -336,7 +333,6 @@ require "tcltklib" すると, 以下のモジュール, クラスが利用可能
: 他のインタープリタの処理継続が不可能になることがある.その
: ような場合でもエラーを無視してイベントループが稼働を続ける
: ことで,他のインタープリタが正常に動作し続けることができる.
- : $SAFE >= 4 では実行が禁止される.
mainloop_abort_on_exception
: Tk インタープリタ上で例外を発生した際に,イベントループをエ
@@ -404,7 +400,6 @@ require "tcltklib" すると, 以下のモジュール, クラスが利用可能
: たとえ明確に false を指定していたとしても,親となるインター
: プリタが safe インタープリタであれば,その設定を引き継いで
: safe インタープリタとして生成される.
- : $SAFE >= 4 では,safe インタープリタ以外の生成が禁止される.
make_safe
: Tcl/Tk インタープリタを safe インタープリタに変更する.
@@ -425,8 +420,8 @@ require "tcltklib" すると, 以下のモジュール, クラスが利用可能
allow_ruby_exit=(mode)
: 対象となるインタープリタの allow_ruby_exit? の状態を変更する.
- : $SAFE >= 4 またはインタープリタが safe インタープリタの場合は
- : 変更が許されない (例外を発生).
+ : インタープリタが safe インタープリタの場合は変更が許されない
+ : (例外を発生).
delete
: Tcl/Tk インタープリタを delete する.
@@ -447,7 +442,6 @@ require "tcltklib" すると, 以下のモジュール, クラスが利用可能
: Tcl/Tk インタープリタの Tk 部分の初期化,再起動を行う.
: 一旦 root widget を破壊した後に再度 Tk の機能が必要と
: なった場合に用いる.
- : $SAFE >= 4 では実行が禁止される.
_eval(str)
_invoke(*args)
diff --git a/ext/tk/lib/multi-tk.rb b/ext/tk/lib/multi-tk.rb
index 5129a6e862..c23c246551 100644
--- a/ext/tk/lib/multi-tk.rb
+++ b/ext/tk/lib/multi-tk.rb
@@ -1265,14 +1265,6 @@ class MultiTkIp
######################################
def initialize(master, safeip=true, keys={})
- if $SAFE >= 4
- fail SecurityError, "cannot create a new interpreter at level #{$SAFE}"
- end
-
- if safeip == nil && $SAFE >= 2
- fail SecurityError, "cannot create a master-ip at level #{$SAFE}"
- end
-
if master.deleted? && safeip == nil
fail RuntimeError, "cannot create a slave of a deleted interpreter"
end
@@ -1307,7 +1299,7 @@ class MultiTkIp
name, safe, safe_opts, tk_opts = _parse_slaveopts(keys)
- safe = 4 if safe && !safe.kind_of?(Fixnum)
+ safe = 1 if safe && !safe.kind_of?(Fixnum)
@safe_base = false
@@ -1423,7 +1415,7 @@ class MultiTkIp
safe = master.safe_level if safe < master.safe_level
@safe_level = [safe]
else
- @safe_level = [4]
+ @safe_level = [1]
end
else
@interp, @ip_name = master.__create_trusted_slave_obj(name, tk_opts)
@@ -1615,7 +1607,7 @@ class << MultiTkIp
end
alias new_trusted_slave new_slave
- def new_safe_slave(safe=4, keys={}, &blk)
+ def new_safe_slave(safe=1, keys={}, &blk)
if safe.kind_of?(Hash)
keys = safe
elsif safe.kind_of?(Integer)
@@ -2754,13 +2746,9 @@ class MultiTkIp
if @wait_on_mainloop[0]
begin
@wait_on_mainloop[1] += 1
- if $SAFE >= 4
- _receiver_mainloop(check_root).join
- else
- @cmd_queue.enq([@system, 'call_mainloop',
- Thread.current, check_root])
- Thread.stop
- end
+ @cmd_queue.enq([@system, 'call_mainloop',
+ Thread.current, check_root])
+ Thread.stop
rescue MultiTkIp_OK => ret
# return value
if ret.value.kind_of?(Thread)
diff --git a/ext/tk/lib/remote-tk.rb b/ext/tk/lib/remote-tk.rb
index 443d66010c..f414489645 100644
--- a/ext/tk/lib/remote-tk.rb
+++ b/ext/tk/lib/remote-tk.rb
@@ -61,10 +61,6 @@ end
class RemoteTkIp
def initialize(remote_ip, displayof=nil, timeout=5)
- if $SAFE >= 4
- fail SecurityError, "cannot access another interpreter at level #{$SAFE}"
- end
-
@interp = MultiTkIp.__getip
if @interp.safe?
fail SecurityError, "safe-IP cannot create RemoteTkIp"
@@ -199,9 +195,7 @@ class RemoteTkIp
raise SecurityError, "no permission to manipulate" unless self.manipulable?
p ['_appsend', [@remote, @displayof], enc_mode, async, cmds] if $DEBUG
- if $SAFE >= 4
- fail SecurityError, "cannot send commands at level 4"
- elsif $SAFE >= 1 && cmds.find{|obj| obj.tainted?}
+ if $SAFE >= 1 && cmds.find{|obj| obj.tainted?}
fail SecurityError, "cannot send tainted commands at level #{$SAFE}"
end
diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb
index 45f86a9253..dd29589e86 100644
--- a/ext/tk/lib/tk.rb
+++ b/ext/tk/lib/tk.rb
@@ -1785,9 +1785,7 @@ EOS
end
def appsend(interp, async, *args)
- if $SAFE >= 4
- fail SecurityError, "cannot send Tk commands at level 4"
- elsif $SAFE >= 1 && args.find{|obj| obj.tainted?}
+ if $SAFE >= 1 && args.find{|obj| obj.tainted?}
fail SecurityError, "cannot send tainted Tk commands at level #{$SAFE}"
end
if async != true && async != false && async != nil
@@ -1802,9 +1800,7 @@ EOS
end
def rb_appsend(interp, async, *args)
- if $SAFE >= 4
- fail SecurityError, "cannot send Ruby commands at level 4"
- elsif $SAFE >= 1 && args.find{|obj| obj.tainted?}
+ if $SAFE >= 1 && args.find{|obj| obj.tainted?}
fail SecurityError, "cannot send tainted Ruby commands at level #{$SAFE}"
end
if async != true && async != false && async != nil
@@ -1820,9 +1816,7 @@ EOS
end
def appsend_displayof(interp, win, async, *args)
- if $SAFE >= 4
- fail SecurityError, "cannot send Tk commands at level 4"
- elsif $SAFE >= 1 && args.find{|obj| obj.tainted?}
+ if $SAFE >= 1 && args.find{|obj| obj.tainted?}
fail SecurityError, "cannot send tainted Tk commands at level #{$SAFE}"
end
win = '.' if win == nil
@@ -1838,9 +1832,7 @@ EOS
end
def rb_appsend_displayof(interp, win, async, *args)
- if $SAFE >= 4
- fail SecurityError, "cannot send Ruby commands at level 4"
- elsif $SAFE >= 1 && args.find{|obj| obj.tainted?}
+ if $SAFE >= 1 && args.find{|obj| obj.tainted?}
fail SecurityError, "cannot send tainted Ruby commands at level #{$SAFE}"
end
win = '.' if win == nil
@@ -1899,7 +1891,7 @@ EOS
INTERP_ROOT_CHECK.wait(INTERP_MUTEX)
status = INTERP_THREAD_STATUS.value
if status && TkCore::INTERP.default_master?
- INTERP_THREAD_STATUS.value = nil if $SAFE < 4
+ INTERP_THREAD_STATUS.value = nil
raise status if status.kind_of?(Exception)
end
}
@@ -2209,9 +2201,6 @@ module Tk
# tk_split_simplelist(INTERP._invoke('set', 'tcl_libPath'))
when :PLATFORM, :TCL_PLATFORM
- if $SAFE >= 4
- fail SecurityError, "can't get #{sym} when $SAFE >= 4"
- end
INTERP._invoke_without_enc('global', 'tcl_platform')
Hash[*tk_split_simplelist(INTERP._invoke_without_enc('array', 'get',
'tcl_platform'))]
@@ -3746,7 +3735,6 @@ module TkConfigMethod
@mode || false
end
def TkConfigMethod.__set_IGNORE_UNKNOWN_CONFIGURE_OPTION__!(mode)
- fail SecurityError, "can't change the mode" if $SAFE>=4
@mode = (mode)? true: false
end
@@ -5650,9 +5638,6 @@ class TkWindow<TkObject
end
def wait_visibility(on_thread = true)
- if $SAFE >= 4
- fail SecurityError, "can't wait visibility at $SAFE >= 4"
- end
on_thread &= (Thread.list.size != 1)
if on_thread
INTERP._thread_tkwait('visibility', path)
@@ -5676,9 +5661,6 @@ class TkWindow<TkObject
alias thread_tkwait_visibility thread_wait_visibility
def wait_destroy(on_thread = true)
- if $SAFE >= 4
- fail SecurityError, "can't wait destroy at $SAFE >= 4"
- end
on_thread &= (Thread.list.size != 1)
if on_thread
INTERP._thread_tkwait('window', epath)
diff --git a/ext/tk/lib/tk/itemconfig.rb b/ext/tk/lib/tk/itemconfig.rb
index 14396048ba..e8eb83d66c 100644
--- a/ext/tk/lib/tk/itemconfig.rb
+++ b/ext/tk/lib/tk/itemconfig.rb
@@ -124,7 +124,6 @@ module TkItemConfigMethod
@mode || false
end
def TkItemConfigMethod.__set_IGNORE_UNKNOWN_CONFIGURE_OPTION__!(mode)
- fail SecurityError, "can't change the mode" if $SAFE>=4
@mode = (mode)? true: false
end
diff --git a/ext/tk/lib/tk/optiondb.rb b/ext/tk/lib/tk/optiondb.rb
index 0f3be30ff7..91d2697a86 100644
--- a/ext/tk/lib/tk/optiondb.rb
+++ b/ext/tk/lib/tk/optiondb.rb
@@ -22,15 +22,9 @@ module TkOptionDB
end
def add(pat, value, pri=None)
- # if $SAFE >= 4
- # fail SecurityError, "can't call 'TkOptionDB.add' at $SAFE >= 4"
- # end
tk_call('option', 'add', pat, value, pri)
end
def clear
- # if $SAFE >= 4
- # fail SecurityError, "can't call 'TkOptionDB.crear' at $SAFE >= 4"
- # end
tk_call_without_enc('option', 'clear')
end
def get(win, name, klass)
diff --git a/ext/tk/lib/tk/timer.rb b/ext/tk/lib/tk/timer.rb
index ddfbfce9be..29aa84b0d9 100644
--- a/ext/tk/lib/tk/timer.rb
+++ b/ext/tk/lib/tk/timer.rb
@@ -498,10 +498,6 @@ class TkTimer
end
def wait(on_thread = true, check_root = false)
- if $SAFE >= 4
- fail SecurityError, "can't wait timer at $SAFE >= 4"
- end
-
unless @running
if @return_value.kind_of?(Exception)
fail @return_value
diff --git a/ext/tk/lib/tk/variable.rb b/ext/tk/lib/tk/variable.rb
index 0487b034bd..496225a92d 100644
--- a/ext/tk/lib/tk/variable.rb
+++ b/ext/tk/lib/tk/variable.rb
@@ -360,9 +360,6 @@ class TkVariable
end
def wait(on_thread = false, check_root = false)
- if $SAFE >= 4
- fail SecurityError, "can't wait variable at $SAFE >= 4"
- end
on_thread &= (Thread.list.size != 1)
if on_thread
if check_root
diff --git a/ext/tk/sample/safe-tk.rb b/ext/tk/sample/safe-tk.rb
index 38131c0155..652dbe75a0 100644..100755
--- a/ext/tk/sample/safe-tk.rb
+++ b/ext/tk/sample/safe-tk.rb
@@ -117,9 +117,6 @@ p ip.eval_str("
:padx=>10, :pady=>7)
", bind)
-puts "\n---- change the safe slave IP's safe-level ==> 4 ----------"
-ip.safe_level = 4
-
puts "\n---- call 3rd and 4th eval_proc ----------"
p ip.eval_proc{
TkLabel.new(:text=>"3rd and 4th eval_proc : $SAFE == #{$SAFE}").pack
diff --git a/ext/tk/sample/tkoptdb-safeTk.rb b/ext/tk/sample/tkoptdb-safeTk.rb
index 7502e30667..8fd35a9e7a 100644..100755
--- a/ext/tk/sample/tkoptdb-safeTk.rb
+++ b/ext/tk/sample/tkoptdb-safeTk.rb
@@ -31,7 +31,7 @@ file = File.expand_path('tkoptdb.rb', File.dirname(__FILE__))
ip = MultiTkIp.new_safeTk{
# When a block is given to 'new_safeTk' method,
- # the block is evaluated on $SAFE==4.
+ # the block is evaluated on $SAFE==1.
ent.each{|pat, val| Tk.tk_call('option', 'add', pat, val)}
}