mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22256 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e52da91987
commit
7a01268aeb
4 changed files with 25 additions and 0 deletions
|
@ -392,6 +392,16 @@ bsock_getpeereid(VALUE self)
|
|||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue