diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-09-09 17:19:52 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-09-09 17:19:52 +0000 |
commit | a75a46710232c09f172523b90756a0e0f79e4811 (patch) | |
tree | 969dded8f2b878f1bac306bfbafe43fb850a60df | |
parent | 83a827ac9be0249471b23ee56980bc33a542a0fa (diff) | |
download | ruby-a75a46710232c09f172523b90756a0e0f79e4811.tar.gz |
* ext/socket/option.c (inspect_peercred): support OpenBSD-current.
patch by Jeremy Evans. [ruby-core:32240]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29206 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | ext/socket/option.c | 15 |
2 files changed, 15 insertions, 5 deletions
@@ -1,3 +1,8 @@ +Fri Sep 10 02:15:29 2010 Tanaka Akira <akr@fsij.org> + + * ext/socket/option.c (inspect_peercred): support OpenBSD-current. + patch by Jeremy Evans. [ruby-core:32240] + Thu Sep 9 23:25:53 2010 Nobuyoshi Nakada <nobu@ruby-lang.org> * vm.c (vm_backtrace_each): skip allocator frames which have no diff --git a/ext/socket/option.c b/ext/socket/option.c index 63bffb9f68..6d437dbcc8 100644 --- a/ext/socket/option.c +++ b/ext/socket/option.c @@ -396,13 +396,18 @@ inspect_timeval_as_interval(int level, int optname, VALUE data, VALUE ret) } } -#if defined(SOL_SOCKET) && defined(SO_PEERCRED) /* GNU/Linux */ +#if defined(SOL_SOCKET) && defined(SO_PEERCRED) /* GNU/Linux, OpenBSD */ +#if defined(__OpenBSD__) +#define RUBY_SOCK_PEERCRED struct sockpeercred +#else +#define RUBY_SOCK_PEERCRED struct ucred +#endif static int inspect_peercred(int level, int optname, VALUE data, VALUE ret) { - if (RSTRING_LEN(data) == sizeof(struct ucred)) { - struct ucred cred; - memcpy(&cred, RSTRING_PTR(data), sizeof(struct ucred)); + if (RSTRING_LEN(data) == sizeof(RUBY_SOCK_PEERCRED)) { + RUBY_SOCK_PEERCRED cred; + memcpy(&cred, RSTRING_PTR(data), sizeof(RUBY_SOCK_PEERCRED)); rb_str_catf(ret, " pid=%u euid=%u egid=%u", (unsigned)cred.pid, (unsigned)cred.uid, (unsigned)cred.gid); rb_str_cat2(ret, " (ucred)"); @@ -569,7 +574,7 @@ sockopt_inspect(VALUE self) # if defined(SO_SNDTIMEO) /* POSIX */ case SO_SNDTIMEO: inspected = inspect_timeval_as_interval(level, optname, data, ret); break; # endif -# if defined(SO_PEERCRED) /* GNU/Linux */ +# if defined(SO_PEERCRED) /* GNU/Linux, OpenBSD */ case SO_PEERCRED: inspected = inspect_peercred(level, optname, data, ret); break; # endif } |