int getObjType( rsComm_t *rsComm, char *objName, char * objType ) { if ( isData( rsComm, objName, NULL ) >= 0 ) { strcpy( objType, "-d" ); } else if ( isColl( rsComm, objName, NULL ) >= 0 ) { strcpy( objType, "-c" ); } else if ( isResc( rsComm, objName ) == 0 ) { strcpy( objType, "-r" ); } else if ( isUser( rsComm, objName ) == 0 ) { strcpy( objType, "-u" ); } else if ( isMeta( rsComm, objName ) == 0 ) { strcpy( objType, "-m" ); } else if ( isToken( rsComm, objName ) == 0 ) { strcpy( objType, "-t" ); } else { return INVALID_OBJECT_TYPE; } return 0; }
int rsGetHostForGet( rsComm_t* rsComm, dataObjInp_t* dataObjInp, char** outHost ) { // =-=-=-=-=-=-=- // default behavior *outHost = strdup( THIS_ADDRESS ); // =-=-=-=-=-=-=- // working on the "home zone", determine if we need to redirect to a different // server in this zone for this operation. if there is a RESC_HIER_STR_KW then // we know that the redirection decision has already been made if ( isColl( rsComm, dataObjInp->objPath, NULL ) < 0 ) { std::string hier; if ( getValByKey( &dataObjInp->condInput, RESC_HIER_STR_KW ) == NULL ) { 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 // =-=-=-=-=-=-=- // extract the host location from the resource hierarchy std::string location; irods::error ret = irods::get_loc_for_hier_string( hier, location ); if ( !ret.ok() ) { irods::log( PASSMSG( "rsGetHostForGet - failed in get_loc_for_hier_string", ret ) ); return -1; } // =-=-=-=-=-=-=- // set the out variable *outHost = strdup( location.c_str() ); } // if not a collection return 0; }
void Button::update( RenderWindow& wnd) { ConvexShape sh(4); sh.setPoint(0, getPosA()); sh.setPoint(1, getPosA() + Vector2f(wh.x, 0) ); sh.setPoint(2, getPosA() + Vector2f(wh.x, wh.y) ); sh.setPoint(3, getPosA() + Vector2f(0, wh.y) ); sh.setFillColor( isColl(wnd) ? clOn : clIn); sh.setOutlineColor(clOut); Base::draw(wnd, sh); txt.updatePos(getPosA()); txt.update(wnd); }
int getObjType(rsComm_t *rsComm, char *objName, char * objType) { if (isData(rsComm, objName, NULL) >= 0) strcpy(objType,"-d"); else if (isColl(rsComm, objName, NULL) >= 0) strcpy(objType,"-c"); else if (isResc(rsComm, objName) == 0) strcpy(objType,"-r"); else if (isRescGroup(rsComm, objName) == 0) strcpy(objType,"-g"); else if (isUser(rsComm, objName) == 0) strcpy(objType,"-u"); else if (isMeta(rsComm, objName) == 0) strcpy(objType,"-m"); else if (isToken(rsComm, objName) == 0) strcpy(objType,"-t"); else return(INVALID_OBJECT_TYPE); return (0); }
void RandomTower::Draw(const math::bbox2f &screen) { math::vec2i start = tilePos(screen.min); math::vec2i end = tilePos(screen.max) + math::vec2i(1,1); for (int j = start.y; j < end.y; ++j) { drawDeletedTiles(j); for (int i = start.x; i < end.x; ++i) { math::bbox2f quad( math::vec2f(i,j)*m_unitsPerTile, math::vec2f(i+1,j+1)*m_unitsPerTile); if (isColl(i,j)) { glColor(Guy::rgb(0.400f, 0.275f, 0.195f)); Guy::draw(quad); } } } }
int mountFileDir (rsComm_t *rsComm, dataObjInp_t *phyPathRegInp, char *filePath, rescInfo_t *rescInfo) { collInp_t collCreateInp; int rescTypeInx; int status; fileStatInp_t fileStatInp; rodsStat_t *myStat = NULL; rodsObjStat_t *rodsObjStatOut = NULL; if (rsComm->clientUser.authInfo.authFlag < LOCAL_PRIV_USER_AUTH) return(CAT_INSUFFICIENT_PRIVILEGE_LEVEL); status = collStat (rsComm, phyPathRegInp, &rodsObjStatOut); if (status < 0) return status; if (rodsObjStatOut->specColl != NULL) { freeRodsObjStat (rodsObjStatOut); rodsLog (LOG_ERROR, "mountFileDir: %s already mounted", phyPathRegInp->objPath); return (SYS_MOUNT_MOUNTED_COLL_ERR); } freeRodsObjStat (rodsObjStatOut); if (isCollEmpty (rsComm, phyPathRegInp->objPath) == False) { rodsLog (LOG_ERROR, "mountFileDir: collection %s not empty", phyPathRegInp->objPath); return (SYS_COLLECTION_NOT_EMPTY); } memset (&fileStatInp, 0, sizeof (fileStatInp)); rstrcpy (fileStatInp.fileName, filePath, MAX_NAME_LEN); rescTypeInx = rescInfo->rescTypeInx; fileStatInp.fileType = (fileDriverType_t)RescTypeDef[rescTypeInx].driverType; rstrcpy (fileStatInp.addr.hostAddr, rescInfo->rescLoc, NAME_LEN); status = rsFileStat (rsComm, &fileStatInp, &myStat); if (status < 0) { fileMkdirInp_t fileMkdirInp; rodsLog (LOG_NOTICE, "mountFileDir: rsFileStat failed for %s, status = %d, create it", fileStatInp.fileName, status); memset (&fileMkdirInp, 0, sizeof (fileMkdirInp)); rstrcpy (fileMkdirInp.dirName, filePath, MAX_NAME_LEN); fileMkdirInp.fileType = (fileDriverType_t)RescTypeDef[rescTypeInx].driverType; fileMkdirInp.mode = getDefDirMode (); rstrcpy (fileMkdirInp.addr.hostAddr, rescInfo->rescLoc, NAME_LEN); status = rsFileMkdir (rsComm, &fileMkdirInp); if (status < 0) { return (status); } } else if ((myStat->st_mode & S_IFDIR) == 0) { rodsLog (LOG_ERROR, "mountFileDir: phyPath %s is not a directory", fileStatInp.fileName); free (myStat); return (USER_FILE_DOES_NOT_EXIST); } free (myStat); /* mk the collection */ memset (&collCreateInp, 0, sizeof (collCreateInp)); rstrcpy (collCreateInp.collName, phyPathRegInp->objPath, MAX_NAME_LEN); addKeyVal (&collCreateInp.condInput, COLLECTION_TYPE_KW, MOUNT_POINT_STR); addKeyVal (&collCreateInp.condInput, COLLECTION_INFO1_KW, filePath); addKeyVal (&collCreateInp.condInput, COLLECTION_INFO2_KW, rescInfo->rescName); /* try to mod the coll first */ status = rsModColl (rsComm, &collCreateInp); if (status < 0) { /* try to create it */ status = rsRegColl (rsComm, &collCreateInp); } if (status >= 0) { char outLogPath[MAX_NAME_LEN]; int status1; /* see if the phyPath is mapped into a real collection */ if (getLogPathFromPhyPath (filePath, rescInfo, outLogPath) >= 0 && strcmp (outLogPath, phyPathRegInp->objPath) != 0) { /* log path not the same as input objPath */ if (isColl (rsComm, outLogPath, NULL) >= 0) { modAccessControlInp_t modAccessControl; /* it is a real collection. better set the collection * to read-only mode because any modification to files * through this mounted collection can be trouble */ bzero (&modAccessControl, sizeof (modAccessControl)); modAccessControl.accessLevel = "read"; modAccessControl.userName = rsComm->clientUser.userName; modAccessControl.zone = rsComm->clientUser.rodsZone; modAccessControl.path = phyPathRegInp->objPath; status1 = rsModAccessControl(rsComm, &modAccessControl); if (status1 < 0) { rodsLog (LOG_NOTICE, "mountFileDir: rsModAccessControl err for %s, stat = %d", phyPathRegInp->objPath, status1); } } } } return (status); }
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); }
int rsCollCreate( rsComm_t *rsComm, collInp_t *collCreateInp ) { int status; rodsServerHost_t *rodsServerHost = NULL; ruleExecInfo_t rei; collInfo_t collInfo; specCollCache_t *specCollCache = NULL; dataObjInfo_t *dataObjInfo = NULL; irods::error ret = validate_logical_path( collCreateInp->collName ); if ( !ret.ok() ) { if ( rsComm->rError.len < MAX_ERROR_MESSAGES ) { char error_msg[ERR_MSG_LEN]; snprintf(error_msg, ERR_MSG_LEN, "%s", ret.user_result().c_str()); addRErrorMsg( &rsComm->rError, ret.code(), error_msg ); } irods::log( ret ); return SYS_INVALID_INPUT_PARAM; } // Issue 3913: retain status in case string too long status = resolveLinkedPath( rsComm, collCreateInp->collName, &specCollCache, &collCreateInp->condInput ); // Issue 3913: retain status in case string too long if (status == USER_STRLEN_TOOLONG) { return USER_STRLEN_TOOLONG; } status = getAndConnRcatHost( rsComm, MASTER_RCAT, ( const char* )collCreateInp->collName, &rodsServerHost ); if ( status < 0 || rodsServerHost == NULL ) { // JMC cppcheck return status; } if ( rodsServerHost->localFlag == LOCAL_HOST ) { initReiWithCollInp( &rei, rsComm, collCreateInp, &collInfo ); status = applyRule( "acPreprocForCollCreate", NULL, &rei, NO_SAVE_REI ); if ( status < 0 ) { if ( rei.status < 0 ) { status = rei.status; } rodsLog( LOG_ERROR, "rsCollCreate:acPreprocForCollCreate error for %s,stat=%d", collCreateInp->collName, status ); return status; } if ( getValByKey( &collCreateInp->condInput, RECURSIVE_OPR__KW ) != NULL ) { status = rsMkCollR( rsComm, "/", collCreateInp->collName ); return status; } std::string svc_role; irods::error ret = get_catalog_service_role(svc_role); if(!ret.ok()) { irods::log(PASS(ret)); return ret.code(); } if( irods::CFG_SERVICE_ROLE_PROVIDER == svc_role ) { /* for STRUCT_FILE_COLL to make a directory in the structFile, the * COLLECTION_TYPE_KW must be set */ status = resolvePathInSpecColl( rsComm, collCreateInp->collName, WRITE_COLL_PERM, 0, &dataObjInfo ); if ( status >= 0 ) { freeDataObjInfo( dataObjInfo ); if ( status == COLL_OBJ_T ) { return 0; } else if ( status == DATA_OBJ_T ) { return USER_INPUT_PATH_ERR; } } else if ( status == SYS_SPEC_COLL_OBJ_NOT_EXIST ) { /* for STRUCT_FILE_COLL to make a directory in the structFile, the * COLLECTION_TYPE_KW must be set */ if ( dataObjInfo != NULL && dataObjInfo->specColl != NULL && dataObjInfo->specColl->collClass == LINKED_COLL ) { /* should not be here because if has been translated */ return SYS_COLL_LINK_PATH_ERR; } else { status = l3Mkdir( rsComm, dataObjInfo ); } freeDataObjInfo( dataObjInfo ); return status; } else { if ( isColl( rsComm, collCreateInp->collName, NULL ) >= 0 ) { return CATALOG_ALREADY_HAS_ITEM_BY_THAT_NAME; } status = _rsRegColl( rsComm, collCreateInp ); } rei.status = status; if ( status >= 0 ) { rei.status = applyRule( "acPostProcForCollCreate", NULL, &rei, NO_SAVE_REI ); if ( rei.status < 0 ) { rodsLog( LOG_ERROR, "rsCollCreate:acPostProcForCollCreate error for %s,stat=%d", collCreateInp->collName, status ); } } } else if( irods::CFG_SERVICE_ROLE_CONSUMER == svc_role ) { status = SYS_NO_RCAT_SERVER_ERR; } else { rodsLog( LOG_ERROR, "role not supported [%s]", svc_role.c_str() ); status = SYS_SERVICE_ROLE_NOT_SUPPORTED; } } else { status = rcCollCreate( rodsServerHost->conn, collCreateInp ); } return status; }
int rsCollCreate( rsComm_t *rsComm, collInp_t *collCreateInp ) { int status; rodsServerHost_t *rodsServerHost = NULL; ruleExecInfo_t rei; collInfo_t collInfo; specCollCache_t *specCollCache = NULL; #ifdef RODS_CAT dataObjInfo_t *dataObjInfo = NULL; #endif irods::error ret = validate_collection_path( collCreateInp->collName ); if ( !ret.ok() ) { irods::log( ret ); return SYS_INVALID_INPUT_PARAM; } resolveLinkedPath( rsComm, collCreateInp->collName, &specCollCache, &collCreateInp->condInput ); status = getAndConnRcatHost( rsComm, MASTER_RCAT, ( const char* )collCreateInp->collName, &rodsServerHost ); if ( status < 0 || rodsServerHost == NULL ) { // JMC cppcheck return status; } if ( rodsServerHost->localFlag == LOCAL_HOST ) { initReiWithCollInp( &rei, rsComm, collCreateInp, &collInfo ); status = applyRule( "acPreprocForCollCreate", NULL, &rei, NO_SAVE_REI ); if ( status < 0 ) { if ( rei.status < 0 ) { status = rei.status; } rodsLog( LOG_ERROR, "rsCollCreate:acPreprocForCollCreate error for %s,stat=%d", collCreateInp->collName, status ); return status; } if ( getValByKey( &collCreateInp->condInput, RECURSIVE_OPR__KW ) != NULL ) { status = rsMkCollR( rsComm, "/", collCreateInp->collName ); return status; } #ifdef RODS_CAT /* for STRUCT_FILE_COLL to make a directory in the structFile, the * COLLECTION_TYPE_KW must be set */ status = resolvePathInSpecColl( rsComm, collCreateInp->collName, WRITE_COLL_PERM, 0, &dataObjInfo ); if ( status >= 0 ) { freeDataObjInfo( dataObjInfo ); if ( status == COLL_OBJ_T ) { return 0; } else if ( status == DATA_OBJ_T ) { return USER_INPUT_PATH_ERR; } } else if ( status == SYS_SPEC_COLL_OBJ_NOT_EXIST ) { /* for STRUCT_FILE_COLL to make a directory in the structFile, the * COLLECTION_TYPE_KW must be set */ if ( dataObjInfo != NULL && dataObjInfo->specColl != NULL && dataObjInfo->specColl->collClass == LINKED_COLL ) { /* should not be here because if has been translated */ return SYS_COLL_LINK_PATH_ERR; } else { status = l3Mkdir( rsComm, dataObjInfo ); } freeDataObjInfo( dataObjInfo ); return status; } else { if ( isColl( rsComm, collCreateInp->collName, NULL ) >= 0 ) { return CATALOG_ALREADY_HAS_ITEM_BY_THAT_NAME; } status = _rsRegColl( rsComm, collCreateInp ); } rei.status = status; if ( status >= 0 ) { rei.status = applyRule( "acPostProcForCollCreate", NULL, &rei, NO_SAVE_REI ); if ( rei.status < 0 ) { rodsLog( LOG_ERROR, "rsCollCreate:acPostProcForCollCreate error for %s,stat=%d", collCreateInp->collName, status ); } } #else status = SYS_NO_RCAT_SERVER_ERR; #endif } else { status = rcCollCreate( rodsServerHost->conn, collCreateInp ); } return status; }
bool Button::isPressed(RenderWindow& wnd, sf::Mouse::Button button, sf::Keyboard::Key key, float cd) { static Control::Timer timer; return timer.isReadyRestart(cd) && ( (isColl(wnd) && sf::Mouse::isButtonPressed(button)) || sf::Keyboard::isKeyPressed(key) ); }