1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

add a test.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22125 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2009-02-08 11:30:26 +00:00
parent aa28707309
commit 732b695163

View file

@ -296,4 +296,22 @@ class TestUNIXSocket < Test::Unit::TestCase
} }
end end
def test_linux_cred
return if /linux/ !~ RUBY_PLATFORM
Dir.mktmpdir {|d|
sockpath = "#{d}/sock"
serv = Socket.unix_server_socket(sockpath)
c = Socket.unix(sockpath)
s, = serv.accept
s.setsockopt(:SOCKET, :PASSCRED, 1)
c.print "a"
msg, cliend_ai, rflags, cred = s.recvmsg
p cred
assert_equal("a", msg)
assert_match(/pid=#{$$} /, cred.inspect)
assert_match(/uid=#{Process.uid} /, cred.inspect)
assert_match(/gid=#{Process.gid}>/, cred.inspect)
}
end
end if defined?(UNIXSocket) && /cygwin/ !~ RUBY_PLATFORM end if defined?(UNIXSocket) && /cygwin/ !~ RUBY_PLATFORM