コード例 #1
0
ファイル: msiHelper.cpp プロジェクト: QuarkDoe/irods
/**
 * \fn msiGetStderrInExecCmdOut (msParam_t *inpExecCmdOut, msParam_t *outStr, ruleExecInfo_t *rei)
 *
 * \brief Gets stderr buffer from ExecCmdOut into buffer.
 *
 * \module core
 *
 * \since pre-2.1
 *
 * \author Mike Wan
 *
 * \usage See clients/icommands/test/rules/
 *
 * \param[in] inpExecCmdOut - a STR_MS_T which specifies the ExecCmdOut.
 * \param[out] outStr - a STR_MS_T to hold the retrieved stderr buffer.
 * \param[in,out] rei - The RuleExecInfo structure that is automatically
 *    handled by the rule engine. The user does not include rei as a
 *    parameter in the rule invocation.
 *
 * \DolVarDependence none
 * \DolVarModified none
 * \iCatAttrDependence none
 * \iCatAttrModified none
 * \sideeffect none
 *
 * \return integer
 * \retval 0 upon success
 * \pre none
 * \post none
 * \sa none
**/
int
msiGetStderrInExecCmdOut( msParam_t *inpExecCmdOut, msParam_t *outStr,
                          ruleExecInfo_t *rei ) {
    char *strPtr = NULL;

    rei->status = getStderrInExecCmdOut( inpExecCmdOut, &strPtr );

    if ( rei->status < 0 ) {
        if ( rei->status != SYS_INTERNAL_NULL_INPUT_ERR ) {
            return rei->status;
        }
        else {
            free( strPtr );
            strPtr = NULL;
            rei->status = 0;
        }
    }

    if ( strPtr != NULL ) {
        fillStrInMsParam( outStr, strPtr );
        free( strPtr );
    }
    else {
        fillStrInMsParam( outStr, "" );
    }

    return rei->status;
}
コード例 #2
0
ファイル: irods_re_plugin.cpp プロジェクト: QuarkDoe/irods
    error convertToMsParam(boost::any &itr, msParam_t *t) {
        if(itr.type() == typeid(std::string)) {
            fillStrInMsParam( t, const_cast<char*>( boost::any_cast<std::string>(itr).c_str() ));
        } else if(itr.type() == typeid(std::string *)) {
            fillStrInMsParam( t, const_cast<char*>( (*(boost::any_cast<std::string *>(itr))).c_str() ));
        } else if(itr.type() == typeid(msParam_t*)) {
            memset(t, 0, sizeof(*t));
            replMsParam(boost::any_cast<msParam_t*>(itr), t);
        } else {
            return ERROR(-1, "cannot convert parameter");
        }

        return SUCCESS();
    }
コード例 #3
0
ファイル: nre.systemMS.cpp プロジェクト: jrandall/irods
/**
 *\fn msiBytesBufToStr(msParam_t* buf_msp,  msParam_t* str_msp, ruleExecInfo_t* )
 *
 * \brief Writes  a bytesBuf_t into a character string
 *
 * \module core
 *
 * \since 3.3
 *
 *
 * \remark This may blow up if the buffer is not a character string. so be careful
 *
 * \note The string can have length up to BUF_LEN_MS_T
 *
 * \usage
 *
 * testrule{
 *    msiBytesBufToStr(*Buff, *St)
 *    writeLine(stdout,*St)
 * }
 * ruleExecOut
 *
 * \param[in] buf_msp - a BUF_LEN_MS_T
 * \param[out] str_msp - a STR_MS_T
 * \param[in,out]  - The RuleExecInfo structure that is automatically
 *    handled by the rule engine. The user does not include rei as a
 *    parameter in the rule invocation.
 *
 * \DolVarDependence none
 * \DolVarModified none
 * \iCatAttrDependence none
 * \iCatAttrModified none
 * \sideeffect none
 *
 * \return integer
 * \retval 0 on success
 * \pre none
 * \post none
 * \sa none
**/
int
msiBytesBufToStr( msParam_t* buf_msp, msParam_t* str_msp, ruleExecInfo_t* ) {
    char *outStr;
    bytesBuf_t *inBuf;
    int single_buff_sz = 0;
    irods::error ret = irods::get_advanced_setting<int>(
                           irods::CFG_MAX_SIZE_FOR_SINGLE_BUFFER,
                           single_buff_sz );
    if ( !ret.ok() ) {
        irods::log( PASS( ret ) );
        return ret.code();
    }
    single_buff_sz *= 1024 * 1024;

    /*check buf_msp */
    if ( buf_msp == NULL || buf_msp->inOutStruct == NULL ) {
        rodsLog( LOG_ERROR, "msiBytesBufToStr: input buf_msp is NULL." );
        return USER__NULL_INPUT_ERR;
    }
    inBuf = buf_msp->inpOutBuf;
    if ( inBuf->len < 0 || inBuf->len > ( single_buff_sz - 10 ) )  {
        rodsLog( LOG_ERROR, "msiBytesBufToStr: input buf_msp is NULL." );
        return USER_INPUT_FORMAT_ERR;
    }
    outStr = ( char * ) malloc( ( inBuf->len + 1 ) );
    outStr[inBuf->len] = '\0';
    strncpy( outStr, ( char * ) inBuf->buf, inBuf->len );
    fillStrInMsParam( str_msp, outStr );
    free( outStr );

    return 0;
}
コード例 #4
0
ファイル: examplesMS.c プロジェクト: DICE-UNC/iRODS-FUSE-Mod
/**
 * msiGetRescAddr
 *
 * @param[in]		rescName	the resource name 
 * @param[out]		outAddress	the returned IP address
 * @param[in,out]	rei		the rule execution information
 * @return				the status code, 0 on success
 */
int
msiGetRescAddr( msParam_t *rescName, msParam_t *outAddress,
	ruleExecInfo_t *rei )
{
    char *tmpPtr;
    int status;
    rescGrpInfo_t *rescGrpInfo = NULL;

    RE_TEST_MACRO( "    Calling msiGetRescAddr" );

    tmpPtr = parseMspForStr (rescName);

    if (tmpPtr == NULL)  {
	rodsLog (LOG_ERROR, "msiGetRescAddr: missing name input");
	rei->status = USER__NULL_INPUT_ERR;
	return USER__NULL_INPUT_ERR;
    }

    status = _getRescInfo (rei->rsComm, tmpPtr, &rescGrpInfo);
    if (status < 0) {
         rodsLog (LOG_ERROR,
          "msiGetRescAddr: _getRescInfo of %s error. stat = %d",
          rescName, status);
        return status;
    }

    fillStrInMsParam (outAddress, rescGrpInfo->rescInfo->rescLoc);

    rei->status = 0;
    return 0;
}
コード例 #5
0
ファイル: nre.systemMS.cpp プロジェクト: leesab/irods
/**
 * \fn msiGetSystemTime(msParam_t* outParam, msParam_t* inpParam, ruleExecInfo_t *rei)
 *
 * \brief This microservice returns the local system time
 *
 * \module framework
 *
 * \since pre-2.1
 *
 * \author  Antoine de Torcy
 * \date    2007-09-19
 *
 * \note Default output format is system time in seconds, use 'human' as input param for human readable format.
 *
 * \usage See clients/icommands/test/rules3.0/
 *
 * \param[out] outParam - a STR_MS_T containing the time
 * \param[in] inpParam - Optional - a STR_MS_T containing the desired output format
 * \param[in,out] rei - The RuleExecInfo structure that is automatically
 *    handled by the rule engine. The user does not include rei as a
 *    parameter in the rule invocation.
 *
 * \DolVarDependence none
 * \DolVarModified none
 * \iCatAttrDependence none
 * \iCatAttrModified none
 * \sideeffect none
 *
 * \return integer
 * \retval 0 on success
 * \pre none
 * \post none
 * \sa none
**/
int
msiGetSystemTime( msParam_t* outParam, msParam_t* inpParam, ruleExecInfo_t *rei ) {
    char *format;
    char tStr0[TIME_LEN], tStr[TIME_LEN];
    int status;

    /* For testing mode when used with irule --test */
    RE_TEST_MACRO( "    Calling msiGetSystemTime" )


    if ( rei == NULL || rei->rsComm == NULL ) {
        rodsLog( LOG_ERROR, "msiGetSystemTime: input rei or rsComm is NULL" );
        return ( SYS_INTERNAL_NULL_INPUT_ERR );
    }


    format = ( char * ) inpParam->inOutStruct;

    if ( !format || strcmp( format, "human" ) ) {
        getNowStr( tStr );
    }
    else {
        getNowStr( tStr0 );
        getLocalTimeFromRodsTime( tStr0, tStr );
    }

    status = fillStrInMsParam( outParam, tStr );

    return( status );
}
コード例 #6
0
ファイル: eudat.c プロジェクト: EUDAT/B2SAFE-core
int 
msiGetFieldFromRodsObjStat(msParam_t *in_rodsObjStat, msParam_t *in_Field, msParam_t *out, ruleExecInfo_t *rei) {
    rodsObjStat_t *rodsObjStatIn = NULL;
    char output[MAX_NAME_LEN];
    char *field;
    
    rei->status = 0;
    
    //process input parameter
    if(in_rodsObjStat->inOutStruct == NULL) {
        rei->status = -1;
        return rei->status;
    }
    rodsObjStatIn = (rodsObjStat_t *)in_rodsObjStat->inOutStruct;
    field = parseMspForStr(in_Field);
    if(field == NULL) {
        rodsLog(LOG_ERROR, (char *) "msiGetFieldFromRodsObjStat :: supplied field cannot be NULL.");
        rei->status = -1;
        return rei->status;
    }
    
    //extract requested field
    if(strcmp(field, "size") == 0 || strcmp(field, "SIZE") == 0) {
        snprintf(output, MAX_NAME_LEN, "%i", rodsObjStatIn->objSize);
    } else {
        rei->status = -1;
        rodsLog(LOG_ERROR, (char *) "msiGetFieldFromRodsObjStat :: unkown field supplied: [%s]", field);
    }
    
    //set output
    if(rei->status >= 0) {
        rei->status = fillStrInMsParam(out, output);        
    }
    return rei->status;
}
コード例 #7
0
    int msiobjget_microservices(msParam_t* outMicroservices, ruleExecInfo_t* rei) {
        rodsLog(LOG_NOTICE, "%s MSI Get Microservices [%s]\n",  MSI_LOG, MSI_VERSION);

        boost::filesystem::path msi_dir_path(MSI_IRODS_42_DIR);
        rodsLog(LOG_NOTICE, "%s !!!Checking %s\n", MSI_LOG, msi_dir_path.string().c_str());

        if (!boost::filesystem::exists(msi_dir_path)) {
            rodsLog(LOG_ERROR, "%s Directory %s does not exist\n", MSI_LOG, msi_dir_path.string().c_str());
            return MSI_ERROR;
        }

        std::string msis;

        boost::filesystem::directory_iterator end_itr;
        for (boost::filesystem::directory_iterator itr(msi_dir_path); itr != end_itr; itr++) {
            if (boost::filesystem::is_directory(itr->status()) ) continue;

            msis.append(itr->path().filename().string().c_str());
            msis.append(",");
        }

        rodsLog(LOG_NOTICE, "%s -> %s\n", MSI_LOG, msis.c_str());

        fillStrInMsParam(outMicroservices, msis.c_str());

        return MSI_SUCCESS;
    }
コード例 #8
0
ファイル: nre.systemMS.cpp プロジェクト: leesab/irods
/**
 * \fn msiGetDiffTime(msParam_t* inpParam1, msParam_t* inpParam2, msParam_t* inpParam3, msParam_t* outParam, ruleExecInfo_t *rei)
 *
 * \brief This microservice returns the difference between two system times
 *
 * \module framework
 *
 * \since 2.1
 *
 * \author  Antoine de Torcy
 * \date    2007-09-19
 *
 * \note If we have arithmetic MSs in the future we should use DOUBLE_MS_T instead of strings.
 *       Default output format is in seconds, use 'human' as the third input param for human readable format.
 *
 * \usage See clients/icommands/test/rules3.0/
 *
 * \param[in] inpParam1 - a STR_MS_T containing the start date (system time in seconds)
 * \param[in] inpParam2 - a STR_MS_T containing the end date (system time in seconds)
 * \param[in] inpParam3 - Optional - a STR_MS_T containing the desired output format
 * \param[out] outParam - a STR_MS_T containing the time elapsed between the two dates
 * \param[in,out] rei - The RuleExecInfo structure that is automatically
 *    handled by the rule engine. The user does not include rei as a
 *    parameter in the rule invocation.
 *
 * \DolVarDependence none
 * \DolVarModified none
 * \iCatAttrDependence none
 * \iCatAttrModified none
 * \sideeffect none
 *
 * \return integer
 * \retval 0 on success
 * \pre none
 * \post none
 * \sa none
**/
int
msiGetDiffTime( msParam_t* inpParam1, msParam_t* inpParam2, msParam_t* inpParam3, msParam_t* outParam, ruleExecInfo_t *rei ) {
    long hours, minutes, seconds;
    char timeStr[TIME_LEN];
    char *format;
    int status;


    /* For testing mode when used with irule --test */
    RE_TEST_MACRO( "    Calling msiGetDiffTime" )


    if ( rei == NULL || rei->rsComm == NULL ) {
        rodsLog( LOG_ERROR, "msiGetDiffTime: input rei or rsComm is NULL" );
        return ( SYS_INTERNAL_NULL_INPUT_ERR );
    }


    /* Check for proper input */
    if ( ( parseMspForStr( inpParam1 ) == NULL ) ) {
        rodsLog( LOG_ERROR, "msiGetDiffTime: input inpParam1 is NULL" );
        return ( USER__NULL_INPUT_ERR );
    }

    if ( ( parseMspForStr( inpParam2 ) == NULL ) ) {
        rodsLog( LOG_ERROR, "msiGetDiffTime: input inpParam2 is NULL" );
        return ( USER__NULL_INPUT_ERR );
    }


    /* get time values from strings */
    seconds = atol( ( char * ) inpParam2->inOutStruct ) - atol( ( char * )inpParam1->inOutStruct );

    /* get desired output format */
    format = ( char * ) inpParam3->inOutStruct;


    /* did they ask for human readable format? */
    if ( format && !strcmp( format, "human" ) ) {
        /* get hours-minutes-seconds */
        hours = seconds / 3600;
        seconds = seconds % 3600;
        minutes = seconds / 60;
        seconds = seconds % 60;

        snprintf( timeStr, TIME_LEN, "%ldh %ldm %lds", hours, minutes, seconds );
    }
    else {
        snprintf( timeStr, TIME_LEN, "%011ld", seconds );
    }


    /* result goes to outParam */
    status = fillStrInMsParam( outParam, timeStr );

    return( status );
}
コード例 #9
0
ファイル: eudat.c プロジェクト: EUDAT/B2SAFE-core
int 
msiGetZoneNameFromPath(msParam_t *inPath, msParam_t *outZoneName, ruleExecInfo_t *rei) {
    char *path;
    char tmp[MAX_NAME_LEN];
    char *ptr;  
    
    path = parseMspForStr(inPath);
    snprintf(tmp, MAX_NAME_LEN, "%s", path);
    strtok_r (tmp, "/", &ptr);
    fillStrInMsParam(outZoneName, tmp);
    
    return 0;
}
コード例 #10
0
ファイル: msiHelper.c プロジェクト: UPPMAX/irods
/**
 * \fn msiGetStdoutInExecCmdOut (msParam_t *inpExecCmdOut, msParam_t *outStr, ruleExecInfo_t *rei)
 *
 * \brief Gets stdout buffer from ExecCmdOut into buffer.
 *
 * \module core
 *
 * \since pre-2.1
 *
 * \author Mike Wan 
 * \date  2009  
 *
 * \usage See clients/icommands/test/rules3.0/
 *
 * \param[in] inpExecCmdOut - a STR_MS_T which specifies the ExecCmdOut.
 * \param[out] outStr - a STR_MS_T to hold the retrieved stdout buffer.
 * \param[in,out] rei - The RuleExecInfo structure that is automatically
 *    handled by the rule engine. The user does not include rei as a
 *    parameter in the rule invocation.
 *
 * \DolVarDependence none
 * \DolVarModified none
 * \iCatAttrDependence none
 * \iCatAttrModified none
 * \sideeffect none
 *
 * \return integer
 * \retval 0 upon success
 * \pre none
 * \post none
 * \sa none
**/
int
msiGetStdoutInExecCmdOut (msParam_t *inpExecCmdOut, msParam_t *outStr,
ruleExecInfo_t *rei)
{
    char *strPtr;

    rei->status = getStdoutInExecCmdOut (inpExecCmdOut, &strPtr);

    if (rei->status < 0) return rei->status;

    fillStrInMsParam (outStr, strPtr);

    return rei->status;
}
コード例 #11
0
ファイル: eudat.c プロジェクト: EUDAT/B2SAFE-core
/*
 * replace slash "/" symbol in string with an hyphen "_"
 * Input: String with / as absolute address of file ex. /tempZone/DATA/file.txt
 * Output: String with _ ex. _tempZone_DATA_file.txt
 * TODO: is there any better Search-Function after slash in C-library ?
 */
int msiReplaceSlash(msParam_t *inPath, msParam_t *outPath, ruleExecInfo_t *rei)
{
    rei->status = 0;
    char *strad =  parseMspForStr(inPath);
    int length = strlen(strad)+1;
    char *buffer = (char*) malloc(length);
    snprintf(buffer, length, "%s", strad);

    int i;
    for (i = 0; i < length; buffer[i] = buffer[i] == '/' ? '_' : buffer[i], i++)

    fillStrInMsParam (outPath, buffer);
    free(buffer);
    return rei->status;
}
コード例 #12
0
/**
 * \fn msiPropertiesToString( msParam_t *listParam, msParam_t* stringParam, ruleExecInfo_t *rei )
 *
 * \brief Convert a property list into a string buffer.  The property list is left unmodified.
 *
 * \module properties
 *
 * \since pre-2.1
 *
 * \author  David R. Nadeau / University of California, San Diego
 * \date     2007
 *
 * \note Convert a property list into a string buffer.
 *
 * \usage See clients/icommands/test/rules3.0/
 *
 * \param[in] listParam - a KeyValPair_MS_T, the property list
 * \param[out] stringParam - a STR_MS_T, a string buffer
 * \param[in,out] rei - The RuleExecInfo structure that is automatically
 *    handled by the rule engine. The user does not include rei as a
 *    parameter in the rule invocation.
 *
 * \DolVarDependence none
 * \DolVarModified none
 * \iCatAttrDependence none
 * \iCatAttrModified none
 * \sideeffect none
 *
 * \return integer
 * \retval 0 on success
 * \pre none
 * \post none
 * \sa  none
**/
int
msiPropertiesToString( msParam_t *listParam, msParam_t* stringParam, ruleExecInfo_t *rei )
{
	char* string = NULL;

	RE_TEST_MACRO( "    Calling msiPropertiesToString" );

	/* Check parameters */
	if ( strcmp( listParam->type, KeyValPair_MS_T ) != 0 )
		return USER_PARAM_TYPE_ERR;

	/* Create and return string */
	keyValToString( (keyValPair_t*)listParam->inOutStruct, &string );
	fillStrInMsParam( stringParam, string );
	return 0;
}
コード例 #13
0
ファイル: icatGeneralMS.cpp プロジェクト: 0x414A/irods
/**
 * \fn msiGetIcatTime (msParam_t *timeOutParam, msParam_t *typeInParam, ruleExecInfo_t *)
 *
 * \brief   This function returns the system time for the iCAT server
 *
 * \module core
 *
 * \since pre-2.1
 *
 *
 * \usage See clients/icommands/test/rules/
 *
 * \param[out] timeOutParam - a msParam of type STR_MS_T
 * \param[in] typeInParam - a msParam of type STR_MS_T
 *    \li "icat" or "unix" will return seconds since epoch
 *    \li otherwise, human friendly
 * \param[in,out] - The RuleExecInfo structure that is automatically
 *    handled by the rule engine. The user does not include rei as a
 *    parameter in the rule invocation.
 *
 * \DolVarDependence none
 * \DolVarModified none
 * \iCatAttrDependence none
 * \iCatAttrModified none
 * \sideeffect none
 *
 * \return integer
 * \retval 0 on success
 * \pre none
 * \post none
 * \sa none
**/
int
msiGetIcatTime( msParam_t* timeOutParam, msParam_t* typeInParam, ruleExecInfo_t* ) {
    char *type;
    char tStr0[TIME_LEN], tStr[TIME_LEN];
    int i;

    type = ( char* )typeInParam->inOutStruct;

    if ( !strcmp( type, "icat" ) || !strcmp( type, "unix" ) ) {
        getNowStr( tStr );
    }
    else { /* !strcmp(type,"human") */
        getNowStr( tStr0 );
        getLocalTimeFromRodsTime( tStr0, tStr );
    }
    i = fillStrInMsParam( timeOutParam, tStr );
    return i;
}
コード例 #14
0
ファイル: keyValPairMS.cpp プロジェクト: QuarkDoe/irods
/**
 * \fn msiGetValByKey(msParam_t* inKVPair, msParam_t* inKey, msParam_t* outVal, ruleExecInfo_t *rei)
 *
 * \brief  Given a list of KVPairs and a Key, this microservice gets the corresponding value.
 *
 * \module core
 *
 * \since pre-2.1
 *
 *
 * \usage See clients/icommands/test/rules/
 *
 * \param[in] inKVPair - This msParam is of type KeyValPair_PI which is a KeyValPair List.
 * \param[in] inKey - This msParam is of type STR_MS_T which is a key.
 * \param[out] outVal - This msParam is of type STR_MS_T which is a value corresponding to key.
 * \param[in,out] rei - The RuleExecInfo structure that is automatically
 *    handled by the rule engine. The user does not include rei as a
 *    parameter in the rule invocation.
 *
 * \DolVarDependence none
 * \DolVarModified none
 * \iCatAttrDependence none
 * \iCatAttrModified none
 * \sideeffect none
 *
 * \return integer
 * \retval 0 on success
 * \pre none
 * \post none
 * \sa none
**/
int msiGetValByKey( msParam_t* inKVPair, msParam_t* inKey, msParam_t* outVal, ruleExecInfo_t *rei ) {
    keyValPair_t *kvp;
    char *s, *k;

    RE_TEST_MACRO( "msiGetValByKey" );

    kvp = ( keyValPair_t* )inKVPair->inOutStruct;
    k = ( char* )inKey->inOutStruct;
    if ( k == NULL ) {
        k = inKey->label;
    }

    s = getValByKey( kvp, k );
    if ( s == NULL ) {
        return UNMATCHED_KEY_OR_INDEX;
    }
    fillStrInMsParam( outVal, s );
    return 0;
}
コード例 #15
0
ファイル: msiHelper.c プロジェクト: UPPMAX/irods
/**
 * \fn msiGetStderrInExecCmdOut (msParam_t *inpExecCmdOut, msParam_t *outStr, ruleExecInfo_t *rei)
 *
 * \brief Gets stderr buffer from ExecCmdOut into buffer.
 *
 * \module core
 *
 * \since pre-2.1
 *
 * \author Mike Wan 
 * \date 2009   
 *
 * \usage See clients/icommands/test/rules3.0/
 *
 * \param[in] inpExecCmdOut - a STR_MS_T which specifies the ExecCmdOut.
 * \param[out] outStr - a STR_MS_T to hold the retrieved stderr buffer.
 * \param[in,out] rei - The RuleExecInfo structure that is automatically
 *    handled by the rule engine. The user does not include rei as a
 *    parameter in the rule invocation.
 *
 * \DolVarDependence none
 * \DolVarModified none
 * \iCatAttrDependence none
 * \iCatAttrModified none
 * \sideeffect none
 *
 * \return integer
 * \retval 0 upon success
 * \pre none
 * \post none
 * \sa none
**/
int
msiGetStderrInExecCmdOut (msParam_t *inpExecCmdOut, msParam_t *outStr,
ruleExecInfo_t *rei)
{
    char *strPtr = NULL;

    rei->status = getStderrInExecCmdOut (inpExecCmdOut, &strPtr);

    if (rei->status < 0) {
      if (rei->status != SYS_INTERNAL_NULL_INPUT_ERR)
	return rei->status; 
      else {
	strPtr = "";
	rei->status = 0;
      }
    }

    if (strPtr == NULL)
      strPtr="";
    fillStrInMsParam (outStr, strPtr);

    return rei->status;
}
コード例 #16
0
ファイル: nre.systemMS.cpp プロジェクト: leesab/irods
/**
 *\fn msiBytesBufToStr(msParam_t* buf_msp,  msParam_t* str_msp, ruleExecInfo_t *rei)
 *
 * \brief Writes  a bytesBuf_t into a character string
 *
 * \module core
 *
 * \since 3.3
 *
 * \author  Arcot Rajasekar
 * \date    2013-06-10
 *
 * \remark This may blow up if the buffer is not a character string. so be careful
 *
 * \note The string can have length up to BUF_LEN_MS_T
 *
 * \usage
 *
 * testrule||msiBytesBufToStr(*Buff, *St)##writeLine(stdout,*St)|nop
 * ruleExecOut
 *
 * \param[in] buf_msp - a BUF_LEN_MS_T
 * \param[out] str_msp - a STR_MS_T
 * \param[in,out] rei - The RuleExecInfo structure that is automatically
 *    handled by the rule engine. The user does not include rei as a
 *    parameter in the rule invocation.
 *
 * \DolVarDependence none
 * \DolVarModified none
 * \iCatAttrDependence none
 * \iCatAttrModified none
 * \sideeffect none
 *
 * \return integer
 * \retval 0 on success
 * \pre none
 * \post none
 * \sa none
 * \bug  no known bugs
**/
int
msiBytesBufToStr( msParam_t* buf_msp, msParam_t* str_msp, ruleExecInfo_t *rei ) {
    char *outStr;
    bytesBuf_t *inBuf;

    /*check buf_msp */
    if ( buf_msp == NULL && buf_msp->inOutStruct == NULL ) {
        rodsLog( LOG_ERROR, "msiBytesBufToStr: input buf_msp is NULL." );
        return ( USER__NULL_INPUT_ERR );
    }
    inBuf = buf_msp->inpOutBuf;
    if ( inBuf->len < 0 || inBuf->len > ( MAX_SZ_FOR_SINGLE_BUF - 10 ) )  {
        rodsLog( LOG_ERROR, "msiBytesBufToStr: input buf_msp is NULL." );
        return ( USER_INPUT_FORMAT_ERR );
    }
    outStr = ( char * ) malloc( ( inBuf->len + 1 ) );
    outStr[inBuf->len] = '\0';
    strncpy( outStr, ( char * ) inBuf->buf, inBuf->len );
    fillStrInMsParam( str_msp, outStr );
    free( outStr );

    return 0;
}
コード例 #17
0
ファイル: nre.systemMS.cpp プロジェクト: jrandall/irods
/**
 * \fn msiHumanToSystemTime(msParam_t* inpParam, msParam_t* outParam, ruleExecInfo_t *rei)
 *
 * \brief Converts a human readable date to a system timestamp
 *
 * \module framework
 *
 * \since pre-2.1
 *
 *
 * \note Expects an input date in the form: YYYY-MM-DD-hh.mm.ss
 *
 * \usage See clients/icommands/test/rules3.0/
 *
 * \param[in] inpParam - a STR_MS_T containing the input date
 * \param[out] outParam - a STR_MS_T containing the timestamp
 * \param[in,out] rei - The RuleExecInfo structure that is automatically
 *    handled by the rule engine. The user does not include rei as a
 *    parameter in the rule invocation.
 *
 * \DolVarDependence none
 * \DolVarModified none
 * \iCatAttrDependence none
 * \iCatAttrModified none
 * \sideeffect none
 *
 * \return integer
 * \retval 0 on success
 * \pre none
 * \post none
 * \sa none
**/
int
msiHumanToSystemTime( msParam_t* inpParam, msParam_t* outParam, ruleExecInfo_t *rei ) {
    //CID26185: prevent buffer overrun
    char sys_time[TIME_LEN + 1], *hr_time;
    int status;

    /* For testing mode when used with irule --test */
    RE_TEST_MACRO( "    Calling msiHumanToSystemTime" )


    /* microservice check */
    if ( rei == NULL || rei->rsComm == NULL ) {
        rodsLog( LOG_ERROR, "msiHumanToSystemTime: input rei or rsComm is NULL" );
        return SYS_INTERNAL_NULL_INPUT_ERR;
    }


    /* parse inpParam (date input string) */
    if ( ( hr_time = parseMspForStr( inpParam ) ) == NULL ) {
        rodsLog( LOG_ERROR, "msiHumanToSystemTime: parseMspForStr error for input param." );
        return rei->status;
    }


    /* left padding with a zero for DB format. Might change that later */
    memset( sys_time, '\0', TIME_LEN );
    sys_time[0] = '0';


    /* conversion */
    if ( ( status = localToUnixTime( hr_time, &sys_time[1] ) )  == 0 ) {
        status = fillStrInMsParam( outParam, sys_time );
    }


    return status;
}
コード例 #18
0
ファイル: examplesMS.c プロジェクト: DICE-UNC/iRODS-FUSE-Mod
/**
 * Hello world example.
 *
 * @param[in]		name		the name of a person 
 * @param[out]		outParam	the output hello message
 * @param[in,out]	rei		the rule execution information
 * @return				the status code, 0 on success
 */
int
msiHello( msParam_t *name, msParam_t *outParam,
	ruleExecInfo_t *rei )
{
    char *tmpPtr;
    char outStr[MAX_NAME_LEN];

    RE_TEST_MACRO( "    Calling msiHello" );

    tmpPtr = parseMspForStr (name);

    if (tmpPtr == NULL)  {
	rodsLog (LOG_ERROR, "msiHello: missing name input");
	rei->status = USER__NULL_INPUT_ERR;
	return USER__NULL_INPUT_ERR;
    }

    snprintf (outStr, MAX_NAME_LEN, "Hello world from %s", tmpPtr);
    
    fillStrInMsParam (outParam, outStr);

    rei->status = 0;
    return 0;
}
コード例 #19
0
ファイル: nre.systemMS.cpp プロジェクト: leesab/irods
/**
 * \fn msiGetFormattedSystemTime(msParam_t* outParam, msParam_t* inpParam,
 *          msParam_t* inpFormatParam, ruleExecInfo_t *rei)
 *
 * \brief Returns the local system time, formatted
 *
 * \module core
 *
 * \since pre-2.1
 *
 * \author  Romain Guinot
 * \date    2008
 *
 * \note Default output format is system time in seconds. Use 'human' as input
 *       parameter for human readable format.
 *
 * \usage See clients/icommands/test/rules3.0/
 *
 * \param[out] outParam - a STR_MS_T containing the time
 * \param[in] inpParam - Optional - a STR_MS_T containing the desired output format (human)
 * \param[in] inpFormatParam - Optional - a STR_MS_T containing printf formatting (if inpParam was human)
 * \param[in,out] rei - The RuleExecInfo structure that is automatically
 *    handled by the rule engine. The user does not include rei as a
 *    parameter in the rule invocation.
 *
 * \DolVarDependence none
 * \DolVarModified none
 * \iCatAttrDependence none
 * \iCatAttrModified none
 * \sideeffect none
 *
 * \return integer
 * \retval 0 on success
 * \pre none
 * \post none
 * \sa none
**/
int
msiGetFormattedSystemTime( msParam_t* outParam, msParam_t* inpParam,
                           msParam_t* inpFormatParam, ruleExecInfo_t *rei ) {
    char *format;
    char *dateFormat;
    char tStr[TIME_LEN];
    time_t myTime;
    struct tm *mytm;
    int status;

    /* For testing mode when used with irule --test */
    RE_TEST_MACRO( "    Calling msiGetFormattedSystemTime" );


    if ( rei == NULL || rei->rsComm == NULL ) {
        rodsLog( LOG_ERROR,
                 "msiGetFormattedSystemTime: input rei or rsComm is NULL" );
        return ( SYS_INTERNAL_NULL_INPUT_ERR );
    }
    format = ( char* )inpParam->inOutStruct;
    dateFormat = ( char* )inpFormatParam->inOutStruct;

    if ( !format || strcmp( format, "human" ) ) {
        getNowStr( tStr );
    }
    else {
        myTime = time( NULL );
        mytm = localtime( &myTime );

        snprintf( tStr, TIME_LEN, dateFormat,
                  mytm->tm_year + 1900, mytm->tm_mon + 1, mytm->tm_mday,
                  mytm->tm_hour, mytm->tm_min, mytm->tm_sec );
    }
    status = fillStrInMsParam( outParam, tStr );
    return( status );
}
コード例 #20
0
ファイル: hello.cpp プロジェクト: 0x414A/irods
    // =-=-=-=-=-=-=-
    // 1. Write a standard issue microservice
    int irods_hello( msParam_t* _out, ruleExecInfo_t* _rei ) {
        std::string my_str = "Hello World!";
        fillStrInMsParam( _out, my_str.c_str() );

        return 0;
    }
コード例 #21
0
ファイル: reIn2p3SysRule.cpp プロジェクト: dthain/irods
void *startMonScript( void *arg ) {
    /***********************************************************
     * launch Perl script on each server, retrieve the result  *
     * and give it to the rodsMonPerfLog function in order to  *
     * insert it into the database .                           *
     **********************************************************/
    char *output;
    msParam_t msp1, msp2, msp3, msp4, msp5, msout;
    int thrid,  status;
    int retval;

    thrInp_t *tinput = ( thrInp_t* )arg;
#ifndef windows_platform
    pthread_setcancelstate( PTHREAD_CANCEL_ENABLE, NULL );
    pthread_setcanceltype( PTHREAD_CANCEL_ASYNCHRONOUS, NULL );
#endif
    fillStrInMsParam( &msp1, tinput->cmd );
    fillStrInMsParam( &msp2, tinput->cmdArgv );
    fillStrInMsParam( &msp3, tinput->execAddr );
    fillStrInMsParam( &msp4, tinput->hintPath );
    fillIntInMsParam( &msp5, tinput->addPathToArgv );
    thrid = tinput->threadId;

    threadIsAlive[thrid] = 0;
    status = msiExecCmd( &msp1, &msp2, &msp3, &msp4, &msp5, &msout, &( tinput->rei ) );

    if ( status < 0 ) {
        char noanswer[MAXSTR] = MON_OUTPUT_NO_ANSWER;
        rodsLogError( LOG_ERROR, status, "Call to msiExecCmd failed in msiServerMonPerf. " );
        rodsMonPerfLog( tinput->execAddr, tinput->rescName, noanswer, &( tinput->rei ) );
        threadIsAlive[thrid] = 1;
        retval = -1;
#ifndef windows_platform
        pthread_exit( ( void * )&retval );
#endif
    }

    /* if (&msout != NULL) { */
    /* write into the irodsMonPerf log file */
    if ( ( char * )( *( ( execCmdOut_t * ) msout.inOutStruct ) ).stdoutBuf.buf != NULL ) {
        output = ( char * )( *( ( execCmdOut_t * ) msout.inOutStruct ) ).stdoutBuf.buf;
        rodsMonPerfLog( tinput->execAddr, tinput->rescName, output, &( tinput->rei ) );
    }
    else {
        char noanswer[MAXSTR] = MON_OUTPUT_NO_ANSWER;
        rodsLog( LOG_ERROR, "Server monitoring: no output for the server %s, status = %i \n", tinput->execAddr, status );
        rodsMonPerfLog( tinput->execAddr, tinput->rescName, noanswer, &( tinput->rei ) );
        threadIsAlive[thrid] = 1;
        retval = -1;
#ifndef windows_platform
        pthread_exit( ( void * )&retval );
#endif
    }
    /*}
      else {
      char noanswer[MAXSTR] = MON_OUTPUT_NO_ANSWER;
      rodsLog(LOG_ERROR, "Server monitoring: problem with the server %s, status = %i \n", tinput->execAddr, status);
      rodsMonPerfLog(tinput->execAddr, tinput->rescName, noanswer,
      &(tinput->rei));
      threadIsAlive[thrid] = 1;
      retval = -1;
      #ifndef windows_platform
      pthread_exit((void *)&retval);
      #endif
      } */

    threadIsAlive[thrid] = 1;

    retval = 0;
#ifndef windows_platform
    pthread_exit( ( void * )&retval );
#endif
}
コード例 #22
0
    /**
    * \fn msiNcGetDimNameInInqOut (msParam_t *ncInqOutParam, msParam_t *inxParam,
    msParam_t *varNameParam, msParam_t *outParam, ruleExecInfo_t *rei)
    * \brief Get the name of a dimension in a NcInqOut_MS_T
    * \module core
    *
    * \since 3.2
    *
    * \author  Mike Wan
    * \date    2012
    *
    * \usage See clients/icommands/test/rules3.0/netcdfTest1.r, netcdfTest2.r and netcdfTest3.r.
    * \param[in] ncInqOutParam - A NcInqOut_MS_T which is the output of msiNcInq.
    * \param[in] inxParam - An INT_MS_T containing the index of an element in the variable's dimension array
    * \param[in] varNameParam - A STR_MS_T containing the name of a variable
    * \param[out] outParam - A STR_MS_T containing the name of the dimension
    *
    * \DolVarDependence none
    * \DolVarModified none
    * \iCatAttrDependence none
    * \iCatAttrModified none
    * \sideeffect none
    *
    * \return integer
    * \retval 0 upon success
    * \pre N/A
    * \post N/A
    * \sa N/A
    *
    **/
    int
    msiNcGetDimNameInInqOut (msParam_t *ncInqOutParam, msParam_t *inxParam,
    msParam_t *varNameParam, msParam_t *outParam, ruleExecInfo_t *rei)
    {
        ncInqOut_t *ncInqOut;
        int inx, i;
        char *name = NULL;

        RE_TEST_MACRO ("    Calling msiNcGetDimNameInInqOut")

        if (ncInqOutParam == NULL || inxParam == NULL || outParam == NULL)
            return USER__NULL_INPUT_ERR;

        if (strcmp (ncInqOutParam->type, NcInqOut_MS_T) != 0) {
            rodsLog (LOG_ERROR,
              "msiNcGetDimNameInInqOut: ncInqOutParam must be NcInqOut_MS_T. %s",
              ncInqOutParam->type);
            return (USER_PARAM_TYPE_ERR);
        } else {
            ncInqOut = (ncInqOut_t *) ncInqOutParam->inOutStruct;
        }
        inx = parseMspForPosInt (inxParam);
        if (inx < UNLIMITED_DIM_INX || inx >= ncInqOut->ndims) {
            rodsLog (LOG_ERROR,
              "msiNcGetDimNameInInqOut: input inx %d is out of range. ndims  = %d",
              inx, ncInqOut->ndims);
            return NETCDF_VAR_COUNT_OUT_OF_RANGE;
        }

        if (inx == UNLIMITED_DIM_INX) {
            /* get the name of unlimdim */
            if (ncInqOut->unlimdimid < 0) return NETCDF_NO_UNLIMITED_DIM;
            for (i = 0; i < ncInqOut->ndims; i++) {
                if (ncInqOut->unlimdimid == ncInqOut->dim[i].id) {
                    name = ncInqOut->dim[i].name;
                    break;
                }
            }
            if (name == NULL) {
                rodsLog (LOG_ERROR,
                  "msiNcGetDimNameInInqOut: no match for unlimdimid %d",
                  ncInqOut->unlimdimid);
                return NETCDF_NO_UNLIMITED_DIM;
            }
        } else {
            char *varName;
            if (varNameParam == NULL) return USER__NULL_INPUT_ERR;
            if (strcmp (varNameParam->type, STR_MS_T) != 0) {
                rodsLog (LOG_ERROR,
                  "msiNcGetDimNameInInqOut: nameParam must be STR_MS_T. %s",
                  varNameParam->type);
                return (USER_PARAM_TYPE_ERR);
            } else {
                varName = (char*) varNameParam->inOutStruct;
            }
            if (strcmp (varName, "null") == 0) {
                /* use the global for inx */
                name = ncInqOut->dim[inx].name;
            } else {
                /* match the varName first */
                for (i = 0; i < ncInqOut->nvars; i++) {
                    int dimId, j;
                    if (strcmp (varName, ncInqOut->var[i].name) == 0) {
                        /* a match in var name */
                        dimId = ncInqOut->var[i].dimId[inx];
                        /* try to match dimId */
                        for (j = 0; j <  ncInqOut->ndims; j++) {
                            if (ncInqOut->dim[j].id == dimId) {
                                name = ncInqOut->dim[j].name;
                                break;
                            }
                        }
                    }
                }
                if (name == NULL) {
                    rodsLog (LOG_ERROR,
                      "msiNcGetDimNameInInqOut: unmatched varName %s and ix %d",
                      varName, inx);
                    return NETCDF_UNMATCHED_NAME_ERR;
                }
            }
        }
        fillStrInMsParam (outParam, name);

        return 0;
    }
コード例 #23
0
    /**
    * \fn msiNcGetElementInArray (msParam_t *arrayStructParam, msParam_t *indexParam, msParam_t *outParam, ruleExecInfo_t *rei)
    * \brief Get the value of an element in an array. The position of the element in the array is given in the indexParam input.
    * \module core
    *
    * \since 3.2
    *
    * \author  Mike Wan
    * \date    2012
    *
    * \usage See clients/icommands/test/rules3.0/netcdfTest1.r, netcdfTest2.r and netcdfTest3.r.
    * \param[in] indexParam - An INT_MS_T containing the index of an element in the array
    * \param[out] outParam - An INT_MS_T, CHAR_MS_T, STR_MS_T, or DOUBLE_MS_T, etc (depending on the dataType of the array) containing the value of the element).
    *
    * \DolVarDependence none
    * \DolVarModified none
    * \iCatAttrDependence none
    * \iCatAttrModified none
    * \sideeffect none
    *
    * \return integer
    * \retval 0 upon success
    * \pre N/A
    * \post N/A
    * \sa N/A
    *
    **/
    int
    msiNcGetElementInArray (msParam_t *arrayStructParam, msParam_t *indexParam,
    msParam_t *outParam, ruleExecInfo_t *rei)
    {
        int myindex;
        void *myarray;
        int dataType;
        int arrayLen;
        char *charArray;
        int *intArray;
        float *floatArray;
        rodsLong_t *longArray;
        char **strArray;

        RE_TEST_MACRO ("    Calling msiNcGetElementInArray")

        if (arrayStructParam == NULL || indexParam == NULL ||
          outParam == NULL) return USER__NULL_INPUT_ERR;

        if (strcmp (arrayStructParam->type, NcInqWithIdOut_MS_T) == 0) {
            /* intArray for the id array */
            ncInqWithIdOut_t *ncInqWithIdOut;
            ncInqWithIdOut = (ncInqWithIdOut_t *) arrayStructParam->inOutStruct;
            dataType = NC_INT;
            myarray = (void *) ncInqWithIdOut->intArray;
            arrayLen = ncInqWithIdOut->ndim;
        } else if (strcmp (arrayStructParam->type, NcGetVarOut_MS_T) == 0) {
            ncGetVarOut_t *ncGetVarOut;
            ncGetVarOut = (ncGetVarOut_t *) arrayStructParam->inOutStruct;
            if (ncGetVarOut == NULL || ncGetVarOut->dataArray == NULL)
                return USER__NULL_INPUT_ERR;
            dataType = ncGetVarOut->dataArray->type;
            myarray = ncGetVarOut->dataArray->buf;
            arrayLen = ncGetVarOut->dataArray->len;
        } else {
            rodsLog (LOG_ERROR,
              "msiNcGetNumDim: Unsupported input Param type %s",
              arrayStructParam->type);
            return (USER_PARAM_TYPE_ERR);
        }
        myindex = parseMspForPosInt (indexParam);
        if (myindex < 0 || myindex >= arrayLen) {
            rodsLog (LOG_ERROR,
              "msiNcGetElementInArray: input index %d out of range. arrayLen = %d",
              myindex, arrayLen);
            return (NETCDF_DIM_MISMATCH_ERR);
        }

        switch (dataType) {
          case NC_CHAR:
          case NC_BYTE:
          case NC_UBYTE:
            charArray = (char *) myarray;
            fillCharInMsParam (outParam, charArray[myindex]);
            break;
          case NC_STRING:
            strArray = (char **) myarray;
            fillStrInMsParam (outParam, strArray[myindex]);
            break;
          case NC_INT:
          case NC_UINT:
            intArray = (int *) myarray;
            fillIntInMsParam (outParam, intArray[myindex]);
            break;
          case NC_FLOAT:
            floatArray = (float *) myarray;
            fillFloatInMsParam (outParam, floatArray[myindex]);
            break;
          case NC_INT64:
          case NC_UINT64:
          case NC_DOUBLE:
            longArray = (rodsLong_t *) myarray;
            fillDoubleInMsParam (outParam, longArray[myindex]);
            break;
          default:
            rodsLog (LOG_ERROR,
              "msiNcGetElementInArray: Unknow dataType %d", dataType);
            return (NETCDF_INVALID_DATA_TYPE);
        }
        return 0;
    }
コード例 #24
0
ファイル: ASPISMS.c プロジェクト: ericliao/ASPiS
int msiGetShibAttributes(msParam_t *userNameIn, msParam_t *attributesOut, ruleExecInfo_t *rei)
{
    char *userName, *attributes_in;
    int status;
    genQueryInp_t genQueryInp;
    genQueryOut_t genQueryOut;

    int iAttr[10];
    int iAttrVal[10] = {0,0,0,0,0};
    int iCond[10];
    char *condVal[10];
    char v1[BIG_STR];

    char buf0[BIG_STR];
    char buf1[BIG_STR];
    char buf2[BIG_STR];
    char decrypt_key[]="1gCBizHWbwIYyWLoysGzTe6SyzqFKMniZX05faZHWAwQKXf6Fs";

    RE_TEST_MACRO ("    Calling msiGetShibAttributes");

    userName = (char *) userNameIn->inOutStruct;
    
    // from rdaHighLevelRoutines.c + test_genq.c
    // runs a chlGenQuery to retrieve the user_info
    memset (&genQueryInp, 0, sizeof (genQueryInp_t));

    iAttr[0] = COL_USER_INFO;
    genQueryInp.selectInp.inx = iAttr;
    genQueryInp.selectInp.value = iAttrVal;
    genQueryInp.selectInp.len = 1;

    iCond[0] = COL_USER_NAME;
    sprintf(v1,"='%s'", userName);
    condVal[0] = v1;

    genQueryInp.sqlCondInp.inx = iCond;
    genQueryInp.sqlCondInp.value = condVal;
    genQueryInp.sqlCondInp.len = 1;

    genQueryInp.maxRows = 10;
    genQueryInp.continueInx = 0;

    status = chlGenQuery(genQueryInp, &genQueryOut);

    if (status < 0 ) { 
       if (status != CAT_NO_ROWS_FOUND) { 
	      rodsLog (LOG_NOTICE, 
		       "chlGenQuery for %s, status = %d", status);
       }
       return (status);
    }
    
    attributes_in = genQueryOut.sqlResult[0].value;       

    // decode attributes
    strncpy(buf0, attributes_in, BIG_STR);
    strncpy(buf1, decrypt_key, BIG_STR);
    obfDecodeAttrByKey(buf0, buf1, buf2);

    // fills in output parameter with user attributes
    fillStrInMsParam(attributesOut, buf2);   
    status = debugPrint("(1) user", userName);
    status = debugPrint("(2) got attributes", buf2);
	return (status); 
}
コード例 #25
0
ファイル: ASPISMS.c プロジェクト: ericliao/ASPiS
int msiGetObjectPermissions(msParam_t *invokingRuleIn, msParam_t *attributesIn, msParam_t *dataObjectIn, 
                            msParam_t *readPermOut, msParam_t *updatePermOut, msParam_t *deletePermOut, ruleExecInfo_t *rei)
{
    int status, readPermCount, updatePermCount, deletePermCount;
    char *invokingRule, *attributes, *dataObject, *parent;
    char *obj_perms, *obj_current, *this_perm;
    char *cp, *targetedId, *affiliation, *entitlement;
    char this_ent[25]; 
    char this_bools[25];
    char read_bool[6];
    char update_bool[6];
    char delete_bool[6];
    const char delimiter[] = "#";
    const char permission_delimiter[] = "\n";    

    bytesBuf_t *readPerm;
    bytesBuf_t *updatePerm;
    bytesBuf_t *deletePerm;
    bytesBuf_t *mybuf;

    RE_TEST_MACRO ("    Calling msiGetObjectPermissions");    

    invokingRule = (char *) invokingRuleIn->inOutStruct;
    attributes = (char *) attributesIn->inOutStruct;
    dataObject = (char *) dataObjectIn->inOutStruct;

    /* buffer init */
	mybuf = (bytesBuf_t *)malloc(sizeof(bytesBuf_t));
	memset (mybuf, 0, sizeof (bytesBuf_t));

    readPerm = (bytesBuf_t *)malloc(sizeof(bytesBuf_t));
	memset (readPerm, 0, sizeof (bytesBuf_t));
    updatePerm = (bytesBuf_t *)malloc(sizeof(bytesBuf_t));
	memset (updatePerm, 0, sizeof (bytesBuf_t));
    deletePerm = (bytesBuf_t *)malloc(sizeof(bytesBuf_t));
	memset (deletePerm, 0, sizeof (bytesBuf_t));
    
    // split the attributes string into targetedId, affiliation, entitlement
    if (strlen(attributes) > 0) {
        cp = strdup(attributes);
        targetedId = strtok(cp, delimiter);
        affiliation = strtok(NULL, delimiter);
        entitlement = strtok(NULL, delimiter);
    }
    else {
        entitlement = "null";
    }

    // retrieves the read/update/delete permission metadata
    //   example: |readPerm|elta,soapi|updatePerm|elta|deletePerm|elta
    //   based on imeta.c + eraMS.c + eraUtil.c

    // invoking rules
    // - acSetRescSchemeForCreate (upload/update)   - check for parent's 'update' permission
    // - acPreprocForDataObjOpen (download/read)    - check for 'read' permission of object
    // - acPreprocForDataObjOpen (upload/update)    - check for 'update' permission of object
    // - acDataDeletePolicy (delete)                - check for 'delete' permission

    if (strncmp(invokingRule, "acSetRescSchemeForCreate", 24) == 0) {
        // check for parent's permission metadata
        parent = dirname(dataObject);
        getCollectionPSmeta(parent, mybuf, rei->rsComm);
        rodsLog (LOG_NOTICE, "(3) got parent (%s) metadata", parent);
    }
    else {
        if (isColl(rei->rsComm, dataObject, NULL) < 0) {
            // it's a data object        
            getDataObjPSmeta(dataObject, mybuf, rei->rsComm);
            rodsLog (LOG_NOTICE, "(3) got data (%s) metadata", dataObject);
        }
        else {
            // it's a collection object
            getCollectionPSmeta(dataObject, mybuf, rei->rsComm);        
            rodsLog (LOG_NOTICE, "(3) got collection (%s) metadata", dataObject);            
        }
    }       

    readPermCount = 0;
    updatePermCount = 0;
    deletePermCount = 0;

    if (mybuf->buf == NULL)
    {
        appendStrToBBuf(readPerm, "invalid");
        appendStrToBBuf(updatePerm, "invalid");
        appendStrToBBuf(deletePerm, "invalid");

    } else {                
        obj_perms = strdup(mybuf->buf);
        obj_current = strtok(obj_perms, permission_delimiter);        

        while (obj_current != NULL) // while there are more entitlement|bool pairs
        {                       
            // do more parsing
            this_perm = strdup(obj_current);              
            sscanf(this_perm, "|%[^|]|%[^|]", this_ent, this_bools);
            
            // do even more parsing
            if (strstr(entitlement, this_ent)) // found entitlement
            {
                sscanf(this_bools, "%[^,],%[^,],%[^,]", read_bool, update_bool, delete_bool);

                if (strstr(read_bool, "true"))
                {
                    appendStrToBBuf(readPerm, this_ent);
                    appendStrToBBuf(readPerm, ",");
                    readPermCount++;                
                }
                if (strstr(update_bool, "true"))
                {
                    appendStrToBBuf(updatePerm, this_ent);
                    appendStrToBBuf(updatePerm, ",");
                    updatePermCount++;
                }
                if (strstr(delete_bool, "true"))
                {
                    appendStrToBBuf(deletePerm, this_ent);
                    appendStrToBBuf(deletePerm, ",");
                    deletePermCount++;
                }
            }
            obj_current = strtok(NULL, permission_delimiter);
        }        
        free(mybuf->buf);
    }        

    // if no valid user entitlements are found
    if (readPermCount == 0)
       appendStrToBBuf(readPerm, "invalid");
    if (updatePermCount == 0)
       appendStrToBBuf(updatePerm, "invalid"); 
    if (deletePermCount == 0)
       appendStrToBBuf(deletePerm, "invalid");  

    status = debugPrint("... read", readPerm->buf);
    status = debugPrint("... update", updatePerm->buf);
    status = debugPrint("... delete", deletePerm->buf);  

    // fills in output parameters with object permissions
    fillStrInMsParam(readPermOut, readPerm->buf);
    fillStrInMsParam(updatePermOut, updatePerm->buf); 
    fillStrInMsParam(deletePermOut, deletePerm->buf); 

    free(readPerm->buf);
    free(updatePerm->buf);
    free(deletePerm->buf);

    return (status); 
}
コード例 #26
0
ファイル: ASPISMS.c プロジェクト: ericliao/ASPiS
int msiCheckPermissions(msParam_t *attributesIn, msParam_t *readPermIn, msParam_t *updatePermIn, msParam_t *deletePermIn, 
                        msParam_t *invokingRuleIn, msParam_t *decisionOut, ruleExecInfo_t *rei)
{
    int status;
    char *cp, *invokingRule, *attributes, *decision;
    char *cp2, *targetedId, *affiliation, *entitlement, *user, *scope;
    char *readPerm, *updatePerm, *deletePerm;
    const char delimiter[] = "#";
    const char affiliation_delimiter[] = "@";

    RE_TEST_MACRO ("    Calling msiCheckPermissions");

    readPerm = (char *) readPermIn->inOutStruct;
    updatePerm = (char *) updatePermIn->inOutStruct;
    deletePerm = (char *) deletePermIn->inOutStruct;
    attributes = (char *) attributesIn->inOutStruct;
    invokingRule = (char *) invokingRuleIn->inOutStruct;

    // split the attributes string into targetedId, affiliation, entitlement
    if (strlen(attributes) > 0) {
        cp = strdup(attributes);
        targetedId = strtok(cp, delimiter);
        affiliation = strtok(NULL, delimiter);
        entitlement = strtok(NULL, delimiter);

        // split the affiliation into user and scope
        cp2 = strdup(affiliation);
        user = strtok(cp2, affiliation_delimiter);
        scope = strtok(NULL, affiliation_delimiter);
    }
    else {
        targetedId = "null";
        affiliation = "null";
        entitlement = "null";
        user = "******";
        scope = "null";
    }
    
    rodsLog (LOG_NOTICE, "(4) got user attributes");
    status = debugPrint("... targetedId", targetedId);
    status = debugPrint("... affiliation", affiliation);
    status = debugPrint("... entitlement", entitlement);    

    // compares the user attributes with the object metadata
    // splits the entitlement if it's multi-valued
    if (strncmp(affiliation, "null", 4) == 0) {
        // fail if no affiliation
        decision = "invalid_affiliation";
    }
    else if ((strncmp(user, "staff", 5) == 0) ||
            (strncmp(user, "employee", 8) == 0) ||
            (strncmp(user, "student", 7) == 0)) {
        // ok if staff or employee or student affiliation
        if ((strncmp(readPerm, "invalid", 7) == 0) ||
            (strncmp(updatePerm, "invalid", 7) == 0) ||
            (strncmp(deletePerm, "invalid", 7) == 0)) {
            decision = "invalid_perm";
        }
        else {
            if (strncmp(invokingRule, "acSetRescSchemeForCreate", 24) == 0) {
                // invoking: acSetRescSchemeForCreate
                if (compareAttributes(updatePerm, entitlement) == 0)
                    decision = "no_update_perm";
                else
                    decision = "valid_perm";
            }
            else if (strncmp(invokingRule, "acPreprocForDataObjOpen", 23) == 0) {
                // invoking: acPreprocForDataObjOpen
                if (compareAttributes(readPerm, entitlement) == 0)
                {
                    decision = "no_read_perm";
                } else if (compareAttributes(updatePerm, entitlement) == 0) {
                    decision = "no_update_perm";
                } else {
                    decision = "valid_perm"; 
                }
            }
            else if (strncmp(invokingRule, "acDataDeletePolicy", 18) == 0) {
                // invoking: acDataDeletePolicy
                if (compareAttributes(deletePerm, entitlement) == 0)
                    decision = "no_delete_perm";
                else
                    decision = "valid_perm";
            }
        }
    }
    else {
        // fail with other affiliations
        decision = "invalid_affiliation";
    }
 
    status = debugPrint("(5) made decision", decision);

    // fills in output parameter with authorization decision
    fillStrInMsParam(decisionOut, decision);  

	return (status); 
}
コード例 #27
0
ファイル: genQueryMS.cpp プロジェクト: SyBernot/irods
/**
 * \fn msiExecStrCondQueryWithOptions(msParam_t* queryParam,
 *        msParam_t* zeroResultsIsOK,
 *        msParam_t* maxReturnedRowsParam,
 *        msParam_t* genQueryOutParam,
 *        ruleExecInfo_t *rei)
 *
 * \brief   This function takes a given condition string and options, creates an iCAT query, executes it and returns the values
 *
 * \module core
 *
 * \since pre-2.1
 *
 * \author  Romain Guinot
 * \date    2007
 *
 * \usage See clients/icommands/test/rules3.0/
 *
 * \param[in] queryParam - a msParam of type GenQueryInp_MS_T
 * \param[in] zeroResultsIsOK - Optional - a msParam of type STR_MS_T - must equal "zeroOK"
 * \param[in] maxReturnedRowsParam - Optional - a msParam of type STR_MS_T - as integer
 * \param[out] genQueryOutParam - a msParam of type GenQueryOut_MS_T
 * \param[in,out] rei - The RuleExecInfo structure that is automatically
 *    handled by the rule engine. The user does not include rei as a
 *    parameter in the rule invocation.
 *
 * \DolVarDependence none
 * \DolVarModified  none
 * \iCatAttrDependence  none
 * \iCatAttrModified  none
 * \sideeffect  none
 *
 * \return integer
 * \retval 0 on success
 * \pre none
 * \post none
 * \sa  msiExecStrCondQuery
**/
int msiExecStrCondQueryWithOptions( msParam_t* queryParam,
                                    msParam_t* zeroResultsIsOK,
                                    msParam_t* maxReturnedRowsParam,
                                    msParam_t* genQueryOutParam,
                                    ruleExecInfo_t *rei ) {
    genQueryInp_t genQueryInp;
    int i;
    genQueryOut_t *genQueryOut = NULL;
    char *query;
    char *maxReturnedRowsStr;
    int maxReturnedRows;

    query = ( char * ) malloc( strlen( ( const char* )queryParam->inOutStruct ) + 10 + MAX_COND_LEN * 8 );
    strcpy( query, ( const char* ) queryParam->inOutStruct );

    memset( &genQueryInp, 0, sizeof( genQueryInp_t ) );
    i = fillGenQueryInpFromStrCond( query, &genQueryInp );
    if ( i < 0 ) {
        return( i );
    }

    if ( maxReturnedRowsParam != NULL ) {
        maxReturnedRowsStr = ( char * ) maxReturnedRowsParam->inOutStruct;
        if ( strcmp( maxReturnedRowsStr, "NULL" ) != 0 ) {
            maxReturnedRows = atoi( maxReturnedRowsStr );
            genQueryInp.maxRows = maxReturnedRows;
        }
        else {
            genQueryInp.maxRows = MAX_SQL_ROWS;
        }
    }
    else {
        genQueryInp.maxRows = MAX_SQL_ROWS;
    }

    genQueryInp.continueInx = 0;

    i = rsGenQuery( rei->rsComm, &genQueryInp, &genQueryOut );
    if ( zeroResultsIsOK != NULL &&
            strcmp( ( const char* )zeroResultsIsOK->inOutStruct, "zeroOK" ) == 0 ) {
        if ( i < 0 && i != CAT_NO_ROWS_FOUND ) {
            return( i );
        }
        else if ( i == CAT_NO_ROWS_FOUND ) {
            genQueryOutParam->type = strdup( STR_MS_T );
            fillStrInMsParam( genQueryOutParam, "emptySet" );

            return( 0 );
        }
    }
    else {
        if ( i < 0 ) {
            return( i );
        }
    }
    if ( i < 0 ) {
        return( i );
    }
    genQueryOutParam->type = strdup( GenQueryOut_MS_T );
    genQueryOutParam->inOutStruct = genQueryOut;
    return( 0 );
}
コード例 #28
0
static int process_single_obj( rsComm_t *conn, char *parColl, char *fileName,
                               int required_num_replicas, char *grpRescForReplication, char *emailToNotify ) {
    genQueryInp_t genQueryInp;
    int i;
    genQueryOut_t *genQueryOut = NULL;
    sqlResult_t *replNumStruct, *rescStruct, *dataPathStruct, *chkSumStruct;
    char *replNum, *rescName, *dataPathName, *chkSum;
    int t;

    int i1a[10];
    int i1b[10];
    int i2a[10];
    char *condVal[2];
    char v1[200], v2[200];
    char vault_path[2048];

    char *chksum_str = NULL;
    dataObjInp_t myDataObjInp;
    dataObjInfo_t *myDataObjInfo = NULL;
    unregDataObj_t myUnregDataObjInp;
    transferStat_t *transStat = NULL;

    ReplicaCheckStatusStruct *pReplicaStatus;
    int nReplicas;

    char tmpstr[1024];

    int at_least_one_copy_is_good = 0;
    int newN;
    int rn;

    int validKwFlags;
    char *outBadKeyWd;
    msParam_t msGrpRescStr;   /* it can be a single resc name or a paired values. */

    /* fprintf(stderr,"msiAutoReplicateService():process_single_obj()\n");  */

    memset( &genQueryInp, 0, sizeof( genQueryInp_t ) );
    i1a[0] = COL_DATA_REPL_NUM;
    i1b[0] = 0;
    i1a[1] = COL_D_RESC_NAME;
    i1b[1] = 0;
    i1a[2] = COL_D_RESC_GROUP_NAME;
    i1b[2] = 0;
    i1a[3] = COL_D_DATA_PATH;
    i1b[3] = 0;
    i1a[4] = COL_D_DATA_CHECKSUM;
    i1b[4] = 0;
    genQueryInp.selectInp.inx = i1a;
    genQueryInp.selectInp.value = i1b;
    genQueryInp.selectInp.len = 5;

    i2a[0] = COL_COLL_NAME;
    i2a[1] = COL_DATA_NAME;
    genQueryInp.sqlCondInp.inx = i2a;
    sprintf( v1, "='%s'", parColl );
    condVal[0] = v1;
    sprintf( v2, "='%s'", fileName );
    condVal[1] = v2;
    genQueryInp.sqlCondInp.value = condVal;
    genQueryInp.sqlCondInp.len = 2;

    genQueryInp.maxRows = 10;
    genQueryInp.continueInx = 0;
    t = rsGenQuery( conn, &genQueryInp, &genQueryOut );
    if ( t < 0 ) {
        rodsLog( LOG_NOTICE, "msiAutoReplicateService():process_single_obj(): rsGenQuery failed errocode=%d", t );
        if ( t == CAT_NO_ROWS_FOUND ) { /* no data is found */
            return 0;
        }

        return( t );
    }

    if ( genQueryOut->rowCnt <= 0 ) {
        rodsLog( LOG_ERROR, "msiAutoReplicateService():process_single_obj(): return 0 record from calling rsGenQuery() for objid=%s/%s", parColl, fileName );
        return 0;
    }

    nReplicas = genQueryOut->rowCnt;
    pReplicaStatus = ( ReplicaCheckStatusStruct * )calloc( nReplicas, sizeof( ReplicaCheckStatusStruct ) );

    for ( i = 0; i < nReplicas; i++ ) {
        pReplicaStatus[i].registered = 0;
        pReplicaStatus[i].checksum[0] = '\0';
    }

    for ( i = 0; i < genQueryOut->rowCnt; i++ ) {
        replNumStruct = getSqlResultByInx( genQueryOut, COL_DATA_REPL_NUM );
        replNum = &replNumStruct->value[replNumStruct->len * i];
        pReplicaStatus[i].repl_num = atoi( replNum );

        rescStruct = getSqlResultByInx( genQueryOut, COL_D_RESC_NAME );
        rescName = &rescStruct->value[rescStruct->len * i];

        getSqlResultByInx( genQueryOut, COL_D_RESC_GROUP_NAME );

        dataPathStruct = getSqlResultByInx( genQueryOut, COL_D_DATA_PATH );
        dataPathName = &dataPathStruct->value[dataPathStruct->len * i];

        chkSumStruct = getSqlResultByInx( genQueryOut, COL_D_DATA_CHECKSUM );
        chkSum = &chkSumStruct->value[chkSumStruct->len * i];

        vault_path[0] = '\0';
        t = get_resource_path( conn, rescName, vault_path );
        if ( t < 0 ) {
            rodsLog( LOG_NOTICE, "msiAutoReplicateService():process_single_obj():get_resource_path failed, status=%d", t );
            free( pReplicaStatus ); // JMc cppcheck - leak
            return t;
        }

        if ( strncmp( dataPathName, vault_path, strlen( vault_path ) ) != 0 ) {
            /* fprintf(stderr,"AB1-> %s/%s, v=%s, is a registered copy.\n", parColl,fileName, replNum); */
            pReplicaStatus[i].registered = 1;
        }
        else {
            pReplicaStatus[i].registered = 0;
        }

        if ( ( chkSum != NULL ) && ( strlen( chkSum ) > 0 ) ) {
            strcpy( pReplicaStatus[i].checksum, chkSum );
        }
    }
    freeGenQueryOut( &genQueryOut );

    /* check replica status */
    at_least_one_copy_is_good = 0;
    for ( i = 0; i < nReplicas; i++ ) {
        /* check the file existence first */
        memset( &myDataObjInp, 0, sizeof( dataObjInp_t ) );
        snprintf( myDataObjInp.objPath, MAX_NAME_LEN, "%s/%s", parColl, fileName );
        myDataObjInp.openFlags = O_RDONLY;
        sprintf( tmpstr, "%d", pReplicaStatus[i].repl_num );
        addKeyVal( &myDataObjInp.condInput, REPL_NUM_KW, tmpstr );
        rn = pReplicaStatus[i].repl_num;
        t = rsDataObjOpen( conn, &myDataObjInp );
        if ( t < 0 ) {
            /* fprintf(stderr,"%d. %s/%s, %d failed to open and has checksum status=%d\n", i, parColl, fileName, rn, t); */
            if ( t == SYS_OUT_OF_FILE_DESC ) {
                free( pReplicaStatus ); // JMc cppcheck - leak
                return t;
            }
            else {
                pReplicaStatus[i].chksum_status = t;
            }
        }
        else {
            openedDataObjInp_t myDataObjCloseInp;
            memset( &myDataObjCloseInp, 0, sizeof( openedDataObjInp_t ) );
            myDataObjCloseInp.l1descInx = t;
            t = rsDataObjClose( conn, &myDataObjCloseInp );

            chksum_str =  NULL;
            /* compute checksum rsDataObjChksum() */
            memset( &myDataObjInp, 0, sizeof( dataObjInp_t ) );
            sprintf( myDataObjInp.objPath, "%s/%s", parColl, fileName );
            addKeyVal( &myDataObjInp.condInput, FORCE_CHKSUM_KW, "" );
            sprintf( tmpstr, "%d", pReplicaStatus[i].repl_num );
            addKeyVal( &myDataObjInp.condInput, REPL_NUM_KW, tmpstr );
            t = rsDataObjChksum( conn, &myDataObjInp, &chksum_str );
            pReplicaStatus[i].chksum_status = t;     /* t == USER_CHKSUM_MISMATCH means a bad copy */
            /* fprintf(stderr,"%d. %s/%s, %d has checksum status=%d\n", i, parColl, fileName, rn, t); */
            if ( t >= 0 ) {
                if ( strlen( pReplicaStatus[i].checksum ) > 0 ) {
                    if ( strcmp( pReplicaStatus[i].checksum, chksum_str ) != 0 ) { /* mismatch */
                        pReplicaStatus[i].chksum_status = USER_CHKSUM_MISMATCH;
                    }
                    else {
                        at_least_one_copy_is_good = 1;
                    }
                }
                else {
                    at_least_one_copy_is_good = 1;
                }
            }
        }
    }

    /* if there is none good copies left. In some casee, the checksum failed due
       to the fact that the server is down. We leave this case to be taken care of next time. */
    if ( at_least_one_copy_is_good == 0 ) {
        rodsLog( LOG_ERROR, "msiAutoReplicateService():process_single_obj(): Obj='%s/%s': Warning: The system detects that all copies might be corrupted.", parColl, fileName );

#ifndef windows_platform
        if ( ( emailToNotify != NULL ) && ( strlen( emailToNotify ) > 0 ) ) {
            char msg_sub[1024], msg_body[1024];
            strcpy( msg_sub, "iRODS msiAutoReplicateService() error" );
            sprintf( msg_body, "msiAutoReplicateService():process_single_obj(): Obj='%s/%s': at least one storage server is down or all copies are corrupted.",
                     parColl, fileName );
            UnixSendEmail( emailToNotify, msg_sub, msg_body );
        }
#endif

        free( pReplicaStatus ); // JMc cppcheck - leak
        return 0;
    }

    /* since we have at least one copy is good. We delete those bad copies (USER_CHKSUM_MISMATCH). */
    newN = nReplicas;
    for ( i = 0; i < nReplicas; i++ ) {
        memset( &myDataObjInp, 0, sizeof( dataObjInp_t ) );
        sprintf( myDataObjInp.objPath, "%s/%s", parColl, fileName );
        sprintf( tmpstr, "%d", pReplicaStatus[i].repl_num );
        addKeyVal( &myDataObjInp.condInput, REPL_NUM_KW, tmpstr );
        rn = pReplicaStatus[i].repl_num;
        if ( pReplicaStatus[i].registered == 1 ) {
            /* here is the catch. iRODS. */
            int adchksum;
            /* fprintf(stderr,"CD->%s/%s, v=%d, is a registered copy.\n", parColl, fileName, rn); */
            adchksum = ( ( int )( pReplicaStatus[i].chksum_status / 1000 ) ) * 1000;
            if ( ( pReplicaStatus[i].chksum_status == USER_CHKSUM_MISMATCH ) || ( pReplicaStatus[i].chksum_status == UNIX_FILE_OPEN_ERR ) || ( adchksum == UNIX_FILE_OPEN_ERR ) )
                /* USER_CHKSUM_MISMATCH  -> indicates the registered file is changed.
                 * UNIX_FILE_OPEN_ERR --> indicates the registered file is removed by original owner.
                 * -510002 is transformed from UNIX open error.
                 */
            {
                rodsLog( LOG_NOTICE, "msiAutoReplicateService():process_single_obj(): registered copy will be removed: %s, repl=%d", myDataObjInp.objPath, rn );
                t = getDataObjInfo( conn, &myDataObjInp, &myDataObjInfo, NULL, 0 );
                if ( t >= 0 ) {
                    myUnregDataObjInp.dataObjInfo = myDataObjInfo;
                    myUnregDataObjInp.condInput = &myDataObjInp.condInput;
                    t = rsUnregDataObj( conn, &myUnregDataObjInp );
                    if ( t >= 0 ) {
                        newN = newN - 1;
                    }
                    else  {
                        rodsLog( LOG_ERROR, "msiAutoReplicateService():rsUnregDataObj(): failed for %s/%s:%d. erStat=%d", parColl, fileName, rn, t );
                        return t;
                    }
                }
                else {
                    rodsLog( LOG_ERROR, "msiAutoReplicateService():getDataObjInfo(): failed for %s/%s:%d. erStat=%d", parColl, fileName, rn, t );
                    return t;
                }
            }
            else {
                rodsLog( LOG_ERROR, "%s:%d, the registered copy has errored checksum status=%d.", myDataObjInp.objPath, rn, pReplicaStatus[i].chksum_status );
                return t;
            }
        }
        else { /* the data file is in vault */
            if ( pReplicaStatus[i].chksum_status == USER_CHKSUM_MISMATCH ) {
                t = rsDataObjUnlink( conn, &myDataObjInp );
                if ( t >= 0 ) {
                    newN = newN - 1;
                }
                else  {
                    rodsLog( LOG_ERROR, "msiAutoReplicateService():rsDataObjUnlink() for %s:%d failed. errStat=%d", myDataObjInp.objPath, rn, t );
                    free( pReplicaStatus ); // JMc cppcheck - leak
                    return t;
                }
            }
        }
    }

    fillStrInMsParam( &msGrpRescStr, grpRescForReplication );

    /* make necessary copies based on the required number of copies */
    if ( newN < required_num_replicas ) {
        rodsLog( LOG_NOTICE, "msiAutoReplicateService():process_single_obj(): making necessary %d copies as required.", ( required_num_replicas - newN ) );
        for ( i = 0; i < ( required_num_replicas - newN ); i++ ) {
            memset( &myDataObjInp, 0, sizeof( dataObjInp_t ) );
            snprintf( myDataObjInp.objPath, MAX_NAME_LEN, "%s/%s", parColl, fileName );
            /* addKeyVal(&myDataObjInp.condInput, DEST_RESC_NAME_KW, grpRescForReplication); */
            validKwFlags = OBJ_PATH_FLAG | DEST_RESC_NAME_FLAG | NUM_THREADS_FLAG |
                           BACKUP_RESC_NAME_FLAG | RESC_NAME_FLAG | UPDATE_REPL_FLAG |
                           REPL_NUM_FLAG | ALL_FLAG | ADMIN_FLAG | VERIFY_CHKSUM_FLAG |
                           RBUDP_TRANSFER_FLAG | RBUDP_SEND_RATE_FLAG | RBUDP_PACK_SIZE_FLAG;
            t = parseMsKeyValStrForDataObjInp( &msGrpRescStr, &myDataObjInp, DEST_RESC_NAME_KW, validKwFlags, &outBadKeyWd );
            if ( t < 0 ) {
                if ( outBadKeyWd != NULL ) {
                    rodsLog( LOG_ERROR, "msiAutoReplicateService():rsDataObjRepl(): input keyWd - %s error. status = %d", outBadKeyWd, t );
                    free( outBadKeyWd );
                }
                else {
                    rodsLog( LOG_ERROR, "msiAutoReplicateService():rsDataObjRepl(): input msKeyValStr error. status = %d", t );
                }

                free( pReplicaStatus ); // JMc cppcheck - leak
                return t;
            }

            t = rsDataObjRepl( conn, &myDataObjInp, &transStat );
            if ( t < 0 ) {
                rodsLog( LOG_ERROR, "msiAutoReplicateService():rsDataObjRepl() failed for %s/%s:%d into '%s'. err code=%d.", parColl, fileName, rn, grpRescForReplication, t );
                repl_storage_error = 1;
                free( pReplicaStatus ); // JMc cppcheck - leak
                return t;
            }
            if ( transStat != NULL ) {
                free( transStat );
            }
        }
    }

    free( pReplicaStatus ); // JMC cppcheck - leak
    return 0;
}