mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
ce6e093734
commit
9e45748143
6 changed files with 93 additions and 12 deletions
|
@ -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|
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue