sync newsandbox code and fix bug

Signed-off-by: nianyuu <zhouwenqiang12@huawei.com>
This commit is contained in:
nianyuu 2024-09-02 14:12:20 +08:00
parent a2b75df2b8
commit 0fb782578e
5 changed files with 13 additions and 8 deletions

View File

@ -114,6 +114,10 @@
"target-name" : "/system/lib",
"link-name" : "/lib",
"check-action-status": "false"
}, {
"target-name" : "/system/lib64",
"link-name" : "/lib64",
"check-action-status": "false"
}, {
"target-name" : "/system/etc",
"link-name" : "/etc",
@ -278,7 +282,7 @@
}, {
"name": "ohos.permission.PROTECT_SCREEN_LOCK_DATA",
"sandbox-switch": "ON",
"mount-group": ["el5"]
"mount-groups": ["el5"]
}, {
"name": "ohos.permission.ACCESS_FILE_CONTENT_SHARE",
"sandbox-switch": "ON",

View File

@ -16,8 +16,6 @@
#ifndef APPSPAWN_SANDBOX_H
#define APPSPAWN_SANDBOX_H
#include <limits.h>
#include "appspawn.h"
#include "appspawn_hook.h"
#include "appspawn_manager.h"

View File

@ -22,8 +22,9 @@
void MakeAtomicServiceDir(const SandboxContext *context, const char *path)
{
struct stat st = {};
if (stat(path, &st) == 0 && S_ISDIR(st.st_mode)) {
APPSPAWN_CHECK_ONLY_EXPER(context != NULL && path != NULL, return);
if (access(path, F_OK) == 0) {
APPSPAWN_LOGV("path %{public}s already exist, no need to recreate", path);
return;
}
int ret = mkdir(path, S_IRWXU);
@ -64,5 +65,4 @@ void MakeAtomicServiceDir(const SandboxContext *context, const char *path)
ret = chown(path, dacInfo->uid, DecodeGid("log"));
}
APPSPAWN_CHECK(ret == 0, return, "chown %{public}s failed, errno %{public}d", path, errno);
return;
}

View File

@ -161,7 +161,7 @@ APPSPAWN_STATIC int ReplaceVariableForDepPath(const SandboxContext *context,
static int ReplaceVariableForpackageName(const SandboxContext *context,
const char *buffer, uint32_t bufferLen, uint32_t *realLen, const VarExtraData *extraData)
{
APPSPAWN_CHECK(context != NULL, return -1, "Invalid extra data");
APPSPAWN_CHECK(context != NULL, return -1, "Invalid context");
AppSpawnMsgBundleInfo *bundleInfo = (AppSpawnMsgBundleInfo *)GetSpawningMsgInfo(context, TLV_BUNDLE_INFO);
APPSPAWN_CHECK(bundleInfo != NULL, return APPSPAWN_TLV_NONE,
"No bundle info in msg %{public}s", context->bundleName);
@ -199,6 +199,7 @@ static int ReplaceVariableForpackageName(const SandboxContext *context,
}
case SANDBOX_PACKAGENAME_ATOMIC_SERVICE: { // 4 +auid-<accountId>+packageName
char *accountId = (char *)GetAppSpawnMsgExtInfo(context->message, MSG_EXT_NAME_ACCOUNT_ID, NULL);
APPSPAWN_CHECK(accountId != NULL, return -1, "Invalid accountId data");
len = sprintf_s((char *)buffer, bufferLen, "+auid-%s+%s", accountId, bundleInfo->bundleName);
break;
}

View File

@ -666,7 +666,9 @@ APPSPAWN_STATIC const char *GetSandboxNameByMode(RunMode mode)
if (mode == MODE_FOR_NATIVE_SPAWN) {
return ISOLATED_SANDBOX_FILE_NAME;
}
if (mode == MODE_FOR_NWEB_SPAWN || mode == MODE_FOR_NWEB_COLD_RUN) {
return WEB_SANDBOX_FILE_NAME;
}
return APP_SANDBOX_FILE_NAME;
}