!557 修改接口入参

Merge pull request !557 from 万欣/master
This commit is contained in:
openharmony_ci 2023-03-27 03:36:29 +00:00 committed by Gitee
commit f8701cff99
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 22 additions and 4 deletions

View File

@ -40,7 +40,11 @@ void SetSelinuxCon(struct AppSpawnContent_ *content, AppSpawnClient *client)
UNUSED(content);
AppSpawnClientExt *appProperty = reinterpret_cast<AppSpawnClientExt *>(client);
HapContext hapContext;
int32_t ret = hapContext.HapDomainSetcontext(appProperty->property.apl, appProperty->property.processName);
HapDomainInfo hapDomainInfo;
hapDomainInfo.apl = appProperty->property.apl;
hapDomainInfo.packageName = appProperty->property.processName;
hapDomainInfo.hapFlags = appProperty->property.hapFlags;
int32_t ret = hapContext.HapDomainSetcontext(hapDomainInfo);
if (ret != 0) {
APPSPAWN_LOGE("AppSpawnServer::Failed to hap domain set context, errno = %d %s",
errno, appProperty->property.apl);

View File

@ -94,6 +94,7 @@ typedef struct AppParameter_ {
int32_t bundleIndex;
AppOperateType code;
uint64_t accessTokenIdEx;
int32_t hapFlags;
#ifndef OHOS_LITE
uint8_t setAllowInternet;
uint8_t allowInternet; // hap sockect allowed

View File

@ -37,7 +37,7 @@
HapContextStub::HapContextStub() {}
HapContextStub::~HapContextStub() {}
static int g_testHapDomainSetcontext = 0;
int HapContextStub::HapDomainSetcontext(const std::string &apl, const std::string &packageName)
int HapContextStub::HapDomainSetcontext(HapDomainInfo& hapDomainInfo)
{
if (g_testHapDomainSetcontext == 0) {
return 0;

View File

@ -18,11 +18,17 @@
#include <iostream>
struct HapDomainInfo {
std::string apl;
std::string packageName;
unsigned int hapFlags = 1;
};
class HapContextStub {
public:
HapContextStub();
~HapContextStub();
int HapDomainSetcontext(const std::string &apl, const std::string &packageName);
int HapDomainSetcontext(HapDomainInfo& hapDomainInfo);
};
#ifdef __cplusplus
extern "C" {

View File

@ -436,7 +436,13 @@ static void SetSelinuxCondition(const std::string &srcPath, const ClientSocket::
#ifndef APPSPAWN_TEST
#ifdef WITH_SELINUX
HapContext hapContext;
hapContext.HapFileRestorecon(srcPath, appProperty->apl, appProperty->bundleName, SELINUX_HAP_RESTORECON_RECURSE);
HapFileInfo hapFileInfo;
hapFileInfo.pathNameOrig.emplace_back(srcPath);
hapFileInfo.apl = appProperty->apl;
hapFileInfo.packageName = appProperty->bundleName;
hapFileInfo.flags = SELINUX_HAP_RESTORECON_RECURSE;
hapFileInfo.hapFlags = appProperty->hapFlags;
hapContext.HapFileRestorecon(hapFileInfo);
#endif
#endif
}
@ -445,6 +451,7 @@ static void SetSelinuxCondition(const std::string &srcPath, const ClientSocket::
void SandboxUtils::CheckAndPrepareSrcPath(const ClientSocket::AppProperty *appProperty, const std::string &srcPath)
{
if (access(srcPath.c_str(), F_OK) == 0) {
SetSelinuxCondition(srcPath, appProperty);
return;
}