Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Side by Side Diff: remoting/host/gnubby_auth_handler_posix.cc

Issue 382143005: Supports DevTools socket access authentication based on Android permissions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Commented process_id Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/socket/unix_domain_server_socket_posix_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "remoting/host/gnubby_auth_handler_posix.h" 5 #include "remoting/host/gnubby_auth_handler_posix.h"
6 6
7 #include <unistd.h> 7 #include <unistd.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 bool operator()(const std::pair<int, GnubbySocket*> element) const { 46 bool operator()(const std::pair<int, GnubbySocket*> element) const {
47 return element.second->IsSocket(socket_); 47 return element.second->IsSocket(socket_);
48 } 48 }
49 49
50 private: 50 private:
51 net::StreamListenSocket* socket_; 51 net::StreamListenSocket* socket_;
52 }; 52 };
53 53
54 // Socket authentication function that only allows connections from callers with 54 // Socket authentication function that only allows connections from callers with
55 // the current uid. 55 // the current uid.
56 bool MatchUid(uid_t user_id, gid_t) { 56 bool MatchUid(const net::UnixDomainServerSocket::Credentials& credentials) {
57 bool allowed = user_id == getuid(); 57 bool allowed = credentials.user_id == getuid();
58 if (!allowed) 58 if (!allowed)
59 HOST_LOG << "Refused socket connection from uid " << user_id; 59 HOST_LOG << "Refused socket connection from uid " << credentials.user_id;
60 return allowed; 60 return allowed;
61 } 61 }
62 62
63 // Returns the command code (the first byte of the data) if it exists, or -1 if 63 // Returns the command code (the first byte of the data) if it exists, or -1 if
64 // the data is empty. 64 // the data is empty.
65 unsigned int GetCommandCode(const std::string& data) { 65 unsigned int GetCommandCode(const std::string& data) {
66 return data.empty() ? -1 : static_cast<unsigned int>(data[0]); 66 return data.empty() ? -1 : static_cast<unsigned int>(data[0]);
67 } 67 }
68 68
69 // Creates a string of byte data from a ListValue of numbers. Returns true if 69 // Creates a string of byte data from a ListValue of numbers. Returns true if
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 } 298 }
299 299
300 void GnubbyAuthHandlerPosix::RequestTimedOut(int connection_id) { 300 void GnubbyAuthHandlerPosix::RequestTimedOut(int connection_id) {
301 HOST_LOG << "Gnubby request timed out"; 301 HOST_LOG << "Gnubby request timed out";
302 ActiveSockets::iterator iter = active_sockets_.find(connection_id); 302 ActiveSockets::iterator iter = active_sockets_.find(connection_id);
303 if (iter != active_sockets_.end()) 303 if (iter != active_sockets_.end())
304 SendErrorAndCloseActiveSocket(iter); 304 SendErrorAndCloseActiveSocket(iter);
305 } 305 }
306 306
307 } // namespace remoting 307 } // namespace remoting
OLDNEW
« no previous file with comments | « net/socket/unix_domain_server_socket_posix_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698