summaryrefslogtreecommitdiff
path: root/test/socket/test_unix.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/socket/test_unix.rb')
-rw-r--r--test/socket/test_unix.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/socket/test_unix.rb b/test/socket/test_unix.rb
index 0ea7f5f5be..e783faff3b 100644
--- a/test/socket/test_unix.rb
+++ b/test/socket/test_unix.rb
@@ -296,4 +296,22 @@ class TestUNIXSocket < Test::Unit::TestCase
}
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