/* Create, modify, or delete a ticket */ int doTicketOp( char *arg1, char *arg2, char *arg3, char *arg4, char *arg5 ) { ticketAdminInp_t ticketAdminInp; int status; char *mySubName; char *myName; ticketAdminInp.arg1 = arg1; ticketAdminInp.arg2 = arg2; ticketAdminInp.arg3 = arg3; ticketAdminInp.arg4 = arg4; ticketAdminInp.arg5 = arg5; ticketAdminInp.arg6 = ""; status = rcTicketAdmin( Conn, &ticketAdminInp ); lastCommandStatus = status; if ( status < 0 ) { if ( Conn->rError ) { rError_t *Err; rErrMsg_t *ErrMsg; int i, len; Err = Conn->rError; len = Err->len; for ( i = 0; i < len; i++ ) { ErrMsg = Err->errMsg[i]; rodsLog( LOG_ERROR, "Level %d: %s", i, ErrMsg->msg ); } } myName = rodsErrorName( status, &mySubName ); rodsLog( LOG_ERROR, "rcTicketAdmin failed with error %d %s %s", status, myName, mySubName ); } return status; }
int isioSetup() { int status; rErrMsg_t errMsg; char *mySubName; char *myName; if (debug) printf("isioSetup\n"); status = getRodsEnv (&myRodsEnv); if (status < 0) { rodsLogError(LOG_ERROR, status, "isioSetup: getRodsEnv error."); } Comm = rcConnect (myRodsEnv.rodsHost, myRodsEnv.rodsPort, myRodsEnv.rodsUserName, myRodsEnv.rodsZone, 0, &errMsg); if (Comm == NULL) { myName = rodsErrorName(errMsg.status, &mySubName); rodsLog(LOG_ERROR, "rcConnect failure %s (%s) (%d) %s", myName, mySubName, errMsg.status, errMsg.msg); status = errMsg.status; return(status); } status = clientLogin(Comm); if (status==0) { setupFlag=1; } return(status); }
void print_irods_error(char *msg, rErrMsg_t *err) { char *subname = 0; char *name = rodsErrorName(err->status, &subname); fprintf(stderr, "%s name %s (%s) (%d) %s\n", msg, name, subname, err->status, err->msg); }
/* Like rodsLogError but with full rodsLog functionality too. Converts the errorcode to a string, and possibly a subcode string, and includes that at the end of a regular log message (with variable arguments). */ void rodsLogError(int level, int rodsErrorCode, char *formatStr, ...) { char bigString[BIG_STRING_LEN]; int i; char *errName; char *errSubName; va_list ap; if (level > verbosityLevel) return; va_start(ap, formatStr); i = vsnprintf(bigString, BIG_STRING_LEN-1, formatStr, ap); va_end(ap); errName = rodsErrorName(rodsErrorCode, &errSubName); if (strlen(errSubName)>0) { rodsLog(level, "%s status = %d %s, %s", bigString, rodsErrorCode, errName, errSubName); } else { rodsLog(level, "%s status = %d %s", bigString, rodsErrorCode, errName); } }
/* Modify (add or remove) AVUs */ int modAVUMetadata(char *arg0, char *arg1, char *arg2, char *arg3, char *arg4, char *arg5, char *arg6, char *arg7, char *arg8) { modAVUMetadataInp_t modAVUMetadataInp; int status; char *mySubName; char *myName; char fullName[MAX_NAME_LEN]; strncpy(fullName, cwd, MAX_NAME_LEN); if (strcmp(arg1,"-R")==0 || strcmp(arg1,"-r")==0 || strcmp(arg1,"-G")==0 || strcmp(arg1,"-g")==0 || strcmp(arg1,"-u")==0) { strncpy(fullName, arg2, MAX_NAME_LEN); } else { if (strlen(arg2)>0) { if (*arg2=='/') { strncpy(fullName, arg2, MAX_NAME_LEN); } else { rstrcat(fullName, "/", MAX_NAME_LEN); rstrcat(fullName, arg2, MAX_NAME_LEN); } } } modAVUMetadataInp.arg0 = arg0; modAVUMetadataInp.arg1 = arg1; modAVUMetadataInp.arg2 = fullName; modAVUMetadataInp.arg3 = arg3; modAVUMetadataInp.arg4 = arg4; modAVUMetadataInp.arg5 = arg5; modAVUMetadataInp.arg6 = arg6; modAVUMetadataInp.arg7 = arg7; modAVUMetadataInp.arg8 = arg8; modAVUMetadataInp.arg9 =""; status = rcModAVUMetadata(Conn, &modAVUMetadataInp); lastCommandStatus = status; if (status < 0 ) { if (Conn->rError) { rError_t *Err; rErrMsg_t *ErrMsg; int i, len; Err = Conn->rError; len = Err->len; for (i=0;i<len;i++) { ErrMsg = Err->errMsg[i]; rodsLog(LOG_ERROR, "Level %d: %s",i, ErrMsg->msg); } } myName = rodsErrorName(status, &mySubName); rodsLog (LOG_ERROR, "rcModAVUMetadata failed with error %d %s %s", status, myName, mySubName); } return(status); }
char *get_irods_error_name(int status, int verb) { char *subname = 0; char *name; name = rodsErrorName(status, &subname); if (verb) { fprintf(stderr, "Extra error message: %s\n", subname); } return name; }
// Modifies the what_ string for a client display suitable what() message void exception::assemble_client_display_what() const throw() { std::stringstream what_ss; what_ss << rodsErrorName( static_cast<int>(code_), NULL ) << ": "; for ( auto entry: message_stack_) { what_ss << entry << "\n"; } what_ss << std::endl; what_ = what_ss.str(); }
/* Convert an error code to a string and log it. This was originally called rodsLogError, but was renamed when we created the new rodsLogError below. This is no longer used ( rodsLogError can be called with the same arguments). */ void rodsLogErrorOld(int level, int rodsErrorCode, char *textStr) { char *errName; char *errSubName; if (level < verbosityLevel) return; errName = rodsErrorName(rodsErrorCode, &errSubName); if (textStr && strlen(textStr)>0) { rodsLog(level, "%s Error: %d: %s, %s", textStr, rodsErrorCode, errName, errSubName); } else { rodsLog(level, "Error: %d: %s, %s", rodsErrorCode, errName, errSubName); } }
// =-=-=-=-=-=-=- // private - helper fcn to build the result string std::string error::build_result_string( std::string _file, int _line, std::string _fcn ) { // =-=-=-=-=-=-=- // decorate message based on status std::string result; if ( status_ ) { result = "[+]\t"; } else { result = "[-]\t"; } // =-=-=-=-=-=-=- // only keep the file name the path back to iRODS std::string line_info; try { //replace with std::to_string when we have c++14 line_info = _file + ":" + boost::lexical_cast<std::string>( _line ) + ":" + _fcn; } catch ( const boost::bad_lexical_cast& ) { line_info = _file + ":<unknown line number>:" + _fcn; } size_t pos = line_info.find( error::iRODS_token_ ); if ( std::string::npos != pos ) { line_info = line_info.substr( pos ); } // =-=-=-=-=-=-=- // get the rods error and errno string char* errno_str = NULL; const char* irods_err = rodsErrorName( code_, &errno_str ); // =-=-=-=-=-=-=- // compose resulting message given all components result += line_info + error::colon_token_ + error::status_token_ + irods_err + "] errno [" + errno_str + "]" + " -- message [" + message_ + "]"; free( errno_str ); return result; } // build_result_string
/* Perform an rcUserAdmin call */ int userAdmin(char *arg0, char *arg1, char *arg2, char *arg3, char *arg4, char *arg5, char *arg6, char *arg7) { userAdminInp_t userAdminInp; int status; char *mySubName; char *myName; char *funcName; userAdminInp.arg0 = arg0; userAdminInp.arg1 = arg1; userAdminInp.arg2 = arg2; userAdminInp.arg3 = arg3; userAdminInp.arg4 = arg4; userAdminInp.arg5 = arg5; userAdminInp.arg6 = arg6; userAdminInp.arg7 = arg7; userAdminInp.arg8 = ""; userAdminInp.arg9 = ""; status = rcUserAdmin(Conn, &userAdminInp); funcName = "rcUserAdmin"; if (Conn->rError) { rError_t *Err; rErrMsg_t *ErrMsg; int i, len; Err = Conn->rError; len = Err->len; for (i=0;i<len;i++) { ErrMsg = Err->errMsg[i]; printf("Level %d message: %s\n",i, ErrMsg->msg); } } if (status < 0 ) { myName = rodsErrorName(status, &mySubName); rodsLog (LOG_ERROR, "%s failed with error %d %s %s",funcName, status, myName, mySubName); if (status == CAT_INVALID_USER_TYPE) { printf("See 'lt user_type' for a list of valid user types.\n"); } } return(status); }
int _rsRegDataObj( rsComm_t *rsComm, dataObjInfo_t *dataObjInfo ) { #ifdef RODS_CAT int status; irods::error ret; status = chlRegDataObj( rsComm, dataObjInfo ); if ( status < 0 ) { char* sys_error; char* rods_error = rodsErrorName( status, &sys_error ); std::stringstream msg; msg << __FUNCTION__; msg << " - Failed to register data object \"" << dataObjInfo->objPath << "\""; msg << " - " << rods_error << " " << sys_error; ret = ERROR( status, msg.str() ); irods::log( ret ); } else { irods::file_object_ptr file_obj( new irods::file_object( rsComm, dataObjInfo ) ); ret = fileRegistered( rsComm, file_obj ); if ( !ret.ok() ) { std::stringstream msg; msg << __FUNCTION__; msg << " - Failed to signal resource that the data object \""; msg << dataObjInfo->objPath; msg << "\" was registered"; ret = PASSMSG( msg.str(), ret ); irods::log( ret ); status = ret.code(); } } return status; #else return SYS_NO_RCAT_SERVER_ERR; #endif }
// Modifies the what_ string for a full what() message void exception::assemble_full_display_what() const throw() { std::stringstream what_ss; what_ss << "iRODS Exception:" << "\n file: " << file_name_ << "\n function: " << function_name_ << "\n line: " << line_number_ << "\n code: " << code_ << " (" << rodsErrorName( static_cast<int>(code_), NULL ) << ")" << "\n message:" << "\n"; for ( auto entry: message_stack_) { what_ss << " " << entry << "\n"; } what_ss << "stack trace:" << "\n" << "--------------" << "\n" << stacktrace_.dump() << std::endl; what_ = what_ss.str(); }
// =-=-=-=-=-=-=- // private - helper fcn to build the result string std::string error::build_result_string( std::string _file, int _line, std::string _fcn ) { // =-=-=-=-=-=-=- // decorate message based on status std::string result; if ( status_ ) { result = "[+]\t"; } else { result = "[-]\t"; } // =-=-=-=-=-=-=- // only keep the file name the path back to iRODS std::string line_info = _file + ":" + boost::lexical_cast<std::string>( _line ) + ":" + _fcn; size_t pos = line_info.find( "iRODS" ); if ( std::string::npos != pos ) { line_info = line_info.substr( pos ); } // =-=-=-=-=-=-=- // get the rods error and errno string char* errno_str = 0; char* irods_err = rodsErrorName( code_, &errno_str ); // =-=-=-=-=-=-=- // compose resulting message given all components result += line_info + " : " + + " status [" + irods_err + "] errno [" + errno_str + "]" + " -- message [" + message_ + "]"; return result; } // build_result_string
int rsDataObjCopy( rsComm_t *rsComm, dataObjCopyInp_t *dataObjCopyInp, transferStat_t **transStat ) { dataObjInp_t *srcDataObjInp, *destDataObjInp; int srcL1descInx, destL1descInx; int status; int existFlag; uint createMode; int remoteFlag; rodsServerHost_t *rodsServerHost; specCollCache_t *specCollCache = NULL; srcDataObjInp = &dataObjCopyInp->srcDataObjInp; destDataObjInp = &dataObjCopyInp->destDataObjInp; resolveLinkedPath( rsComm, srcDataObjInp->objPath, &specCollCache, &srcDataObjInp->condInput ); resolveLinkedPath( rsComm, destDataObjInp->objPath, &specCollCache, &destDataObjInp->condInput ); remoteFlag = getAndConnRemoteZoneForCopy( rsComm, dataObjCopyInp, &rodsServerHost ); if ( remoteFlag < 0 ) { return remoteFlag; } else if ( remoteFlag == REMOTE_HOST ) { status = _rcDataObjCopy( rodsServerHost->conn, dataObjCopyInp, transStat ); return status; } if ( strcmp( srcDataObjInp->objPath, destDataObjInp->objPath ) == 0 ) { rodsLog( LOG_ERROR, "rsDataObjCopy: same src and dest objPath %s not allowed", srcDataObjInp->objPath ); return USER_INPUT_PATH_ERR; } addKeyVal( &srcDataObjInp->condInput, PHYOPEN_BY_SIZE_KW, "" ); srcL1descInx = rsDataObjOpen( rsComm, srcDataObjInp ); if ( srcL1descInx < 0 ) { std::stringstream msg; char* sys_error = NULL; const char* rods_error = rodsErrorName( srcL1descInx, &sys_error ); msg << __FUNCTION__; msg << " - Failed to open source object: \""; msg << srcDataObjInp->objPath; msg << "\" - "; msg << rods_error << " " << sys_error; irods::log( LOG_ERROR, msg.str() ); free( sys_error ); return srcL1descInx; } /* have to set L1desc[srcL1descInx].dataSize because open set this to -1 */ destDataObjInp->dataSize = L1desc[srcL1descInx].dataSize = L1desc[srcL1descInx].dataObjInfo->dataSize; createMode = atoi( L1desc[srcL1descInx].dataObjInfo->dataMode ); if ( createMode >= 0100 ) { destDataObjInp->createMode = createMode; } L1desc[srcL1descInx].oprType = COPY_SRC; if ( L1desc[srcL1descInx].l3descInx <= 2 ) { /* dataSingleBuf */ addKeyVal( &destDataObjInp->condInput, NO_OPEN_FLAG_KW, "" ); } destL1descInx = rsDataObjCreate( rsComm, destDataObjInp ); if ( destL1descInx == CAT_UNKNOWN_COLLECTION ) { /* collection does not exist. make one */ char parColl[MAX_NAME_LEN], child[MAX_NAME_LEN]; splitPathByKey( destDataObjInp->objPath, parColl, MAX_NAME_LEN, child, MAX_NAME_LEN, '/' ); rsMkCollR( rsComm, "/", parColl ); destL1descInx = rsDataObjCreate( rsComm, destDataObjInp ); } if ( destL1descInx < 0 ) { clearKeyVal( &destDataObjInp->condInput ); std::stringstream msg; char* sys_error = NULL; const char* rods_error = rodsErrorName( destL1descInx, &sys_error ); msg << __FUNCTION__; msg << " - Failed to create destination object: \""; msg << destDataObjInp->objPath; msg << "\" - "; msg << rods_error << " " << sys_error; irods::log( LOG_ERROR, msg.str() ); free( sys_error ); return destL1descInx; } if ( L1desc[destL1descInx].replStatus == NEWLY_CREATED_COPY ) { existFlag = 0; } else { existFlag = 1; } L1desc[destL1descInx].oprType = COPY_DEST; L1desc[destL1descInx].srcL1descInx = srcL1descInx; rstrcpy( L1desc[destL1descInx].dataObjInfo->dataType, L1desc[srcL1descInx].dataObjInfo->dataType, NAME_LEN ); /* set dataSize for verification in _rsDataObjClose */ L1desc[destL1descInx].dataSize = L1desc[srcL1descInx].dataObjInfo->dataSize; status = _rsDataObjCopy( rsComm, destL1descInx, existFlag, transStat ); clearKeyVal( &destDataObjInp->condInput ); return status; }
int main( int argc, char **argv ) { int status, i, j; rErrMsg_t errMsg; rodsArguments_t myRodsArgs; char *mySubName; char *myName; int argOffset; int maxCmdTokens = 20; char *cmdToken[20]; int keepGoing; int firstTime; rodsLogLevel( LOG_ERROR ); status = parseCmdLineOpt( argc, argv, "vVhgrcGRCdulz:", 0, &myRodsArgs ); if ( status ) { printf( "Use -h for help.\n" ); exit( 1 ); } if ( myRodsArgs.help == True ) { usage( "" ); exit( 0 ); } if ( myRodsArgs.zone == True ) { strncpy( zoneArgument, myRodsArgs.zoneName, MAX_NAME_LEN ); } if ( myRodsArgs.longOption ) { longMode = 1; } argOffset = myRodsArgs.optind; if ( argOffset > 1 ) { if ( argOffset > 2 ) { if ( *argv[1] == '-' && *( argv[1] + 1 ) == 'z' ) { if ( *( argv[1] + 2 ) == '\0' ) { argOffset = 3; /* skip -z zone */ } else { argOffset = 2; /* skip -zzone */ } } else { argOffset = 1; /* Ignore the parseCmdLineOpt parsing as -d etc handled below*/ } } else { argOffset = 1; /* Ignore the parseCmdLineOpt parsing as -d etc handled below*/ } } status = getRodsEnv( &myEnv ); if ( status < 0 ) { rodsLog( LOG_ERROR, "main: getRodsEnv error. status = %d", status ); exit( 1 ); } strncpy( cwd, myEnv.rodsCwd, BIG_STR ); if ( strlen( cwd ) == 0 ) { strcpy( cwd, "/" ); } for ( i = 0; i < maxCmdTokens; i++ ) { cmdToken[i] = ""; } j = 0; for ( i = argOffset; i < argc; i++ ) { cmdToken[j++] = argv[i]; } #if defined(linux_platform) /* imeta cp -d TestFile1 -d TestFile3 comes in as: -d -d cp TestFile1 TestFile3 so switch it to: cp -d -d TestFile1 TestFile3 */ if ( cmdToken[0] != NULL && *cmdToken[0] == '-' ) { /* args were toggled, switch them back */ if ( cmdToken[1] != NULL && *cmdToken[1] == '-' ) { cmdToken[0] = argv[argOffset + 2]; cmdToken[1] = argv[argOffset]; cmdToken[2] = argv[argOffset + 1]; } else { cmdToken[0] = argv[argOffset + 1]; cmdToken[1] = argv[argOffset]; } } #else /* tested on Solaris, not sure other than Linux/Solaris */ /* imeta cp -d TestFile1 -d TestFile3 comes in as: cp -d TestFile1 -d TestFile3 so switch it to: cp -d -d TestFile1 TestFile3 */ if ( cmdToken[0] != NULL && cmdToken[1] != NULL && *cmdToken[1] == '-' && cmdToken[2] != NULL && cmdToken[3] != NULL && *cmdToken[3] == '-' ) { /* two args */ cmdToken[2] = argv[argOffset + 3]; cmdToken[3] = argv[argOffset + 2]; } #endif if ( strcmp( cmdToken[0], "help" ) == 0 || strcmp( cmdToken[0], "h" ) == 0 ) { usage( cmdToken[1] ); exit( 0 ); } if ( strcmp( cmdToken[0], "spass" ) == 0 ) { char scrambled[MAX_PASSWORD_LEN + 100]; if ( strlen( cmdToken[1] ) > MAX_PASSWORD_LEN - 2 ) { printf( "Password exceeds maximum length\n" ); } else { obfEncodeByKey( cmdToken[1], cmdToken[2], scrambled ); printf( "Scrambled form is:%s\n", scrambled ); } exit( 0 ); } // =-=-=-=-=-=-=- // initialize pluggable api table irods::api_entry_table& api_tbl = irods::get_client_api_table(); irods::pack_entry_table& pk_tbl = irods::get_pack_table(); init_api_table( api_tbl, pk_tbl ); Conn = rcConnect( myEnv.rodsHost, myEnv.rodsPort, myEnv.rodsUserName, myEnv.rodsZone, 0, &errMsg ); if ( Conn == NULL ) { myName = rodsErrorName( errMsg.status, &mySubName ); rodsLog( LOG_ERROR, "rcConnect failure %s (%s) (%d) %s", myName, mySubName, errMsg.status, errMsg.msg ); exit( 2 ); } status = clientLogin( Conn ); if ( status != 0 ) { if ( !debug ) { exit( 3 ); } } keepGoing = 1; firstTime = 1; while ( keepGoing ) { int status; status = doCommand( cmdToken ); if ( status == -1 ) { keepGoing = 0; } if ( firstTime ) { if ( status == 0 ) { keepGoing = 0; } if ( status == -2 ) { keepGoing = 0; lastCommandStatus = -1; } firstTime = 0; } if ( keepGoing ) { getInput( cmdToken, maxCmdTokens ); } } printErrorStack( Conn->rError ); rcDisconnect( Conn ); if ( lastCommandStatus != 0 ) { exit( 4 ); } exit( 0 ); }
int main( int argc, char **argv ) { signal( SIGPIPE, SIG_IGN ); int status; rErrMsg_t errMsg; rodsArguments_t myRodsArgs; rodsEnv myEnv; rodsLogLevel( LOG_ERROR ); status = parseCmdLineOpt( argc, argv, "hvVlz:Z", 1, &myRodsArgs ); if ( status ) { printf( "Use -h for help.\n" ); exit( 1 ); } if ( myRodsArgs.help == True ) { usage(); exit( 0 ); } if ( myRodsArgs.zone == True ) { strncpy( zoneArgument, myRodsArgs.zoneName, MAX_NAME_LEN ); } status = getRodsEnv( &myEnv ); if ( status < 0 ) { rodsLog( LOG_ERROR, "main: getRodsEnv error. status = %d", status ); exit( 1 ); } // =-=-=-=-=-=-=- // initialize pluggable api table irods::pack_entry_table& pk_tbl = irods::get_pack_table(); irods::api_entry_table& api_tbl = irods::get_client_api_table(); init_api_table( api_tbl, pk_tbl ); Conn = rcConnect( myEnv.rodsHost, myEnv.rodsPort, myEnv.rodsUserName, myEnv.rodsZone, 0, &errMsg ); if ( Conn == NULL ) { char *mySubName = NULL; const char *myName = rodsErrorName( errMsg.status, &mySubName ); rodsLog( LOG_ERROR, "rcConnect failure %s (%s) (%d) %s", myName, mySubName, errMsg.status, errMsg.msg ); free( mySubName ); exit( 2 ); } status = clientLogin( Conn ); if ( status != 0 ) { exit( 3 ); } // tree view if ( myRodsArgs.longOption != True ) { if ( myRodsArgs.ascii == True ) { // character set for printing tree gfx_mode = 0; } status = showRescTree( argv[myRodsArgs.optind] ); } else { // regular view status = showResc( argv[myRodsArgs.optind], myRodsArgs.longOption ); } printErrorStack( Conn->rError ); rcDisconnect( Conn ); /* Exit 0 if one or more items were displayed */ if ( status >= 0 ) { return 0; } else { return status; } }
int main(int argc, char **argv) { int status; rsComm_t *Comm; /* rErrMsg_t errMsg;*/ rodsArguments_t myRodsArgs; char *mySubName; char *myName; int didOne; rodsServerConfig_t serverConfig; Comm = (rsComm_t*)malloc (sizeof (rsComm_t)); memset (Comm, 0, sizeof (rsComm_t)); parseCmdLineOpt(argc, argv, "", 0, &myRodsArgs); rodsLogLevel(LOG_NOTICE); rodsLogSqlReq(1); if (argc < 2) { printf("Usage: test_chl testName [args...]\n"); exit(3); } status = getRodsEnv (&myEnv); if (status < 0) { rodsLog (LOG_ERROR, "main: getRodsEnv error. status = %d", status); exit (1); } if (strstr(myEnv.rodsDebug, "CAT") != NULL) { chlDebug(myEnv.rodsDebug); } memset(&serverConfig, 0, sizeof(serverConfig)); status = readServerConfig(&serverConfig); strncpy(Comm->clientUser.userName, myEnv.rodsUserName, sizeof Comm->clientUser.userName); strncpy(Comm->clientUser.rodsZone, myEnv.rodsZone, sizeof Comm->clientUser.rodsZone); /* char rodsUserName[NAME_LEN]; char rodsZone[NAME_LEN]; userInfo_t clientUser; char userName[NAME_LEN]; char rodsZone[NAME_LEN]; */ if ((status = chlOpen(serverConfig.DBUsername, serverConfig.DBPassword)) != 0) { rodsLog (LOG_SYS_FATAL, "initInfoWithRcat: chlopen Error. Status = %d", status); free(Comm); // cppcheck - Memory leak: Comm return (status); } didOne=0; if (strcmp(argv[1],"reg")==0) { status = testRegDataObj(Comm, argv[2], argv[3], argv[4]); didOne=1; } if (strcmp(argv[1],"regmulti")==0) { status = testRegDataMulti(Comm, argv[2], argv[3], argv[4], argv[5]); didOne=1; } if (strcmp(argv[1],"mod")==0) { status = testModDataObjMeta(Comm, argv[2], argv[3], argv[4]); didOne=1; } if (strcmp(argv[1],"mod2")==0) { status = testModDataObjMeta2(Comm, argv[2], argv[3], argv[4]); didOne=1; } if (strcmp(argv[1],"modr")==0) { status = testModRuleMeta(Comm, argv[2], argv[3], argv[4]); didOne=1; } if (strcmp(argv[1],"modc")==0) { status = testModColl(Comm, argv[2], argv[3], argv[4], argv[5]); didOne=1; } if (strcmp(argv[1],"rmrule")==0) { status = testDelRule(Comm, argv[2], argv[3]); didOne=1; } if (strcmp(argv[1],"modrfs")==0) { status = testModResourceFreeSpace(Comm, argv[2], argv[3], argv[4]); didOne=1; } if (strcmp(argv[1],"rep")==0) { if (argc < 6) { printf("too few arguments\n"); exit(1); } status = testRegReplica(Comm, argv[2], argv[3], argv[4], argv[5]); didOne=1; } /* if (strcmp(argv[1],"cml")==0) { status = testCml(Comm); didOne=1; } */ if (strcmp(argv[1],"rmuser")==0) { status = testDelUser(Comm, argv[2], argv[3]); didOne=1; } if (strcmp(argv[1],"mkdir")==0) { status = testRegColl(Comm, argv[2]); didOne=1; } if (strcmp(argv[1],"rmdir")==0) { status = testDelColl(Comm, argv[2]); didOne=1; } if (strcmp(argv[1],"sql")==0) { status = testSimpleQ(Comm, argv[2], argv[3], argv[4]); didOne=1; } if (strcmp(argv[1],"rm")==0) { status = testDelFile(Comm, argv[2], argv[3]); didOne=1; } if (strcmp(argv[1],"rmtrash")==0) { status = testDelFileTrash(Comm, argv[2], argv[3]); didOne=1; } if (strcmp(argv[1],"rmpriv")==0) { status = testDelFilePriv(Comm, argv[2], argv[3], argv[4]); didOne=1; } if (strcmp(argv[1],"chmod")==0) { status = testChmod(Comm, argv[2], argv[3], argv[4], argv[5]); didOne=1; } if (strcmp(argv[1],"regrule")==0) { status = testRegRule(Comm, argv[2]); didOne=1; } if (strcmp(argv[1],"rename")==0) { status = testRename(Comm, argv[2], argv[3]); testCurrent(Comm); /* exercise this as part of rename; testCurrent needs a SQL context */ didOne=1; } if (strcmp(argv[1],"login")==0) { status = testLogin(Comm, argv[2], argv[3], argv[4]); didOne=1; } if (strcmp(argv[1],"move")==0) { status = testMove(Comm, argv[2], argv[3]); didOne=1; } if (strcmp(argv[1],"checkauth")==0) { status = testCheckAuth(Comm, argv[2], argv[3], argv[4]); didOne=1; } if (strcmp(argv[1],"temppw")==0) { status = testTempPw(Comm); didOne=1; } if (strcmp(argv[1],"tpc")==0) { status = testTempPwConvert(argv[2], argv[3]); didOne=1; } if (strcmp(argv[1],"tpw")==0) { status = testTempPwCombined(Comm, argv[2]); didOne=1; } if (strcmp(argv[1],"tpwforother")==0) { status = testTempPwForOther(Comm, argv[2], argv[3]); didOne=1; } if (strcmp(argv[1],"serverload")==0) { status = testServerLoad(Comm, argv[2]); didOne=1; } if (strcmp(argv[1],"purgeload")==0) { status = testPurgeServerLoad(Comm, argv[2]); didOne=1; } if (strcmp(argv[1],"serverdigest")==0) { status = testServerLoadDigest(Comm, argv[2]); didOne=1; } if (strcmp(argv[1],"purgedigest")==0) { status = testPurgeServerLoadDigest(Comm, argv[2]); didOne=1; } if (strcmp(argv[1],"checkquota")==0) { if (argc < 5) { status = testCheckQuota(Comm, argv[2], argv[3], NULL, NULL); } else { status = testCheckQuota(Comm, argv[2], argv[3], argv[4], argv[5]); } didOne=1; } if (strcmp(argv[1],"open")==0) { int i; for (i=0;i<3;i++) { status = chlClose(); if (status) { printf ("close %d error", i); } if ((status = chlOpen(serverConfig.DBUsername, serverConfig.DBPassword)) != 0) { rodsLog (LOG_SYS_FATAL, "initInfoWithRcat: chlopen %d Error. Status = %d", i, status); return (status); } } didOne=1; } if (strcmp(argv[1],"addrule")==0) { status = testAddRule(Comm, argv[2], argv[3], argv[4], argv[5], argv[6], argv[7]); didOne=1; } if (strcmp(argv[1],"versionrulebase")==0) { status = testVersionRuleBase(Comm, argv[2]); didOne=1; } if (strcmp(argv[1],"versiondvmbase")==0) { status = testVersionDvmBase(Comm, argv[2]); didOne=1; } if (strcmp(argv[1],"versionfnmbase")==0) { status = testVersionFnmBase(Comm, argv[2]); didOne=1; } if (strcmp(argv[1],"insfnmtable")==0) { status = testInsFnmTable(Comm, argv[2], argv[3], argv[4], argv[5] ); didOne=1; } if (strcmp(argv[1],"insdvmtable")==0) { status = testInsDvmTable(Comm, argv[2], argv[3], argv[4], argv[5] ); didOne=1; } if (strcmp(argv[1],"insmsrvctable")==0) { status = testInsMsrvcTable(Comm, argv[2], argv[3], argv[4], argv[5], argv[6], argv[7], argv[8], argv[9], argv[10]); if (status==0) { /* do it a second time to test another logic path and different SQL. Since no commit is part of the chl function, and there is not corresponding Delete call, this is an easy way to do this. */ status = testInsMsrvcTable(Comm, argv[2], argv[3], argv[4], argv[5], argv[6], argv[7], argv[8], argv[9], argv[10]); } didOne=1; } if (strcmp(argv[1],"getlocalzone")==0) { status = testGetLocalZone(Comm, argv[2]); didOne=1; } if (strcmp(argv[1],"getpampw")==0) { status = testGetPamPw(Comm, argv[2], argv[3]); didOne=1; } if (status != 0) { /* if (Comm->rError) { rError_t *Err; rErrMsg_t *ErrMsg; int i, len; Err = Comm->rError; len = Err->len; for (i=0;i<len;i++) { ErrMsg = Err->errMsg[i]; rodsLog(LOG_ERROR, "Level %d: %s",i, ErrMsg->msg); } } */ myName = rodsErrorName(status, &mySubName); rodsLog (LOG_ERROR, "%s failed with error %d %s %s", argv[1], status, myName, mySubName); } else { if (didOne) printf("Completed successfully\n"); } if (didOne==0) { printf("Unknown test type: %s\n", argv[1]); } exit(status); }
int main(int argc, char **argv) { int status, status2; rErrMsg_t errMsg; rodsArguments_t myRodsArgs; char *mySubName; char *myName; rodsEnv myEnv; rodsLogLevel(LOG_ERROR); status = parseCmdLineOpt (argc, argv, "AhvVlz:", 0, &myRodsArgs); if (status) { printf("Use -h for help.\n"); exit(1); } if (myRodsArgs.help==True) { usage(); exit(0); } if (myRodsArgs.zone==True) { strncpy(zoneArgument, myRodsArgs.zoneName, MAX_NAME_LEN); } status = getRodsEnv (&myEnv); if (status < 0) { rodsLog (LOG_ERROR, "main: getRodsEnv error. status = %d", status); exit (1); } Conn = rcConnect (myEnv.rodsHost, myEnv.rodsPort, myEnv.rodsUserName, myEnv.rodsZone, 0, &errMsg); if (Conn == NULL) { myName = rodsErrorName(errMsg.status, &mySubName); rodsLog(LOG_ERROR, "rcConnect failure %s (%s) (%d) %s", myName, mySubName, errMsg.status, errMsg.msg); exit (2); } status = clientLogin(Conn); if (status != 0) { exit (3); } status2=0; if (myRodsArgs.optind == argc) { /* no resource name specified */ status = showResc(argv[myRodsArgs.optind], myRodsArgs.longOption); status2 = showRescGroups(myRodsArgs.longOption); } else { if (myRodsArgs.accessControl == True) { showRescAcl(argv[myRodsArgs.optind]); } else { status = showOneRescGroup(argv[myRodsArgs.optind], myRodsArgs.longOption); if (status==0) { status2 = showResc(argv[myRodsArgs.optind], myRodsArgs.longOption); if (status2==0) { /* Only print this if both fail */ printf("Resource-group %s does not exist.\n", argv[myRodsArgs.optind]); } } } } printErrorStack(Conn->rError); rcDisconnect(Conn); /* Exit 0 if one or more items were displayed */ if (status > 0) exit(0); if (status2 > 0) exit(0); exit(4); }
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 }
void CLogin::OnOK() { if((m_PasswordEditbox.GetWindowTextLength() == 0) || (m_ZoneCombobox.GetWindowTextLength() == 0) || (m_HostCombobox.GetWindowTextLength() == 0) || (m_NameCombobox.GetWindowTextLength() == 0) || (m_PortCombobox.GetWindowTextLength() == 0)) { AfxMessageBox("At least one field is empty!"); return; } m_ZoneCombobox.GetWindowText(m_szZone); m_HostCombobox.GetWindowText(m_szHost); m_NameCombobox.GetWindowText(m_szName); m_PortCombobox.GetWindowText(m_szPort); m_PasswordEditbox.GetWindowText(m_szPassword); this->BeginWaitCursor(); // now we start to connect to iRODS server CInquisitorApp* pApp = (CInquisitorApp *)AfxGetApp(); rErrMsg_t errMsg; CString msg; // conn pApp->conn = rcConnect((char *)(LPCTSTR)(m_szHost), atoi((char *)(LPCTSTR)(m_szPort)), (char *)(LPCTSTR)(m_szName), ((char *)(LPCTSTR)m_szZone), 0, &errMsg); if(pApp->conn == NULL) { this->EndWaitCursor(); pApp->conn = NULL; //this->KillTimer(CLOGIN_TIMER_ID); msg = CString(errMsg.msg) + CString("The server on ") + m_szHost + CString(" is probably down."); AfxMessageBox(msg); return; } int t = clientLoginWithPassword(pApp->conn, (char *)(LPCTSTR)(m_szPassword)); if(t < 0) { char *myErrName, *mySubErrName; myErrName = rodsErrorName(t, &mySubErrName); msg.Format("irods login error: %s %s.", myErrName, mySubErrName); free(pApp->conn); pApp->conn = NULL; this->EndWaitCursor(); AfxMessageBox(msg); return; } // go through the list to see if there is a match. If yes, get the default resource CString login_match_str = m_szName + " in " + m_szZone + " at " + m_szHost + " | " + m_szPort; for(int i=0;i<m_ListBox.GetItemCount();i++) { //CString tmpstr = m_ListBox.GetItemText(i, 0); //if(login_match_str.Compare(tmpstr) == 0) if(login_match_str.Compare(m_prevLogins[i]) == 0) { char buf[256]; sprintf(buf, "History\\%d", i+1); m_szDefaultResource = pApp->GetProfileString(buf, "DefaultResource"); m_nProfileId = i+1; pApp->WriteProfileInt("History", "LastLogin", i+1); } } this->EndWaitCursor(); CDialog::OnOK(); }
/* Modify (copy) AVUs */ int modCopyAVUMetadata(char *arg0, char *arg1, char *arg2, char *arg3, char *arg4, char *arg5, char *arg6, char *arg7) { modAVUMetadataInp_t modAVUMetadataInp; int status; char *mySubName; char *myName; char fullName1[MAX_NAME_LEN]; char fullName2[MAX_NAME_LEN]; strncpy(fullName1, cwd, MAX_NAME_LEN); if (strcmp(arg1,"-R")==0 || strcmp(arg1,"-r")==0 || strcmp(arg1,"-G")==0 || strcmp(arg1,"-g")==0 || strcmp(arg1,"-u")==0) { strncpy(fullName1, arg3, MAX_NAME_LEN); } else { if (strlen(arg3)>0) { if (*arg3=='/') { strncpy(fullName1, arg3, MAX_NAME_LEN); } else { rstrcat(fullName1, "/", MAX_NAME_LEN); rstrcat(fullName1, arg3, MAX_NAME_LEN); } } } strncpy(fullName2, cwd, MAX_NAME_LEN); if (strcmp(arg2,"-R")==0 || strcmp(arg2,"-r")==0 || strcmp(arg2,"-G")==0 || strcmp(arg2,"-g")==0 || strcmp(arg2,"-u")==0) { strncpy(fullName2, arg4, MAX_NAME_LEN); } else { if (strlen(arg4)>0) { if (*arg4=='/') { strncpy(fullName2, arg4, MAX_NAME_LEN); } else { rstrcat(fullName2, "/", MAX_NAME_LEN); rstrcat(fullName2, arg4, MAX_NAME_LEN); } } } modAVUMetadataInp.arg0 = arg0; modAVUMetadataInp.arg1 = arg1; modAVUMetadataInp.arg2 = arg2; modAVUMetadataInp.arg3 = fullName1; modAVUMetadataInp.arg4 = fullName2; modAVUMetadataInp.arg5 = arg5; modAVUMetadataInp.arg6 = arg6; modAVUMetadataInp.arg7 = arg7; modAVUMetadataInp.arg8 =""; modAVUMetadataInp.arg9 =""; status = rcModAVUMetadata(Conn, &modAVUMetadataInp); lastCommandStatus = status; if (status < 0 ) { if (Conn->rError) { rError_t *Err; rErrMsg_t *ErrMsg; int i, len; Err = Conn->rError; len = Err->len; for (i=0;i<len;i++) { ErrMsg = Err->errMsg[i]; rodsLog(LOG_ERROR, "Level %d: %s",i, ErrMsg->msg); } } myName = rodsErrorName(status, &mySubName); rodsLog (LOG_ERROR, "rcModAVUMetadata failed with error %d %s %s", status, myName, mySubName); } if (status == CAT_UNKNOWN_FILE) { char tempName[MAX_NAME_LEN]="/"; int len; int isRemote=0; strncat(tempName, myEnv.rodsZone, MAX_NAME_LEN); len = strlen(tempName); if (strncmp(tempName, fullName1, len) != 0) { printf("Cannot copy metadata from a remote zone.\n"); isRemote=1; } if (strncmp(tempName, fullName2, len) != 0) { printf("Cannot copy metadata to a remote zone.\n"); isRemote=1; } if (isRemote) { printf("Copying of metadata is done via SQL within each ICAT\n"); printf("for efficiency. Copying metadata between zones is\n"); printf("not implemented.\n"); } } return(status); }
int main(int argc, char **argv) { int status, i, j; rErrMsg_t errMsg; rodsEnv myEnv; rodsArguments_t myRodsArgs; char *mySubName; char *myName; int argOffset; int maxCmdTokens=20; char *cmdToken[20]; int keepGoing; int firstTime; rodsLogLevel(LOG_ERROR); status = parseCmdLineOpt (argc, argv, "vVh", 0, &myRodsArgs); if (status) { printf("Use -h for help.\n"); exit(1); } if (myRodsArgs.help==True) { usage(""); exit(0); } argOffset = myRodsArgs.optind; status = getRodsEnv (&myEnv); if (status < 0) { rodsLog (LOG_ERROR, "main: getRodsEnv error. status = %d", status); exit (1); } strncpy(myZone, myEnv.rodsZone, sizeof(myZone)); for (i=0;i<maxCmdTokens;i++) { cmdToken[i]=""; } j=0; for (i=argOffset;i<argc;i++) { cmdToken[j++]=argv[i]; } if (strcmp(cmdToken[0],"help")==0 || strcmp(cmdToken[0],"h") == 0) { usage(cmdToken[1]); exit(0); } if (strcmp(cmdToken[0],"spass") ==0) { char scrambled[MAX_PASSWORD_LEN+100]; if (strlen(cmdToken[1])>MAX_PASSWORD_LEN-2) { printf("Password exceeds maximum length\n"); } else { obfEncodeByKey(cmdToken[1], cmdToken[2], scrambled); printf("Scrambled form is:%s\n", scrambled); } exit(0); } Conn = rcConnect (myEnv.rodsHost, myEnv.rodsPort, myEnv.rodsUserName, myEnv.rodsZone, 0, &errMsg); if (Conn == NULL) { myName = rodsErrorName(errMsg.status, &mySubName); rodsLog(LOG_ERROR, "rcConnect failure %s (%s) (%d) %s", myName, mySubName, errMsg.status, errMsg.msg); exit (2); } status = clientLogin(Conn); if (status != 0) { rcDisconnect(Conn); exit (3); } keepGoing=1; firstTime=1; while (keepGoing) { int status; status=doCommand(cmdToken); if (status==-1) keepGoing=0; if (firstTime) { if (status==0) keepGoing=0; if (status==-2) { keepGoing=0; lastCommandStatus=-1; } firstTime=0; } if (keepGoing) { getInput(cmdToken, maxCmdTokens); } } printErrorStack(Conn->rError); rcDisconnect(Conn); if (lastCommandStatus != 0) exit(4); exit(0); }
int main(int argc, char **argv) { int status; rodsArguments_t myRodsArgs; rodsEnv myEnv; int i, j, didOne; char objPath[MAX_NAME_LEN]; int maxCmdTokens=20; char *cmdToken[20]; int argOffset; rcComm_t *Conn; rErrMsg_t errMsg; char *mySubName; char *myName; status = parseCmdLineOpt(argc, argv, "lvVh", 0, &myRodsArgs); if (status) { printf("Use -h for help\n"); exit(1); } if (myRodsArgs.help==True) { usage(""); exit(0); } argOffset = myRodsArgs.optind; status = getRodsEnv (&myEnv); if (status < 0) { rodsLog (LOG_ERROR, "main: getRodsEnv error. status = %d", status); exit (1); } strncpy(objPath,myEnv.rodsCwd,MAX_NAME_LEN); for (i=0;i<maxCmdTokens;i++) { cmdToken[i]=""; } j=0; for (i=argOffset;i<argc;i++) { cmdToken[j++]=argv[i]; } Conn = rcConnect (myEnv.rodsHost, myEnv.rodsPort, myEnv.rodsUserName, myEnv.rodsZone, 0, &errMsg); if (Conn == NULL) { myName = rodsErrorName(errMsg.status, &mySubName); rodsLog(LOG_ERROR, "rcConnect failure %s (%s) (%d) %s", myName, mySubName, errMsg.status, errMsg.msg); exit (2); } status = clientLogin(Conn); if (status != 0) { rcDisconnect(Conn); exit (3); } if (strcmp(cmdToken[0],"ldt")==0) { if (*cmdToken[1]=='\0') { cmdToken[1]=" "; /* just for subsequent checks below */ } } if (*cmdToken[1]=='\0') { usage(""); exit(1); } if (*cmdToken[1]=='/') { rstrcpy(objPath, cmdToken[1], MAX_NAME_LEN); } else { rstrcat(objPath, "/", MAX_NAME_LEN); rstrcat(objPath, cmdToken[1], MAX_NAME_LEN); } didOne=0; if (strcmp(cmdToken[0],"ls")==0) { int longOption; if (myRodsArgs.longOption) longOption=1; if (myRodsArgs.verbose) longOption=1; doLs(Conn, objPath, longOption); didOne=1; } if (strcmp(cmdToken[0],"ldt")==0) { doListDataTypes(Conn); didOne=1; } if (strcmp(cmdToken[0],"mod")==0) { char theTime[TIME_LEN+20]; if (*cmdToken[2]=='\0') { usage(""); exit(1); } if (strcmp(cmdToken[2],"datatype")==0) { if (*cmdToken[3]=='\0') { usage(""); exit(1); } status = doModDatatype(Conn, objPath, cmdToken[3]); didOne=1; } else if (strcmp(cmdToken[2],"comment")==0) { if (*cmdToken[3]=='\0') { usage(""); exit(1); } if (*cmdToken[4]=='\0') { status = doModComment(Conn, objPath, -1, cmdToken[3]); } else { status = doModComment(Conn, objPath, atoi(cmdToken[3]), cmdToken[4]); } didOne=1; } else { rstrcpy(theTime, cmdToken[2], TIME_LEN); status=0; if (*cmdToken[2]=='+') { rstrcpy(theTime, cmdToken[2]+1, TIME_LEN); /* skip the + */ status = checkDateFormat(theTime); /* check and convert the time value */ getOffsetTimeStr(theTime, theTime); /* convert delta format to now + this*/ } else { status = checkDateFormat(theTime); /* check and convert the time value */ } if (status==0) { status = doMod(Conn, objPath, theTime); didOne=1; } else { printf("Invalid time format input\n"); } } } printErrorStack(Conn->rError); rcDisconnect(Conn); if (didOne==0) { usage(""); exit(1); } exit(0); }
int rsDataObjUnlink( rsComm_t *rsComm, dataObjInp_t *dataObjUnlinkInp ) { int status; ruleExecInfo_t rei; int trashPolicy; dataObjInfo_t *dataObjInfoHead = NULL; rodsServerHost_t *rodsServerHost = NULL; int rmTrashFlag = 0; specCollCache_t *specCollCache = NULL; resolveLinkedPath( rsComm, dataObjUnlinkInp->objPath, &specCollCache, &dataObjUnlinkInp->condInput ); status = getAndConnRcatHost( rsComm, MASTER_RCAT, ( const char* )dataObjUnlinkInp->objPath, &rodsServerHost ); if ( status < 0 || NULL == rodsServerHost ) { // JMC cppcheck - nullptr return status; } else if ( rodsServerHost->rcatEnabled == REMOTE_ICAT ) { rcDataObjUnlink( rodsServerHost->conn, dataObjUnlinkInp ); return status; } // =-=-=-=-=-=-=- // 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 // =-=-=-=-=-=-=- // determine the resource hierarchy if one is not provided addKeyVal( &dataObjUnlinkInp->condInput, irods::UNLINK_OPERATION.c_str(), "true" ); if ( getValByKey( &dataObjUnlinkInp->condInput, RESC_HIER_STR_KW ) == NULL ) { std::string hier; irods::error ret = irods::resolve_resource_hierarchy( irods::OPEN_OPERATION, rsComm, dataObjUnlinkInp, hier ); if ( !ret.ok() ) { std::stringstream msg; msg << "failed in irods::resolve_resource_hierarchy for ["; msg << dataObjUnlinkInp->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( &dataObjUnlinkInp->condInput, RESC_HIER_STR_KW, hier.c_str() ); } // if keyword if ( getValByKey( &dataObjUnlinkInp->condInput, ADMIN_RMTRASH_KW ) != NULL || getValByKey( &dataObjUnlinkInp->condInput, RMTRASH_KW ) != NULL ) { if ( isTrashPath( dataObjUnlinkInp->objPath ) == False ) { return SYS_INVALID_FILE_PATH; } rmTrashFlag = 1; } dataObjUnlinkInp->openFlags = O_WRONLY; /* set the permission checking */ status = getDataObjInfoIncSpecColl( rsComm, dataObjUnlinkInp, &dataObjInfoHead ); if ( status < 0 ) { char* sys_error = NULL; const char* rods_error = rodsErrorName( status, &sys_error ); std::stringstream msg; msg << __FUNCTION__; msg << " - Failed to get data objects."; msg << " - " << rods_error << " " << sys_error; irods::error result = ERROR( status, msg.str() ); irods::log( result ); free( sys_error ); return status; } if ( rmTrashFlag == 1 ) { char *tmpAge; int ageLimit; if ( ( tmpAge = getValByKey( &dataObjUnlinkInp->condInput, AGE_KW ) ) != NULL ) { ageLimit = atoi( tmpAge ) * 60; if ( ( time( 0 ) - atoi( dataObjInfoHead->dataModify ) ) < ageLimit ) { /* younger than ageLimit. Nothing to do */ freeAllDataObjInfo( dataObjInfoHead ); return 0; } } } if ( dataObjUnlinkInp->oprType == UNREG_OPR || getValByKey( &dataObjUnlinkInp->condInput, FORCE_FLAG_KW ) != NULL || getValByKey( &dataObjUnlinkInp->condInput, REPL_NUM_KW ) != NULL || getValByKey( &dataObjUnlinkInp->condInput, EMPTY_BUNDLE_ONLY_KW ) != NULL || dataObjInfoHead->specColl != NULL || rmTrashFlag == 1 ) { status = _rsDataObjUnlink( rsComm, dataObjUnlinkInp, &dataObjInfoHead ); } else { initReiWithDataObjInp( &rei, rsComm, dataObjUnlinkInp ); status = applyRule( "acTrashPolicy", NULL, &rei, NO_SAVE_REI ); trashPolicy = rei.status; if ( trashPolicy != NO_TRASH_CAN ) { status = rsMvDataObjToTrash( rsComm, dataObjUnlinkInp, &dataObjInfoHead ); freeAllDataObjInfo( dataObjInfoHead ); return status; } else { status = _rsDataObjUnlink( rsComm, dataObjUnlinkInp, &dataObjInfoHead ); } } initReiWithDataObjInp( &rei, rsComm, dataObjUnlinkInp ); rei.doi = dataObjInfoHead; rei.status = status; // 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); rei.status = applyRule( "acPostProcForDelete", NULL, &rei, NO_SAVE_REI ); if ( rei.status < 0 ) { rodsLog( LOG_NOTICE, "rsDataObjUnlink: acPostProcForDelete error for %s. status = %d", dataObjUnlinkInp->objPath, rei.status ); } /* dataObjInfoHead may be outdated */ freeAllDataObjInfo( dataObjInfoHead ); return status; }