From 9e457481438cf8b4dbe033b6fbd5ea612c4529c1 Mon Sep 17 00:00:00 2001 From: akr Date: Sun, 8 Feb 2009 15:37:55 +0000 Subject: * ext/socket/extconf.rb: check sys/param.h and sys/ucred.h. * ext/socket/rubysocket.h: include sys/param.h and sys/ucred.h. * ext/socket/option.c (inspect_local_peercred): new function to show LOCAL_PEERCRED socket option on FreeBSD. (sockopt_inspect): show as LOCAL_* socket option if AF_UNIX and level is 0. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22137 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/socket/test_unix.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test/socket') diff --git a/test/socket/test_unix.rb b/test/socket/test_unix.rb index d05fd15a95..6799e52fd1 100644 --- a/test/socket/test_unix.rb +++ b/test/socket/test_unix.rb @@ -312,6 +312,20 @@ class TestUNIXSocket < Test::Unit::TestCase } end + def test_getcred_xucred + return if /freebsd/ !~ RUBY_PLATFORM + Dir.mktmpdir {|d| + sockpath = "#{d}/sock" + serv = Socket.unix_server_socket(sockpath) + c = Socket.unix(sockpath) + s, = serv.accept + cred = s.getsockopt(0, Socket::LOCAL_PEERCRED) + inspect = cred.inspect + assert_match(/ uid=#{Process.uid} /, inspect) + assert_match(/ \(xucred\)/, inspect) + } + end + def test_sendcred_ucred return if /linux/ !~ RUBY_PLATFORM Dir.mktmpdir {|d| -- cgit v1.2.3