Revert "adb: Do not use fs_config unless we are root (try 2)."

Revert submission 3001420-main-Ied805bc3912ea0b4e1691127b5032aef632f85fd

Reason for revert: DroidMonitor: Potential culprit for Bug 331999499 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted.

Reverted changes: /q/submissionid:3001420-main-Ied805bc3912ea0b4e1691127b5032aef632f85fd

Change-Id: Ibe525a6fd6c01b1f58c67c086306607c4f4d20db
diff --git a/libcutils/fs_config.cpp b/libcutils/fs_config.cpp
index 756ff8e..919be2f 100644
--- a/libcutils/fs_config.cpp
+++ b/libcutils/fs_config.cpp
@@ -91,7 +91,7 @@
     { 00751, AID_ROOT,         AID_SHELL,        0, "vendor/bin" },
     { 00751, AID_ROOT,         AID_SHELL,        0, "vendor/apex/*/bin" },
     { 00755, AID_ROOT,         AID_SHELL,        0, "vendor" },
-    {},
+    { 00755, AID_ROOT,         AID_ROOT,         0, 0 },
         // clang-format on
 };
 #ifndef __ANDROID_VNDK__
@@ -228,7 +228,7 @@
     { 00755, AID_ROOT,      AID_SHELL,     0, "vendor/bin/*" },
     { 00755, AID_ROOT,      AID_SHELL,     0, "vendor/apex/*bin/*" },
     { 00755, AID_ROOT,      AID_SHELL,     0, "vendor/xbin/*" },
-    {},
+    { 00644, AID_ROOT,      AID_ROOT,      0, 0 },
         // clang-format on
 };
 #ifndef __ANDROID_VNDK__
@@ -318,8 +318,8 @@
 auto __for_testing_only__fs_config_cmp = fs_config_cmp;
 #endif
 
-bool get_fs_config(const char* path, bool dir, const char* target_out_path,
-                   struct fs_config* fs_conf) {
+void fs_config(const char* path, int dir, const char* target_out_path, unsigned* uid, unsigned* gid,
+               unsigned* mode, uint64_t* capabilities) {
     const struct fs_path_config* pc;
     size_t which, plen;
 
@@ -362,11 +362,11 @@
             if (fs_config_cmp(dir, prefix, len, path, plen)) {
                 free(prefix);
                 close(fd);
-                fs_conf->uid = header.uid;
-                fs_conf->gid = header.gid;
-                fs_conf->mode = header.mode;
-                fs_conf->capabilities = header.capabilities;
-                return true;
+                *uid = header.uid;
+                *gid = header.gid;
+                *mode = (*mode & (~07777)) | header.mode;
+                *capabilities = header.capabilities;
+                return;
             }
             free(prefix);
         }
@@ -375,28 +375,11 @@
 
     for (pc = dir ? android_dirs : android_files; pc->prefix; pc++) {
         if (fs_config_cmp(dir, pc->prefix, strlen(pc->prefix), path, plen)) {
-            fs_conf->uid = pc->uid;
-            fs_conf->gid = pc->gid;
-            fs_conf->mode = pc->mode;
-            fs_conf->capabilities = pc->capabilities;
-            return true;
+            break;
         }
     }
-    return false;
-}
-
-void fs_config(const char* path, int dir, const char* target_out_path, unsigned* uid, unsigned* gid,
-               unsigned* mode, uint64_t* capabilities) {
-    struct fs_config conf;
-    if (get_fs_config(path, dir, target_out_path, &conf)) {
-        *uid = conf.uid;
-        *gid = conf.gid;
-        *mode = (*mode & S_IFMT) | conf.mode;
-        *capabilities = conf.capabilities;
-    } else {
-        *uid = AID_ROOT;
-        *gid = AID_ROOT;
-        *mode = (*mode & S_IFMT) | (dir ? 0755 : 0644);
-        *capabilities = 0;
-    }
+    *uid = pc->uid;
+    *gid = pc->gid;
+    *mode = (*mode & (~07777)) | pc->mode;
+    *capabilities = pc->capabilities;
 }