00001 /** 00002 * @file icatGeneralMS.c 00003 * 00004 */ 00005 00006 /*** Copyright (c), The Regents of the University of California *** 00007 *** For more information please refer to files in the COPYRIGHT directory ***/ 00008 #include "reGlobalsExtern.h" 00009 #include "icatHighLevelRoutines.h" 00010 #include "objMetaOpr.h" 00011 00012 /** \mainpage iRODS Documentation 00013 00014 This documentation is generated from the iRODS code. 00015 00016 \section overview Overview 00017 - http://www.irods.org 00018 00019 - <a href="globals.html">Full Alphabetical List of Microservices</a> 00020 00021 - <a href="workflow.html">Rule Engine Workflow Microservices</a> 00022 - #msiGoodFailure - Useful when you want to fail but no recovery initiated 00023 - #msiSleep - Sleep 00024 00025 \section msicore Core Microservices 00026 00027 \subsection msiruleengine Rule Engine Microservices 00028 - #msiAdmChangeCoreIRB - Changes the core.irb file from the client 00029 - #msiAdmAppendToTopOfCoreIRB - Prepends another irb file to the core.irb file 00030 - #msiAdmAddAppRuleStruct - Adds application level IRB rules and DVM and FNM mappings to the rule engine 00031 - #msiAdmClearAppRuleStruct - Clears application level IRB rules and DVM and FNM mappings that were loaded into the rule engine 00032 00033 - #msiAdmShowIRB - Displays the currently loaded rules 00034 - #msiAdmShowDVM - Displays the currently loaded data variable mappings 00035 - #msiAdmShowFNM - Displays the currently loaded microservices and action (function) name mappings 00036 00037 - #msiAdmReadRulesFromFileIntoStruct - Reads a rule configuration file into a rule structure 00038 - #msiAdmInsertRulesFromStructIntoDB - Writes a rule structure into the current rule base 00039 - #msiGetRulesFromDBIntoStruct - Populates a rule structure with rules from the given base name 00040 - #msiAdmWriteRulesFromStructIntoFile - Writes to file the rules within a given rule structure 00041 00042 - #msiAdmReadDVMapsFromFileIntoStruct - Reads a DVM configuration file into a DVM structure 00043 - #msiAdmInsertDVMapsFromStructIntoDB - Writes a DVM structure into the current DVM base 00044 - #msiGetDVMapsFromDBIntoStruct - Populates a DVM structure with DVMs from the given base name 00045 - #msiAdmWriteDVMapsFromStructIntoFile - Writes to file the DVMs within a given DVM structure 00046 00047 - #msiAdmReadFNMapsFromFileIntoStruct - Reads a FNM configuration file into a FNM structure 00048 - #msiAdmInsertFNMapsFromStructIntoDB - Writes an FNM structure into the current FNM base 00049 - #msiGetFNMapsFromDBIntoStruct - Populates an FNM structure with FNMs from the given base name 00050 - #msiAdmWriteFNMapsFromStructIntoFile - Writes to file the FNMs within a given FNM structure 00051 00052 - #msiAdmReadMSrvcsFromFileIntoStruct - Reads a microservice configuration file into a microservice structure 00053 - #msiAdmInsertMSrvcsFromStructIntoDB - Writes a microservice structure into the current microservices base 00054 - #msiGetMSrvcsFromDBIntoStruct - Populates a microservice structure with microservices from the given base name 00055 - #msiAdmWriteMSrvcsFromStructIntoFile - Writes to file the microservices within a given microservice structure 00056 00057 \subsection msihelper Helper Microservices 00058 Can be called by client through irule. 00059 - #msiGetStdoutInExecCmdOut - Gets stdout buffer from ExecCmdOut into buffer 00060 - #msiGetStderrInExecCmdOut - Gets stderr buffer from ExecCmdOut into buffer 00061 - #msiWriteRodsLog - Writes a message into the server rodsLog 00062 - #msiAddKeyValToMspStr - Adds a key and value to existing msKeyValStr 00063 - #msiSplitPath - Splits a pathname into parent and child values 00064 - #msiGetSessionVarValue - Gets the value of a session variable in the rei 00065 - #msiExit - Add a user message to the error stack 00066 00067 \subsection msidatabase Database Object (DBO) and DB Resource (DBR) Microservices 00068 Can be called by client through irule. 00069 - #msiDboExec - Execute a database object on a DBR 00070 - #msiDbrCommit - Executes a commit on a DBR 00071 - #msiDbrRollback - Executes a rollback on a DBR 00072 00073 \subsection msilowlevel Data Object Low-level Microservices 00074 Can be called by client through irule. 00075 - #msiDataObjCreate - Create a data object 00076 - #msiDataObjOpen - Open a data object 00077 - #msiDataObjClose - Close an opened data object 00078 - #msiDataObjLseek - Repositions the read/write offset of an open data object 00079 - #msiDataObjRead - Read an opened data object 00080 - #msiDataObjWrite - Write to an opened data object 00081 00082 \subsection msidataobject Data Object Microservices 00083 Can be called by client through irule. 00084 - #msiDataObjUnlink - Delete a data object 00085 - #msiDataObjRepl - Replicate a data object 00086 - #msiDataObjCopy - Copy a data object 00087 - #msiDataObjGet - Get a data object 00088 - #msiDataObjPut - Put a data object 00089 - #msiDataObjChksum - Checksum a data object 00090 - #msiDataObjPhymv - Move a data object from one resource to another 00091 - #msiDataObjRename - Rename a data object 00092 - #msiDataObjTrim - Trim the replicas of a data object 00093 - #msiPhyPathReg - Register a physical file into iRODS 00094 - #msiObjStat - Stat an iRODS object 00095 - #msiDataObjRsync - Syncs a data object from a source to a destination 00096 - #msiCollRsync - Recursively syncs a source collection to a target collection 00097 - #msiGetObjType - Finds if a given value is a data, coll, resc, ... 00098 - #msiCheckPermission - Check if a data object permission is the same as the one given 00099 - #msiCheckOwner - Check if the user is the owner of the data object 00100 - #msiSetReplComment - Sets the data_comments attribute of a data object 00101 00102 \subsection msicollection Collection Microservices 00103 - #msiCollCreate - Create a collection 00104 - #msiCollRepl - Replicate all files in a collection 00105 - #msiRmColl - Delete a collection 00106 - #msiAutoReplicateService - Checks and repairs up to n replicas 00107 - #msiDataObjAutoMove - Used to automatically move the newly created file into a destination collection 00108 - #msiTarFileExtract - Extracts a tar object file into a target collection 00109 - #msiTarFileCreate - Creates a tar object file from a target collection 00110 - #msiPhyBundleColl - Bundles a collection into a number of tar files, similar to the iphybun command 00111 00112 \subsection msiproxy Proxy Command Microservices 00113 - #msiExecCmd - Remotely execute a command 00114 00115 \subsection msiicat iCAT Microservices 00116 iCAT System Services 00117 - #msiVacuum - Postgres vacuum - done periodically 00118 - #msiQuota - Calculates storage usage and sets quota values 00119 - #msiCommit - Commits the database transaction 00120 - #msiRollback - Rollback the current database transaction 00121 - #msiSetACL - Changes the ACL for a given pathname, either a collection or a data object 00122 - #msiCreateUser - Creates a new user 00123 - #msiDeleteUser - Deletes a user 00124 - #msiAddUserToGroup - Adds a user to a group 00125 - #msiCreateCollByAdmin - Creates a collection by administrator 00126 - #msiDeleteCollByAdmin - Deletes a collection by administrator 00127 - #msiRenameLocalZone - Renames the local zone by updating various tables 00128 - #msiRenameCollection - Renames a collection; used via a rule with the above #msiRenameLocalZone 00129 - #msiExecStrCondQuery - Creates an iCAT query, given a condition string, and executes it and returns the values 00130 - #msiExecStrCondQueryWithOptions - Like #msiExecStrCondQuery, with extra options 00131 - #msiExecGenQuery - Executes a given general query structure and returns results 00132 - #msiMakeQuery - Creates a psuedo-SQL query, given a select list and a condition list 00133 - #msiGetMoreRows - Continues an unfinished query and #msiExecStrCondQuery and returns results 00134 - #msiCloseGenQuery - Closes an unfinished query. Based on #msiGetMoreRows. 00135 - #msiMakeGenQuery - A combination of #msiMakeQuery and #msiExecGenQuery and returns the results of the execution 00136 - #msiGetContInxFromGenQueryOut - Gets continue index value generated by #msiExecGenQuery 00137 - #msiAddSelectFieldToGenQuery - Sets a select field in a genQueryInp_t 00138 - #msiPrintGenQueryInp - Prints the given GenQueryInp_MS_T to the given target buffer 00139 - #msiAddConditionToGenQuery - Adds a condition to a genQueryInp_t 00140 - #msiPrintGenQueryOutToBuffer - Writes the contents of a GenQueryOut_MS_T into a BUF_LEN_MS_T 00141 - #msiDeleteUnusedAVUs - Deletes unused AVUs from the iCAT 00142 00143 \subsection msirda Rule-oriented Database Access Microservices 00144 - #msiRdaToStdout - Calls new RDA functions to interface to an arbitrary database returning results in stdout 00145 - #msiRdaToDataObj - As above but stores results in an iRODS DataObject 00146 - #msiRdaNoResults - As above, performs a SQL operation but without resulting output 00147 - #msiRdaCommit - Commit changes to the database 00148 - #msiRdaRollback - Rollback (don't commit) changes to the database 00149 00150 \subsection msixmsg XMessaging System Microservices 00151 - #msiXmsgServerConnect - Connects to the XMessage Server as designate by iRODS Environment file/variable 00152 - #msiXmsgCreateStream - Creates a new Message Stream 00153 - #msiCreateXmsgInp - Creates an Xmsg packet, given all information values 00154 - #msiSendXmsg - Sends an Xmsg packet 00155 - #msiRcvXmsg - Receives an Xmsg packet 00156 - #msiXmsgServerDisConnect - Disconnects from the XMessage Server 00157 - #readXMsg - Reads a message packet from an XMsgStream 00158 - #writeXMsg - Writes a given string into an XMsgStream 00159 00160 \subsection msistring String Manipulation Microservices 00161 - #msiStrlen - Returns the length of a given string 00162 - #msiStrchop - Removes the last character of a given string 00163 - #msiSubstr - Returns a substring of the given string 00164 00165 \subsection msiemail Email Microservices 00166 - #msiSendMail - Sends email 00167 - #msiSendStdoutAsEmail - Sends rei's stdout as email 00168 00169 \subsection msikv Key-Value (Attr-Value) Microservices 00170 - #writeKeyValPairs - Writes key-value pairs to stdout or stderr and with given separator 00171 - #msiPrintKeyValPair - Prints key-value pairs to rei's stdout separated by = 00172 - #msiGetValByKey - Extracts the corresponding value, given a key and a keyValPair struct 00173 - #msiString2KeyValPair - Converts a \%-separated key=value pair strings into keyValPair structure 00174 - #msiStrArray2String - Converts an array of strings to a string separated by \%-signs 00175 - #msiAssociateKeyValuePairsToObj - Ingests object metadata into iCAT from a AVU structure 00176 - #msiRemoveKeyValuePairsFromObj - Removes object metadata from iCAT using a AVU structure 00177 - #msiAddKeyVal - Adds a new key and value to a keyValPair_t 00178 00179 \subsection msiotheruser Other User Microservices 00180 - #msiExtractNaraMetadata - Extracts NARA style metadata from a local configuration file 00181 - #msiApplyDCMetadataTemplate - Adds Dublin Core Metadata fields to an object or collection 00182 - #msiRegisterData - Registers a new data object 00183 - #writeBytesBuf - Writes the buffer in an inOutStruct to stdout or stderr 00184 - #msiStrToBytesBuf - Converts a string to a bytesBuf_t 00185 - #msiFreeBuffer - Frees a buffer in an inOutStruct, or stdout or stderr 00186 - #writePosInt - Writes an integer to stdout or stderr 00187 - #msiGetDiffTime - Returns the difference between two system timestamps given in unix format (stored in string) 00188 - #msiGetSystemTime - Returns the local system time of server 00189 - #msiHumanToSystemTime - Converts a human readable date to a system timestamp 00190 - #msiGetIcatTime - Returns the system time for the iCAT server 00191 - #msiGetTaggedValueFromString - Gets the value from a file in tagged-format (psuedo-XML), given a tag-name 00192 - #msiExtractTemplateMDFromBuf - Extracts AVU info using template 00193 - #msiReadMDTemplateIntoTagStruct - Loads template file contents into tag structure 00194 00195 \subsection msisystem System Microservices 00196 Can only be called by the server process 00197 - #msiSetDefaultResc - Sets the default resource 00198 - #msiSetNoDirectRescInp - Sets a list of resources that cannot be used by a normal user directly 00199 - #msiSetRescSortScheme - Sets the scheme for selecting the best resource to use 00200 - #msiSetMultiReplPerResc - Sets the number of copies per resource to unlimited 00201 - #msiSetDataObjPreferredResc - Specifies the preferred copy to use, if the data has multiple copies 00202 - #msiSetDataObjAvoidResc - Specifies the copy to avoid 00203 - #msiSetGraftPathScheme - Sets the scheme for composing the physical path in the vault to GRAFT_PATH 00204 - #msiSetRandomScheme - Sets the the scheme for composing the physical path in the vault to RANDOM 00205 - #msiSetResource - sets the resource from default 00206 - #msiSortDataObj - Sort the replica randomly when choosing which copy to use 00207 - #msiSetNumThreads - specify the parameters for determining the number of threads to use for data transfer 00208 - #msiSysChksumDataObj - Checksums a data object 00209 - #msiSysReplDataObj - Replicates a data object 00210 - #msiSysMetaModify - Modifies system metadata 00211 - #msiStageDataObj - Stages the data object to the specified resource before operation 00212 - #msiNoChkFilePathPerm - Does not check file path permission when registering 00213 - #msiNoTrashCan - Sets the policy to no trash can 00214 - #msiSetPublicUserOpr - Sets a list of operations that can be performed by the user "public" 00215 - #msiCheckHostAccessControl - Sets the access control policy 00216 - #msiServerMonPerf - Monitors the servers' activity and performance 00217 - #msiFlushMonStat - Flushes the servers' monitoring statistics 00218 - #msiDigestMonStat - Calculates and stores a digest performance value for each connected resource 00219 - #msiDeleteDisallowed - Sets the policy for determining certain data cannot be deleted 00220 - #msiSetDataTypeFromExt - Gets the data type based on file name extension 00221 - #msiSetReServerNumProc - Sets the number of processes for the rule engine server 00222 - #msiSetRescQuotaPolicy - Sets the resource quota to on or off 00223 - #msiListEnabledMS - Returns the list of compiled microservices on the local iRODS server 00224 - #msiSetBulkPutPostProcPolicy - Sets whether acPostProcForPut should be run after a bulk put 00225 00226 \section msiadmin Admin Microservices 00227 Can only be called by an administrator 00228 - #msiServerBackup - Copies iRODS server files to the local resource 00229 - #msiSetQuota - Sets disk usage quota for a user or group 00230 00231 \section msimodules Module Microservices 00232 00233 \subsection msiera ERA - Electronic Records Archives Program 00234 - #msiRecursiveCollCopy - Recursively copies a collection and its contents including metadata 00235 - #msiGetDataObjACL - Gets ACL (Access Control List) for a data object in | separated format 00236 - #msiGetCollectionACL- Gets ACL (Access Control List) for a collection in | separated format 00237 - #msiGetDataObjAVUs - Retrieves metadata AVU triplets for a data object and returns them as an XML file 00238 - #msiGetDataObjPSmeta - Retrieves metadata AVU triplets for a data object in | separated format 00239 - #msiGetCollectionPSmeta- Retrieves metadata AVU triplets for a collection in | separated format 00240 - #msiGetDataObjAIP - Gets the Archival Information Package of a data object in XML format 00241 - #msiLoadMetadataFromDataObj - Parses an iRODS object for new metadata AVUs from | separated format 00242 - #msiExportRecursiveCollMeta - Exports metadata AVU triplets for a collection and its contents in | separated format 00243 - #msiCopyAVUMetadata - Copies metadata triplets from an iRODS object to another 00244 - #msiStripAVUs - Strips a data object of its metadata AVU triplets 00245 - #msiGetUserInfo - Gets Information about user 00246 - #msiGetUserACL - Gets User ACL for all objects and collections 00247 - #msiCreateUserAccountsFromDataObj - Creates new user from information in an iRODS data object 00248 - #msiLoadUserModsFromDataObj - Modifies user information from information in an iRODS data object 00249 - #msiDeleteUsersFromDataObj - Deletes user from information in an iRODS data object 00250 - #msiLoadACLFromDataObj - Loads ACL from information in an iRODS data object 00251 - #msiGetAuditTrailInfoByUserID - Retrieves Audit Trail information for a user ID 00252 - #msiGetAuditTrailInfoByObjectID - Retrieves Audit Trail information for an object ID 00253 - #msiGetAuditTrailInfoByActionID - Retrieves Audit Trail information for a given action ID 00254 - #msiGetAuditTrailInfoByKeywords - Retrieves Audit Trail information by keywords in the comment field 00255 - #msiGetAuditTrailInfoByTimeStamp - Retrieves Audit Trail information by timestamp period 00256 - #msiSetDataType - Sets data type for an object 00257 - #msiGuessDataType - Guesses the data type of an object based on its file extension 00258 - #msiMergeDataCopies - Custom microservice for NARA consolidation rule 00259 - #msiFlagDataObjwithAVU - Flags a data object with an AVU 00260 - #msiGetCollectionContentsReport - Returns the number of objects in a collection by data type 00261 - #msiGetCollectionSize - Returns the object count and total disk usage of a collection 00262 - #msiGetObjectPath - Returns the path of an iRODS object 00263 - #msiCollectionSpider - Applies a microservice sequence to all data objects in a collection, recursively 00264 - #msiIsColl - Checks if an iRODS path is a collection. For use in workflows 00265 - #msiIsData - Checks if an iRODS path is a data object (an iRODS file). For use in workflows 00266 - #msiStructFileBundle - Bundles a collection for export 00267 - #msiFlagInfectedObjs - Parses output from clamscan and flags infected objects 00268 00269 \subsection msiurl URL 00270 - #msiFtpGet - Gets a remote file using FTP and writes it to an iRODS object 00271 - #msiTwitterPost - Posts a message to twitter.com 00272 00273 \subsection msixml XML 00274 - #msiLoadMetadataFromXml - Loads AVU metadata from an XML file of AVU triplets 00275 - #msiXmlDocSchemaValidate - Validates an XML file against an XSD schema, both iRODS objects 00276 - #msiXsltApply - Returns the xml object after applying the xslt transformation, given an xml object and an xslt object 00277 00278 \subsection msimsodrivers Microservice Object (MSO) Drivers 00279 - #msiobjget_dbo - Gets a DBO object 00280 - #msiobjput_dbo - Puts a DBO object 00281 - #msiobjget_http - Gets an HTTP/HTTPS/FTP object 00282 - #msiobjput_http - Puts an HTTP/HTTPS/FTP object 00283 - #msiobjget_irods - Gets an iRODS object 00284 - #msiobjput_irods - Puts an iRODS object 00285 - #msiobjget_slink - Gets an SLINK object 00286 - #msiobjput_slink - Puts an SLINK object 00287 - #msiobjget_srb - Gets an SRB object 00288 - #msiobjput_srb - Puts an SRB object 00289 - #msiobjget_test - Gets a test object 00290 - #msiobjput_test - Puts a test object 00291 - #msiobjget_z3950 - Gets a Z39.50 object 00292 - #msiobjput_z3950 - Puts a Z39.50 object 00293 00294 \subsection msiimage Image 00295 - #msiImageConvert - Reads a source image file and write it out as a new image file in a chosen format 00296 - #msiImageGetProperties - Gets the properties of an image file 00297 - #msiImageScale - Reads a source image file, scale it up or down in size, and write it out as a new image file in a chosen format 00298 00299 \subsection msihdf HDF 00300 - #msiH5File_open - Opens an HDF file 00301 - #msiH5File_close - Closes an HDF file 00302 - #msiH5Dataset_read - Reads data from an HDF file 00303 - #msiH5Dataset_read_attribute - Reads data attribute from an HDF file 00304 - #msiH5Group_read_attribute - Reads attributes of a group in an HDF file 00305 00306 \subsection msiproperties Properties 00307 - #msiPropertiesNew - Creates a new empty property list 00308 - #msiPropertiesClear - Clears a property list 00309 - #msiPropertiesClone - Clones a property list, returning a new property list 00310 - #msiPropertiesAdd - Adds a property and value to a property list. If the property is already in the list, its value is changed. Otherwise the property is added. 00311 - #msiPropertiesRemove - Removes a property from the list 00312 - #msiPropertiesGet - Gets the value of a property in a property list. The property list is left unmodified. 00313 - #msiPropertiesSet - Sets the value of a property in a property list. If the property is already in the list, its value is changed. Otherwise the property is added. 00314 - #msiPropertiesExists - Returns true (integer 1) if the keyword has a property value in the property list, and false (integer 0) otherwise. The property list is unmodified. 00315 - #msiPropertiesToString - Converts a property list into a string buffer. The property list is left unmodified. 00316 - #msiPropertiesFromString - Parses a string into a new property list. The existing property list, if any, is deleted. 00317 00318 \subsection msiwebservices Web Services 00319 - #msiGetQuote - Returns stock quotation (delayed by web service) using web service provided by http://www.webserviceX.NET 00320 - #msiIp2location - Returns host name and other details given an ipaddress using web service provided by http://ws.fraudlabs.com/ 00321 - #msiConvertCurrency - Returns conversion rate for currencies from one country to another using web service provided by http://www.webserviceX.NET/ 00322 - #msiObjByName - Returns position and type of an astronomical object given a name from the NASA/IPAC Extragalactic Database (NED) using web service at http://voservices.net/NED/ws_v2_0/NED.asmx 00323 - #msiSdssImgCutout_GetJpeg - Returns an image buffer given a position and cutout from the SDSS Image Cut Out service using web service provided by http://skyserver.sdss.org 00324 00325 \subsection msiguinot Guinot 00326 - #msiGetFormattedSystemTime - Returns the local system time 00327 00328 \subsection msiz3950 Z3950 00329 - #msiz3950Submit - Retrieves a record from a Z39.50 server 00330 00331 **/ 00332 00333 00334 00335 00336 00337 /** 00338 * \fn msiGetIcatTime (msParam_t *timeOutParam, msParam_t *typeInParam, ruleExecInfo_t *rei) 00339 * 00340 * \brief This function returns the system time for the iCAT server 00341 * 00342 * \module core 00343 * 00344 * \since pre-2.1 00345 * 00346 * \author DICE 00347 * \date 2008 00348 * 00349 * \usage See clients/icommands/test/rules3.0/ 00350 * 00351 * \param[out] timeOutParam - a msParam of type STR_MS_T 00352 * \param[in] typeInParam - a msParam of type STR_MS_T 00353 * \li "icat" or "unix" will return seconds since epoch 00354 * \li otherwise, human friendly 00355 * \param[in,out] rei - The RuleExecInfo structure that is automatically 00356 * handled by the rule engine. The user does not include rei as a 00357 * parameter in the rule invocation. 00358 * 00359 * \DolVarDependence none 00360 * \DolVarModified none 00361 * \iCatAttrDependence none 00362 * \iCatAttrModified none 00363 * \sideeffect none 00364 * 00365 * \return integer 00366 * \retval 0 on success 00367 * \pre none 00368 * \post none 00369 * \sa none 00370 **/ 00371 int 00372 msiGetIcatTime(msParam_t* timeOutParam, msParam_t* typeInParam, ruleExecInfo_t *rei) 00373 { 00374 char *type; 00375 char tStr0[TIME_LEN],tStr[TIME_LEN]; 00376 int i; 00377 00378 type = (char*)typeInParam->inOutStruct; 00379 00380 if (!strcmp(type,"icat") || !strcmp(type,"unix")) { 00381 getNowStr(tStr); 00382 } 00383 else { /* !strcmp(type,"human") */ 00384 getNowStr(tStr0); 00385 getLocalTimeFromRodsTime(tStr0,tStr); 00386 } 00387 i = fillStrInMsParam (timeOutParam,tStr); 00388 return(i); 00389 } 00390 00391 /** 00392 * \fn msiVacuum (ruleExecInfo_t *rei) 00393 * 00394 * \brief Postgres vacuum, done periodically to optimize indices and performance 00395 * 00396 * \module core 00397 * 00398 * \since pre-2.1 00399 * 00400 * \author Wayne Schroeder 00401 * \date December 2006 00402 * 00403 * \note The effect of this is that iCAT database gets vacuumed. 00404 * This microservice works with PostgreSQL only. 00405 * 00406 * \note This is run via an 'iadmin' command (iadmin pv) via a rule 00407 * in the core.irb. It is not designed for general use in other 00408 * situations (i.e. don't call this from other rules). 00409 * 00410 * \usage See clients/icommands/test/rules3.0/ 00411 * 00412 * \param[in,out] rei - The RuleExecInfo structure that is automatically 00413 * handled by the rule engine. The user does not include rei as a 00414 * parameter in the rule invocation. 00415 * 00416 * \DolVarDependence none 00417 * \DolVarModified none 00418 * \iCatAttrDependence none 00419 * \iCatAttrModified none 00420 * \sideeffect none 00421 * 00422 * \return integer 00423 * \retval 0 on success 00424 * \pre none 00425 * \post none 00426 * \sa none 00427 **/ 00428 int 00429 msiVacuum(ruleExecInfo_t *rei) 00430 { 00431 int i; 00432 rodsLog(LOG_NOTICE, "msiVacuum called\n"); 00433 00434 i = doForkExec("/usr/bin/perl", "./vacuumdb.pl"); 00435 00436 if (i) { 00437 rodsLog(LOG_ERROR, "msiVacuum doForkExec failure\n"); 00438 } 00439 00440 rodsLog(LOG_NOTICE, "msiVacuum done\n"); 00441 00442 return(0); 00443 } 00444 00445 00446 /** 00447 * \fn msiQuota (ruleExecInfo_t *rei) 00448 * 00449 * \brief Calculates storage usage and sets quota values (over/under/how-much). 00450 * 00451 * \module core 00452 * 00453 * \since pre-2.3 00454 * 00455 * \author Wayne Schroeder 00456 * \date January 2010 00457 * 00458 * \note Causes the iCAT quota tables to be updated. 00459 * 00460 * \note This is run via an admin rule 00461 * 00462 * \usage See clients/icommands/test/rules3.0/ and https://www.irods.org/index.php/Quotas 00463 * 00464 * \param[in,out] rei - The RuleExecInfo structure that is automatically 00465 * handled by the rule engine. The user does not include rei as a 00466 * parameter in the rule invocation. 00467 * 00468 * \DolVarDependence rei->rsComm->clientUser.authFlag (must be admin) 00469 * \DolVarModified none 00470 * \iCatAttrDependence Utilizes ICAT data-object information 00471 * \iCatAttrModified Updates the quota tables 00472 * \sideeffect none 00473 * \return integer 00474 * \retval 0 on success 00475 * \pre none 00476 * \post none 00477 * \sa none 00478 **/ 00479 int 00480 msiQuota(ruleExecInfo_t *rei) 00481 { 00482 int status; 00483 00484 #ifdef RODS_CAT 00485 rodsLog(LOG_NOTICE, "msiQuota/chlCalcUsageAndQuota called\n"); 00486 status = chlCalcUsageAndQuota(rei->rsComm); 00487 #else 00488 status = SYS_NO_RCAT_SERVER_ERR; 00489 #endif 00490 return(status); 00491 } 00492 00493 /** 00494 *\fn msiSetResource (msParam_t *xrescName, ruleExecInfo_t *rei) 00495 * 00496 * \brief This microservice sets the resource as part of a workflow execution. 00497 * 00498 * \module core 00499 * 00500 * \since pre-2.1 00501 * 00502 * \author DICE 00503 * \date 2008 00504 * 00505 * \note This microservice sets the resource as part of a workflow execution. 00506 * 00507 * \usage See clients/icommands/test/rules3.0/ 00508 * 00509 * \param[in] xrescName - is a msParam of type STR_MS_T 00510 * \param[in,out] rei - The RuleExecInfo structure that is automatically 00511 * handled by the rule engine. The user does not include rei as a 00512 * parameter in the rule invocation. 00513 * 00514 * \DolVarDependence none 00515 * \DolVarModified none 00516 * \iCatAttrDependence none 00517 * \iCatAttrModified none 00518 * \sideeffect none 00519 * 00520 * \return integer 00521 * \retval 0 on success 00522 * \pre none 00523 * \post none 00524 * \sa none 00525 **/ 00526 int msiSetResource(msParam_t* xrescName, ruleExecInfo_t *rei) 00527 { 00528 char *rescName; 00529 00530 rescName = (char *) xrescName->inOutStruct; 00531 if (reTestFlag > 0 ) { 00532 if (reTestFlag == LOG_TEST_1) 00533 rodsLog (LOG_NOTICE," Calling msiSetResource\n"); 00534 } 00535 00536 strcpy(rei->doi->rescName,rescName); 00537 return(0); 00538 } 00539 00540 00541 /** 00542 * \fn msiCheckOwner (ruleExecInfo_t *rei) 00543 * 00544 * \brief This microservice checks whether the user is the owner 00545 * 00546 * \module core 00547 * 00548 * \since pre-2.1 00549 * 00550 * \author DICE 00551 * \date 2008 00552 * 00553 * \usage See clients/icommands/test/rules3.0/ 00554 * 00555 * \param[in,out] rei - The RuleExecInfo structure that is automatically 00556 * handled by the rule engine. The user does not include rei as a 00557 * parameter in the rule invocation. 00558 * 00559 * \DolVarDependence none 00560 * \DolVarModified none 00561 * \iCatAttrDependence none 00562 * \iCatAttrModified none 00563 * \sideeffect none 00564 * 00565 * \return integer 00566 * \retval 0 on success 00567 * \pre none 00568 * \post none 00569 * \sa none 00570 **/ 00571 int msiCheckOwner(ruleExecInfo_t *rei) 00572 { 00573 if (reTestFlag > 0 ) { 00574 if (reTestFlag == LOG_TEST_1) 00575 rodsLog (LOG_NOTICE," Calling msiCheckOwner\n"); 00576 } 00577 00578 if (!strcmp(rei->doi->dataOwnerName,rei->uoic->userName) && 00579 !strcmp(rei->doi->dataOwnerZone,rei->uoic->rodsZone)) 00580 return(0); 00581 else 00582 return(ACTION_FAILED_ERR); 00583 00584 } 00585 00586 /** 00587 * \fn msiCheckPermission (msParam_t *xperm, ruleExecInfo_t *rei) 00588 * 00589 * \brief This microservice checks the authorization permission (whether or not permission is granted) 00590 * 00591 * \module core 00592 * 00593 * \since pre-2.1 00594 * 00595 * \author DICE 00596 * \date 2008 00597 * 00598 * \usage See clients/icommands/test/rules3.0/ 00599 * 00600 * \param[in] xperm - a msParam of type STR_MS_T 00601 * \param[in,out] rei - The RuleExecInfo structure that is automatically 00602 * handled by the rule engine. The user does not include rei as a 00603 * parameter in the rule invocation. 00604 * 00605 * \DolVarDependence none 00606 * \DolVarModified none 00607 * \iCatAttrDependence none 00608 * \iCatAttrModified none 00609 * \sideeffect none 00610 * 00611 * \return integer 00612 * \retval 0 on success 00613 * \pre none 00614 * \post none 00615 * \sa none 00616 **/ 00617 int msiCheckPermission(msParam_t* xperm, ruleExecInfo_t *rei) 00618 { 00619 char *perm; 00620 00621 perm = (char *) xperm->inOutStruct; 00622 if (reTestFlag > 0 ) { 00623 if (reTestFlag == LOG_TEST_1) 00624 rodsLog (LOG_NOTICE," Calling msiCheckPermission\n"); 00625 } 00626 if (strstr(rei->doi->dataAccess,perm) != NULL) 00627 return(0); 00628 else 00629 return(ACTION_FAILED_ERR); 00630 00631 } 00632 00633 00634 /** 00635 * \fn msiCheckAccess(msParam_t *inObjName, msParam_t * inOperation, msParam_t * outResult, ruleExecInfo_t *rei) 00636 * 00637 * \brief This microservice checks the access permission to perform a given operation 00638 * 00639 * \module core 00640 * 00641 * \since 3.0 00642 * 00643 * \author Arcot Rajasekar 00644 * \date July 2011 00645 * 00646 * \usage See clients/icommands/test/rules3.0/ 00647 * 00648 * \param[in] inObjName - name of Object. A param of type STR_MS_T 00649 * \param[in] inOperation - type of Operation that will be performed. A param of type STR_MS_T. 00650 * \param[out] outResult - result of the operation. 0 for failure and 1 for success. a param of type INT_MS_T. 00651 * \param[in,out] rei - The RuleExecInfo structure that is automatically 00652 * handled by the rule engine. The user does not include rei as a 00653 * parameter in the rule invocation. 00654 * 00655 * \DolVarDependence none 00656 * \DolVarModified none 00657 * \iCatAttrDependence none 00658 * \iCatAttrModified none 00659 * \sideeffect none 00660 * 00661 * \return integer 00662 * \retval 0 on success 00663 * \pre none 00664 * \post none 00665 * \sa none 00666 **/ 00667 int msiCheckAccess(msParam_t *inObjName, msParam_t * inOperation, 00668 msParam_t * outResult, ruleExecInfo_t *rei) 00669 { 00670 char *objName, *oper; 00671 char objType[MAX_NAME_LEN]; 00672 int i; 00673 char *user; 00674 char *zone; 00675 00676 RE_TEST_MACRO (" Calling msiCheckAccess"); 00677 00678 if (inObjName == NULL || inObjName->inOutStruct == NULL || 00679 inObjName->type == NULL || strcmp(inObjName->type, STR_MS_T) != 0 ) 00680 return (USER_PARAM_TYPE_ERR); 00681 00682 if (inOperation == NULL || inOperation->inOutStruct == NULL || 00683 inOperation->type == NULL || strcmp(inOperation->type, STR_MS_T) != 0 ) 00684 return (USER_PARAM_TYPE_ERR); 00685 00686 if (rei == NULL || rei->rsComm == NULL) 00687 return (SYS_INTERNAL_NULL_INPUT_ERR); 00688 00689 if (strlen(rei->rsComm->clientUser.userName) == 0 || 00690 strlen(rei->rsComm->clientUser.rodsZone) == 0) 00691 return (SYS_INTERNAL_NULL_INPUT_ERR); 00692 00693 oper = (char *) inOperation->inOutStruct; 00694 objName = (char *) inObjName->inOutStruct; 00695 user = rei->rsComm->clientUser.userName; 00696 zone = rei->rsComm->clientUser.rodsZone; 00697 00698 i = getObjType(rei->rsComm, objName, objType); 00699 if (i < 0) 00700 return(i); 00701 00702 i = checkPermissionByObjType(rei->rsComm, objName, objType, user, zone, oper); 00703 if (i < 0) 00704 return(i); 00705 fillIntInMsParam (outResult, i); 00706 00707 return(0); 00708 00709 } 00710 00711 00712 /** 00713 * \fn msiCommit (ruleExecInfo_t *rei) 00714 * 00715 * \brief This microservice commits pending database transactions, 00716 * registering the new state information into the iCAT. 00717 * 00718 * \module core 00719 * 00720 * \since pre-2.1 00721 * 00722 * \author Wayne Schroeder 00723 * \date June 2009 00724 * 00725 * \note This is used to commit changes (in any) into the iCAT 00726 * database as part of a rule and microservice chain. See core.irb 00727 * for examples. In other cases, iCAT updates and inserts are 00728 * automatically committed into the iCAT Database as part of the 00729 * normal operations (in the 'C' code). 00730 * 00731 * \usage See clients/icommands/test/rules3.0/ 00732 * 00733 * \param[in,out] rei - The RuleExecInfo structure that is automatically 00734 * handled by the rule engine. The user does not include rei as a 00735 * parameter in the rule invocation. 00736 * 00737 * \DolVarDependence none 00738 * \DolVarModified none 00739 * \iCatAttrDependence commits pending updates (if any) 00740 * \iCatAttrModified pending updates (if any) are committed into the iCAT db 00741 * \sideeffect none 00742 * 00743 * \return integer 00744 * \retval (status) 00745 * \pre none 00746 * \post none 00747 * \sa none 00748 **/ 00749 int 00750 msiCommit(ruleExecInfo_t *rei) { 00751 int status; 00752 00753 /**** This is Just a Test Stub ****/ 00754 if (reTestFlag > 0 ) { 00755 if (reTestFlag == LOG_TEST_1) { 00756 rodsLog (LOG_NOTICE," Calling msiCommit\n"); 00757 } 00758 if (reLoopBackFlag > 0) 00759 return(0); 00760 } 00761 /**** This is Just a Test Stub ****/ 00762 #ifdef RODS_CAT 00763 status = chlCommit(rei->rsComm); 00764 #else 00765 status = SYS_NO_RCAT_SERVER_ERR; 00766 #endif 00767 return(status); 00768 } 00769 00770 /** 00771 * \fn msiRollback (ruleExecInfo_t *rei) 00772 * 00773 * \brief This function deletes user and collection information from the iCAT by rolling back the database transaction 00774 * 00775 * \module core 00776 * 00777 * \since pre-2.1 00778 * 00779 * \author Wayne Schroeder 00780 * \date June 2009 00781 * 00782 * \note This is used to not-commit changes into the iCAT database as 00783 * part of a rule and microservice chain. See core.irb for examples. 00784 * In other cases, iCAT updates and inserts are automatically 00785 * rolled-back as part of the normal operations (in the 'C' code). 00786 * 00787 * \usage See clients/icommands/test/rules3.0/ 00788 * 00789 * \param[in,out] rei - The RuleExecInfo structure that is automatically 00790 * handled by the rule engine. The user does not include rei as a 00791 * parameter in the rule invocation. 00792 * 00793 * \DolVarDependence none 00794 * \DolVarModified none 00795 * \iCatAttrDependence pending updates (if any) are canceled 00796 * \iCatAttrModified pending updates (if any) are canceled 00797 * \sideeffect none 00798 * 00799 * \return integer 00800 * \retval 0 on success 00801 * \pre none 00802 * \post none 00803 * \sa none 00804 **/ 00805 int 00806 msiRollback(ruleExecInfo_t *rei) 00807 { 00808 int status; 00809 /**** This is Just a Test Stub ****/ 00810 if (reTestFlag > 0 ) { 00811 if (reTestFlag == LOG_TEST_1) { 00812 rodsLog (LOG_NOTICE," Calling msiRollback\n"); 00813 } 00814 if (reLoopBackFlag > 0) 00815 return(0); 00816 } 00817 /**** This is Just a Test Stub ****/ 00818 00819 00820 #ifdef RODS_CAT 00821 status = chlRollback(rei->rsComm); 00822 #else 00823 status = SYS_NO_RCAT_SERVER_ERR; 00824 #endif 00825 return(status); 00826 } 00827 00828 /** 00829 * \fn msiSetACL (msParam_t *recursiveFlag, msParam_t *accessLevel, msParam_t *userName, msParam_t *pathName, ruleExecInfo_t *rei) 00830 * 00831 * \brief This microservice changes the ACL for a given pathname, 00832 * either a collection or a data object. 00833 * 00834 * \module core 00835 * 00836 * \since 2.3 00837 * 00838 * \author Jean-Yves Nief 00839 * \date 2010-02-11 00840 * 00841 * \note This microservice modifies the access rights on a given iRODS object or 00842 * collection. For the collections, the modification can be recursive and the 00843 * inheritence bit can be changed as well. 00844 * For admin mode, add MOD_ADMIN_MODE_PREFIX to the access level string, 00845 * e.g: msiSetACL("default", "admin:read", "rods", *path) 00846 * 00847 * \usage See clients/icommands/test/rules3.0/ 00848 * 00849 * \param[in] recursiveFlag - a STR_MS_T, either "default" or "recursive". "recursive" 00850 * is only relevant if set with accessLevel set to "inherit". 00851 * \param[in] accessLevel - a STR_MS_T containing one of the following: 00852 * \li read 00853 * \li write 00854 * \li own 00855 * \li inherit 00856 * \li null 00857 * \param[in] userName - a STR_MS_T, the user name or group name who will have ACL changed. 00858 * \param[in] pathName - a STR_MS_T, the collection or data object that will have its ACL changed. 00859 * \param[in,out] rei - The RuleExecInfo structure that is automatically 00860 * handled by the rule engine. The user does not include rei as a 00861 * parameter in the rule invocation. 00862 * 00863 * \DolVarDependence $userName and/or $objPath and/or $collName 00864 * \DolVarModified none 00865 * \iCatAttrDependence none 00866 * \iCatAttrModified none 00867 * \sideeffect none 00868 * 00869 * \return integer 00870 * \retval 0 on success 00871 * \pre N/A 00872 * \post N/A 00873 * \sa N/A 00874 **/ 00875 int msiSetACL (msParam_t *recursiveFlag, msParam_t *accessLevel, msParam_t *userName, 00876 msParam_t *pathName, ruleExecInfo_t *rei) { 00877 char *acl, *path, *recursiveFlg, *user, uname[NAME_LEN], *zone; 00878 int recFlg, rc; 00879 modAccessControlInp_t modAccessControlInp; 00880 rsComm_t *rsComm = 0; // JMC cppcheck - uninit var 00881 00882 RE_TEST_MACRO (" Calling msiSetACL") 00883 /* the above line is needed for loop back testing using irule -i option */ 00884 00885 if ( recursiveFlag == NULL || accessLevel == NULL || userName == NULL || 00886 pathName == NULL ) { 00887 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status, 00888 "msiSetACL: one of the input parameter is NULL"); 00889 return (SYS_INTERNAL_NULL_INPUT_ERR); 00890 } 00891 00892 recFlg = 0; /* non recursive mode */ 00893 if ( strcmp (recursiveFlag->type, STR_MS_T) == 0 ) { 00894 recursiveFlg = (char *) recursiveFlag->inOutStruct; 00895 if ( strcmp(recursiveFlg,"recursive") == 0 ) { 00896 /* recursive mode */ 00897 recFlg = 1; 00898 } 00899 } 00900 else { 00901 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status, 00902 "msiSetACL: Unsupported input recursiveFlag type %i", 00903 recursiveFlag->type); 00904 return (USER_PARAM_TYPE_ERR); 00905 } 00906 00907 if ( strcmp (accessLevel->type, STR_MS_T) == 0 ) { 00908 acl = (char *) accessLevel->inOutStruct; 00909 } 00910 else { 00911 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status, 00912 "msiSetACL: Unsupported input accessLevel type %s", 00913 accessLevel->type); 00914 return (USER_PARAM_TYPE_ERR); 00915 } 00916 00917 if ( strcmp (userName->type, STR_MS_T) == 0 ) { 00918 user = (char *) userName->inOutStruct; 00919 } 00920 else { 00921 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status, 00922 "msiSetACL: Unsupported input userName type %s", 00923 userName->type); 00924 return (USER_PARAM_TYPE_ERR); 00925 } 00926 00927 if ( strcmp (pathName->type, STR_MS_T) == 0 ) { 00928 path = (char *) pathName->inOutStruct; 00929 } 00930 else { 00931 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status, 00932 "msiSetACL: Unsupported input pathName type %s", 00933 pathName->type); 00934 return (USER_PARAM_TYPE_ERR); 00935 } 00936 00937 rsComm = rei->rsComm; 00938 modAccessControlInp.recursiveFlag = recFlg; 00939 modAccessControlInp.accessLevel = acl; 00940 if ( strchr(user, '#') == NULL ) { 00941 modAccessControlInp.userName = user; 00942 modAccessControlInp.zone = rei->uoic->rodsZone; 00943 } 00944 else { 00945 zone = strchr(user, '#') + 1; 00946 memset(uname, '\0', NAME_LEN); 00947 strncpy(uname, user, strlen(user) - strlen(zone) - 1); 00948 modAccessControlInp.userName = uname; 00949 modAccessControlInp.zone = zone; 00950 } 00951 modAccessControlInp.path = path; 00952 rc = rsModAccessControl(rsComm, &modAccessControlInp); 00953 if ( rc < 0 ) { 00954 rodsLog (LOG_NOTICE, "msiSetACL: ACL modifications has failed for user %s on object %s, error = %i\n", user, path, rc); 00955 } 00956 00957 return (rc); 00958 } 00959 00960 /** 00961 * \fn msiDeleteUnusedAVUs (ruleExecInfo_t *rei) 00962 * 00963 * \brief This microservice deletes unused AVUs from the iCAT. See 'iadmin rum'. 00964 * 00965 * \module core 00966 * 00967 * \since post-2.3 00968 * 00969 * \author Wayne Schroeder 00970 * \date April 13, 2010 00971 * 00972 * \note See 'iadmin help rum'. Do not call this directly. 00973 * 00974 * \usage See clients/icommands/test/rules3.0/ 00975 * 00976 * \param[in,out] rei - The RuleExecInfo structure that is automatically 00977 * handled by the rule engine. The user does not include rei as a 00978 * parameter in the rule invocation. 00979 * 00980 * \DolVarDependence rei->rsComm->clientUser.authFlag (must be admin) 00981 * \DolVarModified none 00982 * \iCatAttrDependence check AVU table 00983 * \iCatAttrModified update AVU table 00984 * \sideeffect none 00985 * 00986 * \return integer 00987 * \retval (status) 00988 * \pre none 00989 * \post none 00990 * \sa none 00991 **/ 00992 int 00993 msiDeleteUnusedAVUs(ruleExecInfo_t *rei) 00994 { 00995 int status; 00996 00997 /**** This is Just a Test Stub ****/ 00998 if (reTestFlag > 0 ) { 00999 if (reTestFlag == LOG_TEST_1) { 01000 rodsLog (LOG_NOTICE," Calling msiDeleteUnusedAVUs\n"); 01001 } 01002 if (reLoopBackFlag > 0) 01003 return(0); 01004 } 01005 /**** This is Just a Test Stub ****/ 01006 01007 #ifdef RODS_CAT 01008 rodsLog(LOG_NOTICE, "msiDeleteUnusedAVUs/chlDelUnusedAVUs called\n"); 01009 status = chlDelUnusedAVUs(rei->rsComm); 01010 #else 01011 status = SYS_NO_RCAT_SERVER_ERR; 01012 #endif 01013 return(status); 01014 }