Beispiel #1
0
int
icatApplyRule( rsComm_t *rsComm, char *ruleName, char *arg1 ) {
    ruleExecInfo_t rei;
    int status;
    const char *args[2];

    rodsLog( LOG_NOTICE, "icatApplyRule called" );
    memset( ( char* )&rei, 0, sizeof( rei ) );
    args[0] = arg1;
    rei.rsComm = rsComm;
    rei.uoic = &rsComm->clientUser;
    rei.uoip = &rsComm->proxyUser;
    status =  applyRuleArg( ruleName,
                            args, 1, &rei, NO_SAVE_REI );
    return status;
}
Beispiel #2
0
int
_rsModAccessControl( rsComm_t *rsComm,
                     modAccessControlInp_t *modAccessControlInp ) {
    int status, status2;

    const char *args[MAX_NUM_OF_ARGS_IN_ACTION];
    ruleExecInfo_t rei2;
    memset( ( char* )&rei2, 0, sizeof( ruleExecInfo_t ) );
    rei2.rsComm = rsComm;
    if ( rsComm != NULL ) {
        rei2.uoic = &rsComm->clientUser;
        rei2.uoip = &rsComm->proxyUser;
    }

    char rFlag[15];
    snprintf( rFlag, sizeof( rFlag ), "%d", modAccessControlInp->recursiveFlag );
    args[0] = rFlag;
    args[1] = modAccessControlInp->accessLevel;
    args[2] = modAccessControlInp->userName;
    args[3] = modAccessControlInp->zone;
    args[4] = modAccessControlInp->path;
    int argc = 5;
    status2 = applyRuleArg( "acPreProcForModifyAccessControl", args, argc, &rei2, NO_SAVE_REI );
    if ( status2 < 0 ) {
        if ( rei2.status < 0 ) {
            status2 = rei2.status;
        }
        rodsLog( LOG_ERROR,
                 "rsModAVUMetadata:acPreProcForModifyAccessControl error for %s.%s of level %s for %s,stat=%d",
                 modAccessControlInp->zone,
                 modAccessControlInp->userName,
                 modAccessControlInp->accessLevel,
                 modAccessControlInp->path, status2 );
        return status2;
    }

    status = chlModAccessControl( rsComm,
                                  modAccessControlInp->recursiveFlag,
                                  modAccessControlInp->accessLevel,
                                  modAccessControlInp->userName,
                                  modAccessControlInp->zone,
                                  modAccessControlInp->path );

    if ( status == 0 ) {
        status2 = applyRuleArg( "acPostProcForModifyAccessControl",
                                args, argc, &rei2, NO_SAVE_REI );
        if ( status2 < 0 ) {
            if ( rei2.status < 0 ) {
                status2 = rei2.status;
            }
            rodsLog( LOG_ERROR,
                     "rsModAVUMetadata:acPostProcForModifyAccessControl error for %s.%s of level %s for %s,stat=%d",
                     modAccessControlInp->zone,
                     modAccessControlInp->userName,
                     modAccessControlInp->accessLevel,
                     modAccessControlInp->path,
                     status2 );
            return status;
        }
    }

    return status;
}
Beispiel #3
0
int
_rsGenQuery (rsComm_t *rsComm, genQueryInp_t *genQueryInp,
	     genQueryOut_t **genQueryOut)
{
    int status;

    static int ruleExecuted=0;
    ruleExecInfo_t rei;
    static int ruleResult=0;


    static int PrePostProcForGenQueryFlag = -2;    
    int i, argc;
    ruleExecInfo_t rei2;
    char *args[MAX_NUM_OF_ARGS_IN_ACTION];
    
    if (PrePostProcForGenQueryFlag < 0) {
      if (getenv("PREPOSTPROCFORGENQUERYFLAG") != NULL)
	PrePostProcForGenQueryFlag = 1;
      else
	PrePostProcForGenQueryFlag = 0;
    }

    memset ((char*)&rei2, 0, sizeof (ruleExecInfo_t));
    rei2.rsComm = rsComm;
    if (rsComm != NULL) {
      rei2.uoic = &rsComm->clientUser;
      rei2.uoip = &rsComm->proxyUser;
    }

    /*  printGenQI(genQueryInp);  for debug */

    *genQueryOut = (genQueryOut_t*)malloc(sizeof(genQueryOut_t));
    memset((char *)*genQueryOut, 0, sizeof(genQueryOut_t));

    if (ruleExecuted==0) {
#if 0
       msParam_t *outMsParam;
#endif
       memset((char*)&rei,0,sizeof(rei));
       rei.rsComm = rsComm;
       if (rsComm != NULL) {
          /* Include the user info for possible use by the rule.  Note
	     that when this is called (as the agent is initializing),
	     this user info is not confirmed yet.  For password
	     authentication though, the agent will soon exit if this
	     is not valid.  But tor GSI, the user information may not
	     be present and/or may be changed when the authentication
	     completes, so it may not be safe to use this in a GSI
	     enabled environment.  This addition of user information
	     was requested by ARCS/IVEC (Sean Fleming) to avoid a
	     local patch.
          */
	  rei.uoic = &rsComm->clientUser;
	  rei.uoip = &rsComm->proxyUser;
       }
#ifdef RULE_ENGINE_N
       if (getRuleEngineStatus() == UNINITIALIZED) { 
          /* Skip the call to run acAclPolicy if the Rule Engine
             hasn't been initialized yet, which happens for a couple
             initial queries made by the agent when starting up.  The
             new RE logs these types of errors and so this avoids that.
          */
          status = -1;
       }
       else 
#endif
       {
          status = applyRule ("acAclPolicy", NULL, &rei, NO_SAVE_REI);
          ruleResult = rei.status;
       }
       if (status==0) {
	  ruleExecuted=1; /* No need to retry next time since it
                             succeeded.  Since this is called at
                             startup, the Rule Engine may not be
                             initialized yet, in which case the
                             default setting is fine and we should
                             retry next time. */
#if 0
	  /* No longer need this as msiAclPolicy calls
	     chlGenQueryAccessControlSetup to set the flag.  Leaving
	     it in the code for now in case needed later. */
	  outMsParam = getMsParamByLabel(&rei.inOutMsParamArray, "STRICT");
	  printf("outMsParam=%x\n",(int)outMsParam);
	  if (outMsParam != NULL) {
	     ruleResult=1;
	  }
#endif
       }
#if 0
       printf("rsGenQuery rule status=%d ruleResult=%d\n",status,ruleResult);
#endif
    }

    chlGenQueryAccessControlSetup(rsComm->clientUser.userName, 
			      rsComm->clientUser.rodsZone,
			      rsComm->clientAddr,
	 		      rsComm->clientUser.authInfo.authFlag,
			      -1);
#if 0
    rodsLog (LOG_NOTICE, 
	     "_rsGenQuery debug: client %s %d proxy %s %d", 
	     rsComm->clientUser.userName, 
	     rsComm->clientUser.authInfo.authFlag,
	     rsComm->proxyUser.userName, 
	     rsComm->proxyUser.authInfo.authFlag);
#endif
    /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/
    if (PrePostProcForGenQueryFlag == 1) {
      args[0] = (char *) malloc(300);
      sprintf(args[0],"%ld",(long) genQueryInp);
      argc = 1;
      i =  applyRuleArg("acPreProcForGenQuery",args,argc, &rei2, NO_SAVE_REI);
      free(args[0]);
      if (i < 0) {
	rodsLog (LOG_ERROR,
		 "rsGenQuery:acPreProcForGenQuery error,stat=%d", i);
        if (i != NO_MICROSERVICE_FOUND_ERR)
	  return i;
      }
    }
    /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/

    status = chlGenQuery(*genQueryInp, *genQueryOut);

    /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/
    if (PrePostProcForGenQueryFlag == 1) {
      args[0] = (char *) malloc(300);
      args[1] = (char *) malloc(300);
      args[2] = (char *) malloc(300);
      sprintf(args[0],"%ld",(long) genQueryInp);
      sprintf(args[1],"%ld",(long) *genQueryOut);
      sprintf(args[2],"%d",status);
      argc = 3;
      i =  applyRuleArg("acPostProcForGenQuery",args,argc, &rei2, NO_SAVE_REI);
      free(args[0]);
      free(args[1]);
      free(args[2]);
      if (i < 0) {
        rodsLog (LOG_ERROR,
                 "rsGenQuery:acPostProcForGenQuery error,stat=%d", i);
	if (i != NO_MICROSERVICE_FOUND_ERR)
	  return i;
      }
    }
    /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/

    if (status < 0) {
       clearGenQueryOut (*genQueryOut);
       free (*genQueryOut);
       *genQueryOut = NULL;
       if (status != CAT_NO_ROWS_FOUND) {
	  rodsLog (LOG_NOTICE, 
		   "_rsGenQuery: genQuery status = %d", status);
       }
       return (status);
    }
    return (status);
} 
Beispiel #4
0
int
_rsModAVUMetadata( rsComm_t *rsComm, modAVUMetadataInp_t *modAVUMetadataInp ) {
    int status, status2;

    const char *args[MAX_NUM_OF_ARGS_IN_ACTION];
    int argc;
    ruleExecInfo_t rei2;

    memset( ( char* )&rei2, 0, sizeof( ruleExecInfo_t ) );
    rei2.rsComm = rsComm;
    if ( rsComm != NULL ) {
        rei2.uoic = &rsComm->clientUser;
        rei2.uoip = &rsComm->proxyUser;
    }

    args[0] = modAVUMetadataInp->arg0; // option add, adda, rm, rmw, rmi, cp, mod, or set
    args[1] = modAVUMetadataInp->arg1; // item type -d,-D,-c,-C,-r,-R,-u,-U
    args[2] = modAVUMetadataInp->arg2; // item name
    args[3] = modAVUMetadataInp->arg3; // attr name
    args[4] = modAVUMetadataInp->arg4; // attr val
    args[5] = modAVUMetadataInp->arg5; // attr unit
    if ( args[5] == NULL ) { args[5] = ""; }
    if ( strcmp( args[0], "mod" ) == 0 ) {
        argc = 9;
#define ARG(arg) { int ix; if( ( ix = checkModArgType(arg) ) >= 0 ) avu[ix] = arg; }
        if ( checkModArgType( modAVUMetadataInp->arg5 ) != 0 ) {
            char *avu[4] = {"", "", "", ""};
            ARG( modAVUMetadataInp->arg5 );
            ARG( modAVUMetadataInp->arg6 );
            ARG( modAVUMetadataInp->arg7 );
            args[5] = "";
            memcpy( args + 6, avu + 1, sizeof( char *[3] ) );
        }
        else {
            char *avu[4] = {"", "", "", ""};
            ARG( modAVUMetadataInp->arg6 ); /* new attr */
            ARG( modAVUMetadataInp->arg7 ); /* new val */
            ARG( modAVUMetadataInp->arg8 ); /* new unit */
            memcpy( args + 6, avu + 1, sizeof( char *[3] ) );
        }
    }
    else if ( strcmp( args[0], "cp" ) == 0 ) {
        argc = 5;
    }
    else {
        argc = 6;
    }

    status2 =  applyRuleArg( "acPreProcForModifyAVUMetadata", args, argc,
                             &rei2, NO_SAVE_REI );
    if ( status2 < 0 ) {
        if ( rei2.status < 0 ) {
            status2 = rei2.status;
        }
        rodsLog( LOG_ERROR,
                 "rsModAVUMetadata:acPreProcForModifyAVUMetadata error for %s of type %s and option %s,stat=%d",
                 modAVUMetadataInp->arg2, modAVUMetadataInp->arg1, modAVUMetadataInp->arg0, status2 );
        return status2;
    }

    if ( strcmp( modAVUMetadataInp->arg0, "add" ) == 0 ) {
        status = chlAddAVUMetadata( rsComm, 0,
                                    modAVUMetadataInp->arg1,
                                    modAVUMetadataInp->arg2,
                                    modAVUMetadataInp->arg3,
                                    modAVUMetadataInp->arg4,
                                    modAVUMetadataInp->arg5 );
    }
    else if ( strcmp( modAVUMetadataInp->arg0, "adda" ) == 0 ) {
        status = chlAddAVUMetadata( rsComm, 1,
                                    modAVUMetadataInp->arg1,
                                    modAVUMetadataInp->arg2,
                                    modAVUMetadataInp->arg3,
                                    modAVUMetadataInp->arg4,
                                    modAVUMetadataInp->arg5 );
    }
    else if ( strcmp( modAVUMetadataInp->arg0, "addw" ) == 0 ) {
        status = chlAddAVUMetadataWild( rsComm, 0,
                                        modAVUMetadataInp->arg1,
                                        modAVUMetadataInp->arg2,
                                        modAVUMetadataInp->arg3,
                                        modAVUMetadataInp->arg4,
                                        modAVUMetadataInp->arg5 );
    }
    else if ( strcmp( modAVUMetadataInp->arg0, "rmw" ) == 0 ) {
        status = chlDeleteAVUMetadata( rsComm, 1,
                                       modAVUMetadataInp->arg1,
                                       modAVUMetadataInp->arg2,
                                       modAVUMetadataInp->arg3,
                                       modAVUMetadataInp->arg4,
                                       modAVUMetadataInp->arg5,
                                       0 );
    }
    else if ( strcmp( modAVUMetadataInp->arg0, "rmi" ) == 0 ) {
        status = chlDeleteAVUMetadata( rsComm, 2,
                                       modAVUMetadataInp->arg1,
                                       modAVUMetadataInp->arg2,
                                       modAVUMetadataInp->arg3,
                                       modAVUMetadataInp->arg4,
                                       modAVUMetadataInp->arg5,
                                       0 );
    }
    else if ( strcmp( modAVUMetadataInp->arg0, "rm" ) == 0 ) {
        status = chlDeleteAVUMetadata( rsComm, 0,
                                       modAVUMetadataInp->arg1,
                                       modAVUMetadataInp->arg2,
                                       modAVUMetadataInp->arg3,
                                       modAVUMetadataInp->arg4,
                                       modAVUMetadataInp->arg5,
                                       0 );
    }
    else if ( strcmp( modAVUMetadataInp->arg0, "cp" ) == 0 ) {
        status = chlCopyAVUMetadata( rsComm,
                                     modAVUMetadataInp->arg1,
                                     modAVUMetadataInp->arg2,
                                     modAVUMetadataInp->arg3,
                                     modAVUMetadataInp->arg4 );
    }
    else if ( strcmp( modAVUMetadataInp->arg0, "mod" ) == 0 ) {
        status = chlModAVUMetadata( rsComm,
                                    modAVUMetadataInp->arg1,
                                    modAVUMetadataInp->arg2,
                                    modAVUMetadataInp->arg3,
                                    modAVUMetadataInp->arg4,
                                    modAVUMetadataInp->arg5,
                                    modAVUMetadataInp->arg6,
                                    modAVUMetadataInp->arg7,
                                    modAVUMetadataInp->arg8 );
    }
    else if ( strcmp( modAVUMetadataInp->arg0, "set" ) == 0 ) { // JMC - backport 4836
        status = chlSetAVUMetadata( rsComm,
                                    modAVUMetadataInp->arg1,
                                    modAVUMetadataInp->arg2,
                                    modAVUMetadataInp->arg3,
                                    modAVUMetadataInp->arg4,
                                    modAVUMetadataInp->arg5 );
    }
    else {
        return CAT_INVALID_ARGUMENT;
    }

    if ( status >= 0 ) {
        status2 =  applyRuleArg( "acPostProcForModifyAVUMetadata", args, argc, &rei2, NO_SAVE_REI );
        if ( status2 < 0 ) {
            if ( rei2.status < 0 ) {
                status2 = rei2.status;
            }
            rodsLog( LOG_ERROR,
                     "rsModAVUMetadata:acPostProcForModifyAVUMetadata error for %s of type %s and option %s,stat=%d",
                     modAVUMetadataInp->arg2,
                     modAVUMetadataInp->arg1,
                     modAVUMetadataInp->arg0,
                     status2 );
            return status2;
        }
    }

    return status;

}
Beispiel #5
0
int
_rsGenQuery( rsComm_t *rsComm, genQueryInp_t *genQueryInp,
             genQueryOut_t **genQueryOut ) {
    int status;

    static int ruleExecuted = 0;
    ruleExecInfo_t rei;


    static int PrePostProcForGenQueryFlag = -2;
    int i, argc;
    ruleExecInfo_t rei2;
    char *args[MAX_NUM_OF_ARGS_IN_ACTION];

    if ( PrePostProcForGenQueryFlag < 0 ) {
        if ( getenv( "PREPOSTPROCFORGENQUERYFLAG" ) != NULL ) {
            PrePostProcForGenQueryFlag = 1;
        }
        else {
            PrePostProcForGenQueryFlag = 0;
        }
    }

    memset( ( char* )&rei2, 0, sizeof( ruleExecInfo_t ) );
    rei2.rsComm = rsComm;
    if ( rsComm != NULL ) {
        rei2.uoic = &rsComm->clientUser;
        rei2.uoip = &rsComm->proxyUser;
    }

    /*  printGenQI(genQueryInp);  for debug */

    *genQueryOut = ( genQueryOut_t* )malloc( sizeof( genQueryOut_t ) );
    memset( ( char * )*genQueryOut, 0, sizeof( genQueryOut_t ) );

    if ( ruleExecuted == 0 ) {
        memset( ( char* )&rei, 0, sizeof( rei ) );
        rei.rsComm = rsComm;
        if ( rsComm != NULL ) {
            /* Include the user info for possible use by the rule.  Note
            that when this is called (as the agent is initializing),
            this user info is not confirmed yet.  For password
            authentication though, the agent will soon exit if this
            is not valid.  But tor GSI, the user information may not
            be present and/or may be changed when the authentication
            completes, so it may not be safe to use this in a GSI
            enabled environment.  This addition of user information
            was requested by ARCS/IVEC (Sean Fleming) to avoid a
            local patch.
            */
            rei.uoic = &rsComm->clientUser;
            rei.uoip = &rsComm->proxyUser;
        }

        if ( getRuleEngineStatus() == UNINITIALIZED ) {
            /* Skip the call to run acAclPolicy if the Rule Engine
               hasn't been initialized yet, which happens for a couple
               initial queries made by the agent when starting up.  The
               new RE logs these types of errors and so this avoids that.
            */
            status = -1;
        }
        else {
            status = applyRule( "acAclPolicy", NULL, &rei, NO_SAVE_REI );
        }
        if ( status == 0 ) {
            ruleExecuted = 1; /* No need to retry next time since it
                             succeeded.  Since this is called at
                             startup, the Rule Engine may not be
                             initialized yet, in which case the
                             default setting is fine and we should
                             retry next time. */
        }
    }

    // =-=-=-=-=-=-=-
    // verify that we are running a query for another agent connection
    irods::server_properties& props = irods::server_properties::getInstance();
    props.capture_if_needed();

    std::string svr_sid;
    irods::error err = props.get_property< std::string >( irods::AGENT_CONN_KW, svr_sid );
    bool agent_conn_flg = err.ok();

    // =-=-=-=-=-=-=-
    // detect if a request for disable of strict acls is made
    int acl_val = -1;
    char* dis_kw = getValByKey( &genQueryInp->condInput, DISABLE_STRICT_ACL_KW );
    if ( agent_conn_flg && dis_kw ) {
        acl_val = 0;
    }

    // =-=-=-=-=-=-=-
    // cache the old acl value for reuse later if necessary
    int old_acl_val =  chlGenQueryAccessControlSetup(
                           rsComm->clientUser.userName,
                           rsComm->clientUser.rodsZone,
                           rsComm->clientAddr,
                           rsComm->clientUser.authInfo.authFlag,
                           acl_val );

    if ( PrePostProcForGenQueryFlag == 1 ) {
        args[0] = ( char * ) malloc( 300 );
        sprintf( args[0], "%ld", ( long ) genQueryInp );
        argc = 1;
        i =  applyRuleArg( "acPreProcForGenQuery", args, argc, &rei2, NO_SAVE_REI );
        free( args[0] );
        if ( i < 0 ) {
            rodsLog( LOG_ERROR,
                     "rsGenQuery:acPreProcForGenQuery error,stat=%d", i );
            if ( i != NO_MICROSERVICE_FOUND_ERR ) {
                return i;
            }
        }
    }
    /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/

    status = chlGenQuery( *genQueryInp, *genQueryOut );

    // =-=-=-=-=-=-=-
    // if a disable was requested, repave with old value immediately
    if ( agent_conn_flg && dis_kw ) {
        chlGenQueryAccessControlSetup(
            rsComm->clientUser.userName,
            rsComm->clientUser.rodsZone,
            rsComm->clientAddr,
            rsComm->clientUser.authInfo.authFlag,
            old_acl_val );
    }

    /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/
    if ( PrePostProcForGenQueryFlag == 1 ) {
        args[0] = ( char * ) malloc( 300 );
        args[1] = ( char * ) malloc( 300 );
        args[2] = ( char * ) malloc( 300 );
        sprintf( args[0], "%ld", ( long ) genQueryInp );
        sprintf( args[1], "%ld", ( long ) *genQueryOut );
        sprintf( args[2], "%d", status );
        argc = 3;
        i =  applyRuleArg( "acPostProcForGenQuery", args, argc, &rei2, NO_SAVE_REI );
        free( args[0] );
        free( args[1] );
        free( args[2] );
        if ( i < 0 ) {
            rodsLog( LOG_ERROR,
                     "rsGenQuery:acPostProcForGenQuery error,stat=%d", i );
            if ( i != NO_MICROSERVICE_FOUND_ERR ) {
                return i;
            }
        }
    }
    /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/

    if ( status < 0 ) {
        clearGenQueryOut( *genQueryOut );
        free( *genQueryOut );
        *genQueryOut = NULL;
        if ( status != CAT_NO_ROWS_FOUND ) {
            rodsLog( LOG_NOTICE,
                     "_rsGenQuery: genQuery status = %d", status );
        }
        return status;
    }
    return status;
}
Beispiel #6
0
int
_rsModAVUMetadata (rsComm_t *rsComm, modAVUMetadataInp_t *modAVUMetadataInp )
{
    int status;

    char *args[MAX_NUM_OF_ARGS_IN_ACTION];
    int i, argc;
    ruleExecInfo_t rei2;

    memset ((char*)&rei2, 0, sizeof (ruleExecInfo_t));
    rei2.rsComm = rsComm;
    if (rsComm != NULL) {
      rei2.uoic = &rsComm->clientUser;
      rei2.uoip = &rsComm->proxyUser;
    }



    /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/
    args[0] = modAVUMetadataInp->arg0; /* option add, adda, rm, rmw, rmi, cp,
					  or mod */
    args[1] = modAVUMetadataInp->arg1; /* item type -d,-d,-c,-C,-r,-R,-u,-U */
    args[2] = modAVUMetadataInp->arg2; /* item name */
    args[3] = modAVUMetadataInp->arg3; /* attr name */
    args[4] = modAVUMetadataInp->arg4; /* attr val */
    args[5] = modAVUMetadataInp->arg5; /* attr unit */
    if (args[5]) {
    	argc = 6;
    } else {
    	argc = 5;
    }
    i =  applyRuleArg("acPreProcForModifyAVUMetadata",args,argc, &rei2, NO_SAVE_REI);
    if (i < 0) {
      if (rei2.status < 0) {
	i = rei2.status;
      }
      rodsLog (LOG_ERROR,
	       "rsModAVUMetadata:acPreProcForModifyAVUMetadata error for %s of type %s and option %s,stat=%d",
	       modAVUMetadataInp->arg2,modAVUMetadataInp->arg1,modAVUMetadataInp->arg0, i);
      return i;
    }
    /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/


    if (strcmp(modAVUMetadataInp->arg0,"add")==0) {
       status = chlAddAVUMetadata(rsComm, 0,
				  modAVUMetadataInp->arg1,
				  modAVUMetadataInp->arg2,
				  modAVUMetadataInp->arg3,
				  modAVUMetadataInp->arg4,
				  modAVUMetadataInp->arg5);
    }
    else if (strcmp(modAVUMetadataInp->arg0,"adda")==0) {
       status = chlAddAVUMetadata(rsComm, 1,
				  modAVUMetadataInp->arg1,
				  modAVUMetadataInp->arg2,
				  modAVUMetadataInp->arg3,
				  modAVUMetadataInp->arg4,
				  modAVUMetadataInp->arg5);
    }
    else if (strcmp(modAVUMetadataInp->arg0,"addw")==0) {
       status = chlAddAVUMetadataWild(rsComm, 0,
				  modAVUMetadataInp->arg1,
				  modAVUMetadataInp->arg2,
				  modAVUMetadataInp->arg3,
				  modAVUMetadataInp->arg4,
				  modAVUMetadataInp->arg5);
    }
    else if (strcmp(modAVUMetadataInp->arg0,"rmw")==0) {
       status = chlDeleteAVUMetadata(rsComm, 1,
				  modAVUMetadataInp->arg1,
				  modAVUMetadataInp->arg2,
				  modAVUMetadataInp->arg3,
				  modAVUMetadataInp->arg4,
				  modAVUMetadataInp->arg5,
				  0);
    }
    else if (strcmp(modAVUMetadataInp->arg0,"rmi")==0) {
       status = chlDeleteAVUMetadata(rsComm, 2,
				  modAVUMetadataInp->arg1,
				  modAVUMetadataInp->arg2,
				  modAVUMetadataInp->arg3,
				  modAVUMetadataInp->arg4,
				  modAVUMetadataInp->arg5,
				  0);
    }
    else if (strcmp(modAVUMetadataInp->arg0,"rm")==0) {
       status = chlDeleteAVUMetadata(rsComm, 0,
				  modAVUMetadataInp->arg1,
				  modAVUMetadataInp->arg2,
				  modAVUMetadataInp->arg3,
				  modAVUMetadataInp->arg4,
			          modAVUMetadataInp->arg5, 
				  0);
    }
    else if (strcmp(modAVUMetadataInp->arg0,"cp")==0) {
       status = chlCopyAVUMetadata(rsComm, 
				  modAVUMetadataInp->arg1,
				  modAVUMetadataInp->arg2,
				  modAVUMetadataInp->arg3,
				  modAVUMetadataInp->arg4);
    }
    else if (strcmp(modAVUMetadataInp->arg0,"mod")==0) {
       status = chlModAVUMetadata(rsComm, 
				  modAVUMetadataInp->arg1,
				  modAVUMetadataInp->arg2,
				  modAVUMetadataInp->arg3,
				  modAVUMetadataInp->arg4,
				  modAVUMetadataInp->arg5,
				  modAVUMetadataInp->arg6,
				  modAVUMetadataInp->arg7,
				  modAVUMetadataInp->arg8);
    }
    else if (strcmp(modAVUMetadataInp->arg0,"set")==0) {
       status = chlSetAVUMetadata(rsComm, 
				  modAVUMetadataInp->arg1,
				  modAVUMetadataInp->arg2,
				  modAVUMetadataInp->arg3,
				  modAVUMetadataInp->arg4,
				  modAVUMetadataInp->arg5);
    }
    else {
      return(CAT_INVALID_ARGUMENT);
    }      
    /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/
    i =  applyRuleArg("acPostProcForModifyAVUMetadata",args,argc, &rei2, NO_SAVE_REI);
    if (i < 0) {
      if (rei2.status < 0) {
        i = rei2.status;
      }
      rodsLog (LOG_ERROR,
               "rsModAVUMetadata:acPostProcForModifyAVUMetadata error for %s of type %s and option %s,stat=%d",
               modAVUMetadataInp->arg2,modAVUMetadataInp->arg1,modAVUMetadataInp->arg0, i);
      return i;
    }
    /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/

    return(status);

} 
Beispiel #7
0
int
_rsUserAdmin( rsComm_t *rsComm, userAdminInp_t *userAdminInp ) {
    int status, status2;

    const char *args[MAX_NUM_OF_ARGS_IN_ACTION];
    char errString1[] =
        "rsUserAdmin:acPreProcForModifyUser error for %s and option %s,stat=%d";
    char errString2[] =
        "rsUserAdmin:acPreProcForModifyUserGroup error for %s and option %s,stat=%d";
    char errString3[] =
        "rsUserAdmin:acPostProcForModifyUserGroup error for %s and option %s,stat=%d";

    int argc;
    ruleExecInfo_t rei2;

    memset( ( char* )&rei2, 0, sizeof( ruleExecInfo_t ) );
    rei2.rsComm = rsComm;
    if ( rsComm != NULL ) {
        rei2.uoic = &rsComm->clientUser;
        rei2.uoip = &rsComm->proxyUser;
    }

    rodsLog( LOG_DEBUG,
             "_rsUserAdmin arg0=%s",
             userAdminInp->arg0 );

    if ( strcmp( userAdminInp->arg0, "userpw" ) == 0 ) {
        args[0] = userAdminInp->arg1; /* username */
        args[1] = userAdminInp->arg2; /* option */
        args[2] = userAdminInp->arg3; /* newValue */
        argc = 3;
        status2 = applyRuleArg( "acPreProcForModifyUser",
                                args, argc, &rei2, NO_SAVE_REI );
        if ( status2 < 0 ) {
            if ( rei2.status < 0 ) {
                status2 = rei2.status;
            }
            rodsLog( LOG_ERROR,
                     userAdminInp->arg1, userAdminInp->arg2, status2 );
            return status2;
        }
        status = chlModUser( rsComm,
                             userAdminInp->arg1,
                             userAdminInp->arg2,
                             userAdminInp->arg3 );
        if ( status != 0 ) {
            chlRollback( rsComm );
        }

        status2 = applyRuleArg( "acPostProcForModifyUser", args, argc,
                                &rei2, NO_SAVE_REI );
        if ( status2 < 0 ) {
            if ( rei2.status < 0 ) {
                status2 = rei2.status;
            }
            rodsLog( LOG_ERROR, errString1,
                     userAdminInp->arg1, userAdminInp->arg2, status2 );
            return status2;
        }
        return status;
    }
    if ( strcmp( userAdminInp->arg0, "modify" ) == 0 ) {
        if ( strcmp( userAdminInp->arg1, "group" ) == 0 ) {
            args[0] = userAdminInp->arg2; /* groupname */
            args[1] = userAdminInp->arg3; /* option */
            args[2] = userAdminInp->arg4; /* username */
            args[3] = userAdminInp->arg5; /* zonename */
            argc = 4;
            status2 = applyRuleArg( "acPreProcForModifyUserGroup",
                                    args, argc, &rei2, NO_SAVE_REI );
            if ( status2 < 0 ) {
                if ( rei2.status < 0 ) {
                    status2 = rei2.status;
                }
                rodsLog( LOG_ERROR, errString2, args[0], args[1], status2 );
                return status2;
            }

            status = chlModGroup( rsComm, userAdminInp->arg2,
                                  userAdminInp->arg3, userAdminInp->arg4,
                                  userAdminInp->arg5 );
            if ( status == 0 ) {
                status2 = applyRuleArg( "acPostProcForModifyUserGroup", args, argc,
                                        &rei2, NO_SAVE_REI );
                if ( status2 < 0 ) {
                    if ( rei2.status < 0 ) {
                        status2 = rei2.status;
                    }
                    rodsLog( LOG_ERROR, errString3, args[0], args[1], status2 );
                    return status2;
                }
            }
            return status;
        }
    }
    // =-=-=-=-=-=-=-
    // JMC - backport 4772
    if ( strcmp( userAdminInp->arg0, "mkuser" ) == 0 ) {
        /* run the acCreateUser rule */
        ruleExecInfo_t rei;
        userInfo_t userInfo;
        memset( ( char* )&rei, 0, sizeof( rei ) );
        memset( ( char* )&userInfo, 0, sizeof( userInfo ) );
        rei.rsComm = rsComm;
        strncpy( userInfo.userName, userAdminInp->arg1,
                 sizeof userInfo.userName );
        strncpy( userInfo.userType, "rodsuser",
                 sizeof userInfo.userType );
        rei.uoio = &userInfo;
        rei.uoic = &rsComm->clientUser;
        rei.uoip = &rsComm->proxyUser;
        status = applyRuleArg( "acCreateUser", NULL, 0, &rei, SAVE_REI );
        if ( status != 0 ) {
            chlRollback( rsComm );
            return status;
        }
        /* And then the chlModUser function to set the initial password */
        status = chlModUser( rsComm,
                             userAdminInp->arg1,
                             "password",
                             userAdminInp->arg2 );
        if ( status != 0 ) {
            chlRollback( rsComm );
        }
        return status;
    }
    if ( strcmp( userAdminInp->arg0, "mkgroup" ) == 0 ) {
        /* run the acCreateUser rule */
        ruleExecInfo_t rei;
        userInfo_t userInfo;
        memset( ( char* )&rei, 0, sizeof( rei ) );
        rei.rsComm = rsComm;
        strncpy( userInfo.userName, userAdminInp->arg1,
                 sizeof userInfo.userName );
        strncpy( userInfo.userType, userAdminInp->arg2,
                 sizeof userInfo.userType );
        strncpy( userInfo.rodsZone, userAdminInp->arg3,
                 sizeof userInfo.rodsZone );
        strncpy( userInfo.authInfo.authStr, userAdminInp->arg4,
                 sizeof userInfo.authInfo.authStr );
        rei.uoio = &userInfo;
        rei.uoic = &rsComm->clientUser;
        rei.uoip = &rsComm->proxyUser;
        status = applyRuleArg( "acCreateUser", NULL, 0, &rei, SAVE_REI );
        if ( status != 0 ) {
            chlRollback( rsComm );
        }
        return status;
    }

    // =-=-=-=-=-=-=-
    return CAT_INVALID_ARGUMENT;
}
int
_rsGeneralAdmin(rsComm_t *rsComm, generalAdminInp_t *generalAdminInp )
{
    int status;
    userInfo_t userInfo;
    collInfo_t collInfo;
    rescInfo_t rescInfo;
    ruleExecInfo_t rei;
    char *args[MAX_NUM_OF_ARGS_IN_ACTION];
    int i, argc;
    ruleExecInfo_t rei2;

    memset ((char*)&rei2, 0, sizeof (ruleExecInfo_t));
    rei2.rsComm = rsComm;
    if (rsComm != NULL) {
      rei2.uoic = &rsComm->clientUser;
      rei2.uoip = &rsComm->proxyUser;
    }

    rodsLog (LOG_DEBUG,
	     "_rsGeneralAdmin arg0=%s", 
	     generalAdminInp->arg0);

    if (strcmp(generalAdminInp->arg0,"pvacuum")==0) {
       char *args[2];
       char argStr[100];    /* argument string */
       memset((char*)&rei,0,sizeof(rei));
       rei.rsComm = rsComm;
       rei.uoic = &rsComm->clientUser;
       rei.uoip = &rsComm->proxyUser;
       rstrcpy(argStr,"",sizeof argStr);
       if (atoi(generalAdminInp->arg1) > 0) {
	  snprintf(argStr,sizeof argStr,"<ET>%s</ET>",generalAdminInp->arg1);
       }
       if (atoi(generalAdminInp->arg2) > 0) {
	  strncat(argStr,"<EF>",100);
	  strncat(argStr,generalAdminInp->arg2,100);
	  strncat(argStr,"</EF>",100);
       }
       args[0]=argStr;
       status = applyRuleArg("acVacuum", args, 1, &rei, SAVE_REI);
       return(status);
    }

    if (strcmp(generalAdminInp->arg0,"add")==0) {
       if (strcmp(generalAdminInp->arg1,"user")==0) { 
	  /* run the acCreateUser rule */
	  char *args[2];
	  memset((char*)&rei,0,sizeof(rei));
	  rei.rsComm = rsComm;
	  strncpy(userInfo.userName, generalAdminInp->arg2, 
		  sizeof userInfo.userName);
	  strncpy(userInfo.userType, generalAdminInp->arg3, 
		  sizeof userInfo.userType);
	  strncpy(userInfo.rodsZone, generalAdminInp->arg4, 
		  sizeof userInfo.rodsZone);
	  strncpy(userInfo.authInfo.authStr, generalAdminInp->arg5, 
		  sizeof userInfo.authInfo.authStr);
	  rei.uoio = &userInfo;
	  rei.uoic = &rsComm->clientUser;
	  rei.uoip = &rsComm->proxyUser;
	  status = applyRuleArg("acCreateUser", args, 0, &rei, SAVE_REI);
	  if (status != 0) chlRollback(rsComm);
          return(status);
       }
       if (strcmp(generalAdminInp->arg1,"dir")==0) {
	  memset((char*)&collInfo,0,sizeof(collInfo));
	  strncpy(collInfo.collName, generalAdminInp->arg2, 
		  sizeof collInfo.collName);
	  if (strlen(generalAdminInp->arg3) > 0) {
	     strncpy(collInfo.collOwnerName, generalAdminInp->arg3,
		     sizeof collInfo.collOwnerName);
	     status = chlRegCollByAdmin(rsComm, &collInfo);
	     if (status == 0) {
		int status2;
		status2 = chlCommit(rsComm);
	     }
	  }
	  else {
	     status = chlRegColl(rsComm, &collInfo);
	  }
	  if (status != 0) chlRollback(rsComm);
	  return(status);
       }
       if (strcmp(generalAdminInp->arg1,"zone")==0) {
	  status = chlRegZone(rsComm, generalAdminInp->arg2,
			      generalAdminInp->arg3, 
			      generalAdminInp->arg4,
			      generalAdminInp->arg5);
	  if (status == 0) {
	     if (strcmp(generalAdminInp->arg3,"remote")==0) {
		memset((char*)&collInfo,0,sizeof(collInfo));
		strncpy(collInfo.collName, "/", sizeof collInfo.collName);
		strncat(collInfo.collName, generalAdminInp->arg2,
			sizeof collInfo.collName);
		strncpy(collInfo.collOwnerName, rsComm->proxyUser.userName,
			sizeof collInfo.collOwnerName);
		status = chlRegCollByAdmin(rsComm, &collInfo);
		if (status == 0) {
		   chlCommit(rsComm);
		}
	     }
	  }
	  return(status);
       }
       if (strcmp(generalAdminInp->arg1,"resource")==0) {
	  strncpy(rescInfo.rescName,  generalAdminInp->arg2, 
		  sizeof rescInfo.rescName);
	  strncpy(rescInfo.rescType,  generalAdminInp->arg3, 
		  sizeof rescInfo.rescType);
	  strncpy(rescInfo.rescClass, generalAdminInp->arg4, 
		  sizeof rescInfo.rescClass);
	  strncpy(rescInfo.rescLoc,   generalAdminInp->arg5, 
		  sizeof rescInfo.rescLoc);
	  strncpy(rescInfo.rescVaultPath, generalAdminInp->arg6, 
		  sizeof rescInfo.rescVaultPath);
	  strncpy(rescInfo.zoneName,  generalAdminInp->arg7, 
		  sizeof rescInfo.zoneName);
	  /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/
	  args[0] = rescInfo.rescName;
	  args[1] = rescInfo.rescType;
	  args[2] = rescInfo.rescClass;
	  args[3] = rescInfo.rescLoc;
	  args[4] = rescInfo.rescVaultPath;
	  args[5] = rescInfo.zoneName;
	  argc = 6;
	  i =  applyRuleArg("acPreProcForCreateResource", args, argc, &rei2, NO_SAVE_REI);
	  if (i < 0) {
	    if (rei2.status < 0) {
	      i = rei2.status;
	    }
	    rodsLog (LOG_ERROR,
		     "rsGeneralAdmin:acPreProcForCreateResource error for %s,stat=%d",
		     rescInfo.rescName,i);
	    return i;
	  }
	  /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/

	  status = chlRegResc(rsComm, &rescInfo);
	  if (status != 0) {
	    chlRollback(rsComm);
	    return(status);
	  }
	  
	  /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/
	  i =  applyRuleArg("acPostProcForCreateResource",args,argc, &rei2, NO_SAVE_REI);
	  if (i < 0) {
	    if (rei2.status < 0) {
	      i = rei2.status;
	    }
	    rodsLog (LOG_ERROR,
		     "rsGeneralAdmin:acPostProcForCreateResource error for %s,stat=%d",
                     rescInfo.rescName,i);
            return i;
          }
          /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/

	  return(status);
       }
       if (strcmp(generalAdminInp->arg1,"token")==0) {
	 
	  /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/
	  args[0] = generalAdminInp->arg2;
	  args[1] = generalAdminInp->arg3;
	  args[2] = generalAdminInp->arg4;
	  args[3] = generalAdminInp->arg5;
	  args[4] = generalAdminInp->arg6;
	  args[5] = generalAdminInp->arg7;
	  argc = 6;
	  i =  applyRuleArg("acPreProcForCreateToken", args, argc, &rei2, NO_SAVE_REI);
	  if (i < 0) {
	    if (rei2.status < 0) {
	      i = rei2.status;
	    }
	    rodsLog (LOG_ERROR,
		     "rsGeneralAdmin:acPreProcForCreateToken error for %s.%s=%s,stat=%d",
		     args[0],args[1],args[2],i);
	    return i;
	  }
	  /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/

	  status = chlRegToken(rsComm, generalAdminInp->arg2,
			       generalAdminInp->arg3, 
			       generalAdminInp->arg4,
			       generalAdminInp->arg5,
			       generalAdminInp->arg6,
			       generalAdminInp->arg7);
          /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/
 	  if (status == 0) {
	    i =  applyRuleArg("acPostProcForCreateToken", args, argc, &rei2, NO_SAVE_REI);
	    if (i < 0) {
	      if (rei2.status < 0) {
		i = rei2.status;
	      }
	      rodsLog (LOG_ERROR,
		       "rsGeneralAdmin:acPostProcForCreateToken error for %s.%s=%s,stat=%d",
		       args[0],args[1],args[2],i);
	      return i;
	    }
	  }
          /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/
 
	  if (status != 0) chlRollback(rsComm);
	  return(status);
       }
       if (strcmp(generalAdminInp->arg1,"specificQuery")==0) {
	  status = chlAddSpecificQuery(rsComm, generalAdminInp->arg2,
				       generalAdminInp->arg3);
	  return(status);
       }
    }
    if (strcmp(generalAdminInp->arg0,"modify")==0) {
       if (strcmp(generalAdminInp->arg1,"user")==0) {
	 /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/
	 args[0] = generalAdminInp->arg2; /* username */
	 args[1] = generalAdminInp->arg3; /* option */
#if 0
	 args[2] = generalAdminInp->arg4; /* newValue */
#else
/* Since the obfuscated password might contain commas, single or
   double quotes, etc, it's hard to escape for processing (often
   causing a seg fault), so for now just pass in a dummy string.  
   It is also unlikely the microservice actually needs the obfuscated
   password. */
	 args[2] = "obfuscatedPw";
#endif
	 argc = 3;
	 i =  applyRuleArg("acPreProcForModifyUser",args,argc, &rei2, NO_SAVE_REI);
	 if (i < 0) {
	   if (rei2.status < 0) {
	     i = rei2.status;
	   }
	   rodsLog (LOG_ERROR,
		    "rsGeneralAdmin:acPreProcForModifyUser error for %s and option %s,stat=%d",
		    args[0],args[1], i);
	   return i;
	 }
	 /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/

	  status = chlModUser(rsComm, generalAdminInp->arg2, 
			      generalAdminInp->arg3, generalAdminInp->arg4);

	  /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/
	  if (status == 0) {
 	    i =  applyRuleArg("acPostProcForModifyUser",args,argc, &rei2, NO_SAVE_REI);
	    if (i < 0) {
	      if (rei2.status < 0) {
		i = rei2.status;
	      }
	      rodsLog (LOG_ERROR,
		       "rsGeneralAdmin:acPostProcForModifyUser error for %s and option %s,stat=%d",
		       args[0],args[1], i);
	      return i;
	    }
	  }
	  /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/
	  if (status != 0) chlRollback(rsComm);
	  return(status);
       }
       if (strcmp(generalAdminInp->arg1,"group")==0) {
    	   userInfo_t ui;
    	   memset(&ui, 0, sizeof(userInfo_t));
    	   rei2.uoio = &ui;
    	   rstrcpy(ui.userName, generalAdminInp->arg4, NAME_LEN);
    	   rstrcpy(ui.rodsZone, generalAdminInp->arg5, NAME_LEN);
         /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/
         args[0] = generalAdminInp->arg2; /* groupname */
         args[1] = generalAdminInp->arg3; /* option */
         args[2] = generalAdminInp->arg4; /* username */
	 args[3] = generalAdminInp->arg5; /* zonename */
         argc = 4;
         i =  applyRuleArg("acPreProcForModifyUserGroup",args,argc, &rei2, NO_SAVE_REI);
         if (i < 0) {
           if (rei2.status < 0) {
             i = rei2.status;
           }
           rodsLog (LOG_ERROR,
                    "rsGeneralAdmin:acPreProcForModifyUserGroup error for %s and option %s,stat=%d",
                    args[0],args[1], i);
           return i;
         }
         /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/

	  status = chlModGroup(rsComm, generalAdminInp->arg2, 
			       generalAdminInp->arg3, generalAdminInp->arg4,
			       generalAdminInp->arg5);
          /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/
          if (status == 0) {
            i =  applyRuleArg("acPostProcForModifyUserGroup",args,argc, &rei2, NO_SAVE_REI);
            if (i < 0) {
              if (rei2.status < 0) {
                i = rei2.status;
              }
              rodsLog (LOG_ERROR,
                       "rsGeneralAdmin:acPostProcForModifyUserGroup error for %s and option %s,stat=%d",
                       args[0],args[1], i);
              return i;
            }
          }
          /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/

	  if (status != 0) chlRollback(rsComm);
	  return(status);
       }
       if (strcmp(generalAdminInp->arg1,"zone")==0) {
	  status = chlModZone(rsComm, generalAdminInp->arg2, 
			      generalAdminInp->arg3, generalAdminInp->arg4);
	  if (status != 0) chlRollback(rsComm);
	  if (status == 0 &&
	      strcmp(generalAdminInp->arg3, "name")==0) {
	     char oldName[MAX_NAME_LEN];
	     char newName[MAX_NAME_LEN];
	     strncpy(oldName, "/", sizeof oldName);
	     strncat(oldName, generalAdminInp->arg2, sizeof oldName);
	     strncpy(newName, generalAdminInp->arg4, sizeof newName);
	     status = chlRenameColl(rsComm, oldName, newName);
	     if (status==0) chlCommit(rsComm);
	  }
	  return(status);
       }
       if (strcmp(generalAdminInp->arg1,"zonecollacl")==0) {
	  status = chlModZoneCollAcl(rsComm, generalAdminInp->arg2, 
			      generalAdminInp->arg3, generalAdminInp->arg4);
	  return(status);
       }
       if (strcmp(generalAdminInp->arg1,"localzonename")==0) {
	  /* run the acRenameLocalZone rule */
	  char *args[2];
	  memset((char*)&rei,0,sizeof(rei));
	  rei.rsComm = rsComm;
	  memset((char*)&rei,0,sizeof(rei));
	  rei.rsComm = rsComm;
	  rei.uoic = &rsComm->clientUser;
	  rei.uoip = &rsComm->proxyUser;
	  args[0]=generalAdminInp->arg2;
	  args[1]=generalAdminInp->arg3;
	  status = applyRuleArg("acRenameLocalZone", args, 2, &rei, 
				NO_SAVE_REI);
	  return(status);
       }
       if (strcmp(generalAdminInp->arg1,"resourcedatapaths")==0) {
	  status = chlModRescDataPaths(rsComm, generalAdminInp->arg2, 
		       generalAdminInp->arg3, generalAdminInp->arg4,
		       generalAdminInp->arg5);
				       
	  return(status);
       }

       if (strcmp(generalAdminInp->arg1,"resource")==0) {
         /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/
         args[0] = generalAdminInp->arg2; /* rescname */
         args[1] = generalAdminInp->arg3; /* option */
         args[2] = generalAdminInp->arg4; /* newvalue */
         argc = 3;
         i =  applyRuleArg("acPreProcForModifyResource",args,argc, &rei2, NO_SAVE_REI);
         if (i < 0) {
           if (rei2.status < 0) {
             i = rei2.status;
           }
           rodsLog (LOG_ERROR,
                    "rsGeneralAdmin:acPreProcForModifyResource error for %s and option %s,stat=%d",
                    args[0],args[1], i);
           return i;
         }
         /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/

	  status = chlModResc(rsComm, generalAdminInp->arg2, 
			      generalAdminInp->arg3, generalAdminInp->arg4);

	  /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/
          if (status == 0) {
            i =  applyRuleArg("acPostProcForModifyResource",args,argc, &rei2, NO_SAVE_REI);
            if (i < 0) {
              if (rei2.status < 0) {
                i = rei2.status;
              }
              rodsLog (LOG_ERROR,
                       "rsGeneralAdmin:acPostProcForModifyResource error for %s and option %s,stat=%d",
                       args[0],args[1], i);
              return i;
            }
          }
          /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/

	  if (status != 0) chlRollback(rsComm);
	  return(status);
       }
       if (strcmp(generalAdminInp->arg1,"resourcegroup")==0) {
	 /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/
         args[0] = generalAdminInp->arg2; /* rescgroupname */
         args[1] = generalAdminInp->arg3; /* option */
         args[2] = generalAdminInp->arg4; /* rescname */
         argc = 3;
         i =  applyRuleArg("acPreProcForModifyResourceGroup",args,argc, &rei2, NO_SAVE_REI);
         if (i < 0) {
           if (rei2.status < 0) {
             i = rei2.status;
           }
           rodsLog (LOG_ERROR,
                    "rsGeneralAdmin:acPreProcForModifyResourceGroup error for %s and option %s,stat=%d",
                    args[0],args[1], i);
           return i;
         }
         /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/

	  status = chlModRescGroup(rsComm, generalAdminInp->arg2, 
			      generalAdminInp->arg3, generalAdminInp->arg4);

	  /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/
          if (status == 0) {
            i =  applyRuleArg("acPostProcForModifyResourceGroup",args,argc, &rei2, NO_SAVE_REI);
            if (i < 0) {
              if (rei2.status < 0) {
                i = rei2.status;
              }
              rodsLog (LOG_ERROR,
                       "rsGeneralAdmin:acPostProcForModifyResourceGroup error for %s and option %s,stat=%d",
                       args[0],args[1], i);
              return i;
            }
          }
          /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/

	  if (status != 0) chlRollback(rsComm);
	  return(status);
       }
    }
    if (strcmp(generalAdminInp->arg0,"rm")==0) {
       if (strcmp(generalAdminInp->arg1,"user")==0) { 
	  /* run the acDeleteUser rule */
	  char *args[2];
	  memset((char*)&rei,0,sizeof(rei));
	  rei.rsComm = rsComm;
	  strncpy(userInfo.userName, generalAdminInp->arg2, 
		  sizeof userInfo.userName);
	  strncpy(userInfo.rodsZone, generalAdminInp->arg3, 
		  sizeof userInfo.rodsZone);
	  rei.uoio = &userInfo;
	  rei.uoic = &rsComm->clientUser;
	  rei.uoip = &rsComm->proxyUser;
	  status = applyRuleArg("acDeleteUser", args, 0, &rei, SAVE_REI);
	  if (status != 0) chlRollback(rsComm);
          return(status);
       }
       if (strcmp(generalAdminInp->arg1,"dir")==0) {
	  memset((char*)&collInfo,0,sizeof(collInfo));
	  strncpy(collInfo.collName, generalAdminInp->arg2, 
		  sizeof collInfo.collName);
	  status = chlDelColl(rsComm, &collInfo);
	  if (status != 0) chlRollback(rsComm);
	  return(status);
       }
       if (strcmp(generalAdminInp->arg1,"resource")==0) {
	  strncpy(rescInfo.rescName,  generalAdminInp->arg2, 
		  sizeof rescInfo.rescName);

	  /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/
	  args[0] = rescInfo.rescName;
	  argc = 1;
          i =  applyRuleArg("acPreProcForDeleteResource", args, argc, &rei2, NO_SAVE_REI);
          if (i < 0) {
            if (rei2.status < 0) {
              i = rei2.status;
            }
            rodsLog (LOG_ERROR,
                     "rsGeneralAdmin:acPreProcForDeleteResource error for %s,stat=%d",
                     rescInfo.rescName,i);
            return i;
          }
          /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/

	  status = chlDelResc(rsComm, &rescInfo);
	  if (status == 0) {
	    /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/
	    i =  applyRuleArg("acPostProcForDeleteResource",args,argc, &rei2, NO_SAVE_REI);
	    if (i < 0) {
	      if (rei2.status < 0) {
		i = rei2.status;
	      }
	      rodsLog (LOG_ERROR,
		       "rsGeneralAdmin:acPostProcForDeleteResource error for %s,stat=%d",
		       rescInfo.rescName,i);
	      return i;
	    }
	  }
	  /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/

	  if (status != 0) chlRollback(rsComm);
	  return(status); 
       }
       if (strcmp(generalAdminInp->arg1,"zone")==0) {
	  status = chlDelZone(rsComm, generalAdminInp->arg2);
	  if (status == 0) {
	     memset((char*)&collInfo,0,sizeof(collInfo));
	     strncpy(collInfo.collName, "/", sizeof collInfo.collName);
	     strncat(collInfo.collName, generalAdminInp->arg2,
		     sizeof collInfo.collName);
	     status = chlDelCollByAdmin(rsComm, &collInfo);
	  }
	  if (status == 0) {
	     status = chlCommit(rsComm);
	  }
	  return(status);
       }
       if (strcmp(generalAdminInp->arg1,"token")==0) {

	 /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/
	 args[0] = generalAdminInp->arg2;
	 args[1] = generalAdminInp->arg3;
	 argc = 2;
	 i =  applyRuleArg("acPreProcForDeleteToken", args, argc, &rei2, NO_SAVE_REI);
	 if (i < 0) {
	   if (rei2.status < 0) {
	     i = rei2.status;
	   }
	   rodsLog (LOG_ERROR,
		    "rsGeneralAdmin:acPreProcForDeleteToken error for %s.%s,stat=%d",
		    args[0],args[1],i);
	   return i;
	 }
	 /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/

	  status = chlDelToken(rsComm, generalAdminInp->arg2,
			       generalAdminInp->arg3);

	  /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/
          if (status == 0) {
            i =  applyRuleArg("acPostProcForDeleteToken", args, argc, &rei2, NO_SAVE_REI);
            if (i < 0) {
              if (rei2.status < 0) {
                i = rei2.status;
              }
              rodsLog (LOG_ERROR,
                       "rsGeneralAdmin:acPostProcForDeleteToken error for %s.%s,stat=%d",
                       args[0],args[1],i);
              return i;
            }
          }
          /** RAJA ADDED June 1 2009 for pre-post processing rule hooks **/

	  if (status != 0) chlRollback(rsComm);
	  return(status);
       }
       if (strcmp(generalAdminInp->arg1,"unusedAVUs")==0) {
	  status = chlDelUnusedAVUs(rsComm);
	  return(status);
       }
       if (strcmp(generalAdminInp->arg1,"specificQuery")==0) {
	  status = chlDelSpecificQuery(rsComm, generalAdminInp->arg2);
	  return(status);
       }
    }
    if (strcmp(generalAdminInp->arg0,"calculate-usage")==0) {
       status = chlCalcUsageAndQuota(rsComm);
       return(status);
    }
    if (strcmp(generalAdminInp->arg0,"set-quota")==0) {
       status = chlSetQuota(rsComm,
			    generalAdminInp->arg1, 
			    generalAdminInp->arg2, 
			    generalAdminInp->arg3, 
			    generalAdminInp->arg4);

       return(status);
    }
    return(CAT_INVALID_ARGUMENT);
}