Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
a5f9e492
S
Startup Init Lite
项目概览
OpenHarmony
/
Startup Init Lite
1 年多 前同步成功
通知
3
Star
37
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Startup Init Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a5f9e492
编写于
5月 05, 2022
作者:
M
Mupceet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: day error
Signed-off-by:
N
Mupceet
<
laiguizhong@huawei.com
>
上级
dee73b9f
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
26 addition
and
28 deletion
+26
-28
begetd.gni
begetd.gni
+1
-0
services/begetctl/BUILD.gn
services/begetctl/BUILD.gn
+6
-1
services/init/lite/bundle.json
services/init/lite/bundle.json
+1
-1
services/init/lite/init.c
services/init/lite/init.c
+2
-0
services/param/adapter/param_selinux.c
services/param/adapter/param_selinux.c
+3
-15
services/param/include/param_manager.h
services/param/include/param_manager.h
+1
-1
services/param/include/param_security.h
services/param/include/param_security.h
+1
-1
services/param/manager/param_manager.c
services/param/manager/param_manager.c
+9
-6
test/unittest/param/param_stub.cpp
test/unittest/param/param_stub.cpp
+2
-3
未找到文件。
begetd.gni
浏览文件 @
a5f9e492
...
...
@@ -15,6 +15,7 @@ declare_args() {
param_feature_watcher = true
param_feature_deviceinfo = false
param_test = true
param_begetctl_liteos_support = false
enable_ohos_startup_init_lite_use_thirdparty_mbedtls = true
enable_ohos_startup_init_lite_use_posix_file_api = false
config_ohos_startup_init_lite_data_path = ""
...
...
services/begetctl/BUILD.gn
浏览文件 @
a5f9e492
...
...
@@ -10,6 +10,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//base/startup/init_lite/begetd.gni")
if (defined(ohos_lite)) {
executable("begetctl") {
...
...
@@ -44,8 +45,12 @@ if (defined(ohos_lite)) {
"//third_party/bounds_checking_function:libsec_static",
]
}
group("begetctl_cmd") {
if (param_begetctl_liteos_support) {
deps = [ ":begetctl" ]
}
}
} else {
import("//base/startup/init_lite/begetd.gni")
import("//build/ohos.gni")
ohos_executable("begetctl") {
...
...
services/init/lite/bundle.json
浏览文件 @
a5f9e492
...
...
@@ -31,7 +31,7 @@
"sub_component"
:
[
"//base/startup/init_lite/interfaces/innerkits:libbegetutil"
,
"//base/startup/init_lite/services:init_lite"
,
"//base/startup/init_lite/services/begetctl:begetctl"
,
"//base/startup/init_lite/services/begetctl:begetctl
_cmd
"
,
"//base/startup/init_lite/watchdog:watchdog"
,
"//base/startup/init_lite/ueventd:ueventd"
],
...
...
services/init/lite/init.c
浏览文件 @
a5f9e492
...
...
@@ -53,6 +53,7 @@ void SystemPrepare(void)
void
SystemConfig
(
void
)
{
InitServiceSpace
();
#ifdef LITEOS_SUPPORT_PARAM
InitParamService
();
// parse parameters
LoadDefaultParams
(
"/system/etc/param/ohos_const"
,
LOAD_PARAM_NORMAL
);
...
...
@@ -60,6 +61,7 @@ void SystemConfig(void)
LoadDefaultParams
(
"/system/etc/param"
,
LOAD_PARAM_ONLY_ADD
);
LoadPersistParams
();
#endif
// read config
ReadConfig
();
...
...
services/param/adapter/param_selinux.c
浏览文件 @
a5f9e492
...
...
@@ -54,7 +54,7 @@ static int InitLocalSecurityLabel(ParamSecurityLabel *security, int isInit)
PARAM_CHECK
(
g_selinuxSpace
.
getParamList
!=
NULL
,
return
-
1
,
"Failed to dlsym getParamList %s"
,
dlerror
());
}
if
(
g_selinuxSpace
.
getParamLabel
==
NULL
)
{
g_selinuxSpace
.
getParamLabel
=
(
int
(
*
)(
const
char
*
,
char
*
*
))
dlsym
(
handle
,
"GetParamLabel"
);
g_selinuxSpace
.
getParamLabel
=
(
const
char
*
(
*
)(
const
char
*
))
dlsym
(
handle
,
"GetParamLabel"
);
PARAM_CHECK
(
g_selinuxSpace
.
getParamLabel
!=
NULL
,
return
-
1
,
"Failed to dlsym getParamLabel %s"
,
dlerror
());
}
if
(
g_selinuxSpace
.
readParamCheck
==
NULL
)
{
...
...
@@ -151,26 +151,14 @@ int RegisterSecuritySelinuxOps(ParamSecurityOps *ops, int isInit)
return
ret
;
}
const
char
*
GetSelinuxContent
(
const
char
*
name
,
char
*
buffer
,
uint32_t
size
)
const
char
*
GetSelinuxContent
(
const
char
*
name
)
{
PARAM_CHECK
(
g_selinuxSpace
.
getParamLabel
!=
NULL
,
return
NULL
,
"Invalid getParamLabel"
);
PARAM_CHECK
(
g_selinuxSpace
.
setSelinuxLogCallback
!=
NULL
,
return
NULL
,
"Invalid setSelinuxLogCallback"
);
// log
g_selinuxSpace
.
setSelinuxLogCallback
();
char
*
label
=
NULL
;
int
ret
=
g_selinuxSpace
.
getParamLabel
(
name
,
&
label
);
if
(
ret
==
0
&&
label
!=
NULL
)
{
if
(
strcpy_s
(
buffer
,
size
,
label
)
==
0
)
{
free
(
label
);
PARAM_LOGV
(
"GetSelinuxContent name %s label %s"
,
name
,
buffer
);
return
buffer
;
}
free
(
label
);
}
PARAM_LOGE
(
"Failed to get content for name %s ret %d"
,
name
,
ret
);
strcpy_s
(
buffer
,
size
,
WORKSPACE_NAME_DEF_SELINUX
);
return
buffer
;
return
g_selinuxSpace
.
getParamLabel
(
name
);
}
#if defined STARTUP_INIT_TEST || defined LOCAL_TEST
...
...
services/param/include/param_manager.h
浏览文件 @
a5f9e492
...
...
@@ -110,7 +110,7 @@ typedef struct {
char
*
prefix
;
}
ParamTraversalContext
;
const
char
*
GetSelinuxContent
(
const
char
*
name
,
char
*
buffer
,
uint32_t
size
);
const
char
*
GetSelinuxContent
(
const
char
*
name
);
int
LoadParamFromCmdLine
(
void
);
void
LoadSelinuxLabel
(
void
);
...
...
services/param/include/param_security.h
浏览文件 @
a5f9e492
...
...
@@ -108,7 +108,7 @@ typedef struct SelinuxSpace_ {
void
*
selinuxHandle
;
void
(
*
setSelinuxLogCallback
)();
int
(
*
setParamCheck
)(
const
char
*
paraName
,
struct
ucred
*
uc
);
int
(
*
getParamLabel
)(
const
char
*
paraName
,
char
**
context
);
const
char
*
(
*
getParamLabel
)(
const
char
*
paraName
);
int
(
*
readParamCheck
)(
const
char
*
paraName
);
ParamContextsList
*
(
*
getParamList
)();
void
(
*
destroyParamList
)(
ParamContextsList
**
list
);
...
...
services/param/manager/param_manager.c
浏览文件 @
a5f9e492
...
...
@@ -543,9 +543,9 @@ int CheckParamPermission(const ParamSecurityLabel *srcLabel, const char *name, u
}
#ifdef PARAM_SUPPORT_SELINUX
if
(
ret
==
DAC_RESULT_PERMISSION
&&
mode
!=
DAC_WRITE
)
{
// open workspace for client read
c
har
content
[
SELINUX_CONTENT_LEN
]
=
{
0
}
;
if
(
GetSelinuxContent
(
name
,
content
,
sizeof
(
content
))
!=
NULL
)
{
AddWorkSpace
(
content
,
1
,
PARAM_WORKSPACE_DEF
);
c
onst
char
*
label
=
GetSelinuxContent
(
name
)
;
if
(
label
!=
NULL
)
{
AddWorkSpace
(
label
,
1
,
PARAM_WORKSPACE_DEF
);
}
else
{
ret
=
DAC_RESULT_FORBIDED
;
}
...
...
@@ -678,9 +678,8 @@ WorkSpace *GetWorkSpace(const char *name)
#ifndef PARAM_SUPPORT_SELINUX
tmpName
=
WORKSPACE_NAME_NORMAL
;
#else
char
content
[
SELINUX_CONTENT_LEN
]
=
{
0
};
if
(
strcmp
(
name
,
WORKSPACE_NAME_DAC
)
!=
0
)
{
tmpName
=
(
char
*
)
GetSelinuxContent
(
name
,
content
,
sizeof
(
content
)
);
tmpName
=
(
char
*
)
GetSelinuxContent
(
name
);
}
#endif
WorkSpace
*
space
=
NULL
;
...
...
@@ -833,7 +832,11 @@ int GetParamSecurityAuditData(const char *name, int type, ParamAuditData *auditD
auditData
->
dacData
.
gid
=
node
->
gid
;
auditData
->
dacData
.
mode
=
node
->
mode
;
#ifdef PARAM_SUPPORT_SELINUX
GetSelinuxContent
(
name
,
auditData
->
label
,
sizeof
(
auditData
->
label
));
const
char
*
tmpName
=
GetSelinuxContent
(
name
);
if
(
tmpName
!=
NULL
)
{
int
ret
=
strcpy_s
(
auditData
->
label
,
sizeof
(
auditData
->
label
),
tmpName
);
PARAM_CHECK
(
ret
==
0
,
return
0
,
"Failed to copy label for %s"
,
name
);
}
#endif
return
0
;
}
...
...
test/unittest/param/param_stub.cpp
浏览文件 @
a5f9e492
...
...
@@ -70,7 +70,7 @@ static int TestSetParamCheck(const char *paraName, struct ucred *uc)
return
g_testPermissionResult
;
}
static
int
TestGetParamLabel
(
const
char
*
paraName
,
char
**
context
)
static
const
char
*
TestGetParamLabel
(
const
char
*
paraName
)
{
BEGET_LOGI
(
"TestGetParamLabel %s"
,
paraName
);
for
(
size_t
i
=
0
;
i
<
ARRAY_LENGTH
(
selinuxLabels
);
i
++
)
{
...
...
@@ -81,8 +81,7 @@ static int TestGetParamLabel(const char *paraName, char **context)
}
int
code
=
TestGenHashCode
(
paraName
);
code
=
code
%
(
ARRAY_LENGTH
(
selinuxLabels
));
*
context
=
strdup
(
selinuxLabels
[
code
][
1
]);
return
0
;
return
selinuxLabels
[
code
][
1
];
}
static
const
char
*
forbitReadParamName
[]
=
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录