예제 #1
0
/**
 * RefreshCredentials: Get the refresh interval
 */
static int
ngcllRefreshCredentialsIntervalGet(
    ngclContext_t *context,
    int *interval,
    int *error)
{
    static const char fName[] = "ngcllRefreshCredentialsIntervalGet";
    ngclLocalMachineInformationManager_t *lmInfoMng;
    ngLog_t *log;
    int result;

    /* Check the arguments */
    assert(context != NULL);
    assert(interval != NULL);

    log = context->ngc_log;
    *interval = 0;

    /* Lock the Local Machine Information */
    result = ngcliLocalMachineInformationListReadLock(context, log, error);
    if (result == 0) {
        ngclLogPrintfContext(context, NG_LOG_CATEGORY_NINFG_PURE,
            NG_LOG_LEVEL_ERROR, NULL,
            "%s: Can't lock the list of Local Machine Information.\n", fName);
        return 0;
    }

    /* Get refresh proxy cred interval */
    lmInfoMng = ngcliLocalMachineInformationCacheGet(context, error);
    if (lmInfoMng == NULL) {
        ngclLogPrintfContext(context, NG_LOG_CATEGORY_NINFG_PURE,
            NG_LOG_LEVEL_ERROR, NULL,
            "%s: Can't get the Local Machine Information.\n", fName);
        goto error;
    }

    /* set the interval of refresh proxy cert */
    *interval = lmInfoMng->nglmim_info.nglmi_refreshInterval;

    /* Unlock the Local Machine Information */
    result = ngcliLocalMachineInformationListReadUnlock(
        context, log, error);
    if (result == 0) {
        ngclLogPrintfContext(context, NG_LOG_CATEGORY_NINFG_PURE,
            NG_LOG_LEVEL_ERROR, NULL,
            "%s: Can't unlock the list of Local Machine Information.\n",
            fName);
        return 0;
    }

    /* Success */
    return 1;

    /* Error occurred */
error:
    /* Unlock */
    result = ngcliLocalMachineInformationListReadUnlock(
        context, log, NULL);
    if (result == 0) {
        ngclLogPrintfContext(context, NG_LOG_CATEGORY_NINFG_PURE,
            NG_LOG_LEVEL_ERROR, NULL,
            "%s: Can't unlock the list of Local Machine Information.\n",
            fName);
        return 0;
    }

    /* Failed */
    return 0;
}
예제 #2
0
static int
ngcllLocalMachineInformationGetCopy(
    ngclContext_t *context,
    ngclLocalMachineInformation_t *lmInfo,
    int *error)
{
    int result;
    ngcliLocalMachineInformationManager_t *lmInfoMng;
    static const char fName[] = "ngcllLocalMachineInformationGetCopy";

    /* Check the arguments */
    if (lmInfo == NULL) {
        NGI_SET_ERROR(error, NG_ERROR_INVALID_ARGUMENT);
        ngclLogErrorContext(context, NG_LOGCAT_NINFG_PURE, fName,  
            "Invalid argument.\n"); 
        return 0;
    }

    /* Lock the Local Machine Information */
    result = ngcliLocalMachineInformationListReadLock(
        context, context->ngc_log, error);
    if (result == 0) {
        ngclLogErrorContext(context, NG_LOGCAT_NINFG_PURE, fName,  
            "Can't lock the list of Local Machine Information.\n"); 
        return 0;
    }

    /* Get the Local Machine Information */
    lmInfoMng = ngcliLocalMachineInformationCacheGet(context, error);
    if (lmInfoMng == NULL) {
        ngclLogErrorContext(context, NG_LOGCAT_NINFG_PURE, fName,  
            "Can't get the Local Machine Information.\n"); 
        goto error;
    }

    /* Copy the Local Machine Information */
    result = ngcliLocalMachineInformationCopy(context,
                    &lmInfoMng->nglmim_info, lmInfo, error);
    if (result == 0) {
        ngclLogErrorContext(context, NG_LOGCAT_NINFG_PURE, fName,
            "Can't copy the Local Machine Information.\n"); 
        goto error;
    }

    /* Unlock the Local Machine Information */
    result = ngcliLocalMachineInformationListReadUnlock(
        context, context->ngc_log, error);
    if (result == 0) {
        ngclLogErrorContext(context, NG_LOGCAT_NINFG_PURE, fName,  
            "Can't unlock the list of Local Machine Information.\n"); 
        return 0;
    }

    /* Success */
    return 1;

    /* Error occurred */
error:
    /* Unlock */
    result = ngcliLocalMachineInformationListReadUnlock(
        context, context->ngc_log, error);
    if (result == 0) {
        ngclLogErrorContext(context, NG_LOGCAT_NINFG_PURE, fName,  
            "Can't unlock the list of Local Machine Information.\n"); 
        return 0;
    }

    /* Failed */
    return 0;
}