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:
parent
aa28707309
commit
732b695163
1 changed files with 18 additions and 0 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue