提交 1401f9c0 编写于 作者: Z zhong_ning

modify init setgid

Signed-off-by: Nzhong_ning <zhong_ning@hoperun.com>
上级 a3f82ef4
...@@ -77,13 +77,13 @@ static int SetAllAmbientCapability() ...@@ -77,13 +77,13 @@ static int SetAllAmbientCapability()
static int SetPerms(const Service *service) static int SetPerms(const Service *service)
{ {
if (KeepCapability() != 0) { INIT_CHECK_RETURN_VALUE(KeepCapability() == 0, SERVICE_FAILURE);
return SERVICE_FAILURE; if (service->servPerm.gIDCnt == 1) {
} INIT_ERROR_CHECK(setgid(service->servPerm.gIDArray[0]) == 0, return SERVICE_FAILURE,
"SetPerms, setgid for %s failed. %d", service->name, errno);
if (setgroups(service->servPerm.gIDCnt, service->servPerm.gIDArray) != 0) { } else if (service->servPerm.gIDCnt > 1){
INIT_LOGE("SetPerms, setgroups failed. errno = %d, gIDCnt=%d", errno, service->servPerm.gIDCnt); INIT_ERROR_CHECK(setgroups(service->servPerm.gIDCnt, service->servPerm.gIDArray) == 0, return SERVICE_FAILURE,
return SERVICE_FAILURE; "SetPerms, setgroups failed. errno = %d, gIDCnt=%d", errno, service->servPerm.gIDCnt);
} }
if (service->servPerm.uID != 0) { if (service->servPerm.uID != 0) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册