diff --git a/services/BUILD.gn b/services/BUILD.gn index 7acdac00ddefc6c38e742957737514fe70dbabf1..2785568c29491057173c910903728a94096c7d07 100755 --- a/services/BUILD.gn +++ b/services/BUILD.gn @@ -46,10 +46,12 @@ executable("appspawn") { "${aafwk_lite_path}/interfaces/innerkits/abilitymgr_lite", "//third_party/bounds_checking_function/include/", "//third_party/cJSON", + "//base/security/access_token/interfaces/innerkits/token_setproc/include", ] deps = [ "${aafwk_lite_path}/frameworks/ability_lite:aafwk_abilitykit_lite", + "//base/security/access_token/interfaces/innerkits/token_setproc:libtoken_setproc", "//build/lite/config/component/cJSON:cjson_shared", "//foundation/communication/ipc_lite:liteipc_adapter", "//foundation/distributedschedule/samgr_lite/samgr:samgr", diff --git a/services/include/appspawn_message.h b/services/include/appspawn_message.h index 1b64942e5ec9f4f243e2a8f156675b837d8e15a8..e45a1154a04ca2e5a0838969e4536c48046e3b63 100644 --- a/services/include/appspawn_message.h +++ b/services/include/appspawn_message.h @@ -15,6 +15,8 @@ #ifndef BASE_STARTUP_APPSPAWN_MESSAGE_H #define BASE_STARTUP_APPSPAWN_MESSAGE_H +#include + #ifdef __cplusplus #if __cplusplus extern "C" { @@ -28,6 +30,7 @@ typedef struct { int gID; unsigned int* caps; unsigned int capsCnt; + uint32_t tokenId; } MessageSt; int SplitMessage(const char* msg, unsigned int msgLen, MessageSt* msgSt); @@ -40,4 +43,4 @@ void FreeMessageSt(MessageSt* targetSt); #endif #endif -#endif // BASE_STARTUP_APPSPAWN_SERVICE_H \ No newline at end of file +#endif // BASE_STARTUP_APPSPAWN_SERVICE_H diff --git a/services/src/appspawn_process.c b/services/src/appspawn_process.c index 70cb0c2c1d9cbe549ec4d8f5a75bce1979c35c6a..aec39fdc8411d764778a8e804782d03b6540897a 100755 --- a/services/src/appspawn_process.c +++ b/services/src/appspawn_process.c @@ -28,6 +28,7 @@ #include "appspawn_adapter.h" #include "log.h" #include "securec.h" +#include "token_setproc.h" #ifdef __LINUX__ #include @@ -149,6 +150,10 @@ pid_t CreateProcess(const MessageSt* msgSt) } #endif // OHOS_DEBUG + int ret = SetSelfTokenID(msgSt->tokenId); + if (ret != 0) { + HILOG_ERROR(HILOG_MODULE_HIVIEW, "[appspawn] Failed to set access token id"); + } // set permissions if (SetPerms(msgSt->uID, msgSt->gID, msgSt->capsCnt, msgSt->caps) != 0) { HILOG_ERROR(HILOG_MODULE_HIVIEW, "[appspawn] sub-process %{public}s exit!", msgSt->bundleName);