diff --git a/ChangeLog b/ChangeLog index 335f56005d..fff9e65c6b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Fri Sep 10 02:15:29 2010 Tanaka Akira + + * 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 * 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 }