diff --git a/BUILD.gn b/BUILD.gn index d0e4d285e6305573c2ec2e587a4a91c2c4dc434f..a4d518248f337b9eb3a690a1c2260e2fb2136fc9 100755 --- a/BUILD.gn +++ b/BUILD.gn @@ -39,7 +39,11 @@ config("appspawn_config") { ohos_executable("appspawn") { sources = [ "${appspawn_path}/src/main.cpp" ] configs = [ ":appspawn_config" ] - deps = [ "${appspawn_path}:appspawn_server" ] + include_dirs = [ "//base/security/access_token/interfaces/innerkits/token_setproc/include" ] + deps = [ + "${appspawn_path}:appspawn_server", + "//base/security/access_token/interfaces/innerkits/token_setproc:libtoken_setproc", + ] external_deps = [ "hiviewdfx_hilog_native:libhilog" ] install_enable = true diff --git a/interfaces/innerkits/include/client_socket.h b/interfaces/innerkits/include/client_socket.h index 2706a7c31bef2a7a6b966492e579eb6ffaa405cf..aeaa79f8267a191adca2955909e02f6b9dfb88da 100644 --- a/interfaces/innerkits/include/client_socket.h +++ b/interfaces/innerkits/include/client_socket.h @@ -95,6 +95,7 @@ public: uint32_t gidCount; // the size of gidTable char processName[LEN_PROC_NAME]; // process name char soPath[LEN_SO_PATH]; // so lib path + uint32_t tokenId; }; private: diff --git a/src/appspawn_server.cpp b/src/appspawn_server.cpp index 38ccf1e4f6302be67dfb68f9007080e5288a5ac7..92f5aa249d322b14c6cdbd62ef61eae5c701c258 100644 --- a/src/appspawn_server.cpp +++ b/src/appspawn_server.cpp @@ -27,6 +27,7 @@ #include "hilog/log.h" #include "main_thread.h" #include "securec.h" +#include "token_setproc.h" #include #include @@ -426,6 +427,11 @@ bool AppSpawnServer::SetAppProcProperty(int connectFd, const ClientSocket::AppPr return false; } + ret = SetSelfTokenID(appProperty->tokenId); + if (ret != 0) { + HiLog::Error(LABEL, "AppSpawnServer::Failed to set access token id, errno = %{public}d", errno); + } + #ifdef GRAPHIC_PERMISSION_CHECK ret = SetUidGid(appProperty->uid, appProperty->gid, appProperty->gidTable, appProperty->gidCount); if (FAILED(ret)) {