From 0adc09721fa130bd1246e6dbee3da9ad9bd176b8 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Tue, 25 Aug 2015 13:14:07 -0700 Subject: [PATCH] Move adb's selinux_android_restorecon up and check for failures. Change-Id: Ib3ff282cf52df03f3b9a0abecf0abda99d7df641 --- adb/file_sync_service.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/adb/file_sync_service.cpp b/adb/file_sync_service.cpp index 214cead1d..6ca8ba1e3 100644 --- a/adb/file_sync_service.cpp +++ b/adb/file_sync_service.cpp @@ -166,9 +166,14 @@ static bool handle_send_file(int s, const char* path, uid_t uid, goto fail; } - // fchown clears the setuid bit - restore it if present. - // Ignore the result of calling fchmod. It's not supported - // by all filesystems. b/12441485 + if (selinux_android_restorecon(path, 0) == -1) { + SendSyncFailErrno(s, "selinux_android_restorecon failed"); + goto fail; + } + + // fchown clears the setuid bit - restore it if present. + // Ignore the result of calling fchmod. It's not supported + // by all filesystems. b/12441485 fchmod(fd, mode); } @@ -201,8 +206,6 @@ static bool handle_send_file(int s, const char* path, uid_t uid, adb_close(fd); - selinux_android_restorecon(path, 0); - utimbuf u; u.actime = timestamp; u.modtime = timestamp;