Exemple #1
0
int
rsUserAdmin( rsComm_t *rsComm, userAdminInp_t *userAdminInp ) {
    rodsServerHost_t *rodsServerHost;
    int status;

    rodsLog( LOG_DEBUG, "userAdmin" );

    status = getAndConnRcatHost( rsComm, MASTER_RCAT, (const char*)NULL, &rodsServerHost );
    if ( status < 0 ) {
        return status;
    }

    if ( rodsServerHost->localFlag == LOCAL_HOST ) {
#ifdef RODS_CAT
        status = _rsUserAdmin( rsComm, userAdminInp );
#else
        status = SYS_NO_RCAT_SERVER_ERR;
#endif
    }
    else {
        status = rcUserAdmin( rodsServerHost->conn,
                              userAdminInp );
    }

    if ( status < 0 ) {
        rodsLog( LOG_NOTICE,
                 "rsUserAdmin: rcUserAdmin failed" );
    }
    return status;
}
Exemple #2
0
int
rsDataObjLock( rsComm_t *rsComm, dataObjInp_t *dataObjInp ) {
    int status;
    int remoteFlag;
    specCollCache_t *specCollCache = NULL;
    rodsServerHost_t *rodsServerHost = NULL;

    resolveLinkedPath( rsComm, dataObjInp->objPath, &specCollCache,
                       &dataObjInp->condInput );

    remoteFlag = getAndConnRcatHost( rsComm, MASTER_RCAT, dataObjInp->objPath,
                                     &rodsServerHost );
    if ( remoteFlag < 0 ) {
        return remoteFlag;
    }
    else if ( remoteFlag == REMOTE_HOST ) {
        if ( rodsServerHost != NULL ) { // JMC - cppcheck null ref
            status = rcDataObjLock( rodsServerHost->conn, dataObjInp );
            return status;
        }
        else {
            status = SYS_NO_RCAT_SERVER_ERR;
        }
    }
    else {
#ifdef RODS_CAT
        status = _rsDataObjLock( dataObjInp );
#else
        status = SYS_NO_RCAT_SERVER_ERR;
#endif
    }
    return status;
}
Exemple #3
0
int
rsGenQuery (rsComm_t *rsComm, genQueryInp_t *genQueryInp, 
genQueryOut_t **genQueryOut)
{
    rodsServerHost_t *rodsServerHost;
    int status;
    char *zoneHint;

    zoneHint = getZoneHintForGenQuery (genQueryInp);
 
    status = getAndConnRcatHost(rsComm, SLAVE_RCAT, zoneHint,
				&rodsServerHost);
    if (status < 0) {
       return(status);
    }

    if (rodsServerHost->localFlag == LOCAL_HOST) {
#ifdef RODS_CAT
       status = _rsGenQuery (rsComm, genQueryInp, genQueryOut);
#else
       rodsLog(LOG_NOTICE, 
	       "rsGenQuery error. RCAT is not configured on this host");
       return (SYS_NO_RCAT_SERVER_ERR);
#endif 
    } else {
        status = rcGenQuery(rodsServerHost->conn,
			   genQueryInp, genQueryOut);
    }
    if (status < 0  && status != CAT_NO_ROWS_FOUND) {
        rodsLog (LOG_NOTICE,
		 "rsGenQuery: rcGenQuery failed, status = %d", status);
    }
    return (status);
}
int
rsRuleExecMod( rsComm_t *rsComm, ruleExecModInp_t *ruleExecModInp ) {
    rodsServerHost_t *rodsServerHost;
    int status;

    status = getAndConnRcatHost( rsComm, MASTER_RCAT, NULL, &rodsServerHost );
    if ( status < 0 ) {
        return( status );
    }

    if ( rodsServerHost->localFlag == LOCAL_HOST ) {
#ifdef RODS_CAT
        status = _rsRuleExecMod( rsComm, ruleExecModInp );
#else
        status = SYS_NO_RCAT_SERVER_ERR;
#endif
    }
    else {
        status = rcRuleExecMod( rodsServerHost->conn,
                                ruleExecModInp );
    }

    if ( status < 0 ) {
        rodsLog( LOG_NOTICE,
                 "rsRuleExecMod: rcRuleExecMod failed" );
    }
    return ( status );
}
Exemple #5
0
int
rsUnregDataObj (rsComm_t *rsComm, unregDataObj_t *unregDataObjInp)
{
    int status;
    rodsServerHost_t *rodsServerHost = NULL;
    dataObjInfo_t *dataObjInfo;
    keyValPair_t *condInput;

    condInput = unregDataObjInp->condInput;
    dataObjInfo = unregDataObjInp->dataObjInfo;

    status = getAndConnRcatHost (rsComm, MASTER_RCAT, dataObjInfo->objPath,
                                 &rodsServerHost);
    if (status < 0) {
        return(status);
    }
    if (rodsServerHost->localFlag == LOCAL_HOST) {
#ifdef RODS_CAT
        status = _rsUnregDataObj (rsComm, unregDataObjInp);
#else
        status = SYS_NO_RCAT_SERVER_ERR;
#endif
    } else {
        status = rcUnregDataObj (rodsServerHost->conn, unregDataObjInp);
    }

    return (status);
}
Exemple #6
0
int
rsRegReplica (rsComm_t *rsComm, regReplica_t *regReplicaInp)
{
    int status;
    rodsServerHost_t *rodsServerHost = NULL;
    dataObjInfo_t *srcDataObjInfo;
    dataObjInfo_t *destDataObjInfo;

    srcDataObjInfo = regReplicaInp->srcDataObjInfo;
    destDataObjInfo = regReplicaInp->destDataObjInfo;

    status = getAndConnRcatHost (rsComm, MASTER_RCAT, srcDataObjInfo->objPath,
      &rodsServerHost);
    if (status < 0) {
       return(status);
    }
    if (rodsServerHost->localFlag == LOCAL_HOST) {
#ifdef RODS_CAT
        status = _rsRegReplica (rsComm, regReplicaInp);
#else
        status = SYS_NO_RCAT_SERVER_ERR;
#endif
    } else {
        status = rcRegReplica (rodsServerHost->conn, regReplicaInp);
	if (status >= 0) regReplicaInp->destDataObjInfo->replNum = status;

    }

    return (status);
}
int
rsGeneralRowInsert (rsComm_t *rsComm, generalRowInsertInp_t *generalRowInsertInp )
{
    rodsServerHost_t *rodsServerHost;
    int status;

    rodsLog(LOG_DEBUG, "generalRowInsert");

    status = getAndConnRcatHost(rsComm, MASTER_RCAT, NULL, &rodsServerHost);
    if (status < 0) {
       return(status);
    }

    if (rodsServerHost->localFlag == LOCAL_HOST) {
#ifdef RODS_CAT
       status = _rsGeneralRowInsert (rsComm, generalRowInsertInp);
#else
       status = SYS_NO_RCAT_SERVER_ERR;
#endif
    }
    else {
       status = rcGeneralRowInsert(rodsServerHost->conn,
			       generalRowInsertInp);
    }

    if (status < 0) { 
       rodsLog (LOG_NOTICE,
		"rsGeneralRowInsert: rcGeneralRowInsert failed");
    }
    return (status);
}
Exemple #8
0
int
rsGetTempPassword( rsComm_t *rsComm,
                   getTempPasswordOut_t **getTempPasswordOut ) {
    rodsServerHost_t *rodsServerHost;
    int status;

    status = getAndConnRcatHost( rsComm, MASTER_RCAT, (const char*)NULL, &rodsServerHost );

    if ( status < 0 ) {
        return status;
    }

    if ( rodsServerHost->localFlag == LOCAL_HOST ) {
#ifdef RODS_CAT
        status = _rsGetTempPassword( rsComm, getTempPasswordOut );
#else
        status = SYS_NO_RCAT_SERVER_ERR;
#endif
    }
    else {
        status = rcGetTempPassword( rodsServerHost->conn,
                                    getTempPasswordOut );
    }

    if ( status < 0 ) {
        rodsLog( LOG_NOTICE,
                 "rsGetTempPassword: rcGetTempPassword failed, status = %d",
                 status );
    }
    return status;
}
int
rsChkObjPermAndStat( rsComm_t *rsComm,
                     chkObjPermAndStat_t *chkObjPermAndStatInp ) {
    int status;
    rodsServerHost_t *rodsServerHost = NULL;

    status = getAndConnRcatHost( rsComm, SLAVE_RCAT,
                                 chkObjPermAndStatInp->objPath, &rodsServerHost );
    if ( status < 0 || rodsServerHost == NULL ) { // JMC cppcheck
        return status;
    }
    if ( rodsServerHost->localFlag == LOCAL_HOST ) {
#ifdef RODS_CAT
        status = _rsChkObjPermAndStat( rsComm, chkObjPermAndStatInp );
#else
        status = SYS_NO_RCAT_SERVER_ERR;
#endif
    }
    else {
        status = rcChkObjPermAndStat( rodsServerHost->conn,
                                      chkObjPermAndStatInp );
    }

    return status;
}
Exemple #10
0
int
reSvrSleep (rsComm_t *rsComm)
{
    int status;
    rodsServerHost_t *rodsServerHost = NULL;

    if ((status = disconnRcatHost (rsComm, MASTER_RCAT, 
      rsComm->myEnv.rodsZone)) == LOCAL_HOST) {
#ifdef RODS_CAT
#ifndef ORA_ICAT
       /* For Oracle, we don't disconnect.  This is to avoid a 
          memory leak in the OCI library */
        disconnectRcat (rsComm);
        if (status < 0) {
            rodsLog (LOG_ERROR,
              "reSvrSleep: disconnectRcat error. status = %d", status);
        }
#endif
#endif
    }
    rodsSleep (RE_SERVER_SLEEP_TIME, 0);

    if ((status = getAndConnRcatHost (rsComm, MASTER_RCAT, 
      rsComm->myEnv.rodsZone, &rodsServerHost)) == LOCAL_HOST) {
#ifdef RODS_CAT
        status = connectRcat (rsComm);
        if (status < 0) {
            rodsLog (LOG_ERROR,
              "reSvrSleep: connectRcat error. status = %d", status);
	}
#endif
    }
    return (status);
}
Exemple #11
0
int
rsGetRescQuota( rsComm_t *rsComm, getRescQuotaInp_t *getRescQuotaInp,
                rescQuota_t **rescQuota ) {
    rodsServerHost_t *rodsServerHost;
    int status = 0;

    status = getAndConnRcatHost(
                 rsComm,
                 SLAVE_RCAT,
                 ( const char* )getRescQuotaInp->zoneHint,
                 &rodsServerHost );

    if ( status < 0 ) {
        return status;
    }

    if ( rodsServerHost->localFlag == LOCAL_HOST ) {
        status = _rsGetRescQuota( rsComm, getRescQuotaInp, rescQuota );
    }
    else {
        status = rcGetRescQuota( rodsServerHost->conn, getRescQuotaInp,
                                 rescQuota );
    }

    return status;
}
int
rsGeneralAdmin (rsComm_t *rsComm, generalAdminInp_t *generalAdminInp )
{
    rodsServerHost_t *rodsServerHost;
    int status;

    rodsLog(LOG_DEBUG, "generalAdmin");

    status = getAndConnRcatHost(rsComm, MASTER_RCAT, NULL, &rodsServerHost);
    if (status < 0) {
       return(status);
    }

    if (rodsServerHost->localFlag == LOCAL_HOST) {
#ifdef RODS_CAT
       status = _rsGeneralAdmin (rsComm, generalAdminInp);
#else
       status = SYS_NO_RCAT_SERVER_ERR;
#endif
    }
    else {
       status = rcGeneralAdmin(rodsServerHost->conn,
			       generalAdminInp);
       if (status < 0) {
	  replErrorStack (rodsServerHost->conn->rError, &rsComm->rError);
       }
    }
    if (status < 0) { 
       rodsLog (LOG_NOTICE,
		"rsGeneralAdmin: rcGeneralAdmin error %d", status);
    }
    return (status);
}
Exemple #13
0
/* rsRegDataObj - This call is strictly an API handler and should not be
 * called directly in the server. For server calls, use svrRegDataObj
 */
int
rsRegDataObj( rsComm_t *rsComm, dataObjInfo_t *dataObjInfo,
              dataObjInfo_t **outDataObjInfo ) {
    int status;
    rodsServerHost_t *rodsServerHost = NULL;

    *outDataObjInfo = NULL;

    status = getAndConnRcatHost( rsComm, MASTER_RCAT, ( const char* )dataObjInfo->objPath,
                                 &rodsServerHost );
    if ( status < 0 || NULL == rodsServerHost ) { // JMC cppcheck - nullptr
        return status;
    }

    if ( rodsServerHost->localFlag == LOCAL_HOST ) {
#ifdef RODS_CAT
        status = _rsRegDataObj( rsComm, dataObjInfo );
        if ( status >= 0 ) {
            *outDataObjInfo = ( dataObjInfo_t * ) malloc( sizeof( dataObjInfo_t ) );
            /* fake pointers will be deleted by the packing */
            //**outDataObjInfo = *dataObjInfo;
            memcpy( *outDataObjInfo, dataObjInfo, sizeof( dataObjInfo_t ) );
        }
#else
        status = SYS_NO_RCAT_SERVER_ERR;
#endif
    }
    else {
        status = rcRegDataObj( rodsServerHost->conn, dataObjInfo,
                               outDataObjInfo );
    }
    return status;
}
int
rsModDataObjMeta( rsComm_t *rsComm, modDataObjMeta_t *modDataObjMetaInp ) {
    int status;
    rodsServerHost_t *rodsServerHost = NULL;
    dataObjInfo_t *dataObjInfo;

    dataObjInfo = modDataObjMetaInp->dataObjInfo;

    status = getAndConnRcatHost( rsComm, MASTER_RCAT, dataObjInfo->objPath,
                                 &rodsServerHost );
    if ( status < 0 || NULL == rodsServerHost ) { // JMC cppcheck - nullptr
        return( status );
    }
    if ( rodsServerHost->localFlag == LOCAL_HOST ) {
#ifdef RODS_CAT
        status = _rsModDataObjMeta( rsComm, modDataObjMetaInp );
#else
        status = SYS_NO_RCAT_SERVER_ERR;
#endif
    }
    else {
        status = rcModDataObjMeta( rodsServerHost->conn, modDataObjMetaInp );
    }

    if ( status >= 0 ) {
        status = _call_file_modified_for_modification( rsComm, modDataObjMetaInp );
    }

    return ( status );
}
Exemple #15
0
int
rsModColl( rsComm_t *rsComm, collInp_t *modCollInp ) {
    int status;
    rodsServerHost_t *rodsServerHost = NULL;

    status = getAndConnRcatHost( 
                 rsComm, 
                 MASTER_RCAT, 
                 (const char*)modCollInp->collName,
                 &rodsServerHost );
    if ( status < 0 || NULL == rodsServerHost ) { // JMC cppcheck - nullptr
        return status;
    }
    if ( rodsServerHost->localFlag == LOCAL_HOST ) {
#ifdef RODS_CAT
        status = _rsModColl( rsComm, modCollInp );
#else
        status = SYS_NO_RCAT_SERVER_ERR;
#endif
    }
    else {
        status = rcModColl( rodsServerHost->conn, modCollInp );
    }

    return status;
}
Exemple #16
0
int
rsEndTransaction( rsComm_t *rsComm, endTransactionInp_t *endTransactionInp ) {
    rodsServerHost_t *rodsServerHost;
    int status;

    rodsLog( LOG_DEBUG, "endTransaction" );

    status = getAndConnRcatHost( rsComm, MASTER_RCAT, NULL, &rodsServerHost );
    if ( status < 0 ) {
        return status;
    }

    if ( rodsServerHost->localFlag == LOCAL_HOST ) {
#ifdef RODS_CAT
        status = _rsEndTransaction( rsComm, endTransactionInp );
#else
        status = SYS_NO_RCAT_SERVER_ERR;
#endif
    }
    else {
        status = rcEndTransaction( rodsServerHost->conn,
                                   endTransactionInp );
    }

    if ( status < 0 ) {
        rodsLog( LOG_NOTICE,
                 "rsEndTransaction: rcEndTransaction failed" );
    }
    return status;
}
int
rsTicketAdmin (rsComm_t *rsComm, ticketAdminInp_t *ticketAdminInp )
{
    rodsServerHost_t *rodsServerHost;
    int status;

    rodsLog(LOG_DEBUG, "ticketAdmin");

    status = getAndConnRcatHost(rsComm, MASTER_RCAT, NULL, &rodsServerHost);
    if (status < 0) {
       return(status);
    }

    if (rodsServerHost->localFlag == LOCAL_HOST) {
#ifdef RODS_CAT
       status = _rsTicketAdmin (rsComm, ticketAdminInp);
#else
       status = SYS_NO_RCAT_SERVER_ERR;
#endif
    }
    else {
       if (strcmp(ticketAdminInp->arg1,"session")==0 ) {
	  ticketAdminInp->arg3 = rsComm->clientAddr;
       }
       status = rcTicketAdmin(rodsServerHost->conn,
                            ticketAdminInp);
    }

    if (status < 0) { 
       rodsLog (LOG_NOTICE,
                "rsTicketAdmin failed, error %d", status);
    }
    return (status);
}
int
rsRuleExecSubmit (rsComm_t *rsComm, ruleExecSubmitInp_t *ruleExecSubmitInp,
char **ruleExecId)
{
    rodsServerHost_t *rodsServerHost;
    int status;

    *ruleExecId = NULL;

    if (ruleExecSubmitInp == NULL || 
      ruleExecSubmitInp->packedReiAndArgBBuf == NULL ||
      ruleExecSubmitInp->packedReiAndArgBBuf->len <= 0 ||
      ruleExecSubmitInp->packedReiAndArgBBuf->buf == NULL) {
       rodsLog(LOG_NOTICE,
        "rsRuleExecSubmit error. NULL input");
       return (SYS_INTERNAL_NULL_INPUT_ERR);
    }

#if 0
    status = getAndConnRcatHost(rsComm, MASTER_RCAT, NULL,
                                &rodsServerHost);
#else
    status = getAndConnReHost (rsComm, &rodsServerHost);
#endif
    if (status < 0) {
       return(status);
    }

    if (rodsServerHost->localFlag == LOCAL_HOST) {
#ifdef RODS_CAT
       status = _rsRuleExecSubmit (rsComm, ruleExecSubmitInp);
        if (status >= 0) {
            *ruleExecId = strdup (ruleExecSubmitInp->ruleExecId);
        }
#else
       rodsLog(LOG_NOTICE,
               "rsRuleExecSubmit error. ICAT is not configured on this host");
       return (SYS_NO_ICAT_SERVER_ERR);
#endif
    } else {
	if (getValByKey (&ruleExecSubmitInp->condInput, EXEC_LOCALLY_KW) != 
	  NULL) {
            rodsLog (LOG_ERROR,
              "rsRuleExecSubmit: reHost config error. reServer not running locally");
	    return SYS_CONFIG_FILE_ERR;
	} else {
	    addKeyVal (&ruleExecSubmitInp->condInput, EXEC_LOCALLY_KW, "");
	}
        status = rcRuleExecSubmit(rodsServerHost->conn, ruleExecSubmitInp,
	  ruleExecId);
    }
    if (status < 0) {
        rodsLog (LOG_ERROR,
          "rsRuleExecSubmit: rcRuleExecSubmit failed, status = %d", 
	  status);
    }
    return (status);
}
Exemple #19
0
int
rsModAVUMetadata (rsComm_t *rsComm, modAVUMetadataInp_t *modAVUMetadataInp )
{
    rodsServerHost_t *rodsServerHost;
    int status;
    char *myHint;

    if (strcmp(modAVUMetadataInp->arg0,"add")==0) {
	myHint = modAVUMetadataInp->arg2;
    } else if (strcmp(modAVUMetadataInp->arg0,"adda")==0) {
        myHint = modAVUMetadataInp->arg2;
    } else if (strcmp(modAVUMetadataInp->arg0,"addw")==0) {
        myHint = modAVUMetadataInp->arg2;
    } else if (strcmp(modAVUMetadataInp->arg0,"rmw")==0) {
        myHint = modAVUMetadataInp->arg2;
    } else if (strcmp(modAVUMetadataInp->arg0,"rmi")==0) {
        myHint = modAVUMetadataInp->arg2;
    } else if (strcmp(modAVUMetadataInp->arg0,"rm")==0) {
        myHint = modAVUMetadataInp->arg2;
    } else if (strcmp(modAVUMetadataInp->arg0,"cp")==0) {
        myHint = modAVUMetadataInp->arg3;
    } else if (strcmp(modAVUMetadataInp->arg0,"mod")==0) {
        myHint = modAVUMetadataInp->arg2;
    } else if (strcmp(modAVUMetadataInp->arg0,"set")==0) {
        myHint = modAVUMetadataInp->arg2;
    } else {
	/* assume local */
	myHint = NULL;
    }
 
    status = getAndConnRcatHost(rsComm, MASTER_RCAT, myHint, &rodsServerHost);
    if (status < 0) {
       return(status);
    }

    if (rodsServerHost->localFlag == LOCAL_HOST) {
#ifdef RODS_CAT
       status = _rsModAVUMetadata (rsComm, modAVUMetadataInp);
#else
       status = SYS_NO_RCAT_SERVER_ERR;
#endif
    }
    else {
       status = rcModAVUMetadata(rodsServerHost->conn,
			       modAVUMetadataInp);
    }

    if (status < 0) { 
       rodsLog (LOG_NOTICE,
		"rsModAVUMetadata: rcModAVUMetadata failed");
    }
    return (status);
}
int
rsPamAuthRequest (rsComm_t *rsComm, pamAuthRequestInp_t *pamAuthRequestInp,
		  pamAuthRequestOut_t **pamAuthRequestOut)
{
    rodsServerHost_t *rodsServerHost;
    int status;

    status = getAndConnRcatHost(rsComm, MASTER_RCAT, 
                                rsComm->clientUser.rodsZone, &rodsServerHost);
    if (status < 0) {
       return(status);
    }
    if (rodsServerHost->localFlag == LOCAL_HOST) {
#ifdef RODS_CAT
       status = _rsPamAuthRequest(rsComm,  pamAuthRequestInp,
				  pamAuthRequestOut);

#else
       status = SYS_NO_RCAT_SERVER_ERR;
#endif
    }
    else {
#ifdef USE_SSL
        /* protect the PAM plain text password by
           using an SSL connection to the remote ICAT */
        status = sslStart(rodsServerHost->conn);
        if (status) {
            rodsLog(LOG_NOTICE, "rsPamAuthRequest: could not establish SSL connection, status %d",
                    status);
            return(status);
        }
#else
        rodsLog(LOG_ERROR, "iRODS doesn't include SSL support, required for PAM authentication.");
        return SSL_NOT_BUILT_INTO_SERVER;
#endif /* USE_SSL */

       status = rcPamAuthRequest(rodsServerHost->conn, pamAuthRequestInp,
				 pamAuthRequestOut);
#ifdef USE_SSL
       sslEnd(rodsServerHost->conn);
#endif
       rcDisconnect(rodsServerHost->conn);
       rodsServerHost->conn = NULL;
       if (status < 0) {
           rodsLog(LOG_NOTICE, "rsPamAuthRequest: rcPamAuthRequest to remote server failed, status %d",
                   status);
       }
    }
    return (status);
}
Exemple #21
0
int
rsSpecificQuery( rsComm_t *rsComm, specificQueryInp_t *specificQueryInp,
                 genQueryOut_t **genQueryOut ) {
    rodsServerHost_t *rodsServerHost;
    int status;
    char *zoneHint = "";

    /*  zoneHint = getZoneHintForGenQuery (genQueryInp); (need something like this?) */
    zoneHint = getValByKey( &specificQueryInp->condInput, ZONE_KW );

    status = getAndConnRcatHost( rsComm, SLAVE_RCAT, ( const char* )zoneHint,
                                 &rodsServerHost );
    if ( status < 0 ) {
        return status;
    }

    if ( rodsServerHost->localFlag == LOCAL_HOST ) {
        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 ) {
            status = _rsSpecificQuery( rsComm, specificQueryInp, genQueryOut );
        } else if( irods::CFG_SERVICE_ROLE_CONSUMER == svc_role ) {
            rodsLog( LOG_NOTICE,
                     "rsSpecificQuery error. RCAT is not configured on this host" );
            return 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 = rcSpecificQuery( rodsServerHost->conn,
                                  specificQueryInp, genQueryOut );
    }
    if ( status < 0  && status != CAT_NO_ROWS_FOUND ) {
        rodsLog( LOG_NOTICE,
                 "rsSpecificQuery: rcSpecificQuery failed, status = %d", status );
    }
    return status;
}
Exemple #22
0
int
rsGenQuery( rsComm_t *rsComm, genQueryInp_t *genQueryInp,
            genQueryOut_t **genQueryOut ) {
    rodsServerHost_t *rodsServerHost;
    int status;
    char *zoneHint;
    zoneHint = getZoneHintForGenQuery( genQueryInp );

    std::string zone_hint_str;
    if ( zoneHint ) {
        zone_hint_str = zoneHint;
    }

    status = getAndConnRcatHost( rsComm, SLAVE_RCAT, zoneHint,
                                 &rodsServerHost );

    if ( status < 0 ) {
        return( status );
    }

    // =-=-=-=-=-=-=-
    // handle non-irods connections
    if ( !zone_hint_str.empty() ) {
        irods::error ret = proc_query_terms_for_non_irods_server( zone_hint_str, genQueryInp );
        if ( !ret.ok() ) {
            irods::log( PASS( ret ) );
        }
    }

    if ( rodsServerHost->localFlag == LOCAL_HOST ) {
#ifdef RODS_CAT
        status = _rsGenQuery( rsComm, genQueryInp, genQueryOut );
#else
        rodsLog( LOG_NOTICE,
                 "rsGenQuery error. RCAT is not configured on this host" );
        return ( SYS_NO_RCAT_SERVER_ERR );
#endif
    }
    else {
        status = rcGenQuery( rodsServerHost->conn,
                             genQueryInp, genQueryOut );
    }
    if ( status < 0  && status != CAT_NO_ROWS_FOUND ) {
        rodsLog( LOG_NOTICE,
                 "rsGenQuery: rcGenQuery failed, status = %d", status );
    }
    return ( status );
}
Exemple #23
0
int
svrUnregColl( rsComm_t *rsComm, collInp_t *rmCollInp ) {
    int status;
#ifdef RODS_CAT
    collInfo_t collInfo;
#endif
    rodsServerHost_t *rodsServerHost = NULL;

    status = getAndConnRcatHost(
                 rsComm,
                 MASTER_RCAT,
                 ( const char* )rmCollInp->collName,
                 &rodsServerHost );
    if ( status < 0 || NULL == rodsServerHost ) { // JMC cppcheck - nullptr
        return status;
    }

    if ( rodsServerHost->localFlag == LOCAL_HOST ) {
#ifdef RODS_CAT
        memset( &collInfo, 0, sizeof( collInfo ) );
        rstrcpy( collInfo.collName, rmCollInp->collName, MAX_NAME_LEN );
        if ( getValByKey( &rmCollInp->condInput, ADMIN_RMTRASH_KW )
                != NULL ) {
            status = chlDelCollByAdmin( rsComm, &collInfo );
            if ( status >= 0 ) {
                chlCommit( rsComm );
            }
        }
        else {
            status = chlDelColl( rsComm, &collInfo );
        }

#else
        status = SYS_NO_RCAT_SERVER_ERR;
#endif
    }
    else {
        collOprStat_t *collOprStat = NULL;;
        addKeyVal( &rmCollInp->condInput, UNREG_COLL_KW, "" );
        status = _rcRmColl( rodsServerHost->conn, rmCollInp, &collOprStat );
        if ( collOprStat != NULL ) {
            free( collOprStat );
        }
    }

    return status;
}
Exemple #24
0
int
rsTicketAdmin( rsComm_t *rsComm, ticketAdminInp_t *ticketAdminInp ) {
    rodsServerHost_t *rodsServerHost;
    int status;

    rodsLog( LOG_DEBUG, "ticketAdmin" );

    status = getAndConnRcatHost( rsComm, MASTER_RCAT, ( const char* )NULL, &rodsServerHost );
    if ( status < 0 ) {
        return status;
    }

    if ( rodsServerHost->localFlag == LOCAL_HOST ) {
        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 ) {
            status = _rsTicketAdmin( rsComm, ticketAdminInp );
        } 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 {
        if ( strcmp( ticketAdminInp->arg1, "session" ) == 0 ) {
            ticketAdminInp->arg3 = rsComm->clientAddr;
        }
        status = rcTicketAdmin( rodsServerHost->conn,
                                ticketAdminInp );
    }

    if ( status < 0 ) {
        rodsLog( LOG_NOTICE,
                 "rsTicketAdmin failed, error %d", status );
    }
    return status;
}
Exemple #25
0
int
rsPamAuthRequest( rsComm_t *rsComm, pamAuthRequestInp_t *pamAuthRequestInp,
                  pamAuthRequestOut_t **pamAuthRequestOut ) {
    rodsServerHost_t *rodsServerHost;
    int status;

    status = getAndConnRcatHost( 
                 rsComm, 
                 MASTER_RCAT,
                 (const char*)rsComm->clientUser.rodsZone, 
                 &rodsServerHost );
    if ( status < 0 ) {
        return status;
    }
    if ( rodsServerHost->localFlag == LOCAL_HOST ) {
#ifdef RODS_CAT
        status = _rsPamAuthRequest( rsComm,  pamAuthRequestInp,
                                    pamAuthRequestOut );

#else
        status = SYS_NO_RCAT_SERVER_ERR;
#endif
    }
    else {
        /* protect the PAM plain text password by
           using an SSL connection to the remote ICAT */
        status = sslStart( rodsServerHost->conn );
        if ( status ) {
            rodsLog( LOG_NOTICE, "rsPamAuthRequest: could not establish SSL connection, status %d",
                     status );
            return status;
        }

        status = rcPamAuthRequest( rodsServerHost->conn, pamAuthRequestInp,
                                   pamAuthRequestOut );
        sslEnd( rodsServerHost->conn );
        rcDisconnect( rodsServerHost->conn );
        rodsServerHost->conn = NULL;
        if ( status < 0 ) {
            rodsLog( LOG_NOTICE, "rsPamAuthRequest: rcPamAuthRequest to remote server failed, status %d",
                     status );
        }
    }
    return status;
}
Exemple #26
0
int
rsRegColl (rsComm_t *rsComm, collInp_t *regCollInp)
{
    int status;
    rodsServerHost_t *rodsServerHost = NULL;
    dataObjInp_t dataObjInp;
    rodsObjStat_t *rodsObjStatOut = NULL;


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

    rstrcpy (dataObjInp.objPath, regCollInp->collName, MAX_NAME_LEN);
#if 0   /* separate specColl */
    status = __rsObjStat (rsComm, &dataObjInp, 1, &rodsObjStatOut);
#endif
    status = rsObjStat (rsComm, &dataObjInp, &rodsObjStatOut);
    if (status >= 0) {
        if (rodsObjStatOut != NULL && rodsObjStatOut->specColl != NULL) {	// cppcheck - Possible null pointer dereference: rodsObjStatOut
            rodsLog (LOG_ERROR,
             "rsRegColl: Reg path %s is in spec coll",
              dataObjInp.objPath);
            freeRodsObjStat (rodsObjStatOut);
            return (SYS_REG_OBJ_IN_SPEC_COLL);
	}
	freeRodsObjStat (rodsObjStatOut);
    }

    status = getAndConnRcatHost (rsComm, MASTER_RCAT, regCollInp->collName,
                                &rodsServerHost);
    if (status < 0) {
       return(status);
    }
    if (rodsServerHost->localFlag == LOCAL_HOST) {
#ifdef RODS_CAT
        status = _rsRegColl (rsComm, regCollInp);
#else
        status = SYS_NO_RCAT_SERVER_ERR;
#endif
    } else {
        status = rcRegColl (rodsServerHost->conn, regCollInp);
    }

    return (status);
}
Exemple #27
0
int
rsModAccessControl( rsComm_t *rsComm, modAccessControlInp_t *modAccessControlInp ) {
    rodsServerHost_t *rodsServerHost;
    int status;
    specCollCache_t *specCollCache = NULL;
    char newPath[MAX_NAME_LEN];
    modAccessControlInp_t newModAccessControlInp = *modAccessControlInp;

    rstrcpy( newPath, newModAccessControlInp.path, MAX_NAME_LEN );
    resolveLinkedPath( rsComm, newPath, &specCollCache, NULL );
    if ( strcmp( newPath, newModAccessControlInp.path ) != 0 ) {
        newModAccessControlInp.path = newPath;
    }

    status = getAndConnRcatHost(
                 rsComm,
                 MASTER_RCAT,
                 ( const char* )newModAccessControlInp.path,
                 &rodsServerHost );
    if ( status < 0 ) {
        return status;
    }

    if ( rodsServerHost->localFlag == LOCAL_HOST ) {
#ifdef RODS_CAT
        status = _rsModAccessControl( rsComm, &newModAccessControlInp );
#else
        status = SYS_NO_RCAT_SERVER_ERR;
#endif
    }
    else {
        status = rcModAccessControl( rodsServerHost->conn,
                                     &newModAccessControlInp );
    }

    if ( status < 0 ) {
        rodsLog( LOG_NOTICE,
                 "rsModAccessControl: rcModAccessControl failed" );
    }
    return status;
}
int
rsModDataObjMeta (rsComm_t *rsComm, modDataObjMeta_t *modDataObjMetaInp)
{
    int status;
    rodsServerHost_t *rodsServerHost = NULL;
    dataObjInfo_t *dataObjInfo;
    keyValPair_t *regParam;

    regParam = modDataObjMetaInp->regParam;
    dataObjInfo = modDataObjMetaInp->dataObjInfo;

    status = getAndConnRcatHost (rsComm, MASTER_RCAT, dataObjInfo->objPath,
      &rodsServerHost);
    if (status < 0) {
       return(status);
    }
    if (rodsServerHost->localFlag == LOCAL_HOST) {
#ifdef RODS_CAT
        status = _rsModDataObjMeta (rsComm, modDataObjMetaInp);
#else
        status = SYS_NO_RCAT_SERVER_ERR;
#endif
    } else {
        status = rcModDataObjMeta (rodsServerHost->conn, modDataObjMetaInp);
        if (getIrodsErrno (status) == SYS_HEADER_READ_LEN_ERR ||
          getIrodsErrno (status) == SYS_HEADER_WRITE_LEN_ERR) {
            /* this connection may be broken. try again */
            int status1 = svrToSvrReConnect (rsComm, rodsServerHost);
            if (status1 >= 0) {
                status = rcModDataObjMeta (rodsServerHost->conn, 
                  modDataObjMetaInp);
            }
        }

    }

    return (status);
}
int
rsRegReplica (rsComm_t *rsComm, regReplica_t *regReplicaInp)
{
    int status;
    rodsServerHost_t *rodsServerHost = NULL;
    dataObjInfo_t *srcDataObjInfo;
    dataObjInfo_t *destDataObjInfo;

    srcDataObjInfo = regReplicaInp->srcDataObjInfo;
    destDataObjInfo = regReplicaInp->destDataObjInfo;

    status = getAndConnRcatHost (rsComm, MASTER_RCAT, srcDataObjInfo->objPath,
      &rodsServerHost);
    if (status < 0) {
       return(status);
    }
    if (rodsServerHost->localFlag == LOCAL_HOST) {
#ifdef RODS_CAT
        status = _rsRegReplica (rsComm, regReplicaInp);
#else
        status = SYS_NO_RCAT_SERVER_ERR;
#endif
    } else {
        status = rcRegReplica (rodsServerHost->conn, regReplicaInp);
        if (getIrodsErrno (status) == SYS_HEADER_READ_LEN_ERR ||
          getIrodsErrno (status) == SYS_HEADER_WRITE_LEN_ERR) {
            /* this connection may be broken. try again */
            int status1 = svrToSvrReConnect (rsComm, rodsServerHost);
            if (status1 >= 0) {
                status = rcRegReplica (rodsServerHost->conn, regReplicaInp);
            }
        }
	if (status >= 0) regReplicaInp->destDataObjInfo->replNum = status;

    }

    return (status);
}
Exemple #30
0
int
svrRegDataObj( rsComm_t *rsComm, dataObjInfo_t *dataObjInfo ) {
    int status;
    rodsServerHost_t *rodsServerHost = NULL;

    if ( dataObjInfo->specColl != NULL ) {
        rodsLog( LOG_NOTICE,
                 "svrRegDataObj: Reg path %s is in spec coll",
                 dataObjInfo->objPath );
        return SYS_REG_OBJ_IN_SPEC_COLL;
    }

    status = getAndConnRcatHost( rsComm, MASTER_RCAT, ( const char* )dataObjInfo->objPath,
                                 &rodsServerHost );
    if ( status < 0 || NULL == rodsServerHost ) { // JMC cppcheck - nullptr
        return status;
    }

    if ( rodsServerHost->localFlag == LOCAL_HOST ) {
#ifdef RODS_CAT
        status = _rsRegDataObj( rsComm, dataObjInfo );
#else
        status = SYS_NO_RCAT_SERVER_ERR;
#endif
    }
    else {
        dataObjInfo_t *outDataObjInfo = NULL;
        status = rcRegDataObj( rodsServerHost->conn, dataObjInfo,
                               &outDataObjInfo );
        if ( status >= 0 && NULL != outDataObjInfo ) { // JMC cppcheck - nullptr
            dataObjInfo->dataId = outDataObjInfo->dataId;
            clearKeyVal( &outDataObjInfo->condInput );
            free( outDataObjInfo );
        }
    }

    return status;
}