/* chkFilePathPerm - check the FilePath permission. * If rodsServerHost */ int chkFilePathPerm( rsComm_t *rsComm, fileOpenInp_t *fileOpenInp, rodsServerHost_t *rodsServerHost, int chkType ) { // JMC - backport 4774 int status; if ( chkType == NO_CHK_PATH_PERM ) { return 0; } else if ( chkType == DISALLOW_PATH_REG ) { return PATH_REG_NOT_ALLOWED; } // =-=-=-=-=-=-=- status = isValidFilePath( fileOpenInp->fileName ); // JMC - backport 4766 if ( status < 0 ) { return status; // JMC - backport 4766 } if ( rodsServerHost == NULL ) { rodsLog( LOG_NOTICE, "chkFilePathPerm: NULL rodsServerHost" ); return SYS_INTERNAL_NULL_INPUT_ERR; } // =-=-=-=-=-=-=- // JMC - backport 4774 if ( chkType == CHK_NON_VAULT_PATH_PERM ) { status = matchCliVaultPath( rsComm, fileOpenInp->fileName, rodsServerHost ); if ( status == 1 ) { /* a match in vault */ return status; } else if ( status == -1 ) { /* in vault, but not in user's vault */ return CANT_REG_IN_VAULT_FILE; } } else if ( chkType == DO_CHK_PATH_PERM ) { std::string out_path; irods::error ret = resc_mgr.validate_vault_path( fileOpenInp->fileName, rodsServerHost, out_path ); if ( ret.ok() ) { /* a match */ return CANT_REG_IN_VAULT_FILE; } } else { return SYS_INVALID_INPUT_PARAM; // =-=-=-=-=-=-=- } status = rsChkNVPathPermByHost( rsComm, fileOpenInp, rodsServerHost ); return status; }
/* chkFilePathPerm - check the FilePath permission. * If rodsServerHost */ int chkFilePathPerm (rsComm_t *rsComm, fileOpenInp_t *fileOpenInp, rodsServerHost_t *rodsServerHost, int chkType) { int status; char *outVaultPath = NULL; if (chkType == NO_CHK_PATH_PERM) { return 0; } else if (chkType == DISALLOW_PATH_REG) { return PATH_REG_NOT_ALLOWED; } status = isValidFilePath (fileOpenInp->fileName); if (status < 0) return status; if (rodsServerHost == NULL) { rodsLog (LOG_NOTICE, "chkFilePathPerm: NULL rodsServerHost"); return (SYS_INTERNAL_NULL_INPUT_ERR); } if (chkType == CHK_NON_VAULT_PATH_PERM) { status = matchCliVaultPath (rsComm, fileOpenInp->fileName, rodsServerHost); if (status == 1) { /* a match in vault */ return (status); } else if (status == -1) { /* in vault, but not in user's vault */ return CANT_REG_IN_VAULT_FILE; } } else if (chkType == DO_CHK_PATH_PERM) { if (matchVaultPath (rsComm, fileOpenInp->fileName, rodsServerHost, &outVaultPath) > 0) { /* a match */ return CANT_REG_IN_VAULT_FILE; } } else { return SYS_INVALID_INPUT_PARAM; } status = rsChkNVPathPermByHost (rsComm, fileOpenInp, rodsServerHost); return (status); }
int rsChkNVPathPerm( rsComm_t *rsComm, fileOpenInp_t *chkNVPathPermInp ) { rodsServerHost_t *rodsServerHost; int remoteFlag; int status; //remoteFlag = resolveHost (&chkNVPathPermInp->addr, &rodsServerHost); irods::error ret = irods::get_host_for_hier_string( chkNVPathPermInp->resc_hier_, remoteFlag, rodsServerHost ); if ( !ret.ok() ) { irods::log( PASSMSG( "rsChkNVPathPerm - failed in call to irods::get_host_for_hier_string", ret ) ); return -1; } if ( remoteFlag < 0 ) { return remoteFlag; } else { status = rsChkNVPathPermByHost( rsComm, chkNVPathPermInp, rodsServerHost ); return status; } }