Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
114e6829
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
114e6829
编写于
7月 20, 2021
作者:
O
openharmony_ci
提交者:
Gitee
7月 20, 2021
浏览文件
操作
浏览文件
下载
差异文件
!340 代码规范整改
Merge pull request !340 from 胡吉翔/security_20210720
上级
befeeda4
588aa762
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
62 addition
and
27 deletion
+62
-27
security_lite/permission_posix/dac/src/ActsDacPreTest.cpp
security_lite/permission_posix/dac/src/ActsDacPreTest.cpp
+62
-27
未找到文件。
security_lite/permission_posix/dac/src/ActsDacPreTest.cpp
浏览文件 @
114e6829
...
...
@@ -29,8 +29,10 @@ using namespace testing::ext;
static
int
TestSetUid
()
{
// Test the 'setuid' interface
int
ret
;
uid_t
ruid
,
euid
,
suid
;
int
ret
=
0
;
uid_t
ruid
=
0
;
uid_t
euid
=
0
;
uid_t
suid
=
0
;
// Step 1: Verify that UID is set to 0
ret
=
setuid
(
UID0
);
if
(
ret
!=
0
)
{
...
...
@@ -85,8 +87,10 @@ static int TestSetUid()
static
int
TestSetREUid
()
{
// Test the 'setreuid' interface
int
ret
;
uid_t
ruid
,
euid
,
suid
;
int
ret
=
0
;
uid_t
ruid
=
0
;
uid_t
euid
=
0
;
uid_t
suid
=
0
;
// Step 1: Verify that UID is set to 0
ret
=
setreuid
(
UID0
,
UID0
);
if
(
ret
!=
0
)
{
...
...
@@ -141,8 +145,10 @@ static int TestSetREUid()
static
int
TestSetRESUid
()
{
// Test the 'setresuid' interface
int
ret
;
uid_t
ruid
,
euid
,
suid
;
int
ret
=
0
;
uid_t
ruid
=
0
;
uid_t
euid
=
0
;
uid_t
suid
=
0
;
// Step 1: Verify that UID is set to 0
ret
=
setresuid
(
UID0
,
UID0
,
UID0
);
if
(
ret
!=
0
)
{
...
...
@@ -197,8 +203,13 @@ static int TestSetRESUid()
static
int
TestSetUidAbnormal
()
{
// Enter the exception parameter when invoke the 'setuid','setreuid','setresuid' interface
int
ret
;
uid_t
newruid
,
neweuid
,
newsuid
,
ruid
,
euid
,
suid
;
int
ret
=
0
;
uid_t
newruid
=
0
;
uid_t
neweuid
=
0
;
uid_t
newsuid
=
0
;
uid_t
ruid
=
0
;
uid_t
euid
=
0
;
uid_t
suid
=
0
;
// Obtain the ruid, euid, suid of the current process
getresuid
(
&
ruid
,
&
euid
,
&
suid
);
// Step 1: Verify that UID is set to -100 with the 'setuid' interface
...
...
@@ -243,8 +254,10 @@ static int TestSetUidAbnormal()
static
int
TestSetGid
()
{
// Test the 'setgid' interface
int
ret
;
gid_t
rgid
,
egid
,
sgid
;
int
ret
=
0
;
gid_t
rgid
=
0
;
gid_t
egid
=
0
;
gid_t
sgid
=
0
;
// Step 1: Verify that GID is set to 0
ret
=
setgid
(
GID0
);
if
(
ret
!=
0
)
{
...
...
@@ -299,8 +312,10 @@ static int TestSetGid()
static
int
TestSetREGid
()
{
// Test the 'setregid' interface
int
ret
;
gid_t
rgid
,
egid
,
sgid
;
int
ret
=
0
;
gid_t
rgid
=
0
;
gid_t
egid
=
0
;
gid_t
sgid
=
0
;
// Step 1: Verify that GID is set to 0
ret
=
setregid
(
GID0
,
GID0
);
if
(
ret
!=
0
)
{
...
...
@@ -355,8 +370,10 @@ static int TestSetREGid()
static
int
TestSetRESGid
()
{
// Test the 'setresgid' interface
int
ret
;
gid_t
rgid
,
egid
,
sgid
;
int
ret
=
0
;
gid_t
rgid
=
0
;
gid_t
egid
=
0
;
gid_t
sgid
=
0
;
// Step 1: Verify that GID is set to 0
ret
=
setresgid
(
GID0
,
GID0
,
GID0
);
if
(
ret
!=
0
)
{
...
...
@@ -411,8 +428,13 @@ static int TestSetRESGid()
static
int
TestSetGidAbnormal
()
{
// Enter the exception parameter when invoke the 'setgid','setregid','setresgid' interface
int
ret
;
gid_t
newrgid
,
newegid
,
newsgid
,
rgid
,
egid
,
sgid
;
int
ret
=
0
;
gid_t
newrgid
=
0
;
gid_t
newegid
=
0
;
gid_t
newsgid
=
0
;
gid_t
rgid
=
0
;
gid_t
egid
=
0
;
gid_t
sgid
=
0
;
// Obtain the rgid, egid, sgid of the current process
getresgid
(
&
rgid
,
&
egid
,
&
sgid
);
// Step 1: Verify that GID is set to -100 with the 'setgid' interface
...
...
@@ -546,8 +568,13 @@ static int ChangeSensitiveInformation()
*/
HWTEST_F
(
DacTestSuite
,
DACTest0010
,
Function
|
MediumTest
|
Level1
)
{
int
ret
;
uid_t
ruid
,
euid
,
suid
,
newruid
,
neweuid
,
newsuid
;
int
ret
=
0
;
uid_t
ruid
=
0
;
uid_t
euid
=
0
;
uid_t
suid
=
0
;
uid_t
newruid
=
0
;
uid_t
neweuid
=
0
;
uid_t
newsuid
=
0
;
// Preset action: Obtain the ruid, euid, suid of the current process
getresuid
(
&
ruid
,
&
euid
,
&
suid
);
// Step 1: Test the 'setuid' interface
...
...
@@ -578,8 +605,13 @@ HWTEST_F(DacTestSuite, DACTest0010, Function | MediumTest | Level1)
*/
HWTEST_F
(
DacTestSuite
,
DACTest0020
,
Function
|
MediumTest
|
Level1
)
{
int
ret
;
gid_t
rgid
,
egid
,
sgid
,
newrgid
,
newegid
,
newsgid
;
int
ret
=
0
;
gid_t
rgid
=
0
;
gid_t
egid
=
0
;
gid_t
sgid
=
0
;
gid_t
newrgid
=
0
;
gid_t
newegid
=
0
;
gid_t
newsgid
=
0
;
// Preset action: Obtain the rgid, egid, sgid of the current process
getresgid
(
&
rgid
,
&
egid
,
&
sgid
);
// Step 1: Test the 'setgid' interface
...
...
@@ -613,7 +645,7 @@ HWTEST_F(DacTestSuite, DACTest0030, Function | MediumTest | Level1)
int
ret
;
gid_t
grouplist
[
SIZE255
];
// Preset action: Obtain the groups of the current process
in
t
groupsize
=
getgroups
(
0
,
grouplist
);
size_
t
groupsize
=
getgroups
(
0
,
grouplist
);
if
(
groupsize
>=
0
)
{
getgroups
(
groupsize
,
grouplist
);
}
else
{
...
...
@@ -648,7 +680,7 @@ HWTEST_F(DacTestSuite, DACTest0040, Function | MediumTest | Level2)
int
ret
;
gid_t
grouplist
[
SIZE255
];
// Preset action: Obtain the groups of the current process
in
t
groupsize
=
getgroups
(
0
,
grouplist
);
size_
t
groupsize
=
getgroups
(
0
,
grouplist
);
if
(
groupsize
>=
0
)
{
getgroups
(
groupsize
,
grouplist
);
}
else
{
...
...
@@ -683,7 +715,7 @@ HWTEST_F(DacTestSuite, DACTest0050, Function | MediumTest | Level3)
int
ret
;
gid_t
grouplist
[
SIZE255
];
// Preset action: Obtain the groups of the current process
in
t
groupsize
=
getgroups
(
0
,
grouplist
);
size_
t
groupsize
=
getgroups
(
0
,
grouplist
);
if
(
groupsize
>=
0
)
{
getgroups
(
groupsize
,
grouplist
);
}
else
{
...
...
@@ -718,7 +750,7 @@ HWTEST_F(DacTestSuite, DACTest0060, Function | MediumTest | Level3)
int
ret
;
gid_t
grouplist
[
SIZE255
];
// Preset action: Obtain the groups of the current process
in
t
groupsize
=
getgroups
(
0
,
grouplist
);
size_
t
groupsize
=
getgroups
(
0
,
grouplist
);
if
(
groupsize
>=
0
)
{
getgroups
(
groupsize
,
grouplist
);
}
else
{
...
...
@@ -818,8 +850,11 @@ HWTEST_F(DacTestSuite, DACTest0070, Security | MediumTest | Level2)
HWTEST_F
(
DacTestSuite
,
DACTest0080
,
Function
|
MediumTest
|
Level2
)
{
int
ret
;
uid_t
ruid
,
euid
,
suid
,
newruid
,
neweuid
,
newsuid
;
gid_t
rgid
,
egid
,
sgid
,
newrgid
,
newegid
,
newsgid
,
grouplist
[
SIZE255
];
uid_t
ruid
=
0
;
uid_t
euid
=
0
;
uid_t
suid
=
0
;
uid_t
newruid
=
0
;
uid_t
neweuid
=
0
;
uid_t
newsuid
=
0
;
gid_t
rgid
=
0
;
gid_t
egid
=
0
;
gid_t
sgid
=
0
;
gid_t
newrgid
=
0
;
gid_t
newegid
=
0
;
gid_t
newsgid
=
0
;
gid_t
grouplist
[
SIZE255
];
// Preset action: Obtain the ruid, euid, suid of the current process
getresuid
(
&
ruid
,
&
euid
,
&
suid
);
// Preset action: Obtain the rgid, egid, sgid of the current process
...
...
@@ -947,4 +982,4 @@ HWTEST_F(DacTestSuite, DACTest0130, Performance | MediumTest | Level2)
SetUidGid
(
UID0
,
GID0
);
setgroups
(
0
,
nullptr
);
}
#endif
\ No newline at end of file
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录