Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
e6599fb7
S
Startup Init Lite
项目概览
OpenHarmony
/
Startup Init Lite
接近 2 年 前同步成功
通知
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看板
提交
e6599fb7
编写于
6月 23, 2022
作者:
M
Mupceet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
initgid
Signed-off-by:
N
Mupceet
<
laiguizhong@huawei.com
>
上级
b676d4a2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
20 addition
and
6 deletion
+20
-6
services/init/init_service_manager.c
services/init/init_service_manager.c
+17
-3
services/utils/init_utils.c
services/utils/init_utils.c
+3
-3
未找到文件。
services/init/init_service_manager.c
浏览文件 @
e6599fb7
...
...
@@ -318,6 +318,20 @@ static int GetUid(cJSON *json, uid_t *uid)
return
SERVICE_SUCCESS
;
}
static
int
GetGid
(
cJSON
*
json
,
gid_t
*
gid
,
Service
*
curServ
)
{
INIT_CHECK_RETURN_VALUE
(
json
!=
NULL
,
SERVICE_SUCCESS
);
if
(
cJSON_IsString
(
json
))
{
char
*
str
=
cJSON_GetStringValue
(
json
);
INIT_ERROR_CHECK
(
str
!=
NULL
,
return
SERVICE_FAILURE
,
"Failed to get gid for %s"
,
curServ
->
name
);
*
gid
=
DecodeGid
(
str
);
}
else
if
(
cJSON_IsNumber
(
json
))
{
*
gid
=
(
gid_t
)
cJSON_GetNumberValue
(
json
);
}
INIT_ERROR_CHECK
(
*
gid
!=
(
gid_t
)(
-
1
),
return
SERVICE_FAILURE
,
"Failed to get gid for %s"
,
curServ
->
name
);
return
SERVICE_SUCCESS
;
}
static
int
GetServiceGids
(
const
cJSON
*
curArrItem
,
Service
*
curServ
)
{
int
gidCount
;
...
...
@@ -338,15 +352,15 @@ static int GetServiceGids(const cJSON *curArrItem, Service *curServ)
gid_t
gid
;
if
(
!
cJSON_IsArray
(
arrItem
))
{
int
ret
=
Get
Uid
(
arrItem
,
&
gid
);
INIT_ERROR_CHECK
(
ret
==
0
,
return
SERVICE_FAILURE
,
"Failed to
u
id"
);
int
ret
=
Get
Gid
(
arrItem
,
&
gid
,
curServ
);
INIT_ERROR_CHECK
(
ret
==
0
,
return
SERVICE_FAILURE
,
"Failed to
g
id"
);
curServ
->
servPerm
.
gIDArray
[
0
]
=
gid
;
return
SERVICE_SUCCESS
;
}
for
(
int
i
=
0
;
i
<
gidCount
;
++
i
)
{
cJSON
*
item
=
cJSON_GetArrayItem
(
arrItem
,
i
);
int
ret
=
Get
Uid
(
item
,
&
gid
);
int
ret
=
Get
Gid
(
item
,
&
gid
,
curServ
);
if
(
ret
!=
0
)
{
curServ
->
servPerm
.
gIDArray
[
i
]
=
0
;
continue
;
...
...
services/utils/init_utils.c
浏览文件 @
e6599fb7
...
...
@@ -77,13 +77,13 @@ uid_t DecodeUid(const char *name)
if
(
!
StringToUint
(
name
,
&
uid
))
{
return
uid
;
}
else
{
INIT_LOGE
(
"Failed to decode uid
"
);
INIT_LOGE
(
"Failed to decode uid
for %s"
,
name
);
return
-
1
;
}
}
struct
passwd
*
p
=
getpwnam
(
name
);
if
(
p
==
NULL
)
{
INIT_LOGE
(
"Failed to decode uid
"
);
INIT_LOGE
(
"Failed to decode uid
for %s"
,
name
);
return
-
1
;
}
return
p
->
pw_uid
;
...
...
@@ -101,7 +101,7 @@ gid_t DecodeGid(const char *name)
if
(
!
StringToUint
(
name
,
&
gid
))
{
return
gid
;
}
else
{
INIT_LOGE
(
"Failed to decode gid
"
);
INIT_LOGE
(
"Failed to decode gid
for %s"
,
name
);
return
-
1
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录