openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/libpam/1.3.1-r0/Linux-PAM-1.3.1/modules/pam_keyinit/pam_keyinit.c
static void kill_keyrings(pam_handle_t* pamh)
{
    int old_uid, old_gid;

    /* revoke the session keyring we created earlier */
    if (my_session_keyring > 0)
    {
        debug(pamh, "REVOKE %d", my_session_keyring);

        old_uid = geteuid();
        old_gid = getegid();
        debug(pamh, "UID:%d [%d]  GID:%d [%d]", revoke_as_uid, old_uid,
              revoke_as_gid, old_gid);

        /* switch to the real UID and GID so that we have permission to
         * revoke the key */
        if (revoke_as_gid != old_gid && setregid(-1, revoke_as_gid) < 0)
            error(pamh, "Unable to change GID to %d temporarily\n",
                  revoke_as_gid);

        if (revoke_as_uid != old_uid &&
            setresuid(-1, revoke_as_uid, old_uid) < 0)
            error(pamh, "Unable to change UID to %d temporarily\n",
                  revoke_as_uid);

        syscall(__NR_keyctl, KEYCTL_REVOKE, my_session_keyring);

        /* return to the orignal UID and GID (probably root) */
        if (revoke_as_uid != old_uid && setreuid(-1, old_uid) < 0)
            error(pamh, "Unable to change UID back to %d\n", old_uid);

        if (revoke_as_gid != old_gid && setregid(-1, old_gid) < 0)
            error(pamh, "Unable to change GID back to %d\n", old_gid);

        my_session_keyring = 0;
    }
}
/*
 * revoke the session keyring for this process
 */
revoke the session keyring for this process
revoke the session keyring for this process
static void kill_keyrings(pam_handle_t* pamh)
{
    int old_uid, old_gid;
    if (my_session_keyring > 0)
    {
        debug(pamh, "REVOKE %d", my_session_keyring);
        old_uid = geteuid();
        old_gid = getegid();
        debug(pamh, "UID:%d [%d]  GID:%d [%d]", revoke_as_uid, old_uid,
              revoke_as_gid, old_gid);
        if (revoke_as_gid != old_gid && setregid(-1, revoke_as_gid) < 0)
            error(pamh, "Unable to change GID to %d temporarily\n",
                  revoke_as_gid);
        if (revoke_as_uid != old_uid &&
            setresuid(-1, revoke_as_uid, old_uid) < 0)
            error(pamh, "Unable to change UID to %d temporarily\n",
                  revoke_as_uid);
        syscall(__NR_keyctl, KEYCTL_REVOKE, my_session_keyring);
        if (revoke_as_uid != old_uid && setreuid(-1, old_uid) < 0)
            error(pamh, "Unable to change UID back to %d\n", old_uid);
        if (revoke_as_gid != old_gid && setregid(-1, old_gid) < 0)
            error(pamh, "Unable to change GID back to %d\n", old_gid);
        my_session_keyring = 0;
    }
}
static void kill_keyrings ( pam_handle_t * pamh ) { int old_uid , old_gid ; if ( my_session_keyring > 0 ) { debug ( pamh , " " , my_session_keyring ) ; old_uid = geteuid ( ) ; old_gid = getegid ( ) ; debug ( pamh , " " , revoke_as_uid , old_uid , revoke_as_gid , old_gid ) ; if ( revoke_as_gid != old_gid && setregid ( -1 , revoke_as_gid ) < 0 ) error ( pamh , " \n " , revoke_as_gid ) ; if ( revoke_as_uid != old_uid && setresuid ( -1 , revoke_as_uid , old_uid ) < 0 ) error ( pamh , " \n " , revoke_as_uid ) ; syscall ( __NR_keyctl , KEYCTL_REVOKE , my_session_keyring ) ; if ( revoke_as_uid != old_uid && setreuid ( -1 , old_uid ) < 0 ) error ( pamh , " \n " , old_uid ) ; if ( revoke_as_gid != old_gid && setregid ( -1 , old_gid ) < 0 ) error ( pamh , " \n " , old_gid ) ; my_session_keyring = 0 ; } }
revoke the session keyring for this process
revoke the session keyring for this process
/* revoke the session keyring we created earlier */ /* switch to the real UID and GID so that we have permission to
         * revoke the key */ /* return to the orignal UID and GID (probably root) */