aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com>2024-03-11 17:45:30 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2024-03-11 17:45:30 +0000
commita21f7a625a0673175190b141ed8d04806db26504 (patch)
tree0f327873ad47040f41958130dd321f61a9f75b43
parent5e80f31967e4fee8a84f91470237cc0c85e9cdeb (diff)
parent92d60ac2ecc15c326e9fe25af35c5f86a70c20ad (diff)
downloadadb-a21f7a625a0673175190b141ed8d04806db26504.tar.gz
Merge "adb: Do not use fs_config unless we are root." into main
-rw-r--r--daemon/file_sync_service.cpp15
1 files changed, 5 insertions, 10 deletions
diff --git a/daemon/file_sync_service.cpp b/daemon/file_sync_service.cpp
index 5891d30e..a549beee 100644
--- a/daemon/file_sync_service.cpp
+++ b/daemon/file_sync_service.cpp
@@ -68,14 +68,9 @@ using android::base::Dirname;
using android::base::Realpath;
using android::base::StringPrintf;
-static bool should_use_fs_config(const std::string& path) {
-#if defined(__ANDROID__)
- // TODO: use fs_config to configure permissions on /data too.
- return !android::base::StartsWith(path, "/data/");
-#else
- UNUSED(path);
- return false;
-#endif
+static bool should_use_fs_config() {
+ // Only root has the necessary permissions to be able to apply fs_config.
+ return getuid() == 0;
}
static bool update_capabilities(const char* path, uint64_t capabilities) {
@@ -119,7 +114,7 @@ static bool secure_mkdirs(const std::string& path) {
}
partial_path += path_component;
- if (should_use_fs_config(partial_path)) {
+ if (should_use_fs_config()) {
adbd_fs_config(partial_path.c_str(), 1, nullptr, &uid, &gid, &mode, &capabilities);
}
if (adb_mkdir(partial_path.c_str(), mode) == -1) {
@@ -530,7 +525,7 @@ static bool send_impl(int s, const std::string& path, mode_t mode, CompressionTy
uid_t uid = -1;
gid_t gid = -1;
uint64_t capabilities = 0;
- if (should_use_fs_config(path) && !dry_run) {
+ if (should_use_fs_config() && !dry_run) {
adbd_fs_config(path.c_str(), 0, nullptr, &uid, &gid, &mode, &capabilities);
}