int doTest2() { genQueryInp_t genQueryInp; genQueryOut_t genQueryOut; int status; rodsLogSqlReq( 1 ); memset( ( char* )&genQueryInp, 0, sizeof( genQueryInp ) ); addInxIval( &genQueryInp.selectInp, COL_R_RESC_ID, 1 ); addInxIval( &genQueryInp.selectInp, COL_R_RESC_NAME, 1 ); addInxIval( &genQueryInp.selectInp, COL_R_ZONE_NAME, 1 ); addInxIval( &genQueryInp.selectInp, COL_R_TYPE_NAME, 1 ); addInxIval( &genQueryInp.selectInp, COL_R_CLASS_NAME, 1 ); addInxIval( &genQueryInp.selectInp, COL_R_LOC, 1 ); addInxIval( &genQueryInp.selectInp, COL_R_VAULT_PATH, 1 ); addInxIval( &genQueryInp.selectInp, COL_R_FREE_SPACE, 1 ); addInxIval( &genQueryInp.selectInp, COL_R_RESC_INFO, 1 ); addInxIval( &genQueryInp.selectInp, COL_R_RESC_COMMENT, 1 ); addInxIval( &genQueryInp.selectInp, COL_R_CREATE_TIME, 1 ); addInxIval( &genQueryInp.selectInp, COL_R_MODIFY_TIME, 1 ); status = chlGenQuery( genQueryInp, &genQueryOut ); printf( "chlGenQuery status=%d\n", status ); return status; }
/* Now that only extension tables are allowed, I added this test so the the columns could be referenced by number. This makes it easier to test various extension table columns, which may conditionally defined. For example, with the example2 extension tables, this works: bin/test_genu 5 10003 'B' 10001 'archive' 10002 'test' With example1, using the string values of UPDATE_NEXT_SEQ_VALUE and UPDATE_NOW_TIME, this works: bin/test_genu 5 10001 gq_next_sequence_value_core 10002 n1 10003 update_now_time */ int doTest5(char *arg1, char *arg2, char *arg3, char *arg4, char *arg5, char *arg6) { generalUpdateInp_t generalUpdateInp; int status; printf("dotest2\n"); rodsLogSqlReq(1); memset (&generalUpdateInp, 0, sizeof (generalUpdateInp)); addInxVal (&generalUpdateInp.values, atoi(arg1), arg2); if (arg3 !=0 && *arg3 !='\0' && arg4 !=0 && *arg4 !='\0' ) { addInxVal (&generalUpdateInp.values, atoi(arg3), arg4); } if (arg5 !=0 && *arg5 !='\0' && arg6 !=0 && *arg6 !='\0' ) { addInxVal (&generalUpdateInp.values, atoi(arg5), arg6); } generalUpdateInp.type = GENERAL_UPDATE_INSERT; status = chlGeneralUpdate(generalUpdateInp); printf("chlGenUpdate status=%d\n",status); return(status); }
int doTest3(char *arg1, char *arg2, char *arg3, char *arg4) { generalUpdateInp_t generalUpdateInp; int status; printf("dotest3\n"); rodsLogSqlReq(1); memset (&generalUpdateInp, 0, sizeof (generalUpdateInp)); addInxVal (&generalUpdateInp.values, COL_RULE_ID, UPDATE_NEXT_SEQ_VALUE); addInxVal (&generalUpdateInp.values, COL_RULE_NAME, arg1); addInxVal (&generalUpdateInp.values, COL_RULE_BASE_NAME, arg2); addInxVal (&generalUpdateInp.values, COL_RULE_BODY, arg3); addInxVal (&generalUpdateInp.values, COL_RULE_EVENT, "e"); addInxVal (&generalUpdateInp.values, COL_RULE_RECOVERY, "r"); addInxVal (&generalUpdateInp.values, COL_RULE_OWNER_NAME, "on"); addInxVal (&generalUpdateInp.values, COL_RULE_OWNER_ZONE, "oz"); addInxVal (&generalUpdateInp.values, COL_RULE_CREATE_TIME, UPDATE_NOW_TIME); addInxVal (&generalUpdateInp.values, COL_RULE_MODIFY_TIME, UPDATE_NOW_TIME); generalUpdateInp.type = GENERAL_UPDATE_INSERT; status = chlGeneralUpdate(generalUpdateInp); printf("chlGenUpdate status=%d\n",status); return(status); }
int doTest6( char *testString ) { genQueryInp_t genQueryInp; genQueryOut_t genQueryOut; char condStr1[MAX_NAME_LEN]; char condStr2[MAX_NAME_LEN]; int status; printf( "dotest6\n" ); rodsLogSqlReq( 1 ); memset( &genQueryInp, 0, sizeof( genQueryInp ) ); addInxIval( &genQueryInp.selectInp, COL_TOKEN_NAME, 1 ); snprintf( condStr1, MAX_NAME_LEN, "= 'data_type'" ); addInxVal( &genQueryInp.sqlCondInp, COL_TOKEN_NAMESPACE, condStr1 ); /* snprintf (condStr2, MAX_NAME_LEN, "like '%s|%s|%s'", "%", testString,"%"); */ snprintf( condStr2, MAX_NAME_LEN, "like '%s%s%s'", "%", testString, "%" ); addInxVal( &genQueryInp.sqlCondInp, COL_TOKEN_VALUE2, condStr2 ); genQueryInp.maxRows = 1; status = chlGenQuery( genQueryInp, &genQueryOut ); printf( "chlGenQuery status=%d\n", status ); if ( status == 0 ) { printGenQOut( &genQueryOut ); } return status; }
int doTest4() { genQueryInp_t genQueryInp; genQueryOut_t genQueryOut; char condStr[MAX_NAME_LEN]; int status; printf( "dotest4\n" ); rodsLogSqlReq( 1 ); memset( &genQueryInp, 0, sizeof( genQueryInp ) ); addInxIval( &genQueryInp.selectInp, COL_RESC_GROUP_RESC_ID, 1 ); addInxIval( &genQueryInp.selectInp, COL_R_RESC_NAME, 1 ); /* compound condition test: */ snprintf( condStr, MAX_NAME_LEN, "like 'abc'" ); addInxVal( &genQueryInp.sqlCondInp, COL_RESC_GROUP_NAME, condStr ); genQueryInp.maxRows = 2; status = chlGenQuery( genQueryInp, &genQueryOut ); printf( "chlGenQuery status=%d\n", status ); if ( status == 0 ) { printGenQOut( &genQueryOut ); } return status; }
int doTest13( char *userName, char *rodsZone, char *accessPerm, char *collection, char *fileName ) { genQueryInp_t genQueryInp; genQueryOut_t genQueryOut; char condStr[MAX_NAME_LEN]; char condStr2[MAX_NAME_LEN]; int status; char accStr[LONG_NAME_LEN]; printf( "dotest13\n" ); rodsLogSqlReq( 1 ); memset( &genQueryInp, 0, sizeof( genQueryInp ) ); //doAccessControlToQuery snprintf( accStr, LONG_NAME_LEN, "%s", userName ); addKeyVal( &genQueryInp.condInput, USER_NAME_CLIENT_KW, accStr ); snprintf( accStr, LONG_NAME_LEN, "%s", rodsZone ); addKeyVal( &genQueryInp.condInput, RODS_ZONE_CLIENT_KW, accStr ); snprintf( accStr, LONG_NAME_LEN, "%s", accessPerm ); addKeyVal( &genQueryInp.condInput, ACCESS_PERMISSION_KW, accStr ); snprintf( condStr, MAX_NAME_LEN, "='%s'", collection ); addInxVal( &genQueryInp.sqlCondInp, COL_COLL_NAME, condStr ); snprintf( condStr, MAX_NAME_LEN, "='%s'", fileName ); addInxVal( &genQueryInp.sqlCondInp, COL_DATA_NAME, condStr ); addInxIval( &genQueryInp.selectInp, COL_D_DATA_ID, 1 ); snprintf( condStr2, LONG_NAME_LEN, "='%s'", userName ); addInxVal( &genQueryInp.sqlCondInp, COL_DATA_USER_NAME, condStr2 ); snprintf( condStr2, LONG_NAME_LEN, "='%s'", rodsZone ); addInxVal( &genQueryInp.sqlCondInp, COL_DATA_USER_ZONE, condStr2 ); addInxIval( &genQueryInp.selectInp, COL_DATA_ACCESS_NAME, ORDER_BY ); genQueryInp.maxRows = 10; /* status = rsGenQuery (rsComm, &genQueryInp, &genQueryOut); */ status = chlGenQuery( genQueryInp, &genQueryOut ); printf( "chlGenQuery status=%d\n", status ); printf( "genQueryOut->totalRowCount=%d\n", genQueryOut.totalRowCount ); if ( status == 0 ) { printGenQOut( &genQueryOut ); } return 0; }
/* similar to ls2 but will do it repeatedly */ int doLs3( int repCount ) { rodsLogSqlReq( 0 ); /* less verbosity */ for ( int i = 0; i < repCount; i++ ) { int status = doLs3a(); if ( status ) { return status; } } return 0; }
int doTest8( char *testString, char *testString2, char *testString3 ) { genQueryInp_t genQueryInp; genQueryOut_t genQueryOut; /* char condStr1[MAX_NAME_LEN]; */ char condStr2[MAX_NAME_LEN]; int status, status2; printf( "dotest8\n" ); rodsLogSqlReq( 1 ); memset( &genQueryInp, 0, sizeof( genQueryInp ) ); /* for : test_genq gen8 / 0 10 (should find 1) or : test_genq gen8 /tempZone 0 10 (should find 2) or : test_genq gen8 abc 0 10 (should find 0) */ addInxIval( &genQueryInp.selectInp, COL_COLL_NAME, 1 ); snprintf( condStr2, MAX_NAME_LEN, "begin_of '%s'", testString ); addInxVal( &genQueryInp.sqlCondInp, COL_COLL_NAME, condStr2 ); genQueryInp.options = RETURN_TOTAL_ROW_COUNT; genQueryInp.maxRows = 5; if ( testString3 != NULL && *testString3 != '\0' ) { genQueryInp.maxRows = atoi( testString3 ); } if ( testString2 != NULL && *testString2 != '\0' ) { genQueryInp.rowOffset = atoi( testString2 ); } status = chlGenQuery( genQueryInp, &genQueryOut ); printf( "chlGenQuery status=%d\n", status ); printf( "genQueryOut->totalRowCount=%d\n", genQueryOut.totalRowCount ); if ( status == 0 ) { printGenQOut( &genQueryOut ); } if ( genQueryOut.continueInx > 0 ) { genQueryInp.continueInx = genQueryOut.continueInx; printf( "Second call to chlGenQuery\n" ); status2 = chlGenQuery( genQueryInp, &genQueryOut ); printf( "chlGenQuery status=%d\n", status2 ); if ( status2 == 0 ) { printGenQOut( &genQueryOut ); } } return status; }
int doTest2(char *arg1, char *arg2, char *arg3, char *arg4) { generalUpdateInp_t generalUpdateInp; int status; printf("dotest2\n"); rodsLogSqlReq(1); memset (&generalUpdateInp, 0, sizeof (generalUpdateInp)); addInxVal (&generalUpdateInp.values, COL_TOKEN_NAMESPACE, arg1); addInxVal (&generalUpdateInp.values, COL_TOKEN_ID, arg2); addInxVal (&generalUpdateInp.values, COL_TOKEN_NAME, arg3); generalUpdateInp.type = GENERAL_UPDATE_DELETE; status = chlGeneralUpdate(generalUpdateInp); printf("chlGenUpdate status=%d\n",status); return(status); }
/* Based on doTest7, but tests AUTO_CLOSE */ int doTest15( char *testString, char *testString2, char *testString3 ) { genQueryInp_t genQueryInp; genQueryOut_t genQueryOut; char condStr1[MAX_NAME_LEN]; char condStr2[MAX_NAME_LEN]; int status; printf( "dotest15\n" ); rodsLogSqlReq( 1 ); memset( &genQueryInp, 0, sizeof( genQueryInp ) ); addInxIval( &genQueryInp.selectInp, COL_TOKEN_NAME, 1 ); snprintf( condStr1, MAX_NAME_LEN, "= 'data_type'" ); addInxVal( &genQueryInp.sqlCondInp, COL_TOKEN_NAMESPACE, condStr1 ); snprintf( condStr2, MAX_NAME_LEN, "like '%s%s%s'", "%", testString, "%" ); addInxVal( &genQueryInp.sqlCondInp, COL_TOKEN_VALUE2, condStr2 ); genQueryInp.options = AUTO_CLOSE; genQueryInp.maxRows = 1; if ( testString3 != NULL && *testString3 != '\0' ) { genQueryInp.maxRows = atoi( testString3 ); } if ( testString2 != NULL && *testString2 != '\0' ) { genQueryInp.rowOffset = atoi( testString2 ); } status = chlGenQuery( genQueryInp, &genQueryOut ); printf( "chlGenQuery status=%d\n", status ); if ( status == 0 ) { printGenQOut( &genQueryOut ); } return status; }
int doTest5() { genQueryInp_t genQueryInp; genQueryOut_t genQueryOut; char condStr[MAX_NAME_LEN]; int status; printf( "dotest5\n" ); rodsLogSqlReq( 1 ); memset( &genQueryInp, 0, sizeof( genQueryInp ) ); addInxIval( &genQueryInp.selectInp, COL_RULE_EXEC_ID, 1 ); addInxIval( &genQueryInp.selectInp, COL_RULE_EXEC_NAME, 1 ); addInxIval( &genQueryInp.selectInp, COL_RULE_EXEC_REI_FILE_PATH, 1 ); addInxIval( &genQueryInp.selectInp, COL_RULE_EXEC_USER_NAME, 1 ); addInxIval( &genQueryInp.selectInp, COL_RULE_EXEC_ADDRESS, 1 ); addInxIval( &genQueryInp.selectInp, COL_RULE_EXEC_TIME, 1 ); addInxIval( &genQueryInp.selectInp, COL_RULE_EXEC_FREQUENCY, 1 ); addInxIval( &genQueryInp.selectInp, COL_RULE_EXEC_PRIORITY, 1 ); addInxIval( &genQueryInp.selectInp, COL_RULE_EXEC_ESTIMATED_EXE_TIME, 1 ); addInxIval( &genQueryInp.selectInp, COL_RULE_EXEC_NOTIFICATION_ADDR, 1 ); /* compound condition test: */ snprintf( condStr, MAX_NAME_LEN, "= 'Wayne'" ); addInxVal( &genQueryInp.sqlCondInp, COL_RULE_EXEC_USER_NAME, condStr ); genQueryInp.maxRows = 2; status = chlGenQuery( genQueryInp, &genQueryOut ); printf( "chlGenQuery status=%d\n", status ); if ( status == 0 ) { printGenQOut( &genQueryOut ); } return status; }
/* #define SERVER_DEBUG 1 */ int main(int argc, char *argv[]) { int status; rsComm_t rsComm; char *tmpStr; ProcessType = AGENT_PT; #ifdef RUN_SERVER_AS_ROOT #ifndef windows_platform if (initServiceUser() < 0) { exit (1); } #endif #endif #ifdef windows_platform iRODSNtAgentInit(argc, argv); #endif #ifndef windows_platform signal(SIGINT, signalExit); signal(SIGHUP, signalExit); signal(SIGTERM, signalExit); /* set to SIG_DFL as recommended by andy.salnikov so that system() * call returns real values instead of 1 */ signal(SIGCHLD, SIG_DFL); signal(SIGUSR1, signalExit); signal(SIGPIPE, rsPipSigalHandler); #endif #ifndef windows_platform #ifdef SERVER_DEBUG if (isPath ("/tmp/rodsdebug")) sleep (20); #endif #endif #ifdef SYS_TIMING rodsLogLevel(LOG_NOTICE); printSysTiming ("irodsAgent", "exec", 1); #endif memset (&rsComm, 0, sizeof (rsComm)); status = initRsCommWithStartupPack (&rsComm, NULL); if (status < 0) { sendVersion (rsComm.sock, status, 0, NULL, 0); cleanupAndExit (status); } /* Handle option to log sql commands */ tmpStr = getenv (SP_LOG_SQL); if (tmpStr != NULL) { #ifdef IRODS_SYSLOG int j = atoi(tmpStr); rodsLogSqlReq(j); #else rodsLogSqlReq(1); #endif } /* Set the logging level */ tmpStr = getenv (SP_LOG_LEVEL); if (tmpStr != NULL) { int i; i = atoi(tmpStr); rodsLogLevel(i); } else { rodsLogLevel(LOG_NOTICE); /* default */ } #ifdef IRODS_SYSLOG /* Open a connection to syslog */ #ifdef SYSLOG_FACILITY_CODE openlog("rodsAgent",LOG_ODELAY|LOG_PID,SYSLOG_FACILITY_CODE); #else openlog("rodsAgent",LOG_ODELAY|LOG_PID,LOG_DAEMON); #endif #endif status = getRodsEnv (&rsComm.myEnv); if (status < 0) { sendVersion (rsComm.sock, SYS_AGENT_INIT_ERR, 0, NULL, 0); cleanupAndExit (status); } #if RODS_CAT if (strstr(rsComm.myEnv.rodsDebug, "CAT") != NULL) { chlDebug(rsComm.myEnv.rodsDebug); } #endif #ifdef RULE_ENGINE_N status = initAgent (RULE_ENGINE_TRY_CACHE, &rsComm); #else status = initAgent (&rsComm); #endif #ifdef SYS_TIMING printSysTiming ("irodsAgent", "initAgent", 0); #endif if (status < 0) { sendVersion (rsComm.sock, SYS_AGENT_INIT_ERR, 0, NULL, 0); cleanupAndExit (status); } /* move configConnectControl behind initAgent for now. need zoneName if * the user does not specify one in the input */ initConnectControl (); if (rsComm.clientUser.userName[0] != '\0') { status = chkAllowedUser (rsComm.clientUser.userName, rsComm.clientUser.rodsZone); if (status < 0) { sendVersion (rsComm.sock, status, 0, NULL, 0); cleanupAndExit (status); } } /* send the server version and atatus as part of the protocol. Put * rsComm.reconnPort as the status */ status = sendVersion (rsComm.sock, status, rsComm.reconnPort, rsComm.reconnAddr, rsComm.cookie); if (status < 0) { sendVersion (rsComm.sock, SYS_AGENT_INIT_ERR, 0, NULL, 0); cleanupAndExit (status); } #ifdef SYS_TIMING printSysTiming ("irodsAgent", "sendVersion", 0); #endif logAgentProc (&rsComm); status = agentMain (&rsComm); cleanupAndExit (status); return (status); }
int main( int argc, char **argv ) { int i1 = 0, i2 = 0, i3 = 0, i = 0; genQueryInp_t genQueryInp; int i1a[10]; int i2a[10]; int done = 0; int mode = 0; char *condVal[2]; char v1[20]; /* remove this call or change to LOG_NOTICE for more verbosity */ rodsLogLevel( LOG_ERROR ); /* this will cause the sql to be printed, comment this out to skip it */ rodsLogSqlReq( 1 ); i1 = 7; i2 = 5; done = 0; mode = 0; if ( argc >= 2 ) { if ( strcmp( argv[1], "gen" ) == 0 ) { mode = 1; } if ( strcmp( argv[1], "ls" ) == 0 ) { mode = 2; } if ( strcmp( argv[1], "gen2" ) == 0 ) { mode = 3; } if ( strcmp( argv[1], "gen3" ) == 0 ) { mode = 4; } if ( strcmp( argv[1], "gen4" ) == 0 ) { mode = 5; } if ( strcmp( argv[1], "gen5" ) == 0 ) { mode = 6; } if ( strcmp( argv[1], "gen6" ) == 0 ) { mode = 7; } if ( strcmp( argv[1], "gen7" ) == 0 ) { mode = 8; } if ( strcmp( argv[1], "gen8" ) == 0 ) { mode = 9; } if ( strcmp( argv[1], "gen9" ) == 0 ) { mode = 10; } if ( strcmp( argv[1], "gen10" ) == 0 ) { mode = 11; } if ( strcmp( argv[1], "gen11" ) == 0 ) { mode = 12; } if ( strcmp( argv[1], "gen12" ) == 0 ) { mode = 13; } if ( strcmp( argv[1], "gen13" ) == 0 ) { mode = 14; } if ( strcmp( argv[1], "lsr" ) == 0 ) { mode = 15; } if ( strcmp( argv[1], "gen15" ) == 0 ) { mode = 16; } } if ( argc == 3 && mode == 0 ) { i1 = atoi( argv[1] ); i2 = atoi( argv[2] ); sTest( i1, i2 ); done++; } if ( argc == 4 && mode == 0 ) { i1 = atoi( argv[1] ); i2 = atoi( argv[2] ); i3 = atoi( argv[3] ); sTest2( i1, i2, i3 ); done++; } if ( argc == 2 && mode == 0 ) { int j; j = atoi( argv[1] ); if ( j >= 0 ) { printf( "finding cycles starting with table %d\n", j ); i = findCycles( j ); printf( "status = %d\n", i ); } else { printf( "finding cycles for all tables\n" ); printf( "last test should be -816000 if last table finished\n" ); i = 0; for ( j = 0; i == 0; j++ ) { i = findCycles( j ); printf( "starting with table %d status = %d\n", j, i ); } if ( j > 70 && i == CAT_INVALID_ARGUMENT ) { printf( "Success: Searched all tables (0 to %d) and no cycles found\n", j - 1 ); exit( 0 ); } else { exit( 5 ); } } done++; } memset( ( char* )&genQueryInp, 0, sizeof( genQueryInp ) ); genQueryInp.maxRows = 10; genQueryInp.continueInx = 0; /* (another test case that could be used) i1a[0]=COL_R_RESC_NAME; i1a[1]=COL_R_ZONE_NAME; i1a[2]=COL_R_TYPE_NAME; i1a[3]=COL_R_CLASS_NAME; */ /* i1a[0]=COL_COLL_INHERITANCE; */ i1a[0] = COL_COLL_NAME; genQueryInp.selectInp.inx = i1a; genQueryInp.selectInp.len = 1; i2a[0] = COL_D_DATA_PATH; genQueryInp.sqlCondInp.inx = i2a; strcpy( v1, "='b'" ); condVal[0] = v1; genQueryInp.sqlCondInp.value = condVal; genQueryInp.sqlCondInp.len = 1; if ( mode == 1 ) { if ( argc == 3 ) { i1a[0] = atoi( argv[2] ); } } if ( done == 0 ) { int status; genQueryOut_t result; rodsEnv myEnv; memset( ( char * )&result, 0, sizeof( result ) ); memset( ( char * )&myEnv, 0, sizeof( myEnv ) ); status = getRodsEnv( &myEnv ); if ( status < 0 ) { rodsLog( LOG_ERROR, "main: getRodsEnv error. status = %d", status ); exit( 1 ); } // capture server properties irods::server_properties::getInstance().capture(); if ( ( status = chlOpen() ) != 0 ) { rodsLog( LOG_SYS_FATAL, "chlopen Error. Status = %d", status ); return status; } /* This is no longer ifdef'ed GEN_QUERY_AC (since msiAclPolicy now used), so just do it. */ chlGenQueryAccessControlSetup( myEnv.rodsUserName, myEnv.rodsZone, "", LOCAL_PRIV_USER_AUTH, 1 ); if ( strstr( myEnv.rodsDebug, "CAT" ) != NULL ) { chlDebug( myEnv.rodsDebug ); } if ( mode == 2 ) { /* doLs(); */ doLs2(); exit( 0 ); } if ( mode == 3 ) { doTest2(); exit( 0 ); } if ( mode == 4 ) { doTest3(); exit( 0 ); } if ( mode == 5 ) { doTest4(); exit( 0 ); } if ( mode == 6 ) { doTest5(); exit( 0 ); } if ( mode == 7 ) { doTest6( argv[2] ); exit( 0 ); } if ( mode == 8 ) { status = doTest7( argv[2], argv[3], argv[4], argv[5] ); if ( status < 0 ) { exit( 1 ); } exit( 0 ); } if ( mode == 9 ) { status = doTest8( argv[2], argv[3], argv[4] ); if ( status < 0 ) { exit( 2 ); } exit( 0 ); } if ( mode == 10 ) { status = doTest9( argv[2], argv[3] ); if ( status < 0 ) { exit( 2 ); } exit( 0 ); } if ( mode == 11 ) { status = doTest10( argv[2], argv[3], argv[4], argv[5] ); if ( status < 0 ) { exit( 2 ); } exit( 0 ); } if ( mode == 12 ) { status = doTest11( argv[2], argv[3], argv[4], argv[5], argv[6] ); if ( status < 0 ) { exit( 2 ); } exit( 0 ); } if ( mode == 13 ) { status = doTest12( argv[2], argv[3], argv[4], argv[5] ); if ( status < 0 ) { exit( 2 ); } exit( 0 ); } if ( mode == 14 ) { status = doTest13( argv[2], argv[3], argv[4], argv[5], argv[6] ); if ( status < 0 ) { exit( 2 ); } exit( 0 ); } if ( mode == 15 ) { try { int reps = boost::lexical_cast<int>( argv[2] ); reps = reps > 0 && reps <= std::numeric_limits<int>::max() ? reps : 0; status = doLs3( reps ); } catch ( boost::bad_lexical_cast e ) { exit( 2 ); } if ( status < 0 ) { exit( 2 ); } exit( 0 ); } if ( mode == 16 ) { status = doTest15( argv[2], argv[3], argv[4] ); if ( status < 0 ) { exit( 2 ); } exit( 0 ); } genQueryInp.maxRows = 2; i = chlGenQuery( genQueryInp, &result ); printf( "chlGenQuery status=%d\n", i ); printf( "result.rowCnt=%d\n", result.rowCnt ); if ( result.rowCnt > 0 ) { int i; for ( i = 0; i < result.rowCnt; i++ ) { printf( "result.SqlResult[%d].value=%s\n", i, result.sqlResult[i].value ); } } } exit( 0 ); }
/* #define SERVER_DEBUG 1 */ int main( int, char ** ) { int status; rsComm_t rsComm; char *tmpStr; ProcessType = AGENT_PT; // capture server properties irods::server_properties& props = irods::server_properties::getInstance(); irods::error result = props.capture_if_needed(); if ( !result.ok() ) { irods::log( PASSMSG( "failed to read server configuration", result ) ); } #ifdef windows_platform iRODSNtAgentInit( argc, argv ); #endif #ifndef windows_platform signal( SIGINT, signalExit ); signal( SIGHUP, signalExit ); signal( SIGTERM, signalExit ); /* set to SIG_DFL as recommended by andy.salnikov so that system() * call returns real values instead of 1 */ signal( SIGCHLD, SIG_DFL ); signal( SIGUSR1, signalExit ); signal( SIGPIPE, SIG_IGN ); // register irods signal handlers register_handlers(); #endif #ifndef windows_platform #ifdef SERVER_DEBUG if ( isPath( "/tmp/rodsdebug" ) ) { sleep( 20 ); } #endif #endif memset( &rsComm, 0, sizeof( rsComm ) ); rsComm.thread_ctx = ( thread_context* )malloc( sizeof( thread_context ) ); status = initRsCommWithStartupPack( &rsComm, NULL ); // =-=-=-=-=-=-=- // manufacture a network object for comms irods::network_object_ptr net_obj; irods::error ret = irods::network_factory( &rsComm, net_obj ); if ( !ret.ok() ) { irods::log( PASS( ret ) ); } if ( status < 0 ) { sendVersion( net_obj, status, 0, NULL, 0 ); cleanupAndExit( status ); } /* Handle option to log sql commands */ tmpStr = getenv( SP_LOG_SQL ); if ( tmpStr != NULL ) { #ifdef SYSLOG int j = atoi( tmpStr ); rodsLogSqlReq( j ); #else rodsLogSqlReq( 1 ); #endif } /* Set the logging level */ tmpStr = getenv( SP_LOG_LEVEL ); if ( tmpStr != NULL ) { int i; i = atoi( tmpStr ); rodsLogLevel( i ); } else { rodsLogLevel( LOG_NOTICE ); /* default */ } #ifdef SYSLOG /* Open a connection to syslog */ openlog( "rodsAgent", LOG_ODELAY | LOG_PID, LOG_DAEMON ); #endif status = getRodsEnv( &rsComm.myEnv ); if ( status < 0 ) { rodsLog( LOG_ERROR, "agentMain :: getRodsEnv failed" ); sendVersion( net_obj, SYS_AGENT_INIT_ERR, 0, NULL, 0 ); cleanupAndExit( status ); } ret = setRECacheSaltFromEnv(); if ( !ret.ok() ) { rodsLog( LOG_ERROR, "rodsAgent::main: Failed to set RE cache mutex name\n%s", ret.result().c_str() ); exit( 1 ); } // =-=-=-=-=-=-=- // load server side pluggable api entries irods::api_entry_table& RsApiTable = irods::get_server_api_table(); irods::pack_entry_table& ApiPackTable = irods::get_pack_table(); ret = irods::init_api_table( RsApiTable, ApiPackTable, false ); if ( !ret.ok() ) { irods::log( PASS( ret ) ); return 1; } // =-=-=-=-=-=-=- // load client side pluggable api entries irods::api_entry_table& RcApiTable = irods::get_client_api_table(); ret = irods::init_api_table( RcApiTable, ApiPackTable, true ); if ( !ret.ok() ) { irods::log( PASS( ret ) ); return 1; } #if RODS_CAT if ( strstr( rsComm.myEnv.rodsDebug, "CAT" ) != NULL ) { chlDebug( rsComm.myEnv.rodsDebug ); } #endif status = initAgent( RULE_ENGINE_TRY_CACHE, &rsComm ); if ( status < 0 ) { rodsLog( LOG_ERROR, "agentMain :: initAgent failed: %d", status ); sendVersion( net_obj, SYS_AGENT_INIT_ERR, 0, NULL, 0 ); cleanupAndExit( status ); } /* move configConnectControl behind initAgent for now. need zoneName if * the user does not specify one in the input */ initConnectControl(); if ( rsComm.clientUser.userName[0] != '\0' ) { status = chkAllowedUser( rsComm.clientUser.userName, rsComm.clientUser.rodsZone ); if ( status < 0 ) { sendVersion( net_obj, status, 0, NULL, 0 ); cleanupAndExit( status ); } } // =-=-=-=-=-=-=- // handle negotiations with the client regarding TLS if requested // this scope block makes valgrind happy { std::string neg_results; ret = irods::client_server_negotiation_for_server( net_obj, neg_results ); if ( !ret.ok() || neg_results == irods::CS_NEG_FAILURE ) { irods::log( PASS( ret ) ); // =-=-=-=-=-=-=- // send a 'we failed to negotiate' message here?? // or use the error stack rule engine thingie irods::log( PASS( ret ) ); sendVersion( net_obj, SYS_AGENT_INIT_ERR, 0, NULL, 0 ); cleanupAndExit( ret.code() ); } else { // =-=-=-=-=-=-=- // copy negotiation results to comm for action by network objects snprintf( rsComm.negotiation_results, sizeof( rsComm.negotiation_results ), "%s", neg_results.c_str() ); //rsComm.ssl_do_accept = 1; } } /* send the server version and atatus as part of the protocol. Put * rsComm.reconnPort as the status */ ret = sendVersion( net_obj, status, rsComm.reconnPort, rsComm.reconnAddr, rsComm.cookie ); if ( !ret.ok() ) { irods::log( PASS( ret ) ); sendVersion( net_obj, SYS_AGENT_INIT_ERR, 0, NULL, 0 ); cleanupAndExit( status ); } logAgentProc( &rsComm ); // call initialization for network plugin as negotiated irods::network_object_ptr new_net_obj; ret = irods::network_factory( &rsComm, new_net_obj ); if ( !ret.ok() ) { return ret.code(); } ret = sockAgentStart( new_net_obj ); if ( !ret.ok() ) { irods::log( PASS( ret ) ); return ret.code(); } new_net_obj->to_server( &rsComm ); status = agentMain( &rsComm ); // call initialization for network plugin as negotiated ret = sockAgentStop( new_net_obj ); if ( !ret.ok() ) { irods::log( PASS( ret ) ); return ret.code(); } new_net_obj->to_server( &rsComm ); cleanup(); free( rsComm.thread_ctx ); free( rsComm.auth_scheme ); rodsLog( LOG_NOTICE, "Agent exiting with status = %d", status ); return status; }
int doTest9( char *testString, char *testString2 ) { genQueryInp_t genQueryInp; genQueryOut_t genQueryOut; char condStr1[MAX_NAME_LEN]; int status, status2; int type; printf( "dotest9\n" ); rodsLogSqlReq( 1 ); memset( &genQueryInp, 0, sizeof( genQueryInp ) ); type = 0; if ( testString2 != NULL ) { if ( strcmp( testString2, "min" ) == 0 ) { type = 1; } if ( strcmp( testString2, "max" ) == 0 ) { type = 2; } if ( strcmp( testString2, "sum" ) == 0 ) { type = 3; } if ( strcmp( testString2, "avg" ) == 0 ) { type = 4; } if ( strcmp( testString2, "count" ) == 0 ) { type = 5; } } if ( type == 0 ) { addInxIval( &genQueryInp.selectInp, COL_DATA_SIZE, 0 ); } if ( type == 1 ) { addInxIval( &genQueryInp.selectInp, COL_DATA_SIZE, SELECT_MIN ); } if ( type == 2 ) { addInxIval( &genQueryInp.selectInp, COL_DATA_SIZE, SELECT_MAX ); } if ( type == 3 ) { addInxIval( &genQueryInp.selectInp, COL_DATA_SIZE, SELECT_SUM ); } if ( type == 4 ) { addInxIval( &genQueryInp.selectInp, COL_DATA_SIZE, SELECT_AVG ); } if ( type == 5 ) { addInxIval( &genQueryInp.selectInp, COL_DATA_SIZE, SELECT_COUNT ); } snprintf( condStr1, MAX_NAME_LEN, "= '%s'", testString ); addInxVal( &genQueryInp.sqlCondInp, COL_R_RESC_NAME, condStr1 ); genQueryInp.maxRows = 5; status = chlGenQuery( genQueryInp, &genQueryOut ); printf( "chlGenQuery status=%d\n", status ); printf( "genQueryOut->totalRowCount=%d\n", genQueryOut.totalRowCount ); if ( status == 0 ) { printGenQOut( &genQueryOut ); } if ( genQueryOut.continueInx > 0 ) { genQueryInp.continueInx = genQueryOut.continueInx; printf( "Second call to chlGenQuery\n" ); status2 = chlGenQuery( genQueryInp, &genQueryOut ); printf( "chlGenQuery status=%d\n", status2 ); if ( status2 == 0 ) { printGenQOut( &genQueryOut ); } } return status; }
/* A few tests to verify basic functionality (including talking with the database via ODBC). */ int cllTest( const char *userArg, const char *pwArg ) { int i; int j, k; int OK; int stmt; int numOfCols; char userName[500]; int numRows; struct passwd *ppasswd; icatSessionStruct icss; icss.stmtPtr[0] = 0; rodsLogSqlReq( 1 ); OK = 1; i = cllOpenEnv( &icss ); if ( i != 0 ) { OK = 0; } if ( userArg == 0 || *userArg == '\0' ) { ppasswd = getpwuid( getuid() ); /* get user passwd entry */ strcpy( userName, ppasswd->pw_name ); /* get user name */ } else { strncpy( userName, userArg, 500 ); } printf( "userName=%s\n", userName ); printf( "password=%s\n", pwArg ); strncpy( icss.databaseUsername, userName, DB_USERNAME_LEN ); if ( pwArg == 0 || *pwArg == '\0' ) { strcpy( icss.databasePassword, "" ); } else { strncpy( icss.databasePassword, pwArg, DB_PASSWORD_LEN ); } i = cllConnect( &icss ); if ( i != 0 ) { exit( -1 ); } i = cllExecSqlNoResult( &icss, "drop table test" ); i = cllExecSqlNoResult( &icss, "create table test (i integer, a2345678901234567890123456789j integer, a varchar(50) )" ); if ( i != 0 && i != CAT_SUCCESS_BUT_WITH_NO_INFO ) { OK = 0; } i = cllExecSqlNoResult( &icss, "insert into test values ('1', '2', 'asdfas')" ); if ( i != 0 ) { OK = 0; } i = cllExecSqlNoResult( &icss, "commit" ); if ( i != 0 ) { OK = 0; } i = cllExecSqlNoResult( &icss, "insert into test values (2, 3, 'a')" ); if ( i != 0 ) { OK = 0; } i = cllExecSqlNoResult( &icss, "commit" ); if ( i != 0 ) { OK = 0; } i = cllExecSqlNoResult( &icss, "bad sql" ); if ( i == 0 ) { OK = 0; /* should fail, if not it's not OK */ } i = cllExecSqlNoResult( &icss, "delete from test where i = '1'" ); if ( i != 0 && i != CAT_SUCCESS_BUT_WITH_NO_INFO ) { OK = 0; } i = cllExecSqlNoResult( &icss, "commit" ); if ( i != 0 ) { OK = 0; } i = cllExecSqlWithResult( &icss, &stmt, "select * from test where a = 'a'" ); if ( i != 0 ) { OK = 0; } if ( i == 0 ) { numOfCols = 1; for ( j = 0; j < 10 && numOfCols > 0; j++ ) { i = cllGetRow( &icss, stmt ); if ( i != 0 ) { OK = 0; break; } else { numOfCols = icss.stmtPtr[stmt]->numOfCols; if ( numOfCols == 0 ) { printf( "No more rows returned\n" ); i = cllFreeStatement( &icss, stmt ); } else { for ( k = 0; k < numOfCols || k < icss.stmtPtr[stmt]->numOfCols; k++ ) { printf( "resultValue[%d]=%s\n", k, icss.stmtPtr[stmt]->resultValue[k] ); } } } } } cllBindVars[cllBindVarCount++] = "a"; i = cllExecSqlWithResult( &icss, &stmt, "select * from test where a = ?" ); if ( i != 0 ) { OK = 0; } numRows = 0; if ( i == 0 ) { numOfCols = 1; for ( j = 0; j < 10 && numOfCols > 0; j++ ) { i = cllGetRow( &icss, stmt ); if ( i != 0 ) { OK = 0; } else { numOfCols = icss.stmtPtr[stmt]->numOfCols; if ( numOfCols == 0 ) { printf( "No more rows returned\n" ); i = cllFreeStatement( &icss, stmt ); } else { numRows++; for ( k = 0; k < numOfCols || k < icss.stmtPtr[stmt]->numOfCols; k++ ) { printf( "resultValue[%d]=%s\n", k, icss.stmtPtr[stmt]->resultValue[k] ); } } } } } if ( numRows != 1 ) { printf( "Error: Did not return 1 row, %d instead\n", numRows ); OK = 0; } i = cllExecSqlNoResult( &icss, "drop table test" ); if ( i != 0 && i != CAT_SUCCESS_BUT_WITH_NO_INFO ) { OK = 0; } i = cllExecSqlNoResult( &icss, "commit" ); if ( i != 0 ) { OK = 0; } i = cllDisconnect( &icss ); if ( i != 0 ) { OK = 0; } i = cllCloseEnv( &icss ); if ( i != 0 ) { OK = 0; } if ( OK ) { printf( "The tests all completed normally\n" ); return 0; } else { printf( "One or more tests DID NOT complete normally\n" ); return -1; } }
int doTest7( char *testString, char *testString2, char *testString3, char *minTotalRows ) { genQueryInp_t genQueryInp; genQueryOut_t genQueryOut; char condStr1[MAX_NAME_LEN]; char condStr2[MAX_NAME_LEN]; int status, status2; printf( "dotest7\n" ); rodsLogSqlReq( 1 ); memset( &genQueryInp, 0, sizeof( genQueryInp ) ); addInxIval( &genQueryInp.selectInp, COL_TOKEN_NAME, 1 ); snprintf( condStr1, MAX_NAME_LEN, "= 'data_type'" ); addInxVal( &genQueryInp.sqlCondInp, COL_TOKEN_NAMESPACE, condStr1 ); snprintf( condStr2, MAX_NAME_LEN, "like '%s%s%s'", "%", testString, "%" ); addInxVal( &genQueryInp.sqlCondInp, COL_TOKEN_VALUE2, condStr2 ); genQueryInp.options = RETURN_TOTAL_ROW_COUNT; genQueryInp.maxRows = 5; if ( testString3 != NULL && *testString3 != '\0' ) { genQueryInp.maxRows = atoi( testString3 ); } if ( testString2 != NULL && *testString2 != '\0' ) { genQueryInp.rowOffset = atoi( testString2 ); } status = chlGenQuery( genQueryInp, &genQueryOut ); printf( "chlGenQuery status=%d\n", status ); printf( "genQueryOut->totalRowCount=%d\n", genQueryOut.totalRowCount ); if ( status == 0 ) { printGenQOut( &genQueryOut ); } if ( minTotalRows != NULL && *minTotalRows != '\0' ) { int minTotalRowsInt; minTotalRowsInt = atoi( minTotalRows ); if ( genQueryOut.totalRowCount < minTotalRowsInt ) { rodsLog( LOG_ERROR, "doTest7 chlGenQuery totalRowCount(%d) is less than minimum expected (%d)\n", genQueryOut.totalRowCount, minTotalRowsInt ); return -1; } } if ( genQueryOut.continueInx > 0 ) { genQueryInp.continueInx = genQueryOut.continueInx; printf( "Second call to chlGenQuery\n" ); status2 = chlGenQuery( genQueryInp, &genQueryOut ); printf( "chlGenQuery status=%d\n", status2 ); if ( status2 == 0 ) { printGenQOut( &genQueryOut ); } } return status; }
/* A few tests to verify basic functionality (including talking with the database via ODBC). */ int cllTest(char *userArg, char *pwArg) { int i; int j, k; int OK; int stmt; int numOfCols; char userName[500]; int ival; struct passwd *ppasswd; icatSessionStruct icss; icss.stmtPtr[0]=0; icss.databaseType = DB_TYPE_POSTGRES; #ifdef MY_ICAT icss.databaseType = DB_TYPE_MYSQL; #endif rodsLogSqlReq(1); OK=1; i = cllOpenEnv(&icss); if (i != 0) OK=0; if (userArg==0 || *userArg=='\0') { ppasswd = getpwuid(getuid()); /* get user passwd entry */ strcpy(userName,ppasswd->pw_name); /* get user name */ } else { strncpy(userName, userArg, 500); } printf("userName=%s\n",userName); printf("password=%s\n",pwArg); strncpy(icss.databaseUsername,userName, DB_USERNAME_LEN); if (pwArg==0 || *pwArg=='\0') { strcpy(icss.databasePassword,""); } else { strncpy(icss.databasePassword,pwArg, DB_PASSWORD_LEN); } i = cllConnect(&icss); if (i != 0) exit(-1); i = cllExecSqlNoResult(&icss,"create table test (i integer, j integer, a varchar(32))"); if (i != 0 && i != CAT_SUCCESS_BUT_WITH_NO_INFO) OK=0; i = cllExecSqlNoResult(&icss, "insert into test values (2, 3, 'a')"); if (i != 0) OK=0; i = cllExecSqlNoResult(&icss, "commit"); if (i != 0) OK=0; i = cllExecSqlNoResult(&icss, "bad sql"); if (i == 0) OK=0; /* should fail, if not it's not OK */ i = cllExecSqlNoResult(&icss, "rollback"); /* close the bad transaction*/ i = cllExecSqlNoResult(&icss, "delete from test where i = 1"); if (i != 0 && i != CAT_SUCCESS_BUT_WITH_NO_INFO) OK=0; i = cllExecSqlNoResult(&icss, "commit"); if (i != 0) OK=0; i = cllExecSqlWithResultBV(&icss, &stmt, "select * from test where a = ?", "a",0 ,0,0,0,0); if (i != 0) OK=0; if (i == 0) { numOfCols = 1; for (j=0;j<10 && numOfCols>0;j++) { i = cllGetRow(&icss, stmt); if (i != 0) { OK=0; } else { numOfCols = icss.stmtPtr[stmt]->numOfCols; if (numOfCols == 0) { printf("No more rows returned\n"); i = cllFreeStatement(&icss,stmt); } else { for (k=0; k<numOfCols || k < icss.stmtPtr[stmt]->numOfCols; k++){ printf("resultValue[%d]=%s\n",k, icss.stmtPtr[stmt]->resultValue[k]); } } } } } ival=2; i = cllExecSqlWithResultBV(&icss, &stmt, "select * from test where i = ?", "2",0,0,0,0,0); if (i != 0) OK=0; if (i == 0) { numOfCols = 1; for (j=0;j<10 && numOfCols>0;j++) { i = cllGetRow(&icss, stmt); if (i != 0) { OK=0; } else { numOfCols = icss.stmtPtr[stmt]->numOfCols; if (numOfCols == 0) { printf("No more rows returned\n"); i = cllFreeStatement(&icss,stmt); } else { for (k=0; k<numOfCols || k < icss.stmtPtr[stmt]->numOfCols; k++){ printf("resultValue[%d]=%s\n",k, icss.stmtPtr[stmt]->resultValue[k]); } } } } } i = cllExecSqlNoResult(&icss,"drop table test;"); if (i != 0 && i != CAT_SUCCESS_BUT_WITH_NO_INFO) OK=0; i = cllExecSqlNoResult(&icss, "commit"); if (i != 0) OK=0; i = cllDisconnect(&icss); if (i != 0) OK=0; i = cllCloseEnv(&icss); if (i != 0) OK=0; if (OK) { printf("The tests all completed normally\n"); return(0); } else { printf("One or more tests DID NOT complete normally\n"); return(-1); } }
int main(int argc, char **argv) { int status; rsComm_t *Comm; /* rErrMsg_t errMsg;*/ rodsArguments_t myRodsArgs; char *mySubName; char *myName; int didOne; rodsServerConfig_t serverConfig; Comm = (rsComm_t*)malloc (sizeof (rsComm_t)); memset (Comm, 0, sizeof (rsComm_t)); parseCmdLineOpt(argc, argv, "", 0, &myRodsArgs); rodsLogLevel(LOG_NOTICE); rodsLogSqlReq(1); if (argc < 2) { printf("Usage: test_chl testName [args...]\n"); exit(3); } status = getRodsEnv (&myEnv); if (status < 0) { rodsLog (LOG_ERROR, "main: getRodsEnv error. status = %d", status); exit (1); } if (strstr(myEnv.rodsDebug, "CAT") != NULL) { chlDebug(myEnv.rodsDebug); } memset(&serverConfig, 0, sizeof(serverConfig)); status = readServerConfig(&serverConfig); strncpy(Comm->clientUser.userName, myEnv.rodsUserName, sizeof Comm->clientUser.userName); strncpy(Comm->clientUser.rodsZone, myEnv.rodsZone, sizeof Comm->clientUser.rodsZone); /* char rodsUserName[NAME_LEN]; char rodsZone[NAME_LEN]; userInfo_t clientUser; char userName[NAME_LEN]; char rodsZone[NAME_LEN]; */ if ((status = chlOpen(serverConfig.DBUsername, serverConfig.DBPassword)) != 0) { rodsLog (LOG_SYS_FATAL, "initInfoWithRcat: chlopen Error. Status = %d", status); free(Comm); // cppcheck - Memory leak: Comm return (status); } didOne=0; if (strcmp(argv[1],"reg")==0) { status = testRegDataObj(Comm, argv[2], argv[3], argv[4]); didOne=1; } if (strcmp(argv[1],"regmulti")==0) { status = testRegDataMulti(Comm, argv[2], argv[3], argv[4], argv[5]); didOne=1; } if (strcmp(argv[1],"mod")==0) { status = testModDataObjMeta(Comm, argv[2], argv[3], argv[4]); didOne=1; } if (strcmp(argv[1],"mod2")==0) { status = testModDataObjMeta2(Comm, argv[2], argv[3], argv[4]); didOne=1; } if (strcmp(argv[1],"modr")==0) { status = testModRuleMeta(Comm, argv[2], argv[3], argv[4]); didOne=1; } if (strcmp(argv[1],"modc")==0) { status = testModColl(Comm, argv[2], argv[3], argv[4], argv[5]); didOne=1; } if (strcmp(argv[1],"rmrule")==0) { status = testDelRule(Comm, argv[2], argv[3]); didOne=1; } if (strcmp(argv[1],"modrfs")==0) { status = testModResourceFreeSpace(Comm, argv[2], argv[3], argv[4]); didOne=1; } if (strcmp(argv[1],"rep")==0) { if (argc < 6) { printf("too few arguments\n"); exit(1); } status = testRegReplica(Comm, argv[2], argv[3], argv[4], argv[5]); didOne=1; } /* if (strcmp(argv[1],"cml")==0) { status = testCml(Comm); didOne=1; } */ if (strcmp(argv[1],"rmuser")==0) { status = testDelUser(Comm, argv[2], argv[3]); didOne=1; } if (strcmp(argv[1],"mkdir")==0) { status = testRegColl(Comm, argv[2]); didOne=1; } if (strcmp(argv[1],"rmdir")==0) { status = testDelColl(Comm, argv[2]); didOne=1; } if (strcmp(argv[1],"sql")==0) { status = testSimpleQ(Comm, argv[2], argv[3], argv[4]); didOne=1; } if (strcmp(argv[1],"rm")==0) { status = testDelFile(Comm, argv[2], argv[3]); didOne=1; } if (strcmp(argv[1],"rmtrash")==0) { status = testDelFileTrash(Comm, argv[2], argv[3]); didOne=1; } if (strcmp(argv[1],"rmpriv")==0) { status = testDelFilePriv(Comm, argv[2], argv[3], argv[4]); didOne=1; } if (strcmp(argv[1],"chmod")==0) { status = testChmod(Comm, argv[2], argv[3], argv[4], argv[5]); didOne=1; } if (strcmp(argv[1],"regrule")==0) { status = testRegRule(Comm, argv[2]); didOne=1; } if (strcmp(argv[1],"rename")==0) { status = testRename(Comm, argv[2], argv[3]); testCurrent(Comm); /* exercise this as part of rename; testCurrent needs a SQL context */ didOne=1; } if (strcmp(argv[1],"login")==0) { status = testLogin(Comm, argv[2], argv[3], argv[4]); didOne=1; } if (strcmp(argv[1],"move")==0) { status = testMove(Comm, argv[2], argv[3]); didOne=1; } if (strcmp(argv[1],"checkauth")==0) { status = testCheckAuth(Comm, argv[2], argv[3], argv[4]); didOne=1; } if (strcmp(argv[1],"temppw")==0) { status = testTempPw(Comm); didOne=1; } if (strcmp(argv[1],"tpc")==0) { status = testTempPwConvert(argv[2], argv[3]); didOne=1; } if (strcmp(argv[1],"tpw")==0) { status = testTempPwCombined(Comm, argv[2]); didOne=1; } if (strcmp(argv[1],"tpwforother")==0) { status = testTempPwForOther(Comm, argv[2], argv[3]); didOne=1; } if (strcmp(argv[1],"serverload")==0) { status = testServerLoad(Comm, argv[2]); didOne=1; } if (strcmp(argv[1],"purgeload")==0) { status = testPurgeServerLoad(Comm, argv[2]); didOne=1; } if (strcmp(argv[1],"serverdigest")==0) { status = testServerLoadDigest(Comm, argv[2]); didOne=1; } if (strcmp(argv[1],"purgedigest")==0) { status = testPurgeServerLoadDigest(Comm, argv[2]); didOne=1; } if (strcmp(argv[1],"checkquota")==0) { if (argc < 5) { status = testCheckQuota(Comm, argv[2], argv[3], NULL, NULL); } else { status = testCheckQuota(Comm, argv[2], argv[3], argv[4], argv[5]); } didOne=1; } if (strcmp(argv[1],"open")==0) { int i; for (i=0;i<3;i++) { status = chlClose(); if (status) { printf ("close %d error", i); } if ((status = chlOpen(serverConfig.DBUsername, serverConfig.DBPassword)) != 0) { rodsLog (LOG_SYS_FATAL, "initInfoWithRcat: chlopen %d Error. Status = %d", i, status); return (status); } } didOne=1; } if (strcmp(argv[1],"addrule")==0) { status = testAddRule(Comm, argv[2], argv[3], argv[4], argv[5], argv[6], argv[7]); didOne=1; } if (strcmp(argv[1],"versionrulebase")==0) { status = testVersionRuleBase(Comm, argv[2]); didOne=1; } if (strcmp(argv[1],"versiondvmbase")==0) { status = testVersionDvmBase(Comm, argv[2]); didOne=1; } if (strcmp(argv[1],"versionfnmbase")==0) { status = testVersionFnmBase(Comm, argv[2]); didOne=1; } if (strcmp(argv[1],"insfnmtable")==0) { status = testInsFnmTable(Comm, argv[2], argv[3], argv[4], argv[5] ); didOne=1; } if (strcmp(argv[1],"insdvmtable")==0) { status = testInsDvmTable(Comm, argv[2], argv[3], argv[4], argv[5] ); didOne=1; } if (strcmp(argv[1],"insmsrvctable")==0) { status = testInsMsrvcTable(Comm, argv[2], argv[3], argv[4], argv[5], argv[6], argv[7], argv[8], argv[9], argv[10]); if (status==0) { /* do it a second time to test another logic path and different SQL. Since no commit is part of the chl function, and there is not corresponding Delete call, this is an easy way to do this. */ status = testInsMsrvcTable(Comm, argv[2], argv[3], argv[4], argv[5], argv[6], argv[7], argv[8], argv[9], argv[10]); } didOne=1; } if (strcmp(argv[1],"getlocalzone")==0) { status = testGetLocalZone(Comm, argv[2]); didOne=1; } if (strcmp(argv[1],"getpampw")==0) { status = testGetPamPw(Comm, argv[2], argv[3]); didOne=1; } if (status != 0) { /* if (Comm->rError) { rError_t *Err; rErrMsg_t *ErrMsg; int i, len; Err = Comm->rError; len = Err->len; for (i=0;i<len;i++) { ErrMsg = Err->errMsg[i]; rodsLog(LOG_ERROR, "Level %d: %s",i, ErrMsg->msg); } } */ myName = rodsErrorName(status, &mySubName); rodsLog (LOG_ERROR, "%s failed with error %d %s %s", argv[1], status, myName, mySubName); } else { if (didOne) printf("Completed successfully\n"); } if (didOne==0) { printf("Unknown test type: %s\n", argv[1]); } exit(status); }
int main(int argc, char **argv) { int mode; rodsServerConfig_t serverConfig; int status; rodsEnv myEnv; /* remove this call or change to LOG_NOTICE for more verbosity */ rodsLogLevel(LOG_ERROR); /* this will cause the sql to be printed, comment this out to skip it */ rodsLogSqlReq(1); mode = 0; if (strcmp(argv[1],"1")==0) mode=1; if (strcmp(argv[1],"2")==0) mode=2; if (strcmp(argv[1],"3")==0) mode=3; if (strcmp(argv[1],"4")==0) mode=4; if (strcmp(argv[1],"5")==0) mode=5; if (strcmp(argv[1],"6")==0) mode=6; memset((char *)&myEnv, 0, sizeof(myEnv)); status = getRodsEnv (&myEnv); if (status < 0) { rodsLog (LOG_ERROR, "main: getRodsEnv error. status = %d", status); exit (1); } if (strstr(myEnv.rodsDebug, "CAT") != NULL) { chlDebug(myEnv.rodsDebug); } memset(&serverConfig, 0, sizeof(serverConfig)); status = readServerConfig(&serverConfig); if ((status = chlOpen(serverConfig.DBUsername, serverConfig.DBPassword)) != 0) { rodsLog (LOG_SYS_FATAL, "chlopen Error. Status = %d", status); return (status); } if (mode==1) { status = doTest1(argv[2], argv[3], argv[4], argv[5]); if (status <0) exit(2); exit(0); } if (mode==2) { status = doTest2(argv[2], argv[3], argv[4], argv[5]); if (status <0) exit(2); exit(0); } if (mode==3) { status = doTest3(argv[2], argv[3], argv[4], argv[5]); if (status <0) exit(2); exit(0); } if (mode==4) { status = doTest4(argv[2], argv[3], argv[4], argv[5]); if (status <0) exit(2); exit(0); } if (mode==5) { status = doTest5(argv[2], argv[3], argv[4], argv[5], argv[6], argv[7]); if (status <0) exit(2); exit(0); } if (mode==6) { status = doTest6(argv[2], argv[3], argv[4], argv[5]); if (status <0) exit(2); exit(0); } exit(0); }
int main(int argc, char **argv) { int status; int c; rsComm_t rsComm; int runMode = IRODS_SERVER; int flagval = 0; char *logDir = NULL; char *tmpStr; int logFd; char *ruleExecId = NULL; int jobType = 0; ProcessType = RE_SERVER_PT; #ifdef RUN_SERVER_AS_ROOT #ifndef windows_platform if (initServiceUser() < 0) { exit (1); } #endif #endif #ifndef _WIN32 signal(SIGINT, signalExit); signal(SIGHUP, signalExit); signal(SIGTERM, signalExit); signal(SIGUSR1, signalExit); signal(SIGPIPE, rsPipSigalHandler); /* XXXXX switched to SIG_DFL for embedded python. child process * went away. But probably have to call waitpid. * signal(SIGCHLD, SIG_IGN); */ signal(SIGCHLD, SIG_DFL); #endif /* Handle option to log sql commands */ tmpStr = getenv (SP_LOG_SQL); if (tmpStr != NULL) { #ifdef IRODS_SYSLOG int j = atoi(tmpStr); rodsLogSqlReq(j); #else rodsLogSqlReq(1); #endif } /* Set the logging level */ tmpStr = getenv (SP_LOG_LEVEL); if (tmpStr != NULL) { int i; i = atoi(tmpStr); rodsLogLevel(i); } else { rodsLogLevel(LOG_NOTICE); /* default */ } #ifdef IRODS_SYSLOG /* Open a connection to syslog */ openlog("rodsReServer",LOG_ODELAY|LOG_PID,LOG_DAEMON); #endif while ((c=getopt(argc, argv,"sSvD:j:t:")) != EOF) { switch (c) { case 's': runMode = SINGLE_PASS; break; case 'S': runMode = STANDALONE_SERVER; break; case 'v': /* verbose */ flagval |= v_FLAG; break; case 'D': /* user specified a log directory */ logDir = strdup (optarg); break; case 'j': runMode = SINGLE_PASS; ruleExecId = strdup (optarg); break; case 't': jobType = atoi (optarg); break; default: usage (argv[0]); exit (1); } } status = initRsComm (&rsComm); if (status < 0) { cleanupAndExit (status); } if ((logFd = logFileOpen (runMode, logDir, RULE_EXEC_LOGFILE)) < 0) { exit (1); } daemonize (runMode, logFd); #ifdef RULE_ENGINE_N status = initAgent (RULE_ENGINE_INIT_CACHE, &rsComm); #else status = initAgent (&rsComm); #endif if (status < 0) { cleanupAndExit (status); } if (ruleExecId != NULL) { status = reServerSingleExec (&rsComm, ruleExecId, jobType); if (status >= 0) { exit (0); } else { exit (1); } } else { reServerMain (&rsComm); } cleanupAndExit (status); exit (0); }
int main( int argc, char **argv ) { int c; int runMode = SERVER; int flagval = 0; char *logDir = NULL; char *tmpStr; int logFd; ProcessType = XMSG_SERVER_PT; // capture server properties try { irods::server_properties::instance().capture_if_needed(); } catch ( const irods::exception& e ) { rodsLog( LOG_ERROR, e.what() ); return e.code(); } #ifndef _WIN32 signal( SIGINT, signalExit ); signal( SIGHUP, signalExit ); signal( SIGTERM, signalExit ); signal( SIGUSR1, signalExit ); signal( SIGPIPE, rsPipeSignalHandler ); #endif /* Handle option to log sql commands */ tmpStr = getenv( SP_LOG_SQL ); if ( tmpStr != NULL ) { rodsLogSqlReq( 1 ); } /* Set the logging level */ tmpStr = getenv( SP_LOG_LEVEL ); if ( tmpStr != NULL ) { int i; i = atoi( tmpStr ); rodsLogLevel( i ); } else { rodsLogLevel( LOG_NOTICE ); /* default */ } while ( ( c = getopt( argc, argv, "sSc:vD:" ) ) != EOF ) { switch ( c ) { case 's': runMode = SINGLE_PASS; break; case 'S': runMode = STANDALONE_SERVER; break; case 'v': /* verbose */ flagval |= v_FLAG; break; case 'c': loopCnt = atoi( optarg ); break; case 'D': /* user specified a log directory */ logDir = strdup( optarg ); break; default: usage( argv[0] ); exit( 1 ); } } if ( ( logFd = logFileOpen( runMode, logDir, XMSG_SVR_LOGFILE ) ) < 0 ) { exit( 1 ); } irods::error ret = setRECacheSaltFromEnv(); if ( !ret.ok() ) { rodsLog( LOG_ERROR, "irodsXmsgServer::main: Failed to set RE cache mutex name\n%s", ret.result().c_str() ); exit( 1 ); } daemonize( runMode, logFd ); xmsgServerMain(); sleep( 5 ); exit( 0 ); }