OLD | NEW |
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 <unistd.h> | 7 #include <unistd.h> |
8 #include <sys/types.h> | 8 #include <sys/types.h> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 | 11 |
12 namespace content { | 12 namespace content { |
13 | 13 |
14 bool CanUserConnectToDevTools(uid_t uid, gid_t gid) { | 14 bool CanUserConnectToDevTools(pid_t, uid_t uid, gid_t gid) { |
15 struct passwd* creds = getpwuid(uid); | 15 struct passwd* creds = getpwuid(uid); |
16 if (!creds || !creds->pw_name) { | 16 if (!creds || !creds->pw_name) { |
17 LOG(WARNING) << "DevTools: can't obtain creds for uid " << uid; | 17 LOG(WARNING) << "DevTools: can't obtain creds for uid " << uid; |
18 return false; | 18 return false; |
19 } | 19 } |
20 if (gid == uid && | 20 if (gid == uid && |
21 (strcmp("root", creds->pw_name) == 0 || // For rooted devices | 21 (strcmp("root", creds->pw_name) == 0 || // For rooted devices |
22 strcmp("shell", creds->pw_name) == 0 || // For non-rooted devices | 22 strcmp("shell", creds->pw_name) == 0 || // For non-rooted devices |
23 uid == getuid())) { // From processes signed with the same key | 23 uid == getuid())) { // From processes signed with the same key |
24 return true; | 24 return true; |
25 } | 25 } |
26 LOG(WARNING) << "DevTools: connection attempt from " << creds->pw_name; | 26 LOG(WARNING) << "DevTools: connection attempt from " << creds->pw_name; |
27 return false; | 27 return false; |
28 } | 28 } |
29 | 29 |
30 } // namespace content | 30 } // namespace content |
OLD | NEW |