protected function setUserAndGroup()
    {
        if (!is_null($this->user)) {
            if (!is_null($this->group)) {
                $group_info = posix_getgrnam($this->user);
                $group_id = $group_info['gid'];
                if (!posix_setgid($group_id)) {
                    throw new \RuntimeException("set group failed");
                }
            }
            $user_info = posix_getpwnam($this->user);
            $user_id = $user_info["uid"];
            if (!posix_setuid($user_id)) {
                throw new \RuntimeException("set user failed");
            }
        }
    }
protected function setUserAndGroup()
    {
        if (!is_null($this->user)) {
            if (!is_null($this->group)) {
                $group_info = posix_getgrnam($this->user);
                $group_id = $group_info['gid'];
                if (!posix_setgid($group_id)) {
                    throw new \RuntimeException("set group failed");
                }
            }
            $user_info = posix_getpwnam($this->user);
            $user_id = $user_info["uid"];
            if (!posix_setuid($user_id)) {
                throw new \RuntimeException("set user failed");
            }
        }
    }
protected function setUserAndGroup ( ) { if ( ! is_null ( $ this -> user ) ) { if ( ! is_null ( $ this -> group ) ) { $ group_info = posix_getgrnam ( $ this -> user ) ; $ group_id = $ group_info [ 'gid' ] ; if ( ! posix_setgid ( $ group_id ) ) { throw new \ RuntimeException ( "set group failed" ) ; } } $ user_info = posix_getpwnam ( $ this -> user ) ; $ user_id = $ user_info [ "uid" ] ; if ( ! posix_setuid ( $ user_id ) ) { throw new \ RuntimeException ( "set user failed" ) ; } } }
set user and group if they are not null
set user and group if they are not null