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