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 int init_keyrings(pam_handle_t* pamh, int force)
{
    int session, usession, ret;

    if (!force)
    {
        /* get the IDs of the session keyring and the user session
         * keyring */
        session = syscall(__NR_keyctl, KEYCTL_GET_KEYRING_ID,
                          KEY_SPEC_SESSION_KEYRING, 0);
        debug(pamh, "GET SESSION = %d", session);
        if (session < 0)
        {
            /* don't worry about keyrings if facility not
             * installed */
            if (errno == ENOSYS)
                return PAM_SUCCESS;
            return PAM_SESSION_ERR;
        }

        usession = syscall(__NR_keyctl, KEYCTL_GET_KEYRING_ID,
                           KEY_SPEC_USER_SESSION_KEYRING, 0);
        debug(pamh, "GET SESSION = %d", usession);
        if (usession < 0)
            return PAM_SESSION_ERR;

        /* if the user session keyring is our keyring, then we don't
         * need to do anything if we're not forcing */
        if (session != usession)
            return PAM_SUCCESS;
    }

    /* create a session keyring, discarding the old one */
    ret = syscall(__NR_keyctl, KEYCTL_JOIN_SESSION_KEYRING, NULL);
    debug(pamh, "JOIN = %d", ret);
    if (ret < 0)
        return PAM_SESSION_ERR;

    my_session_keyring = ret;

    /* make a link from the session keyring to the user keyring */
    ret = syscall(__NR_keyctl, KEYCTL_LINK, KEY_SPEC_USER_KEYRING,
                  KEY_SPEC_SESSION_KEYRING);

    return ret < 0 ? PAM_SESSION_ERR : PAM_SUCCESS;
}
/*
 * initialise the session keyring for this process
 */
initialise the session keyring for this process
initialise the session keyring for this process
static int init_keyrings(pam_handle_t* pamh, int force)
{
    int session, usession, ret;
    if (!force)
    {
        session = syscall(__NR_keyctl, KEYCTL_GET_KEYRING_ID,
                          KEY_SPEC_SESSION_KEYRING, 0);
        debug(pamh, "GET SESSION = %d", session);
        if (session < 0)
        {
            if (errno == ENOSYS)
                return PAM_SUCCESS;
            return PAM_SESSION_ERR;
        }
        usession = syscall(__NR_keyctl, KEYCTL_GET_KEYRING_ID,
                           KEY_SPEC_USER_SESSION_KEYRING, 0);
        debug(pamh, "GET SESSION = %d", usession);
        if (usession < 0)
            return PAM_SESSION_ERR;
        if (session != usession)
            return PAM_SUCCESS;
    }
    ret = syscall(__NR_keyctl, KEYCTL_JOIN_SESSION_KEYRING, NULL);
    debug(pamh, "JOIN = %d", ret);
    if (ret < 0)
        return PAM_SESSION_ERR;
    my_session_keyring = ret;
    ret = syscall(__NR_keyctl, KEYCTL_LINK, KEY_SPEC_USER_KEYRING,
                  KEY_SPEC_SESSION_KEYRING);
    return ret < 0 ? PAM_SESSION_ERR : PAM_SUCCESS;
}
static int init_keyrings ( pam_handle_t * pamh , int force ) { int session , usession , ret ; if ( ! force ) { session = syscall ( __NR_keyctl , KEYCTL_GET_KEYRING_ID , KEY_SPEC_SESSION_KEYRING , 0 ) ; debug ( pamh , " " , session ) ; if ( session < 0 ) { if ( errno == ENOSYS ) return PAM_SUCCESS ; return PAM_SESSION_ERR ; } usession = syscall ( __NR_keyctl , KEYCTL_GET_KEYRING_ID , KEY_SPEC_USER_SESSION_KEYRING , 0 ) ; debug ( pamh , " " , usession ) ; if ( usession < 0 ) return PAM_SESSION_ERR ; if ( session != usession ) return PAM_SUCCESS ; } ret = syscall ( __NR_keyctl , KEYCTL_JOIN_SESSION_KEYRING , NULL ) ; debug ( pamh , " " , ret ) ; if ( ret < 0 ) return PAM_SESSION_ERR ; my_session_keyring = ret ; ret = syscall ( __NR_keyctl , KEYCTL_LINK , KEY_SPEC_USER_KEYRING , KEY_SPEC_SESSION_KEYRING ) ; return ret < 0 ? PAM_SESSION_ERR : PAM_SUCCESS ; }
initialise the session keyring for this process
initialise the session keyring for this process
/* get the IDs of the session keyring and the user session
         * keyring */ /* don't worry about keyrings if facility not
             * installed */ /* if the user session keyring is our keyring, then we don't
         * need to do anything if we're not forcing */ /* create a session keyring, discarding the old one */ /* make a link from the session keyring to the user keyring */