From 3903bcddb0aa35a747f0c77f9f824f4126f3a2db Mon Sep 17 00:00:00 2001 From: xionglei6 Date: Fri, 14 Jan 2022 18:35:49 +0800 Subject: [PATCH 1/5] =?UTF-8?q?add:=20=E6=96=B0=E5=A2=9E=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?access=20token=20id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xionglei6 --- services/BUILD.gn | 2 ++ services/include/appspawn_message.h | 3 ++- services/src/appspawn_process.c | 5 +++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/services/BUILD.gn b/services/BUILD.gn index 7acdac0..b9928ac 100755 --- a/services/BUILD.gn +++ b/services/BUILD.gn @@ -46,6 +46,7 @@ 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 = [ @@ -55,6 +56,7 @@ executable("appspawn") { "//foundation/distributedschedule/samgr_lite/samgr:samgr", "//third_party/bounds_checking_function:libsec_shared", "//utils/native/lite/kv_store:kv_store", + "//base/security/access_token/interfaces/innerkits/token_setproc:libtoken_setproc", ] if (enable_ohos_appexecfwk_feature_ability == true) { diff --git a/services/include/appspawn_message.h b/services/include/appspawn_message.h index 1b64942..8c506a1 100644 --- a/services/include/appspawn_message.h +++ b/services/include/appspawn_message.h @@ -28,6 +28,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 +41,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 70cb0c2..7c1c464 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(appProperty->accessTokenId); + 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); -- Gitee From 885d47fe847e0ab1a338a53519d155e182276d52 Mon Sep 17 00:00:00 2001 From: xionglei6 Date: Fri, 14 Jan 2022 18:56:32 +0800 Subject: [PATCH 2/5] =?UTF-8?q?add:=20=E6=96=B0=E5=A2=9E=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?access=20token=20id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xionglei6 --- services/include/appspawn_message.h | 4 +++- services/src/appspawn_process.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/services/include/appspawn_message.h b/services/include/appspawn_message.h index 8c506a1..48961c3 100644 --- a/services/include/appspawn_message.h +++ b/services/include/appspawn_message.h @@ -13,7 +13,9 @@ * limitations under the License. */ #ifndef BASE_STARTUP_APPSPAWN_MESSAGE_H -#define BASE_STARTUP_APPSPAWN_MESSAGE_H +#define BASE_STARTUPi_APPSPAWN_MESSAGE_H + +#include #ifdef __cplusplus #if __cplusplus diff --git a/services/src/appspawn_process.c b/services/src/appspawn_process.c index 7c1c464..54ca4db 100755 --- a/services/src/appspawn_process.c +++ b/services/src/appspawn_process.c @@ -151,7 +151,7 @@ pid_t CreateProcess(const MessageSt* msgSt) #endif // OHOS_DEBUG int ret = SetSelfTokenID(appProperty->accessTokenId); - if(ret != 0) { + if (ret != 0) { HILOG_ERROR(HILOG_MODULE_HIVIEW, "[appspawn] Failed to set access token id"); } // set permissions -- Gitee From 13b20c28dcfb377f25a8a3b49146509cc59c0a65 Mon Sep 17 00:00:00 2001 From: xionglei6 Date: Fri, 14 Jan 2022 19:47:29 +0800 Subject: [PATCH 3/5] =?UTF-8?q?add:=20=E6=96=B0=E5=A2=9E=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?access=20token=20id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xionglei6 --- services/include/appspawn_message.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/include/appspawn_message.h b/services/include/appspawn_message.h index 48961c3..e45a115 100644 --- a/services/include/appspawn_message.h +++ b/services/include/appspawn_message.h @@ -13,7 +13,7 @@ * limitations under the License. */ #ifndef BASE_STARTUP_APPSPAWN_MESSAGE_H -#define BASE_STARTUPi_APPSPAWN_MESSAGE_H +#define BASE_STARTUP_APPSPAWN_MESSAGE_H #include -- Gitee From f9d1afc872568e8e21cb43d4e56b2bfb1c7827bf Mon Sep 17 00:00:00 2001 From: xionglei6 Date: Fri, 14 Jan 2022 20:11:54 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=AE=BE=E7=BD=AEaccess?= =?UTF-8?q?=20token=20id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xionglei6 --- services/src/appspawn_process.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/src/appspawn_process.c b/services/src/appspawn_process.c index 54ca4db..aec39fd 100755 --- a/services/src/appspawn_process.c +++ b/services/src/appspawn_process.c @@ -150,7 +150,7 @@ pid_t CreateProcess(const MessageSt* msgSt) } #endif // OHOS_DEBUG - int ret = SetSelfTokenID(appProperty->accessTokenId); + int ret = SetSelfTokenID(msgSt->tokenId); if (ret != 0) { HILOG_ERROR(HILOG_MODULE_HIVIEW, "[appspawn] Failed to set access token id"); } -- Gitee From 340a228b457dca2510add32d0fa4269aadbbac77 Mon Sep 17 00:00:00 2001 From: xionglei6 Date: Mon, 17 Jan 2022 11:30:08 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9BUILD.gn=20format?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xionglei6 --- services/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/BUILD.gn b/services/BUILD.gn index b9928ac..2785568 100755 --- a/services/BUILD.gn +++ b/services/BUILD.gn @@ -51,12 +51,12 @@ executable("appspawn") { 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", "//third_party/bounds_checking_function:libsec_shared", "//utils/native/lite/kv_store:kv_store", - "//base/security/access_token/interfaces/innerkits/token_setproc:libtoken_setproc", ] if (enable_ohos_appexecfwk_feature_ability == true) { -- Gitee