OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ipc/ipc_channel_posix.h" | 5 #include "ipc/ipc_channel_posix.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 #include <sys/types.h> | 10 #include <sys/types.h> |
11 #include <sys/socket.h> | 11 #include <sys/socket.h> |
12 #include <sys/stat.h> | 12 #include <sys/stat.h> |
13 #include <sys/un.h> | 13 #include <sys/un.h> |
14 | 14 |
| 15 #if defined(OS_OPENBSD) |
| 16 #include <sys/uio.h> |
| 17 #endif |
| 18 |
15 #include <string> | 19 #include <string> |
16 #include <map> | 20 #include <map> |
17 | 21 |
18 #include "base/command_line.h" | 22 #include "base/command_line.h" |
19 #include "base/eintr_wrapper.h" | 23 #include "base/eintr_wrapper.h" |
20 #include "base/file_path.h" | 24 #include "base/file_path.h" |
21 #include "base/file_util.h" | 25 #include "base/file_util.h" |
22 #include "base/global_descriptors_posix.h" | 26 #include "base/global_descriptors_posix.h" |
23 #include "base/location.h" | 27 #include "base/location.h" |
24 #include "base/logging.h" | 28 #include "base/logging.h" |
(...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
937 bool Channel::ChannelImpl::AcceptsConnections() const { | 941 bool Channel::ChannelImpl::AcceptsConnections() const { |
938 return server_listen_pipe_ != -1; | 942 return server_listen_pipe_ != -1; |
939 } | 943 } |
940 | 944 |
941 bool Channel::ChannelImpl::HasAcceptedConnection() const { | 945 bool Channel::ChannelImpl::HasAcceptedConnection() const { |
942 return AcceptsConnections() && pipe_ != -1; | 946 return AcceptsConnections() && pipe_ != -1; |
943 } | 947 } |
944 | 948 |
945 bool Channel::ChannelImpl::GetClientEuid(uid_t* client_euid) const { | 949 bool Channel::ChannelImpl::GetClientEuid(uid_t* client_euid) const { |
946 DCHECK(HasAcceptedConnection()); | 950 DCHECK(HasAcceptedConnection()); |
947 #if defined(OS_MACOSX) | 951 #if defined(OS_MACOSX) || defined(OS_OPENBSD) |
948 uid_t peer_euid; | 952 uid_t peer_euid; |
949 gid_t peer_gid; | 953 gid_t peer_gid; |
950 if (getpeereid(pipe_, &peer_euid, &peer_gid) != 0) { | 954 if (getpeereid(pipe_, &peer_euid, &peer_gid) != 0) { |
951 PLOG(ERROR) << "getpeereid " << pipe_; | 955 PLOG(ERROR) << "getpeereid " << pipe_; |
952 return false; | 956 return false; |
953 } | 957 } |
954 *client_euid = peer_euid; | 958 *client_euid = peer_euid; |
955 return true; | 959 return true; |
956 #elif defined(OS_SOLARIS) | 960 #elif defined(OS_SOLARIS) |
957 return false; | 961 return false; |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1247 } | 1251 } |
1248 | 1252 |
1249 #if defined(OS_LINUX) | 1253 #if defined(OS_LINUX) |
1250 // static | 1254 // static |
1251 void Channel::SetGlobalPid(int pid) { | 1255 void Channel::SetGlobalPid(int pid) { |
1252 ChannelImpl::SetGlobalPid(pid); | 1256 ChannelImpl::SetGlobalPid(pid); |
1253 } | 1257 } |
1254 #endif // OS_LINUX | 1258 #endif // OS_LINUX |
1255 | 1259 |
1256 } // namespace IPC | 1260 } // namespace IPC |
OLD | NEW |