From: Minero Aoki Date: 2003-11-05T18:59:30+09:00 Subject: [ruby-list:38756] ruby-dev summary 21730-21822 /draft 青木です。 またも大幅に遅れてしまいましたが先週分 21730-21822 の要約ドラフト です。「[ruby-dev:21639] load() blocks thread scheduling」もまと めようかと思ったんですが、まだスレッドが中途半端なのでやめました。 なお ruby-dev summary チームでは常時新しい要約メンバーを募集して います。興味のあるかたはとりあえずこの ML にメールを投げてくださ い。いまは 4 人でやっていますが、もう一人増えて 5 人になると一ヶ 月に一回しか回ってこなくなるのでかなり気軽にできるのではないかと 思います。 [ruby-dev:21616] access ENV on $SAFE==4 (contd.) From the previous ruby-dev summary ([ruby-talk:84412]): Hidetoshi NAGAI found that Safe interpreter of Tcl/Tk don't allow to refer some informations of environments, such as env, OS, library and so on. And he asked whether we should forbid to use ENV, RUBY_PLATFORM and $LOAD_PATH when $SAFE=4. Hidetoshi NAGAI posted a summary of the thread in [ruby-dev:21804]. This entry is an incomplete translation of his summary. * $LOAD_PATH $SAFE >= 4 でのアクセスが禁止される. We cannot refer/modify $LOAD_PATH if $SAFE>=4. * ENV Following new methods are defined. `insecure' means $SAFE>=4 in this document. : ENV.allow_insecure_ref(varname) $SAFE >= 4 での環境変数 name の読み出しを許可する. $SAFE >= 4 でこのメソッドが呼ばれた場合は例外を発生する. すべての環境変数のデフォルト設定は「読み出し可」である. ( $SAFE >= 4 での書き込みは常に例外を発生することに注意.) Allows to refer VARNAME environment variable for insecure programs. Raises SecurityError if this method is called on $SAFE>=4. We can refer all environment variables by default, for backward compatibility. : ENV.deny_insecure_ref(varname) $SAFE >= 4 での環境変数 name の読み出しを禁止する. $SAFE >= 4 でこのメソッドが呼ばれた場合は例外を発生する. 読み出し禁止に設定した環境変数を $SAFE >= 4 で読み出そうとすると, その環境変数が存在しない場合と同様に nil が返る. また,読み出し禁止の環境変数は ENV.keys 等でも表示されない. Hides VARNAME environment variable from insecure programs. Raises SecurityError if this method is called on $SAFE>=4. : ENV.insecure_ref_allowed?(varname) -> bool 環境変数 name (文字列指定) への $SAFE >= 4 でのアクセスが 許可されているならば true を,そうでなければ false を返す. $SAFE >= 4 でこのメソッドが呼ばれた場合は例外を発生する. Returns true if insecure programs can refer VARNAME. Raises SecurityError if this method is called on $SAFE>=4. : ENV.insecure_ref_denied?(name) -> bool ENV.insecure_ref_allowed?(name) の否定 $SAFE >= 4 でこのメソッドが呼ばれた場合は例外を発生する. Returns true if VARNAME is hidden from insecure programs. Raises SecurityError if this method is called on $SAFE>=4. : ENV.insecure_ref_allowings -> [String] $SAFE >= 4 でのアクセスが許可されている環境変数のリストを得る. $SAFE >= 4 でこのメソッドが呼ばれた場合は例外を発生する. Returns a list of variable names which insecure programs can refer. Raises SecurityError if this method is called on $SAFE>=4. : ENV.insecure_ref_denyings -> [String] $SAFE >= 4 でのアクセスが禁止されている環境変数のリストを得る. $SAFE >= 4 でこのメソッドが呼ばれた場合は例外を発生する. Returns a list of variable names which are hidden from insecure programs. Raises SecurityError if this method is called on $SAFE>=4. * Module Following new methods are defined. `insecure' means $SAFE>=4 in this document. : Module#allow_insecure_ref(constname) module/class において,定数 const (文字列またはシンボル) への $SAFE >= 4 での参照を許可する.(戻り値は const のシンボル) $SAFE >= 4 でこのメソッドが呼ばれた場合は例外を発生する. すべての定数のデフォルト設定は「参照禁止」である. Allow to refer CONSTNAME constant for insecure programs. Raises SecurityError if this method is called on $SAFE>=4. : Module#deny_insecure_ref(const) module/class において,定数 const (文字列またはシンボル) への $SAFE >= 4 での参照を禁止する.(戻り値は const のシンボル) $SAFE >= 4 でこのメソッドが呼ばれた場合は例外を発生する. 参照禁止に設定した定数を $SAFE >= 4 で参照しようとすると 例外を発生する. Hides CONSTNAME constant from insecure programs. Raises SecurityError if this method is called on $SAFE>=4. : Module#insecure_ref_allowed?(constname) -> bool module/class において,定数 const (文字列またはシンボル) への $SAFE >= 4 での参照が許可されているならば true を, 禁止されているならば false を返す. $SAFE >= 4 でこのメソッドが呼ばれた場合は例外を発生する. Returns true if insecure programs can refer CONSTNAME constant. Raises SecurityError if this method is called on $SAFE>=4. : Module#insecure_ref_denied?(const) Module#insecure_ref_allowed?(const) の否定 $SAFE >= 4 でこのメソッドが呼ばれた場合は例外を発生する. Returns true if CONSTNAME constant is hidden from insecure programs. Raises SecurityError if this method is called on $SAFE>=4. : Module#insecure_ref_allowings -> [String] module/class において,$SAFE >= 4 での参照が許可されている 定数の一覧を返す. $SAFE >= 4 でこのメソッドが呼ばれた場合は例外を発生する. Returns a list of constant names which insecure programs can refer. Raises SecurityError if this method is called on $SAFE>=4. : Module#insecure_ref_denyings -> [String] module/class において,$SAFE >= 4 での参照が禁止されている 定数の一覧を返す. $SAFE >= 4 でこのメソッドが呼ばれた場合は例外を発生する. Returns a list of constant names which are hidden from insecure programs. Raises SecurityError if this method is called on $SAFE>=4. * RUBY_PLATFORM, PLATFORM Object.deny_insecure_ref(:RUBY_PLATFORM) および Object.deny_insecure_ref(:PLATFORM) として設定されている. Object.deny_insecure_ref(:RUBY_PLATFORM) and Object.deny_insecure_ref(:PLATFORM) is the default. These constants are invisible for insecure programs. Matz agreed with him on the concept, but we still needs better method names. [ruby-dev:21707] drb Hash#each Matz found that the Hash#each test case of dRuby is failed on the latest ruby. The reason of this failure is the feature mismatch between yield([k,v]) and Proc#call([k,v]): % cat t def m1 yield [1,2] end m1 {|k,v| p [k,v] } def m2( &block ) block.call([1,2]) end m2 {|k,v| p [k,v] } % ruby -v t ruby 1.8.1 (2003-10-26) [i686-linux] [1, 2] [[1, 2], nil] Matz finally changed Proc#call behavior, now yield and Proc#call produces same results: % ruby -v t ruby 1.8.1 (2003-11-04) [i686-linux] [1, 2] [1, 2] [ruby-dev:21794] rb_iter_break() on ruby 1.8.1p2 MURATA Kenta reported that ruby 1.8.1p2 break the following program: #include static VALUE ahi_ahi(VALUE obj) { rb_yield(Qnil); } static VALUE ahi_abort(VALUE obj) { rb_iter_break(); } void Init_ahi(void) { VALUE cAhi = rb_define_class("Ahi", rb_cObject); rb_define_method(cAhi, "ahi", ahi_ahi, 0); rb_define_method(cAhi, "abort", ahi_abort, 0); } If you compile this extension and execute it, ruby will exit with status 1: $ ruby -rahi -e "a = Ahi.new; a.ahi { a.abort }" -e:1:in `abort': unexpected break (LocalJumpError) from -e:1 from -e:1:in `ahi' from -e:1 This is because rb_iter_break() is called in another method frame is not what the block is executed on. ※ 「ブロックが実行されているのとは違うフレーム上で rb_iter_breakが呼ばれたから」と言いたいのですが、 わたしの英語力の限界を越えてしまいました For these kind of purpose, you should use rb_catch() and rb_throw(). These APIs are described in Pickaxe page 195. For the "right" usage of rb_iter_break(), see enum.c. [ruby-dev:21816] "this method is deprecated" warning messages Koji Arai reported that some warning messages are not printed on ruby 1.8.1 preview 1. Corresponding warnings messages are: % ruby-1.8.0 -e "{1=>'a', 2=>'b', 3=>'c'}.select(1,2,3)" -e:1: warning: Hash#select(key..) is deprecated; use Hash#values_at % ruby-1.8.0 -e '"foo" =~ "foo"' -e:1: warning: string =~ string will be obsolete; use explicit regexp % ruby-1.8.0 -e '$_ = "foo"; p ~"foo"' -e:1: warning: ~string will be obsolete; use explicit regexp Matz decided to remove these functions from 1.8.1, with these warnings. ------------------------------------------------------------------- 青木峰郎