[#7978] Patch for Unix socket peer credentials — "James F. Hranicky" <jfh@...>

This patch adds support for getting the uid and gid of the peer

27 messages 2006/06/09
[#8004] Re: Patch for Unix socket peer credentials — Tanaka Akira <akr@...17n.org> 2006/06/16

In article <200606091528.30171.jfh@cise.ufl.edu>,

[#8005] Re: Patch for Unix socket peer credentials — "James F. Hranicky" <jfh@...> 2006/06/16

On Friday 16 June 2006 11:51, Tanaka Akira wrote:

[#8010] Re: Patch for Unix socket peer credentials — Tanaka Akira <akr@...17n.org> 2006/06/17

In article <200606161327.35948.jfh@cise.ufl.edu>,

[#8191] Re: Patch for Unix socket peer credentials — "James F. Hranicky" <jfh@...> 2006/07/10

On Saturday 17 June 2006 06:27, Tanaka Akira wrote:

[#8193] Re: Patch for Unix socket peer credentials — Tanaka Akira <akr@...> 2006/07/11

In article <200607101352.16804.jfh@cise.ufl.edu>,

[#8212] Re: Patch for Unix socket peer credentials — "James F. Hranicky" <jfh@...> 2006/07/13

On Tuesday 11 July 2006 00:10, Tanaka Akira wrote:

[#8217] Re: Patch for Unix socket peer credentials — nobu@... 2006/07/14

Hi,

[#8257] Re: Patch for Unix socket peer credentials — "James F. Hranicky" <jfh@...> 2006/07/18

On Thursday 13 July 2006 22:48, nobu@ruby-lang.org wrote:

[#8258] Re: Patch for Unix socket peer credentials — Eric Hodel <drbrain@...7.net> 2006/07/18

On Jul 18, 2006, at 12:27 PM, James F. Hranicky wrote:

[#8073] 1.8.5p1 build failure on Solaris 10 — "Daniel Berger" <Daniel.Berger@...>

Solaris 10

23 messages 2006/06/27
[#8074] Re: 1.8.5p1 build failure on Solaris 10 — Yukihiro Matsumoto <matz@...> 2006/06/28

Hi,

[#8078] Re: 1.8.5p1 build failure on Solaris 10 — "Daniel Berger" <Daniel.Berger@...> 2006/06/28

Yukihiro Matsumoto wrote:

[#8079] Re: 1.8.5p1 build failure on Solaris 10 — ts <decoux@...> 2006/06/28

>>>>> "D" == Daniel Berger <Daniel.Berger@qwest.com> writes:

[#8096] Re: 1.8.5p1 build failure on Solaris 10 — ville.mattila@... 2006/06/29

ts <decoux@moulon.inra.fr> wrote on 28.06.2006 17:37:00:

[PATCH] File.mkfifo File.mknod

From: "guillaume pierronnet" <guillaume.pierronnet@...>
Date: 2006-06-21 13:01:35 UTC
List: ruby-core #8036
hi list,

i've seen an old patch on ruby-talk
(http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/91735)
who add support for mkfifo() and mknod() in ruby. It doesn't seems to
have been included in ruby.

Here is a updated version of this patch against the latest CVS.

regards

Attachments (1)

mkfifo_mknod.patch (4.12 KB, text/x-diff)
Index: configure.in
===================================================================
RCS file: /src/ruby/configure.in,v
retrieving revision 1.301
diff -u -r1.301 configure.in
--- configure.in	9 Jun 2006 21:20:13 -0000	1.301
+++ configure.in	21 Jun 2006 12:54:40 -0000
@@ -510,7 +510,7 @@
 	      getpriority getrlimit setrlimit\
 	      dlopen sigprocmask sigaction _setjmp vsnprintf snprintf\
 	      setsid telldir seekdir fchmod mktime timegm cosh sinh tanh log2\
-	      setuid setgid daemon select_large_fdset setenv unsetenv)
+	      setuid setgid daemon select_large_fdset setenv unsetenv mkfifo mknod)
 AC_ARG_ENABLE(setreuid,
        [  --enable-setreuid       use setreuid()/setregid() according to need even if obsolete.],
        [use_setreuid=$enableval])
Index: file.c
===================================================================
RCS file: /src/ruby/file.c,v
retrieving revision 1.240
diff -u -r1.240 file.c
--- file.c	20 Jun 2006 18:02:16 -0000	1.240
+++ file.c	21 Jun 2006 12:54:42 -0000
@@ -3368,6 +3368,103 @@
     return Qnil;		/* not reached */
 }
 
+/*
+ *  call-seq:
+ *     File.mknod(file_name, [type, [mode, [dev]]])  => 0
+ *  
+ * Create a filesystem node (file, device special file or named pipe)
+ * named _file_name_, specified by _mode_ and _dev_.
+ *
+ * _type_ and _mode_ specifies the type and the permissions of node to
+ * be created respectively.
+ *
+ * The permissions are modified by the process's umask in the usual
+ * way: the permissions of the created node are (mode & ~umask).
+ *
+ * _type_ should be one of +?f+, +?c+, +?b+ and +?p+ to specify a
+ * normal file (which will be created empty), character special file,
+ * block special file or FIFO (named pipe), respectively, or +nil+,
+ * which will create a normal file.
+ */
+
+static VALUE
+rb_file_s_mknod(argc, argv)
+    int argc;
+    VALUE *argv;
+{
+#ifdef HAVE_MKNOD
+    VALUE path, type, vmode, vdev;
+    int mode = 0666, dev = 0, t;
+
+    rb_secure(4);
+    switch (rb_scan_args(argc, argv, "13", &path, &type, &vmode, &vdev)) {
+      case 4:
+	dev = NUM2INT(vdev);
+      case 3:
+	mode = NUM2INT(vmode) & ~S_IFMT;
+    }
+    SafeStringValue(path);
+    if (!NIL_P(type)) {
+	rb_check_safe_obj(type);
+	switch (t = NUM2CHR(type)) {
+	  case 'f': mode |= S_IFREG; break;
+	  case 'c': mode |= S_IFCHR; break;
+#ifdef S_IFBLK
+	  case 'b': mode |= S_IFBLK; break;
+#endif
+#ifdef S_IFIFO
+	  case 'p': mode |= S_IFIFO; break;
+#endif
+	  default:
+	    rb_raise(rb_eArgError, "unknown node type - %c", t);
+	}
+    }
+    if (mknod(RSTRING(path)->ptr, mode, dev)) {
+	rb_sys_fail(0);
+    }
+#else
+    rb_notimplement();
+#endif
+    return INT2FIX(0);
+}
+
+/*
+ *  call-seq:
+ *     File.mkfifo(file_name, mode)  => 0
+ *  
+ *  Creates a FIFO special file with name _file_name_.  _mode_
+ *  specifies the FIFO's permissions. It is modified by the process's
+ *  umask in the usual way: the permissions of the created file are
+ *  (mode & ~umask).
+ */
+
+static VALUE
+rb_file_s_mkfifo(argc, argv)
+    int argc;
+    VALUE *argv;
+{
+#if !defined HAVE_MKFIFO && defined HAVE_MKNOD && defined S_IFIFO
+#define mkfifo(path, mode) mknod(path, (mode)&~S_IFMT|S_IFIFO, 0)
+#define HAVE_MKFIFO
+#endif
+#ifdef HAVE_MKFIFO
+    VALUE path, vmode;
+    int mode = 0666;
+
+    rb_secure(4);
+    if (rb_scan_args(argc, argv, "11", &path, &vmode) > 1) {
+	mode = NUM2INT(vmode);
+    }
+    SafeStringValue(path);
+    if (mkfifo(RSTRING(path)->ptr, mode)) {
+	rb_sys_fail(0);
+    }
+#else
+    rb_notimplement();
+#endif
+    return INT2FIX(0);
+}
+
 
 
 /*
@@ -4341,6 +4438,8 @@
     rb_define_singleton_method(rb_cFile, "rename", rb_file_s_rename, 2);
     rb_define_singleton_method(rb_cFile, "umask", rb_file_s_umask, -1);
     rb_define_singleton_method(rb_cFile, "truncate", rb_file_s_truncate, 2);
+    rb_define_singleton_method(rb_cFile, "mknod", rb_file_s_mknod, -1);
+    rb_define_singleton_method(rb_cFile, "mkfifo", rb_file_s_mkfifo, -1);
     rb_define_singleton_method(rb_cFile, "expand_path", rb_file_s_expand_path, -1);
     rb_define_singleton_method(rb_cFile, "basename", rb_file_s_basename, -1);
     rb_define_singleton_method(rb_cFile, "dirname", rb_file_s_dirname, 1);

In This Thread

Prev Next