From d0515e71652910c3a46f5cea8be75c0cf9132556 Mon Sep 17 00:00:00 2001 From: Jin Qian Date: Wed, 2 Nov 2016 16:27:17 -0700 Subject: [PATCH] Set file capabilities after writing file data File capabilities will be cleared if we set them before writing file data. Bug: 32543395 Change-Id: I88cc0a0ec23cd6fc6dbe86c93a76914809d7e5f9 --- adb/file_sync_service.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/adb/file_sync_service.cpp b/adb/file_sync_service.cpp index 837902a0a..7a92d2ee4 100644 --- a/adb/file_sync_service.cpp +++ b/adb/file_sync_service.cpp @@ -198,11 +198,6 @@ static bool handle_send_file(int s, const char* path, uid_t uid, gid_t gid, uint // Ignore the result of calling fchmod. It's not supported // by all filesystems, so we don't check for success. b/12441485 fchmod(fd, mode); - - if (!update_capabilities(path, capabilities)) { - SendSyncFailErrno(s, "update_capabilities failed"); - goto fail; - } } while (true) { @@ -232,6 +227,11 @@ static bool handle_send_file(int s, const char* path, uid_t uid, gid_t gid, uint adb_close(fd); + if (!update_capabilities(path, capabilities)) { + SendSyncFailErrno(s, "update_capabilities failed"); + goto fail; + } + utimbuf u; u.actime = timestamp; u.modtime = timestamp;