openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/rsyslog/8.1903.0-r0/rsyslog-8.1903.0/runtime/rsconf.c
static rsRetVal doDropPrivGid(void)
{
    int res;
    uchar szBuf[1024];
    DEFiRet;

    if (!ourConf->globals.gidDropPrivKeepSupplemental)
    {
        res = setgroups(0, NULL); /* remove all supplemental group IDs */
        if (res)
        {
            rs_strerror_r(errno, (char*)szBuf, sizeof(szBuf));
            LogError(0, RS_RET_ERR_DROP_PRIV,
                     "could not remove supplemental group IDs: %s", szBuf);
            ABORT_FINALIZE(RS_RET_ERR_DROP_PRIV);
        }
        DBGPRINTF("setgroups(0, NULL): %d\n", res);
    }
    res = setgid(ourConf->globals.gidDropPriv);
    if (res)
    {
        rs_strerror_r(errno, (char*)szBuf, sizeof(szBuf));
        LogError(0, RS_RET_ERR_DROP_PRIV,
                 "could not set requested group id: %s", szBuf);
        ABORT_FINALIZE(RS_RET_ERR_DROP_PRIV);
    }
    DBGPRINTF("setgid(%d): %d\n", ourConf->globals.gidDropPriv, res);
    snprintf((char*)szBuf, sizeof(szBuf), "rsyslogd's groupid changed to %d",
             ourConf->globals.gidDropPriv);
    logmsgInternal(NO_ERRCODE, LOG_SYSLOG | LOG_INFO, szBuf, 0);
finalize_it:
    RETiRet;
}
/* drop to specified group
 * if something goes wrong, the function never returns
 */
drop to specified group
if something goes wrong, the function never returns
drop to specified group if something goes wrong the function never returns
static rsRetVal doDropPrivGid(void)
{
    int res;
    uchar szBuf[1024];
    DEFiRet;
    if (!ourConf->globals.gidDropPrivKeepSupplemental)
    {
        res = setgroups(0, NULL); 
        if (res)
        {
            rs_strerror_r(errno, (char*)szBuf, sizeof(szBuf));
            LogError(0, RS_RET_ERR_DROP_PRIV,
                     "could not remove supplemental group IDs: %s", szBuf);
            ABORT_FINALIZE(RS_RET_ERR_DROP_PRIV);
        }
        DBGPRINTF("setgroups(0, NULL): %d\n", res);
    }
    res = setgid(ourConf->globals.gidDropPriv);
    if (res)
    {
        rs_strerror_r(errno, (char*)szBuf, sizeof(szBuf));
        LogError(0, RS_RET_ERR_DROP_PRIV,
                 "could not set requested group id: %s", szBuf);
        ABORT_FINALIZE(RS_RET_ERR_DROP_PRIV);
    }
    DBGPRINTF("setgid(%d): %d\n", ourConf->globals.gidDropPriv, res);
    snprintf((char*)szBuf, sizeof(szBuf), "rsyslogd's groupid changed to %d",
             ourConf->globals.gidDropPriv);
    logmsgInternal(NO_ERRCODE, LOG_SYSLOG | LOG_INFO, szBuf, 0);
finalize_it:
    RETiRet;
}
static rsRetVal doDropPrivGid ( void ) { int res ; uchar szBuf [ 1024 ] ; DEFiRet ; if ( ! ourConf -> globals . gidDropPrivKeepSupplemental ) { res = setgroups ( 0 , NULL ) ; if ( res ) { rs_strerror_r ( errno , ( char * ) szBuf , sizeof ( szBuf ) ) ; LogError ( 0 , RS_RET_ERR_DROP_PRIV , " " , szBuf ) ; ABORT_FINALIZE ( RS_RET_ERR_DROP_PRIV ) ; } DBGPRINTF ( " \n " , res ) ; } res = setgid ( ourConf -> globals . gidDropPriv ) ; if ( res ) { rs_strerror_r ( errno , ( char * ) szBuf , sizeof ( szBuf ) ) ; LogError ( 0 , RS_RET_ERR_DROP_PRIV , " " , szBuf ) ; ABORT_FINALIZE ( RS_RET_ERR_DROP_PRIV ) ; } DBGPRINTF ( " \n " , ourConf -> globals . gidDropPriv , res ) ; snprintf ( ( char * ) szBuf , sizeof ( szBuf ) , " " , ourConf -> globals . gidDropPriv ) ; logmsgInternal ( NO_ERRCODE , LOG_SYSLOG | LOG_INFO , szBuf , 0 ) ; finalize_it : RETiRet ; }
drop to specified group
 if something goes wrong, the function never returns
drop to specified group if something goes wrong the function never returns
/* remove all supplemental group IDs */