int main() { OM_uint32 minor_status; OM_uint32 major_status; gss_cred_id_t cred; char * error_str; int rc = EXIT_SUCCESS; printf("1..1\n"); globus_module_activate(GLOBUS_GSI_GSS_ASSIST_MODULE); globus_module_activate(GLOBUS_GSI_GSSAPI_MODULE); major_status = gss_acquire_cred( &minor_status, NULL, GSS_C_INDEFINITE, GSS_C_NO_OID_SET, GSS_C_BOTH, &cred, NULL, NULL); if(GSS_ERROR(major_status)) { globus_gss_assist_display_status_str(&error_str, NULL, major_status, minor_status, 0); fprintf(stderr, "\nLINE %d ERROR: %s\n", __LINE__, error_str); free(error_str); rc = EXIT_FAILURE; goto fail; } major_status = gss_release_cred( &minor_status, &cred); if(GSS_ERROR(major_status)) { globus_gss_assist_display_status_str(&error_str, NULL, major_status, minor_status, 0); fprintf(stderr, "\nLINE %d ERROR: %s\n", __LINE__, error_str); free(error_str); rc = EXIT_FAILURE; goto fail; } fail: printf("%s gssapi_acquire_test\n", (rc == EXIT_SUCCESS) ? "ok" : "not ok"); globus_module_deactivate_all(); return rc; }
int main(int argc, char * argv[]) { globus_ftp_client_handle_t handle; globus_ftp_client_operationattr_t attr; globus_result_t result; globus_ftp_client_handleattr_t handle_attr; char * src; char * dst; globus_module_activate(GLOBUS_FTP_CLIENT_MODULE); globus_ftp_client_handleattr_init(&handle_attr); globus_ftp_client_operationattr_init(&attr); globus_mutex_init(&lock, GLOBUS_NULL); globus_cond_init(&cond, GLOBUS_NULL); test_parse_args(argc, argv, &handle_attr, &attr, &src, &dst); globus_ftp_client_operationattr_set_type(&attr, GLOBUS_FTP_CONTROL_TYPE_ASCII); globus_ftp_client_handle_init(&handle, &handle_attr); done = GLOBUS_FALSE; result = globus_ftp_client_symlink(&handle, src, dst, &attr, done_cb, 0); if(result != GLOBUS_SUCCESS) { done = GLOBUS_TRUE; } globus_mutex_lock(&lock); while(!done) { globus_cond_wait(&cond, &lock); } globus_mutex_unlock(&lock); globus_ftp_client_handle_destroy(&handle); globus_module_deactivate_all(); if(test_abort_count && error) { return 0; } return error; }
int main(int argc, char *argv[]) { int rc = 0; int test_num = 0; int not_ok = 0; LTDL_SET_PRELOADED_SYMBOLS(); if(argc < 2) { fprintf(stderr, "Usage: %s resource-manager-contact [test number]\n", argv[0]); exit(1); } resource_manager_contact = argv[1]; if(argc > 2) { test_num = atoi(argv[2]); } rc = globus_module_activate(GLOBUS_COMMON_MODULE); if(rc) { not_ok |= rc; goto end; } if(test_num == 0 || test_num == 1) { rc = test1(); printf("%sok\n", rc ? "not " : ""); not_ok |= rc; } if(test_num == 0 || test_num == 2) { rc = test2(); printf("%sok\n", rc ? "not " : ""); not_ok |= rc; } if(test_num == 0 || test_num == 3) { rc = test3(); printf("%sok\n", rc ? "not " : ""); not_ok |= rc; } globus_module_deactivate_all(); end: return not_ok; }
static int globus_l_gram_deactivate(void) { (void) globus_xio_stack_destroy( globus_i_gram_job_manager_file_stack); (void) globus_xio_stack_destroy( globus_i_gram_job_manager_popen_stack); globus_xio_driver_unload(globus_i_gram_job_manager_file_driver); globus_xio_driver_unload(globus_i_gram_job_manager_popen_driver); return globus_module_deactivate_all(); }
int main() { globus_object_t * err; char * s; static char * myname = "main"; globus_module_activate(GLOBUS_COMMON_MODULE); err = globus_error_construct_string(GLOBUS_COMMON_MODULE, GLOBUS_ERROR_NO_INFO, "[%s]: Error doing something hard at %s:%d\n", GLOBUS_COMMON_MODULE->module_name, myname, __LINE__); s = globus_object_printable_to_string(err); globus_libc_printf("%s",s); return globus_module_deactivate_all(); }
int main(int argc, char *argv[]) { int i; int failed; test_case_t tests[] = { TEST_CASE(test_stdio_update), {NULL, NULL} }; LTDL_SET_PRELOADED_SYMBOLS(); printf("1..%d\n", (int) (sizeof(tests)/sizeof(tests[0]) - 1)); contact_string = getenv("CONTACT_STRING"); if (argc == 2) { contact_string = argv[1]; } if (contact_string == NULL) { fprintf(stderr, "Usage: %s CONTACT-STRING\n", argv[0]); exit(1); } globus_module_activate(GLOBUS_GRAM_CLIENT_MODULE); globus_module_activate(GLOBUS_GASS_TRANSFER_MODULE); for (i = 0, failed = 0; tests[i].test_name != NULL; i++) { int rc = tests[i].test_case(); if (rc != 0) { printf("not "); failed++; } printf("ok %s\n", tests[i].test_name); } globus_module_deactivate_all(); return failed; }
int main(int argc, char *argv[]) { globus_ftp_client_handle_t handle; globus_ftp_client_operationattr_t attr; globus_byte_t buffer[1024]; globus_size_t buffer_length = sizeof(buffer); globus_result_t result; char * src; char * dst; globus_ftp_client_handleattr_t handle_attr; LTDL_SET_PRELOADED_SYMBOLS(); globus_module_activate(GLOBUS_FTP_CLIENT_MODULE); globus_ftp_client_handleattr_init(&handle_attr); globus_ftp_client_operationattr_init(&attr); test_parse_args(argc, argv, &handle_attr, &attr, &src, &dst); globus_mutex_init(&lock, GLOBUS_NULL); globus_cond_init(&cond, GLOBUS_NULL); globus_ftp_client_handle_init(&handle, &handle_attr); done = GLOBUS_FALSE; result = globus_ftp_client_get(&handle, src, &attr, GLOBUS_NULL, done_cb, 0); globus_module_deactivate_all(); return done; }
int main(int argc, char *argv[]) { int rc; LTDL_SET_PRELOADED_SYMBOLS(); rc = globus_module_activate(GLOBUS_GRAM_CLIENT_MODULE); if(rc != GLOBUS_SUCCESS) { fprintf(stderr, "Error activating GRAM Client\n"); goto error_exit; } if(argc < 2) { rc = -1; fprintf(stderr, "Usage: %s rm_contact\n", argv[0]); goto deactivate_exit; } rc = globus_gram_client_ping(argv[1]); if(rc == GLOBUS_SUCCESS) { printf("Success pinging %s\n", argv[1]); } else { printf("Failed pinging %s because %s\n", argv[1], globus_gram_client_error_string(rc)); } deactivate_exit: globus_module_deactivate_all(); error_exit: return rc; }
int main( int argc, char * argv[]) { globus_io_handle_t listener; globus_io_handle_t server_handle; globus_io_handle_t client_handle; globus_io_attr_t attr; unsigned short port = 0; globus_result_t result; globus_io_secure_authorization_data_t auth_data; globus_l_io_authorization_test_monitor_t monitor; char greeting[] = "Hello, my friend."; char reply_buffer[256]; globus_size_t written; globus_size_t read_amt; LTDL_SET_PRELOADED_SYMBOLS(); globus_module_activate(GLOBUS_COMMON_MODULE); globus_module_activate(GLOBUS_IO_MODULE); /* Initialize monitor */ globus_mutex_init(&monitor.mutex, GLOBUS_NULL); globus_cond_init(&monitor.cond, GLOBUS_NULL); monitor.connected = GLOBUS_FALSE; /* Prepare attributes */ globus_io_secure_authorization_data_initialize(&auth_data); globus_io_tcpattr_init(&attr); globus_io_attr_set_secure_authentication_mode( &attr, GLOBUS_IO_SECURE_AUTHENTICATION_MODE_GSSAPI, GSS_C_NO_CREDENTIAL); if(argc >= 2) { if(! strcasecmp(argv[1], "self")) { globus_io_attr_set_secure_authorization_mode( &attr, GLOBUS_IO_SECURE_AUTHORIZATION_MODE_SELF, &auth_data); } else if(argc > 2 && ! strcasecmp(argv[1], "identity") ) { globus_io_secure_authorization_data_set_identity(&auth_data, argv[2]); globus_io_attr_set_secure_authorization_mode( &attr, GLOBUS_IO_SECURE_AUTHORIZATION_MODE_IDENTITY, &auth_data); } else if(! strcasecmp(argv[1], "callback")) { globus_io_secure_authorization_data_set_callback( &auth_data, globus_l_io_authorization_test_callback, GLOBUS_NULL); globus_io_attr_set_secure_authorization_mode( &attr, GLOBUS_IO_SECURE_AUTHORIZATION_MODE_CALLBACK, &auth_data); } else if(! strcasecmp(argv[1], "-callback")) { globus_io_secure_authorization_data_set_callback( &auth_data, globus_l_io_authorization_test_callback, (void *) 0x1); globus_io_attr_set_secure_authorization_mode( &attr, GLOBUS_IO_SECURE_AUTHORIZATION_MODE_CALLBACK, &auth_data); } else { goto no_authorization_mode; } } else { goto no_authorization_mode; } result = globus_io_tcp_create_listener( &port, -1, &attr, &listener); if(result != GLOBUS_SUCCESS) { char *msg = globus_error_print_friendly(globus_error_peek(result)); globus_libc_fprintf(stderr, "# Could not create listener: %s\n", msg); free(msg); goto error_exit; } result = globus_io_tcp_register_connect( "localhost", port, &attr, globus_l_io_authorization_test_connect_callback, &monitor, &client_handle); if(result != GLOBUS_SUCCESS) { globus_libc_printf("# Could not register connect\n"); goto error_exit; } result = globus_io_tcp_listen(&listener); if(result != GLOBUS_SUCCESS) { globus_libc_printf("# Could not listen for connections\n"); goto error_exit; } result = globus_io_tcp_accept(&listener, &attr, &server_handle); if(result != GLOBUS_SUCCESS) { if(strcasecmp(argv[1], "-callback") == 0) { globus_module_deactivate_all(); exit(0); } else { globus_libc_printf("# Could not accept connection\n"); goto error_exit; } } globus_mutex_lock(&monitor.mutex); while(! monitor.connected) { globus_cond_wait(&monitor.cond, &monitor.mutex); } result = globus_io_close(&listener); if(result != GLOBUS_SUCCESS) { globus_libc_printf("# Could not close listener\n"); goto error_exit; } result = globus_io_write(&server_handle, greeting, sizeof(greeting), &written); if(result != GLOBUS_SUCCESS) { globus_libc_printf("# Could not write greeting\n"); goto error_exit; } result = globus_io_close(&server_handle); if(result != GLOBUS_SUCCESS) { globus_libc_printf("# Could not close server\n"); goto error_exit; } result = globus_io_read(&client_handle, reply_buffer, sizeof(reply_buffer), sizeof(reply_buffer), &read_amt); if(result != GLOBUS_SUCCESS) { globus_object_t * err; err = globus_error_get(result); if(! globus_io_eof(err)) { globus_libc_printf("# Could not read greeting\n"); goto error_exit; } } result = globus_io_close(&client_handle); if(result != GLOBUS_SUCCESS) { globus_libc_printf("# Could not close client\n"); goto error_exit; } if(!memcmp(greeting, reply_buffer, sizeof(greeting)) == 0) { result = GLOBUS_FAILURE; goto error_exit; } globus_module_deactivate_all(); exit(0); no_authorization_mode: globus_libc_printf( "Usage: %s AUTHORIZATION\n" " AUTHORIZATION is one of\n" " self use Globus I/O's self-authorization mode\n" " identity \"subject\" use Globus I/O's subject-based authorization\n" " callback use Globus I/O's callback authorization\n" " -callback use Globus I/O's callback authorization with\n" " a failure callback\n", argv[0]); error_exit: globus_module_deactivate_all(); exit(1); }
int main(int argc, char **argv) { globus_ftp_client_handle_t handle; globus_ftp_client_operationattr_t attr; globus_result_t result; globus_ftp_client_handleattr_t handle_attr; char * src; char * dst; LTDL_SET_PRELOADED_SYMBOLS(); globus_module_activate(GLOBUS_FTP_CLIENT_MODULE); globus_ftp_client_handleattr_init(&handle_attr); globus_mutex_init(&lock, GLOBUS_NULL); globus_cond_init(&cond, GLOBUS_NULL); globus_ftp_client_operationattr_init(&attr); test_parse_args(argc, argv, &handle_attr, &attr, &src, &dst); globus_ftp_client_handle_init(&handle, &handle_attr); done = GLOBUS_FALSE; result = globus_ftp_client_third_party_transfer(&handle, src, &attr, dst, &attr, GLOBUS_NULL, done_cb, 0); if(result != GLOBUS_SUCCESS) { globus_object_t * err; char * tmpstr; err = globus_error_get(result); tmpstr = globus_object_printable_to_string(err); fprintf(stderr, "Error: %s", tmpstr); globus_object_free(err); globus_libc_free(tmpstr); error = GLOBUS_TRUE; done = GLOBUS_TRUE; } globus_mutex_lock(&lock); while(!done) { globus_cond_wait(&cond, &lock); } globus_mutex_unlock(&lock); globus_ftp_client_handle_destroy(&handle); globus_module_deactivate_all(); if(test_abort_count && error) { return 0; } return error; }
/* * Timeout test: * -t server|client * Configure the server or client to cause a timeout. If server is * selected, then it will delay its part of the operation longer than the * timeout value, causing the client to time out (and vice versa). * -T timeout-in-ms * Set the timeout value in ms * -a * Expect / cause the accept operation to delay longer than the timeout. * -r * Expect / cause a read operation to delay longer than the timeout. * */ int main( int argc, char * argv[]) { int rc; char * contact = NULL; globus_result_t result; globus_l_timeout_info_t client_timeout_info; globus_l_timeout_info_t server_timeout_info; globus_reltime_t timeout; client_timeout_info.cause_timeout = GLOBUS_TRUE; client_timeout_info.expect_timeout = GLOBUS_FALSE; server_timeout_info.cause_timeout = GLOBUS_FALSE; server_timeout_info.expect_timeout = GLOBUS_TRUE; client_timeout_info.timeout_state = GLOBUS_XIO_OPERATION_TYPE_ACCEPT; server_timeout_info.timeout_state = GLOBUS_XIO_OPERATION_TYPE_ACCEPT; client_timeout_info.timeout = 1000; server_timeout_info.timeout = 1000; while ((rc = getopt(argc, argv, "t:T:arh")) != EOF) { switch (rc) { case 'h': usage(argv[0]); exit(0); case 't': if (strcmp(optarg, "client") == 0) { client_timeout_info.cause_timeout = GLOBUS_TRUE; client_timeout_info.expect_timeout = GLOBUS_FALSE; server_timeout_info.cause_timeout = GLOBUS_FALSE; server_timeout_info.expect_timeout = GLOBUS_TRUE; } else if (strcmp(optarg, "server") == 0) { client_timeout_info.cause_timeout = GLOBUS_FALSE; client_timeout_info.expect_timeout = GLOBUS_TRUE; server_timeout_info.cause_timeout = GLOBUS_TRUE; server_timeout_info.expect_timeout = GLOBUS_FALSE; } else { usage(argv[0]); exit(1); } break; case 'T': client_timeout_info.timeout = atoi(optarg); server_timeout_info.timeout = atoi(optarg); break; case 'a': client_timeout_info.timeout_state = GLOBUS_XIO_OPERATION_TYPE_ACCEPT; server_timeout_info.timeout_state = GLOBUS_XIO_OPERATION_TYPE_ACCEPT; break; case 'r': client_timeout_info.timeout_state = GLOBUS_XIO_OPERATION_TYPE_READ; server_timeout_info.timeout_state = GLOBUS_XIO_OPERATION_TYPE_READ; break; default: usage(argv[0]); exit(1); } } rc = http_test_initialize( &globus_l_tcp_driver, &globus_l_http_driver, &globus_l_http_stack); if (rc != GLOBUS_SUCCESS) { exit(2); } globus_mutex_init(&lock, NULL); globus_cond_init(&cond, NULL); GlobusTimeReltimeSet(timeout, 0, (server_timeout_info.timeout * 1000)); globus_xio_attr_init(&client_timeout_info.attr); globus_xio_attr_init(&server_timeout_info.attr); switch (server_timeout_info.timeout_state) { case GLOBUS_XIO_OPERATION_TYPE_ACCEPT: if (client_timeout_info.cause_timeout) { globus_xio_attr_cntl( server_timeout_info.attr, NULL, GLOBUS_XIO_ATTR_SET_TIMEOUT_ACCEPT, globus_l_timeout_callback, &timeout, NULL); } else { fprintf(stderr, "Unable to handle server-caused accept timeout\n"); exit(6); } break; case GLOBUS_XIO_OPERATION_TYPE_READ: if (client_timeout_info.cause_timeout) { globus_xio_attr_cntl( server_timeout_info.attr, NULL, GLOBUS_XIO_ATTR_SET_TIMEOUT_READ, globus_l_timeout_callback, &timeout, NULL); } else { globus_xio_attr_cntl( client_timeout_info.attr, NULL, GLOBUS_XIO_ATTR_SET_TIMEOUT_READ, globus_l_timeout_callback, &timeout, NULL); } break; default: fprintf(stderr, "Error: invalid timeout state\n"); exit(3); } /* Set up client attributes */ globus_xio_attr_cntl( client_timeout_info.attr, globus_l_http_driver, GLOBUS_XIO_HTTP_ATTR_SET_REQUEST_METHOD, "POST"); /* Modulate timeout state to causer's related state for delaying */ if (client_timeout_info.cause_timeout) { switch (client_timeout_info.timeout_state) { case GLOBUS_XIO_OPERATION_TYPE_ACCEPT: client_timeout_info.timeout_state = GLOBUS_XIO_OPERATION_TYPE_OPEN; break; case GLOBUS_XIO_OPERATION_TYPE_READ: client_timeout_info.timeout_state = GLOBUS_XIO_OPERATION_TYPE_WRITE; break; case GLOBUS_XIO_OPERATION_TYPE_WRITE: case GLOBUS_XIO_OPERATION_TYPE_OPEN: case GLOBUS_XIO_OPERATION_TYPE_CLOSE: case GLOBUS_XIO_OPERATION_TYPE_FINISHED: case GLOBUS_XIO_OPERATION_TYPE_NONE: case GLOBUS_XIO_OPERATION_TYPE_DRIVER: case GLOBUS_XIO_OPERATION_TYPE_DD: case GLOBUS_XIO_OPERATION_TYPE_SERVER_INIT: fprintf(stderr, "Error: unexpected state: %d\n", client_timeout_info.state); exit(4); } } else { globus_assert(server_timeout_info.cause_timeout); switch (server_timeout_info.timeout_state) { case GLOBUS_XIO_OPERATION_TYPE_ACCEPT: fprintf(stderr, "Invalid option (server-caused accept timeout)\n"); exit(5); case GLOBUS_XIO_OPERATION_TYPE_READ: server_timeout_info.timeout_state = GLOBUS_XIO_OPERATION_TYPE_WRITE; break; case GLOBUS_XIO_OPERATION_TYPE_WRITE: case GLOBUS_XIO_OPERATION_TYPE_OPEN: case GLOBUS_XIO_OPERATION_TYPE_CLOSE: case GLOBUS_XIO_OPERATION_TYPE_FINISHED: case GLOBUS_XIO_OPERATION_TYPE_NONE: case GLOBUS_XIO_OPERATION_TYPE_DRIVER: case GLOBUS_XIO_OPERATION_TYPE_DD: case GLOBUS_XIO_OPERATION_TYPE_SERVER_INIT: fprintf(stderr, "Error: unexpected state: %d\n", server_timeout_info.state); exit(4); } } /* create server */ server_timeout_info.state = GLOBUS_XIO_OPERATION_TYPE_ACCEPT; server_timeout_info.handle = NULL; server_timeout_info.result = GLOBUS_SUCCESS; server_timeout_info.contact = NULL; result = globus_xio_server_create( &server_timeout_info.server, server_timeout_info.attr, globus_l_http_stack); result = globus_xio_server_get_contact_string( server_timeout_info.server, &contact); client_timeout_info.contact = globus_common_create_string("http://%s/%s", contact, "ok"); /* create client handle */ client_timeout_info.state = GLOBUS_XIO_OPERATION_TYPE_OPEN; client_timeout_info.handle = NULL; client_timeout_info.result = GLOBUS_SUCCESS; client_timeout_info.server = NULL; result = globus_xio_handle_create( &client_timeout_info.handle, globus_l_http_stack); /* oneshot to start server state machine */ result = globus_callback_register_oneshot( NULL, &globus_i_reltime_zero, state_machine, &server_timeout_info); /* oneshot to start client state machine */ result = globus_callback_register_oneshot( NULL, &globus_i_reltime_zero, state_machine, &client_timeout_info); /* wait for both state machines to terminate */ globus_mutex_lock(&lock); while (client_timeout_info.state != GLOBUS_XIO_OPERATION_TYPE_NONE && server_timeout_info.state != GLOBUS_XIO_OPERATION_TYPE_NONE) { globus_cond_wait(&cond, &lock); } globus_mutex_unlock(&lock); globus_mutex_destroy(&lock); globus_module_deactivate_all(); return (client_timeout_info.result || server_timeout_info.result || client_timeout_info.expect_timeout || server_timeout_info.expect_timeout); }
int main() { int rc = 0; int count=0; globus_ftp_client_handle_t handle; globus_ftp_client_plugin_t restart_plugin; globus_ftp_client_plugin_t debug_plugin; globus_result_t result; globus_ftp_client_handleattr_t handleattr; globus_module_activate(GLOBUS_FTP_CLIENT_MODULE); globus_module_activate(GLOBUS_FTP_CLIENT_RESTART_PLUGIN_MODULE); globus_module_activate(GLOBUS_FTP_CLIENT_DEBUG_PLUGIN_MODULE); /* Test using attributes */ result = globus_ftp_client_handleattr_init(&handleattr); globus_assert(result == GLOBUS_SUCCESS); result = globus_ftp_client_restart_plugin_init( &restart_plugin, 0, GLOBUS_NULL, GLOBUS_NULL); globus_assert(result == GLOBUS_SUCCESS); result = globus_ftp_client_debug_plugin_init( &debug_plugin, stderr, "hello"); globus_assert(result == GLOBUS_SUCCESS); /* Test 1: insert restart plugin into handle attr */ count++; result = globus_ftp_client_handleattr_add_plugin(&handleattr, &restart_plugin); if(result != GLOBUS_SUCCESS) { printf("Failed test %d\n", count); rc++; } /* Test 2: insert restart plugin into handle attr (fail) */ count++; result = globus_ftp_client_handleattr_add_plugin(&handleattr, &restart_plugin); if(result == GLOBUS_SUCCESS) { printf("Failed test %d\n", count); rc++; } /* Test 3: create/destroy handle with attr */ count++; result = globus_ftp_client_handle_init(&handle, &handleattr); if(result != GLOBUS_SUCCESS) { printf("Failed test %d\n", count); rc++; } else if(globus_ftp_client_handle_destroy(&handle) != GLOBUS_SUCCESS) { printf("Failed test %d\n", count); rc++; } /* Test 4: insert debug plugin into handle attr */ count++; result = globus_ftp_client_handleattr_add_plugin(&handleattr, &debug_plugin); if(result != GLOBUS_SUCCESS) { printf("Failed test %d\n", count); rc++; } /* Test 5: create/destroy handle with attr */ count++; result = globus_ftp_client_handle_init(&handle, &handleattr); if(result != GLOBUS_SUCCESS) { printf("Failed test %d\n", count); rc++; } else if(globus_ftp_client_handle_destroy(&handle) != GLOBUS_SUCCESS) { printf("Failed test %d\n", count); rc++; } /* Test 6: remove restart plugin from handle attr */ count++; result = globus_ftp_client_handleattr_remove_plugin(&handleattr, &restart_plugin); if(result != GLOBUS_SUCCESS) { printf("Failed test %d\n", count); rc++; } /* Test 7: remove restart plugin from handle attr (fail) */ count++; result = globus_ftp_client_handleattr_remove_plugin(&handleattr, &restart_plugin); if(result == GLOBUS_SUCCESS) { printf("Failed test %d\n", count); rc++; } /* Test 8: insert debug plugin into handle attr (fail) */ count++; result = globus_ftp_client_handleattr_add_plugin(&handleattr, &debug_plugin); if(result == GLOBUS_SUCCESS) { printf("Failed test %d\n", count); rc++; } /* Test 9: remove debug plugin from handle attr */ count++; result = globus_ftp_client_handleattr_remove_plugin(&handleattr, &debug_plugin); if(result != GLOBUS_SUCCESS) { printf("Failed test %d\n", count); rc++; } /* Test 10: remove restart plugin from handle attr (fail) */ count++; result = globus_ftp_client_handleattr_remove_plugin(&handleattr, &restart_plugin); if(result == GLOBUS_SUCCESS) { printf("Failed test %d\n", count); rc++; } /* Test 11: create/destroy handle with attr */ count++; result = globus_ftp_client_handle_init(&handle, &handleattr); if(result != GLOBUS_SUCCESS) { printf("Failed test %d\n", count); rc++; } else if(globus_ftp_client_handle_destroy(&handle) != GLOBUS_SUCCESS) { printf("Failed test %d\n", count); rc++; } /* Test without attributes */ /* Test 12: create handle without attr */ count++; result = globus_ftp_client_handle_init(&handle, GLOBUS_NULL); if(result != GLOBUS_SUCCESS) { printf("Failed test %d\n", count); rc++; } /* Test 13: add restart plugin into handle */ count++; result = globus_ftp_client_handle_add_plugin(&handle, &restart_plugin); if(result != GLOBUS_SUCCESS) { printf("Failed test %d\n", count); rc++; } /* Test 14: add restart plugin into handle (fail) */ count++; result = globus_ftp_client_handle_add_plugin(&handle, &restart_plugin); if(result == GLOBUS_SUCCESS) { printf("Failed test %d\n", count); rc++; } /* Test 15: add debug plugin into handle */ count++; result = globus_ftp_client_handle_add_plugin(&handle, &debug_plugin); if(result != GLOBUS_SUCCESS) { printf("Failed test %d\n", count); rc++; } /* Test 16: remove restart plugin from handle */ count++; result = globus_ftp_client_handle_remove_plugin(&handle, &restart_plugin); if(result != GLOBUS_SUCCESS) { printf("Failed test %d\n", count); rc++; } /* Test 17: remove restart plugin from handle (fail) */ count++; result = globus_ftp_client_handle_remove_plugin(&handle, &restart_plugin); if(result == GLOBUS_SUCCESS) { printf("Failed test %d\n", count); rc++; } /* Test 18: add debug plugin into handle (fail) */ count++; result = globus_ftp_client_handle_add_plugin(&handle, &debug_plugin); if(result == GLOBUS_SUCCESS) { printf("Failed test %d\n", count); rc++; } /* Test 19: remove debug plugin into handle */ count++; result = globus_ftp_client_handle_remove_plugin(&handle, &debug_plugin); if(result != GLOBUS_SUCCESS) { printf("Failed test %d\n", count); rc++; } /* Test 20: remove restart plugin into handle (fail) */ count++; result = globus_ftp_client_handle_remove_plugin(&handle, &restart_plugin); if(result == GLOBUS_SUCCESS) { printf("Failed test %d\n", count); rc++; } /* Test 21: destroy handle */ count++; result = globus_ftp_client_handle_destroy(&handle); if(result != GLOBUS_SUCCESS) { printf("Failed test %d\n", count); rc++; } globus_module_deactivate_all(); return rc; }
int main(int argc, char **argv) { globus_ftp_client_handle_t handle; globus_ftp_client_operationattr_t attr; globus_result_t result; int i; globus_ftp_client_handleattr_t handle_attr; char * src; char * dst; LTDL_SET_PRELOADED_SYMBOLS(); globus_module_activate(GLOBUS_FTP_CLIENT_MODULE); globus_ftp_client_handleattr_init(&handle_attr); globus_ftp_client_operationattr_init(&attr); globus_mutex_init(&lock, GLOBUS_NULL); globus_cond_init(&cond, GLOBUS_NULL); test_parse_args(argc, argv, &handle_attr, &attr, &src, &dst); globus_ftp_client_handle_init(&handle, &handle_attr); globus_ftp_client_handle_cache_url_state(&handle, src); globus_ftp_client_handle_cache_url_state(&handle, dst); for (i = 0; i < 2; i++) { done = GLOBUS_FALSE; result = globus_ftp_client_third_party_transfer(&handle, src, &attr, dst, &attr, GLOBUS_NULL, done_cb, 0); if(result != GLOBUS_SUCCESS) { done = GLOBUS_TRUE; } globus_mutex_lock(&lock); while(!done) { globus_cond_wait(&cond, &lock); } globus_mutex_unlock(&lock); } globus_ftp_client_handle_destroy(&handle); globus_module_deactivate_all(); if(test_abort_count && error) { return 0; } return error; }
int main(int argc, char *argv[]) { globus_ftp_client_handle_t handle; globus_ftp_client_operationattr_t attr; globus_byte_t * buffer; globus_size_t buffer_length; globus_result_t result; char * src; char * dst; globus_ftp_client_handleattr_t handle_attr; globus_ftp_control_mode_t mode; int i; globus_ftp_control_parallelism_t parallelism; globus_module_activate(GLOBUS_FTP_CLIENT_MODULE); globus_ftp_client_handleattr_init(&handle_attr); globus_ftp_client_operationattr_init(&attr); parallelism.mode = GLOBUS_FTP_CONTROL_PARALLELISM_FIXED; parallelism.fixed.size = 1; mode = GLOBUS_FTP_CONTROL_MODE_STREAM; for(i = 1; i < argc; i++) { if(strcmp(argv[i], "-P") == 0 && i + 1 < argc) { mode = GLOBUS_FTP_CONTROL_MODE_EXTENDED_BLOCK; parallelism.mode = GLOBUS_FTP_CONTROL_PARALLELISM_FIXED; parallelism.fixed.size = atoi(argv[i+1]); test_remove_arg(&argc, argv, &i, 1); } } test_parse_args(argc, argv, &handle_attr, &attr, &src, &dst); buffer = globus_libc_malloc(SIZE); buffer_length = SIZE; globus_mutex_init(&lock, GLOBUS_NULL); globus_cond_init(&cond, GLOBUS_NULL); globus_ftp_client_operationattr_set_mode(&attr, mode); globus_ftp_client_operationattr_set_parallelism(&attr, ¶llelism); globus_ftp_client_operationattr_set_read_all(&attr, GLOBUS_TRUE, intermediate_cb, GLOBUS_NULL); globus_ftp_client_handle_init(&handle, &handle_attr); done = GLOBUS_FALSE; result = globus_ftp_client_get(&handle, src, &attr, GLOBUS_NULL, done_cb, 0); if(result != GLOBUS_SUCCESS) { fprintf(stderr, globus_object_printable_to_string(globus_error_get(result))); error = GLOBUS_TRUE; done = GLOBUS_TRUE; } else { globus_ftp_client_register_read( &handle, buffer, buffer_length, data_cb, 0); } globus_mutex_lock(&lock); while(!done) { globus_cond_wait(&cond, &lock); } globus_mutex_unlock(&lock); globus_ftp_client_handle_destroy(&handle); globus_libc_free(buffer); globus_module_deactivate_all(); if(test_abort_count && error) { return 0; } return error; }
void test_parse_args(int argc, char **argv, globus_ftp_client_handleattr_t * handle_attr, globus_ftp_client_operationattr_t * operation_attr, char **src, char **dst) { int c; extern char * optarg; extern int opterr; globus_reltime_t timeout; globus_ftp_client_plugin_t *plugin; globus_ftp_control_dcau_t dcau; globus_abstime_t deadline_time; globus_reltime_t interval_time; int max_retries; long interval; long deadline; char * subject; *src = GLOBUS_NULL; *dst = GLOBUS_NULL; setvbuf(stdout, 0, _IONBF, 0); #ifdef WIN32 _setmode(_fileno(stdin), _O_BINARY); _setmode(_fileno(stdout), _O_BINARY); _setmode(_fileno(stderr), _O_BINARY); #endif opterr = 0; while((c = getopt(argc, argv, "-f:a:ps:d:r:zMTc:t:i")) != -1) { switch(c) { case 'a': globus_module_activate(GLOBUS_FTP_CLIENT_TEST_ABORT_PLUGIN_MODULE); plugin = globus_libc_malloc(sizeof(globus_ftp_client_plugin_t)); globus_ftp_client_test_abort_plugin_init(plugin); if(atoi(optarg) >= FTP_ABORT_LAST || atoi(optarg) < 0) { printf("Abort plugin argument out of range\n"); globus_module_deactivate_all(); exit(1); } globus_ftp_client_test_abort_plugin_set_abort_point(plugin, atoi(optarg)); globus_ftp_client_test_abort_plugin_set_abort_counter( plugin, &test_abort_count); globus_ftp_client_handleattr_add_plugin(handle_attr, plugin); break; case 'p': plugin = globus_libc_malloc(sizeof(globus_ftp_client_plugin_t)); globus_module_activate(GLOBUS_FTP_CLIENT_DEBUG_PLUGIN_MODULE); globus_ftp_client_debug_plugin_init(plugin, stderr, "[Debug Plugin]"); globus_ftp_client_handleattr_add_plugin(handle_attr, plugin); break; case 'M': plugin = globus_libc_malloc(sizeof(globus_ftp_client_plugin_t)); globus_module_activate(GLOBUS_FTP_CLIENT_TEST_PERF_PLUGIN_MODULE); globus_ftp_client_test_perf_plugin_init(plugin); globus_ftp_client_handleattr_add_plugin(handle_attr, plugin); break; case 'T': plugin = globus_libc_malloc(sizeof(globus_ftp_client_plugin_t)); globus_module_activate(GLOBUS_FTP_CLIENT_TEST_THROUGHPUT_PLUGIN_MODULE); globus_ftp_client_test_throughput_plugin_init(plugin); globus_ftp_client_handleattr_add_plugin(handle_attr, plugin); break; case 'z': globus_module_activate(GLOBUS_FTP_CLIENT_TEST_PAUSE_PLUGIN_MODULE); plugin = globus_libc_malloc(sizeof(globus_ftp_client_plugin_t)); globus_ftp_client_test_pause_plugin_init(plugin); globus_ftp_client_handleattr_add_plugin(handle_attr, plugin); break; case 'r': globus_module_activate(GLOBUS_FTP_CLIENT_TEST_RESTART_PLUGIN_MODULE); plugin = globus_libc_malloc(sizeof(globus_ftp_client_plugin_t)); globus_ftp_client_test_restart_plugin_init(plugin); if(atoi(optarg) >= FTP_RESTART_LAST || atoi(optarg) < 0) { printf("Restart plugin argument out of range\n"); globus_module_deactivate_all(); exit(1); } else { char *p; p = strchr(optarg, ','); if(p) { GlobusTimeReltimeSet(timeout, atoi(p+1),0); } else { GlobusTimeReltimeSet(timeout, 0, 0); } globus_ftp_client_test_restart_plugin_set_restart_point( plugin, atoi(optarg), &timeout); globus_ftp_client_handleattr_add_plugin(handle_attr, plugin); } break; case 's': *src = optarg; break; case 'd': *dst = optarg; break; case 'c': if(!strcmp(optarg, "none")) { dcau.mode = GLOBUS_FTP_CONTROL_DCAU_NONE; globus_ftp_client_operationattr_set_dcau(operation_attr, &dcau); } else if(!strcmp(optarg, "self")) { dcau.mode = GLOBUS_FTP_CONTROL_DCAU_SELF; globus_ftp_client_operationattr_set_dcau(operation_attr, &dcau); } else { dcau.mode = GLOBUS_FTP_CONTROL_DCAU_SUBJECT; dcau.subject.subject = optarg; globus_ftp_client_operationattr_set_dcau(operation_attr, &dcau); } break; case 't': if(!strcmp(optarg, "clear")) { globus_ftp_client_operationattr_set_data_protection( operation_attr, GLOBUS_FTP_CONTROL_PROTECTION_CLEAR); } else if(!strcmp(optarg, "safe")) { globus_ftp_client_operationattr_set_data_protection( operation_attr, GLOBUS_FTP_CONTROL_PROTECTION_SAFE); } else if(!strcmp(optarg, "private")) { globus_ftp_client_operationattr_set_data_protection( operation_attr, GLOBUS_FTP_CONTROL_PROTECTION_PRIVATE); } break; case 'f': globus_module_activate(GLOBUS_FTP_CLIENT_RESTART_PLUGIN_MODULE); sscanf(optarg, "%d,%ld,%ld", &max_retries, &interval, &deadline); if(interval < 0.1) { GlobusTimeReltimeSet(interval_time, 0, 0); } else { GlobusTimeReltimeSet(interval_time, interval, 0); } deadline_time.tv_sec = deadline; deadline_time.tv_nsec = 0; plugin = globus_libc_malloc(sizeof(globus_ftp_client_plugin_t)); globus_ftp_client_restart_plugin_init(plugin, max_retries, &interval_time, &deadline_time); globus_ftp_client_handleattr_add_plugin(handle_attr, plugin); break; case 'i': globus_ftp_client_operationattr_set_control_protection( operation_attr, GLOBUS_FTP_CONTROL_PROTECTION_SAFE); break; case '?': /* globus_module_deactivate_all(); exit(0); */ break; } } subject = globus_libc_getenv("GLOBUS_FTP_CLIENT_TEST_SUBJECT"); if(subject) { globus_ftp_client_operationattr_set_authorization( operation_attr, GSS_C_NO_CREDENTIAL, ":globus-mapping:", "", GLOBUS_NULL, subject); } }
int main(int argc, char *argv[]) { globus_url_t url; int i; int result; globus_bool_t ok; int num_successful = 0; int rc; globus_module_activate(GLOBUS_COMMON_MODULE); globus_libc_printf("Testing globus_url_parse()\n"); if(argc > 1) { globus_libc_printf("Bypassing standard tests, parsing command line arguments\n"); for(i = 1; i < argc; i++) { globus_libc_printf("Parsing \"%s\"\n", argv[i]); result = globus_url_parse(argv[i], &url); globus_libc_printf("Parse returned %d\n", result); if(result == GLOBUS_SUCCESS) { #define printable_string(x) (x==GLOBUS_NULL ? "NULL" : x) globus_libc_printf("url_scheme = \"%s\"\n" "url_scheme_type = %d\n" "user = \"%s\"\n" "password = \"%s\"\n" "host = \"%s\"\n" "port = %u\n" "url_path = \"%s\"\n" "dn = \"%s\"\n" "attributes = \"%s\"\n" "scope = \"%s\"\n" "filter = \"%s\"\n" "url_specific_part = \"%s\"\n", printable_string(url.scheme), url.scheme_type, printable_string(url.user), printable_string(url.password), printable_string(url.host), url.port, printable_string(url.url_path), printable_string(url.dn), printable_string(url.attributes), printable_string(url.scope), printable_string(url.filter), printable_string(url.url_specific_part)); result = globus_url_destroy(&url); globus_libc_printf("globus_url_destroy returned %d\n", result); } } globus_module_deactivate_all(); return 0; } for(i = 0; i < NUM_TESTS; i++) { ok = GLOBUS_TRUE; result = globus_url_parse(test_urls[i].url, &url); if(result != test_urls[i].result) { globus_libc_printf( "test %d: FAILED (url=%s, expected %d, parse returned %d)\n", i+1, test_urls[i].url, test_urls[i].result, result); ok = GLOBUS_FALSE; } if(test_urls[i].result == GLOBUS_SUCCESS) { /* Verify that parse did what we wanted it to do */ if(!compare_strings(url.scheme, test_urls[i].url_result.scheme, i+1, "scheme")) { ok = GLOBUS_FALSE; } if(!compare_ints(url.scheme_type, test_urls[i].url_result.scheme_type, i+1, "scheme_type")) { ok = GLOBUS_FALSE; } if(!compare_strings(url.user, test_urls[i].url_result.user, i+1, "user")) { ok = GLOBUS_FALSE; } if(!compare_strings(url.password, test_urls[i].url_result.password, i+1, "password")) { ok = GLOBUS_FALSE; } if(!compare_strings(url.host, test_urls[i].url_result.host, i+1, "host")) { ok = GLOBUS_FALSE; } if(!compare_ints((int) url.port, (int) test_urls[i].url_result.port, i+1, "port")) { ok = GLOBUS_FALSE; } if(!compare_strings(url.url_path, test_urls[i].url_result.url_path, i+1, "url_path")) { ok = GLOBUS_FALSE; } if(!compare_strings(url.dn, test_urls[i].url_result.dn, i+1, "dn")) { ok = GLOBUS_FALSE; } if(!compare_strings(url.attributes, test_urls[i].url_result.attributes, i+1, "attributes")) { ok = GLOBUS_FALSE; } if(!compare_strings(url.scope, test_urls[i].url_result.scope, i+1, "scope")) { ok = GLOBUS_FALSE; } if(!compare_strings(url.filter, test_urls[i].url_result.filter, i+1, "filter")) { ok = GLOBUS_FALSE; } if(!compare_strings(url.url_specific_part, test_urls[i].url_result.url_specific_part, i+1, "url_specific_part")) { ok = GLOBUS_FALSE; } result = globus_url_destroy(&url); if(result != GLOBUS_SUCCESS) { globus_libc_printf( "test %d: FAILED (could not destroy parsed url)\n", i+1); ok = GLOBUS_FALSE; } } if(ok) { num_successful++; } } globus_libc_printf("------------------------------------\n"); if(num_successful == i) { globus_libc_printf("ALL TESTS SUCCESSFUL\n"); } else { globus_libc_printf("%d OF %d TESTS FAILED\n", i - num_successful, i); } globus_libc_printf("------------------------------------\n"); rc = (num_successful == i) ? 0 : 1; globus_module_deactivate_all(); return rc; }
int main(int argc, char *argv[]) { globus_ftp_client_handle_t handle; globus_ftp_client_operationattr_t attr; globus_ftp_client_handleattr_t handle_attr; globus_byte_t buffer[SIZE]; globus_size_t buffer_length = sizeof(buffer); globus_result_t result; globus_off_t size; char * src; char * dst; LTDL_SET_PRELOADED_SYMBOLS(); globus_module_activate(GLOBUS_FTP_CLIENT_MODULE); globus_ftp_client_handleattr_init(&handle_attr); globus_ftp_client_operationattr_init(&attr); test_parse_args(argc, argv, &handle_attr, &attr, &src, &dst); globus_mutex_init(&lock, GLOBUS_NULL); globus_cond_init(&cond, GLOBUS_NULL); globus_ftp_client_handle_init(&handle, &handle_attr); done = GLOBUS_FALSE; result = globus_ftp_client_size(&handle, src, &attr, &size, done_cb, 0); if(result != GLOBUS_SUCCESS) { fprintf(stderr, "%s", globus_object_printable_to_string(globus_error_get(result))); error = GLOBUS_TRUE; done = GLOBUS_TRUE; } globus_mutex_lock(&lock); while(!done) { globus_cond_wait(&cond, &lock); } globus_mutex_unlock(&lock); globus_ftp_client_handle_destroy(&handle); globus_module_deactivate_all(); if(test_abort_count && error) { return 0; } if(error == GLOBUS_SUCCESS) { printf("%"GLOBUS_OFF_T_FORMAT"\n", size); } return error; }
int main(int argc, char **argv) { globus_ftp_client_handle_t handle; globus_ftp_client_operationattr_t attr; globus_byte_t * buffer; globus_result_t result; globus_ftp_client_handleattr_t handle_attr; char * src; char * dst; int i; globus_size_t parallelism_level = 1; globus_ftp_control_parallelism_t parallelism; globus_ftp_control_layout_t layout; LTDL_SET_PRELOADED_SYMBOLS(); globus_module_activate(GLOBUS_FTP_CLIENT_MODULE); globus_ftp_client_handleattr_init(&handle_attr); globus_ftp_client_operationattr_init(&attr); /* Parse local arguments */ for(i = 1; i < argc; i++) { if(strcmp(argv[i], "-P") == 0 && i + 1 < argc) { parallelism_level = atoi(argv[i+1]); test_remove_arg(&argc, argv, &i, 1); } } test_parse_args(argc, argv, &handle_attr, &attr, &src, &dst); if(parallelism_level < 1) { parallelism_level = 1; } parallelism.mode = GLOBUS_FTP_CONTROL_PARALLELISM_FIXED; parallelism.fixed.size = parallelism_level; layout.mode = GLOBUS_FTP_CONTROL_STRIPING_BLOCKED_ROUND_ROBIN; layout.round_robin.block_size = 64*1024; globus_mutex_init(&lock, GLOBUS_NULL); globus_cond_init(&cond, GLOBUS_NULL); globus_ftp_client_operationattr_set_mode( &attr, GLOBUS_FTP_CONTROL_MODE_EXTENDED_BLOCK); globus_ftp_client_operationattr_set_parallelism(&attr, ¶llelism); globus_ftp_client_operationattr_set_layout(&attr, &layout); globus_ftp_client_handle_init(&handle, &handle_attr); done = GLOBUS_FALSE; result = globus_ftp_client_put(&handle, dst, &attr, GLOBUS_NULL, done_cb, 0); globus_mutex_lock(&lock); if(result != GLOBUS_SUCCESS) { globus_object_t * err; err = globus_error_get(result); fprintf(stderr, "%s", globus_object_printable_to_string(err)); done = GLOBUS_TRUE; } else { int rc=1; int i; for(i = 0; i < parallelism_level && rc != 0; i++) { buffer = malloc(MYSIZE); rc = read(0, buffer, MYSIZE); globus_ftp_client_register_write( &handle, buffer, rc, global_offset, rc == 0, data_cb, 0); global_offset += rc; } } while(!done) { globus_cond_wait(&cond, &lock); } globus_mutex_unlock(&lock); globus_ftp_client_handle_destroy(&handle); globus_module_deactivate_all(); if(test_abort_count && error) { return 0; } return error; }
int main(int argc, char *argv[]) { int rc; globus_result_t result; char modname[] = "load_test_module"; char * globus_loc = NULL; int notok=3; printf("1..3\n"); rc = globus_module_activate(GLOBUS_SCHEDULER_EVENT_GENERATOR_MODULE); if (rc != GLOBUS_SUCCESS) { goto error; } result = globus_location(&globus_loc); if (result != GLOBUS_SUCCESS) { rc = 1; goto error; } result = globus_scheduler_event_generator_load_module(modname); if (result != GLOBUS_SUCCESS) { fprintf(stderr, "# Load %s returned %s\n", modname, globus_error_print_friendly(globus_error_peek(result))); rc = 1; goto deactivate_error; } notok--; globus_module_deactivate_all(); notok--; rc = globus_module_activate(GLOBUS_SCHEDULER_EVENT_GENERATOR_MODULE); if (rc != GLOBUS_SUCCESS) { goto error; } result = globus_scheduler_event_generator_load_module("bogus"); if (result == GLOBUS_SUCCESS) { rc = 1; goto deactivate_error; } printf("ok - module load\n"); notok--; deactivate_error: globus_module_deactivate_all(); error: if (rc != 0) { while (notok-- > 0) { printf("not ok\n"); } } return rc; }
int gsiftp_put(char *filename, FILE **gsiftpfile, int num_streams) { int i; char gsiurl[MAXLEN]; globus_ftp_client_handle_t handle; globus_ftp_client_operationattr_t attr; globus_ftp_client_handleattr_t handle_attr; globus_ftp_control_parallelism_t parallelism; globus_ftp_control_layout_t layout; globus_byte_t * buffer; globus_size_t buffer_length = sizeof(buffer); globus_result_t result; globus_ftp_client_restart_marker_t restart; globus_ftp_control_type_t filetype; globus_module_activate(GLOBUS_FTP_CLIENT_MODULE); globus_mutex_init(&lock, GLOBUS_NULL); globus_cond_init(&cond, GLOBUS_NULL); globus_ftp_client_handle_init(&handle, GLOBUS_NULL); globus_ftp_client_handleattr_init(&handle_attr); globus_ftp_client_operationattr_init(&attr); layout.mode = GLOBUS_FTP_CONTROL_STRIPING_NONE; globus_ftp_client_restart_marker_init(&restart); globus_ftp_client_operationattr_set_mode( &attr, GLOBUS_FTP_CONTROL_MODE_EXTENDED_BLOCK); if (num_streams >= 1) { parallelism.mode = GLOBUS_FTP_CONTROL_PARALLELISM_FIXED; parallelism.fixed.size = num_streams; globus_ftp_client_operationattr_set_parallelism( &attr, ¶llelism); } globus_ftp_client_operationattr_set_layout(&attr, &layout); filetype = GLOBUS_FTP_CONTROL_TYPE_IMAGE; globus_ftp_client_operationattr_set_type (&attr, filetype); globus_ftp_client_handle_init(&handle, &handle_attr); done = GLOBUS_FALSE; strcpy(gsiurl,"gsiftp://"); if (strlen(gsiurl)+strlen(filename) > MAXLEN-1) { ffpmsg("file name too long (gsiftp_put)"); return (FILE_NOT_OPENED); } strcat(gsiurl,filename); *gsiftpfile = fopen(gsiftp_tmpfile,"r"); if (!*gsiftpfile) { ffpmsg("Unable to open temporary file!"); return (FILE_NOT_OPENED); } result = globus_ftp_client_put(&handle, gsiurl, &attr, &restart, done_cb, 0); if(result != GLOBUS_SUCCESS) { globus_object_t * err; err = globus_error_get(result); fprintf(stderr, "%s", globus_object_printable_to_string(err)); done = GLOBUS_TRUE; } else { int rc; int curr_offset; for (i = 0; i< 2 * num_streams && feof(*gsiftpfile) == 0; i++) { buffer = malloc(MAX_BUFFER_SIZE_W); globus_mutex_lock(&lock); curr_offset = global_offset; rc = fread(buffer, 1, MAX_BUFFER_SIZE_W, *gsiftpfile); global_offset += rc; globus_mutex_unlock(&lock); globus_ftp_client_register_write( &handle, buffer, rc, curr_offset, feof(*gsiftpfile) != 0, data_cb_write, (void*) *gsiftpfile); } } globus_mutex_lock(&lock); while(!done) { globus_cond_wait(&cond, &lock); } globus_mutex_unlock(&lock); globus_ftp_client_handle_destroy(&handle); globus_module_deactivate_all(); return 0; }
int main() { OM_uint32 init_maj_stat; OM_uint32 accept_maj_stat; OM_uint32 maj_stat; OM_uint32 min_stat; OM_uint32 ret_flags; OM_uint32 req_flags = 0; OM_uint32 time_rec; gss_buffer_desc send_tok; gss_buffer_desc recv_tok; gss_buffer_desc * token_ptr; gss_OID mech_type; gss_name_t target_name; gss_ctx_id_t init_context; gss_ctx_id_t accept_context; gss_ctx_id_t del_init_context; gss_ctx_id_t del_accept_context; gss_cred_id_t delegated_cred; gss_cred_id_t imported_cred; gss_cred_id_t cred_handle; char * error_str; int rc = EXIT_SUCCESS; printf("1..1\n"); /* Initialize variables */ token_ptr = GSS_C_NO_BUFFER; init_context = GSS_C_NO_CONTEXT; accept_context = GSS_C_NO_CONTEXT; del_init_context = GSS_C_NO_CONTEXT; del_accept_context = GSS_C_NO_CONTEXT; delegated_cred = GSS_C_NO_CREDENTIAL; accept_maj_stat = GSS_S_CONTINUE_NEEDED; ret_flags = 0; req_flags |= GSS_C_GLOBUS_SSL_COMPATIBLE; /* Activate Modules */ globus_module_activate(GLOBUS_GSI_GSS_ASSIST_MODULE); globus_module_activate(GLOBUS_GSI_GSSAPI_MODULE); maj_stat = gss_acquire_cred(&min_stat, NULL, GSS_C_INDEFINITE, GSS_C_NO_OID_SET, GSS_C_BOTH, &cred_handle, NULL, NULL); if(maj_stat != GSS_S_COMPLETE) { globus_gss_assist_display_status_str(&error_str, NULL, maj_stat, min_stat, 0); printf("\nLINE %d ERROR: %s\n\n", __LINE__, error_str); globus_print_error((globus_result_t) min_stat); rc = EXIT_FAILURE; goto fail; } /* get the subject name */ maj_stat = gss_inquire_cred(&min_stat, cred_handle, &target_name, NULL, NULL, NULL); if(maj_stat != GSS_S_COMPLETE) { globus_gss_assist_display_status_str(&error_str, NULL, maj_stat, min_stat, 0); fprintf(stderr, "\nLINE %d ERROR: %s\n\n", __LINE__, error_str); globus_print_error((globus_result_t) min_stat); rc = EXIT_FAILURE; goto fail; } /* set up the first security context */ init_maj_stat = gss_init_sec_context(&min_stat, cred_handle, &init_context, target_name, GSS_C_NULL_OID, 0, 0, GSS_C_NO_CHANNEL_BINDINGS, token_ptr, NULL, &send_tok, NULL, NULL); if(init_maj_stat != GSS_S_CONTINUE_NEEDED) { globus_gss_assist_display_status_str(&error_str, NULL, init_maj_stat, min_stat, 0); fprintf(stderr, "\nLINE %d ERROR: %s\n\n", __LINE__, error_str); globus_print_error((globus_result_t) min_stat); rc = EXIT_FAILURE; goto fail; } while(1) { accept_maj_stat=gss_accept_sec_context(&min_stat, &accept_context, GSS_C_NO_CREDENTIAL, &send_tok, GSS_C_NO_CHANNEL_BINDINGS, NULL, &mech_type, &recv_tok, &ret_flags, /* ignore time_rec */ NULL, NULL); if(accept_maj_stat != GSS_S_COMPLETE && accept_maj_stat != GSS_S_CONTINUE_NEEDED) { globus_gss_assist_display_status_str(&error_str, NULL, init_maj_stat, min_stat, 0); fprintf(stderr, "\nLINE %d ERROR: %s\n\n", __LINE__, error_str); globus_print_error((globus_result_t) min_stat); rc = EXIT_FAILURE; goto fail; } else if(accept_maj_stat == GSS_S_COMPLETE) { break; } init_maj_stat = gss_init_sec_context(&min_stat, GSS_C_NO_CREDENTIAL, &init_context, target_name, GSS_C_NULL_OID, 0, 0, GSS_C_NO_CHANNEL_BINDINGS, &recv_tok, NULL, &send_tok, NULL, NULL); if(init_maj_stat != GSS_S_COMPLETE && init_maj_stat != GSS_S_CONTINUE_NEEDED) { globus_gss_assist_display_status_str(&error_str, NULL, init_maj_stat, min_stat, 0); fprintf(stderr, "\nLINE %d ERROR: %s\n\n", __LINE__, error_str); globus_print_error((globus_result_t) min_stat); rc = EXIT_FAILURE; goto fail; } } printf("# %s:%d: Successfully established initial security context\n", __FILE__, __LINE__); init_maj_stat = gss_init_delegation(&min_stat, init_context, cred_handle, GSS_C_NO_OID, GSS_C_NO_OID_SET, GSS_C_NO_BUFFER_SET, token_ptr, req_flags, 0, &send_tok); if(init_maj_stat != GSS_S_COMPLETE && init_maj_stat != GSS_S_CONTINUE_NEEDED) { globus_gss_assist_display_status_str(&error_str, NULL, init_maj_stat, min_stat, 0); fprintf(stderr, "\nLINE %d ERROR: %s\n\n", __LINE__, error_str); globus_print_error((globus_result_t) min_stat); rc = EXIT_FAILURE; goto fail; } internal_release_buffer(&recv_tok); maj_stat = gss_wrap(&min_stat, init_context, 0, GSS_C_QOP_DEFAULT, &send_tok, NULL, &recv_tok); if(maj_stat != GSS_S_COMPLETE) { globus_gss_assist_display_status_str(&error_str, NULL, maj_stat, min_stat, 0); fprintf(stderr, "\nLINE %d ERROR: %s\n\n", __LINE__, error_str); globus_print_error((globus_result_t) min_stat); rc = EXIT_FAILURE; goto fail; } while(1) { internal_release_buffer(&send_tok); maj_stat = gss_unwrap(&min_stat, accept_context, &recv_tok, &send_tok, NULL, NULL); if(maj_stat != GSS_S_COMPLETE) { globus_gss_assist_display_status_str(&error_str, NULL, maj_stat, min_stat, 0); fprintf(stderr, "\nLINE %d ERROR: %s\n\n", __LINE__, error_str); globus_print_error((globus_result_t) min_stat); rc = EXIT_FAILURE; goto fail; } internal_release_buffer(&recv_tok); accept_maj_stat=gss_accept_delegation(&min_stat, accept_context, GSS_C_NO_OID_SET, GSS_C_NO_BUFFER_SET, &send_tok, req_flags, 0, &time_rec, &delegated_cred, &mech_type, &recv_tok); if(accept_maj_stat != GSS_S_COMPLETE && accept_maj_stat != GSS_S_CONTINUE_NEEDED) { globus_gss_assist_display_status_str(&error_str, NULL, init_maj_stat, min_stat, 0); fprintf(stderr, "\nLINE %d ERROR: %s\n\n", __LINE__, error_str); globus_print_error((globus_result_t) min_stat); rc = EXIT_FAILURE; goto fail; } else if(accept_maj_stat == GSS_S_COMPLETE) { break; } internal_release_buffer(&send_tok); maj_stat = gss_wrap(&min_stat, accept_context, 0, GSS_C_QOP_DEFAULT, &recv_tok, NULL, &send_tok); if(maj_stat != GSS_S_COMPLETE) { globus_gss_assist_display_status_str(&error_str, NULL, maj_stat, min_stat, 0); fprintf(stderr, "\nLINE %d ERROR: %s\n\n", __LINE__, error_str); globus_print_error((globus_result_t) min_stat); rc = EXIT_FAILURE; goto fail; } internal_release_buffer(&recv_tok); maj_stat = gss_unwrap(&min_stat, init_context, &send_tok, &recv_tok, NULL, NULL); if(maj_stat != GSS_S_COMPLETE) { globus_gss_assist_display_status_str(&error_str, NULL, maj_stat, min_stat, 0); fprintf(stderr, "\nLINE %d ERROR: %s\n\n", __LINE__, error_str); globus_print_error((globus_result_t) min_stat); rc = EXIT_FAILURE; goto fail; } internal_release_buffer(&send_tok); init_maj_stat = gss_init_delegation(&min_stat, init_context, cred_handle, GSS_C_NO_OID, GSS_C_NO_OID_SET, GSS_C_NO_BUFFER_SET, &recv_tok, req_flags, 0, &send_tok); if(init_maj_stat != GSS_S_COMPLETE && init_maj_stat != GSS_S_CONTINUE_NEEDED) { globus_gss_assist_display_status_str(&error_str, NULL, init_maj_stat, min_stat, 0); fprintf(stderr, "\nLINE %d ERROR: %s\n\n", __LINE__, error_str); globus_print_error((globus_result_t) min_stat); rc = EXIT_FAILURE; goto fail; } internal_release_buffer(&recv_tok); maj_stat = gss_wrap(&min_stat, init_context, 0, GSS_C_QOP_DEFAULT, &send_tok, NULL, &recv_tok); if(maj_stat != GSS_S_COMPLETE) { globus_gss_assist_display_status_str(&error_str, NULL, maj_stat, min_stat, 0); fprintf(stderr, "\nLINE %d ERROR: %s\n\n", __LINE__, error_str); globus_print_error((globus_result_t) min_stat); rc = EXIT_FAILURE; goto fail; } } printf("# %s:%d: Successfully delegated credential\n", __FILE__, __LINE__); /* export and import the delegated credential */ /* this can be done both to a buffer and to a file */ /* New in GT 2.0 */ internal_release_buffer(&send_tok); maj_stat = gss_export_cred(&min_stat, delegated_cred, GSS_C_NO_OID, 0, &send_tok); if(maj_stat != GSS_S_COMPLETE) { globus_gss_assist_display_status_str(&error_str, NULL, init_maj_stat, min_stat, 0); fprintf(stderr, "\nLINE %d ERROR: %s\n\n", __LINE__, error_str); globus_print_error((globus_result_t) min_stat); rc = EXIT_FAILURE; goto fail; } maj_stat = gss_import_cred(&min_stat, &imported_cred, GSS_C_NO_OID, 0, &send_tok, 0, &time_rec); if(maj_stat != GSS_S_COMPLETE) { globus_gss_assist_display_status_str(&error_str, NULL, init_maj_stat, min_stat, 0); fprintf(stderr, "\nLINE %d ERROR: %s\n\n", __LINE__, error_str); globus_print_error((globus_result_t) min_stat); rc = EXIT_FAILURE; goto fail; } internal_release_buffer(&send_tok); printf("# %s:%d: Successfully exported/imported the delegated credential\n", __FILE__, __LINE__); /* set up another security context using the delegated credential */ init_maj_stat = gss_init_sec_context(&min_stat, imported_cred, &del_init_context, target_name, GSS_C_NULL_OID, 0, 0, GSS_C_NO_CHANNEL_BINDINGS, token_ptr, NULL, &send_tok, NULL, NULL); if(init_maj_stat != GSS_S_COMPLETE && init_maj_stat != GSS_S_CONTINUE_NEEDED) { globus_gss_assist_display_status_str(&error_str, NULL, init_maj_stat, min_stat, 0); fprintf(stderr, "\nLINE %d ERROR: %s\n\n", __LINE__, error_str); globus_print_error((globus_result_t) min_stat); rc = EXIT_FAILURE; goto fail; } while(1) { internal_release_buffer(&recv_tok); accept_maj_stat=gss_accept_sec_context(&min_stat, &del_accept_context, imported_cred, &send_tok, GSS_C_NO_CHANNEL_BINDINGS, &target_name, &mech_type, &recv_tok, &ret_flags, /* ignore time_rec */ NULL, NULL); if(accept_maj_stat != GSS_S_COMPLETE && accept_maj_stat != GSS_S_CONTINUE_NEEDED) { globus_gss_assist_display_status_str(&error_str, NULL, init_maj_stat, min_stat, 0); fprintf(stderr, "\nLINE %d ERROR: %s\n\n", __LINE__, error_str); globus_print_error((globus_result_t) min_stat); rc = EXIT_FAILURE; goto fail; } else if(accept_maj_stat == GSS_S_COMPLETE) { break; } init_maj_stat = gss_init_sec_context(&min_stat, imported_cred, &del_init_context, target_name, GSS_C_NULL_OID, 0, 0, GSS_C_NO_CHANNEL_BINDINGS, &recv_tok, NULL, &send_tok, NULL, NULL); if(init_maj_stat != GSS_S_COMPLETE && init_maj_stat != GSS_S_CONTINUE_NEEDED) { globus_gss_assist_display_status_str(&error_str, NULL, init_maj_stat, min_stat, 0); fprintf(stderr, "\nLINE %d ERROR: %s\n\n", __LINE__, error_str); globus_print_error((globus_result_t) min_stat); rc = EXIT_FAILURE; goto fail; } } /* got sec context based on delegated cred now */ printf("# %s:%d: Successfully established security context with delegated credential\n", __FILE__, __LINE__); fail: printf("%s gssapi_delegation_compat_test\n", (rc == EXIT_SUCCESS) ? "ok" : "not ok"); globus_module_deactivate_all(); exit(rc); }
int main( int argc, char ** argv) { int rc = 0; globus_result_t result; char * cs; globus_xio_contact_t parsed_contact; char * new_banner; char * old_banner; GlobusGFSName(main); /* activte globus stuff */ if((rc = globus_module_activate(GLOBUS_COMMON_MODULE)) != GLOBUS_SUCCESS || (rc = globus_module_activate( GLOBUS_GRIDFTP_SERVER_MODULE)) != GLOBUS_SUCCESS) { fprintf(stderr, "Error: Failed to initialize:\n%s", globus_error_print_friendly(globus_error_peek(rc))); goto error_activate; } /* initialize global variables */ globus_mutex_init(&globus_l_gfs_mutex, GLOBUS_NULL); globus_cond_init(&globus_l_gfs_cond, GLOBUS_NULL); globus_l_gfs_signal_init(); globus_libc_printf("Embedded server starting.\n"); globus_mutex_lock(&globus_l_gfs_mutex); { result = globus_gridftp_server_embed_init( &globus_l_gfs_server_handle, argv); if(result != GLOBUS_SUCCESS) { rc = 1; goto error_lock; } /* add our acl module */ globus_gfs_acl_add_module(&globus_gfs_acl_test_module); /* customize some config */ old_banner = globus_gridftp_server_embed_config_get_string( globus_l_gfs_server_handle, "banner"); new_banner = globus_common_create_string( "%s\nEMBEDDED", old_banner); globus_gridftp_server_embed_config_set_ptr( globus_l_gfs_server_handle, "banner", new_banner); globus_free(old_banner); globus_gridftp_server_embed_config_set_int( globus_l_gfs_server_handle, "connections_max", 10); globus_gridftp_server_embed_config_set_int( globus_l_gfs_server_handle, "auth_level", 1 | /* identity check */ 2 | /* file access checks */ 4 | /* disable setuid (not really needed with gridmap disabled)*/ 8); /* disable gridmap lookup */ result = globus_gridftp_server_embed_start( globus_l_gfs_server_handle, globus_l_gfs_event_cb, NULL); if(result != GLOBUS_SUCCESS) { rc = 1; goto error_lock; } globus_l_gfs_server_active = GLOBUS_TRUE; cs = globus_gridftp_server_embed_config_get_string( globus_l_gfs_server_handle, "contact_string"); globus_xio_contact_parse(&parsed_contact, cs); globus_libc_printf( "Server listening on port %s.\n", parsed_contact.port); globus_xio_contact_destroy(&parsed_contact); /* run until we are done */ while(!globus_l_gfs_terminated || globus_l_gfs_server_active) { globus_cond_wait(&globus_l_gfs_cond, &globus_l_gfs_mutex); } } globus_mutex_unlock(&globus_l_gfs_mutex); globus_module_deactivate_all(); GlobusGFSDebugExit(); return 0; error_lock: globus_mutex_unlock(&globus_l_gfs_mutex); error_activate: globus_module_deactivate_all(); GlobusGFSDebugExitWithError(); return rc; }
int main() { gss_cred_id_t credential; int listen_fd; int accept_fd; struct sockaddr_in address = {0}; globus_sockaddr_t connect_address; globus_socklen_t connect_address_len = sizeof(connect_address); struct thread_arg * arg = NULL; globus_thread_t thread_handle; int i; int ret; int error; LTDL_SET_PRELOADED_SYMBOLS(); globus_thread_set_model(THREAD_MODEL); globus_module_activate(GLOBUS_COMMON_MODULE); globus_module_activate(GLOBUS_GSI_GSSAPI_MODULE); printf("1..%d\n", NUM_CLIENTS); /* initialize global mutex */ globus_mutex_init(&mutex, NULL); /* and the condition variable */ globus_cond_init(&done, NULL); /* setup listener */ address.sin_family = AF_INET; address.sin_port = 0; address.sin_addr.s_addr = htonl(INADDR_LOOPBACK); listen_fd = socket(AF_INET, SOCK_STREAM, 0); if (listen_fd == 0) { perror("socket"); exit(EXIT_FAILURE); } ret = bind(listen_fd, (struct sockaddr *) &address, sizeof(struct sockaddr_in)); if (ret != 0) { perror("bind"); exit(EXIT_FAILURE); } ret = getsockname(listen_fd, (struct sockaddr *) &connect_address, &connect_address_len); if (ret != 0) { perror("getsockname"); exit(EXIT_FAILURE); } ret = listen(listen_fd, -1); if (ret != 0) { perror("listen"); exit(EXIT_FAILURE); } /* acquire credentials */ credential = globus_gsi_gssapi_test_acquire_credential(); if(credential == GSS_C_NO_CREDENTIAL) { fprintf(stderr,"Unable to aquire credential\n"); exit(-1); } /* start the clients here */ for(i=0;i<NUM_CLIENTS;i++) { arg = malloc(sizeof(struct thread_arg)); arg->address = &connect_address; arg->len = connect_address_len; arg->credential = credential; globus_mutex_lock(&mutex); { client_thread_count++; } globus_mutex_unlock(&mutex); globus_thread_create(&thread_handle,NULL,client_func,(void *) arg); } /* accept connections */ globus_mutex_lock(&mutex); while (client_thread_count > 0) { while (pending_connects > 0) { accept_fd = accept(listen_fd,NULL,0); if(accept_fd < 0) { perror("accept"); abort(); } arg = malloc(sizeof(struct thread_arg)); arg->fd = accept_fd; arg->credential = credential; server_thread_count++; pending_connects--; globus_thread_create(&thread_handle,NULL,server_func,(void *) arg); } globus_cond_wait(&done, &mutex); } /* wait for last thread to terminate */ while (server_thread_count > 0) { globus_cond_wait(&done, &mutex); } globus_mutex_unlock(&mutex); /* destroy global mutex */ globus_mutex_destroy(&mutex); /* and the condition variable */ globus_cond_destroy(&done); /* close the listener */ close(listen_fd); /* release credentials */ globus_gsi_gssapi_test_release_credential(&credential); globus_module_deactivate_all(); exit(client_failed); }
int main( int argc, char * argv[]) { int rc; globus_bool_t server = GLOBUS_FALSE; char gets_buffer[1024]; http_test_info_t * info; performance_t perf; info = (http_test_info_t *) globus_malloc(sizeof(http_test_info_t)); info->version = GLOBUS_XIO_HTTP_VERSION_UNSET; info->transfer_encoding = NULL; info->iterations = 100; info->temp_iterations = 100; info->size = 0; info->contact = NULL; while ((rc = getopt(argc, argv, "h:cst:b:v:i:")) != EOF) { switch (rc) { case 'h': usage(argv[0]); exit(0); case 'c': server = GLOBUS_FALSE; info->contact = fgets(gets_buffer, sizeof(gets_buffer), stdin); break; case 's': server = GLOBUS_TRUE; info->contact = NULL; break; case 't': if ((strcmp(optarg, CHUNKED) == 0) || (strcmp(optarg, IDENTITY) == 0)) { info->transfer_encoding = optarg; } else { usage(argv[0]); exit(1); } break; case 'b': sscanf(optarg, "%zd", &info->size); if (rc != 1) { usage(argv[0]); exit(1); } break; case 'v': if (strcmp(optarg, HTTP_1_0) == 0) { info->version = GLOBUS_XIO_HTTP_VERSION_1_0; } else if (strcmp(optarg, HTTP_1_1) == 0) { info->version = GLOBUS_XIO_HTTP_VERSION_1_1; } else { usage(argv[0]); exit(1); } break; case 'i': info->iterations = atoi(optarg); if (info->iterations <= 0) { usage(argv[0]); exit(1); } info->temp_iterations = info->iterations; break; default: usage(argv[0]); exit(1); } } if ((!server) && (info->contact == NULL)) { usage(argv[0]); exit(1); } if (info->iterations > 1 && info->version == GLOBUS_XIO_HTTP_VERSION_1_0) { fprintf(stderr, "Can't have multiple iterations with HTTP/1.0 server\n"); usage(argv[0]); exit(1); } rc = http_test_initialize( &info->tcp_driver, &info->http_driver, &info->stack); if (rc != 0) { goto error_exit; } if (server) { performance_init( &perf, server_test, throughput_next_size, info->iterations, "throughput-globus-xio-http", info->size); performance_start_slave(&perf, info); } else { performance_init( &perf, client_test, throughput_next_size, info->iterations, "throughput-globus-xio-http", info->size); rc = performance_start_master(&perf, info); if (rc != 0) { goto error_exit; } performance_write_timers(&perf); } globus_xio_stack_destroy(info->stack); globus_xio_driver_unload(info->tcp_driver); globus_xio_driver_unload(info->http_driver); globus_module_deactivate_all(); error_exit: if (rc == 0) { printf("Success\n"); } else { printf("Error\n"); } return rc; }
int main(int argc, char *argv[]) { globus_ftp_client_handle_t handle; globus_ftp_client_operationattr_t attr; globus_byte_t buffer[SIZE]; globus_size_t buffer_length = sizeof(buffer); globus_result_t result; char * src; char * dst; globus_ftp_client_handleattr_t handle_attr; globus_ftp_control_layout_t layout; globus_ftp_control_parallelism_t parallelism; int i; globus_ftp_client_restart_marker_t restart; LTDL_SET_PRELOADED_SYMBOLS(); globus_module_activate(GLOBUS_FTP_CLIENT_MODULE); globus_ftp_client_handleattr_init(&handle_attr); globus_ftp_client_operationattr_init(&attr); layout.mode = GLOBUS_FTP_CONTROL_STRIPING_NONE; parallelism.mode = GLOBUS_FTP_CONTROL_PARALLELISM_NONE; globus_ftp_client_restart_marker_init(&restart); /* Parse local arguments */ for(i = 1; i < argc; i++) { if(strcmp(argv[i], "-S") == 0 && i < argc) { layout.mode = GLOBUS_FTP_CONTROL_STRIPING_BLOCKED_ROUND_ROBIN; layout.round_robin.block_size = 15; test_remove_arg(&argc, argv, &i, 0); } else if(strcmp(argv[i], "-P") == 0 && i + 1 < argc) { parallelism.mode = GLOBUS_FTP_CONTROL_PARALLELISM_FIXED; parallelism.fixed.size = atoi(argv[i+1]); test_remove_arg(&argc, argv, &i, 1); } else if(strcmp(argv[i], "-R") == 0 && i+1 < argc) { char * p; globus_off_t offset, end; int bytes; p = argv[i+1]; while((*p) && (sscanf(p, "%"GLOBUS_OFF_T_FORMAT "-%"GLOBUS_OFF_T_FORMAT"%n", &offset, &end, &bytes) >= 2)) { globus_ftp_client_restart_marker_insert_range( &restart, offset, end); p += bytes; if(*p && *p == ',') p++; } test_remove_arg(&argc, argv, &i, 1); } } test_parse_args(argc, argv, &handle_attr, &attr, &src, &dst); globus_mutex_init(&lock, GLOBUS_NULL); globus_cond_init(&cond, GLOBUS_NULL); globus_ftp_client_operationattr_set_mode( &attr, GLOBUS_FTP_CONTROL_MODE_EXTENDED_BLOCK); globus_ftp_client_operationattr_set_layout(&attr, &layout); globus_ftp_client_operationattr_set_parallelism(&attr, ¶llelism); globus_ftp_client_handle_init(&handle, &handle_attr); done = GLOBUS_FALSE; result = globus_ftp_client_get(&handle, src, &attr, &restart, done_cb, 0); if(result != GLOBUS_SUCCESS) { fprintf(stderr, "%s", globus_object_printable_to_string(globus_error_get(result))); done = GLOBUS_TRUE; error = GLOBUS_TRUE; } else { globus_ftp_client_register_read( &handle, buffer, buffer_length, data_cb, 0); } globus_mutex_lock(&lock); while(!done) { globus_cond_wait(&cond, &lock); } globus_mutex_unlock(&lock); globus_ftp_client_handle_destroy(&handle); globus_module_deactivate_all(); if(test_abort_count && error) { return 0; } return error; }
int main( int argc, char * argv[]) { int rc; char * filename = NULL; char * contact = NULL; globus_bool_t server = GLOBUS_FALSE; char gets_buffer[1024]; while ((rc = getopt(argc, argv, "hf:cst:b:v:i:")) != EOF) { switch (rc) { case 'h': usage(argv[0]); exit(0); case 'f': filename = optarg; break; case 'c': server = GLOBUS_FALSE; contact = fgets(gets_buffer, sizeof(gets_buffer), stdin); break; case 's': server = GLOBUS_TRUE; contact = NULL; break; case 't': if ((strcmp(optarg, CHUNKED) == 0) || (strcmp(optarg, IDENTITY) == 0)) { transfer_encoding = optarg; } else { usage(argv[0]); exit(1); } break; case 'b': buffer_size = atoi(optarg); if (buffer_size < 0) { usage(argv[0]); exit(1); } break; case 'v': if (strcmp(optarg, HTTP_1_0) == 0) { version = GLOBUS_XIO_HTTP_VERSION_1_0; } else if (strcmp(optarg, HTTP_1_1) == 0) { version = GLOBUS_XIO_HTTP_VERSION_1_1; } else { usage(argv[0]); exit(1); } break; case 'i': iterations = atoi(optarg); if (iterations <= 0) { usage(argv[0]); exit(1); } break; default: usage(argv[0]); exit(1); } } if (((!server) && (contact == NULL)) || (filename == NULL)) { usage(argv[0]); exit(1); } if (iterations > 1 && version == GLOBUS_XIO_HTTP_VERSION_1_0) { fprintf(stderr, "Can't have multiple iterations with HTTP/1.0 server\n"); usage(argv[0]); exit(1); } rc = http_test_initialize(&tcp_driver, &http_driver, &stack); if (rc != 0) { goto error_exit; } if (server) { rc = server_main( filename); } else { rc = client_main( filename, contact, version); } globus_xio_stack_destroy(stack); globus_xio_driver_unload(http_driver); globus_xio_driver_unload(tcp_driver); globus_module_deactivate_all(); error_exit: return rc; }
int main(int argc, char * argv[]) { globus_ftp_client_handle_t handle; globus_ftp_client_operationattr_t attr; globus_result_t result; globus_ftp_client_handleattr_t handle_attr; char * src = NULL; char * dst = NULL; struct tm modtime; extern char * optarg; extern int optind; int c; globus_module_activate(GLOBUS_FTP_CLIENT_MODULE); globus_ftp_client_handleattr_init(&handle_attr); globus_ftp_client_operationattr_init(&attr); globus_mutex_init(&lock, GLOBUS_NULL); globus_cond_init(&cond, GLOBUS_NULL); test_parse_args(argc, argv, &handle_attr, &attr, &src, &dst); optind = 1; while((c = getopt(argc, argv, "T:")) != -1) { switch(c) { case 'T': memset(&modtime, 0, sizeof(modtime)); if (sscanf(optarg, "%4d%2d%2d%2d%2d%2d", &modtime.tm_year, &modtime.tm_mon, &modtime.tm_mday, &modtime.tm_hour, &modtime.tm_min, &modtime.tm_sec) != 6) { printf("Invalid time format\n"); return GLOBUS_TRUE; } modtime.tm_year -= 1900; modtime.tm_mon -= 1; break; } } globus_ftp_client_operationattr_set_type(&attr, GLOBUS_FTP_CONTROL_TYPE_ASCII); globus_ftp_client_handleattr_set_cache_all(&handle_attr, GLOBUS_TRUE); globus_ftp_client_handle_init(&handle, &handle_attr); done = GLOBUS_FALSE; result = globus_ftp_client_utime(&handle, src, &modtime, &attr, done_cb, 0); if(result != GLOBUS_SUCCESS) { done = GLOBUS_TRUE; } globus_mutex_lock(&lock); while(!done) { globus_cond_wait(&cond, &lock); } globus_mutex_unlock(&lock); globus_ftp_client_handle_destroy(&handle); globus_module_deactivate_all(); if(test_abort_count && error) { return 0; } return error; }
int main(int argc, char *argv[]) { char * callback_contact; char * job_contact; char * rm_contact; monitor_t monitor; int rc = 0; LTDL_SET_PRELOADED_SYMBOLS(); printf("1..1\n"); rm_contact = getenv("CONTACT_STRING"); if (argc == 2) { rm_contact = argv[1]; } if (rm_contact == NULL) { fprintf(stderr, "Usage: %s resource-manager-contact\n", argv[0]); exit(1); } rc = globus_module_activate(GLOBUS_COMMON_MODULE); if(rc) { goto end; } rc = globus_module_activate(GLOBUS_GRAM_CLIENT_MODULE); if(rc) { goto disable_modules; } globus_mutex_init(&monitor.mutex ,GLOBUS_NULL); globus_cond_init(&monitor.cond, GLOBUS_NULL); monitor.state = GLOBUS_GRAM_PROTOCOL_JOB_STATE_PENDING; rc = globus_gram_client_callback_allow(gram_state_callback, &monitor, &callback_contact); if(rc != GLOBUS_SUCCESS) { fprintf(stderr, "Error creating callback contact %s.\n", globus_gram_client_error_string(rc)); goto error_exit; } globus_mutex_lock(&monitor.mutex); rc = globus_gram_client_job_request( rm_contact, "&(executable=/bin/sleep)(arguments=300)", GLOBUS_GRAM_PROTOCOL_JOB_STATE_ALL, callback_contact, &job_contact); if(rc != GLOBUS_SUCCESS) { fprintf(stderr, "Error submitting job request %s.\n", globus_gram_client_error_string(rc)); goto destroy_callback_contact; } while(monitor.state != GLOBUS_GRAM_PROTOCOL_JOB_STATE_ACTIVE && monitor.state != GLOBUS_GRAM_PROTOCOL_JOB_STATE_FAILED && monitor.state != GLOBUS_GRAM_PROTOCOL_JOB_STATE_DONE) { globus_cond_wait(&monitor.cond, &monitor.mutex); } if(monitor.state == GLOBUS_GRAM_PROTOCOL_JOB_STATE_ACTIVE) { rc = globus_gram_client_job_cancel(job_contact); if(rc != GLOBUS_SUCCESS) { fprintf(stderr, "Error cancelling job %s.\n", globus_gram_client_error_string(rc)); goto destroy_callback_contact; } } while(monitor.state != GLOBUS_GRAM_PROTOCOL_JOB_STATE_DONE && monitor.state != GLOBUS_GRAM_PROTOCOL_JOB_STATE_FAILED) { globus_cond_wait(&monitor.cond, &monitor.mutex); } rc = monitor.errorcode; if(rc == GLOBUS_GRAM_PROTOCOL_ERROR_USER_CANCELLED) { rc = GLOBUS_SUCCESS; } destroy_callback_contact: globus_mutex_unlock(&monitor.mutex); globus_gram_client_callback_disallow(callback_contact); free(callback_contact); free(job_contact); error_exit: globus_mutex_destroy(&monitor.mutex); globus_cond_destroy(&monitor.cond); disable_modules: globus_module_deactivate_all(); end: printf("%s - cancel-test\n", rc == 0 ? "ok" : "not ok"); return rc; }
int main() { OM_uint32 init_maj_stat; OM_uint32 accept_maj_stat; OM_uint32 maj_stat; OM_uint32 min_stat; OM_uint32 ret_flags; OM_uint32 req_flags = 0; OM_uint32 time_rec; gss_buffer_desc send_tok; gss_buffer_desc recv_tok; gss_buffer_desc * token_ptr; gss_OID mech_type; gss_name_t target_name; gss_ctx_id_t init_context; gss_ctx_id_t accept_context; gss_ctx_id_t del_init_context; gss_ctx_id_t del_accept_context; gss_cred_id_t delegated_cred; gss_cred_id_t imported_cred; gss_cred_id_t cred_handle; char * error_str; globus_result_t result; globus_gsi_cert_utils_cert_type_t cert_type; int rc = EXIT_SUCCESS; printf("1..1\n"); /* Activate Modules */ globus_module_activate(GLOBUS_GSI_GSSAPI_MODULE); /* Initialize variables */ token_ptr = GSS_C_NO_BUFFER; init_context = GSS_C_NO_CONTEXT; accept_context = GSS_C_NO_CONTEXT; del_init_context = GSS_C_NO_CONTEXT; del_accept_context = GSS_C_NO_CONTEXT; delegated_cred = GSS_C_NO_CREDENTIAL; accept_maj_stat = GSS_S_CONTINUE_NEEDED; ret_flags = 0; req_flags |= GSS_C_GLOBUS_LIMITED_DELEG_PROXY_FLAG; /* acquire the credential */ maj_stat = gss_acquire_cred(&min_stat, NULL, GSS_C_INDEFINITE, GSS_C_NO_OID_SET, GSS_C_BOTH, &cred_handle, NULL, NULL); if(maj_stat != GSS_S_COMPLETE) { globus_gsi_gssapi_test_print_error(stderr, maj_stat, min_stat); rc = EXIT_FAILURE; goto fail; } /* get the subject name */ maj_stat = gss_inquire_cred(&min_stat, cred_handle, &target_name, NULL, NULL, NULL); if(maj_stat != GSS_S_COMPLETE) { globus_gsi_gssapi_test_print_error(stderr, maj_stat, min_stat); rc = EXIT_FAILURE; goto fail; } /* set up the first security context */ init_maj_stat = gss_init_sec_context(&min_stat, cred_handle, &init_context, target_name, GSS_C_NULL_OID, 0, 0, GSS_C_NO_CHANNEL_BINDINGS, token_ptr, NULL, &send_tok, NULL, NULL); if(init_maj_stat != GSS_S_CONTINUE_NEEDED) { globus_gsi_gssapi_test_print_error(stderr, init_maj_stat, min_stat); rc = EXIT_FAILURE; goto fail; } while(1) { accept_maj_stat=gss_accept_sec_context(&min_stat, &accept_context, GSS_C_NO_CREDENTIAL, &send_tok, GSS_C_NO_CHANNEL_BINDINGS, NULL, &mech_type, &recv_tok, &ret_flags, /* ignore time_rec */ NULL, NULL); if(accept_maj_stat != GSS_S_COMPLETE && accept_maj_stat != GSS_S_CONTINUE_NEEDED) { globus_gsi_gssapi_test_print_error(stderr, accept_maj_stat, min_stat); rc = EXIT_FAILURE; goto fail; } else if(accept_maj_stat == GSS_S_COMPLETE) { break; } init_maj_stat = gss_init_sec_context(&min_stat, GSS_C_NO_CREDENTIAL, &init_context, target_name, GSS_C_NULL_OID, 0, 0, GSS_C_NO_CHANNEL_BINDINGS, &recv_tok, NULL, &send_tok, NULL, NULL); if(init_maj_stat != GSS_S_COMPLETE && init_maj_stat != GSS_S_CONTINUE_NEEDED) { globus_gsi_gssapi_test_print_error(stderr, init_maj_stat, min_stat); rc = EXIT_FAILURE; goto fail; } } printf("# %s:%d: Successfully established initial security context\n", __FILE__, __LINE__); /* delegate our credential over the initial security context and * insert a restriction extension into the delegated credential. * This is a post GT 2.0 feature. */ init_maj_stat = gss_init_delegation(&min_stat, init_context, cred_handle, GSS_C_NO_OID, GSS_C_NO_OID_SET, GSS_C_NO_BUFFER_SET, token_ptr, req_flags, 0, &send_tok); if(init_maj_stat != GSS_S_COMPLETE && init_maj_stat != GSS_S_CONTINUE_NEEDED) { globus_gsi_gssapi_test_print_error(stderr, init_maj_stat, min_stat); rc = EXIT_FAILURE; goto fail; } while(1) { accept_maj_stat=gss_accept_delegation(&min_stat, accept_context, GSS_C_NO_OID_SET, GSS_C_NO_BUFFER_SET, &send_tok, req_flags, 0, &time_rec, &delegated_cred, &mech_type, &recv_tok); if(accept_maj_stat != GSS_S_COMPLETE && accept_maj_stat != GSS_S_CONTINUE_NEEDED) { globus_gsi_gssapi_test_print_error(stderr, accept_maj_stat, min_stat); rc = EXIT_FAILURE; goto fail; } else if(accept_maj_stat == GSS_S_COMPLETE) { break; } init_maj_stat = gss_init_delegation(&min_stat, init_context, cred_handle, GSS_C_NO_OID, GSS_C_NO_OID_SET, GSS_C_NO_BUFFER_SET, &recv_tok, req_flags, 0, &send_tok); if(init_maj_stat != GSS_S_COMPLETE && init_maj_stat != GSS_S_CONTINUE_NEEDED) { globus_gsi_gssapi_test_print_error(stderr, init_maj_stat, min_stat); rc = EXIT_FAILURE; goto fail; } } printf("# %s:%d: Successfully delegated credential\n", __FILE__, __LINE__); /* export and import the delegated credential */ /* this can be done both to a buffer and to a file */ /* New in GT 2.0 */ maj_stat = gss_export_cred(&min_stat, delegated_cred, GSS_C_NO_OID, 0, &send_tok); if(maj_stat != GSS_S_COMPLETE) { globus_gsi_gssapi_test_print_error(stderr, maj_stat, min_stat); rc = EXIT_FAILURE; goto fail; } maj_stat = gss_import_cred(&min_stat, &imported_cred, GSS_C_NO_OID, 0, &send_tok, 0, &time_rec); if(maj_stat != GSS_S_COMPLETE) { globus_gsi_gssapi_test_print_error(stderr, maj_stat, min_stat); rc = EXIT_FAILURE; goto fail; } printf("# %s:%d: Successfully exported/imported the delegated credential\n", __FILE__, __LINE__); /* set up another security context using the delegated credential */ init_maj_stat = gss_init_sec_context(&min_stat, imported_cred, &del_init_context, target_name, GSS_C_NULL_OID, 0, 0, GSS_C_NO_CHANNEL_BINDINGS, token_ptr, NULL, &send_tok, NULL, NULL); if(init_maj_stat != GSS_S_COMPLETE && init_maj_stat != GSS_S_CONTINUE_NEEDED) { globus_gsi_gssapi_test_print_error(stderr, init_maj_stat, min_stat); rc = EXIT_FAILURE; goto fail; } while(1) { accept_maj_stat=gss_accept_sec_context(&min_stat, &del_accept_context, imported_cred, &send_tok, GSS_C_NO_CHANNEL_BINDINGS, NULL, &mech_type, &recv_tok, &ret_flags, /* ignore time_rec */ NULL, NULL); if(accept_maj_stat != GSS_S_COMPLETE && accept_maj_stat != GSS_S_CONTINUE_NEEDED) { globus_gsi_gssapi_test_print_error(stderr, accept_maj_stat, min_stat); rc = EXIT_FAILURE; goto fail; } else if(accept_maj_stat == GSS_S_COMPLETE) { break; } init_maj_stat = gss_init_sec_context(&min_stat, imported_cred, &del_init_context, target_name, GSS_C_NULL_OID, 0, 0, GSS_C_NO_CHANNEL_BINDINGS, &recv_tok, NULL, &send_tok, NULL, NULL); if(init_maj_stat != GSS_S_COMPLETE && init_maj_stat != GSS_S_CONTINUE_NEEDED) { globus_gsi_gssapi_test_print_error(stderr, init_maj_stat, min_stat); rc = EXIT_FAILURE; goto fail; } } /* got sec context based on delegated cred now */ printf("# %s:%d: Successfully established security context with delegated credential\n", __FILE__, __LINE__); /* Verify that the delegated credential is a limited proxy */ result = globus_gsi_cred_get_cert_type( ((gss_cred_id_desc *)imported_cred)->cred_handle, &cert_type); if(result != GLOBUS_SUCCESS) { char * error_str; globus_object_t * error_obj; error_obj = globus_error_get(result); error_str = globus_error_print_chain(error_obj); fprintf(stderr, "%s", error_str); globus_libc_free(error_str); globus_object_free(error_obj); rc = EXIT_FAILURE; goto fail; } if (! GLOBUS_GSI_CERT_UTILS_IS_LIMITED_PROXY(cert_type)) { fprintf(stderr, "Invalid certificate type. Expected a limited proxy, got %d\n", (int) cert_type); rc = EXIT_FAILURE; goto fail; } fail: printf("%s gssapi_limited_delegation_test\n", (rc==EXIT_SUCCESS) ? "ok" : "not ok"); globus_module_deactivate_all(); exit(rc); }
int main(int argc, char **argv) { globus_ftp_client_handle_t handle; globus_ftp_client_operationattr_t attr; globus_byte_t buffer[1024]; globus_size_t buffer_length = sizeof(buffer); globus_result_t result; globus_ftp_client_handleattr_t handle_attr; char * src; char * dst; globus_module_activate(GLOBUS_FTP_CLIENT_MODULE); globus_ftp_client_handleattr_init(&handle_attr); globus_ftp_client_operationattr_init(&attr); test_parse_args(argc, argv, &handle_attr, &attr, &src, &dst); globus_mutex_init(&lock, GLOBUS_NULL); globus_cond_init(&cond, GLOBUS_NULL); globus_ftp_client_handle_init(&handle, &handle_attr); done = GLOBUS_FALSE; result = globus_ftp_client_get(&handle, src, &attr, GLOBUS_NULL, done_cb, 0); if(result != GLOBUS_SUCCESS) { done = GLOBUS_TRUE; } else { globus_ftp_client_register_read( &handle, (globus_byte_t *) 0x1, buffer_length, data_cb, 0); globus_ftp_client_register_read( &handle, (globus_byte_t *) 0x0, buffer_length, data_cb, 0); } globus_mutex_lock(&lock); globus_poll(); globus_ftp_client_register_read( &handle, (globus_byte_t *) 0x3, buffer_length, data_cb, 0); while(!done) { globus_cond_wait(&cond, &lock); } globus_mutex_unlock(&lock); globus_ftp_client_handle_destroy(&handle); globus_module_deactivate_all(); return 0; }