Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Kernel Liteos A
提交
206f8186
K
Kernel Liteos A
项目概览
OpenHarmony
/
Kernel Liteos A
1 年多 前同步成功
通知
464
Star
414
Fork
55
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
4
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel Liteos A
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
4
Issue
4
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
206f8186
编写于
4月 30, 2021
作者:
O
openharmony_ci
提交者:
Gitee
4月 30, 2021
浏览文件
操作
浏览文件
下载
差异文件
!210 补充Dac的ReadAndSearch用例
Merge pull request !210 from 野生毛霉君/master
上级
2fb1f0e7
e64e1e72
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
64 addition
and
4 deletion
+64
-4
testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_Dac_001.cpp
testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_Dac_001.cpp
+64
-4
未找到文件。
testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_Dac_001.cpp
浏览文件 @
206f8186
...
...
@@ -371,6 +371,58 @@ static int TestAccess(const char *path)
return
0
;
}
static
int
SetReadAndSearch
()
{
int
capNum
=
2
;
struct
__user_cap_header_struct
capheader
;
struct
__user_cap_data_struct
capdata
[
capNum
];
int
ret
;
memset
(
&
capheader
,
0
,
sizeof
(
struct
__user_cap_header_struct
));
memset
(
capdata
,
0
,
capNum
*
sizeof
(
struct
__user_cap_data_struct
));
capdata
[
0
].
permitted
=
0xffffffff
;
capdata
[
1
].
permitted
=
0xffffffff
;
capheader
.
version
=
_LINUX_CAPABILITY_VERSION_3
;
capdata
[
CAP_TO_INDEX
(
CAP_SETPCAP
)].
effective
|=
CAP_TO_MASK
(
CAP_SETPCAP
);
capdata
[
CAP_TO_INDEX
(
CAP_SETUID
)].
effective
|=
CAP_TO_MASK
(
CAP_SETUID
);
capdata
[
CAP_TO_INDEX
(
CAP_SETGID
)].
effective
|=
CAP_TO_MASK
(
CAP_SETGID
);
capdata
[
CAP_TO_INDEX
(
CAP_CHOWN
)].
effective
|=
CAP_TO_MASK
(
CAP_CHOWN
);
capdata
[
CAP_TO_INDEX
(
CAP_DAC_READ_SEARCH
)].
effective
|=
CAP_TO_MASK
(
CAP_DAC_READ_SEARCH
);
ret
=
capset
(
&
capheader
,
&
capdata
[
0
]);
ICUNIT_ASSERT_EQUAL
(
ret
,
0
,
ret
);
return
0
;
}
static
int
TestCapReadSearch
()
{
int
ret
;
char
filenameParent
[
64
]
=
{
0
};
char
filenameChild
[
64
]
=
{
0
};
ret
=
setuid
(
0
);
ICUNIT_ASSERT_EQUAL
(
ret
,
0
,
ret
);
ret
=
setgid
(
0
);
ICUNIT_ASSERT_EQUAL
(
ret
,
0
,
ret
);
ret
=
mkdir
(
"/storage/test_jffs2"
,
0757
);
// mode 0757
ICUNIT_ASSERT_EQUAL
(
ret
,
0
,
ret
);
sprintf
(
filenameParent
,
"%s/%s"
,
"/storage/test_jffs2"
,
"testParent"
);
sprintf
(
filenameChild
,
"%s/%s"
,
filenameParent
,
"testChild"
);
ret
=
mkdir
(
filenameParent
,
0222
);
// mode 0222
ICUNIT_ASSERT_EQUAL
(
ret
,
0
,
ret
);
SetReadAndSearch
();
ret
=
mkdir
(
filenameChild
,
0777
);
// mode 0777
ICUNIT_ASSERT_NOT_EQUAL
(
ret
,
0
,
ret
);
ret
=
rmdir
(
filenameParent
);
ICUNIT_ASSERT_EQUAL
(
ret
,
0
,
ret
);
ret
=
rmdir
(
"/storage/test_jffs2"
);
ICUNIT_ASSERT_EQUAL
(
ret
,
0
,
ret
);
return
0
;
}
/* execve */
/* access */
...
...
@@ -433,9 +485,6 @@ static int ChildFunc(VOID)
ret
=
setgid
(
2
);
// gid: 2
ICUNIT_ASSERT_EQUAL
(
ret
,
0
,
ret
);
capdata
[
0
].
effective
=
0xffffffff
;
capdata
[
1
].
effective
=
0xffffffff
;
(
void
)
capset
(
&
capheader
,
capdata
);
return
0
;
}
...
...
@@ -444,13 +493,24 @@ static int testcase(VOID)
int
ret
;
int
status
=
0
;
pid_t
pid
=
fork
();
ICUNIT_GOTO_WITHIN_EQUAL
(
pid
,
0
,
100000
,
pid
,
EXIT
);
ICUNIT_GOTO_WITHIN_EQUAL
(
pid
,
0
,
100000
,
pid
,
EXIT
);
// pid must in range 0 - 100000
if
(
pid
==
0
)
{
ret
=
ChildFunc
();
printf
(
"err line :%d error code: %d
\n
"
,
0
,
0
);
exit
(
0
);
}
ret
=
waitpid
(
pid
,
&
status
,
0
);
ICUNIT_GOTO_EQUAL
(
ret
,
pid
,
ret
,
EXIT
);
pid
=
fork
();
ICUNIT_GOTO_WITHIN_EQUAL
(
pid
,
0
,
100000
,
pid
,
EXIT
);
// pid must in range 0 - 100000
if
(
pid
==
0
)
{
ret
=
TestCapReadSearch
();
printf
(
"err line :%d error code: %d
\n
"
,
0
,
0
);
exit
(
0
);
}
ret
=
waitpid
(
pid
,
&
status
,
0
);
ICUNIT_GOTO_EQUAL
(
ret
,
pid
,
ret
,
EXIT
);
status
=
WEXITSTATUS
(
status
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录