ruby-changes:10693
From: akr <ko1@a...>
Date: Thu, 12 Feb 2009 21:43:18 +0900 (JST)
Subject: [ruby-changes:10693] Ruby:r22256 (trunk): * ext/socket/basicsocket.c (bsock_getpeereid): implemented for Solaris
akr 2009-02-12 21:43:04 +0900 (Thu, 12 Feb 2009) New Revision: 22256 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=22256 Log: * ext/socket/basicsocket.c (bsock_getpeereid): implemented for Solaris using getpeerucred. * ext/socket/extconf.rb: check ucred.h and getpeerucred. * ext/socket/rubysocket.h: include ucred.h if available. Modified files: trunk/ChangeLog trunk/ext/socket/basicsocket.c trunk/ext/socket/extconf.rb trunk/ext/socket/rubysocket.h Index: ChangeLog =================================================================== --- ChangeLog (revision 22255) +++ ChangeLog (revision 22256) @@ -1,3 +1,12 @@ +Thu Feb 12 12:36:35 2009 Tanaka Akira <akr@f...> + + * ext/socket/basicsocket.c (bsock_getpeereid): implemented for Solaris + using getpeerucred. + + * ext/socket/extconf.rb: check ucred.h and getpeerucred. + + * ext/socket/rubysocket.h: include ucred.h if available. + Thu Feb 12 19:42:33 2009 Nobuyoshi Nakada <nobu@r...> * compile.c (compile_array_, defined_expr, iseq_compile_each): hide Index: ext/socket/rubysocket.h =================================================================== --- ext/socket/rubysocket.h (revision 22255) +++ ext/socket/rubysocket.h (revision 22256) @@ -79,6 +79,9 @@ #ifdef HAVE_SYS_UCRED_H #include <sys/ucred.h> #endif +#ifdef HAVE_UCRED_H +#include <ucred.h> +#endif #ifndef EWOULDBLOCK #define EWOULDBLOCK EAGAIN Index: ext/socket/extconf.rb =================================================================== --- ext/socket/extconf.rb (revision 22255) +++ ext/socket/extconf.rb (revision 22256) @@ -316,6 +316,9 @@ have_func("getpeereid") +have_header("ucred.h", headers) +have_func("getpeerucred") + $distcleanfiles << "constants.h" << "constdefs.*" if have_func(test_func) Index: ext/socket/basicsocket.c =================================================================== --- ext/socket/basicsocket.c (revision 22255) +++ ext/socket/basicsocket.c (revision 22256) @@ -392,6 +392,16 @@ if (getsockopt(fptr->fd, SOL_SOCKET, SO_PEERCRED, &cred, &len) == -1) rb_sys_fail("getsockopt(SO_PEERCRED)"); return rb_assoc_new(UIDT2NUM(cred.uid), GIDT2NUM(cred.gid)); +#elif defined(HAVE_GETPEERUCRED) /* Solaris */ + rb_io_t *fptr; + ucred_t *uc = NULL; + VALUE ret; + GetOpenFile(self, fptr); + if (getpeerucred(fptr->fd, &uc) == -1) + rb_sys_fail("getpeerucred"); + ret = rb_assoc_new(UIDT2NUM(ucred_geteuid(uc)), GIDT2NUM(ucred_getegid(uc))); + ucred_free(uc); + return ret; #else rb_notimplement(); #endif -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/