Home | History | Annotate | Download | only in android
      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
      3 // found in the LICENSE file.
      4 
      5 #include "content/public/browser/android/devtools_auth.h"
      6 
      7 #include "base/logging.h"
      8 
      9 namespace content {
     10 
     11 bool CanUserConnectToDevTools(uid_t uid, gid_t gid) {
     12   struct passwd* creds = getpwuid(uid);
     13   if (!creds || !creds->pw_name) {
     14     LOG(WARNING) << "DevTools: can't obtain creds for uid " << uid;
     15     return false;
     16   }
     17   if (gid == uid &&
     18       (strcmp("root", creds->pw_name) == 0 ||  // For rooted devices
     19        strcmp("shell", creds->pw_name) == 0)) {  // For non-rooted devices
     20     return true;
     21   }
     22   LOG(WARNING) << "DevTools: connection attempt from " << creds->pw_name;
     23   return false;
     24 }
     25 
     26 }  // namespace content
     27