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 void doDropPrivUid(int iUid)
{
    int res;
    uchar szBuf[1024];
    struct passwd* pw;
    gid_t gid;

    /* Try to set appropriate supplementary groups for this user.
     * Failure is not fatal.
     */
    pw = getpwuid(iUid);
    if (pw)
    {
        gid = getgid();
        res = initgroups(pw->pw_name, gid);
        DBGPRINTF("initgroups(%s, %d): %d\n", pw->pw_name, gid, res);
    }
    else
    {
        rs_strerror_r(errno, (char*)szBuf, sizeof(szBuf));
        LogError(0, NO_ERRCODE, "could not get username for userid %d: %s",
                 iUid, szBuf);
    }

    res = setuid(iUid);
    if (res)
    {
        /* if we can not set the userid, this is fatal, so let's unconditionally
         * abort */
        perror("could not set requested userid");
        exit(1);
    }
    DBGPRINTF("setuid(%d): %d\n", iUid, res);
    snprintf((char*)szBuf, sizeof(szBuf), "rsyslogd's userid changed to %d",
             iUid);
    logmsgInternal(NO_ERRCODE, LOG_SYSLOG | LOG_INFO, szBuf, 0);
}
/* drop to specified user
 * if something goes wrong, the function never returns
 * Note that such an abort can cause damage to on-disk structures, so we should
 * re-design the "interface" in the long term. -- rgerhards, 2008-11-19
 */
drop to specified user
if something goes wrong, the function never returns
Note that such an abort can cause damage to on-disk structures, so we should
re-design the "interface" in the long term.
drop to specified user if something goes wrong the function never returns Note that such an abort can cause damage to on - disk structures so we should re - design the " interface " in the long term .
static void doDropPrivUid(int iUid)
{
    int res;
    uchar szBuf[1024];
    struct passwd* pw;
    gid_t gid;
    pw = getpwuid(iUid);
    if (pw)
    {
        gid = getgid();
        res = initgroups(pw->pw_name, gid);
        DBGPRINTF("initgroups(%s, %d): %d\n", pw->pw_name, gid, res);
    }
    else
    {
        rs_strerror_r(errno, (char*)szBuf, sizeof(szBuf));
        LogError(0, NO_ERRCODE, "could not get username for userid %d: %s",
                 iUid, szBuf);
    }
    res = setuid(iUid);
    if (res)
    {
        perror("could not set requested userid");
        exit(1);
    }
    DBGPRINTF("setuid(%d): %d\n", iUid, res);
    snprintf((char*)szBuf, sizeof(szBuf), "rsyslogd's userid changed to %d",
             iUid);
    logmsgInternal(NO_ERRCODE, LOG_SYSLOG | LOG_INFO, szBuf, 0);
}
static void doDropPrivUid ( int iUid ) { int res ; uchar szBuf [ 1024 ] ; struct passwd * pw ; gid_t gid ; pw = getpwuid ( iUid ) ; if ( pw ) { gid = getgid ( ) ; res = initgroups ( pw -> pw_name , gid ) ; DBGPRINTF ( " \n " , pw -> pw_name , gid , res ) ; } else { rs_strerror_r ( errno , ( char * ) szBuf , sizeof ( szBuf ) ) ; LogError ( 0 , NO_ERRCODE , " " , iUid , szBuf ) ; } res = setuid ( iUid ) ; if ( res ) { perror ( " " ) ; exit ( 1 ) ; } DBGPRINTF ( " \n " , iUid , res ) ; snprintf ( ( char * ) szBuf , sizeof ( szBuf ) , " " , iUid ) ; logmsgInternal ( NO_ERRCODE , LOG_SYSLOG | LOG_INFO , szBuf , 0 ) ; }
drop to specified user
 if something goes wrong, the function never returns
 Note that such an abort can cause damage to on-disk structures, so we should
 re-design the "interface" in the long term.
drop to specified user if something goes wrong the function never returns Note that such an abort can cause damage to on - disk structures so we should re - design the " interface " in the long term .
/* Try to set appropriate supplementary groups for this user.
     * Failure is not fatal.
     */ /* if we can not set the userid, this is fatal, so let's unconditionally
         * abort */