[#2139] Best way to install ri documentation — Dave Thomas <dave@...>

Folks:

69 messages 2004/01/04
[#2140] Re: Best way to install ri documentation — Gavin Sinclair <gsinclair@...> 2004/01/04

On Monday, January 5, 2004, 2:29:57 AM, Dave wrote:

[#2141] Re: Best way to install ri documentation — matz@... (Yukihiro Matsumoto) 2004/01/04

Hi,

[#2145] Re: Best way to install ri documentation — Richard Kilmer <rich@...> 2004/01/05

Perhaps make it available for mirrors and save ruby-lang's bandwidth?

[#2147] Re: Best way to install ri documentation — Dave Thomas <dave@...> 2004/01/05

[#2148] Re: Best way to install ri documentation -- please check this — Dave Thomas <dave@...> 2004/01/05

So, I'm thinking about doing the following? Is this OK with everyone?

[#2149] Re: Best way to install ri documentation -- please check this — "J.Herre" <jlst@...> 2004/01/05

[#2152] Re: Best way to install ri documentation -- please check this — Dave Thomas <dave@...> 2004/01/05

[#2153] Re: Best way to install ri documentation -- please check this — nobu.nokada@... 2004/01/05

Hi,

[#2154] Re: Best way to install ri documentation -- please check this — Dave Thomas <dave@...> 2004/01/05

[#2219] Re: Best way to install ri documentation -- please check this — "James F. Hranicky" <jfh@...> 2004/01/12

On Tue, 6 Jan 2004 00:47:41 +0900

[#2194] File.readable_world? and File.writable_world? — Ian Macdonald <ian@...>

Hello,

27 messages 2004/01/09
[#2195] Re: [PATCH] File.readable_world? and File.writable_world? — Eivind Eklund <eivind@...> 2004/01/09

On Fri, Jan 09, 2004 at 06:02:07PM +0900, Ian Macdonald wrote:

[#2199] Re: [PATCH] File.readable_world? and File.writable_world? — Ian Macdonald <ian@...> 2004/01/09

On Fri 09 Jan 2004 at 23:10:02 +0900, Eivind Eklund wrote:

[#2200] Re: [PATCH] File.readable_world? and File.writable_world? — matz@... (Yukihiro Matsumoto) 2004/01/10

Hi,

[#2203] Re: [PATCH] File.readable_world? and File.writable_world? — Ian Macdonald <ian@...> 2004/01/11

On Sun 11 Jan 2004 at 00:47:33 +0900, Yukihiro Matsumoto wrote:

[#2206] Re: [PATCH] File.readable_world? and File.writable_world? — matz@... (Yukihiro Matsumoto) 2004/01/11

Hi,

[#2208] Re: [PATCH] File.readable_world? and File.writable_world? — Ian Macdonald <ian@...> 2004/01/11

On Sun 11 Jan 2004 at 21:40:22 +0900, Yukihiro Matsumoto wrote:

[#2209] Re: [PATCH] File.readable_world? and File.writable_world? — matz@... (Yukihiro Matsumoto) 2004/01/12

Hi,

[#2216] ruby aborts in data-handling applications — xsdg <xsdg@...>

I reported a similar bug about 2 or 3 months ago. The problem seemed to go

12 messages 2004/01/12

Re: [PATCH] File.readable_world? and File.writable_world?

From: Ian Macdonald <ian@...>
Date: 2004-01-11 09:15:20 UTC
List: ruby-core #2204
On Sun 11 Jan 2004 at 11:06:59 +0900, Yukihiro Matsumoto wrote:

> In message "Re: [PATCH] File.readable_world? and File.writable_world?"
>     on 04/01/11, Ian Macdonald <ian@caliban.org> writes:
> 
> |> I prefer world_writable? that means being writable from anybody.
> |
> |Do you want me to submit a new patch?
> 
> Yes, hopefully with ChangeLog entry.

OK. Here's the patch that implements File::readable_others?,
File::world_readable?, File::writable_others? and File::world_writable?.
The corresponding instance methods in FileTest have also been
implemented.

I have attached the ChangeLog entry to this message.

Will this go into 1.9 or also into 1.8.2?

Ian
-- 
Ian Macdonald               | Successful and fortunate crime is called
System Administrator        | virtue. - Seneca 
ian@caliban.org             | 
http://www.caliban.org      | 
                            | 

Attachments (2)

ruby-1.8.1-File2.diff (3.77 KB, text/x-diff)
diff -uNr ruby-1.8.1.orig/ruby/file.c ruby-1.8.1/ruby/file.c
--- ruby-1.8.1.orig/ruby/file.c	2003-12-24 07:19:09.000000000 -0800
+++ ruby-1.8.1/ruby/file.c	2004-01-11 01:00:39.000000000 -0800
@@ -1015,6 +1015,47 @@
     return Qtrue;
 }
 
+/*
+ * call-seq:
+ *    File.readable_others?(file_name)   => true or false
+ *
+ * Returns <code>true</code> if the named file is readable by others.
+ */
+
+static VALUE
+test_ro(obj, fname)
+    VALUE obj, fname;
+{
+#ifdef S_IROTH
+    struct stat st;
+
+    if (rb_stat(fname, &st) < 0) return Qfalse;
+    if ((st.st_mode & S_IROTH) != 0) return Qtrue;
+#endif
+    return Qfalse;
+}
+
+/*
+ * call-seq:
+ *    File.world_readable?(file_name)   => true or false
+ *
+ * Returns <code>true</code> if the named file is readable by everyone.
+ */
+
+static VALUE
+test_wr(obj, fname)
+    VALUE obj, fname;
+{
+#ifdef S_IROTH
+    struct stat st;
+
+    if (rb_stat(fname, &st) < 0) return Qfalse;
+    if ((st.st_mode & (S_IRUSR|S_IRGRP|S_IROTH)) ==
+        (S_IRUSR|S_IRGRP|S_IROTH)) return Qtrue;
+#endif
+    return Qfalse;
+}
+
 
 /*
  * call-seq:
@@ -1052,6 +1093,47 @@
 
 /*
  * call-seq:
+ *    File.writable_others?(file_name)   => true or false
+ *
+ * Returns <code>true</code> if the named file is writable by others.
+ */
+
+static VALUE
+test_wo(obj, fname)
+    VALUE obj, fname;
+{
+#ifdef S_IWOTH
+    struct stat st;
+
+    if (rb_stat(fname, &st) < 0) return Qfalse;
+    if ((st.st_mode & S_IWOTH) != 0) return Qtrue;
+#endif
+    return Qfalse;
+}
+
+/*
+ * call-seq:
+ *    File.world_writable?(file_name)   => true or false
+ *
+ * Returns <code>true</code> if the named file is writable by everyone.
+ */
+
+static VALUE
+test_ww(obj, fname)
+    VALUE obj, fname;
+{
+#ifdef S_IWOTH
+    struct stat st;
+
+    if (rb_stat(fname, &st) < 0) return Qfalse;
+    if ((st.st_mode & (S_IWUSR|S_IWGRP|S_IWOTH)) ==
+        (S_IWUSR|S_IWGRP|S_IWOTH)) return Qtrue;
+#endif
+    return Qfalse;
+}
+
+/*
+ * call-seq:
  *    File.executable?(file_name)   => true or false
  *
  * Returns <code>true</code> if the named file is executable by the effective
@@ -4052,8 +4134,12 @@
     define_filetest_function("exists?", test_e, 1); /* temporary */
     define_filetest_function("readable?", test_r, 1);
     define_filetest_function("readable_real?", test_R, 1);
+    define_filetest_function("readable_others?", test_ro, 1);
+    define_filetest_function("world_readable?", test_wr, 1);
     define_filetest_function("writable?", test_w, 1);
     define_filetest_function("writable_real?", test_W, 1);
+    define_filetest_function("writable_others?", test_wo, 1);
+    define_filetest_function("world_writable?", test_ww, 1);
     define_filetest_function("executable?", test_x, 1);
     define_filetest_function("executable_real?", test_X, 1);
     define_filetest_function("file?", test_f, 1);
diff -uNr ruby-1.8.1.orig/ruby/lib/pathname.rb ruby-1.8.1/ruby/lib/pathname.rb
--- ruby-1.8.1.orig/ruby/lib/pathname.rb	2003-12-25 23:42:35.000000000 -0800
+++ ruby-1.8.1/ruby/lib/pathname.rb	2004-01-11 01:00:14.000000000 -0800
@@ -423,6 +423,8 @@
   def owned?() FileTest.owned?(@path) end
   def readable?() FileTest.readable?(@path) end
   def readable_real?() FileTest.readable_real?(@path) end
+  def readable_others?() FileTest.readable_others?(@path) end
+  def world_readable?() FileTest.world_readable?(@path) end
   def setuid?() FileTest.setuid?(@path) end
   def setgid?() FileTest.setgid?(@path) end
   def size() FileTest.size(@path) end
@@ -431,6 +433,8 @@
   def symlink?() FileTest.symlink?(@path) end
   def writable?() FileTest.writable?(@path) end
   def writable_real?() FileTest.writable_real?(@path) end
+  def writable_others?() FileTest.writable_others?(@path) end
+  def world_writable?() FileTest.world_writable?(@path) end
   def zero?() FileTest.zero?(@path) end
 end
 
ChangeLog (407 Bytes, text/plain)
Sun Jan 11 01:08:04 2004  Ian Macdonald  <ian@caliban.org>
	
	* file.c (test_ro, test_wr, test_wo, test_ww): New functions
	  implementing new methods (File::readable_others?,
	  File::world_readable?, File::writable_others? and
	  File::world_writable?).
	
	* lib/pathname.rb: New methods (FileTest#readable_others?,
	  FileTest#world_readable?, FileTest#writable_others? and
	  FileTest#world_writable?).

In This Thread