Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/socket/unix_domain_client_socket_posix.h" | 5 #include "net/socket/unix_domain_client_socket_posix.h" |
| 6 | 6 |
| 7 #include <unistd.h> | 7 #include <unistd.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/files/scoped_temp_dir.h" | 11 #include "base/files/scoped_temp_dir.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "net/base/io_buffer.h" | 13 #include "net/base/io_buffer.h" |
| 14 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
| 15 #include "net/base/test_completion_callback.h" | 15 #include "net/base/test_completion_callback.h" |
| 16 #include "net/socket/unix_domain_server_socket_posix.h" | 16 #include "net/socket/unix_domain_server_socket_posix.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 18 |
| 19 namespace net { | 19 namespace net { |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 const char kSocketFilename[] = "socket_for_testing"; | 22 const char kSocketFilename[] = "socket_for_testing"; |
| 23 | 23 |
| 24 bool UserCanConnectCallback(bool allow_user, uid_t uid, gid_t gid) { | 24 bool UserCanConnectCallback(bool allow_user, |
| 25 const UnixDomainServerSocket::Credentials& credentials) { | |
|
byungchul
2014/08/04 22:18:02
wrong indentation
SeRya
2014/08/05 10:32:27
Done.
| |
| 25 // Here peers are running in same process. | 26 // Here peers are running in same process. |
| 26 EXPECT_EQ(getuid(), uid); | 27 #if defined(OS_LINUX) || defined(OS_ANDROID) |
| 27 EXPECT_EQ(getgid(), gid); | 28 EXPECT_EQ(getpid(), credentials.process_id); |
| 29 #endif | |
| 30 EXPECT_EQ(getuid(), credentials.user_id); | |
| 31 EXPECT_EQ(getgid(), credentials.group_id); | |
| 28 return allow_user; | 32 return allow_user; |
| 29 } | 33 } |
| 30 | 34 |
| 31 UnixDomainServerSocket::AuthCallback CreateAuthCallback(bool allow_user) { | 35 UnixDomainServerSocket::AuthCallback CreateAuthCallback(bool allow_user) { |
| 32 return base::Bind(&UserCanConnectCallback, allow_user); | 36 return base::Bind(&UserCanConnectCallback, allow_user); |
| 33 } | 37 } |
| 34 | 38 |
| 35 // Connects socket synchronously. | 39 // Connects socket synchronously. |
| 36 int ConnectSynchronously(StreamSocket* socket) { | 40 int ConnectSynchronously(StreamSocket* socket) { |
| 37 TestCompletionCallback connect_callback; | 41 TestCompletionCallback connect_callback; |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 388 0)); | 392 0)); |
| 389 | 393 |
| 390 // Disconnect from server side after read-write. | 394 // Disconnect from server side after read-write. |
| 391 accepted_socket->Disconnect(); | 395 accepted_socket->Disconnect(); |
| 392 EXPECT_FALSE(accepted_socket->IsConnected()); | 396 EXPECT_FALSE(accepted_socket->IsConnected()); |
| 393 EXPECT_FALSE(client_socket.IsConnected()); | 397 EXPECT_FALSE(client_socket.IsConnected()); |
| 394 } | 398 } |
| 395 | 399 |
| 396 } // namespace | 400 } // namespace |
| 397 } // namespace net | 401 } // namespace net |
| OLD | NEW |