[#11073] segfault printing instruction sequence for iterator — <noreply@...>

Bugs item #10527, was opened at 2007-05-02 14:42

14 messages 2007/05/02
[#11142] Re: [ ruby-Bugs-10527 ] segfault printing instruction sequence for iterator — Nobuyoshi Nakada <nobu@...> 2007/05/10

Hi,

[#11188] Re: [ ruby-Bugs-10527 ] segfault printing instruction sequence for iterator — Paul Brannan <pbrannan@...> 2007/05/16

On Thu, May 10, 2007 at 04:51:18PM +0900, Nobuyoshi Nakada wrote:

[#11234] Planning to release 1.8.6 errata — Urabe Shyouhei <shyouhei@...>

Hi all.

17 messages 2007/05/25

Re: FileUtils.rm_rf misfeature?

From: Nobuyoshi Nakada <nobu@...>
Date: 2007-05-16 02:26:23 UTC
List: ruby-core #11180
Hi,

At Wed, 16 May 2007 10:03:42 +0900,
johan556@gmail.com wrote in [ruby-core:11176]:
> Should this be considered a bug in FileUtils, or is there some reason
> why FileUtils differ in behavior?

I don't think there is such reason.

> Below I give a Ruby unit-test that illustrates the current "misfeature".

It depends on external environments, sudo command and
user/group names.  It would be good enough to change the mode
of the parent directory, I guess.


Index: lib/fileutils.rb
===================================================================
--- lib/fileutils.rb	(revision 12283)
+++ lib/fileutils.rb	(working copy)
@@ -715,9 +715,9 @@ module FileUtils
       begin
         ent.remove
-      rescue
+      rescue Errno::ENOENT
         raise unless force
       end
     end
-  rescue
+  rescue Errno::ENOENT
     raise unless force
   end
@@ -749,9 +749,9 @@ module FileUtils
       begin
         ent.remove
-      rescue
+      rescue Errno::ENOENT
         raise unless force
       end
     end
-  rescue
+  rescue Errno::ENOENT
     raise unless force
   end
@@ -764,5 +764,5 @@ module FileUtils
   def remove_file(path, force = false)
     Entry_.new(path).remove_file
-  rescue
+  rescue Errno::ENOENT
     raise unless force
   end
Index: test/fileutils/test_fileutils.rb
===================================================================
--- test/fileutils/test_fileutils.rb	(revision 12283)
+++ test/fileutils/test_fileutils.rb	(working copy)
@@ -416,5 +416,5 @@ end
     Dir.rmdir 'tmpdatadir'
 
-    Dir.mkdir 'tmp/tmpdir'
+    Dir.mkdir 'tmp/tmpdir', 0700
     File.open('tmp/tmpdir/a', 'w') {|f| f.puts 'dummy' }
     File.open('tmp/tmpdir/c', 'w') {|f| f.puts 'dummy' }
@@ -422,4 +422,14 @@ end
     assert_file_not_exist 'tmp/tmpdir/a'
     assert_file_not_exist 'tmp/tmpdir/c'
+    File.open('tmp/tmpdir/d', 'w') {|f| f.puts 'dummy' }
+    File.chmod(0500, 'tmp/tmpdir')
+    begin
+      assert_file_exist 'tmp/tmpdir/d'
+      assert_raises(Errno::EACCES) {rm_f 'tmp/tmpdir/d'}
+      assert_file_exist 'tmp/tmpdir/d'
+    ensure
+      File.chmod(0700, 'tmp/tmpdir')
+      File.unlink 'tmp/tmpdir/d'
+    end
     Dir.rmdir 'tmp/tmpdir'
 


-- 
Nobu Nakada

In This Thread