提交 e4ec3363 编写于 作者: X xionglei6

fix:fix param bug

Signed-off-by: Nxionglei6 <xionglei6@huawei.com>
上级 3135a696
......@@ -91,6 +91,7 @@ static char *GetRealParameter(BShellHandle shell, const char *name, char *buffer
} else {
realLen = sprintf_s(buffer, buffSize, "%s", name);
}
BSH_CHECK(realLen >= 0, return NULL, "Failed to format buffer");
buffer[realLen] = '\0';
BSH_LOGV("GetRealParameter current %s input %s real %s", current, name, buffer);
return buffer;
......@@ -158,7 +159,7 @@ static void ShowParam(BShellHandle shell, const char *name, const char *value)
BSH_LOGE("Failed to get param security for %s", name);
return;
}
char permissionStr[MASK_LENGTH_MAX] = {'-', '-', '-', 0};
char permissionStr[3][MASK_LENGTH_MAX] = {}; // 3 permission
struct passwd *user = getpwuid(auditData.dacData.uid);
struct group *group = getgrgid(auditData.dacData.gid);
if (user == NULL || group == NULL) {
......@@ -167,9 +168,9 @@ static void ShowParam(BShellHandle shell, const char *name, const char *value)
}
BShellEnvOutput(shell, "Parameter infomation:\r\n");
BShellEnvOutput(shell, " dac : %s(%s) %s(%s) (%s) \r\n",
user->pw_name, GetPermissionString(auditData.dacData.mode, 0, permissionStr, MASK_LENGTH_MAX),
group->gr_name, GetPermissionString(auditData.dacData.mode, DAC_GROUP_START, permissionStr, MASK_LENGTH_MAX),
GetPermissionString(auditData.dacData.mode, DAC_OTHER_START, permissionStr, MASK_LENGTH_MAX));
user->pw_name, GetPermissionString(auditData.dacData.mode, 0, permissionStr[0], MASK_LENGTH_MAX),
group->gr_name, GetPermissionString(auditData.dacData.mode, DAC_GROUP_START, permissionStr[1], MASK_LENGTH_MAX),
GetPermissionString(auditData.dacData.mode, DAC_OTHER_START, permissionStr[2], MASK_LENGTH_MAX)); // 2 other
BShellEnvOutput(shell, " name : %s\r\n", name);
if (value != NULL) {
BShellEnvOutput(shell, " value: %s\r\n", value);
......
......@@ -23,6 +23,7 @@ logd:x:1036:
shared_relro:x:1037:
audioserver:x:1041:
cameraserver:x:1047:
servicectrl:x:1050:root,shell,system,samgr,hdf_devmgr
shell:x:2000:
cache:x:2001:
net_bw_stats:x:3006:
......
......@@ -253,10 +253,10 @@ static int CheckParamPermission(const ParamSecurityLabel *srcLabel, const ParamA
if ((auditData->dacData.mode & localMode) != 0) {
ret = DAC_RESULT_PERMISSION;
}
PARAM_LOGV("Src label gid:%d uid:%d ", srcLabel->cred.gid, srcLabel->cred.uid);
PARAM_LOGV("local label gid:%d uid:%d mode %o",
PARAM_LOGI("Src label gid:%d uid:%d ", srcLabel->cred.gid, srcLabel->cred.uid);
PARAM_LOGI("local label gid:%d uid:%d mode %o",
auditData->dacData.gid, auditData->dacData.uid, auditData->dacData.mode);
PARAM_LOGV("%s check %o localMode %o ret %d", auditData->name, mode, localMode, ret);
PARAM_LOGI("%s check %o localMode %o ret %d", auditData->name, mode, localMode, ret);
return ret;
#endif
}
......
......@@ -304,6 +304,7 @@ int CheckParamPermission(const ParamWorkSpace *workSpace,
if (mode == DAC_WRITE) {
int ret = CheckParamPermissionWithSelinux(srcLabel, name, mode);
if (ret == DAC_RESULT_PERMISSION) {
PARAM_LOGI("CheckParamPermission %s", name);
return DAC_RESULT_PERMISSION;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册