[#8123] Unit/Regression tests for Ruby builtin classes and modules — Wayne Kelly <w.kelly@...>
[#8129] segmentation fault while evaluating printf:Kernel — <noreply@...>
Bugs item #4949, was opened at 2006-07-05 18:03
[#8131] thread mystery — ara.t.howard@...
[#8132] rdoc, C extensions, stop and start — "Daniel Berger" <Daniel.Berger@...>
Hi,
[#8136] Confused exception handling in Continuation Context — "Robert Dober" <robert.dober@...>
Hi all
Robert Dober schrieb:
On 7/6/06, Pit Capitain <pit@capitain.de> wrote:
Hi,
[#8142] thread/sync.rb memory corruption — ara.t.howard@...
Could someone please confirm this can be reproduced on 1.8.5 pre1?
On Thu, 6 Jul 2006, URABE Shyouhei wrote:
[#8167] bug in printf — <noreply@...>
Bugs item #4970, was opened at 2006-07-07 14:18
Hi,
On 7/25/06, nobu@ruby-lang.org <nobu@ruby-lang.org> wrote:
Hi,
[#8169] next in ensure body (Ruby 1.8.x) — "Dominik Bathon" <dbatml@...>
Hi,
[#8180] Called method not removed after remove_method — <noreply@...>
Bugs item #4998, was opened at 2006-07-09 13:20
[#8194] rss patch -- mostly doc, plus English adjustments. — Hugh Sasse <hgs@...>
This is a patch set against the stable snapshot.
Hi,
[#8196] SONY VIAOLAPTOP-------------$750USD,NOKIA N93-------------------$250USD — <noreply@...>
Bugs item #5032, was opened at 2006-07-12 18:41
I think this is more of an enhancement...
> Subject: Re: [ ruby-Bugs-5032 ] SONY
[#8201] Please implement expect.rb for Windows Ruby — <noreply@...>
Bugs item #5036, was opened at 2006-07-12 14:44
Hi,
Yukihiro Matsumoto wrote:
Hi,
[#8203] Re: [PATCH] --fqname option to test/unit/autorunner.rb — "Berger, Daniel" <Daniel.Berger@...>
> -----Original Message-----
Thanks again for getting back to me. Perhaps my original focus on the
[#8222] Rdoc patch for lib/prettyprint.rb — Hugh Sasse <hgs@...>
This is a first pass at converting the RDTool docs for lib/prettyprint.rb
[#8223] Unexpected pointer behavior with unpack — "Justin Bailey" <jgbailey@...>
I have had the opportunity to work [1] a lot with Ruby's ability to create
[#8229] open-uri fails under multithreading — <noreply@...>
Bugs item #5067, was opened at 2006-07-14 19:11
[#8243] tuplespace - make comments visible to rdoc. — Hugh Sasse <hgs@...>
comments in rdoc conventionally don't start with two # marks and don't
On Jul 17, 2006, at 10:09 AM, Hugh Sasse wrote:
That 'doesn't add anything' is meant to the last paragraph, as i understood it.
On Tue, 18 Jul 2006, Jan Svitok wrote:
[#8248] One-Click Installer: MinGW? or VC2005? — "Curt Hibbs" <ml.chibbs@...>
I just posted this to ruby-talk. But I would also like to discuss this
Dear Curt,
On 7/20/06, Kaspar Schiess <eule@space.ch> wrote:
I was wondering if the toolchain could be built around rake?
The One-Click Ruby Installer's build process is, in fact, controlled via
From my experience using both tool chains on Windows (for the ruby-prof
Tim, I'm going to top reply since your post was so long. I'm interested in
> Tim, I'm going to top reply since your post was so long. I'm interested in
On 7/19/06, Charlie Savage <cfis@savagexi.com> wrote:
Curt Hibbs wrote:
On 7/19/06, M. Edward (Ed) Borasky <znmeb@cesmail.net> wrote:
Hello,
[#8262] Instability around popen due to missing rb_thread_atfork — <noreply@...>
Patches item #5111, was opened at 2006-07-18 22:36
Hi,
On 19 Jul 2006, at 8:25, <nobu@ruby-lang.org> <nobu@ruby-lang.org>
[#8271] my sandboxing extension!! — why the lucky stiff <ruby-core@...>
I have (what feels like) very exciting news. I finally sat down to code up my
On Wed, Jul 19, 2006 at 06:40:34PM +0900, why the lucky stiff wrote:
On Wed, Jul 19, 2006 at 08:00:15PM +0900, Mauricio Fernandez wrote:
On Wed, Jul 19, 2006 at 11:18:27PM +0900, why the lucky stiff wrote:
Okay, it turns out that, in order for this to work, I also need the following
Hi,
On Thu, Jul 20, 2006 at 03:11:34PM +0900, Yukihiro Matsumoto wrote:
Hi,
On 7/20/06, Yukihiro Matsumoto <matz@ruby-lang.org> wrote:
[#8273] Regular-Expressions Problem/Bug — Reto Schuettel <reto-ruby-core@...>
Hi
On Wed, 19 Jul 2006, Reto Schuettel wrote:
Hi
>>>>> "R" == Reto Schuettel <reto-ruby-core@schuettel.ch> writes:
[#8299] Interest in NTLM/Negotiate patch for net/http? — "Justin Bailey" <jgbailey@...>
My workplace recently installed Microsoft's ISA server, which proxies all
On Jul 19, 2006, at 5:01 PM, Justin Bailey wrote:
[#8331] (Fwd) Re: Patch to Ruby in 2005 — "John Fletcher" <J.P.Fletcher@...>
Hi
Hi,
On Fri, 21 Jul 2006, nobu@ruby-lang.org wrote:
[#8379] rdoc grows to large size. — Hugh Sasse <hgs@...>
While working on that .document patch I noticed that rdoc grew to
On Jul 24, 2006, at 6:09 AM, Hugh Sasse wrote:
[#8394] Re: rdoc grows to large size. — "Berger, Daniel" <Daniel.Berger@...>
> -----Original Message-----
[#8423] doc patch: readbytes.rb — Hugh Sasse <hgs@...>
A patch against the stable snapshot.
[#8427] RDoc picking up comments from function prototypes — Tilman Sauerbeck <tilman@...>
Hi,
Tilman Sauerbeck [2006-07-29 02:39]:
On Aug 9, 2006, at 9:52 AM, Tilman Sauerbeck wrote:
[#8430] Re: doc patch: weakref. — "Berger, Daniel" <Daniel.Berger@...>
> -----Original Message-----
Hi,
Yukihiro Matsumoto wrote:
On Sat, Jul 29, 2006 at 07:37:24PM +0900, Daniel Berger wrote:
On Sun, 30 Jul 2006, Mauricio Fernandez wrote:
On Jul 31, 2006, at 3:20 AM, Hugh Sasse wrote:
On Tue, 1 Aug 2006, Eric Hodel wrote:
On Aug 1, 2006, at 2:13 AM, Hugh Sasse wrote:
[#8441] Inconsistency in scoping during module_eval? — "Charles O Nutter" <headius@...>
I have the following code:
Hi,
Why does this:
Hi,
So to clarify...
I don't want to take this thread off-course, but what I meant was
On Mon, 31 Jul 2006, Matt Todd wrote:
On 7/30/06, Mathieu Bouchard <matju@artengine.ca> wrote:
Awesome. Thank you very much for your responses. Curious. I knew a
On 7/31/06, Matt Todd <chiology@gmail.com> wrote:
[#8447] #if should be #ifdef in ruby.h — <noreply@...>
Bugs item #5243, was opened at 2006-07-30 16:31
noreply@rubyforge.org wrote:
[#8466] Multi-Line Date Formate Patch — James Edward Gray II <james@...>
It was pointed out to me that the following code is surprising:
On Jul 31, 2006, at 8:26 AM, James Edward Gray II wrote:
Hi,
Re: Patch for Unix socket peer credentials
On Tuesday 11 July 2006 00:10, Tanaka Akira wrote: > In article <200607101352.16804.jfh@cise.ufl.edu>, > > I think it's good enough. Ok. I changed it to a struct, and made it a method of BasicSock: ruby -rsocket -e 'p UNIXServer.new(ARGV.shift).accept.peer_cred' /tmp/sock #<struct Struct::SockCred uid=987, gid=10426, ruid=987, rgid=10426, euid=987, egid=10426> Here's the patch. The method should throw an error if any of the system calls fail or if (uid < 0 || gid < 0). Questions or comments welcome. Jim
Attachments (1)
diff -ur ruby-1.8.5-preview1/ext/socket/extconf.rb ruby-1.8.5-preview1.mod/ext/socket/extconf.rb
--- ruby-1.8.5-preview1/ext/socket/extconf.rb 2006-06-06 22:40:22.000000000 -0400
+++ ruby-1.8.5-preview1.mod/ext/socket/extconf.rb 2006-07-11 16:51:55.717600000 -0400
@@ -226,6 +226,20 @@
EOS
end
+if have_library("c", "getpeerucred")
+ $defs << "-DHAVE_GETPEERUCRED "
+else
+ puts "no getpeerucred"
+end
+
+if have_library("c", "getpeereid")
+ $defs << "-DHAVE_GETPEEREID "
+end
+
+if have_macro("SO_PEERCRED", "sys/socket.h")
+ $defs << "-DHAVE_SO_PEERCRED "
+end
+
case with_config("lookup-order-hack", "UNSPEC")
when "INET"
$defs << "-DLOOKUP_ORDER_HACK_INET"
diff -ur ruby-1.8.5-preview1/ext/socket/socket.c ruby-1.8.5-preview1.mod/ext/socket/socket.c
--- ruby-1.8.5-preview1/ext/socket/socket.c 2006-06-21 16:19:07.000000000 -0400
+++ ruby-1.8.5-preview1.mod/ext/socket/socket.c 2006-07-13 14:58:17.499317000 -0400
@@ -71,6 +71,13 @@
#endif
#include "sockport.h"
+#if defined(HAVE_GETPEERUCRED)
+#include <ucred.h>
+#elif defined(HAVE_GETPEEREID)
+#include <sys/types.h>
+#include <unistd.h>
+#endif
+
#if defined(__vms)
#include <tcp.h>
#endif
@@ -89,6 +96,7 @@
VALUE rb_cSocket;
static VALUE rb_eSocket;
+static VALUE sSockCred;
#ifdef SOCKS
VALUE rb_cSOCKSSocket;
@@ -1643,6 +1651,101 @@
return ipaddr((struct sockaddr*)&addr);
}
+/*
+ * Document-method: peer_cred
+ * call-seq: socket.peer_cred => s
+ * s.uid => ruid || euid
+ * s.gid => rgid || egid
+ * s.ruid => ruid
+ * s.euid => euid
+ * s.rgid => rgid
+ * s.egid => egid
+ * }
+ *
+ * Returns a struct containing the credentials of the peer socket for
+ * Unix domain stream sockets
+ *
+ * === Example
+ * # Client example
+ * require 'socket'
+ * s = UNIXSocket.new("/path/to/socket")
+ * puts "Peer uid is #{s.peer_cred.uid}"
+ *
+ * # Server example
+ * require 'socket'
+ * s = UNIXServer.new("/path/to/socket")
+ * ns = s.accept
+ * puts "Peer uid is #{ns.peer_cred.uid}"
+ *
+ */
+
+static VALUE
+unix_peer_cred(sock)
+ VALUE sock;
+{
+ char buf[1024];
+ socklen_t len = sizeof buf;
+ OpenFile *fptr;
+ int uid, gid, ruid, rgid, euid, egid;
+ uid = gid = ruid = rgid = euid = egid = -1;
+
+#if defined(HAVE_GETPEERUCRED)
+ ucred_t *creds;
+#elif defined(HAVE_SO_PEERCRED)
+ struct ucred creds;
+#else
+ rb_raise(rb_eSocket, "peer_cred not implemented on this platform");
+#endif
+
+ GetOpenFile(sock, fptr);
+
+#if defined(HAVE_GETPEERUCRED)
+ if ((creds = malloc(ucred_size())) == NULL)
+ rb_sys_fail("malloc");
+
+ if (getpeerucred(fileno(fptr->f), &creds) < 0)
+ rb_sys_fail("getpeerucred(2)");
+
+ uid = ucred_getruid(creds);
+ gid = ucred_getrgid(creds);
+ ruid = ucred_getruid(creds);
+ rgid = ucred_getrgid(creds);
+ euid = ucred_geteuid(creds);
+ egid = ucred_getegid(creds);
+
+ ucred_free(creds);
+
+#elif defined(HAVE_SO_PEERCRED)
+
+ if (getsockopt(fileno(fptr->f), SOL_SOCKET, SO_PEERCRED, &creds, &len) < 0)
+ rb_sys_fail("getsockopt");
+
+ uid = creds.uid;
+ gid = creds.gid;
+ euid = creds.uid;
+ egid = creds.gid;
+
+#elif defined(HAVE_GETPEEREID)
+ if (getpeereid(fileno(fptr->f), &euid, &egid) < 0)
+ rb_sys_fail("getpeereid");
+
+ uid = euid;
+ gid = egid;
+
+#endif
+
+ if (uid < 0 || gid < 0)
+ rb_raise(rb_eSocket, "Invalid credentials: uid %d, gid %d", uid, gid);
+
+ return rb_struct_new(sSockCred, INT2FIX(uid),
+ INT2FIX(gid),
+ INT2FIX(ruid),
+ INT2FIX(rgid),
+ INT2FIX(euid),
+ INT2FIX(egid),
+ 0);
+}
+
static VALUE
ip_recvfrom(argc, argv, sock)
int argc;
@@ -3864,6 +3967,10 @@
rb_define_method(rb_cBasicSocket, "recv", bsock_recv, -1);
rb_define_method(rb_cBasicSocket, "recv_nonblock", bsock_recv_nonblock, -1);
+ rb_global_variable(&sSockCred);
+ sSockCred = rb_struct_define("SockCred", "uid", "gid", "ruid", "rgid", "euid", "egid", NULL);
+ rb_define_method(rb_cBasicSocket, "peer_cred", unix_peer_cred, 0);
+
rb_cIPSocket = rb_define_class("IPSocket", rb_cBasicSocket);
rb_define_global_const("IPsocket", rb_cIPSocket);
rb_define_method(rb_cIPSocket, "addr", ip_addr, 0);