diff --git a/adapter/appspawn_adapter.cpp b/adapter/appspawn_adapter.cpp index 64e8240bcc9e6d1dd9fe24ac38f43563d10e19f7..382ed49fa57131cf022fad3791fcd5fb3f11238b 100644 --- a/adapter/appspawn_adapter.cpp +++ b/adapter/appspawn_adapter.cpp @@ -29,10 +29,14 @@ void SetAppAccessToken(struct AppSpawnContent_ *content, AppSpawnClient *client) int32_t ret = SetSelfTokenID(appProperty->property.accessTokenId); APPSPAWN_LOGI("AppSpawnServer::set access token id = %d, ret = %d %d", appProperty->property.accessTokenId, ret, getuid()); +} +void SetSelinuxCon(struct AppSpawnContent_ *content, AppSpawnClient *client) +{ #ifdef WITH_SELINUX + AppSpawnClientExt *appProperty = (AppSpawnClientExt *)client; HapContext hapContext; - ret = hapContext.HapDomainSetcontext(appProperty->property.apl, appProperty->property.processName); + int32_t ret = hapContext.HapDomainSetcontext(appProperty->property.apl, appProperty->property.processName); if (ret != 0) { APPSPAWN_LOGE("AppSpawnServer::Failed to hap domain set context, errno = %d %s", errno, appProperty->property.apl); diff --git a/adapter/appspawn_adapter.h b/adapter/appspawn_adapter.h index bf0928d4a9f03db36d5cb544a8126362f81d3119..88dcba3b32eaec0b5b11080d9b128da5cad656f1 100644 --- a/adapter/appspawn_adapter.h +++ b/adapter/appspawn_adapter.h @@ -26,6 +26,7 @@ extern "C" { int32_t SetAppSandboxProperty(struct AppSpawnContent_ *content, AppSpawnClient *client); void SetAppAccessToken(struct AppSpawnContent_ *content, AppSpawnClient *client); +void SetSelinuxCon(struct AppSpawnContent_ *content, AppSpawnClient *client); void LoadExtendLib(AppSpawnContent *content); void RunChildProcessor(AppSpawnContent *content, AppSpawnClient *client); int GetRenderProcessTerminationStatus(int32_t pid, int *status); diff --git a/standard/appspawn_process.c b/standard/appspawn_process.c index 14786bf50045f8920671a0aa6d5966adf838f27b..26a26ff020a0c39ccab19cd720c89691b5cad162 100644 --- a/standard/appspawn_process.c +++ b/standard/appspawn_process.c @@ -117,6 +117,7 @@ static int SetCapabilities(struct AppSpawnContent_ *content, AppSpawnClient *cli // set capabilities isRet = capset(&cap_header, &cap_data[0]) == -1; APPSPAWN_CHECK(!isRet, return -errno, "capset failed: %d", errno); + SetSelinuxCon(content, client); return 0; }