Example #1
0
int getRescGrpForCreate( rsComm_t *rsComm, dataObjInp_t *dataObjInp, rescGrpInfo_t** myRescGrpInfo ) {
    int            status;
    ruleExecInfo_t rei;

    /* query rcat for resource info and sort it */
    initReiWithDataObjInp( &rei, rsComm, dataObjInp );

    if ( dataObjInp->oprType == REPLICATE_OPR ) { // JMC - backport 4660
        status = applyRule( "acSetRescSchemeForRepl", NULL, &rei, NO_SAVE_REI );

    }
    else {
        status = applyRule( "acSetRescSchemeForCreate", NULL, &rei, NO_SAVE_REI );

    }

    if ( status < 0 ) {
        if ( rei.status < 0 ) {
            status = rei.status;
        }

        rodsLog( LOG_NOTICE, "getRescGrpForCreate:acSetRescSchemeForCreate error for %s,status=%d",
                 dataObjInp->objPath, status );

        return ( status );
    }

    if ( rei.rgi == NULL ) {
        /* def resc group has not been initialized yet */
        // JMC - legacy resource status = setDefaultResc (rsComm, NULL, NULL, &dataObjInp->condInput, myRescGrpInfo );
        //if( !(*myRescGrpInfo) ) {
        ( *myRescGrpInfo ) = new rescGrpInfo_t;
        bzero( ( *myRescGrpInfo ), sizeof( rescGrpInfo_t ) );
        ( *myRescGrpInfo )->rescInfo = new rescInfo_t;
        //}

        irods::error set_err = irods::set_default_resource( rsComm, "", "", &dataObjInp->condInput, *( *myRescGrpInfo ) );
        if ( !set_err.ok() ) {
            irods::log( PASS( set_err ) );
            return SYS_INVALID_RESC_INPUT;
        }

    }
    else {
        *myRescGrpInfo = rei.rgi;
    }

    status = setRescQuota( rsComm, dataObjInp->objPath, myRescGrpInfo, dataObjInp->dataSize );

    if ( status == SYS_RESC_QUOTA_EXCEEDED ) {
        return SYS_RESC_QUOTA_EXCEEDED;
    }

    return 0; // JMC - should this be 1 per above block?
}
Example #2
0
int getRescForCreate( rsComm_t *rsComm, dataObjInp_t *dataObjInp, std::string& _resc_name ) {
    int            status;
    ruleExecInfo_t rei;

    /* query rcat for resource info and sort it */
    initReiWithDataObjInp( &rei, rsComm, dataObjInp );

    if ( dataObjInp->oprType == REPLICATE_OPR ) { // JMC - backport 4660
        status = applyRule( "acSetRescSchemeForRepl", NULL, &rei, NO_SAVE_REI );

    }
    else {
        status = applyRule( "acSetRescSchemeForCreate", NULL, &rei, NO_SAVE_REI );

    }

    if ( status < 0 ) {
        if ( rei.status < 0 ) {
            status = rei.status;
        }

        rodsLog( LOG_NOTICE, "getRescForCreate:acSetRescSchemeForCreate error for %s,status=%d",
                 dataObjInp->objPath, status );

        return status;
    }

    // get resource name
    if ( !strlen( rei.rescName ) ) {
        irods::error set_err = irods::set_default_resource( rsComm, "", "", &dataObjInp->condInput, _resc_name );

        if ( !set_err.ok() ) {
            irods::log( PASS( set_err ) );
            return SYS_INVALID_RESC_INPUT;
        }
    }
    else {
        _resc_name = rei.rescName;
    }

#if 0	// #1472
    status = setRescQuota( rsComm, dataObjInp->objPath, myRescGrpInfo, dataObjInp->dataSize );

    if ( status == SYS_RESC_QUOTA_EXCEEDED ) {
        if ( rei.rgi == NULL ) {
            delete( *myRescGrpInfo )->rescInfo;
            delete( *myRescGrpInfo );
            *myRescGrpInfo = NULL;
        }
        return SYS_RESC_QUOTA_EXCEEDED;
    }
#endif

    return 0; // JMC - should this be 1 per above block?
}
Example #3
0
int
chkPreProcDeleteRule (rsComm_t *rsComm, dataObjInp_t *dataObjUnlinkInp,
dataObjInfo_t *dataObjInfoHead)
{
    dataObjInfo_t *tmpDataObjInfo;
    ruleExecInfo_t rei;
    int status = 0;

    initReiWithDataObjInp (&rei, rsComm, dataObjUnlinkInp);
    tmpDataObjInfo = dataObjInfoHead;
    while (tmpDataObjInfo != NULL) {
        /* have to go through the loop to test each copy (resource). */
        rei.doi = tmpDataObjInfo;

        status = applyRule ("acDataDeletePolicy", NULL, &rei, NO_SAVE_REI);

        if (status < 0 && status != NO_MORE_RULES_ERR &&
          status != SYS_DELETE_DISALLOWED) {
            rodsLog (LOG_ERROR,
              "chkPreProcDeleteRule: acDataDeletePolicy err for %s. stat = %d",
              dataObjUnlinkInp->objPath, status);
            return (status);
        }

        if (rei.status == SYS_DELETE_DISALLOWED) {
            rodsLog (LOG_ERROR,
            "chkPreProcDeleteRule:acDataDeletePolicy disallowed delete of %s",
              dataObjUnlinkInp->objPath);
            return (rei.status);
        }
        tmpDataObjInfo = tmpDataObjInfo->next;
    }
    return status;
}
Example #4
0
int
applyPreprocRuleForOpen( rsComm_t *rsComm, dataObjInp_t *dataObjInp,
                         dataObjInfo_t **dataObjInfoHead ) {
    int status;
    ruleExecInfo_t rei;

    initReiWithDataObjInp( &rei, rsComm, dataObjInp );
    rei.doi = *dataObjInfoHead;

    // make resource properties available as rule session variables
    irods::get_resc_properties_as_kvp(rei.doi->rescHier, rei.condInputData);

    status = applyRule( "acPreprocForDataObjOpen", NULL, &rei, NO_SAVE_REI );
    clearKeyVal(rei.condInputData);
    free(rei.condInputData);

    if ( status < 0 ) {
        if ( rei.status < 0 ) {
            status = rei.status;
        }
        rodsLog( LOG_ERROR,
                 "applyPreprocRuleForOpen:acPreprocForDataObjOpen error for %s,stat=%d",
                 dataObjInp->objPath, status );
    }
    else {
        *dataObjInfoHead = rei.doi;
    }
    return status;
}
bool QMetaCodeGenerator::grammar(QVariantConstPtr input, QString& output, ParseErrorPtr &pe)
{
    ENTRYV(*input);

    EXPECT(input->type() == QVariant::List);

    {
        const QVariantList& l = input->value<QVariantList>();

        EXPECT(l.count() == 3);

        EXPECT(thisStr(&l[0], "GRAMMAR", cpe));

        {
            QVariant str;
            EXPECT(string(&l[1], str, cpe));

            const QVariantList& inp2 = l[2].value<QVariantList>();

            QVariantList rules;

            foreach(const QVariant& inp, inp2) {
                QString rule;
                EXPECT(applyRule(RULE, &inp, rule, cpe));
                rules.append(rule);
            }
        }
    }
Example #6
0
bool TextStyleBuilder::addFeatureCommon(const Feature& _feat, const DrawRule& _rule, bool _iconText) {
    TextStyle::Parameters params = applyRule(_rule, _feat.props, _iconText);

    Label::Type labelType;
    if (_feat.geometryType == GeometryType::lines) {
        labelType = Label::Type::line;
        params.wordWrap = false;
    } else {
        labelType = Label::Type::point;
    }

    // Keep start position of new quads
    size_t quadsStart = m_quads.size();
    size_t numLabels = m_labels.size();

    if (!prepareLabel(params, labelType)) { return false; }

    if (_feat.geometryType == GeometryType::points) {
        for (auto& point : _feat.points) {
            auto p = glm::vec2(point);
            addLabel(params, Label::Type::point, { p, p });
        }

    } else if (_feat.geometryType == GeometryType::polygons) {
        for (auto& polygon : _feat.polygons) {
            if (_iconText) {
                auto p = centroid(polygon);
                addLabel(params, Label::Type::point, { p, p });
            } else {
                for (auto& line : polygon) {
                    for (auto& point : line) {
                        auto p = glm::vec2(point);
                        addLabel(params, Label::Type::point, { p });
                    }
                }
            }
        }

    } else if (_feat.geometryType == GeometryType::lines) {

        if (_iconText) {
            for (auto& line : _feat.lines) {
                for (auto& point : line) {
                    auto p = glm::vec2(point);
                    addLabel(params, Label::Type::point, { p });
                }
            }
        } else {
            addLineTextLabels(_feat, params);
        }
    }

    if (numLabels == m_labels.size()) {
        // Drop quads when no label was added
        m_quads.resize(quadsStart);
    }
    return true;
}
void TextStyleBuilder::addPoint(const Point& _point, const Properties& _props, const DrawRule& _rule) {

    TextStyle::Parameters params = applyRule(_rule, _props);

    if (!params.isValid()) { return; }

    if (!m_builder.prepareLabel(m_style.fontContext(), params)) { return; }

    m_builder.addLabel(params, Label::Type::point, { glm::vec2(_point), glm::vec2(_point) });
}
Example #8
0
int
_rsRmCollRecur( rsComm_t *rsComm, collInp_t *rmCollInp,
                collOprStat_t **collOprStat ) {
    int status;
    ruleExecInfo_t rei;
    int trashPolicy;
    dataObjInfo_t *dataObjInfo = NULL;
    /* check for specColl and permission */
    status = resolvePathInSpecColl( rsComm, rmCollInp->collName,
                                    WRITE_COLL_PERM, 0, &dataObjInfo );

    if ( status < 0 && status != CAT_NO_ROWS_FOUND ) {
        return status;
    }
    if ( status == COLL_OBJ_T && dataObjInfo->specColl != NULL &&
            dataObjInfo->specColl->collClass == LINKED_COLL ) {
        rstrcpy( rmCollInp->collName, dataObjInfo->objPath,
                 MAX_NAME_LEN );
        free( dataObjInfo->specColl );
        dataObjInfo->specColl = NULL;
    }
    if ( status != COLL_OBJ_T || dataObjInfo->specColl == NULL ) {
        /* a normal coll */
        if ( rmCollInp->oprType != UNREG_OPR &&
                getValByKey( &rmCollInp->condInput, FORCE_FLAG_KW ) == NULL &&
                getValByKey( &rmCollInp->condInput, RMTRASH_KW ) == NULL &&
                getValByKey( &rmCollInp->condInput, ADMIN_RMTRASH_KW ) == NULL ) {
            initReiWithDataObjInp( &rei, rsComm, NULL );
            status = applyRule( "acTrashPolicy", NULL, &rei, NO_SAVE_REI );
            trashPolicy = rei.status;
            if ( trashPolicy != NO_TRASH_CAN ) {
                status = rsMvCollToTrash( rsComm, rmCollInp );
                if ( status >= 0 && collOprStat != NULL ) {
                    if ( *collOprStat == NULL ) {
                        *collOprStat = ( collOprStat_t* )malloc( sizeof( collOprStat_t ) );
                        memset( *collOprStat, 0, sizeof( collOprStat_t ) );
                    }
                    ( *collOprStat )->filesCnt = 1;
                    ( *collOprStat )->totalFileCnt = 1;
                    rstrcpy( ( *collOprStat )->lastObjPath, rmCollInp->collName,
                             MAX_NAME_LEN );
                }
                return status;
            }
        }
    }
    /* got here. will recursively phy delete the collection */
    status = _rsPhyRmColl( rsComm, rmCollInp, dataObjInfo, collOprStat );

    if ( dataObjInfo != NULL ) {
        freeDataObjInfo( dataObjInfo );
    }
    return status;
}
Example #9
0
void TextStyle::buildPoint(const Point& _point, const DrawRule& _rule, const Properties& _props,
                           VboMesh& _mesh, Tile& _tile) const {

    auto& buffer = static_cast<TextBuffer&>(_mesh);

    Parameters params = applyRule(_rule, _props);

    if (!params.visible || !params.isValid()) { return; }

    buffer.addLabel(params, { glm::vec2(_point), glm::vec2(_point) },
                    Label::Type::point, *m_fontContext);
}
Example #10
0
int
chkRescQuotaPolicy( rsComm_t *rsComm ) {
    int status;
    ruleExecInfo_t rei;

    if ( RescQuotaPolicy == RESC_QUOTA_UNINIT ) {
        initReiWithDataObjInp( &rei, rsComm, NULL );
        status = applyRule( "acRescQuotaPolicy", NULL, &rei, NO_SAVE_REI );
        if ( status < 0 ) {
            rodsLog( LOG_ERROR,
                     "queRescQuota: acRescQuotaPolicy error status = %d", status );
            RescQuotaPolicy = RESC_QUOTA_OFF;
        }
    }
    return RescQuotaPolicy;
}
Example #11
0
void TextStyle::buildLine(const Line& _line, const DrawRule& _rule, const Properties& _props,
        VboMesh& _mesh, Tile& _tile) const {

    auto& buffer = static_cast<TextBuffer&>(_mesh);

    Parameters params = applyRule(_rule, _props);

    if (!params.visible || !params.isValid()) { return; }

    for (size_t i = 0; i < _line.size() - 1; i++) {
        glm::vec2 p1 = glm::vec2(_line[i]);
        glm::vec2 p2 = glm::vec2(_line[i + 1]);

        buffer.addLabel(params, { p1, p2 }, Label::Type::line, *m_fontContext);
    }
}
Example #12
0
/* Runs a loop checking each rule in each orientation in each valid
 * position on the grid, checking if the rule applies, and, if so,
 * applying it, and continue updating them until there are no longer
 * any changes being made. */
void Solver::applyRules(int selectedRules[]) {
    while (grid_->getUpdated()) {
        grid_->setUpdated(false);
        for (int i = 0; i < grid_->getHeight(); i++) {
            for (int j = 0; j < grid_->getWidth(); j++) {
                if (grid_->getUpdateMatrix(i, j)) {
                    for (int x = 0; x < selectLength_; x++) {
                        for (Orientation orient : (Orientation[]){ UP, DOWN, LEFT, RIGHT, UPFLIP, DOWNFLIP, LEFTFLIP, RIGHTFLIP }) {
                            if (ruleApplies(i, j, rules_[selectedRules[x]], orient)) {
                                applyRule(i, j, rules_[selectedRules[x]], orient);
                            }
                        }
                    }
                }
                grid_->setUpdateMatrix(i, j, false);
            }
        }
    }
}
Example #13
0
void PointStyleBuilder::addPoint(const Point& _point, const Properties& _props,
                                 const DrawRule& _rule) {

    PointStyle::Parameters p = applyRule(_rule, _props);
    glm::vec4 uvsQuad;

    if (!getUVQuad(p, uvsQuad)) {
        return;
    }

    Label::Transform transform = { glm::vec2(_point) };

    addLabel(transform, p.size, *m_mesh, m_vertices.size(),
             p.labelOptions, p.extrudeScale, p.anchor);

    pushQuad(m_vertices, p.size,
             {uvsQuad.x, uvsQuad.y},
             {uvsQuad.z, uvsQuad.w},
             p.color, p.extrudeScale);
}
Example #14
0
LSystem::LSystem(char* s)
{
	string = new char[strlen(s)];
	strcpy(string, s);
	printf("Initializing LSystem using %s\n",string);
	for(int j = 0; j < numRecursions; j++)
	{
		for(int i = 0; i < strlen(string); i++)
		{
			for(int k = 0; k < strlen(conditions); k++)
			{
				if(string[i] == conditions[k]) {
					applyRule(i,k);
					i = i + strlen(rules[k]) - 1;
				}
			}
		}
	}
	generateLines();
}
Example #15
0
int
_rsTicketAdmin(rsComm_t *rsComm, ticketAdminInp_t *ticketAdminInp )
{
    int status;
    if (strcmp(ticketAdminInp->arg1,"session")==0 ) {
       ruleExecInfo_t rei;

       memset((char*)&rei,0,sizeof(rei));
       rei.rsComm = rsComm;
       rei.uoic = &rsComm->clientUser;
       rei.uoip = &rsComm->proxyUser;
       status = applyRule("acTicketPolicy", NULL, &rei, NO_SAVE_REI);
       rodsLog(LOG_DEBUG, "debug ticket rule status:%d", status);
       if (status != 0) return(status);
    }
    status = chlModTicket(rsComm, ticketAdminInp->arg1, 
			  ticketAdminInp->arg2, ticketAdminInp->arg3, 
			  ticketAdminInp->arg4, ticketAdminInp->arg5);
    return(status);
}
Example #16
0
void PointStyleBuilder::addPolygon(const Polygon& _polygon, const Properties& _props,
                                   const DrawRule& _rule) {

    PointStyle::Parameters p = applyRule(_rule, _props);
    glm::vec4 uvsQuad;

    if (!getUVQuad(p, uvsQuad)) {
        return;
    }

    if (!p.centroid) {

        int size = 0;
        for (auto line : _polygon) { size += line.size(); }

        for (auto line : _polygon) {
            for (auto point : line) {
                Label::Transform transform = { glm::vec2(point) };

                addLabel(transform, p.size, *m_mesh, m_vertices.size(),
                         p.labelOptions, p.extrudeScale, p.anchor);

                pushQuad(m_vertices, p.size,
                         {uvsQuad.x, uvsQuad.y},
                         {uvsQuad.z, uvsQuad.w},
                         p.color, p.extrudeScale);
            }
        }
    } else {
        glm::vec2 c = centroid(_polygon);
        Label::Transform transform = { c };

        addLabel(transform, p.size, *m_mesh, m_vertices.size(),
                 p.labelOptions, p.extrudeScale, p.anchor);

        pushQuad(m_vertices, p.size,
                 {uvsQuad.x, uvsQuad.y},
                 {uvsQuad.z, uvsQuad.w},
                 p.color, p.extrudeScale);
    }
}
Example #17
0
int
applyRuleForPostProcForRead( rsComm_t *rsComm, bytesBuf_t *dataObjReadOutBBuf, char *objPath ) {
    if ( ReadWriteRuleState != ON_STATE ) {
        return 0;
    }

    ruleExecInfo_t rei2;
    memset( ( char* )&rei2, 0, sizeof( ruleExecInfo_t ) );
    msParamArray_t msParamArray;
    memset( ( char* )&msParamArray, 0, sizeof( msParamArray_t ) );

    if ( rsComm != NULL ) {
        rei2.rsComm = rsComm;
        rei2.uoic = &rsComm->clientUser;
        rei2.uoip = &rsComm->proxyUser;
    }
    rei2.doi = ( dataObjInfo_t* )mallocAndZero( sizeof( dataObjInfo_t ) );
    snprintf( rei2.doi->objPath, sizeof( rei2.doi->objPath ), "%s", objPath );

    memset( &msParamArray, 0, sizeof( msParamArray ) );
    int * myInOutStruct = ( int* )malloc( sizeof( int ) );
    *myInOutStruct = dataObjReadOutBBuf->len;
    addMsParamToArray( &msParamArray, "*ReadBuf", BUF_LEN_MS_T, myInOutStruct,
                       dataObjReadOutBBuf, 0 );
    int status = applyRule( "acPostProcForDataObjRead(*ReadBuf)", &msParamArray, &rei2,
                    NO_SAVE_REI );
    free( rei2.doi );
    if ( status < 0 ) {
        if ( rei2.status < 0 ) {
            status = rei2.status;
        }
        rodsLog( LOG_ERROR,
                 "rsDataObjRead: acPostProcForDataObjRead error=%d", status );
        clearMsParamArray( &msParamArray, 0 );
        return status;
    }
    clearMsParamArray( &msParamArray, 0 );

    return 0;

}
Example #18
0
int
chkPreProcDeleteRule( rsComm_t *rsComm, dataObjInp_t *dataObjUnlinkInp,
                      dataObjInfo_t *dataObjInfoHead ) {
    dataObjInfo_t *tmpDataObjInfo;
    ruleExecInfo_t rei;
    int status = 0;

    initReiWithDataObjInp( &rei, rsComm, dataObjUnlinkInp );
    tmpDataObjInfo = dataObjInfoHead;
    while ( tmpDataObjInfo != NULL ) {
        /* have to go through the loop to test each copy (resource). */
        rei.doi = tmpDataObjInfo;

        // make resource properties available as rule session variables
        rei.condInputData = (keyValPair_t *)malloc(sizeof(keyValPair_t));
        memset(rei.condInputData, 0, sizeof(keyValPair_t));
        irods::get_resc_properties_as_kvp(rei.doi->rescHier, rei.condInputData);

        status = applyRule( "acDataDeletePolicy", NULL, &rei, NO_SAVE_REI );

        if ( status < 0 && status != NO_MORE_RULES_ERR &&
                status != SYS_DELETE_DISALLOWED ) {
            rodsLog( LOG_ERROR,
                     "chkPreProcDeleteRule: acDataDeletePolicy err for %s. stat = %d",
                     dataObjUnlinkInp->objPath, status );
            return status;
        }

        if ( rei.status == SYS_DELETE_DISALLOWED ) {
            rodsLog( LOG_ERROR,
                     "chkPreProcDeleteRule:acDataDeletePolicy disallowed delete of %s",
                     dataObjUnlinkInp->objPath );
            return rei.status;
        }
        tmpDataObjInfo = tmpDataObjInfo->next;
    }
    return status;
}
Example #19
0
int
filePathReg (rsComm_t *rsComm, dataObjInp_t *phyPathRegInp, char *filePath, 
rescInfo_t *rescInfo)
{
    dataObjInfo_t dataObjInfo;
    int status;

    initDataObjInfoWithInp (&dataObjInfo, phyPathRegInp);
    dataObjInfo.replStatus = NEWLY_CREATED_COPY;
    dataObjInfo.rescInfo = rescInfo;
    rstrcpy (dataObjInfo.rescName, rescInfo->rescName, NAME_LEN);

    if (dataObjInfo.dataSize <= 0 && 
      (dataObjInfo.dataSize = getSizeInVault (rsComm, &dataObjInfo)) < 0) {
	status = (int) dataObjInfo.dataSize;
        rodsLog (LOG_ERROR,
         "filePathReg: getSizeInVault for %s failed, status = %d",
          dataObjInfo.objPath, status);
	return (status);
    }

    status = svrRegDataObj (rsComm, &dataObjInfo);
    if (status < 0) {
        rodsLog (LOG_ERROR,
         "filePathReg: rsRegDataObj for %s failed, status = %d",
          dataObjInfo.objPath, status);
    } else {
        ruleExecInfo_t rei;
        initReiWithDataObjInp (&rei, rsComm, phyPathRegInp);
	rei.doi = &dataObjInfo;
	rei.status = status;
        rei.status = applyRule ("acPostProcForFilePathReg", NULL, &rei,
          NO_SAVE_REI);
    }

    return (status);
}
void TextStyleBuilder::addLine(const Line& _line, const Properties& _props, const DrawRule& _rule) {

    TextStyle::Parameters params = applyRule(_rule, _props);

    if (!params.isValid()) { return; }

    // Not yet supported for line labels
    params.wordWrap = false;

    if (!m_builder.prepareLabel(m_style.fontContext(), params)) { return; }

    // Check if any line segment is long enough for the label
    // when the tile is magnified to 2 zoom-levels above (=> 0.25)
    float pixel = 1.0 / (m_tileSize * m_style.pixelScale());
    float minLength = m_builder.labelWidth() * pixel * 0.25;

    for (size_t i = 0; i < _line.size() - 1; i++) {
        glm::vec2 p1 = glm::vec2(_line[i]);
        glm::vec2 p2 = glm::vec2(_line[i + 1]);
        if (glm::length(p1-p2) > minLength) {
            m_builder.addLabel(params, Label::Type::line, { p1, p2 });
        }
    }
}
Example #21
0
int
_rsGenQuery (rsComm_t *rsComm, genQueryInp_t *genQueryInp,
	     genQueryOut_t **genQueryOut)
{
    int status;

    static int ruleExecuted=0;
    ruleExecInfo_t rei;
    static int ruleResult=0;


    static int PrePostProcForGenQueryFlag = -2;    
    int i, argc;
    ruleExecInfo_t rei2;
    char *args[MAX_NUM_OF_ARGS_IN_ACTION];
    
    if (PrePostProcForGenQueryFlag < 0) {
      if (getenv("PREPOSTPROCFORGENQUERYFLAG") != NULL)
	PrePostProcForGenQueryFlag = 1;
      else
	PrePostProcForGenQueryFlag = 0;
    }

    memset ((char*)&rei2, 0, sizeof (ruleExecInfo_t));
    rei2.rsComm = rsComm;
    if (rsComm != NULL) {
      rei2.uoic = &rsComm->clientUser;
      rei2.uoip = &rsComm->proxyUser;
    }

    /*  printGenQI(genQueryInp);  for debug */

    *genQueryOut = (genQueryOut_t*)malloc(sizeof(genQueryOut_t));
    memset((char *)*genQueryOut, 0, sizeof(genQueryOut_t));

    if (ruleExecuted==0) {
#if 0
       msParam_t *outMsParam;
#endif
       memset((char*)&rei,0,sizeof(rei));
       rei.rsComm = rsComm;
       if (rsComm != NULL) {
          /* Include the user info for possible use by the rule.  Note
	     that when this is called (as the agent is initializing),
	     this user info is not confirmed yet.  For password
	     authentication though, the agent will soon exit if this
	     is not valid.  But tor GSI, the user information may not
	     be present and/or may be changed when the authentication
	     completes, so it may not be safe to use this in a GSI
	     enabled environment.  This addition of user information
	     was requested by ARCS/IVEC (Sean Fleming) to avoid a
	     local patch.
          */
	  rei.uoic = &rsComm->clientUser;
	  rei.uoip = &rsComm->proxyUser;
       }
#ifdef RULE_ENGINE_N
       if (getRuleEngineStatus() == UNINITIALIZED) { 
          /* Skip the call to run acAclPolicy if the Rule Engine
             hasn't been initialized yet, which happens for a couple
             initial queries made by the agent when starting up.  The
             new RE logs these types of errors and so this avoids that.
          */
          status = -1;
       }
       else 
#endif
       {
          status = applyRule ("acAclPolicy", NULL, &rei, NO_SAVE_REI);
          ruleResult = rei.status;
       }
       if (status==0) {
	  ruleExecuted=1; /* No need to retry next time since it
                             succeeded.  Since this is called at
                             startup, the Rule Engine may not be
                             initialized yet, in which case the
                             default setting is fine and we should
                             retry next time. */
#if 0
	  /* No longer need this as msiAclPolicy calls
	     chlGenQueryAccessControlSetup to set the flag.  Leaving
	     it in the code for now in case needed later. */
	  outMsParam = getMsParamByLabel(&rei.inOutMsParamArray, "STRICT");
	  printf("outMsParam=%x\n",(int)outMsParam);
	  if (outMsParam != NULL) {
	     ruleResult=1;
	  }
#endif
       }
#if 0
       printf("rsGenQuery rule status=%d ruleResult=%d\n",status,ruleResult);
#endif
    }

    chlGenQueryAccessControlSetup(rsComm->clientUser.userName, 
			      rsComm->clientUser.rodsZone,
			      rsComm->clientAddr,
	 		      rsComm->clientUser.authInfo.authFlag,
			      -1);
#if 0
    rodsLog (LOG_NOTICE, 
	     "_rsGenQuery debug: client %s %d proxy %s %d", 
	     rsComm->clientUser.userName, 
	     rsComm->clientUser.authInfo.authFlag,
	     rsComm->proxyUser.userName, 
	     rsComm->proxyUser.authInfo.authFlag);
#endif
    /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/
    if (PrePostProcForGenQueryFlag == 1) {
      args[0] = (char *) malloc(300);
      sprintf(args[0],"%ld",(long) genQueryInp);
      argc = 1;
      i =  applyRuleArg("acPreProcForGenQuery",args,argc, &rei2, NO_SAVE_REI);
      free(args[0]);
      if (i < 0) {
	rodsLog (LOG_ERROR,
		 "rsGenQuery:acPreProcForGenQuery error,stat=%d", i);
        if (i != NO_MICROSERVICE_FOUND_ERR)
	  return i;
      }
    }
    /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/

    status = chlGenQuery(*genQueryInp, *genQueryOut);

    /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/
    if (PrePostProcForGenQueryFlag == 1) {
      args[0] = (char *) malloc(300);
      args[1] = (char *) malloc(300);
      args[2] = (char *) malloc(300);
      sprintf(args[0],"%ld",(long) genQueryInp);
      sprintf(args[1],"%ld",(long) *genQueryOut);
      sprintf(args[2],"%d",status);
      argc = 3;
      i =  applyRuleArg("acPostProcForGenQuery",args,argc, &rei2, NO_SAVE_REI);
      free(args[0]);
      free(args[1]);
      free(args[2]);
      if (i < 0) {
        rodsLog (LOG_ERROR,
                 "rsGenQuery:acPostProcForGenQuery error,stat=%d", i);
	if (i != NO_MICROSERVICE_FOUND_ERR)
	  return i;
      }
    }
    /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/

    if (status < 0) {
       clearGenQueryOut (*genQueryOut);
       free (*genQueryOut);
       *genQueryOut = NULL;
       if (status != CAT_NO_ROWS_FOUND) {
	  rodsLog (LOG_NOTICE, 
		   "_rsGenQuery: genQuery status = %d", status);
       }
       return (status);
    }
    return (status);
} 
Example #22
0
int
_rsGenQuery( rsComm_t *rsComm, genQueryInp_t *genQueryInp,
             genQueryOut_t **genQueryOut ) {
    int status;

    static int ruleExecuted = 0;
    ruleExecInfo_t rei;


    static int PrePostProcForGenQueryFlag = -2;
    int i, argc;
    ruleExecInfo_t rei2;
    char *args[MAX_NUM_OF_ARGS_IN_ACTION];

    if ( PrePostProcForGenQueryFlag < 0 ) {
        if ( getenv( "PREPOSTPROCFORGENQUERYFLAG" ) != NULL ) {
            PrePostProcForGenQueryFlag = 1;
        }
        else {
            PrePostProcForGenQueryFlag = 0;
        }
    }

    memset( ( char* )&rei2, 0, sizeof( ruleExecInfo_t ) );
    rei2.rsComm = rsComm;
    if ( rsComm != NULL ) {
        rei2.uoic = &rsComm->clientUser;
        rei2.uoip = &rsComm->proxyUser;
    }

    /*  printGenQI(genQueryInp);  for debug */

    *genQueryOut = ( genQueryOut_t* )malloc( sizeof( genQueryOut_t ) );
    memset( ( char * )*genQueryOut, 0, sizeof( genQueryOut_t ) );

    if ( ruleExecuted == 0 ) {
        memset( ( char* )&rei, 0, sizeof( rei ) );
        rei.rsComm = rsComm;
        if ( rsComm != NULL ) {
            /* Include the user info for possible use by the rule.  Note
            that when this is called (as the agent is initializing),
            this user info is not confirmed yet.  For password
            authentication though, the agent will soon exit if this
            is not valid.  But tor GSI, the user information may not
            be present and/or may be changed when the authentication
            completes, so it may not be safe to use this in a GSI
            enabled environment.  This addition of user information
            was requested by ARCS/IVEC (Sean Fleming) to avoid a
            local patch.
            */
            rei.uoic = &rsComm->clientUser;
            rei.uoip = &rsComm->proxyUser;
        }

        if ( getRuleEngineStatus() == UNINITIALIZED ) {
            /* Skip the call to run acAclPolicy if the Rule Engine
               hasn't been initialized yet, which happens for a couple
               initial queries made by the agent when starting up.  The
               new RE logs these types of errors and so this avoids that.
            */
            status = -1;
        }
        else {
            status = applyRule( "acAclPolicy", NULL, &rei, NO_SAVE_REI );
        }
        if ( status == 0 ) {
            ruleExecuted = 1; /* No need to retry next time since it
                             succeeded.  Since this is called at
                             startup, the Rule Engine may not be
                             initialized yet, in which case the
                             default setting is fine and we should
                             retry next time. */
        }
    }

    // =-=-=-=-=-=-=-
    // verify that we are running a query for another agent connection
    irods::server_properties& props = irods::server_properties::getInstance();
    props.capture_if_needed();

    std::string svr_sid;
    irods::error err = props.get_property< std::string >( irods::AGENT_CONN_KW, svr_sid );
    bool agent_conn_flg = err.ok();

    // =-=-=-=-=-=-=-
    // detect if a request for disable of strict acls is made
    int acl_val = -1;
    char* dis_kw = getValByKey( &genQueryInp->condInput, DISABLE_STRICT_ACL_KW );
    if ( agent_conn_flg && dis_kw ) {
        acl_val = 0;
    }

    // =-=-=-=-=-=-=-
    // cache the old acl value for reuse later if necessary
    int old_acl_val =  chlGenQueryAccessControlSetup(
                           rsComm->clientUser.userName,
                           rsComm->clientUser.rodsZone,
                           rsComm->clientAddr,
                           rsComm->clientUser.authInfo.authFlag,
                           acl_val );

    if ( PrePostProcForGenQueryFlag == 1 ) {
        args[0] = ( char * ) malloc( 300 );
        sprintf( args[0], "%ld", ( long ) genQueryInp );
        argc = 1;
        i =  applyRuleArg( "acPreProcForGenQuery", args, argc, &rei2, NO_SAVE_REI );
        free( args[0] );
        if ( i < 0 ) {
            rodsLog( LOG_ERROR,
                     "rsGenQuery:acPreProcForGenQuery error,stat=%d", i );
            if ( i != NO_MICROSERVICE_FOUND_ERR ) {
                return i;
            }
        }
    }
    /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/

    status = chlGenQuery( *genQueryInp, *genQueryOut );

    // =-=-=-=-=-=-=-
    // if a disable was requested, repave with old value immediately
    if ( agent_conn_flg && dis_kw ) {
        chlGenQueryAccessControlSetup(
            rsComm->clientUser.userName,
            rsComm->clientUser.rodsZone,
            rsComm->clientAddr,
            rsComm->clientUser.authInfo.authFlag,
            old_acl_val );
    }

    /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/
    if ( PrePostProcForGenQueryFlag == 1 ) {
        args[0] = ( char * ) malloc( 300 );
        args[1] = ( char * ) malloc( 300 );
        args[2] = ( char * ) malloc( 300 );
        sprintf( args[0], "%ld", ( long ) genQueryInp );
        sprintf( args[1], "%ld", ( long ) *genQueryOut );
        sprintf( args[2], "%d", status );
        argc = 3;
        i =  applyRuleArg( "acPostProcForGenQuery", args, argc, &rei2, NO_SAVE_REI );
        free( args[0] );
        free( args[1] );
        free( args[2] );
        if ( i < 0 ) {
            rodsLog( LOG_ERROR,
                     "rsGenQuery:acPostProcForGenQuery error,stat=%d", i );
            if ( i != NO_MICROSERVICE_FOUND_ERR ) {
                return i;
            }
        }
    }
    /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/

    if ( status < 0 ) {
        clearGenQueryOut( *genQueryOut );
        free( *genQueryOut );
        *genQueryOut = NULL;
        if ( status != CAT_NO_ROWS_FOUND ) {
            rodsLog( LOG_NOTICE,
                     "_rsGenQuery: genQuery status = %d", status );
        }
        return status;
    }
    return status;
}
Example #23
0
int
getNumThreads( rsComm_t *rsComm, rodsLong_t dataSize, int inpNumThr,
               keyValPair_t *condInput, char *destRescHier, char *srcRescHier, int oprType ) {
    ruleExecInfo_t rei;
    dataObjInp_t doinp;
    int status;
    int numDestThr = -1;
    int numSrcThr = -1;


    if ( inpNumThr == NO_THREADING ) {
        return 0;
    }

    if ( dataSize < 0 ) {
        return 0;
    }

    if ( dataSize <= MIN_SZ_FOR_PARA_TRAN ) {
        if ( inpNumThr > 0 ) {
            inpNumThr = 1;
        }
        else {
            return 0;
        }
    }

    if ( getValByKey( condInput, NO_PARA_OP_KW ) != NULL ) {
        /* client specify no para opr */
        return 1;
    }

    memset( &doinp, 0, sizeof( doinp ) );
    doinp.numThreads = inpNumThr;

    doinp.dataSize = dataSize;
    doinp.oprType = oprType;

    initReiWithDataObjInp( &rei, rsComm, &doinp );

    if (destRescHier && strlen(destRescHier)) {

        // get resource (hierarchy) location
        std::string location;
        irods::error ret = irods::get_loc_for_hier_string( destRescHier, location );
        if ( !ret.ok() ) {
            irods::log( PASSMSG( "getNumThreads - failed in get_loc_for_hier_string", ret ) );
            return -1;
        }

        irods::hierarchy_parser parser;
        parser.set_string( destRescHier );

        std::string last_resc;
        parser.last_resc( last_resc );

        irods::error err = irods::is_resc_live( last_resc.c_str() );
        if ( err.ok() ) {
            status = applyRule( "acSetNumThreads", NULL, &rei, NO_SAVE_REI );

            if ( status < 0 ) {
                rodsLog( LOG_ERROR,
                         "getNumThreads: acGetNumThreads error, status = %d",
                         status );
            }
            else {
                numDestThr = rei.status;
                if ( numDestThr == 0 ) {
                    return 0;
                }
                else if ( numDestThr == 1 && srcRescHier == NULL &&
                          isLocalHost( location.c_str() ) ) {
                    /* one thread and resource on local host */
                    return 0;
                }
            }
        }
    }

    if (destRescHier && strlen(destRescHier) && srcRescHier && strlen(srcRescHier)) {
        if ( numDestThr > 0 && strcmp( destRescHier, srcRescHier ) == 0 ) {
            return numDestThr;
        }

        // get resource (hierarchy) location
        std::string location;
        irods::error ret = irods::get_loc_for_hier_string( destRescHier, location );
        if ( !ret.ok() ) {
            irods::log( PASSMSG( "getNumThreads - failed in get_loc_for_hier_string", ret ) );
            return -1;
        }

        irods::hierarchy_parser parser;
        parser.set_string( srcRescHier );

        std::string last_resc;
        parser.last_resc( last_resc );

        irods::error err = irods::is_resc_live( last_resc.c_str() );

        if ( err.ok() ) {
            status = applyRule( "acSetNumThreads", NULL, &rei, NO_SAVE_REI );
            if ( status < 0 ) {
                rodsLog( LOG_ERROR,
                         "getNumThreads: acGetNumThreads error, status = %d",
                         status );
            }
            else {
                numSrcThr = rei.status;
                if ( numSrcThr == 0 ) {
                    return 0;
                }
            }
        }
    }

    if ( numDestThr > 0 ) {
        if ( getValByKey( condInput, RBUDP_TRANSFER_KW ) != NULL ) {
            return 1;
        }
        else {
            return numDestThr;
        }
    }
    if ( numSrcThr > 0 ) {
        if ( getValByKey( condInput, RBUDP_TRANSFER_KW ) != NULL ) {
            return 1;
        }
        else {
            return numSrcThr;
        }
    }
    /* should not be here. do one with no resource */
    status = applyRule( "acSetNumThreads", NULL, &rei, NO_SAVE_REI );
    if ( status < 0 ) {
        rodsLog( LOG_ERROR,
                 "getNumThreads: acGetNumThreads error, status = %d",
                 status );
        return 0;
    }
    else {
        if ( rei.status > 0 ) {
            return rei.status;
        }
        else {
            return 0;
        }
    }
}
Example #24
0
int
getNumThreads (rsComm_t *rsComm, rodsLong_t dataSize, int inpNumThr,
               keyValPair_t *condInput, char *destRescName, char *srcRescName)
{
    ruleExecInfo_t rei;
    dataObjInp_t doinp;
    int status;
    int numDestThr = -1;
    int numSrcThr = -1;
    rescGrpInfo_t *rescGrpInfo;

    if (inpNumThr == NO_THREADING)
        return 0;

    if (dataSize < 0)
        return 0;

    if (dataSize <= MIN_SZ_FOR_PARA_TRAN) {
        if (inpNumThr > 0) {
            inpNumThr = 1;
        } else {
            return 0;
        }
    }

    if (getValByKey (condInput, NO_PARA_OP_KW) != NULL) {
        /* client specify no para opr */
        return (1);
    }

#ifndef PARA_OPR
    return (1);
#endif

    memset (&doinp, 0, sizeof (doinp));
    doinp.numThreads = inpNumThr;

    doinp.dataSize = dataSize;

    initReiWithDataObjInp (&rei, rsComm, &doinp);

    if (destRescName != NULL) {
        rescGrpInfo = NULL;
        status = resolveAndQueResc (destRescName, NULL, &rescGrpInfo);
        if (status >= 0) {
            rei.rgi = rescGrpInfo;
            status = applyRule ("acSetNumThreads", NULL, &rei, NO_SAVE_REI);
            freeRescGrpInfo (rescGrpInfo);
            if (status < 0) {
                rodsLog (LOG_ERROR,
                         "getNumThreads: acGetNumThreads error, status = %d",
                         status);
            } else {
                numDestThr = rei.status;
                if (numDestThr == 0) {
                    return 0;
                } else if (numDestThr == 1 && srcRescName == NULL &&
                           isLocalHost (rescGrpInfo->rescInfo->rescLoc)) {
                    /* one thread and resouce on local host */
                    return 0;
                }
            }
        }
    }

    if (srcRescName != NULL) {
        if (numDestThr > 0 && strcmp (destRescName, srcRescName) == 0)
            return numDestThr;
        rescGrpInfo = NULL;
        status = resolveAndQueResc (srcRescName, NULL, &rescGrpInfo);
        if (status >= 0) {
            rei.rgi = rescGrpInfo;
            status = applyRule ("acSetNumThreads", NULL, &rei, NO_SAVE_REI);
            freeRescGrpInfo (rescGrpInfo);
            if (status < 0) {
                rodsLog (LOG_ERROR,
                         "getNumThreads: acGetNumThreads error, status = %d",
                         status);
            } else {
                numSrcThr = rei.status;
                if (numSrcThr == 0) return 0;
            }
        }
    }

    /* At this point, number of threads for both source and destination
       have been set based on acSetNumThreads policy point, and neither
       of them are set to 0 (to turn off threading). If both numDestThr
       and numSrcThr are set, choose the smallest one. The reasoning is
       that acSetNumThreads is used by a site to limit the default
       maximum parallel threads, so we should honor the most restrictive
       setting. */
    if (numDestThr > 0 && numSrcThr > 0) {
        if (getValByKey (condInput, RBUDP_TRANSFER_KW) != NULL) {
            return 1;
        } else if (numDestThr < numSrcThr) {
            return numDestThr;
        } else {
            return numSrcThr;
        }
    }
    if (numDestThr > 0) {
        if (getValByKey (condInput, RBUDP_TRANSFER_KW) != NULL) {
            return 1;
        } else {
            return numDestThr;
        }
    }
    if (numSrcThr > 0) {
        if (getValByKey (condInput, RBUDP_TRANSFER_KW) != NULL) {
            return 1;
        } else {
            return numSrcThr;
        }
    }
    /* should not be here. do one with no resource */
    rei.rgi = NULL;
    status = applyRule ("acSetNumThreads", NULL, &rei, NO_SAVE_REI);
    if (status < 0) {
        rodsLog (LOG_ERROR,
                 "getNumThreads: acGetNumThreads error, status = %d",
                 status);
        return 0;
    } else {
        if (rei.status > 0)
            return rei.status;
        else
            return 0;
    }
}
    int msiobjget_z3950(
        msParam_t*  inRequestPath,
        msParam_t* inFileMode,
        msParam_t* inFileFlags,
        msParam_t* inCacheFilename,
        ruleExecInfo_t* rei ) {

        char *reqStr;
        int mode;
        char *cacheFilename;
        char *str;
        int status, bytesWritten, objLen;
        int destFd;
        char *locStr, *queryStr, *syntaxStr;
        char *myMSICall;
        int i;
        ruleExecInfo_t rei2;
        msParamArray_t msParamArray;
        msParam_t *mP;


        RE_TEST_MACRO( "    Calling msiobjget_z3950" );

        /*  check for input parameters */
        if ( inRequestPath ==  NULL ||
                strcmp( inRequestPath->type , STR_MS_T ) != 0 ||
                inRequestPath->inOutStruct == NULL ) {
            return( USER_PARAM_TYPE_ERR );
        }

        if ( inFileMode ==  NULL ||
                strcmp( inFileMode->type , STR_MS_T ) != 0 ||
                inFileMode->inOutStruct == NULL ) {
            return( USER_PARAM_TYPE_ERR );
        }

        if ( inFileFlags ==  NULL ||
                strcmp( inFileFlags->type , STR_MS_T ) != 0 ||
                inFileFlags->inOutStruct == NULL ) {
            return( USER_PARAM_TYPE_ERR );
        }

        if ( inCacheFilename ==  NULL ||
                strcmp( inCacheFilename->type , STR_MS_T ) != 0 ||
                inCacheFilename->inOutStruct == NULL ) {
            return( USER_PARAM_TYPE_ERR );
        }

        /*  coerce input to local variables */
        reqStr = ( char * ) inRequestPath->inOutStruct;
        cacheFilename = ( char * ) inCacheFilename->inOutStruct;
        mode  = atoi( ( char * ) inFileMode->inOutStruct );

        /* Do the processing */

        /* first skipping the mso-name */
        if ( ( str = strstr( reqStr, ":" ) ) == NULL ) {
            str = reqStr;
        }
        else {
            str++;
        }

        /* getting parameters for the calls */
        i = getz3950Params( str, &locStr, &queryStr, &syntaxStr );
        if ( i != 0 ) {
            printf( "msiobjget_z3950: Error in request format for %s:%i\n", str, i );
            return( USER_INPUT_FORMAT_ERR );
        }

        myMSICall = ( char * ) malloc( strlen( reqStr ) + 200 );

        sprintf( myMSICall, "msiz3950Submit(\"%s\",\"%s\",\"%s\",*OutBuffer)",
                 locStr, queryStr, syntaxStr );


        /*  sprintf(myMSICall, "msiz3950Submit(\"z3950.loc.gov:7090/Voyager\",\"@attr 1=1003 Marx\",\"USMARC\",*OutBuffer)" );
            printf("MM:%s***\n",myMSICall);
         */
        free( locStr );
        free( queryStr );
        free( syntaxStr );
        memset( ( char* )&rei2, 0, sizeof( ruleExecInfo_t ) );
        memset( ( char* )&msParamArray, 0, sizeof( msParamArray_t ) );


        rei2.rsComm = rei->rsComm;
        if ( rei2.rsComm != NULL ) {
            rei2.uoic = &rei2.rsComm->clientUser;
            rei2.uoip = &rei2.rsComm->proxyUser;
        }


#ifdef RULE_ENGINE_N
        i = applyRuleUpdateParams( myMSICall, &msParamArray, &rei2, NO_SAVE_REI );
#else
        i = applyRule( myMSICall, &msParamArray, &rei2, NO_SAVE_REI );
#endif
        if ( i != 0 ) {
            printf( "msiobjget_z3950: Error in calling %s: %i\n", myMSICall, i );
            free( myMSICall );
            return( i );
        }
        free( myMSICall );
        mP = getMsParamByLabel( &msParamArray, "*OutBuffer" );
        if ( mP == NULL ) {
            printf( "msiobjget_z3950: Error in Getting Parameter after call for *OutBuffer\n" );
            return( UNKNOWN_PARAM_IN_RULE_ERR );
        }
        str = ( char * ) mP->inOutStruct;
        objLen = strlen( str );

        /* write the resulting buffer   in  cache file */
        destFd = open( cacheFilename, O_WRONLY | O_CREAT | O_TRUNC, mode );
        if ( destFd < 0 ) {
            status = UNIX_FILE_OPEN_ERR - errno;
            printf(
                "msigetobj_z3950: open error for cacheFilename %s, status = %d",
                cacheFilename, status );
            clearMsParamArray( &msParamArray, 0 );
            return status;
        }
        bytesWritten = write( destFd, str, objLen );
        close( destFd );
        clearMsParamArray( &msParamArray, 0 );
        if ( bytesWritten != objLen ) {
            printf(
                "msigetobj_z3950: In Cache File %s bytesWritten %d != returned objLen %i\n",
                cacheFilename, bytesWritten, objLen );
            return SYS_COPY_LEN_ERR;
        }

        /* clean up */

        /*return */
        return( 0 );
    }
Example #26
0
            rodsLog( LOG_ERROR, "boost encountered thread_resource_error." );
            return SYS_THREAD_RESOURCE_ERR;
        }
    }
    initExecCmdMutex();
#endif

    InitialState = INITIAL_DONE;
    ThisComm = rsComm;

    /* use a tmp myComm is needed to get the permission right for the call */
    myComm = *rsComm;
    myComm.clientUser.authInfo.authFlag = LOCAL_PRIV_USER_AUTH;
    rei.rsComm = &myComm;

    status = applyRule( "acSetPublicUserPolicy", NULL, &rei, NO_SAVE_REI );

    if ( status < 0 ) {
        rodsLog( LOG_ERROR,
                 "initAgent: acSetPublicUserPolicy error, status = %d",
                 status );
        return status;
    }

    return status;
}

void
cleanup() {
#ifdef RODS_CAT
    disconnectRcat();
Example #27
0
int
rsDataObjPhymv( rsComm_t *rsComm, dataObjInp_t *dataObjInp,
                transferStat_t **transStat ) {
    int status = 0;
    dataObjInfo_t *dataObjInfoHead = NULL;
    dataObjInfo_t *oldDataObjInfoHead = NULL;
    rescGrpInfo_t *myRescGrpInfo = NULL;
    ruleExecInfo_t rei;
    int multiCopyFlag = 0;
    char *accessPerm = NULL;
    int remoteFlag = 0;
    rodsServerHost_t *rodsServerHost = NULL;
    specCollCache_t *specCollCache = NULL;

    resolveLinkedPath( rsComm, dataObjInp->objPath, &specCollCache,
                       &dataObjInp->condInput );
    remoteFlag = getAndConnRemoteZone( rsComm, dataObjInp, &rodsServerHost,
                                       REMOTE_OPEN );

    if ( remoteFlag < 0 ) {
        return remoteFlag;
    }
    else if ( remoteFlag == REMOTE_HOST ) {
        status = _rcDataObjPhymv( rodsServerHost->conn, dataObjInp,
                                  transStat );
        return status;
    }

    // =-=-=-=-=-=-=-
    // determine hierarchy string
    if ( getValByKey( &dataObjInp->condInput, RESC_HIER_STR_KW ) == NULL ) {
        std::string       hier;
        irods::error ret = irods::resolve_resource_hierarchy( irods::OPEN_OPERATION, rsComm,
                           dataObjInp, hier );
        if ( !ret.ok() ) {
            std::stringstream msg;
            msg << __FUNCTION__;
            msg << " :: failed in irods::resolve_resource_hierarchy for [";
            msg << dataObjInp->objPath << "]";
            irods::log( PASSMSG( msg.str(), ret ) );
            return ret.code();
        }

        // =-=-=-=-=-=-=-
        // we resolved the redirect and have a host, set the hier str for subsequent
        // api calls, etc.
        addKeyVal( &dataObjInp->condInput, RESC_HIER_STR_KW, hier.c_str() );

    } // if keyword

    *transStat = ( transferStat_t* )malloc( sizeof( transferStat_t ) );
    memset( *transStat, 0, sizeof( transferStat_t ) );

    if ( getValByKey( &dataObjInp->condInput, ADMIN_KW ) != NULL ) {
        if ( rsComm->clientUser.authInfo.authFlag < LOCAL_PRIV_USER_AUTH ) {
            return CAT_INSUFFICIENT_PRIVILEGE_LEVEL;
        }
        accessPerm = NULL;
    }
    else {
        accessPerm = ACCESS_DELETE_OBJECT;
    }

    /* query rcat for resource info and sort it */
    status = getRescGrpForCreate( rsComm, dataObjInp, &myRescGrpInfo );
    if ( status < 0 ) {
        delete myRescGrpInfo->rescInfo;
        delete myRescGrpInfo;
        return status;
    }

    initReiWithDataObjInp( &rei, rsComm, dataObjInp );
    status = applyRule( "acSetMultiReplPerResc", NULL, &rei, NO_SAVE_REI );
    if ( strcmp( rei.statusStr, MULTI_COPIES_PER_RESC ) == 0 ) {
        multiCopyFlag = 1;
    }
    else {
        multiCopyFlag = 0;
    }

    /* query rcat for dataObjInfo and sort it */
    status = getDataObjInfo( rsComm, dataObjInp, &dataObjInfoHead,
                             accessPerm, 1 );

    if ( status < 0 ) {
        rodsLog( LOG_NOTICE,
                 "rsDataObjPhymv: getDataObjInfo for %s", dataObjInp->objPath );
        delete myRescGrpInfo->rescInfo;
        delete myRescGrpInfo;
        return status;
    }

    status = resolveInfoForPhymv( &dataObjInfoHead, &oldDataObjInfoHead, &myRescGrpInfo, &dataObjInp->condInput, multiCopyFlag );

    if ( status < 0 ) {
        freeAllDataObjInfo( dataObjInfoHead );
        freeAllDataObjInfo( oldDataObjInfoHead );
        if ( myRescGrpInfo ) {
            delete myRescGrpInfo->rescInfo;
            delete myRescGrpInfo;
        }
        if ( status == CAT_NO_ROWS_FOUND ) {
            return 0;
        }
        else {
            return status;
        }
    }

    status = _rsDataObjPhymv( rsComm, dataObjInp, dataObjInfoHead,
                              myRescGrpInfo, *transStat, multiCopyFlag );

    freeAllDataObjInfo( dataObjInfoHead );
    freeAllDataObjInfo( oldDataObjInfoHead );
    if ( myRescGrpInfo ) {
        delete myRescGrpInfo->rescInfo;
        delete myRescGrpInfo;
    }

    return status;
}
Example #28
0
int
_rsModColl (rsComm_t *rsComm, collInp_t *modCollInp)
{
#ifdef RODS_CAT
    int status;
    collInfo_t collInfo;
    char *tmpStr;

    int i;
    ruleExecInfo_t rei2;

    memset ((char*)&rei2, 0, sizeof (ruleExecInfo_t));
    rei2.rsComm = rsComm;
    if (rsComm != NULL) {
      rei2.uoic = &rsComm->clientUser;
      rei2.uoip = &rsComm->proxyUser;
    }

    memset (&collInfo, 0, sizeof (collInfo));

    rstrcpy (collInfo.collName, modCollInp->collName, MAX_NAME_LEN);

    if ((tmpStr = getValByKey (&modCollInp->condInput,
      COLLECTION_TYPE_KW)) != NULL) {
        rstrcpy (collInfo.collType, tmpStr, NAME_LEN);
    }
    if ((tmpStr = getValByKey (&modCollInp->condInput,
      COLLECTION_INFO1_KW)) != NULL) {
        rstrcpy (collInfo.collInfo1, tmpStr, MAX_NAME_LEN);
    }
    if ((tmpStr = getValByKey (&modCollInp->condInput,
      COLLECTION_INFO2_KW)) != NULL) {
        rstrcpy (collInfo.collInfo2, tmpStr, MAX_NAME_LEN);
    }
    /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/
    rei2.coi = &collInfo;
    i =  applyRule("acPreProcForModifyCollMeta",NULL, &rei2, NO_SAVE_REI);
    if (i < 0) {
      if (rei2.status < 0) {
	i = rei2.status;
      }
      rodsLog (LOG_ERROR,
	       "rsGeneralAdmin:acPreProcForModifyCollMeta error for %s,stat=%d",
	       modCollInp->collName, i);
      return i;
    }
    /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/

    status = chlModColl (rsComm, &collInfo);

    /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/
    if (status >= 0) {
      i =  applyRule("acPostProcForModifyCollMeta",NULL, &rei2, NO_SAVE_REI);
      if (i < 0) {
	if (rei2.status < 0) {
	  i = rei2.status;
	}
	rodsLog (LOG_ERROR,
		 "rsGeneralAdmin:acPostProcForModifyCollMeta error for %s,stat=%d",
		 modCollInp->collName, i);
	return i;
      }
    }
    /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/

    /* XXXX need to commit */
    if (status >= 0) {
       status = chlCommit(rsComm);
    }
    else {
       int status1;
       status1 = chlRollback(rsComm);
    }

    return (status);
#else
    return (SYS_NO_RCAT_SERVER_ERR);
#endif
}
Example #29
0
int
initAgent( int processType, rsComm_t *rsComm ) {
    int status;
    rsComm_t myComm;
    ruleExecInfo_t rei;

    initProcLog();

    status = initServerInfo( rsComm );
    if ( status < 0 ) {
        rodsLog( LOG_ERROR,
                 "initAgent: initServerInfo error, status = %d",
                 status );
        return status;
    }

    initL1desc();
    initSpecCollDesc();
    status = initFileDesc();
    if ( status < 0 ) {
        rodsLog( LOG_ERROR,
                 "initAgent: initFileDesc error, status = %d",
                 status );
        return status;
    }
#ifdef TAR_STRUCT_FILE
//    initStructFileDesc ();
//    initTarSubFileDesc ();
#endif
    status = initRuleEngine( processType, rsComm, reRuleStr, reVariableMapStr, reFuncMapStr );
    if ( status < 0 ) {
        rodsLog( LOG_ERROR,
                 "initAgent: initRuleEngine error, status = %d", status );
        return status;
    }

    memset( &rei, 0, sizeof( rei ) );
    rei.rsComm = rsComm;

    if ( ProcessType == AGENT_PT ) {
        status = applyRule( "acChkHostAccessControl", NULL, &rei,
                            NO_SAVE_REI );

        if ( status < 0 ) {
            rodsLog( LOG_ERROR,
                     "initAgent: acChkHostAccessControl error, status = %d",
                     status );
            return status;
        }
    }

    /* Initialize the global quota */

    GlobalQuotaLimit = RESC_QUOTA_UNINIT;
    GlobalQuotaOverrun = 0;
    RescQuotaPolicy = RESC_QUOTA_UNINIT;

#ifndef windows_platform
    if ( rsComm->reconnFlag == RECONN_TIMEOUT ) {
        rsComm->reconnSock = svrSockOpenForInConn( rsComm, &rsComm->reconnPort,
                             &rsComm->reconnAddr, SOCK_STREAM );
        if ( rsComm->reconnSock < 0 ) {
            rsComm->reconnPort = 0;
            rsComm->reconnAddr = NULL;
        }
        else {
            rsComm->cookie = ( int )( getRandomInt() >> 1 );
        }
        try {
            rsComm->thread_ctx->lock      = new boost::mutex;
            rsComm->thread_ctx->cond      = new boost::condition_variable;
            rsComm->thread_ctx->reconnThr = new boost::thread( reconnManager, rsComm );
        }
        catch ( boost::thread_resource_error& ) {
            rodsLog( LOG_ERROR, "boost encountered thread_resource_error." );
            return SYS_THREAD_RESOURCE_ERR;
        }
    }
int
_rsModDataObjMeta( rsComm_t *rsComm, modDataObjMeta_t *modDataObjMetaInp ) {
#ifdef RODS_CAT
    int status = 0;
    dataObjInfo_t *dataObjInfo;
    keyValPair_t *regParam;
    int i;
    ruleExecInfo_t rei2;

    memset( ( char* )&rei2, 0, sizeof( ruleExecInfo_t ) );
    rei2.rsComm = rsComm;
    if ( rsComm != NULL ) {
        rei2.uoic = &rsComm->clientUser;
        rei2.uoip = &rsComm->proxyUser;
    }
    rei2.doi = modDataObjMetaInp->dataObjInfo;
    rei2.condInputData = modDataObjMetaInp->regParam;
    regParam = modDataObjMetaInp->regParam;
    dataObjInfo = modDataObjMetaInp->dataObjInfo;

    if ( regParam->len == 0 ) {
        return ( 0 );
    }

    /* In dataObjInfo, need just dataId. But it will accept objPath too,
     * but less efficient
     */

    /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/
    rei2.doi = dataObjInfo;
    i =  applyRule( "acPreProcForModifyDataObjMeta", NULL, &rei2, NO_SAVE_REI );
    if ( i < 0 ) {
        if ( rei2.status < 0 ) {
            i = rei2.status;
        }
        rodsLog( LOG_ERROR, "_rsModDataObjMeta:acPreProcForModifyDataObjMeta error stat=%d", i );

        return i;
    }
    /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/

    if ( getValByKey( regParam, ALL_KW ) != NULL ) {
        /* all copies */
        dataObjInfo_t *dataObjInfoHead = NULL;
        dataObjInfo_t *tmpDataObjInfo;
        dataObjInp_t dataObjInp;

        bzero( &dataObjInp, sizeof( dataObjInp ) );
        rstrcpy( dataObjInp.objPath, dataObjInfo->objPath, MAX_NAME_LEN );
        status = getDataObjInfoIncSpecColl( rsComm, &dataObjInp, &dataObjInfoHead );

        if ( status < 0 )  {
            rodsLog( LOG_NOTICE, "%s - Failed to get data objects.", __FUNCTION__ );
            return status;
        }
        tmpDataObjInfo = dataObjInfoHead;
        while ( tmpDataObjInfo != NULL ) {
            if ( tmpDataObjInfo->specColl != NULL ) {
                break;
            }
            status = chlModDataObjMeta( rsComm, tmpDataObjInfo, regParam );
            if ( status < 0 ) {
                rodsLog( LOG_ERROR,
                         "_rsModDataObjMeta:chlModDataObjMeta %s error stat=%d",
                         tmpDataObjInfo->objPath, status );
            }
            tmpDataObjInfo = tmpDataObjInfo->next;
        }
        freeAllDataObjInfo( dataObjInfoHead );
    }
    else {
        status = chlModDataObjMeta( rsComm, dataObjInfo, regParam );
        if ( status < 0 ) {
            char* sys_error;
            char* rods_error = rodsErrorName( status, &sys_error );
            std::stringstream msg;
            msg << __FUNCTION__;
            msg << " - Failed to modify the database for object \"";
            msg << dataObjInfo->objPath;
            msg << "\" - " << rods_error << " " << sys_error;
            irods::error ret = ERROR( status, msg.str() );
            irods::log( ret );
        }
    }

    /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/
    if ( status >= 0 ) {
        i =  applyRule( "acPostProcForModifyDataObjMeta", NULL, &rei2, NO_SAVE_REI );
        if ( i < 0 ) {
            if ( rei2.status < 0 ) {
                i = rei2.status;
            }
            rodsLog( LOG_ERROR,
                     "_rsModDataObjMeta:acPostProcForModifyDataObjMeta error stat=%d", i );
            return i;
        }
    }
    else {
        rodsLog( LOG_NOTICE, "%s - Failed updating the database with object info.", __FUNCTION__ );
        return status;
    }
    /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/

    return ( status );
#else
    return ( SYS_NO_RCAT_SERVER_ERR );
#endif

}