mirror of
https://gitee.com/openharmony/startup_init
synced 2024-11-23 16:20:00 +00:00
modify init setgid
Signed-off-by: zhong_ning <zhong_ning@hoperun.com>
This commit is contained in:
parent
a3f82ef4e6
commit
1401f9c0fa
@ -77,13 +77,13 @@ static int SetAllAmbientCapability()
|
||||
|
||||
static int SetPerms(const Service *service)
|
||||
{
|
||||
if (KeepCapability() != 0) {
|
||||
return SERVICE_FAILURE;
|
||||
}
|
||||
|
||||
if (setgroups(service->servPerm.gIDCnt, service->servPerm.gIDArray) != 0) {
|
||||
INIT_LOGE("SetPerms, setgroups failed. errno = %d, gIDCnt=%d", errno, service->servPerm.gIDCnt);
|
||||
return SERVICE_FAILURE;
|
||||
INIT_CHECK_RETURN_VALUE(KeepCapability() == 0, 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);
|
||||
} else if (service->servPerm.gIDCnt > 1){
|
||||
INIT_ERROR_CHECK(setgroups(service->servPerm.gIDCnt, service->servPerm.gIDArray) == 0, return SERVICE_FAILURE,
|
||||
"SetPerms, setgroups failed. errno = %d, gIDCnt=%d", errno, service->servPerm.gIDCnt);
|
||||
}
|
||||
|
||||
if (service->servPerm.uID != 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user