From 2af5e6a5df031ebce1745e403ef0b535773a7361 Mon Sep 17 00:00:00 2001 From: Eric Holk Date: Wed, 9 Jan 2019 18:17:27 -0800 Subject: [view compilation] Add viewcompiler support to installd This change adds methods to installd to call viewcompiler and generate precompiled layouts when requested either by `pm compile --compile-layouts`, package install, or package upgrade. Bug: 111895153 Test: manual Change-Id: Ic021d7a41c15642664f44542653170ad24055f22 --- cmds/installd/utils.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'cmds/installd/utils.cpp') diff --git a/cmds/installd/utils.cpp b/cmds/installd/utils.cpp index 74ad1841a5..bbf14cb5f7 100644 --- a/cmds/installd/utils.cpp +++ b/cmds/installd/utils.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -34,6 +35,7 @@ #include #include +#include "dexopt_return_codes.h" #include "globals.h" // extern variables. #ifndef LOG_TAG @@ -1063,5 +1065,26 @@ bool collect_profiles(std::vector* profiles_paths) { } } +void drop_capabilities(uid_t uid) { + if (setgid(uid) != 0) { + PLOG(ERROR) << "setgid(" << uid << ") failed in installd during dexopt"; + exit(DexoptReturnCodes::kSetGid); + } + if (setuid(uid) != 0) { + PLOG(ERROR) << "setuid(" << uid << ") failed in installd during dexopt"; + exit(DexoptReturnCodes::kSetUid); + } + // drop capabilities + struct __user_cap_header_struct capheader; + struct __user_cap_data_struct capdata[2]; + memset(&capheader, 0, sizeof(capheader)); + memset(&capdata, 0, sizeof(capdata)); + capheader.version = _LINUX_CAPABILITY_VERSION_3; + if (capset(&capheader, &capdata[0]) < 0) { + PLOG(ERROR) << "capset failed"; + exit(DexoptReturnCodes::kCapSet); + } +} + } // namespace installd } // namespace android -- cgit v1.2.3-59-g8ed1b