[#34911] erb still treats $KCODE — "Yusuke ENDOH" <mame@...>

遠藤です。

16 messages 2008/06/03

[#34923] open() and encodings — "NARUSE, Yui" <naruse@...>

成瀬です。

53 messages 2008/06/03
[#34924] Re: open() and encodings — Yukihiro Matsumoto <matz@...> 2008/06/04

まつもと ゆきひろです

[#34931] Re: open() and encodings — "NARUSE, Yui" <naruse@...> 2008/06/04

成瀬です。

[#34934] Re: open() and encodings — Yukihiro Matsumoto <matz@...> 2008/06/05

まつもと ゆきひろです

[#34935] Re: open() and encodings — "U.Nakamura" <usa@...> 2008/06/05

こんにちは、なかむら(う)です。

[#34936] Re: open() and encodings — Yukihiro Matsumoto <matz@...> 2008/06/05

まつもと ゆきひろです

[#34937] Re: open() and encodings — "U.Nakamura" <usa@...> 2008/06/05

こんにちは、なかむら(う)です。

[#34948] Re: open() and encodings — Hidetoshi NAGAI <nagai@...> 2008/06/05

永井@知能.九工大です.

[#34961] Re: open() and encodings — "NARUSE, Yui" <naruse@...> 2008/06/05

成瀬です。

[#34997] Re: [ruby-changes:5517] Ruby:r17021 (trunk): * vm_insnhelper.c, vm.c, proc.c (proc_call): allow call method with — SASADA Koichi <ko1@...>

 ささだです.

19 messages 2008/06/08
[#34998] Re: [ruby-changes:5517] Ruby:r17021 (trunk): * vm_insnhelper.c, vm.c, proc.c (proc_call): allow call method with — Yukihiro Matsumoto <matz@...> 2008/06/08

まつもと ゆきひろです

[#34999] Re: [ruby-changes:5517] Ruby:r17021 (trunk): * vm_insnhelper.c, vm.c, proc.c (proc_call): allow call method with — SASADA Koichi <ko1@...> 2008/06/08

 ささだです.

[#35000] Re: [ruby-changes:5517] Ruby:r17021 (trunk): * vm_insnhelper.c, vm.c, proc.c (proc_call): allow call method with — Yukihiro Matsumoto <matz@...> 2008/06/08

まつもと ゆきひろです

[#35001] Re: [ruby-changes:5517] Ruby:r17021 (trunk): * vm_insnhelper.c, vm.c, proc.c (proc_call): allow call method with — SASADA Koichi <ko1@...> 2008/06/08

 ささだです.

[#35003] Re: [ruby-changes:5517] Ruby:r17021 (trunk): * vm_insnhelper.c, vm.c, proc.c (proc_call): allow call method with — Yukihiro Matsumoto <matz@...> 2008/06/08

まつもと ゆきひろです

[#35007] Re: [ruby-changes:5517] Ruby:r17021 (trunk): * vm_insnhelper.c, vm.c, proc.c (proc_call): allow call method with — "Yusuke ENDOH" <mame@...> 2008/06/09

遠藤です。

[#35013] Re: [ruby-changes:5517] Ruby:r17021 (trunk): * vm_insnhelper.c, vm.c, proc.c (proc_call): allow call method with — Yukihiro Matsumoto <matz@...> 2008/06/09

まつもと ゆきひろです

[#35019] Re: [ruby-changes:5517] Ruby:r17021 (trunk): * vm_insnhelper.c, vm.c, proc.c (proc_call): allow call method with — "Yusuke ENDOH" <mame@...> 2008/06/09

遠藤です。

[#35021] Re: [ruby-changes:5517] Ruby:r17021 (trunk): * vm_insnhelper.c, vm.c, proc.c (proc_call): allow call method with — Yukihiro Matsumoto <matz@...> 2008/06/09

まつもと ゆきひろです

[#35020] Ruby 1.8.7-p17 has been released — "Akinori MUSHA" <knu@...>

 Ruby 1.8.7-p17 をリリースしました。

13 messages 2008/06/09

[#35044] deadlock detection for 1.9 — "Yusuke ENDOH" <mame@...>

遠藤です。

14 messages 2008/06/10

[#35108] Re: [ruby-list:44988] Re: 各ブランチの計画 — Urabe Shyouhei <shyouhei@...>

卜部です。

15 messages 2008/06/15

[#35200] Win32 Unicode console output — Tietew <tietew@...>

Tietew です。

22 messages 2008/06/22
[#35270] Re: Win32 Unicode console output — "NARUSE, Yui" <naruse@...> 2008/06/29

[#35226] [PATCH] freeze required_paths in gem_prelude.rb — "Keita Yamaguchi" <keita.yamaguchi@...>

山口と申します。

14 messages 2008/06/25
[#35228] Re: [PATCH] freeze required_paths in gem_prelude.rb — "Yusuke ENDOH" <mame@...> 2008/06/25

遠藤です。

[#35230] Re: [PATCH] freeze required_paths in gem_prelude.rb — Yukihiro Matsumoto <matz@...> 2008/06/25

まつもと ゆきひろです

[#35227] [Bug:trunk] Re: [ruby-cvs:24798] Ruby:r17573 (trunk): * parse.y (primary): make functional-style not operator to act — "U.Nakamura" <usa@...>

こんにちは、なかむら(う)です。

7 messages 2008/06/25

[#35247] Re: [ruby-list:45128] Re: Ruby 1.9.0/1.8.7/1.8.6/1.8.5 new releases (Security Fix) — Urabe Shyouhei <shyouhei@...>

卜部です。-devに振ります。ひょっとしてこんなパッチでSEGVのほうはおさまっ

13 messages 2008/06/26
[#35250] Re: [ruby-list:45128] Re: Ruby 1.9.0/1.8.7/1.8.6/1.8.5 new releases (Security Fix) — Yukihiro Matsumoto <matz@...> 2008/06/26

まつもと ゆきひろです

[#35273] $SAFEの今後 — Urabe Shyouhei <shyouhei@...>

〜これまでのあらすじ〜

24 messages 2008/06/30
[#35293] Re: $SAFEの今後 — Yukihiro Matsumoto <matz@...> 2008/07/01

まつもと ゆきひろです

[#35298] Re: $SAFEの今後 — Urabe Shyouhei <shyouhei@...> 2008/07/01

卜部です。

[#35303] Re: $SAFEの今後 — Yukihiro Matsumoto <matz@...> 2008/07/01

まつもと ゆきひろです

[#35304] Re: $SAFEの今後 — Urabe Shyouhei <shyouhei@...> 2008/07/01

卜部です。

[#35305] Re: $SAFEの今後 — Yukihiro Matsumoto <matz@...> 2008/07/01

まつもと ゆきひろです

[#35306] Re: $SAFEの今後 — "Shugo Maeda" <shugo@...> 2008/07/02

前田です。

[#35278] [BUG] test_win32ole_event.rb in trunk — Masaki Suketa <masaki.suketa@...>

助田です。

22 messages 2008/06/30
[#35281] Re: [BUG] test_win32ole_event.rb in trunk — "U.Nakamura" <usa@...> 2008/06/30

こんにちは、なかむら(う)です。

[#35282] Re: [BUG] test_win32ole_event.rb in trunk — arton <artonx@...> 2008/06/30

artonです。

[#35295] Re: [BUG] test_win32ole_event.rb in trunk — Masaki Suketa <masaki.suketa@...> 2008/07/01

助田です。

[ruby-dev:35269] $SAFE=2 and tempfile, tmpdir

From: arton <artonx@...>
Date: 2008-06-28 18:57:25 UTC
List: ruby-dev #35269
artonです。

Ruby 1.8.7-p22で、2点あります。
1つは、tempfile.rbで、$SAFE >= 2の場合にTempfile.newがRuntimeErrorで失敗
するのが意図的かどうかの確認です。

C:\home\arton\>ruby -rtempfile -e '$SAFE=2;Tempfile.new("test")'
c:/home/ruby/lib/ruby/1.8/tempfile.rb:52:in `initialize': cannot generate tempfi
le `' (RuntimeError)
        from -e:1:in `new'
        from -e:1

もし意図的でなければ、$SAFEが2の場合にはTempfile.newは成功して欲しいです。
Fileクラスは与えられたファイル名がtaintでなければ、$SAFEが4より小さけれ
ばファイルの作成を許していますが、Tempfileのファイル名は安全なはずなので、
同様であってほしいと思います。具体的にやりたいことは、open-uriを使った
Webサイトからのコンテンツ読み込みです。
なお、RuntimeErrorとなる原因は、ファイル名生成のときに呼び出すmake_tmpname
で、$$を利用してpid($SAFE=2でSecurityError)を取得しようとしているため、
get_pidが、$SAFE>=2でSecurityErrorとしているからです。このためファイル名
が生成されていない状態でファイルを作成しようとして、RuntimeErrorとなりま
す。

2点目は、Windows Vista以降のWindows固有の現象ですが、$SAFE>0の場合の
tmpdir.rbのDir::tmpdirの挙動というか設定があまりうまくありません。
具体的には、$SAFE>0のため、環境変数を参照せずに安全なテンポラリディレク
トリを得ようという意図だとは思いますが、@@systmpdirを利用しています。
で、@@systemdirとして、Win32 APIで取得したWindowsディレクトリ内のTempディ
レクトリを設定していますが、このディレクトリは、Windows Vistaでは管理者権限のみ
アクセス可能で、一般のユーザーは読み書きできません。

C:\home\arton>ruby -rtmpdir -e 'p Dir::tmpdir'
"C:/Users/arton/AppData/Local/Temp"

C:\home\arton>ruby -rtmpdir -e '$SAFE=1; p Dir::tmpdir'
"C:/Windows/Temp"

Windows側の意図と、元のtmpdirの意図を、尊重するならば、ユーザー固有のテ
ンポラリディレクトリを、Win32 APIで取得するのがあるべき姿ではないでしょ
うか。
というわけで、以下にtmpdir.rbのパッチを添付します。
SHGetFolderPath APIで現在のユーザーの専用ディレクトリを得るようにしてい
ます。SHGetFolderPath APIが取れない場合(古いWindows)については、従来の動
作となるようにしています。

diff -u tmpdir.rb.org tmpdir.rb
--- tmpdir.rb.org	Sun Jun 29 02:20:44 2008
+++ tmpdir.rb	Sun Jun 29 02:47:54 2008
@@ -9,18 +9,25 @@
 class Dir
 
   @@systmpdir = '/tmp'
-
+  CSIDL_LOCAL_APPDATA = 0x001c
+  
   begin
     require 'Win32API'
     max_pathlen = 260
     windir = ' '*(max_pathlen+1)
     begin
-      getdir = Win32API.new('kernel32', 'GetSystemWindowsDirectory', 'PL', 'L')
+      getdir = Win32API.new('shell32', 'SHGetFolderPath', 'LLLLP', 'L')
+      raise RuntimeError if getdir.call(0, CSIDL_LOCAL_APPDATA, 0, 0, windir) != 0
+      windir = File.expand_path(windir.rstrip)
     rescue RuntimeError
-      getdir = Win32API.new('kernel32', 'GetWindowsDirectory', 'PL', 'L')
+      begin
+        getdir = Win32API.new('kernel32', 'GetSystemWindowsDirectory', 'PL', 'L')
+      rescue RuntimeError
+        getdir = Win32API.new('kernel32', 'GetWindowsDirectory', 'PL', 'L')
+      end
+      len = getdir.call(windir, windir.size)
+      windir = File.expand_path(windir[0, len])
     end
-    len = getdir.call(windir, windir.size)
-    windir = File.expand_path(windir[0, len])
     temp = File.join(windir, 'temp')
     @@systmpdir = temp if File.directory?(temp) and File.writable?(temp)
   rescue LoadError

パッチ後は、$SAFE=0の従来の値と同じものになりますが、TMP環境変数の設定に
は影響されないことで確認できます。
C:\home\arton\test>set TMP=c:\home\arton\test
C:\home\arton\test>ruby -rtmpdir -e '$SAFE=1;p Dir::tmpdir'
"C:/Users/arton/AppData/Local/Temp"

もっとも、Ruby-1.9.0-01だと、Tempfile.newもDir::tmpdirも、$SAFE>0では、
いずれもFile.expand_pathに引っかかってSecurityErrorになります。
できれば、こちらも動いて欲しいです。

-- 
arton <artonx@yahoo.co.jp>

--------------------------------------
Power up the Internet with Yahoo! Toolbar.
http://pr.mail.yahoo.co.jp/toolbar/

In This Thread

Prev Next