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

Side by Side Diff: content/browser/android/devtools_auth.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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/public/browser/android/devtools_auth.h" 5 #include "content/public/browser/android/devtools_auth.h"
6 6
7 #include <pwd.h>
8 #include <sys/types.h>
7 #include <unistd.h> 9 #include <unistd.h>
8 #include <sys/types.h>
9 10
10 #include "base/logging.h" 11 #include "base/logging.h"
11 12
12 namespace content { 13 namespace content {
13 14
14 bool CanUserConnectToDevTools(uid_t uid, gid_t gid) { 15 bool CanUserConnectToDevTools(
15 struct passwd* creds = getpwuid(uid); 16 const net::UnixDomainServerSocket::Credentials& credentials) {
17 struct passwd* creds = getpwuid(credentials.user_id);
16 if (!creds || !creds->pw_name) { 18 if (!creds || !creds->pw_name) {
17 LOG(WARNING) << "DevTools: can't obtain creds for uid " << uid; 19 LOG(WARNING) << "DevTools: can't obtain creds for uid "
20 << credentials.user_id;
18 return false; 21 return false;
19 } 22 }
20 if (gid == uid && 23 if (credentials.group_id == credentials.user_id &&
21 (strcmp("root", creds->pw_name) == 0 || // For rooted devices 24 (strcmp("root", creds->pw_name) == 0 || // For rooted devices
22 strcmp("shell", creds->pw_name) == 0 || // For non-rooted devices 25 strcmp("shell", creds->pw_name) == 0 || // For non-rooted devices
23 uid == getuid())) { // From processes signed with the same key 26
27 // From processes signed with the same key
28 credentials.user_id == getuid())) {
24 return true; 29 return true;
25 } 30 }
26 LOG(WARNING) << "DevTools: connection attempt from " << creds->pw_name; 31 LOG(WARNING) << "DevTools: connection attempt from " << creds->pw_name;
27 return false; 32 return false;
28 } 33 }
29 34
30 } // namespace content 35 } // namespace content
OLDNEW
« no previous file with comments | « chrome/browser/android/dev_tools_server.cc ('k') | content/public/browser/android/devtools_auth.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698