Ruby1.9 での $SAFE==4 時の autoload 動作

e$B1J0f!wCNG=!%6e9)Bg$G$9!%e(B

From: Hidetoshi NAGAI [email protected]
Subject: [ruby-dev:34265] Re: Ruby1.9 e$B$G$Ne(B $SAFE==4
e$B$G$NF0:n$N;EMMJQ99$K$D$$$Fe(B
Date: Mon, 7 Apr 2008 10:39:29 +0900
Message-ID: [email protected]

e$B$3$l$G<!$N2]Bj$K?J$a$^$9!%e(B(^_^;

e$B$H$$$&$o$1$G!$<!$N2]Bj$G$9!%e(B(^_^)
Ruby 1.9 e$B$K$*$$$F!$e(B$SAFE==4 e$B$N;~$Ke(B autoload
e$B$,$&$^$/F/$$$F$/$l$^$;$s!%e(B
autoload [email protected]_Dj$Oe(B $SAFE==0 e$B$N;~$K$J$5$l$F$$$F!$e(B
e$B:G=i$K;2>H$5$l$?$N$,e(B $SAFE==4 e$B$N;~$G$"$C$?$H$$$&%1!<%9$G$9!%e(B
Ruby 1.8 e$B$G$O!$$=$&$7$?%1!<%9$G$be(B autoload
e$B$,$&$^$/5!G=$7$^$9$,!$e(B
Ruby 1.9 e$B$G$Oe(B insecure_operation at level 4 (SecurityError)
e$B$G$9!%e(B
e$B$7$+$b%(%i!<%a%C%;!<%8$G$O!$e(Bautoload
e$B$,F/$$$?;~$K<B9TCf$N%a%=%C%I$,e(B
SecurityError e$B$H$$$&$3$H$K$5$l$F$7$^$C$F$$$^$9!%e(B

$SAFE==0 [email protected]_Dj$7$?$b$N$rCY1dFI$9~$[email protected][email protected]$($k$N$G!$e(B
autoload
e$B$K$h$kFI$9~$$r9T$C$F$b%;%-%e%j%F%#E*$KLdBj$O$J$$$H;W$($^$9!%e(B

e$BNc$($P!$:#!$e(Bautoload e$BBP>]$,e(B

-----<zzz.rb>------------------
class ZZZ
def hoge
[:hoge, $SAFE]
end
end

e$B$G$"$C$?$H$7$^$9!%$3$N$H$-!$e(B

-----<xx1.rb>------------------
autoload :ZZZ, ./zzz.rb
module M; end
p Thread.new{M.instance_eval(ZZZ.new.hoge)}.value

e$B$de(B

-----<xx2.rb>------------------
autoload :ZZZ, ./zzz.rb
module M; end
p ZZZ.new.hoge
p Thread.new{M.instance_eval($SAFE=4; ZZZ.new.hoge)}.value

e$B$Oe(B (e$BEvA3e(B?) e$B%(%i!<$J$/<B9T$5$l$^$9$,!$e(B

-----<xx3.rb>------------------
autoload :ZZZ, ./zzz.rb
module M; end
p Thread.new{M.instance_eval($SAFE=4; ZZZ.new.hoge)}.value

e$B$Oe(B


./xx3.rb:3:in instance_eval': Insecure operation at level 4 (SecurityError) from ./zzza.rb:3:ininstance_eval
from ./zzza.rb:3:in `block in

e$B$H$$$&$3$H$K$J$j$^$9!%e(B
e$B%(%i!<%a%C%;!<%8$H$7$F$bG<[email protected][email protected]$H;W$$$^$9!%e(B

e$B%Q%C%A$J$7$NJs9p$N$$G$9$$^$;$s$,!$$h$m$7$/$*4j$$CW$7$^$9!%e(B

[email protected]$G$9!#e(B

At Mon, 7 Apr 2008 23:15:04 +0900,
Hidetoshi NAGAI wrote in [ruby-dev:34266]:

Ruby 1.9 e$B$K$*$$$F!$e(B$SAFE==4 e$B$N;~$Ke(B autoload e$B$,$&$^$/F/$$$F$/$l$^$;$s!%e(B
autoload [email protected]_Dj$Oe(B $SAFE==0 e$B$N;~$K$J$5$l$F$$$F!$e(B
e$B:G=i$K;2>H$5$l$?$N$,e(B $SAFE==4 e$B$N;~$G$"$C$?$H$$$&%1!<%9$G$9!%e(B
Ruby 1.8 e$B$G$O!$$=$&$7$?%1!<%9$G$be(B autoload e$B$,$&$^$/5!G=$7$^$9$,!$e(B
Ruby 1.9 e$B$G$Oe(B insecure_operation at level 4 (SecurityError) e$B$G$9!%e(B
e$B$7$+$b%(%i!<%a%C%;!<%8$G$O!$e(Bautoload e$B$,F/$$$?;~$K<B9TCf$N%a%=%C%I$,e(B
SecurityError e$B$H$$$&$3$H$K$5$l$F$7$^$C$F$$$^$9!%e(B

autoloade$B$Ke(B"./e$B$de(B/e$B$G;O$^$kAjBP%Q%9$r;XDj$7$F$$$k$H!e(Bautoload
[email protected]$Ke(Brequiree$B$7$?$H$-$K%(%i!<$K$J$k$H$$$&%P%0$b$$C$?$N$G!$^e(B
e$B$H$a$FD>$7$^$7$?!#e(B

e$B1J0f!wCNG=!%6e9)Bg$G$9!%e(B

From: Nobuyoshi N. [email protected]
Subject: [ruby-dev:34267] Re: Ruby1.9 e$B$G$Ne(B $SAFE==4 e$B;~$Ne(B
autoload e$BF0:ne(B
Date: Tue, 8 Apr 2008 03:44:46 +0900
Message-ID: [email protected]

autoloade$B$Ke(B"./e$B$de(B/e$B$G;O$^$kAjBP%Q%9$r;XDj$7$F$$$k$H!e(Bautoload
[email protected]$Ke(Brequiree$B$7$?$H$-$K%(%i!<$K$J$k$H$$$&%P%0$b$$C$?$N$G!$^e(B
e$B$H$a$FD>$7$^$7$?!#e(B

e$B$"$j$,$H$&$4$6$$$^$9!%$G$9$,!$$^[email protected]>$C$F$O$$$J$$$h$&$G$9!%e(B


autoload :ZZZ, File.join(Dir.pwd, zzz.rb)

module M; end

#p ZZZ.new.hoge ## < (*)

#p Thread.new{M.instance_eval($SAFE=4; ZZZ.new.hoge)}.value
#p Thread.new{$SAFE=4; M.instance_eval(ZZZ.new.hoge)}.value
#p Thread.new{$SAFE=4; eval(ZZZ.new.hoge)}.value
#p Thread.new{eval($SAFE=4; ZZZ.new.hoge)}.value

e$B>e5-$Ne(B (*) e$B$N9T$rM-8z$K$7$F!$e(Bautoload
[email protected]$KF/$+$;$J$$8B$j!$e(B
e$B0J2<$Ne(B 4 e$B9T$N$$$:$l$rM-8z$K$7$F$be(B Insecure operation
e$B$H$J$j$^$9!%e(B

e$B$D$$$G$K$G$9$,!$B?J,e(B Revision: 15915 [email protected]$N7k2L$K$h$j!$e(B

$ /usr/local/bin/ruby19 ./ext/tk/sample/tkhello.rb
/usr/local/lib/ruby/1.9.0/tk.rb:2344:in find': unknown encoding name - binary (ArgumentError) from /usr/local/lib/ruby/1.9.0/tk.rb:2344:inmodule:Encoding
from /usr/local/lib/ruby/1.9.0/tk.rb:2328:in <module:Tk>' from /usr/local/lib/ruby/1.9.0/tk.rb:2327:in<top
(required)>
from ./ext/tk/sample/tkhello.rb:1:in require' from ./ext/tk/sample/tkhello.rb:1:in

[email protected]$G$9!#e(B

At Tue, 8 Apr 2008 06:10:24 +0900,
Hidetoshi NAGAI wrote in [ruby-dev:34268]:

#p Thread.new{$SAFE=4; M.instance_eval(ZZZ.new.hoge)}.value
#p Thread.new{$SAFE=4; eval(ZZZ.new.hoge)}.value
#p Thread.new{eval($SAFE=4; ZZZ.new.hoge)}.value

e$B>e5-$Ne(B (*) e$B$N9T$rM-8z$K$7$F!$e(Bautoload [email protected]$KF/$+$;$J$$8B$j!$e(B
e$B0J2<$Ne(B 4 e$B9T$N$$$:$l$rM-8z$K$7$F$be(B Insecure operation e$B$H$J$j$^$9!%e(B

r15921e$B$Ge(Bbootstraptest/test_autoload.rbe$B$KDI2C$7$F$*$-$^$7$?$,!"DL$Ce(B
e$B$F$7$^$C$F$$$k$h$&$J5$$,$7$^$9!#%F%9%H$,$^$:$$e(B?

e$B$D$$$G$K$G$9$,!$B?J,e(B Revision: 15915 [email protected]$N7k2L$K$h$j!$e(B

$ /usr/local/bin/ruby19 ./ext/tk/sample/tkhello.rb
/usr/local/lib/ruby/1.9.0/tk.rb:2344:in `find: unknown encoding name - binary (ArgumentError)

e$B$J$I$H$$$&%(%i!<$r=P$9$h$&$K$J$j$^$7$?!%e(B
e$B860x$O$3$l$+$iD4$Y$h$&$H;W$$$^$9$,!$e(B
e$B?4Ev$?$j$,$"$j$^$7$?$i65$([email protected]$1$^$9$H=u$+$j$^$9!%e(B

enc/prelude.rbe$B$K=q$$$F$"$k%i%$%V%i%jL>$,4V0c$C$F$$$^$7$?!#e(B

[email protected]$G$9!#e(B

At Tue, 8 Apr 2008 16:09:32 +0900,
Hidetoshi NAGAI wrote in [ruby-dev:34270]:

r15921e$B$Ge(Bbootstraptest/test_autoload.rbe$B$KDI2C$7$F$*$-$^$7$?$,!"DL$Ce(B
e$B$F$7$^$C$F$$$k$h$&$J5$$,$7$^$9!#%F%9%H$,$^$:$$e(B?

r15927 e$B$GD>$C$F$$$k$3$H$r3NG$7$^$7$?!%e(B
e$B>$7$/3NG$7$F$O$$$^$;$s$,!$$-$C$He(B r15923 e$B$N$*$+$2$J$N$G$7$g$&$M!%e(B

e$B<j85$Ge(Br15921e$B$GDL$C$F$7$^$C$F$$$?$N$O!"e(Bautoloade$B$be(B-re$B%*%W%7%g%s$HF1e(B
e$B$8$/e(BKernel#requiree$B$r7PM3$9$k$h$&$K$7$F$$$?$;$$$G$7$?!#$3$l$O$3$le(B
e$B$GG:$^$7$$$s$G$9$1$I$M!#e(B

e$B1J0f!wCNG=!%6e9)Bg$G$9!%e(B

From: Nobuyoshi N. [email protected]
Subject: [ruby-dev:34269] Re: Ruby1.9 e$B$G$Ne(B $SAFE==4 e$B;~$Ne(B
autoload e$BF0:ne(B
Date: Tue, 8 Apr 2008 11:02:13 +0900
Message-ID: [email protected]

r15921e$B$Ge(Bbootstraptest/test_autoload.rbe$B$KDI2C$7$F$*$-$^$7$?$,!"DL$Ce(B
e$B$F$7$^$C$F$$$k$h$&$J5$$,$7$^$9!#%F%9%H$,$^$:$$e(B?

r15927 e$B$GD>$C$F$$$k$3$H$r3NG$7$^$7$?!%e(B
e$B>$7$/3NG$7$F$O$$$^$;$s$,!$$-$C$He(B r15923
e$B$N$*$+$2$J$N$G$7$g$&$M!%e(B

enc/prelude.rbe$B$K=q$$$F$"$k%i%$%V%i%jL>$,4V0c$C$F$$$^$7$?!#e(B
e$B$3$A$i$bF1$8$/D>$C$F$$$k$3$H$r3NG$7$^$7$?!%e(B
e$B$"$j$,$H$&$4$6$$$^$7$?!%e(B

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs