summaryrefslogtreecommitdiff
path: root/ext/socket/basicsocket.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/socket/basicsocket.c')
-rw-r--r--ext/socket/basicsocket.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/ext/socket/basicsocket.c b/ext/socket/basicsocket.c
index b818ffa..fd74930 100644
--- a/ext/socket/basicsocket.c
+++ b/ext/socket/basicsocket.c
@@ -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