diff --git a/callout/source/configure.ac b/callout/source/configure.ac index bf90d12df4..e76b301230 100644 --- a/callout/source/configure.ac +++ b/callout/source/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ([2.60]) -AC_INIT([globus_callout], [4.3], [https://github.com/gridcf/gct/issues]) +AC_INIT([globus_callout], [4.4], [https://github.com/gridcf/gct/issues]) AC_CONFIG_MACRO_DIR([m4]) AC_SUBST([MAJOR_VERSION], [${PACKAGE_VERSION%%.*}]) AC_SUBST([MINOR_VERSION], [${PACKAGE_VERSION##*.}]) diff --git a/callout/source/library/globus_callout.c b/callout/source/library/globus_callout.c index b84007b959..454bb4b81a 100644 --- a/callout/source/library/globus_callout.c +++ b/callout/source/library/globus_callout.c @@ -85,7 +85,7 @@ globus_l_callout_activate(void) if(tmp_string != GLOBUS_NULL) { globus_i_callout_debug_level = atoi(tmp_string); - + if(globus_i_callout_debug_level < 0) { globus_i_callout_debug_level = 0; @@ -186,7 +186,7 @@ globus_callout_handle_init( GLOBUS_CALLOUT_MALLOC_ERROR(result); goto exit; } - + if((rc = globus_hashtable_init(&((*handle)->symbol_htable), GLOBUS_I_CALLOUT_HASH_SIZE, globus_hashtable_string_hash, @@ -198,7 +198,7 @@ globus_callout_handle_init( GLOBUS_CALLOUT_ERROR_WITH_HASHTABLE, ("globus_hashtable_init retuned %d", rc)); goto exit; - } + } if((rc = globus_hashtable_init(&((*handle)->library_htable), GLOBUS_I_CALLOUT_HASH_SIZE, @@ -212,12 +212,12 @@ globus_callout_handle_init( GLOBUS_CALLOUT_ERROR_WITH_HASHTABLE, ("globus_hashtable_init retuned %d", rc)); goto exit; - } + } GLOBUS_I_CALLOUT_DEBUG_EXIT; exit: - + return result; }/*globus_callout_handle_init*/ @@ -238,7 +238,7 @@ globus_callout_handle_destroy( static char * _function_name_ = "globus_callout_handle_destroy"; GLOBUS_I_CALLOUT_DEBUG_ENTER; - + /* free hashes */ globus_hashtable_destroy_all( @@ -250,7 +250,7 @@ globus_callout_handle_destroy( globus_l_callout_data_free); free(handle); - + GLOBUS_I_CALLOUT_DEBUG_EXIT; return result; @@ -273,7 +273,7 @@ globus_callout_handle_destroy( * of the callout. The library argument can be specified in two forms, * libfoo or libfoo_flavor. When using the former version the * current flavor will automatically be added to the library name if - * needed. + * needed. * * @param handle * The handle that is to be configured @@ -306,13 +306,13 @@ globus_callout_read_config( globus_result_t result; globus_i_callout_data_t * datum = NULL; globus_i_callout_data_t * existing_datum; - + static char * _function_name_ = "globus_callout_read_config"; GLOBUS_I_CALLOUT_DEBUG_ENTER; - + conf_file = fopen(filename, "r"); if(conf_file == NULL) @@ -323,7 +323,7 @@ globus_callout_read_config( ("filename %s", filename)); goto error_exit; } - + while(fgets(buffer,GLOBUS_I_CALLOUT_LINEBUF,conf_file)) { if(!strchr(buffer, '\n')) @@ -339,12 +339,12 @@ globus_callout_read_config( pound = strchr(buffer, '#'); if(pound != NULL) - { + { *pound = '\0'; } /* strip white space from start */ - + index = 0; while(buffer[index] == '\t' || buffer[index] == ' ') @@ -353,12 +353,12 @@ globus_callout_read_config( } /* if blank line continue */ - + if(buffer[index] == '\0' || buffer[index] == '\n') - { + { continue; } - + if(sscanf(&buffer[index],"%127s%255s%127s",type,library,symbol) < 3) { GLOBUS_CALLOUT_ERROR_RESULT( @@ -367,7 +367,7 @@ globus_callout_read_config( ("malformed line: %s", &buffer[index])); goto error_exit; } - + /* check for ENV vars to set */ env_argstr = strstr(buffer, "ENV:"); if(env_argstr && strchr(env_argstr, '=')) @@ -375,7 +375,7 @@ globus_callout_read_config( int i; char * ptr; char * start; - + numpairs = 0; ptr = strchr(env_argstr, '='); while(ptr) @@ -396,26 +396,26 @@ globus_callout_read_config( } ptr = strchr(ptr + 1, '='); } - + if(numpairs > 0) { env_args = globus_calloc(numpairs*2+1, sizeof(char *)); - + start = env_argstr + 4; - + i = 0; while(start) - { + { /* skip initial space */ while(isspace(*start)) { start++; } - + /* find var name */ ptr = strchr(start, '='); *ptr = '\0'; - + if(strcspn(start, " \"=") != strlen(start)) { GLOBUS_CALLOUT_ERROR_RESULT( @@ -426,10 +426,10 @@ globus_callout_read_config( } env_args[i] = globus_libc_strdup(start); - + /* find value in quotes or before a space or end of line */ start = ++ptr; - + if(*start == '"') { start++; @@ -443,7 +443,7 @@ globus_callout_read_config( { ptr = strchr(start, '\n'); } - *ptr = '\0'; + *ptr = '\0'; } env_args[i+1] = globus_libc_strdup(start); @@ -460,8 +460,8 @@ globus_callout_read_config( { start = NULL; } - - i += 2; + + i += 2; } env_args[i] = NULL; } @@ -470,7 +470,7 @@ globus_callout_read_config( { env_args = NULL; } - + /* push values into hash */ datum = malloc(sizeof(globus_i_callout_data_t)); @@ -488,7 +488,7 @@ globus_callout_read_config( (strstr(flavor_start, "32") || strstr(flavor_start, "64"))) { datum->file = strdup(library); - + if(datum->file == NULL) { GLOBUS_CALLOUT_MALLOC_ERROR(result); @@ -496,7 +496,7 @@ globus_callout_read_config( } } else - { + { datum->file = malloc(strlen(library) + 2 + strlen(flavor)); if(datum->file == NULL) { @@ -508,7 +508,7 @@ globus_callout_read_config( strcat(datum->file, "_"); strcat(datum->file, flavor); } - + datum->symbol = strdup(symbol); if(datum->symbol == NULL) @@ -516,7 +516,7 @@ globus_callout_read_config( GLOBUS_CALLOUT_MALLOC_ERROR(result); goto error_exit; } - + if(*type == '|') { datum->mandatory = GLOBUS_FALSE; @@ -552,7 +552,7 @@ globus_callout_read_config( } fclose(conf_file); - + GLOBUS_I_CALLOUT_DEBUG_EXIT; return GLOBUS_SUCCESS; @@ -603,23 +603,23 @@ globus_callout_register( globus_i_callout_data_t * datum = NULL; globus_i_callout_data_t * existing_datum; char * flavor_start; - + static char * _function_name_ = "globus_callout_register"; GLOBUS_I_CALLOUT_DEBUG_ENTER; - - + + /* push values into hash */ datum = malloc(sizeof(globus_i_callout_data_t)); - + if(datum == NULL) { GLOBUS_CALLOUT_MALLOC_ERROR(result); goto error_exit; } - + memset(datum,'\0',sizeof(globus_i_callout_data_t)); datum->mandatory = GLOBUS_TRUE; @@ -627,7 +627,7 @@ globus_callout_register( (strstr(flavor_start, "32") || strstr(flavor_start, "64"))) { datum->file = strdup(library); - + if(datum->file == NULL) { GLOBUS_CALLOUT_MALLOC_ERROR(result); @@ -635,7 +635,7 @@ globus_callout_register( } } else - { + { datum->file = malloc(strlen(library) + 2 + strlen(flavor)); if(datum->file == NULL) { @@ -644,26 +644,26 @@ globus_callout_register( } datum->file[0] = '\0'; strcat(datum->file, library); - strcat(datum->file, "_"); + strcat(datum->file, "_"); strcat(datum->file, flavor); } - + datum->symbol = strdup(symbol); - + if(datum->symbol == NULL) { GLOBUS_CALLOUT_MALLOC_ERROR(result); goto error_exit; } - + datum->type = strdup(type); - + if(datum->type == NULL) { GLOBUS_CALLOUT_MALLOC_ERROR(result); goto error_exit; } - + if((rc = globus_hashtable_insert(&handle->symbol_htable, datum->type, datum)) == -1) @@ -676,7 +676,7 @@ globus_callout_register( } existing_datum->next = datum; } - + GLOBUS_I_CALLOUT_DEBUG_EXIT; return GLOBUS_SUCCESS; @@ -684,12 +684,12 @@ globus_callout_register( error_exit: GLOBUS_I_CALLOUT_DEBUG_EXIT; - + if(datum != NULL) { globus_l_callout_data_free(datum); } - + return result; }/*globus_callout_register*/ @@ -731,7 +731,7 @@ globus_callout_call_type( char * flavor_start; char * file; char library[1024]; - char ** save_env; + char ** save_env = NULL; int i; globus_i_callout_data_t * tmp_datum; int mandatory_callouts_remaining = 0; @@ -749,7 +749,7 @@ globus_callout_call_type( ("unknown type: %s\n", type)); goto exit; } - + tmp_datum = current_datum; while(tmp_datum) { @@ -759,7 +759,7 @@ globus_callout_call_type( } tmp_datum = tmp_datum->next; } - + do { dlhandle = globus_hashtable_lookup(&handle->library_htable, @@ -768,12 +768,12 @@ globus_callout_call_type( if(dlhandle == NULL) { dlhandle = malloc(sizeof(lt_dlhandle)); - + if(dlhandle == NULL) { GLOBUS_CALLOUT_MALLOC_ERROR(result); } - + *dlhandle = NULL; rc = globus_hashtable_insert(&handle->library_htable, current_datum->file, @@ -786,15 +786,15 @@ globus_callout_call_type( GLOBUS_CALLOUT_ERROR_WITH_HASHTABLE, ("globus_hashtable_insert retuned %d", rc)); goto exit; - } + } } - + if(*dlhandle == NULL) { /* first time a symbol is referenced in this library -> * need to open it */ - + *dlhandle = lt_dlopenext(current_datum->file); if(*dlhandle == NULL) { @@ -803,7 +803,7 @@ globus_callout_call_type( library[1023] = 0; *dlhandle = lt_dlopenext(library); } - + if(*dlhandle == NULL) { /* try again with flavor string removed */ @@ -834,7 +834,7 @@ globus_callout_call_type( GLOBUS_CALLOUT_ERROR_WITH_DL, ("couldn't dlopen %s: %s\n", library, - (dlerror = lt_dlerror()) ? dlerror : + (dlerror = lt_dlerror()) ? dlerror : "unknown error, possibly file not found.")); goto exit; } @@ -855,16 +855,16 @@ globus_callout_call_type( } if(current_datum->env_args) - { + { save_env = globus_calloc( current_datum->num_env_args*2+1, sizeof(char *)); i = 0; - while(current_datum->env_args[i] != NULL && + while(current_datum->env_args[i] != NULL && current_datum->env_args[i+1] != NULL) { save_env[i] = current_datum->env_args[i]; - save_env[i+1] = + save_env[i+1] = globus_libc_strdup(getenv(current_datum->env_args[i])); globus_libc_setenv(current_datum->env_args[i], current_datum->env_args[i+1], 1); i += 2; @@ -873,14 +873,14 @@ globus_callout_call_type( } va_start(ap,type); - + result = ((globus_callout_function_t) function)(ap); - + va_end(ap); - if(current_datum->env_args) + if(current_datum->env_args && save_env) { - i = 0; + i = 0; while(save_env[i] != NULL) { if(save_env[i+1] == NULL) @@ -892,7 +892,7 @@ globus_callout_call_type( globus_libc_setenv(save_env[i], save_env[i+1], 1); globus_free(save_env[i+1]); } - + i += 2; } globus_free(save_env); @@ -904,13 +904,13 @@ globus_callout_call_type( { mandatory_callouts_remaining--; } - + if(!mandatory_callouts_remaining) { goto exit; } } - + if(result != GLOBUS_SUCCESS) { if(current_datum->mandatory) @@ -938,7 +938,7 @@ globus_callout_call_type( current_datum = current_datum->next; } while(current_datum); - + exit: GLOBUS_I_CALLOUT_DEBUG_EXIT; return result; @@ -961,17 +961,17 @@ globus_l_callout_data_free( { free(data->type); } - + if(data->file != NULL) { free(data->file); } - + if(data->symbol != NULL) { free(data->symbol); } - + if(data->env_args != NULL) { int i = 0; @@ -982,10 +982,10 @@ globus_l_callout_data_free( } free(data->env_args); } - + free(data); } - + GLOBUS_I_CALLOUT_DEBUG_EXIT; } @@ -996,7 +996,6 @@ globus_l_callout_library_table_element_free( void * element) { lt_dlhandle * dlhandle; - globus_result_t result; static char * _function_name_ = "globus_l_callout_library_table_element_free"; GLOBUS_I_CALLOUT_DEBUG_ENTER; @@ -1004,21 +1003,15 @@ globus_l_callout_library_table_element_free( dlhandle = (lt_dlhandle *) element; if(dlhandle != NULL) - { + { if(*dlhandle != NULL) { - if(lt_dlclose(*dlhandle) < 0) - { - GLOBUS_CALLOUT_ERROR_RESULT( - result, - GLOBUS_CALLOUT_ERROR_WITH_DL, - ("failed to close library")); - } + lt_dlclose(*dlhandle); } free(dlhandle); } - + GLOBUS_I_CALLOUT_DEBUG_EXIT; return; } diff --git a/common/source/configure.ac b/common/source/configure.ac index d5543661e8..fce7a03788 100644 --- a/common/source/configure.ac +++ b/common/source/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ([2.60]) -AC_INIT([globus_common], [18.15], [https://github.com/gridcf/gct/issues]) +AC_INIT([globus_common], [18.16], [https://github.com/gridcf/gct/issues]) AC_CONFIG_MACRO_DIR([m4]) AC_SUBST([MAJOR_VERSION], [${PACKAGE_VERSION%%.*}]) AC_SUBST([MINOR_VERSION], [${PACKAGE_VERSION##*.}]) diff --git a/common/source/library/globus_args.c b/common/source/library/globus_args.c index ca9ff24bac..b91f2e468a 100644 --- a/common/source/library/globus_args.c +++ b/common/source/library/globus_args.c @@ -33,34 +33,34 @@ /* ---------------------------------------------------------------------- globus_l_args_create_msg() - + creates (and possibly prints) a message ---------------------------------------------------------------------- */ int globus_l_args_create_msg( char ** msg_storage, - char * message ) + char * message ) { if (msg_storage) - *msg_storage = message; + *msg_storage = message; else - globus_libc_fprintf( stderr, "%s", message ); + globus_libc_fprintf( stderr, "%s", message ); return GLOBUS_SUCCESS; } /* ---------------------------------------------------------------------- globus_l_args_create_error_msg() - + creates (and possibly prints) an error message ---------------------------------------------------------------------- */ int globus_l_args_create_error_msg( char ** error_msg, - int current_argc, - char * current_argv, - char * error_string, - const char * oneline_usage ) + int current_argc, + char * current_argv, + char * error_string, + const char * oneline_usage ) { char * my_error_string; char * p; @@ -78,15 +78,15 @@ globus_l_args_create_error_msg( char ** error_msg, + strlen(my_error_string) + strlen(oneline_usage) + strlen(error_epilogue) - + 10; + + 10; p = globus_l_args_malloc( char, len ); globus_assert( p ); globus_libc_sprintf( p, - error_format, - current_argc, - current_argv, - my_error_string ); + error_format, + current_argc, + current_argv, + my_error_string ); usage_len = strlen( oneline_usage ); @@ -95,11 +95,11 @@ globus_l_args_create_error_msg( char ** error_msg, sprintf( &p[len+usage_len], "%s", error_epilogue ); if (error_msg) - *error_msg = p; + *error_msg = p; else { - globus_libc_fprintf( stderr, "%s", p ); - free(p); + globus_libc_fprintf( stderr, "%s", p ); + free(p); } return GLOBUS_SUCCESS; @@ -119,12 +119,12 @@ globus_l_args_create_error_msg( char ** error_msg, int -globus_l_args_validate( globus_args_option_descriptor_t * option, - int start_argc, - char ** argv, - char *** values, - const char * oneline_usage, - char ** msg_storage ) +globus_l_args_validate( globus_args_option_descriptor_t * option, + int start_argc, + char ** argv, + char *** values, + const char * oneline_usage, + char ** msg_storage ) { int rc; int i; @@ -134,43 +134,43 @@ globus_l_args_validate( globus_args_option_descriptor_t * option, *values = globus_l_args_malloc(char*, option->arity); globus_assert(*values); - + rc = GLOBUS_SUCCESS; for (i=0; !rc && iarity; i++) { - argp = argv[start_argc+1+i]; - if (option->tests && option->tests[i] ) - { - p = GLOBUS_NULL; - if ( option->test_parms && option->test_parms[i] ) - p = option->test_parms[i]; - - validation_error = GLOBUS_NULL; - rc = option->tests[i]( argp, - p, - &validation_error ); - - /* API defines non-zero return as an error */ - if (rc) - { - globus_l_args_create_error_msg( msg_storage, - start_argc+1+i, - argp, - validation_error, - oneline_usage ); - continue; - } - } /* if */ - - (*values)[i] = argp; + argp = argv[start_argc+1+i]; + if (option->tests && option->tests[i] ) + { + p = GLOBUS_NULL; + if ( option->test_parms && option->test_parms[i] ) + p = option->test_parms[i]; + + validation_error = GLOBUS_NULL; + rc = option->tests[i]( argp, + p, + &validation_error ); + + /* API defines non-zero return as an error */ + if (rc) + { + globus_l_args_create_error_msg( msg_storage, + start_argc+1+i, + argp, + validation_error, + oneline_usage ); + continue; + } + } /* if */ + + (*values)[i] = argp; } /* for */ if (rc) { - free(*values); - rc = GLOBUS_FAILURE; + free(*values); + rc = GLOBUS_FAILURE; } return rc; @@ -180,15 +180,15 @@ globus_l_args_validate( globus_args_option_descriptor_t * option, /* --------------------------------------------------------------------- globus_l_args_add_instance() - + help function : creates an option instance and inserts in the fifo list. */ - + int globus_l_args_add_instance( globus_fifo_t * fifo, - globus_args_option_descriptor_t * option, - char ** values ) + globus_args_option_descriptor_t * option, + char ** values ) { globus_args_option_instance_t * t; @@ -209,7 +209,7 @@ globus_l_args_add_instance( globus_fifo_t * fifo, globus_l_args_check_options() (7) The argument flags "-help", "-usage", "-version", and "-versions" are - reserved, and if they are detected the library will create an + reserved, and if they are detected the library will create an appropriate message and signal an error. */ @@ -229,27 +229,27 @@ globus_l_args_check_options( rc = GLOBUS_SUCCESS; for (i=0; !rc && i= *argc) { globus_l_args_create_error_msg( - error_msg, - my_argc, - my_arg, - _GCSL("not enough arguments"), - oneline_usage ); + error_msg, + my_argc, + my_arg, + _GCSL("not enough arguments"), + oneline_usage ); rc = GLOBUS_FAILURE; continue; } - rc = globus_l_args_validate( &options[i], - my_argc, - (*argv), - &arglist, - oneline_usage, - error_msg ); + rc = globus_l_args_validate( &options[i], + my_argc, + (*argv), + &arglist, + oneline_usage, + error_msg ); } /* if */ if (rc==GLOBUS_SUCCESS) { - /* option successfully detected: add it */ + /* option successfully detected: add it */ globus_l_args_add_instance( &fifo, &options[i], arglist ); @@ -443,16 +443,16 @@ globus_args_scan( } /* strcmp(my_arg,*alias)) */ } /* alias */ } /* i */ - if (!found) - { - /* my_arg contains an unregistered option */ - rc = GLOBUS_FAILURE; - globus_l_args_create_error_msg( error_msg, - my_argc, - my_arg, - _GCSL("unknown option"), - oneline_usage ); - } + if (!found) + { + /* my_arg contains an unregistered option */ + rc = GLOBUS_FAILURE; + globus_l_args_create_error_msg( error_msg, + my_argc, + my_arg, + _GCSL("unknown option"), + oneline_usage ); + } if (rc!=GLOBUS_SUCCESS) { done = GLOBUS_TRUE; @@ -462,20 +462,20 @@ globus_args_scan( if (rc==GLOBUS_SUCCESS) { - /* if successful, return number of options found */ - rc = globus_fifo_size(&fifo); + /* if successful, return number of options found */ + rc = globus_fifo_size(&fifo); *options_found = globus_fifo_convert_to_list( &fifo ); - /* modify argc/argv */ - if (my_argc>1) - { - for (i = my_argc; i < *argc; i++) - (*argv)[i-my_argc+1] = (*argv)[i]; + /* modify argc/argv */ + if (my_argc>1) + { + for (i = my_argc; i < *argc; i++) + (*argv)[i-my_argc+1] = (*argv)[i]; - *argc -= my_argc - 1; - } + *argc -= my_argc - 1; + } } - + globus_fifo_destroy(&fifo); globus_mutex_unlock(&args_mutex); return rc; @@ -498,18 +498,18 @@ void globus_args_option_instance_list_free( globus_list_t ** list ) { globus_args_option_instance_t * t; - + while(!globus_list_empty(*list)) { t = (globus_args_option_instance_t *) globus_list_remove(list, *list); - globus_assert(t); - if (t->values) - free( t->values ); - globus_free(t); - + globus_assert(t); + if (t->values) + free( t->values ); + globus_free(t); + } - + return; } @@ -546,8 +546,8 @@ globus_validate_int( char * value, if (!parms) { - *error_msg = _GCSL(globus_l_validate_error_null_parms); - return GLOBUS_FAILURE; + *error_msg = _GCSL(globus_l_validate_error_null_parms); + return GLOBUS_FAILURE; } format = "%d"; @@ -579,18 +579,18 @@ globus_validate_int( char * value, if ((range->range_type & GLOBUS_VALIDATE_INT_MIN) && (range->range_min > val)) { - globus_libc_sprintf(globus_l_validate_error_buf, - _GCSL("value is smaller than allowed min=%d"), - range->range_min); - *error_msg = globus_l_validate_error_buf; + globus_libc_sprintf(globus_l_validate_error_buf, + _GCSL("value is smaller than allowed min=%d"), + range->range_min); + *error_msg = globus_l_validate_error_buf; return GLOBUS_FAILURE; } if ((range->range_type & GLOBUS_VALIDATE_INT_MAX) && (range->range_max < val)) { - globus_libc_sprintf(globus_l_validate_error_buf, - _GCSL("value is larger than allowed max=%d"), - range->range_max); + globus_libc_sprintf(globus_l_validate_error_buf, + _GCSL("value is larger than allowed max=%d"), + range->range_max); *error_msg = globus_l_validate_error_buf; return GLOBUS_FAILURE; } @@ -618,8 +618,8 @@ globus_validate_filename( char * value, if (!parms) { - *error_msg = _GCSL(globus_l_validate_error_null_parms); - return GLOBUS_FAILURE; + *error_msg = _GCSL(globus_l_validate_error_null_parms); + return GLOBUS_FAILURE; } mode = *((int *)(parms)); @@ -627,8 +627,8 @@ globus_validate_filename( char * value, my_errno = errno; if (fd < 0) { - *error_msg = globus_libc_system_error_string(my_errno); - return GLOBUS_FAILURE; + *error_msg = globus_libc_system_error_string(my_errno); + return GLOBUS_FAILURE; } globus_libc_close(fd); @@ -640,54 +640,53 @@ globus_validate_filename( char * value, /* ---------------------------------------------------------------------------- globus_bytestr_to_num() - converts a string such as 40M, 256K, 2G to an equivalent off_t. + converts a string such as 40M, 256K, 2G to an equivalent off_t. Valid multipliers are G,g, M,m, K,k, B,b. - + Returns 0 on success, nonzero on error. */ int -globus_args_bytestr_to_num( +globus_args_bytestr_to_num( const char * str, - globus_off_t * out) -{ - char * end = NULL; + globus_off_t * out) +{ + char * end = NULL; globus_off_t size = 0; int consumed; - int rc; - + if(str == NULL || !(isdigit(*str) || *str == '-')) { return 1; } - - rc = globus_libc_scan_off_t((char *)str, &size, &consumed); + + globus_libc_scan_off_t((char *)str, &size, &consumed); end = (char *)str + consumed; if(size && end && *end) - { - switch(*end) - { - case 'g': - case 'G': - size *= 1024; - case 'm': - case 'M': - size *= 1024; - case 'k': - case 'K': - size *= 1024; - case 'b': - case 'B': - break; - - default: + { + switch(*end) + { + case 'g': + case 'G': + size *= 1024; + case 'm': + case 'M': + size *= 1024; + case 'k': + case 'K': + size *= 1024; + case 'b': + case 'B': + break; + + default: return 1; - break; - } - } - + break; + } + } + *out = size; - + return 0; -} +} diff --git a/common/source/library/globus_callback.h b/common/source/library/globus_callback.h index bb4e580772..d36c4bf32f 100644 --- a/common/source/library/globus_callback.h +++ b/common/source/library/globus_callback.h @@ -127,7 +127,7 @@ typedef struct globus_l_callback_space_attr_s * globus_callback_space_attr_t; */ /** - * @name Convenience Macros + * @name Convenience Macros */ /* @{ */ @@ -285,16 +285,16 @@ typedef struct globus_l_callback_space_attr_s * globus_callback_space_attr_t; * @ingroup globus_callback_api * * @details - * This is the signature of the function registered with the + * This is the signature of the function registered with the * globus_callback_register_* calls. * * If this is a periodic callback, it is guaranteed that the call canNOT * be reentered unless globus_thread_blocking_space_will_block() is called * (explicitly, or implicitly via globus_cond_wait()). Also, if - * globus_callback_unregister() is called to cancel this periodic from within + * globus_callback_unregister() is called to cancel this periodic from within * this callback, it is guaranteed that the callback will NOT be requeued again - * - * If the function will block at all, the user should call + * + * If the function will block at all, the user should call * globus_callback_get_timeout() to see how long this function can safely block * or call globus_thread_blocking_space_will_block() * @@ -324,7 +324,7 @@ void * * @details * This function registers the callback_func to start some delay_time from - * now. + * now. * * @param callback_handle * Storage for a handle. This may be NULL. If it is NOT NULL, you @@ -347,7 +347,7 @@ void * - GLOBUS_CALLBACK_ERROR_INVALID_ARGUMENT * - GLOBUS_CALLBACK_ERROR_MEMORY_ALLOC * - GLOBUS_SUCCESS - * + * * @see globus_callback_func_t * @see globus_callback_spaces */ @@ -371,7 +371,7 @@ globus_callback_space_register_oneshot( * @ingroup globus_callback_api * * @details - * This function registers a periodic callback_func to start some delay_time + * This function registers a periodic callback_func to start some delay_time * and run every period from then. * * @param callback_handle @@ -398,7 +398,7 @@ globus_callback_space_register_oneshot( * - GLOBUS_CALLBACK_ERROR_INVALID_ARGUMENT * - GLOBUS_CALLBACK_ERROR_MEMORY_ALLOC * - GLOBUS_SUCCESS - * + * * @see #globus_callback_unregister() * @see #globus_callback_func_t * @see @link globus_callback_spaces @endlink @@ -452,7 +452,7 @@ globus_callback_space_register_periodic( * - GLOBUS_CALLBACK_ERROR_INVALID_CALLBACK_HANDLE * - GLOBUS_CALLBACK_ERROR_ALREADY_CANCELED * - GLOBUS_SUCCESS - * + * * @see #globus_callback_space_register_periodic() * @see #globus_callback_func_t */ @@ -487,7 +487,7 @@ globus_callback_unregister( * - GLOBUS_CALLBACK_ERROR_INVALID_CALLBACK_HANDLE * - GLOBUS_CALLBACK_ERROR_ALREADY_CANCELED * - GLOBUS_SUCCESS - * + * * @see globus_callback_space_register_periodic() */ globus_result_t @@ -508,7 +508,7 @@ globus_callback_adjust_oneshot( * until another time by passing a period of NULL. The callback can later * be resumed by passing in a new period. * - * Note that the callback will not be fired sooner than 'new_period' from now. + * Note that the callback will not be fired sooner than 'new_period' from now. * A 'suspended' callback must still be unregistered to free its resources. * * @param callback_handle @@ -524,7 +524,7 @@ globus_callback_adjust_oneshot( * - GLOBUS_CALLBACK_ERROR_INVALID_CALLBACK_HANDLE * - GLOBUS_CALLBACK_ERROR_ALREADY_CANCELED * - GLOBUS_SUCCESS - * + * * @see globus_callback_space_register_periodic() */ globus_result_t @@ -543,25 +543,25 @@ globus_callback_adjust_period( * @ingroup globus_callback_api * * @details - * This function is used to poll for registered callbacks. + * This function is used to poll for registered callbacks. * * For non-threaded builds, callbacks are not/can not be delivered unless this - * is called. Any call to this can cause callbacks registered with the - * 'global' space to be fired. Whereas callbacks registered with a user's + * is called. Any call to this can cause callbacks registered with the + * 'global' space to be fired. Whereas callbacks registered with a user's * space will only be delivered when this is called with that space. * * For threaded builds, this only needs to be called to poll user spaces with * behavior == GLOBUS_CALLBACK_SPACE_BEHAVIOR_SINGLE. The 'global' space - * and other user spaces are constantly polled in a separate thread. + * and other user spaces are constantly polled in a separate thread. * (If it is called in a threaded build for these spaces, it will just yield * its thread) * * In general, you never need to call this function directly. It is called * (when necessary) by globus_cond_wait(). The only case in which a user may - * wish to call this explicitly is if the application has no aspirations of + * wish to call this explicitly is if the application has no aspirations of * ever being built threaded. * - * This function (when not yielding) will block up to timestop or until + * This function (when not yielding) will block up to timestop or until * globus_callback_signal_poll() is called by one of the fired callbacks. It * will always try and kick out ready callbacks, regardless of the timestop. * @@ -591,12 +591,9 @@ globus_callback_space_poll( * * In general, you never need to call this function directly. It is called * (when necessary) by globus_cond_signal() or globus_cond_broadcast. The only - * case in which a user may wish to call this explicitly is if the application + * case in which a user may wish to call this explicitly is if the application * has no aspirations of ever being built threaded. * - * @return - * - void - * * @see globus_callback_space_poll() */ void @@ -615,8 +612,8 @@ globus_callback_signal_poll(); * @details * This function retrieves the remaining time a callback is allowed to run. * If a callback has already timed out, time_left will be set to zero and - * GLOBUS_TRUE returned. This function is intended to be called within a - * callback's stack, but is harmless to call anywhere (will return + * GLOBUS_TRUE returned. This function is intended to be called within a + * callback's stack, but is harmless to call anywhere (will return * GLOBUS_FALSE and an infinite time_left) * * @param time_left @@ -651,8 +648,8 @@ globus_callback_has_time_expired(); * @ingroup globus_callback_api * * @details - * If the callback is a oneshot, this merely means the callback called - * globus_thread_blocking_space_will_block (or globus_cond_wait() at + * If the callback is a oneshot, this merely means the callback called + * globus_thread_blocking_space_will_block (or globus_cond_wait() at * some point. * * For a periodic, it signifies the same and also that the periodic has been @@ -682,7 +679,7 @@ globus_callback_was_restarted(); * @details * The 'global' space handle. * - * This is the default space handle implied if no spaces are + * This is the default space handle implied if no spaces are * explicitly created. */ #define GLOBUS_CALLBACK_GLOBAL_SPACE -2 @@ -695,25 +692,25 @@ globus_callback_was_restarted(); * In a non-threaded build all spaces exhibit a * behavior == _BEHAVIOR_SINGLE. Setting a specific behavior in this case * is ignored. - * + * * In a threaded build, _BEHAVIOR_SINGLE retains all the rules and * behaviors of a non-threaded build while _BEHAVIOR_THREADED makes the * space act as the global space. * - * Setting a space's behavior to _BEHAVIOR_SINGLE guarantees that the + * Setting a space's behavior to _BEHAVIOR_SINGLE guarantees that the * poll protection will always be there and all callbacks are serialized and * only kicked out when polled for. In a threaded build, it is still necessary * to poll for callbacks in a _BEHAVIOR_SINGLE space. (globus_cond_wait() * will take care of this for you also) * - * Setting a space's behavior to _BEHAVIOR_SERIALIZED guarantees that the + * Setting a space's behavior to _BEHAVIOR_SERIALIZED guarantees that the * poll protection will always be there and all callbacks are serialized. In a - * threaded build, it is NOT necessary to poll for callbacks in a + * threaded build, it is NOT necessary to poll for callbacks in a * _BEHAVIOR_SERIALIZED space. Callbacks in this space will be delivered as * soon as possible, but only one outstanding (and unblocked) callback will be * allowed at any time. * - * Setting a space's behavior to _BEHAVIOR_THREADED allows the user to + * Setting a space's behavior to _BEHAVIOR_THREADED allows the user to * have the poll protection provided by spaces when built non-threaded, yet, * be fully threaded when built threaded (where poll protection is not needed) */ @@ -723,7 +720,7 @@ typedef enum * and single threaded behavior (callbacks need to be explicitly polled for */ GLOBUS_CALLBACK_SPACE_BEHAVIOR_SINGLE, - /** Indicates that you want poll protection and all callbacks to be + /** Indicates that you want poll protection and all callbacks to be * serialized (but they do not need to be polled for in a threaded build) */ GLOBUS_CALLBACK_SPACE_BEHAVIOR_SERIALIZED, @@ -788,20 +785,20 @@ globus_callback_space_reference( * * @details * This will destroy a reference to a previously initialized space. Space will - * not actually be destroyed until all callbacks registered with this space + * not actually be destroyed until all callbacks registered with this space * have been run and unregistered (if the user has a handle to that callback) * AND all references (from globus_callback_space_reference()) have been * destroyed. * * @param space - * space to destroy, previously initialized by - * globus_callback_space_init() or referenced with + * space to destroy, previously initialized by + * globus_callback_space_init() or referenced with * globus_callback_space_reference() * * @return * - GLOBUS_CALLBACK_ERROR_INVALID_SPACE * - GLOBUS_SUCCESS - * + * * @see globus_callback_space_init() * @see globus_callback_space_reference() */ @@ -835,13 +832,13 @@ globus_callback_space_attr_init( * @ingroup globus_callback_spaces * @details * @param attr - * attr to destroy, previously initialized with + * attr to destroy, previously initialized with * globus_callback_space_attr_init() * * @return * - GLOBUS_CALLBACK_ERROR_INVALID_ARGUMENT on NULL attr * - GLOBUS_SUCCESS - * + * * @see globus_callback_space_attr_init() */ globus_result_t @@ -861,7 +858,7 @@ globus_callback_space_attr_destroy( * @return * - GLOBUS_CALLBACK_ERROR_INVALID_ARGUMENT * - GLOBUS_SUCCESS - * + * * @see globus_callback_space_behavior_t */ globus_result_t @@ -925,7 +922,7 @@ globus_callback_space_get_depth( globus_callback_space_t space); /** - * @brief See if the specified space is a single threaded behavior space + * @brief See if the specified space is a single threaded behavior space * @ingroup globus_callback_spaces * * @param space @@ -949,7 +946,7 @@ globus_callback_space_is_single( /** * @hideinitializer * @ingroup globus_callback_signal - * + * * @details * Use this to trap interrupts (SIGINT on unix). In the future, this will * also map to handle ctrl-C on win32. @@ -963,7 +960,7 @@ globus_callback_space_is_single( /** * @brief Fire a callback when the specified signal is received. * @ingroup globus_callback_signal - * + * * @details * Note that there is a tiny delay between the time this call returns * and the signal is actually handled by this library. It is likely that, if @@ -1006,7 +1003,7 @@ globus_callback_space_register_signal_handler( /** * @brief Unregister a signal handling callback * @ingroup globus_callback_signal - * + * * @param signum * The signal to unregister. * @@ -1036,29 +1033,29 @@ globus_callback_unregister_signal_handler( /** * @brief Register a wakeup handler with callback library * @ingroup globus_callback_signal - * + * * @details * This is really only needed in non-threaded builds, but for cross builds * should be used everywhere that a callback may sleep for an extended period * of time. - * + * * An example use is for an io poller that sleeps indefinitely on select(). If * the callback library receives a signal that it needs to deliver asap, it * will call the wakeup handler(s), These wakeup handlers must run as though * they were called from a signal handler (don't use any thread utilities). * The io poll example will likely write a single byte to a pipe that select() * is monitoring. - * + * * This handler will not be unregistered until the callback library is * deactivated (via common). - * + * * @param wakeup * function to call when callback library needs you to return asap * from any blocked callbacks. - * + * * @param user_arg * user data that will be passed along in the wakeup handler - * + * */ void globus_callback_add_wakeup_handler( diff --git a/common/source/library/globus_error_errno.c b/common/source/library/globus_error_errno.c index 90c7033842..62fff6b3f3 100644 --- a/common/source/library/globus_error_errno.c +++ b/common/source/library/globus_error_errno.c @@ -49,7 +49,7 @@ * The resulting error object. It is the user's responsibility * to eventually free this object using globus_object_free(). A * globus_result_t may be obtained by calling - * globus_error_put() on this object. + * globus_error_put() on this object. */ globus_object_t * globus_error_construct_errno_error( @@ -83,7 +83,7 @@ globus_error_construct_errno_error( /** * Initialize a previously allocated error of type * GLOBUS_ERROR_TYPE_ERRNO - * @ingroup globus_errno_error_object + * @ingroup globus_errno_error_object * * @param error * The previously allocated error object. @@ -125,7 +125,7 @@ globus_error_initialize_errno_error( /*@{*/ /** * Retrieve the system errno from a errno error object. - * @ingroup globus_errno_error_accessor + * @ingroup globus_errno_error_accessor * * @param error * The error from which to retrieve the errno @@ -151,14 +151,12 @@ globus_error_errno_get_errno( /*@{*/ /** * Set the errno in a errno error object. - * @ingroup globus_errno_error_accessor + * @ingroup globus_errno_error_accessor * * @param error * The error object for which to set the errno * @param system_errno * The system errno - * @return - * void */ void globus_error_errno_set_errno( @@ -181,7 +179,7 @@ globus_error_errno_set_errno( /** * Check whether the error originated from a specific module and * matches a specific errno. - * @ingroup globus_errno_error_utility + * @ingroup globus_errno_error_utility * * This function checks whether the error or any of it's causative * errors originated from a specific module and contains a specific @@ -207,7 +205,7 @@ globus_error_errno_match( globus_object_t * errno_error = NULL; globus_module_descriptor_t * source_module; int current_errno; - + if(error == NULL) { return GLOBUS_FALSE; @@ -226,7 +224,7 @@ globus_error_errno_match( source_module = globus_error_get_source(errno_error); current_errno = globus_error_errno_get_errno(errno_error); - + if(source_module == module && current_errno == system_errno) { return GLOBUS_TRUE; @@ -244,7 +242,7 @@ globus_error_errno_match( /*@{*/ /** * @brief Search for an errno value in an error chain - * @ingroup globus_errno_error_utility + * @ingroup globus_errno_error_utility * @details * This function searches the error object and its causal errors for * an error of type GLOBUS_ERROR_TYPE_ERRNO and returns the errno @@ -256,14 +254,14 @@ globus_error_errno_match( * @return * This function returns 0 if no errorno is found, otherwise the * error. - * + * */ int globus_error_errno_search( globus_object_t * error) { int current_errno; - + if(error == NULL) { return 0; @@ -289,7 +287,7 @@ globus_error_errno_search( /** * Allocate and initialize an error of type GLOBUS_ERROR_TYPE_GLOBUS * which contains a causal error of type GLOBUS_ERROR_TYPE_ERRNO. - * @ingroup globus_errno_error_utility + * @ingroup globus_errno_error_utility * * @param base_source * Pointer to the originating module. @@ -315,7 +313,7 @@ globus_error_errno_search( * The resulting error object. It is the user's responsibility * to eventually free this object using globus_object_free(). A * globus_result_t may be obtained by calling - * globus_error_put() on this object. + * globus_error_put() on this object. */ globus_object_t * globus_error_wrap_errno_error( @@ -343,9 +341,9 @@ globus_error_wrap_errno_error( { return GLOBUS_NULL; } - + va_start(ap, short_desc_format); - + sys_error = strerror(system_errno); if(sys_error) { @@ -356,12 +354,12 @@ globus_error_wrap_errno_error( sprintf(fmt, "%s: %s", short_desc_format, sys_error); } } - + if(!fmt) { fmt = (char *) short_desc_format; } - + error = globus_error_v_construct_error( base_source, causal_error, @@ -373,19 +371,19 @@ globus_error_wrap_errno_error( ap); va_end(ap); - + if(fmt != short_desc_format) { globus_free(fmt); } - + if(error == GLOBUS_NULL) { globus_object_free(causal_error); } - + return error; - + }/* globus_error_wrap_errno_error */ /*@}*/ diff --git a/common/source/library/globus_error_generic.c b/common/source/library/globus_error_generic.c index 1c11b84b76..21dac77d57 100644 --- a/common/source/library/globus_error_generic.c +++ b/common/source/library/globus_error_generic.c @@ -79,7 +79,7 @@ typedef struct * The resulting error object. It is the user's responsibility * to eventually free this object using globus_object_free(). A * globus_result_t may be obtained by calling - * globus_error_put() on this object. + * globus_error_put() on this object. */ globus_object_t * globus_error_construct_error( @@ -148,7 +148,7 @@ globus_error_construct_error( * The resulting error object. It is the user's responsibility * to eventually free this object using globus_object_free(). A * globus_result_t may be obtained by calling - * globus_error_put() on this object. + * globus_error_put() on this object. */ globus_object_t * globus_error_v_construct_error( @@ -192,7 +192,7 @@ globus_error_v_construct_error( /** * Initialize a previously allocated error of type * GLOBUS_ERROR_TYPE_GLOBUS - * @ingroup globus_generic_error_object + * @ingroup globus_generic_error_object * * @param error * The previously allocated error object. @@ -241,7 +241,7 @@ globus_error_initialize_error( { return NULL; } - + instance_data = (globus_l_error_data_t *) malloc(sizeof(globus_l_error_data_t)); @@ -263,12 +263,12 @@ globus_error_initialize_error( va_end(ap_copy); size++; - + if ((instance_data->short_desc = malloc (size)) == NULL) { return NULL; } - + globus_libc_vsnprintf(instance_data->short_desc, size, short_desc_format, @@ -289,7 +289,7 @@ globus_error_initialize_error( /*@{*/ /** * Retrieve the originating module descriptor from a error object. - * @ingroup globus_generic_error_accessor + * @ingroup globus_generic_error_accessor * * @param error * The error from which to retrieve the module descriptor @@ -310,14 +310,12 @@ globus_error_get_source( /*@{*/ /** * Set the originating module descriptor in a error object. - * @ingroup globus_generic_error_accessor + * @ingroup globus_generic_error_accessor * * @param error * The error object for which to set the causative error * @param source_module * The originating module descriptor - * @return - * void */ void globus_error_set_source( @@ -334,7 +332,7 @@ globus_error_set_source( /*@{*/ /** * Retrieve the underlying error from a error object. - * @ingroup globus_generic_error_accessor + * @ingroup globus_generic_error_accessor * * @param error * The error from which to retrieve the causative error. @@ -357,14 +355,12 @@ globus_error_get_cause ( /*@{*/ /** * Set the causative error in a error object. - * @ingroup globus_generic_error_accessor + * @ingroup globus_generic_error_accessor * * @param error * The error object for which to set the causative error. * @param causal_error * The causative error. - * @return - * void */ void globus_error_set_cause ( @@ -382,7 +378,7 @@ globus_error_set_cause ( /*@{*/ /** * Retrieve the error type from a generic globus error object. - * @ingroup globus_generic_error_accessor + * @ingroup globus_generic_error_accessor * * @param error * The error from which to retrieve the error type @@ -394,7 +390,7 @@ globus_error_get_type( globus_object_t * error) { globus_object_t * tmp; - + if ((tmp = globus_object_upcast(error, GLOBUS_ERROR_TYPE_GLOBUS)) != NULL) { return ((globus_l_error_data_t *) @@ -418,14 +414,12 @@ globus_error_get_type( /*@{*/ /** * Set the error type in a generic globus error object. - * @ingroup globus_generic_error_accessor + * @ingroup globus_generic_error_accessor * * @param error * The error object for which to set the error type * @param type * The error type - * @return - * void */ void globus_error_set_type( @@ -449,8 +443,8 @@ globus_error_set_type( /*@{*/ /** * Retrieve the short error description from a generic globus error - * object. - * @ingroup globus_generic_error_accessor + * object. + * @ingroup globus_generic_error_accessor * * @param error * The error from which to retrieve the description @@ -479,8 +473,8 @@ globus_error_get_short_desc( */ /*@{*/ /** - * Set the short error description in a generic globus error object. - * @ingroup globus_generic_error_accessor + * Set the short error description in a generic globus error object. + * @ingroup globus_generic_error_accessor * * @param error * The error object for which to set the description @@ -489,8 +483,6 @@ globus_error_get_short_desc( * of the error. To be passed on to the user. * @param ... * Arguments for the format string. - * @return - * void */ void globus_error_set_short_desc( @@ -501,7 +493,7 @@ globus_error_set_short_desc( char ** instance_short_desc; va_list ap; int size; - + if ((error = globus_object_upcast(error, GLOBUS_ERROR_TYPE_GLOBUS)) == NULL) { return; @@ -509,7 +501,7 @@ globus_error_set_short_desc( instance_short_desc = &((globus_l_error_data_t *) globus_object_get_local_instance_data(error))->short_desc; - + if(*instance_short_desc != NULL) { globus_libc_free(*instance_short_desc); @@ -522,7 +514,7 @@ globus_error_set_short_desc( size = globus_libc_vprintf_length(short_desc_format,ap); va_end(ap); - + size++; if ((*instance_short_desc = malloc (size)) == NULL) @@ -531,14 +523,14 @@ globus_error_set_short_desc( } va_start(ap, short_desc_format); - + globus_libc_vsnprintf(*instance_short_desc, size, short_desc_format, ap); va_end(ap); - + return; }/* globus_error_set_short_desc */ /*@}*/ @@ -550,8 +542,8 @@ globus_error_set_short_desc( /*@{*/ /** * Retrieve the long error description from a generic globus error - * object. - * @ingroup globus_generic_error_accessor + * object. + * @ingroup globus_generic_error_accessor * * @param error * The error from which to retrieve the description @@ -578,15 +570,13 @@ globus_error_get_long_desc( /*@{*/ /** * Set the long error description in a generic globus error object. - * @ingroup globus_generic_error_accessor + * @ingroup globus_generic_error_accessor * * @param error * The error object for which to set the description * @param long_desc_format * Longer format string giving a more detailed explanation of - * the error. - * @return - * void + * the error. */ void globus_error_set_long_desc( @@ -597,7 +587,7 @@ globus_error_set_long_desc( char ** instance_long_desc; va_list ap; int size; - + if ((error = globus_object_upcast(error, GLOBUS_ERROR_TYPE_GLOBUS)) == NULL) { return; @@ -605,7 +595,7 @@ globus_error_set_long_desc( instance_long_desc = &((globus_l_error_data_t *) globus_object_get_local_instance_data(error))->long_desc; - + if(*instance_long_desc != NULL) { globus_libc_free(*instance_long_desc); @@ -633,7 +623,7 @@ globus_error_set_long_desc( long_desc_format, ap); va_end(ap); - + return; }/* globus_error_set_long_desc */ /*@}*/ @@ -646,7 +636,7 @@ globus_error_set_long_desc( /** * Check whether the error originated from a specific module and is of * a specific type. - * @ingroup globus_generic_error_utility + * @ingroup globus_generic_error_utility * * This function checks whether the error or any of it's causative * errors originated from a specific module and is of a specific @@ -672,12 +662,12 @@ globus_error_match( globus_module_descriptor_t * source_module; int error_type; globus_object_t * tmp; - + if(error == NULL) { return GLOBUS_FALSE; } - + if ((tmp = globus_object_upcast(error, GLOBUS_ERROR_TYPE_GLOBUS)) != NULL) { error = tmp; @@ -696,7 +686,7 @@ globus_error_match( } source_module = globus_error_get_source(error); error_type = globus_error_get_type(error); - + if(source_module == module && error_type == type) { return GLOBUS_TRUE; @@ -719,7 +709,7 @@ globus_error_match( /** * Return a string containing all printable errors found in a error * object and it's causative error chain. - * @ingroup globus_generic_error_utility + * @ingroup globus_generic_error_utility * * If the GLOBUS_ERROR_VERBOSE env is set, file, line and function info will * also be printed (where available). Otherwise, only the module name will @@ -739,7 +729,7 @@ globus_error_print_chain( char * tmp; int length = 0; globus_object_t * current_error; - + current_error = error; error_string = (char *) globus_libc_malloc(1); @@ -749,12 +739,12 @@ globus_error_print_chain( if(tmp != NULL) { int l; - + l = strlen(tmp); if(l) { char * ns; - + ns = (char *) globus_libc_realloc( error_string, length + l + 2); if(ns) @@ -769,15 +759,15 @@ globus_error_print_chain( } } while((current_error = globus_error_get_cause(current_error))); - + error_string[length] = '\0'; - + if(length == 0) { globus_libc_free(error_string); error_string = NULL; } - + return error_string; }/* globus_error_print_chain */ /*@}*/ @@ -794,7 +784,7 @@ globus_l_error_multiple_print( char ** free_ptrs = NULL; char * error_string; int i = 0; - + if ((error = globus_object_upcast(error, GLOBUS_ERROR_TYPE_MULTIPLE)) == NULL) { return NULL; @@ -810,28 +800,28 @@ globus_l_error_multiple_print( { globus_list_t * tmp; int j = 0; - + if(data->desc && *data->desc) { layout[i++] = data->desc; layout[i++] = "\n"; } - + for(tmp = data->chains; - !globus_list_empty(tmp); + !globus_list_empty(tmp); tmp = globus_list_rest(tmp)) { globus_l_error_multiple_chain_t * instance; - + instance = (globus_l_error_multiple_chain_t *) globus_list_first(tmp); - + if(instance->desc && *instance->desc) { layout[i++] = instance->desc; layout[i++] = "\n"; } - + if(friendly) { free_ptrs[j++] = layout[i++] = @@ -839,13 +829,13 @@ globus_l_error_multiple_print( } else { - free_ptrs[j++] = layout[i++] = + free_ptrs[j++] = layout[i++] = globus_error_print_chain(instance->chain); } } } } - + error_string = layout ? globus_libc_join((const char **) layout, i) : NULL; if(layout) { @@ -892,7 +882,7 @@ globus_l_add_error_string( layout[(*idx)++] = "\n"; } } - + return msg; } @@ -908,7 +898,7 @@ globus_l_add_error_string( * @ingroup globus_generic_error_utility * * If the GLOBUS_ERROR_VERBOSE env is set, then the result from - * globus_error_print_chain() will be used. + * globus_error_print_chain() will be used. * * @param error * The error to print @@ -932,16 +922,16 @@ globus_error_print_friendly( char * bottom3 = NULL; char * verbose = NULL; globus_bool_t verbose_allowed = GLOBUS_TRUE; - + if(!error) { return NULL; } - + if(globus_i_error_verbose) { int * in_progress; - + in_progress = (int *) globus_thread_getspecific(globus_i_error_verbose_key); if(in_progress) @@ -954,7 +944,7 @@ globus_error_print_friendly( globus_i_error_verbose_key, (int *) 0x01); } } - + if(globus_i_error_verbose && verbose_allowed) { verbose = globus_error_print_chain(error); @@ -962,7 +952,7 @@ globus_error_print_friendly( { layout[i++] = verbose; } - + globus_thread_setspecific(globus_i_error_verbose_key, NULL); } else @@ -970,7 +960,7 @@ globus_error_print_friendly( globus_object_t * source_error1 = NULL; globus_object_t * source_error2 = NULL; globus_object_t * source_error3; - + /* here we only take the top error and the bottom 3 */ current_error = error; do @@ -986,9 +976,9 @@ globus_error_print_friendly( globus_object_get_type(current_error)); } } while((current_error = globus_error_get_cause(current_error))); - + top = globus_l_add_error_string(layout, &i, error); - + if(error != source_error1) { if(error != source_error2) @@ -998,22 +988,22 @@ globus_error_print_friendly( bottom3 = globus_l_add_error_string( layout, &i, source_error3); } - + bottom2 = globus_l_add_error_string(layout, &i, source_error2); } - + bottom1 = globus_l_add_error_string(layout, &i, source_error1); } - + if(friendly && *friendly) { layout[i++] = friendly; layout[i++] = "\n"; } } - + error_string = globus_libc_join((const char **) layout, i); - + if(top) { globus_free(top); @@ -1038,7 +1028,7 @@ globus_error_print_friendly( { globus_free(verbose); } - + return error_string; }/* globus_error_print_friendly */ /*@}*/ @@ -1053,7 +1043,7 @@ globus_error_print_friendly( * Construct a container object for multiple error chains. Useful when * an application tries many things (and each fails) before finally * giving up; - * + * * Use globus_error_mutliple_add_chain() to add error objects/chains to this * object. * @@ -1071,7 +1061,7 @@ globus_error_print_friendly( * The resulting error object. It is the user's responsibility * to eventually free this object using globus_object_free(). A * globus_result_t may be obtained by calling - * globus_error_put() on this object. + * globus_error_put() on this object. */ globus_object_t * globus_error_construct_multiple( @@ -1083,58 +1073,58 @@ globus_error_construct_multiple( globus_object_t * newerror; globus_object_t * error; globus_l_error_multiple_t * data; - + newerror = globus_object_construct(GLOBUS_ERROR_TYPE_MULTIPLE); if(!newerror) { goto error_object; } - + data = (globus_l_error_multiple_t *) globus_malloc(sizeof(globus_l_error_multiple_t)); if(!data) { goto error_data; } - + data->type = type; data->chains = NULL; data->desc = NULL; - + if(fmt) { int size; va_list ap; va_list ap_copy; - + va_start(ap, fmt); - + globus_libc_va_copy(ap_copy, ap); size = globus_libc_vprintf_length(fmt, ap_copy); va_end(ap_copy); - + data->desc = (char *) globus_malloc(size + 1); if(data->desc) { globus_libc_vsnprintf(data->desc, size + 1, fmt, ap); } - + va_end(ap); } - + globus_object_set_local_instance_data(newerror, data); error = globus_error_initialize_base(newerror, base_source, NULL); if(!error) { goto error_construct; } - + return error; error_construct: error_data: globus_object_free(newerror); - + error_object: return NULL; } @@ -1150,8 +1140,6 @@ globus_error_construct_multiple( * over 'chain''s memory after this call. * @param fmt * a printf style format string describing this chain - * @return - * void */ void globus_error_mutliple_add_chain( @@ -1162,7 +1150,7 @@ globus_error_mutliple_add_chain( { globus_l_error_multiple_t * data; globus_l_error_multiple_chain_t * instance; - + data = (globus_l_error_multiple_t *) globus_object_get_local_instance_data(multiple_error); if(data && chain) @@ -1173,28 +1161,28 @@ globus_error_mutliple_add_chain( { instance->chain = chain; instance->desc = NULL; - + if(fmt) { int size; va_list ap; va_list ap_copy; - + va_start(ap, fmt); - + globus_libc_va_copy(ap_copy, ap); size = globus_libc_vprintf_length(fmt, ap_copy); va_end(ap_copy); - + instance->desc = (char *) globus_malloc(size + 1); if(instance->desc) { globus_libc_vsnprintf(instance->desc, size + 1, fmt, ap); } - + va_end(ap); } - + globus_list_insert(&data->chains, instance); } } @@ -1215,13 +1203,13 @@ globus_error_multiple_remove_chain( { globus_l_error_multiple_t * data; globus_object_t * chain = NULL; - + data = (globus_l_error_multiple_t *) globus_object_get_local_instance_data(multiple_error); if(data && data->chains) { globus_l_error_multiple_chain_t * instance; - + instance = (globus_l_error_multiple_chain_t *) globus_list_remove(&data->chains, data->chains); chain = instance->chain; @@ -1231,7 +1219,7 @@ globus_error_multiple_remove_chain( } globus_free(instance); } - + return chain; } @@ -1243,28 +1231,28 @@ globus_l_error_multiple_copy( { globus_l_error_multiple_t * copy; globus_l_error_multiple_t * source; - + source = (globus_l_error_multiple_t *) src; - copy = (globus_l_error_multiple_t *) + copy = (globus_l_error_multiple_t *) globus_malloc(sizeof(globus_l_error_multiple_t)); if(copy) { globus_list_t * tmp; - + copy->type = source->type; copy->chains = globus_list_copy(source->chains); copy->desc = source->desc ? globus_libc_strdup(source->desc) : NULL; - + for(tmp = copy->chains; - !globus_list_empty(tmp); + !globus_list_empty(tmp); tmp = globus_list_rest(tmp)) { globus_l_error_multiple_chain_t * instance; globus_l_error_multiple_chain_t * new_instance; - + instance = (globus_l_error_multiple_chain_t *) globus_list_first(tmp); - + new_instance = (globus_l_error_multiple_chain_t *) globus_malloc(sizeof(globus_l_error_multiple_chain_t)); if(new_instance) @@ -1276,7 +1264,7 @@ globus_l_error_multiple_copy( globus_list_replace_first(tmp, new_instance); } } - + *dst = copy; } @@ -1286,14 +1274,14 @@ globus_l_error_multiple_destroy_all( void * data) { globus_l_error_multiple_chain_t * instance; - + if(!data) { return; } - + instance = (globus_l_error_multiple_chain_t *) data; - + globus_object_free(instance->chain); if(instance->desc) { @@ -1308,7 +1296,7 @@ globus_l_error_multiple_free( void * data) { globus_l_error_multiple_t * d; - + d = (globus_l_error_multiple_t *) data; if(d->chains) { @@ -1330,7 +1318,7 @@ globus_l_error_multiple_printable( return globus_l_error_multiple_print(error, GLOBUS_FALSE); } -const globus_object_type_t GLOBUS_ERROR_TYPE_MULTIPLE_DEFINITION = +const globus_object_type_t GLOBUS_ERROR_TYPE_MULTIPLE_DEFINITION = globus_error_type_static_initializer ( GLOBUS_ERROR_TYPE_BASE, globus_l_error_multiple_copy, diff --git a/common/source/library/globus_libc.c b/common/source/library/globus_libc.c index 03327dce3b..8d2ccfe29a 100644 --- a/common/source/library/globus_libc.c +++ b/common/source/library/globus_libc.c @@ -22,7 +22,7 @@ #endif /* GLOBUS_DONT_DOCUMENT_INTERNAL */ /****************************************************************************** - Include header files + Include header files ******************************************************************************/ #include "globus_i_common_config.h" #include "globus_common.h" @@ -56,13 +56,13 @@ extern int h_errno; extern globus_bool_t globus_i_module_initialized; /****************************************************************************** - Define module specific variables + Define module specific variables ******************************************************************************/ /* mutex to make globus_libc reentrant */ globus_mutex_t globus_libc_mutex; /****************************************************************************** - Module specific function prototypes + Module specific function prototypes ******************************************************************************/ static int globus_l_libc_copy_hostent_data_to_buffer( @@ -122,9 +122,9 @@ Function: globus_libc_strncasecmp ******************************************************************************/ int globus_libc_strncasecmp( - const char * s1, - const char * s2, - globus_size_t n) + const char * s1, + const char * s2, + globus_size_t n) { int rc; int save_errno; @@ -144,35 +144,35 @@ globus_libc_strncasecmp( for(ctr = 0; ctr < n; ctr++) { - if(s2[ctr] == '\0' && s1[ctr] == '\0') - { - rc = 0; - goto exit; - } - else if(s2[ctr] == '\0') - { - rc = -1; - goto exit; - } - else if(s1[ctr] == '\0') - { - rc = 1; - goto exit; - } + if(s2[ctr] == '\0' && s1[ctr] == '\0') + { + rc = 0; + goto exit; + } + else if(s2[ctr] == '\0') + { + rc = -1; + goto exit; + } + else if(s1[ctr] == '\0') + { + rc = 1; + goto exit; + } else - { + { ch1 = toupper(s2[ctr]); ch2 = toupper(s1[ctr]); if(ch2 > ch1) - { + { rc = 1; goto exit; - } + } else if(ch2 < ch1) - { + { rc = -1; goto exit; - } + } } } rc = 0; @@ -215,26 +215,26 @@ globus_l_libc_vsnprintf(char *s, size_t n, const char *format, va_list ap) if ( rc < 0 ) { - return rc; + return rc; } else if ( rc < n ) { - return vsprintf( s, format, ap ); + return vsprintf( s, format, ap ); } else { - char *buf = malloc( rc + 1 ); - if (buf == NULL) - { - return -1; - } - rc = vsprintf( buf, format, ap ); - save_errno = errno; - strncpy( s, buf, n - 1 ); - s[n - 1] = '\0'; - free( buf ); - errno = save_errno; - return rc; + char *buf = malloc( rc + 1 ); + if (buf == NULL) + { + return -1; + } + rc = vsprintf( buf, format, ap ); + save_errno = errno; + strncpy( s, buf, n - 1 ); + s[n - 1] = '\0'; + free( buf ); + errno = save_errno; + return rc; } } @@ -297,7 +297,7 @@ globus_libc_scan_off_t(char * s, globus_off_t * off, int * consumed) if(consumed == GLOBUS_NULL) { - consumed = &dummy; + consumed = &dummy; } globus_libc_lock(); @@ -324,7 +324,7 @@ globus_libc_gethostname(char *name, int len) static globus_mutex_t gethostname_mutex; static int initialized = GLOBUS_FALSE; char * env; - + globus_libc_lock(); if(initialized == GLOBUS_FALSE) { @@ -333,7 +333,7 @@ globus_libc_gethostname(char *name, int len) initialized = GLOBUS_TRUE; } globus_libc_unlock(); - + globus_mutex_lock(&gethostname_mutex); /* ToDo: This change should perhaps be applied to unix side as well? @@ -346,23 +346,23 @@ globus_libc_gethostname(char *name, int len) if ((env = getenv("GLOBUS_HOSTNAME")) != GLOBUS_NULL) { size_t hlen = strlen(env); - if (hlen < (size_t) len) - { - size_t i; - strcpy(name, env); - for (i=0; i < hlen; i++) - name[i] = tolower(name[i]); - globus_mutex_unlock(&gethostname_mutex); - return 0; - } - else - { - globus_mutex_unlock(&gethostname_mutex); - errno=EFAULT; - return(-1); - } - } - #else + if (hlen < (size_t) len) + { + size_t i; + strcpy(name, env); + for (i=0; i < hlen; i++) + name[i] = tolower(name[i]); + globus_mutex_unlock(&gethostname_mutex); + return 0; + } + else + { + globus_mutex_unlock(&gethostname_mutex); + errno=EFAULT; + return(-1); + } + } + #else if (hostname_length == 0U && (env = getenv("GLOBUS_HOSTNAME")) != GLOBUS_NULL) { @@ -382,7 +382,7 @@ globus_libc_gethostname(char *name, int len) globus_mutex_unlock(&gethostname_mutex); return(-1); } - + hostname_length = strlen(hostname); if(strchr(hostname, '.') != GLOBUS_NULL) { @@ -395,13 +395,13 @@ globus_libc_gethostname(char *name, int len) globus_mutex_unlock(&gethostname_mutex); return 0; } - + memset(&hints, 0, sizeof(globus_addrinfo_t)); hints.ai_flags = GLOBUS_AI_CANONNAME; hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = 0; - + result = globus_libc_getaddrinfo(hostname, NULL, &hints, &addrinfo); if(result == GLOBUS_SUCCESS) { @@ -410,7 +410,7 @@ globus_libc_gethostname(char *name, int len) strncpy(hostname, addrinfo->ai_canonname, sizeof(hostname)); hostname[sizeof(hostname) - 1] = 0; } - + globus_libc_freeaddrinfo(addrinfo); } } @@ -461,19 +461,19 @@ globus_libc_gethostaddr_by_family( globus_addrinfo_t * save_addrinfo; globus_addrinfo_t * addrinfo; globus_result_t result; - + rc = globus_libc_gethostname(hostname, sizeof(hostname)); if(rc < 0) { return rc; } - + memset(&hints, 0, sizeof(globus_addrinfo_t)); hints.ai_flags = 0; hints.ai_family = family; hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = 0; - + result = globus_libc_getaddrinfo( hostname, GLOBUS_NULL, &hints, &save_addrinfo); if(result != GLOBUS_SUCCESS) @@ -486,13 +486,13 @@ globus_libc_gethostaddr_by_family( if(GlobusLibcProtocolFamilyIsIP(addrinfo->ai_family)) { memcpy(addr, addrinfo->ai_addr, addrinfo->ai_addrlen); - + break; } } - + globus_libc_freeaddrinfo(save_addrinfo); - + return 0; } @@ -747,9 +747,6 @@ globus_libc_gethostbyname_r( struct hostent_data hp_data; int rc; # endif -# if defined(GLOBUS_HAVE_GETHOSTBYNAME_R_6) - int rc; -# endif globus_libc_lock(); @@ -757,8 +754,8 @@ globus_libc_gethostbyname_r( { hp = gethostbyname(hostname); - if(hp != GLOBUS_NULL) - { + if(hp != GLOBUS_NULL) + { memcpy(result, hp, sizeof(struct hostent)); if(globus_l_libc_copy_hostent_data_to_buffer( result, @@ -768,28 +765,28 @@ globus_libc_gethostbyname_r( hp = GLOBUS_NULL; } else - { + { hp = result; } - - if (h_errnop != GLOBUS_NULL) - { - *h_errnop = 0; - } - } - else - { - if (h_errnop != GLOBUS_NULL) - { - *h_errnop = h_errno; - } - } + + if (h_errnop != GLOBUS_NULL) + { + *h_errnop = 0; + } + } + else + { + if (h_errnop != GLOBUS_NULL) + { + *h_errnop = h_errno; + } + } } # elif defined(GLOBUS_HAVE_GETHOSTBYNAME_R_3) { - rc = gethostbyname_r(hostname, - result, - &hp_data); + rc = gethostbyname_r(hostname, + result, + &hp_data); if(rc == 0) { if(globus_l_libc_copy_hostent_data_to_buffer( @@ -798,7 +795,7 @@ globus_libc_gethostbyname_r( hp = GLOBUS_NULL; } else - { + { hp = result; } if(h_errnop != GLOBUS_NULL) @@ -818,23 +815,23 @@ globus_libc_gethostbyname_r( # elif defined(GLOBUS_HAVE_GETHOSTBYNAME_R_5) { hp = gethostbyname_r(hostname, - result, - buffer, - buflen, - h_errnop); + result, + buffer, + buflen, + h_errnop); } # elif defined(GLOBUS_HAVE_GETHOSTBYNAME_R_6) { - rc = gethostbyname_r(hostname, - result, - buffer, - buflen, - &hp, - h_errnop); + gethostbyname_r(hostname, + result, + buffer, + buflen, + &hp, + h_errnop); } # else { - GLOBUS_HAVE_GETHOSTBYNAME symbol must be defined!!!; + GLOBUS_HAVE_GETHOSTBYNAME symbol must be defined!!!; } # endif @@ -847,23 +844,23 @@ globus_libc_gethostbyname_r( */ if (hp == GLOBUS_NULL) { - if(isdigit(hostname[0])) - { - struct in_addr addr; - - addr.s_addr = inet_addr(hostname); - if ((int) addr.s_addr != -1) - { - hp = globus_libc_gethostbyaddr_r( - (void *) &addr, - sizeof(addr), - AF_INET, - result, - buffer, - buflen, - h_errnop); - } - } + if(isdigit(hostname[0])) + { + struct in_addr addr; + + addr.s_addr = inet_addr(hostname); + if ((int) addr.s_addr != -1) + { + hp = globus_libc_gethostbyaddr_r( + (void *) &addr, + sizeof(addr), + AF_INET, + result, + buffer, + buflen, + h_errnop); + } + } } return hp; @@ -881,34 +878,26 @@ Function: globus_libc_gethostbyaddr_r() ******************************************************************************/ struct hostent * globus_libc_gethostbyaddr_r(char *addr, - int length, - int type, - struct hostent *result, - char *buffer, - int buflen, - int *h_errnop) + int length, + int type, + struct hostent *result, + char *buffer, + int buflen, + int *h_errnop) { struct hostent *hp=GLOBUS_NULL; # if defined(GLOBUS_HAVE_GETHOSTBYADDR_R_5) struct hostent_data hp_data; - int rc; -# endif - -# if defined(GLOBUS_HAVE_GETHOSTBYADDR_R_8) - int rc; -# endif -# if defined(GLOBUS_HAVE_GETHOSTBYADDR_R_7) - int rc; + int rc; # endif - globus_libc_lock(); # if !defined(HAVE_GETHOSTBYADDR_R) { hp = gethostbyaddr(addr, length, type); - if(hp != GLOBUS_NULL) - { + if(hp != GLOBUS_NULL) + { memcpy(result, hp, sizeof(struct hostent)); if(globus_l_libc_copy_hostent_data_to_buffer( result, buffer, buflen) == -1) @@ -916,31 +905,31 @@ globus_libc_gethostbyaddr_r(char *addr, hp = GLOBUS_NULL; } else - { + { hp = result; } - if (h_errnop != GLOBUS_NULL) - { - *h_errnop = h_errno; - } - } - else - { - if (h_errnop != GLOBUS_NULL) - { - *h_errnop = h_errno; - } - } + if (h_errnop != GLOBUS_NULL) + { + *h_errnop = h_errno; + } + } + else + { + if (h_errnop != GLOBUS_NULL) + { + *h_errnop = h_errno; + } + } } # elif defined(GLOBUS_HAVE_GETHOSTBYADDR_R_5) { - rc = gethostbyaddr_r(addr, - length, - type, - result, - &hp_data); + rc = gethostbyaddr_r(addr, + length, + type, + result, + &hp_data); if(rc == 0) - { + { if(globus_l_libc_copy_hostent_data_to_buffer( result, buffer, buflen) == -1) { @@ -950,45 +939,45 @@ globus_libc_gethostbyaddr_r(char *addr, { hp = result; } - - if (h_errnop != GLOBUS_NULL) - { - *h_errnop = h_errno; - } + + if (h_errnop != GLOBUS_NULL) + { + *h_errnop = h_errno; + } } - else - { - hp = GLOBUS_NULL; - if (h_errnop != GLOBUS_NULL) - { - *h_errnop = h_errno; - } + else + { + hp = GLOBUS_NULL; + if (h_errnop != GLOBUS_NULL) + { + *h_errnop = h_errno; + } } } # elif defined(GLOBUS_HAVE_GETHOSTBYADDR_R_7) { hp = gethostbyaddr_r(addr, - length, - type, - result, - buffer, - buflen, - h_errnop); + length, + type, + result, + buffer, + buflen, + h_errnop); } # elif defined(GLOBUS_HAVE_GETHOSTBYADDR_R_8) { - rc = gethostbyaddr_r(addr, - length, - type, - result, - buffer, - buflen, - &hp, - h_errnop); + gethostbyaddr_r(addr, + length, + type, + result, + buffer, + buflen, + &hp, + h_errnop); } # else { - GLOBUS_HAVE_GETHOSTBYADDR symbol must be defined!!!; + GLOBUS_HAVE_GETHOSTBYADDR symbol must be defined!!!; } # endif @@ -1009,35 +998,35 @@ Function: globus_libc_ctime_r() ******************************************************************************/ char * globus_libc_ctime_r(time_t *clock, - char *buf, - int buflen) + char *buf, + int buflen) { char *tmp_buf; # if !defined(HAVE_CTIME_R) { - globus_libc_lock(); - tmp_buf = ctime(clock); + globus_libc_lock(); + tmp_buf = ctime(clock); - if(tmp_buf != GLOBUS_NULL) - { - strncpy(buf,tmp_buf,buflen); - } - globus_libc_unlock(); + if(tmp_buf != GLOBUS_NULL) + { + strncpy(buf,tmp_buf,buflen); + } + globus_libc_unlock(); - tmp_buf = buf; + tmp_buf = buf; } # endif # if defined(GLOBUS_HAVE_CTIME_R_2) { - tmp_buf = ctime_r(clock, buf); + tmp_buf = ctime_r(clock, buf); } # endif # if defined(GLOBUS_HAVE_CTIME_R_3) { - tmp_buf = ctime_r(clock, buf, buflen); + tmp_buf = ctime_r(clock, buf, buflen); } # endif @@ -1056,23 +1045,23 @@ Function: globus_libc_localtime_r() ******************************************************************************/ struct tm * globus_libc_localtime_r( - const time_t *timep, + const time_t *timep, struct tm *result) { struct tm * tmp_tm; - + # if !defined(HAVE_LOCALTIME_R) { - globus_libc_lock(); - tmp_tm = localtime(timep); + globus_libc_lock(); + tmp_tm = localtime(timep); - if(tmp_tm != GLOBUS_NULL) - { - memcpy(result, tmp_tm, sizeof(struct tm)); - } - globus_libc_unlock(); + if(tmp_tm != GLOBUS_NULL) + { + memcpy(result, tmp_tm, sizeof(struct tm)); + } + globus_libc_unlock(); - tmp_tm = result; + tmp_tm = result; } # else { @@ -1095,23 +1084,23 @@ Function: globus_libc_gmtime_r() ******************************************************************************/ struct tm * globus_libc_gmtime_r( - const time_t *timep, + const time_t *timep, struct tm *result) { struct tm * tmp_tm; - + # if !defined(HAVE_GMTIME_R) { - globus_libc_lock(); - tmp_tm = gmtime(timep); + globus_libc_lock(); + tmp_tm = gmtime(timep); - if(tmp_tm != GLOBUS_NULL) - { - memcpy(result, tmp_tm, sizeof(struct tm)); - } - globus_libc_unlock(); + if(tmp_tm != GLOBUS_NULL) + { + memcpy(result, tmp_tm, sizeof(struct tm)); + } + globus_libc_unlock(); - tmp_tm = result; + tmp_tm = result; } # else { @@ -1140,10 +1129,10 @@ Function: globus_libc_getpwnam_r() ******************************************************************************/ int globus_libc_getpwnam_r(char *name, - struct passwd *pwd, - char *buffer, - int buflen, - struct passwd **result) + struct passwd *pwd, + char *buffer, + int buflen, + struct passwd **result) { return getpwnam_r(name, pwd, buffer, buflen, result); } /* globus_libc_getpwnam_r */ @@ -1162,10 +1151,10 @@ Function: globus_libc_getpwuid_r() #endif int globus_libc_getpwuid_r(uid_t uid, - struct passwd *pwd, - char *buffer, - int buflen, - struct passwd **result) + struct passwd *pwd, + char *buffer, + int buflen, + struct passwd **result) { return getpwuid_r(uid, pwd, buffer, buflen, result); } /* globus_libc_getpwuid_r */ @@ -1191,25 +1180,25 @@ globus_l_libc_copy_hostent_data_to_buffer( char ** ptr; char ** ptr_buffer = (char **) buffer; int num_ptrs=0; - + /* list of addresses from name server */ if(h->h_addr_list != GLOBUS_NULL) { - for(ptr = h->h_addr_list; (*ptr) != GLOBUS_NULL; ptr++) - { - num_ptrs++; - } - num_ptrs++; + for(ptr = h->h_addr_list; (*ptr) != GLOBUS_NULL; ptr++) + { + num_ptrs++; + } + num_ptrs++; } if(h->h_aliases != GLOBUS_NULL) { - /* host aliases */ - for(ptr = h->h_aliases; *ptr != GLOBUS_NULL; ptr++) - { - num_ptrs++; - } - num_ptrs++; + /* host aliases */ + for(ptr = h->h_aliases; *ptr != GLOBUS_NULL; ptr++) + { + num_ptrs++; + } + num_ptrs++; } offset += num_ptrs * sizeof(char *); @@ -1218,68 +1207,68 @@ globus_l_libc_copy_hostent_data_to_buffer( { return -1; } - + /* official hostname of host */ if(h->h_name != NULL) - { - size_t name_len; + { + size_t name_len; - name_len = strlen(h->h_name); - if(name_len + 1 + offset > buflen) - { + name_len = strlen(h->h_name); + if(name_len + 1 + offset > buflen) + { return -1; - } + } strncpy(&buffer[offset], h->h_name, name_len); - buffer[offset + name_len] = '\0'; - h->h_name = &buffer[offset]; + buffer[offset + name_len] = '\0'; + h->h_name = &buffer[offset]; offset += name_len + 1; } /* list of addresses from name server */ if(h->h_addr_list != GLOBUS_NULL) { - size_t addrsize = h->h_length; + size_t addrsize = h->h_length; - ptr = h->h_addr_list; - h->h_addr_list = ptr_buffer; + ptr = h->h_addr_list; + h->h_addr_list = ptr_buffer; - for(; (*ptr) != GLOBUS_NULL; ptr++) - { - if(offset + addrsize > buflen) - { + for(; (*ptr) != GLOBUS_NULL; ptr++) + { + if(offset + addrsize > buflen) + { return -1; - } + } memcpy(&buffer[offset], *ptr, addrsize); *ptr_buffer = &buffer[offset]; ptr_buffer++; offset += addrsize; - } - *ptr_buffer = GLOBUS_NULL; - ptr_buffer++; - } + } + *ptr_buffer = GLOBUS_NULL; + ptr_buffer++; + } if(h->h_aliases != GLOBUS_NULL) { - ptr = h->h_aliases; - h->h_aliases = ptr_buffer; + ptr = h->h_aliases; + h->h_aliases = ptr_buffer; - /* host aliases */ - for(; *ptr != GLOBUS_NULL; ptr++) - { - if(strlen(*ptr) + offset + 1 > buflen) - { + /* host aliases */ + for(; *ptr != GLOBUS_NULL; ptr++) + { + if(strlen(*ptr) + offset + 1 > buflen) + { return -1; - } - + } + strcpy(&buffer[offset], *ptr); *ptr_buffer = &buffer[offset]; ptr_buffer++; offset += strlen(*ptr) + 1; - } - *ptr_buffer = GLOBUS_NULL; - ptr_buffer++; + } + *ptr_buffer = GLOBUS_NULL; + ptr_buffer++; } return 0; } /* globus_l_libc_copy_hostent_data_to_buffer() */ @@ -1342,59 +1331,59 @@ globus_libc_gethomedir(char *result, int bufsize) char * p; struct passwd * pwres; - + globus_libc_lock(); if (!initialized) { - globus_mutex_init(&gethomedir_mutex, - (globus_mutexattr_t *) GLOBUS_NULL); - initialized = GLOBUS_TRUE; + globus_mutex_init(&gethomedir_mutex, + (globus_mutexattr_t *) GLOBUS_NULL); + initialized = GLOBUS_TRUE; } globus_libc_unlock(); globus_mutex_lock(&gethomedir_mutex); { - rc = 0; - - if (homedir_len == 0) - { - p = getenv("HOME"); - if (!p || strlen(p)==0) - { - p = GLOBUS_NULL; - rc = globus_libc_getpwuid_r(geteuid(), - &pw, - buf, - 1024, - &pwres); - - if (!rc && pwres && pwres->pw_dir) - p = pwres->pw_dir; - } - - if (!rc && p) - { - len = strlen(p); - homedir = globus_malloc(len + 1); - if (homedir) - { - memcpy(homedir, p, len); - homedir[len] = '\0'; - homedir_len = strlen(homedir); - } - else - rc = -1; - } - } - - if (homedir_len > bufsize) - rc = -1; - - if (!rc) - { - memcpy(result, homedir, homedir_len); - result[homedir_len] = '\0'; - } + rc = 0; + + if (homedir_len == 0) + { + p = getenv("HOME"); + if (!p || strlen(p)==0) + { + p = GLOBUS_NULL; + rc = globus_libc_getpwuid_r(geteuid(), + &pw, + buf, + 1024, + &pwres); + + if (!rc && pwres && pwres->pw_dir) + p = pwres->pw_dir; + } + + if (!rc && p) + { + len = strlen(p); + homedir = globus_malloc(len + 1); + if (homedir) + { + memcpy(homedir, p, len); + homedir[len] = '\0'; + homedir_len = strlen(homedir); + } + else + rc = -1; + } + } + + if (homedir_len > bufsize) + rc = -1; + + if (!rc) + { + memcpy(result, homedir, homedir_len); + result[homedir_len] = '\0'; + } } globus_mutex_unlock(&gethomedir_mutex); @@ -1472,13 +1461,13 @@ globus_libc_strdup(const char * string) if(string) { - l = strlen(string); + l = strlen(string); - ns = globus_malloc(sizeof(char) * (l + 1)); - if(ns) - { - memcpy(ns, string, l + 1); - } + ns = globus_malloc(sizeof(char) * (l + 1)); + if(ns) + { + memcpy(ns, string, l + 1); + } } return ns; @@ -1500,7 +1489,7 @@ globus_libc_strndup(const char * string, globus_size_t length) { for(i = 0; i < length && string[i] != '\0'; i++) ns[i] = string[i]; - + ns[i] = '\0'; } } @@ -1526,8 +1515,8 @@ Function: globus_libc_lseek() int globus_libc_lseek(int fd, - globus_off_t offset, - int whence) + globus_off_t offset, + int whence) { int rc; int save_errno; @@ -1574,19 +1563,19 @@ globus_libc_telldir(DIR *dirp) if(dirp != GLOBUS_NULL) { - globus_libc_lock(); + globus_libc_lock(); - pos = telldir(dirp); - save_errno=errno; + pos = telldir(dirp); + save_errno=errno; - globus_libc_unlock(); - errno = save_errno; + globus_libc_unlock(); + errno = save_errno; - return pos; + return pos; } else { - return pos; + return pos; } } #endif /* defined(HAVE_TELLDIR) */ @@ -1595,21 +1584,21 @@ globus_libc_telldir(DIR *dirp) #undef globus_libc_seekdir extern void globus_libc_seekdir(DIR *dirp, - long loc) + long loc) { int save_errno; if(dirp != GLOBUS_NULL) { - globus_libc_lock(); + globus_libc_lock(); - seekdir(dirp, loc); + seekdir(dirp, loc); - save_errno = errno; + save_errno = errno; - globus_libc_unlock(); - errno = save_errno; - return; + globus_libc_unlock(); + errno = save_errno; + return; } } #endif /* defined(HAVE_SEEKDIR) */ @@ -1623,15 +1612,15 @@ globus_libc_rewinddir(DIR *dirp) if(dirp != GLOBUS_NULL) { - globus_libc_lock(); + globus_libc_lock(); - rewinddir(dirp); + rewinddir(dirp); - save_errno = errno; + save_errno = errno; - globus_libc_unlock(); - errno = save_errno; - return; + globus_libc_unlock(); + errno = save_errno; + return; } #else errno = EINVAL; @@ -1664,116 +1653,116 @@ globus_libc_closedir(DIR *dirp) #undef globus_libc_readdir_r extern int globus_libc_readdir_r(DIR *dirp, - struct dirent **result) + struct dirent **result) { #if HAVE_DIRENT_H #if !defined(HAVE_READDIR_R) { - struct dirent *tmpdir, *entry; - int save_errno; + struct dirent *tmpdir, *entry; + int save_errno; - globus_libc_lock(); + globus_libc_lock(); - tmpdir = readdir(dirp); - save_errno = errno; + tmpdir = readdir(dirp); + save_errno = errno; - if(tmpdir == GLOBUS_NULL) - { - *result = GLOBUS_NULL; + if(tmpdir == GLOBUS_NULL) + { + *result = GLOBUS_NULL; - globus_libc_unlock(); + globus_libc_unlock(); - errno = save_errno; + errno = save_errno; - return -1; - } + return -1; + } - entry = (struct dirent *) globus_malloc(offsetof(struct dirent, d_name) - + strlen(tmpdir->d_name) - + 1); + entry = (struct dirent *) globus_malloc(offsetof(struct dirent, d_name) + + strlen(tmpdir->d_name) + + 1); - /* copy returned buffer into data structure */ - entry->d_ino = tmpdir->d_ino; + /* copy returned buffer into data structure */ + entry->d_ino = tmpdir->d_ino; # if defined(GLOBUS_HAVE_DIRENT_OFF) - { - entry->d_off = tmpdir->d_off; - } + { + entry->d_off = tmpdir->d_off; + } # endif # if defined(GLOBUS_HAVE_DIRENT_OFFSET) - { - entry->d_offset = tmpdir->d_offset; - } + { + entry->d_offset = tmpdir->d_offset; + } # endif # if defined(GLOBUS_HAVE_DIRENT_TYPE) - { - entry->d_type = tmpdir->d_type; - } + { + entry->d_type = tmpdir->d_type; + } # endif -# if defined(GLOBUS_HAVE_DIRENT_RECLEN) - { - entry->d_reclen = tmpdir->d_reclen; - } +# if defined(GLOBUS_HAVE_DIRENT_RECLEN) + { + entry->d_reclen = tmpdir->d_reclen; + } # endif - strcpy(&entry->d_name[0], &tmpdir->d_name[0]); + strcpy(&entry->d_name[0], &tmpdir->d_name[0]); - *result = entry; - globus_libc_unlock(); - errno = save_errno; - return 0; + *result = entry; + globus_libc_unlock(); + errno = save_errno; + return 0; } # else { - int errno; + int errno; # if defined(GLOBUS_HAVE_READDIR_R_3) - { - int rc = 0; - struct dirent *entry = globus_malloc(offsetof(struct dirent, d_name) - + NAME_MAX - + 1); + { + int rc = 0; + struct dirent *entry = globus_malloc(offsetof(struct dirent, d_name) + + NAME_MAX + + 1); - rc = readdir_r(dirp, entry, result); + rc = readdir_r(dirp, entry, result); if(rc != 0 || *result == NULL) { - globus_free(entry); - *result = GLOBUS_NULL; + globus_free(entry); + *result = GLOBUS_NULL; } return rc; - } + } # elif defined(GLOBUS_HAVE_READDIR_R_2) - { - struct dirent *entry = globus_malloc(offsetof(struct dirent, d_name) - + NAME_MAX - + 1); - int rc=0; + { + struct dirent *entry = globus_malloc(offsetof(struct dirent, d_name) + + NAME_MAX + + 1); + int rc=0; # if defined(TARGET_ARCH_SOLARIS) - { - *result = readdir_r(dirp, entry); - if(*result == GLOBUS_NULL) - { - rc = -1; - } - } + { + *result = readdir_r(dirp, entry); + if(*result == GLOBUS_NULL) + { + rc = -1; + } + } # elif defined(TARGET_ARCH_HPUX) - { - rc = readdir_r(dirp, entry); - *result = entry; - } + { + rc = readdir_r(dirp, entry); + *result = entry; + } # endif - if(rc != GLOBUS_SUCCESS) - { - globus_free(entry); - *result = GLOBUS_NULL; - return rc; - } - else - { - return 0; - } - } + if(rc != GLOBUS_SUCCESS) + { + globus_free(entry); + *result = GLOBUS_NULL; + return rc; + } + else + { + return 0; + } + } # endif } # endif @@ -1787,14 +1776,14 @@ globus_libc_readdir_r(DIR *dirp, int globus_libc_vprintf_length(const char * fmt, va_list ap) { - static FILE * devnull = GLOBUS_NULL; + static FILE * devnull = GLOBUS_NULL; int save_errno; globus_libc_lock(); if(devnull == GLOBUS_NULL) { #ifndef _WIN32 - devnull = fopen("/dev/null", "w"); + devnull = fopen("/dev/null", "w"); if(devnull == GLOBUS_NULL) { @@ -1805,7 +1794,7 @@ globus_libc_vprintf_length(const char * fmt, va_list ap) } fcntl(fileno(devnull), F_SETFD, FD_CLOEXEC); #else - devnull = fopen("NUL", "w"); + devnull = fopen("NUL", "w"); if(devnull == GLOBUS_NULL) { save_errno = errno; @@ -1881,7 +1870,7 @@ globus_common_v_create_string( va_list ap_copy; globus_libc_va_copy(ap_copy,ap); - + len = globus_libc_vprintf_length(format,ap_copy); va_end(ap_copy); @@ -1890,19 +1879,19 @@ globus_common_v_create_string( { return NULL; } - + len++; if((new_string = malloc(len)) == NULL) { return NULL; } - + globus_libc_vsnprintf(new_string, len, format, ap); - + return new_string; } @@ -1970,37 +1959,37 @@ globus_libc_vsnprintf(char *s, size_t n, const char *format, va_list ap) STACK_DIRECTION = 0 => direction of growth unknown */ #ifndef STACK_DIRECTION -#define STACK_DIRECTION 0 /* Direction unknown. */ +#define STACK_DIRECTION 0 /* Direction unknown. */ #endif #if STACK_DIRECTION != 0 -#define STACK_DIR STACK_DIRECTION /* Known at compile-time. */ +#define STACK_DIR STACK_DIRECTION /* Known at compile-time. */ #else /* STACK_DIRECTION == 0; need run-time code. */ -static int stack_dir=0; /* 1 or -1 once known. */ -#define STACK_DIR stack_dir +static int stack_dir=0; /* 1 or -1 once known. */ +#define STACK_DIR stack_dir static void find_stack_direction () { - static char *addr = GLOBUS_NULL; /* Address of first `dummy', once known. */ - auto char dummy; /* To get stack address. */ + static char *addr = GLOBUS_NULL; /* Address of first `dummy', once known. */ + auto char dummy; /* To get stack address. */ if (addr == GLOBUS_NULL) - { /* Initial entry. */ + { /* Initial entry. */ addr = ADDRESS_FUNCTION (dummy); - find_stack_direction (); /* Recurse once. */ + find_stack_direction (); /* Recurse once. */ } else { /* Second entry. */ if (ADDRESS_FUNCTION (dummy) > addr) - stack_dir = 1; /* Stack grew upward. */ + stack_dir = 1; /* Stack grew upward. */ else - stack_dir = -1; /* Stack grew downward. */ + stack_dir = -1; /* Stack grew downward. */ } } @@ -2012,21 +2001,21 @@ find_stack_direction () It is very important that sizeof(header) agree with malloc alignment chunk size. The following default should work okay. */ -#ifndef ALIGN_SIZE -#define ALIGN_SIZE sizeof(double) +#ifndef ALIGN_SIZE +#define ALIGN_SIZE sizeof(double) #endif typedef union hdr { - char align[ALIGN_SIZE]; /* To force sizeof(header). */ + char align[ALIGN_SIZE]; /* To force sizeof(header). */ struct { - union hdr *next; /* For chaining headers. */ - char *deep; /* For stack depth measure. */ + union hdr *next; /* For chaining headers. */ + char *deep; /* For stack depth measure. */ } h; } header; -static header *last_alloca_header = GLOBUS_NULL; /* -> last alloca header. */ +static header *last_alloca_header = GLOBUS_NULL; /* -> last alloca header. */ /* Return a pointer to at least SIZE bytes of storage, which will be automatically reclaimed upon exit from @@ -2039,11 +2028,11 @@ void * alloca (size) unsigned size; { - auto char probe; /* Probes stack depth: */ + auto char probe; /* Probes stack depth: */ register char *depth = ADDRESS_FUNCTION (probe); #if STACK_DIRECTION == 0 - if (STACK_DIR == 0) /* Unknown growth direction. */ + if (STACK_DIR == 0) /* Unknown growth direction. */ find_stack_direction (); #endif @@ -2051,7 +2040,7 @@ alloca (size) was allocated from deeper in the stack than currently. */ { - register header *hp; /* Traverses linked list. */ + register header *hp; /* Traverses linked list. */ #ifdef emacs BLOCK_INPUT; @@ -2059,18 +2048,18 @@ alloca (size) for (hp = last_alloca_header; hp != GLOBUS_NULL;) if ((STACK_DIR > 0 && hp->h.deep > depth) - || (STACK_DIR < 0 && hp->h.deep < depth)) - { - register header *np = hp->h.next; + || (STACK_DIR < 0 && hp->h.deep < depth)) + { + register header *np = hp->h.next; - free ((void *) hp); /* Collect garbage. */ + free ((void *) hp); /* Collect garbage. */ - hp = np; /* -> next header. */ - } + hp = np; /* -> next header. */ + } else - break; /* Rest are not deeper. */ + break; /* Rest are not deeper. */ - last_alloca_header = hp; /* -> last valid storage. */ + last_alloca_header = hp; /* -> last valid storage. */ #ifdef emacs UNBLOCK_INPUT; @@ -2078,7 +2067,7 @@ alloca (size) } if (size == 0) - return GLOBUS_NULL; /* No allocation required. */ + return GLOBUS_NULL; /* No allocation required. */ /* Allocate combined header + user data storage. */ @@ -2107,10 +2096,10 @@ alloca (size) /* Stack structures for CRAY-1, CRAY X-MP, and CRAY Y-MP */ struct stack_control_header { - long shgrow:32; /* Number of times stack has grown. */ - long shaseg:32; /* Size of increments to stack. */ - long shhwm:32; /* High water mark of stack. */ - long shsize:32; /* Current size of stack (all segments). */ + long shgrow:32; /* Number of times stack has grown. */ + long shaseg:32; /* Size of increments to stack. */ + long shhwm:32; /* High water mark of stack. */ + long shsize:32; /* Current size of stack (all segments). */ }; /* The stack segment linkage control information occurs at @@ -2122,21 +2111,21 @@ struct stack_control_header struct stack_segment_linkage { - long ss[0200]; /* 0200 overflow words. */ - long sssize:32; /* Number of words in this segment. */ - long ssbase:32; /* Offset to stack base. */ + long ss[0200]; /* 0200 overflow words. */ + long sssize:32; /* Number of words in this segment. */ + long ssbase:32; /* Offset to stack base. */ long:32; - long sspseg:32; /* Offset to linkage control of previous - segment of stack. */ + long sspseg:32; /* Offset to linkage control of previous + segment of stack. */ long:32; - long sstcpt:32; /* Pointer to task common address block. */ - long sscsnm; /* Private control structure number for - microtasking. */ - long ssusr1; /* Reserved for user. */ - long ssusr2; /* Reserved for user. */ - long sstpid; /* Process ID for pid based multi-tasking. */ - long ssgvup; /* Pointer to multitasking thread giveup. */ - long sscray[7]; /* Reserved for Cray Research. */ + long sstcpt:32; /* Pointer to task common address block. */ + long sscsnm; /* Private control structure number for + microtasking. */ + long ssusr1; /* Reserved for user. */ + long ssusr2; /* Reserved for user. */ + long sstpid; /* Process ID for pid based multi-tasking. */ + long ssgvup; /* Pointer to multitasking thread giveup. */ + long sscray[7]; /* Reserved for Cray Research. */ long ssa0; long ssa1; long ssa2; @@ -2160,27 +2149,27 @@ struct stack_segment_linkage returned by the STKSTAT library routine. */ struct stk_stat { - long now; /* Current total stack size. */ - long maxc; /* Amount of contiguous space which would - be required to satisfy the maximum - stack demand to date. */ - long high_water; /* Stack high-water mark. */ - long overflows; /* Number of stack overflow ($STKOFEN) calls. */ - long hits; /* Number of internal buffer hits. */ - long extends; /* Number of block extensions. */ - long stko_mallocs; /* Block allocations by $STKOFEN. */ - long underflows; /* Number of stack underflow calls ($STKRETN). */ - long stko_free; /* Number of deallocations by $STKRETN. */ - long stkm_free; /* Number of deallocations by $STKMRET. */ - long segments; /* Current number of stack segments. */ - long maxs; /* Maximum number of stack segments so far. */ - long pad_size; /* Stack pad size. */ - long current_address; /* Current stack segment address. */ - long current_size; /* Current stack segment size. This - number is actually corrupted by STKSTAT to - include the fifteen word trailer area. */ - long initial_address; /* Address of initial segment. */ - long initial_size; /* Size of initial segment. */ + long now; /* Current total stack size. */ + long maxc; /* Amount of contiguous space which would + be required to satisfy the maximum + stack demand to date. */ + long high_water; /* Stack high-water mark. */ + long overflows; /* Number of stack overflow ($STKOFEN) calls. */ + long hits; /* Number of internal buffer hits. */ + long extends; /* Number of block extensions. */ + long stko_mallocs; /* Block allocations by $STKOFEN. */ + long underflows; /* Number of stack underflow calls ($STKRETN). */ + long stko_free; /* Number of deallocations by $STKRETN. */ + long stkm_free; /* Number of deallocations by $STKMRET. */ + long segments; /* Current number of stack segments. */ + long maxs; /* Maximum number of stack segments so far. */ + long pad_size; /* Stack pad size. */ + long current_address; /* Current stack segment address. */ + long current_size; /* Current stack segment size. This + number is actually corrupted by STKSTAT to + include the fifteen word trailer area. */ + long initial_address; /* Address of initial segment. */ + long initial_size; /* Size of initial segment. */ }; /* The following structure describes the data structure which trails @@ -2189,13 +2178,13 @@ struct stk_stat struct stk_trailer { - long this_address; /* Address of this block. */ - long this_size; /* Size of this block (does not include - this trailer). */ + long this_address; /* Address of this block. */ + long this_size; /* Size of this block (does not include + this trailer). */ long unknown2; long unknown3; - long link; /* Address of trailer block of previous - segment. */ + long link; /* Address of trailer block of previous + segment. */ long unknown5; long unknown6; long unknown7; @@ -2233,8 +2222,8 @@ globus_l_libc_i00afunc (long *address) /* Set up the iteration. */ trailer = (struct stk_trailer *) (status.current_address - + status.current_size - - 15); + + status.current_size + - 15); /* There must be at least one stack segment. Therefore it is a fatal error if "trailer" is null. */ @@ -2249,10 +2238,10 @@ globus_l_libc_i00afunc (long *address) block = (long *) trailer->this_address; size = trailer->this_size; if (block == 0 || size == 0) - abort (); + abort (); trailer = (struct stk_trailer *) trailer->link; if ((block <= address) && (address < (block + size))) - break; + break; } /* Set the result to the offset in this segment and add the sizes @@ -2268,7 +2257,7 @@ globus_l_libc_i00afunc (long *address) do { if (trailer->this_size <= 0) - abort (); + abort (); result += trailer->this_size; trailer = (struct stk_trailer *) trailer->link; } @@ -2331,7 +2320,7 @@ globus_l_libc_i00afunc (long address) fprintf (stderr, "%011o %011o %011o\n", this_segment, address, stkl); #endif if (pseg == 0) - break; + break; stkl = stkl - pseg; ssptr = (struct stack_segment_linkage *) stkl; size = ssptr->sssize; @@ -2377,11 +2366,11 @@ globus_l_libc_copy_addrinfo( globus_addrinfo_t * new_addrinfo; globus_addrinfo_t * addrinfo; char * canonname = NULL; - + addrinfo = in_addrinfo; if(addrinfo) { - new_addrinfo = (globus_addrinfo_t *) + new_addrinfo = (globus_addrinfo_t *) globus_malloc(sizeof(globus_addrinfo_t)); memcpy(new_addrinfo, addrinfo, sizeof(globus_addrinfo_t)); new_addrinfo->ai_addr = (struct sockaddr *) @@ -2397,19 +2386,19 @@ globus_l_libc_copy_addrinfo( addrinfo; addrinfo = addrinfo->ai_next) { - new_addrinfo->ai_next = (globus_addrinfo_t *) + new_addrinfo->ai_next = (globus_addrinfo_t *) globus_malloc(sizeof(globus_addrinfo_t)); new_addrinfo = new_addrinfo->ai_next; memcpy(new_addrinfo, addrinfo, sizeof(globus_addrinfo_t)); new_addrinfo->ai_addr = (struct sockaddr *) globus_malloc(addrinfo->ai_addrlen); - memcpy(new_addrinfo->ai_addr, addrinfo->ai_addr, + memcpy(new_addrinfo->ai_addr, addrinfo->ai_addr, addrinfo->ai_addrlen); new_addrinfo->ai_canonname = canonname; } } - - return 0; + + return 0; } #endif @@ -2423,7 +2412,7 @@ globus_libc_getaddrinfo( int rc; globus_result_t result; const char * port_str = service; - + #ifdef TARGET_ARCH_AIX5 if(port_str && port_str[0] == '0' && port_str[1] == '\0') { @@ -2434,7 +2423,7 @@ globus_libc_getaddrinfo( port_str = "56789"; } #endif - + result = GLOBUS_SUCCESS; rc = getaddrinfo(node, port_str, hints, res); @@ -2474,7 +2463,7 @@ globus_libc_getaddrinfo( #ifdef TARGET_ARCH_AIX5 { globus_addrinfo_t * addrinfo; - + /* aix's getaddrinfo also doesnt fill in the family and len fields of * the sockaddrs */ @@ -2526,7 +2515,7 @@ globus_libc_getnameinfo( /* * Code to work around a bug in getnameinfo() on OS X on Intel (bug * #4292 in Globus bugzilla). - * Problem observed on OS X 10.4.8: + * Problem observed on OS X 10.4.8: * getnameinfo() fails to convert port number to host byte order * when generating service port string. If the host is requested * in numeric form, a different code path in getnameinfo() is used @@ -2685,7 +2674,7 @@ globus_libc_addr_is_loopback( switch(_addr->sa_family) { case AF_INET: - if(*(uint8_t *) &((struct sockaddr_in *) + if(*(uint8_t *) &((struct sockaddr_in *) _addr)->sin_addr.s_addr == 127) { result = GLOBUS_TRUE; @@ -2695,8 +2684,8 @@ globus_libc_addr_is_loopback( case AF_INET6: if(IN6_IS_ADDR_LOOPBACK(&((struct sockaddr_in6 *) _addr)->sin6_addr) || (IN6_IS_ADDR_V4MAPPED(&((struct sockaddr_in6 *) _addr)->sin6_addr) && - *(uint8_t *) &((struct sockaddr_in6 *) - _addr)->sin6_addr.s6_addr[12] == 127)) + *(uint8_t *) &((struct sockaddr_in6 *) + _addr)->sin6_addr.s6_addr[12] == 127)) { result = GLOBUS_TRUE; } @@ -2717,7 +2706,7 @@ globus_libc_addr_is_wildcard( { struct sockaddr * _addr = (struct sockaddr *) addr; globus_bool_t result = GLOBUS_FALSE; - + switch(_addr->sa_family) { case AF_INET: @@ -2740,7 +2729,7 @@ globus_libc_addr_is_wildcard( break; #endif default: - printf("%d\n%d\n", _addr->sa_family, AF_INET6); + printf("%d\n%d\n", _addr->sa_family, AF_INET6); globus_assert(0 && "Unknown family in globus_libc_addr_is_wildcard"); break; @@ -2859,7 +2848,7 @@ globus_libc_addr_to_contact_string( int port_no; int ni_flags = 0; char * cs; - + if(!GlobusLibcProtocolFamilyIsIP(GlobusLibcSockaddrGetFamily(*addr))) { result = globus_error_put( @@ -2873,12 +2862,12 @@ globus_libc_addr_to_contact_string( "Invalid addr family")); goto error_nameinfo; } - + if(opts_mask & GLOBUS_LIBC_ADDR_LOCAL || globus_libc_addr_is_wildcard(addr)) { int family; - + #if AF_INET6 family = (opts_mask & GLOBUS_LIBC_ADDR_IPV6) ? AF_INET6 : ((opts_mask & GLOBUS_LIBC_ADDR_IPV4) @@ -2887,7 +2876,7 @@ globus_libc_addr_to_contact_string( family = (opts_mask & GLOBUS_LIBC_ADDR_IPV4) ? AF_INET : AF_UNSPEC; #endif - + if(globus_libc_gethostaddr_by_family(&myaddr, family) != 0) { result = globus_error_put( @@ -2901,12 +2890,12 @@ globus_libc_addr_to_contact_string( "globus_libc_gethostaddr failed")); goto error_nameinfo; } - + GlobusLibcSockaddrGetPort(*addr, port_no); GlobusLibcSockaddrSetPort(myaddr, port_no); addr = &myaddr; } - + ni_flags = GLOBUS_NI_NUMERICSERV; if(opts_mask & GLOBUS_LIBC_ADDR_NUMERIC) @@ -2920,7 +2909,7 @@ globus_libc_addr_to_contact_string( { goto error_nameinfo; } - + cs = globus_malloc(strlen(host) + strlen(port) + 4); if(!cs) { @@ -2935,7 +2924,7 @@ globus_libc_addr_to_contact_string( "malloc failed")); goto error_memory; } - + if(strchr(host, ':')) { sprintf(cs, "[%s]:%s", host, port); @@ -2944,9 +2933,9 @@ globus_libc_addr_to_contact_string( { sprintf(cs, "%s:%s", host, port); } - + *contact_string = cs; - + return GLOBUS_SUCCESS; error_memory: @@ -2955,7 +2944,7 @@ globus_libc_addr_to_contact_string( } /** convert a numeric contact string to an array of ints - * + * * (port is optional and may be NULL. 0 will be passed back if no port is * found) * host needs to have room for at least 16 ints @@ -2977,13 +2966,13 @@ globus_libc_contact_string_to_ints( struct in6_addr addr6; #endif unsigned char * paddr; -#ifdef WIN32 +#ifdef WIN32 int rc; struct addrinfo hints; struct addrinfo * pres = NULL; struct sockaddr_in6 sockaddr6; #endif - + memset(host, 0, sizeof(int) * 16); strncpy(buf, contact_string, sizeof(buf)); buf[255] = 0; @@ -3014,7 +3003,7 @@ globus_libc_contact_string_to_ints( else { char * pbuf = buf; - + *count = 16; if(*pbuf == '[') { @@ -3028,7 +3017,7 @@ globus_libc_contact_string_to_ints( if(*(s++) != ':') { s = NULL; - } + } } else { @@ -3057,7 +3046,7 @@ globus_libc_contact_string_to_ints( { goto error_parse; } - + paddr = (unsigned char *) &((struct sockaddr_in6*)pres->ai_addr)->sin6_addr; #else #ifdef AF_INET6 @@ -3071,7 +3060,7 @@ globus_libc_contact_string_to_ints( #endif #endif } - + if(port) { *port = 0; @@ -3080,7 +3069,7 @@ globus_libc_contact_string_to_ints( sscanf(s, "%hu", port); } } - + for(i = 0; i < *count; i++) { host[i] = paddr[i]; @@ -3092,9 +3081,9 @@ globus_libc_contact_string_to_ints( } #endif - + return GLOBUS_SUCCESS; - + error_parse: return globus_error_put( globus_error_construct_error( @@ -3121,7 +3110,7 @@ globus_libc_ints_to_contact_string( int b = 0; globus_bool_t need_bracket = GLOBUS_FALSE; globus_bool_t compressed = GLOBUS_FALSE; - + if(count == 16) { if(port) @@ -3129,7 +3118,7 @@ globus_libc_ints_to_contact_string( layout[l++] = "["; need_bracket = GLOBUS_TRUE; } - + /* count up leading zeros */ while(h < 16 && host[h] == 0) h++; if(h == 12) @@ -3166,7 +3155,7 @@ globus_libc_ints_to_contact_string( { layout[l++] = ":"; } - + h += 6; while(h < 15 && host[h] == 0 && host[h + 1] == 0) h += 2; } @@ -3181,43 +3170,43 @@ globus_libc_ints_to_contact_string( snprintf(bufs[b], 10, "%X%.2X", host[h] & 0xff, host[h + 1] & 0xff); } - + layout[l++] = bufs[b++]; if(h < 14) { layout[l++] = ":"; } - + h += 2; } } } } - + if(count == 4) { snprintf(ipv4, sizeof(ipv4), "%d.%d.%d.%d", host[h + 0], host[h + 1], host[h + 2], host[h + 3]); layout[l++] = ipv4; } - + if(need_bracket) { layout[l++] = "]"; } - + if(port && l > 0) { sprintf(bufs[b], ":%d", (int) port); layout[l++] = bufs[b++]; } - + return globus_libc_join((const char **)layout, l); } /** * create a new string from all of the strings in array - * + * * @param array * an array of strings to concatenate (null entries are skipped) * @param count @@ -3232,24 +3221,24 @@ globus_libc_join( int len; char * s; int i; - + if(count <= 0) { return NULL; } - + lens = (int *) globus_malloc(sizeof(int) * count); if(!lens) { return NULL; } - + len = 0; for(i = 0; i < count; i++) { len += lens[i] = array[i] ? strlen(array[i]) : 0; } - + if(len) { s = (char *) globus_malloc(sizeof(char) * (len + 1)); @@ -3264,7 +3253,7 @@ globus_libc_join( len += lens[i]; } } - + s[len] = '\0'; } } @@ -3272,9 +3261,9 @@ globus_libc_join( { s = NULL; } - + globus_free(lens); - + return s; } diff --git a/common/source/library/globus_logging.c b/common/source/library/globus_logging.c index 2a09c25a7f..9239d8cbbd 100644 --- a/common/source/library/globus_logging.c +++ b/common/source/library/globus_logging.c @@ -121,7 +121,7 @@ globus_l_logging_periodic( globus_mutex_lock(&handle->mutex); { - globus_l_logging_flush(handle); + globus_l_logging_flush(handle); } globus_mutex_unlock(&handle->mutex); } @@ -145,7 +145,7 @@ globus_logging_init( globus_logging_handle_t * out_handle, globus_reltime_t * flush_period, int buffer_length_in, - int log_type, + int log_type, globus_logging_module_t * module, void * user_arg) { @@ -171,7 +171,7 @@ globus_logging_init( { buffer_length = GLOBUS_L_LOGGING_MAX_MESSAGE; } - + if(module == NULL || module->write_func == NULL) { res = GlobusLoggingErrorParameter("module"); @@ -187,7 +187,7 @@ globus_logging_init( } globus_l_logging_pid = getpid(); - + handle->module.open_func = module->open_func; handle->module.write_func = module->write_func; handle->module.close_func = module->close_func; @@ -203,7 +203,7 @@ globus_logging_init( { handle->module.open_func(handle->user_arg); } - + GlobusTimeReltimeSet(zero, 0, 0); if(flush_period != NULL && globus_reltime_cmp(flush_period, &zero) != 0) { @@ -276,7 +276,7 @@ globus_logging_vwrite( handle->used_length += nbytes; remain -= nbytes; } - rc = vsnprintf((char *) &handle->buffer[handle->used_length], + rc = vsnprintf((char *) &handle->buffer[handle->used_length], remain, fmt, ap); if (rc < 0) { @@ -289,24 +289,24 @@ globus_logging_vwrite( if(nbytes > remain) { char suffix[64]; - + globus_libc_snprintf( - suffix, - sizeof(suffix), - " *** TRUNCATED %lu bytes\n", + suffix, + sizeof(suffix), + " *** TRUNCATED %lu bytes\n", (unsigned long) (nbytes - remain + sizeof(suffix))); - + memcpy( - &handle->buffer[handle->buffer_length - sizeof(suffix)], + &handle->buffer[handle->buffer_length - sizeof(suffix)], suffix, sizeof(suffix)); - + nbytes = remain - sizeof(suffix) + strlen(suffix); } handle->used_length += nbytes; remain -= nbytes; - if(type & GLOBUS_LOGGING_INLINE || + if(type & GLOBUS_LOGGING_INLINE || handle->type_mask & GLOBUS_LOGGING_INLINE || remain < GLOBUS_L_LOGGING_MAX_MESSAGE) { @@ -321,7 +321,7 @@ globus_logging_vwrite( err: return res; } - + globus_result_t globus_logging_write( globus_logging_handle_t handle, @@ -411,13 +411,12 @@ globus_logging_stdio_header_func( globus_size_t * len) { char str[256]; - char * tmp; time_t tm; globus_size_t str_len; int nbytes; tm = time(NULL); - tmp = globus_libc_ctime_r(&tm, str, sizeof(str)); + globus_libc_ctime_r(&tm, str, sizeof(str)); str_len = strlen(str); if(str[str_len - 1] == '\n') { @@ -447,14 +446,14 @@ globus_logging_ng_header_func( if(gettimeofday(&tv, NULL) == 0) { globus_libc_gmtime_r(&tv.tv_sec, &tm); - nbytes = snprintf(buf, *len, "ts=%04d-%02d-%02dT%02d:%02d:%02d.%06dZ id=%d ", - tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, - tm.tm_hour, tm.tm_min, tm.tm_sec , (int) tv.tv_usec, + nbytes = snprintf(buf, *len, "ts=%04d-%02d-%02dT%02d:%02d:%02d.%06dZ id=%d ", + tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, + tm.tm_hour, tm.tm_min, tm.tm_sec , (int) tv.tv_usec, globus_l_logging_pid); } else { - nbytes = snprintf(buf, *len, "ts=0000-00-00T00:00:00.000000Z id=%d ", + nbytes = snprintf(buf, *len, "ts=0000-00-00T00:00:00.000000Z id=%d ", globus_l_logging_pid); } if(nbytes < 0) @@ -481,7 +480,7 @@ globus_logging_syslog_close_func( { closelog(); } - + void globus_logging_syslog_write_func( globus_byte_t * buf, diff --git a/common/source/library/globus_module.c b/common/source/library/globus_module.c index 838005f498..bebd04548c 100644 --- a/common/source/library/globus_module.c +++ b/common/source/library/globus_module.c @@ -22,7 +22,7 @@ #endif /* GLOBUS_DONT_DOCUMENT_INTERNAL */ /****************************************************************************** - Include header files + Include header files ******************************************************************************/ #include "globus_i_common_config.h" #include "globus_common_include.h" @@ -36,7 +36,7 @@ #include "globus_thread.h" /****************************************************************************** - Type definitions + Type definitions ******************************************************************************/ /* @@ -52,10 +52,10 @@ static globus_thread_key_t globus_l_deactivate_parent_key; */ typedef struct { - globus_mutex_t mutex; - globus_cond_t cond; - globus_thread_t thread_id; - int level; + globus_mutex_t mutex; + globus_cond_t cond; + globus_thread_t thread_id; + int level; } globus_l_module_mutex_t; /* @@ -64,15 +64,15 @@ typedef struct typedef globus_module_activation_func_t globus_l_module_key_t; typedef struct { - globus_module_descriptor_t * descriptor; - globus_list_t * clients; - int reference_count; + globus_module_descriptor_t * descriptor; + globus_list_t * clients; + int reference_count; globus_module_deactivate_proxy_cb_t deactivate_cb; void * user_arg; } globus_l_module_entry_t; /****************************************************************************** - Define module specific variables + Define module specific variables ******************************************************************************/ globus_bool_t @@ -84,59 +84,59 @@ static globus_bool_t globus_l_environ_mutex_initialized = GLOBUS_FALSE; /* Recursive mutex to protect internal data structures */ -static globus_l_module_mutex_t globus_l_module_mutex; +static globus_l_module_mutex_t globus_l_module_mutex; /* Hash table and list to maintain a table of registered modules */ const int GLOBUS_L_MODULE_TABLE_SIZE = 13; -static globus_hashtable_t globus_l_module_table; -static globus_list_t * globus_l_module_list; +static globus_hashtable_t globus_l_module_table; +static globus_list_t * globus_l_module_list; /* Hash table for globus_environ*/ const int GLOBUS_L_ENVIRON_TABLE_SIZE = 13; -static globus_mutex_t globus_l_environ_hashtable_mutex; -static globus_hashtable_t globus_l_environ_table; +static globus_mutex_t globus_l_environ_hashtable_mutex; +static globus_hashtable_t globus_l_environ_table; globus_list_t *globus_l_module_atexit_funcs = GLOBUS_NULL; /****************************************************************************** - Module specific function prototypes + Module specific function prototypes ******************************************************************************/ static void globus_l_module_initialize(); static globus_bool_t globus_l_module_increment( - globus_module_descriptor_t * module_descriptor, - globus_l_module_key_t parent_key, + globus_module_descriptor_t * module_descriptor, + globus_l_module_key_t parent_key, globus_module_deactivate_proxy_cb_t deactivate_cb, void * user_arg); static globus_l_module_entry_t * globus_l_module_decrement( - globus_module_descriptor_t * module_descriptor, - globus_l_module_key_t parent_key); + globus_module_descriptor_t * module_descriptor, + globus_l_module_key_t parent_key); static int globus_l_module_reference_count( - globus_module_descriptor_t * module_descriptor); + globus_module_descriptor_t * module_descriptor); /****************************************************************************** - Recursive mutex function prototypes + Recursive mutex function prototypes ******************************************************************************/ static void globus_l_module_mutex_init( - globus_l_module_mutex_t * mutex); + globus_l_module_mutex_t * mutex); static void globus_l_module_mutex_lock( - globus_l_module_mutex_t * mutex); + globus_l_module_mutex_t * mutex); static void globus_l_module_mutex_unlock( - globus_l_module_mutex_t * mutex); - + globus_l_module_mutex_t * mutex); + /****************************************************************************** - API function definitions + API function definitions ******************************************************************************/ #if USE_SYMBOL_LABELS @@ -167,14 +167,14 @@ __attribute__ ((externally_visible)) #endif int globus_module_activate_proxy( - globus_module_descriptor_t * module_descriptor, + globus_module_descriptor_t * module_descriptor, globus_module_deactivate_proxy_cb_t deactivate_cb, void * user_arg) { globus_l_module_key_t parent_key; int ret_val; globus_l_module_key_t parent_key_save; - + /* * If this is the first time this routine has been called, then we need to * initialize the internal data structures and activate the threads @@ -182,10 +182,10 @@ globus_module_activate_proxy( */ if (globus_i_module_initialized == GLOBUS_FALSE) { - globus_i_module_initialized = GLOBUS_TRUE; - globus_l_module_initialize(); + globus_i_module_initialized = GLOBUS_TRUE; + globus_l_module_initialize(); } - + parent_key = (globus_l_module_key_t) globus_thread_getspecific(globus_l_activate_parent_key); /* @@ -195,22 +195,22 @@ globus_module_activate_proxy( */ globus_l_module_mutex_lock(&globus_l_module_mutex); { - ret_val = GLOBUS_SUCCESS; - - if (module_descriptor->activation_func != GLOBUS_NULL) - { - if (globus_l_module_increment(module_descriptor, - parent_key, - deactivate_cb, - user_arg) == GLOBUS_TRUE) - { - parent_key_save = parent_key; - globus_thread_setspecific( - globus_l_activate_parent_key, - module_descriptor->activation_func); - - ret_val = module_descriptor->activation_func(); - + ret_val = GLOBUS_SUCCESS; + + if (module_descriptor->activation_func != GLOBUS_NULL) + { + if (globus_l_module_increment(module_descriptor, + parent_key, + deactivate_cb, + user_arg) == GLOBUS_TRUE) + { + parent_key_save = parent_key; + globus_thread_setspecific( + globus_l_activate_parent_key, + module_descriptor->activation_func); + + ret_val = module_descriptor->activation_func(); + if(ret_val != GLOBUS_SUCCESS) { globus_l_module_decrement( @@ -218,9 +218,9 @@ globus_module_activate_proxy( } else { - /* - * Set up the exit handler - */ + /* + * Set up the exit handler + */ if(module_descriptor->atexit_func != GLOBUS_NULL) { /* only call the atexit function once */ @@ -236,11 +236,11 @@ globus_module_activate_proxy( } } } - + globus_thread_setspecific( - globus_l_activate_parent_key, parent_key_save); - } - } + globus_l_activate_parent_key, parent_key_save); + } + } } globus_l_module_mutex_unlock(&globus_l_module_mutex); @@ -264,7 +264,7 @@ __attribute__ ((externally_visible)) #endif int globus_module_activate( - globus_module_descriptor_t * module_descriptor) + globus_module_descriptor_t * module_descriptor) { return globus_module_activate_proxy(module_descriptor, NULL, NULL); } @@ -276,7 +276,7 @@ globus_module_activate( * Activate an NULL-terminated array of modules. If any fail to activate, all * are deactivated and the error from the failed activation is returned. If * nonzero is returned, and failed_module is non-NULL, it will be set to point - * to the 1st module which failed to activate. + * to the 1st module which failed to activate. * @param module_array * NULL-terminated array of module descriptors to activate. * @param failed_module @@ -329,7 +329,7 @@ __attribute__ ((externally_visible)) #endif int globus_module_activate_proxy_compat( - globus_module_descriptor_t * module_descriptor, + globus_module_descriptor_t * module_descriptor, globus_module_deactivate_proxy_cb_t deactivate_cb, void * user_arg) { @@ -350,7 +350,7 @@ __attribute__ ((externally_visible)) #endif int globus_module_activate_compat( - globus_module_descriptor_t * module_descriptor) + globus_module_descriptor_t * module_descriptor) { int rc; rc = globus_thread_set_model("pthread"); @@ -393,11 +393,11 @@ globus_module_activate_array_compat( */ int globus_module_deactivate( - globus_module_descriptor_t * module_descriptor) + globus_module_descriptor_t * module_descriptor) { globus_l_module_key_t parent_key; - int ret_val; - globus_l_module_key_t parent_key_save; + int ret_val; + globus_l_module_key_t parent_key_save; /* @@ -405,9 +405,9 @@ globus_module_deactivate( */ if (!globus_i_module_initialized) { - return GLOBUS_FAILURE; + return GLOBUS_FAILURE; } - + parent_key = (globus_l_module_key_t) globus_thread_getspecific(globus_l_deactivate_parent_key); /* @@ -419,19 +419,19 @@ globus_module_deactivate( if (module_descriptor->activation_func != GLOBUS_NULL) { globus_l_module_entry_t * entry; - + globus_l_module_mutex_lock(&globus_l_module_mutex); - + entry = globus_l_module_decrement(module_descriptor, parent_key); if (entry && entry->reference_count == 0) { globus_l_module_mutex_unlock(&globus_l_module_mutex); - + parent_key_save = parent_key; globus_thread_setspecific( globus_l_deactivate_parent_key, module_descriptor->activation_func); - + if(entry->deactivate_cb) { ret_val = entry->deactivate_cb( @@ -441,7 +441,7 @@ globus_module_deactivate( { ret_val = module_descriptor->deactivation_func(); } - + globus_thread_setspecific( globus_l_deactivate_parent_key, parent_key_save); } @@ -470,39 +470,39 @@ globus_module_deactivate_all(void) */ if (!globus_i_module_initialized) { - return GLOBUS_FAILURE; + return GLOBUS_FAILURE; } - + globus_l_module_mutex_lock(&globus_l_module_mutex); { - globus_bool_t deactivated_one; - - deactivated_one = GLOBUS_TRUE; - - while(deactivated_one) - { - globus_list_t * module_list; - - module_list = globus_l_module_list; - deactivated_one = GLOBUS_FALSE; - - while(!globus_list_empty(module_list)) - { - globus_l_module_entry_t *module_entry; - - module_entry = globus_list_first(module_list); - module_list = globus_list_rest(module_list); - - if(globus_list_empty(module_entry->clients) && - module_entry->reference_count > 0) - { - globus_l_module_mutex_unlock(&globus_l_module_mutex); - globus_module_deactivate(module_entry->descriptor); - globus_l_module_mutex_lock(&globus_l_module_mutex); - deactivated_one = GLOBUS_TRUE; - } - } - } + globus_bool_t deactivated_one; + + deactivated_one = GLOBUS_TRUE; + + while(deactivated_one) + { + globus_list_t * module_list; + + module_list = globus_l_module_list; + deactivated_one = GLOBUS_FALSE; + + while(!globus_list_empty(module_list)) + { + globus_l_module_entry_t *module_entry; + + module_entry = globus_list_first(module_list); + module_list = globus_list_rest(module_list); + + if(globus_list_empty(module_entry->clients) && + module_entry->reference_count > 0) + { + globus_l_module_mutex_unlock(&globus_l_module_mutex); + globus_module_deactivate(module_entry->descriptor); + globus_l_module_mutex_lock(&globus_l_module_mutex); + deactivated_one = GLOBUS_TRUE; + } + } + } } globus_l_module_mutex_unlock(&globus_l_module_mutex); @@ -517,7 +517,7 @@ globus_module_deactivate_all(void) void * globus_module_get_module_pointer( - globus_module_descriptor_t * structptr) + globus_module_descriptor_t * structptr) { void * retptr; void * (*module_func)(); @@ -525,7 +525,7 @@ globus_module_get_module_pointer( module_func=structptr->get_pointer_func; if (module_func!=NULL) - { + { retptr=(*module_func)(); } else @@ -534,20 +534,20 @@ globus_module_get_module_pointer( } return(retptr); -} +} /*globus_module_get_module_pointer();*/ /* * globus_module_setenv(); - */ + */ void globus_module_setenv( const char * name, const char * value) { - int rc; + int rc; /* * First, check to see if the environment mutex has been initialized @@ -555,38 +555,38 @@ globus_module_setenv( if(globus_l_environ_mutex_initialized == GLOBUS_FALSE) { - if(globus_i_module_initialized == GLOBUS_TRUE) - { - rc = globus_mutex_init(&globus_l_environ_hashtable_mutex, + if(globus_i_module_initialized == GLOBUS_TRUE) + { + rc = globus_mutex_init(&globus_l_environ_hashtable_mutex, (globus_mutexattr_t *) GLOBUS_NULL); globus_assert (rc == 0); - globus_l_environ_mutex_initialized = GLOBUS_TRUE; - } + globus_l_environ_mutex_initialized = GLOBUS_TRUE; + } } - + /* * then, check to see if the environment hash table has been initialized */ - + if(globus_l_environ_initialized == GLOBUS_FALSE) { - if(globus_i_module_initialized==GLOBUS_TRUE) - { - globus_mutex_lock(&globus_l_environ_hashtable_mutex); - } + if(globus_i_module_initialized==GLOBUS_TRUE) + { + globus_mutex_lock(&globus_l_environ_hashtable_mutex); + } globus_hashtable_init(&globus_l_environ_table, GLOBUS_L_ENVIRON_TABLE_SIZE, globus_hashtable_string_hash, globus_hashtable_string_keyeq); - globus_l_environ_initialized = GLOBUS_TRUE; + globus_l_environ_initialized = GLOBUS_TRUE; - if(globus_i_module_initialized == GLOBUS_TRUE) - { - globus_mutex_unlock(&globus_l_environ_hashtable_mutex); - } + if(globus_i_module_initialized == GLOBUS_TRUE) + { + globus_mutex_unlock(&globus_l_environ_hashtable_mutex); + } } /* @@ -595,12 +595,12 @@ globus_module_setenv( if(globus_i_module_initialized == GLOBUS_TRUE) { - globus_mutex_lock(&globus_l_environ_hashtable_mutex); + globus_mutex_lock(&globus_l_environ_hashtable_mutex); } globus_hashtable_remove( - &globus_l_environ_table, - (void *) name); + &globus_l_environ_table, + (void *) name); globus_hashtable_insert( &globus_l_environ_table, (void *) name, @@ -608,7 +608,7 @@ globus_module_setenv( if(globus_i_module_initialized == GLOBUS_TRUE) { - globus_mutex_unlock(&globus_l_environ_hashtable_mutex); + globus_mutex_unlock(&globus_l_environ_hashtable_mutex); } } @@ -618,31 +618,31 @@ globus_module_setenv( * globus_module_getenv(); */ -char * +char * globus_module_getenv( const char * name) { - char * entry; + char * entry; if(globus_l_environ_initialized == GLOBUS_TRUE) { - if((globus_i_module_initialized == GLOBUS_TRUE) - &&(globus_l_environ_mutex_initialized == GLOBUS_TRUE)) - { - globus_mutex_lock(&globus_l_environ_hashtable_mutex); - } + if((globus_i_module_initialized == GLOBUS_TRUE) + &&(globus_l_environ_mutex_initialized == GLOBUS_TRUE)) + { + globus_mutex_lock(&globus_l_environ_hashtable_mutex); + } entry = globus_hashtable_lookup( &globus_l_environ_table, - (void *) name); + (void *) name); - if((globus_i_module_initialized == GLOBUS_TRUE) - &&(globus_l_environ_mutex_initialized == GLOBUS_TRUE)) - { - globus_mutex_unlock(&globus_l_environ_hashtable_mutex); - } + if((globus_i_module_initialized == GLOBUS_TRUE) + &&(globus_l_environ_mutex_initialized == GLOBUS_TRUE)) + { + globus_mutex_unlock(&globus_l_environ_hashtable_mutex); + } } else { @@ -655,7 +655,7 @@ globus_module_getenv( if (entry!=GLOBUS_NULL) { - return(entry); + return(entry); } /* @@ -666,7 +666,7 @@ globus_module_getenv( if (entry!=NULL) { - return(entry); + return(entry); } return(GLOBUS_NULL); @@ -695,22 +695,22 @@ globus_module_getenv( int globus_module_get_version( - globus_module_descriptor_t * module_descriptor, + globus_module_descriptor_t * module_descriptor, globus_version_t * version) { globus_version_t * module_version; - + module_version = module_descriptor->version; - + if(!module_version) { return GLOBUS_FAILURE; } - - version->major = module_version->major; - version->minor = module_version->minor; - version->timestamp = module_version->timestamp; - version->branch_id = module_version->branch_id; + + version->major = module_version->major; + version->minor = module_version->minor; + version->timestamp = module_version->timestamp; + version->branch_id = module_version->branch_id; return GLOBUS_SUCCESS; } @@ -719,7 +719,7 @@ globus_module_get_version( /** * print module's version * - * This function prints a modules version info using the standard form + * This function prints a modules version info using the standard form * provided by globus_version_print * * @param module_descriptor @@ -729,17 +729,14 @@ globus_module_get_version( * stream to print on (stdout, stderr, etc) * * @param verbose - * If GLOBUS_TRUE, then all available version info is printed + * If GLOBUS_TRUE, then all available version info is printed * (ex: globus_module: 1.1 (1013708618-5)) * else, only the major.minor is printed (ex: globus_module: 1.1) - * - * @return - * - void */ void globus_module_print_version( - globus_module_descriptor_t * module_descriptor, + globus_module_descriptor_t * module_descriptor, FILE * stream, globus_bool_t verbose) { @@ -753,19 +750,16 @@ globus_module_print_version( /** * print all activated modules' versions * - * This function prints all activated modules' version info using the standard + * This function prints all activated modules' version info using the standard * form provided by globus_version_print * * @param stream * stream to print on (stdout, stderr, etc) * * @param verbose - * If GLOBUS_TRUE, then all available version info is printed + * If GLOBUS_TRUE, then all available version info is printed * (ex: globus_module: 1.1 (1013708618-5)) * else, only the major.minor is printed (ex: globus_module: 1.1) - * - * @return - * - void */ void @@ -781,19 +775,19 @@ globus_module_print_activated_versions( { return; } - + globus_l_module_mutex_lock(&globus_l_module_mutex); { - globus_list_t * module_list; - + globus_list_t * module_list; + module_list = globus_l_module_list; while(!globus_list_empty(module_list)) { globus_l_module_entry_t * module_entry; - + module_entry = globus_list_first(module_list); module_list = globus_list_rest(module_list); - + if(module_entry->reference_count > 0) { globus_version_print( @@ -818,7 +812,7 @@ globus_module_print_activated_versions( * name: major.minor if verbose = false * name: major.minor.timestamp-branch_id if verbose = true * - * In either case, if name is NULL, then only the numerical version will be + * In either case, if name is NULL, then only the numerical version will be * printed. * * @param name @@ -832,12 +826,9 @@ globus_module_print_activated_versions( * stream to print on (stdout, stderr, etc) * * @param verbose - * If GLOBUS_TRUE, then all available version info is printed + * If GLOBUS_TRUE, then all available version info is printed * (ex: globus_module: 1.1 (1013708618-5)) * else, only the major.minor is printed (ex: globus_module: 1.1) - * - * @return - * - void */ void @@ -851,14 +842,14 @@ globus_version_print( { globus_libc_fprintf(stream, "%s: ", name); } - + if(version) { if(verbose) { globus_libc_fprintf( - stream, - "%d.%d (%lu-%d)\n", + stream, + "%d.%d (%lu-%d)\n", version->major, version->minor, version->timestamp, @@ -867,8 +858,8 @@ globus_version_print( else { globus_libc_fprintf( - stream, - "%d.%d\n", + stream, + "%d.%d\n", version->major, version->minor); } @@ -881,7 +872,7 @@ globus_version_print( /****************************************************************************** - Module specific function definitions + Module specific function definitions ******************************************************************************/ /* @@ -900,20 +891,20 @@ globus_l_module_initialize() * Initialize the registered module table and list */ globus_hashtable_init(&globus_l_module_table, - GLOBUS_L_MODULE_TABLE_SIZE, - globus_hashtable_voidp_hash, - globus_hashtable_voidp_keyeq); + GLOBUS_L_MODULE_TABLE_SIZE, + globus_hashtable_voidp_hash, + globus_hashtable_voidp_keyeq); globus_l_module_list = GLOBUS_NULL; - + /* * Initialize the recursive mutex */ globus_l_module_mutex_init(&globus_l_module_mutex); - + globus_thread_key_create(&globus_l_activate_parent_key, NULL); globus_thread_key_create(&globus_l_deactivate_parent_key, NULL); - + /* * Now finish initializing the threads package */ @@ -927,71 +918,71 @@ globus_l_module_initialize() */ static globus_bool_t globus_l_module_increment( - globus_module_descriptor_t * module_descriptor, - globus_l_module_key_t parent_key, + globus_module_descriptor_t * module_descriptor, + globus_l_module_key_t parent_key, globus_module_deactivate_proxy_cb_t deactivate_cb, void * user_arg) { - globus_l_module_entry_t * entry; - + globus_l_module_entry_t * entry; + entry = - globus_hashtable_lookup( - &globus_l_module_table, - (void *) module_descriptor->activation_func); + globus_hashtable_lookup( + &globus_l_module_table, + (void *) module_descriptor->activation_func); if (entry != GLOBUS_NULL) { - /* - * The module has already been registered. Increment its reference - * counter and add any new clients to the dependency list - */ - entry->reference_count++; - if (parent_key != GLOBUS_NULL - && globus_list_search(entry->clients, - (void *) parent_key) == GLOBUS_NULL) - { - globus_list_insert(&entry->clients, (void *) parent_key); - } - - if(entry->reference_count == 1) - { - entry->deactivate_cb = deactivate_cb; - entry->user_arg = user_arg; - return GLOBUS_TRUE; - } - else - { - return GLOBUS_FALSE; - } + /* + * The module has already been registered. Increment its reference + * counter and add any new clients to the dependency list + */ + entry->reference_count++; + if (parent_key != GLOBUS_NULL + && globus_list_search(entry->clients, + (void *) parent_key) == GLOBUS_NULL) + { + globus_list_insert(&entry->clients, (void *) parent_key); + } + + if(entry->reference_count == 1) + { + entry->deactivate_cb = deactivate_cb; + entry->user_arg = user_arg; + return GLOBUS_TRUE; + } + else + { + return GLOBUS_FALSE; + } } else { - /* - * This is the first time this module has been registered. Create a - * new entry in the modules table. - */ - entry = (globus_l_module_entry_t *) - globus_malloc(sizeof(globus_l_module_entry_t)); - globus_assert(entry != GLOBUS_NULL); - - entry->descriptor = module_descriptor; - entry->reference_count = 1; - entry->clients = GLOBUS_NULL; - entry->deactivate_cb = deactivate_cb; - entry->user_arg = user_arg; - if (parent_key != GLOBUS_NULL) - { - globus_list_insert(&entry->clients, (void *) parent_key); - } - - globus_hashtable_insert( - &globus_l_module_table, - (void *) module_descriptor->activation_func, - entry); - - globus_list_insert(&globus_l_module_list, entry); - - return GLOBUS_TRUE; + /* + * This is the first time this module has been registered. Create a + * new entry in the modules table. + */ + entry = (globus_l_module_entry_t *) + globus_malloc(sizeof(globus_l_module_entry_t)); + globus_assert(entry != GLOBUS_NULL); + + entry->descriptor = module_descriptor; + entry->reference_count = 1; + entry->clients = GLOBUS_NULL; + entry->deactivate_cb = deactivate_cb; + entry->user_arg = user_arg; + if (parent_key != GLOBUS_NULL) + { + globus_list_insert(&entry->clients, (void *) parent_key); + } + + globus_hashtable_insert( + &globus_l_module_table, + (void *) module_descriptor->activation_func, + entry); + + globus_list_insert(&globus_l_module_list, entry); + + return GLOBUS_TRUE; } } /* globus_l_module_increment() */ @@ -999,17 +990,17 @@ globus_l_module_increment( static int globus_l_module_reference_count( - globus_module_descriptor_t * module_descriptor) + globus_module_descriptor_t * module_descriptor) { - globus_l_module_entry_t * entry; - + globus_l_module_entry_t * entry; + entry = - globus_hashtable_lookup( - &globus_l_module_table, - (void *) module_descriptor->activation_func); + globus_hashtable_lookup( + &globus_l_module_table, + (void *) module_descriptor->activation_func); if (entry == GLOBUS_NULL || entry->reference_count <= 0) { - return 0; + return 0; } else { @@ -1022,34 +1013,34 @@ globus_l_module_reference_count( */ static globus_l_module_entry_t * globus_l_module_decrement( - globus_module_descriptor_t * module_descriptor, - globus_l_module_key_t parent_key) + globus_module_descriptor_t * module_descriptor, + globus_l_module_key_t parent_key) { - globus_l_module_entry_t * entry; - + globus_l_module_entry_t * entry; + entry = - globus_hashtable_lookup( - &globus_l_module_table, - (void *) module_descriptor->activation_func); + globus_hashtable_lookup( + &globus_l_module_table, + (void *) module_descriptor->activation_func); if (entry == GLOBUS_NULL || entry->reference_count <= 0) { - return NULL; + return NULL; } entry->reference_count--; - + if (parent_key != GLOBUS_NULL) { - globus_list_t * client_entry; + globus_list_t * client_entry; + - - client_entry = globus_list_search(entry->clients, - (void *) parent_key); - if(client_entry != GLOBUS_NULL) + client_entry = globus_list_search(entry->clients, + (void *) parent_key); + if(client_entry != GLOBUS_NULL) { - globus_list_remove(&entry->clients, client_entry); - } - /* else module was activated outside this parent */ + globus_list_remove(&entry->clients, client_entry); + } + /* else module was activated outside this parent */ } return entry; @@ -1059,52 +1050,52 @@ globus_l_module_decrement( void globus_i_module_dump( - FILE * out_f) + FILE * out_f) { - globus_list_t * module_list; + globus_list_t * module_list; globus_libc_fprintf(out_f, "==========\nModule List\n----------\n"); - + module_list = globus_l_module_list; while(!globus_list_empty(module_list)) { - globus_list_t * client_list; - globus_l_module_entry_t * module_entry; - - module_entry = globus_list_first(module_list); - module_list = globus_list_rest(module_list); - - globus_libc_fprintf(out_f, "%s; cnt=%d", - module_entry->descriptor->module_name, - module_entry->reference_count); - - client_list = module_entry->clients; - - if (!globus_list_empty(client_list)) - { - void * client_entry; - globus_l_module_entry_t * client_module_entry; - - client_entry = globus_list_first(client_list); - client_list = globus_list_rest(client_list); - client_module_entry = - globus_hashtable_lookup(&globus_l_module_table, client_entry); - globus_libc_fprintf(out_f, "; clients=%s", - client_module_entry->descriptor->module_name); - - while(!globus_list_empty(client_list)) - { - client_entry = globus_list_first(client_list); - client_list = globus_list_rest(client_list); - client_module_entry = - globus_hashtable_lookup(&globus_l_module_table, - client_entry); - globus_libc_fprintf(out_f, ",%s", - client_module_entry->descriptor->module_name); - } - } - - globus_libc_fprintf(out_f, "\n"); + globus_list_t * client_list; + globus_l_module_entry_t * module_entry; + + module_entry = globus_list_first(module_list); + module_list = globus_list_rest(module_list); + + globus_libc_fprintf(out_f, "%s; cnt=%d", + module_entry->descriptor->module_name, + module_entry->reference_count); + + client_list = module_entry->clients; + + if (!globus_list_empty(client_list)) + { + void * client_entry; + globus_l_module_entry_t * client_module_entry; + + client_entry = globus_list_first(client_list); + client_list = globus_list_rest(client_list); + client_module_entry = + globus_hashtable_lookup(&globus_l_module_table, client_entry); + globus_libc_fprintf(out_f, "; clients=%s", + client_module_entry->descriptor->module_name); + + while(!globus_list_empty(client_list)) + { + client_entry = globus_list_first(client_list); + client_list = globus_list_rest(client_list); + client_module_entry = + globus_hashtable_lookup(&globus_l_module_table, + client_entry); + globus_libc_fprintf(out_f, ",%s", + client_module_entry->descriptor->module_name); + } + } + + globus_libc_fprintf(out_f, "\n"); } globus_libc_fprintf(out_f, "==========\n"); @@ -1112,7 +1103,7 @@ globus_i_module_dump( /****************************************************************************** - Recursive mutex function definitions + Recursive mutex function definitions ******************************************************************************/ /* @@ -1120,7 +1111,7 @@ globus_i_module_dump( */ static void globus_l_module_mutex_init( - globus_l_module_mutex_t * mutex) + globus_l_module_mutex_t * mutex) { globus_mutex_init(&mutex->mutex, (globus_mutexattr_t *) GLOBUS_NULL); globus_cond_init(&mutex->cond, (globus_condattr_t *) GLOBUS_NULL); @@ -1134,20 +1125,20 @@ globus_l_module_mutex_init( */ static void globus_l_module_mutex_lock( - globus_l_module_mutex_t * mutex) + globus_l_module_mutex_t * mutex) { globus_mutex_lock(&mutex->mutex); { - globus_assert(mutex->level >= 0); - while (mutex->level > 0 - && !globus_thread_equal( mutex->thread_id, globus_thread_self()) ) - { - globus_cond_wait(&mutex->cond, &mutex->mutex); - } - - mutex->level++; - mutex->thread_id = globus_thread_self(); - + globus_assert(mutex->level >= 0); + while (mutex->level > 0 + && !globus_thread_equal( mutex->thread_id, globus_thread_self()) ) + { + globus_cond_wait(&mutex->cond, &mutex->mutex); + } + + mutex->level++; + mutex->thread_id = globus_thread_self(); + } globus_mutex_unlock(&mutex->mutex); } @@ -1158,18 +1149,18 @@ globus_l_module_mutex_lock( */ static void globus_l_module_mutex_unlock( - globus_l_module_mutex_t * mutex) + globus_l_module_mutex_t * mutex) { globus_mutex_lock(&mutex->mutex); { - globus_assert(mutex->level > 0); - globus_assert( globus_thread_equal( mutex->thread_id, globus_thread_self() ) ); - - mutex->level--; - if (mutex->level == 0) - { - globus_cond_signal(&mutex->cond); - } + globus_assert(mutex->level > 0); + globus_assert( globus_thread_equal( mutex->thread_id, globus_thread_self() ) ); + + mutex->level--; + if (mutex->level == 0) + { + globus_cond_signal(&mutex->cond); + } } globus_mutex_unlock(&mutex->mutex); } diff --git a/common/source/test/error_test.c b/common/source/test/error_test.c index 99a184e6ee..951b9f1c38 100644 --- a/common/source/test/error_test.c +++ b/common/source/test/error_test.c @@ -102,9 +102,7 @@ main() for (i = 0; i <= MAX_ERROR_NUM; i++) { - globus_result_t result; - - result = throw_error(i); + throw_error(i); } for (i = 1; i <= MAX_ERROR_NUM; i++) diff --git a/common/source/test/handle_table_test.c b/common/source/test/handle_table_test.c index ca33fedf3d..33f0314120 100644 --- a/common/source/test/handle_table_test.c +++ b/common/source/test/handle_table_test.c @@ -35,7 +35,6 @@ destructor(void *datum) int main(void) { - globus_bool_t rc; int *data, i; globus_handle_table_t handle_table; @@ -106,7 +105,7 @@ main(void) (i == object3_count-1), "decrement_object_3_%d", i); } object3_count = 0; - rc = globus_handle_table_decrement_reference(&handle_table, object2_handle); + globus_handle_table_decrement_reference(&handle_table, object2_handle); object2_count--; /* perform additional lookups */ diff --git a/gass/cache/source/configure.ac b/gass/cache/source/configure.ac index 1d55c7083e..c8ff03fbee 100644 --- a/gass/cache/source/configure.ac +++ b/gass/cache/source/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ([2.60]) -AC_INIT([globus_gass_cache],[10.3],[https://github.com/gridcf/gct/issues]) +AC_INIT([globus_gass_cache],[10.4],[https://github.com/gridcf/gct/issues]) AC_CONFIG_MACRO_DIR([m4]) AC_SUBST([MAJOR_VERSION], [${PACKAGE_VERSION%%.*}]) AC_SUBST([MINOR_VERSION], [${PACKAGE_VERSION##*.}]) diff --git a/gass/cache/source/globus_gass_cache.c b/gass/cache/source/globus_gass_cache.c index f687b57d78..a3b21270df 100644 --- a/gass/cache/source/globus_gass_cache.c +++ b/gass/cache/source/globus_gass_cache.c @@ -26,7 +26,7 @@ * The GASS cache management API is part of the Globus module called "GASS", * (Global Access to Secondary Storage) * The GASS cache management API defines calls for manipulating a local file - * cache. + * cache. * * Each cache entry can be locked during addition and deletion to allow for * atomic handling of the cache file contents. @@ -35,7 +35,7 @@ * independent of the local cache file's modification time. Rather, the * cache entry timestamp is maintained by the user. It can, for example, be * used to keep track of the timestamp of a remote file that is associated - * with the cache entry. + * with the cache entry. * * Note: all timestamps are as seconds since the epoch. * (01 Jan 1970, 00:00 GMT) @@ -99,7 +99,7 @@ * #define EQUSR 60 (User file/inode quota limit reached) * #define EQGRP 61 (Group file/inode quota limit reached) * #define EQACT 62 (Account file/inode quota limit reached) - * #define EOFQUOTA 363 (File offline, retrieval would + * #define EOFQUOTA 363 (File offline, retrieval would * exceed disk space quota) */ #ifdef EDQUOT @@ -308,7 +308,7 @@ globus_module_descriptor_t globus_i_gass_cache_module = ******************************************************************************/ /* variables not used by themselves, but pointed by the field "init" of the - cache_handle structures, to indicate if the cache has been initialised + cache_handle structures, to indicate if the cache has been initialised simple methode to help the user: it is his responsbility to open the cache before using it. A list of handlers could be used...*/ static char globus_l_gass_cache_is_init; @@ -319,7 +319,7 @@ static int globus_l_gass_cache_fn_fudge; /* it is fine to declare those macro here, together with the var. they uses */ #define CHECK_CACHE_IS_INIT(_handle_) if (_handle_->init != &globus_l_gass_cache_is_init) return(GLOBUS_GASS_CACHE_ERROR_CACHE_NOT_OPENED) #define CHECK_CACHE_IS_NOT_INIT(_handle_) if (_handle_->init == &globus_l_gass_cache_is_init) return(GLOBUS_GASS_CACHE_ERROR_CACHE_ALREADY_OPENED) - + /* this is not in the globus_gass_cache specs, but we can see if we want to add it. It is a list of error message corresponding to each error codes returned by globus_gass_cache functions. The user does not have direct @@ -473,14 +473,14 @@ void error_backtrace(FILE *fp) * Write in the file [first param] the message passed as a * "printf-like" argument list, prepended by the date, the hostname and * the PID of the caller process. - * - * Parameters: + * + * Parameters: * f - file to write in. * * Returns: * none */ static -void +void globus_l_gass_cache_log( FILE* f, const char* str, @@ -539,16 +539,16 @@ globus_l_gass_cache_log( * This function should be called this way: * globus_l_gass_cache_trace(__FILE__,__LINE," printf-like format string", * args...); - * + * * Parameters: * source_file - File name of the source code * line - line number in the source code * *Returns: - * none - */ + * none + */ static -void +void globus_l_gass_cache_trace( const char* source_file, int line, @@ -594,8 +594,8 @@ globus_l_gass_cache_trace( gettimeofday( & tv, NULL ); va_start(args,format); - - fprintf(fp,"GC %ld.%06ld: %s %d : ", + + fprintf(fp,"GC %ld.%06ld: %s %d : ", tv.tv_sec, tv.tv_usec, source_file, line); vfprintf(fp, format, args); va_end(args); @@ -603,7 +603,7 @@ globus_l_gass_cache_trace( fprintf(fp,"\n"); fflush(fp); - + } /* globus_l_gass_cache_trace() */ #endif @@ -616,7 +616,7 @@ globus_l_gass_cache_trace( * Two tests are performed: * (a) link inside a local directory * (b) link across a directory boundary - * + * * Parameters: * cache - Cache handle, containing cache_directory_path which * is known to exist @@ -644,7 +644,7 @@ globus_l_gass_cache_linktest(globus_i_gass_cache_t *cache) cache->cache_directory_path, (long) globus_libc_getpid(), (long) t.dummy ); - + sprintf(file, "%s/file", dir ); sprintf(link1, "%s/link", dir ); @@ -682,7 +682,7 @@ globus_l_gass_cache_linktest(globus_i_gass_cache_t *cache) goto cleanup; rc = DIRECTORY_TYPE_NORMAL; - + cleanup: remove(link1); remove(link2); @@ -698,7 +698,7 @@ globus_l_gass_cache_linktest(globus_i_gass_cache_t *cache) * Build a cache filename by concatenating a file name onto a * directory name. If no file name is provided, the directory name * alone is copied into the output path buffer. - * + * * Parameters: * dir - Incoming directory name * separator - Incoming directory separator @@ -707,7 +707,7 @@ globus_l_gass_cache_linktest(globus_i_gass_cache_t *cache) * pathsize - if non-null, points to size of already allocated memory * for path. Will realloc if more is necessary. * path - Outgoing full file path - + * * Returns: VOID * @@ -726,13 +726,13 @@ globus_l_gass_cache_build_filename(const char *dir, globus_size_t uniqlen; globus_size_t len; char * p; - + /* Compute the lengths */ filelen = (file) ? strlen( file ) : 0; uniqlen = (uniq) ? strlen( uniq ) : 0; len = dirlen + filelen + uniqlen + 2; /* a separator and \0 */ - + /* Allocate the buffer */ if ( !*path || !pathsize || *pathsize < len ) { @@ -764,7 +764,7 @@ globus_l_gass_cache_build_filename(const char *dir, } *p = '\0'; - + /* All done, good */ return GLOBUS_SUCCESS; @@ -772,7 +772,7 @@ globus_l_gass_cache_build_filename(const char *dir, /* * globus_l_gass_cache_mangle_html() - * + * * Parameters: * string - The string to mangle * mangled - Pointer to the buffer to mangle into (or NULL) @@ -881,7 +881,7 @@ globus_l_gass_cache_mangle_html(const char *string, /* * globus_l_gass_cache_mangle_md5() - * + * * Parameters: * string - The string to mangle * mangled - Pointer to the buffer to mangle into (or NULL) @@ -942,7 +942,7 @@ globus_l_gass_cache_mangle_md5(const char *string, * * Mangles the given string (typically URL or tag) into a chunk * suitable for using as a file / path name. - * + * * Parameters: * cache - GASS cache handle * @@ -971,16 +971,15 @@ globus_l_gass_cache_mangle(const globus_gass_cache_t cache, { cache_mangling_option_t *option; int rc; - int option_no; int len; char *separator; - + separator = directory_separator[cache->cache_type]; /* Get the mangled length */ - for ( option_no = 0, option = &cache_mangling_list[0]; + for ( option = &cache_mangling_list[0]; option->flagbits; - option_no++, option++ ) + option++ ) { if ( cache->mangling_options & option->flagbits ) { @@ -1043,7 +1042,7 @@ globus_l_gass_cache_mangle(const globus_gass_cache_t cache, * * Build a cache filename; can be used to generate either the global * or local file names. Pass tag=NULL for global. - * + * * Parameters: * * Returns: @@ -1108,7 +1107,7 @@ globus_l_gass_cache_build_dirname( const char *root, /* * globus_l_gass_cache_build_uniqname() - * + * * Parameters: * * Returns: @@ -1147,7 +1146,7 @@ globus_l_gass_cache_build_uniqname( char **uniq ) * globus_l_gass_cache_names_free() * * Free all allocated names - * + * * Parameters: * names - Pointer to the "names" structure * @@ -1204,7 +1203,7 @@ globus_l_gass_cache_names_free( cache_names_t *names ) * globus_l_gass_cache_names_fill_global() * * Fill the global portion of the names structure - * + * * Parameters: * names - The names structure to fill * @@ -1227,7 +1226,7 @@ globus_l_gass_cache_names_fill_global( cache_names_t *names ) if ( GLOBUS_SUCCESS == rc ) { - rc = globus_l_gass_cache_build_dirname( + rc = globus_l_gass_cache_build_dirname( names->global_root, names->separator, NULL, @@ -1249,7 +1248,7 @@ globus_l_gass_cache_names_fill_global( cache_names_t *names ) } if ( GLOBUS_SUCCESS == rc ) { - rc = globus_l_gass_cache_build_filename( + rc = globus_l_gass_cache_build_filename( names->global_dir, names->separator, URL_FILE, @@ -1274,7 +1273,7 @@ globus_l_gass_cache_names_fill_global( cache_names_t *names ) * globus_l_gass_cache_names_fill_local() * * Fill the local portion of the names structure - * + * * Parameters: * names - The names structure to fill * @@ -1298,7 +1297,7 @@ globus_l_gass_cache_names_fill_local( cache_names_t *names ) /* Create the base local directory name (we don't need the URL for it) */ if ( GLOBUS_SUCCESS == rc ) { - rc = globus_l_gass_cache_build_dirname( + rc = globus_l_gass_cache_build_dirname( names->local_root, names->separator, names->mangled_tag, @@ -1314,7 +1313,7 @@ globus_l_gass_cache_names_fill_local( cache_names_t *names ) /* And, the local tag file */ if ( GLOBUS_SUCCESS == rc ) { - rc = globus_l_gass_cache_build_filename( + rc = globus_l_gass_cache_build_filename( names->local_base_dir, names->separator, TAG_FILE, @@ -1332,7 +1331,7 @@ globus_l_gass_cache_names_fill_local( cache_names_t *names ) /* Create the local directory name. */ if ( GLOBUS_SUCCESS == rc ) { - rc = globus_l_gass_cache_build_dirname( + rc = globus_l_gass_cache_build_dirname( names->local_root, names->separator, names->mangled_tag, @@ -1344,7 +1343,7 @@ globus_l_gass_cache_names_fill_local( cache_names_t *names ) /* Build the local data file name; *everything* uses it anyway */ if ( GLOBUS_SUCCESS == rc ) { - rc = globus_l_gass_cache_build_filename( + rc = globus_l_gass_cache_build_filename( names->local_dir, names->separator, DATA_FILE, @@ -1355,7 +1354,7 @@ globus_l_gass_cache_names_fill_local( cache_names_t *names ) /* The local tag "link" name */ if ( GLOBUS_SUCCESS == rc ) { - rc = globus_l_gass_cache_build_filename( + rc = globus_l_gass_cache_build_filename( names->local_dir, names->separator, TAG_FILE, @@ -1380,7 +1379,7 @@ globus_l_gass_cache_names_fill_local( cache_names_t *names ) * globus_l_gass_cache_names_init() * * Initialize the common names structure - * + * * Parameters: * * Returns: @@ -1434,7 +1433,7 @@ globus_l_gass_cache_names_init( const globus_gass_cache_t cache, rc = globus_l_gass_cache_mangle(cache, tag, cache->max_mangled_tag, - &names->mangled_tag, + &names->mangled_tag, NULL ); } /* directory separator character (for flat vs. hierarchial) */ @@ -1470,7 +1469,7 @@ globus_l_gass_cache_names_init( const globus_gass_cache_t cache, { assert(mangle_prefix_end != NULL); - names->local_mangle_root = + names->local_mangle_root = globus_common_create_string( "%s%s%.*s", names->local_root, @@ -1585,7 +1584,7 @@ globus_l_gass_cache_names_new_murl( const char *mangled_url, { rc = globus_l_gass_cache_names_fill_local( names ); } - + /* If we've had failures, free up all allocated memory */ if ( GLOBUS_SUCCESS != rc ) { @@ -1603,7 +1602,7 @@ globus_l_gass_cache_names_new_murl( const char *mangled_url, * * Build a cache filename; can be used to generate either the global * or local file names. Pass tag=NULL for global. - * + * * Parameters: * * Returns: @@ -1669,7 +1668,7 @@ static void TODOgu( const char *g, const char *u, const char *msg ) CACHE_TRACE5( "%d/%s: data/uniq %d/%d", getpid(), msg, data_inode, uniq_inode ); } - + } #else # define TODOgu(_g_,_u_,_m_) @@ -1677,7 +1676,7 @@ static void TODOgu( const char *g, const char *u, const char *msg ) /* * globus_l_gass_cache_create() - * + * * Parameters: * * Returns: @@ -1707,7 +1706,7 @@ globus_l_gass_cache_create( const char *filepath, if ( ENOENT == errno ) { /* If the app gave us a directory, try again... */ - if ( ( NULL != dir ) && + if ( ( NULL != dir ) && ( ++mkdir_try < CREATE_MAX_TRIES ) ) { int rc = globus_l_gass_cache_make_dirtree( @@ -1786,7 +1785,7 @@ globus_l_gass_cache_create( const char *filepath, /* * globus_l_gass_cache_link() - * + * * Parameters: * * Returns: @@ -1821,14 +1820,14 @@ globus_l_gass_cache_link( const char *oldfile, /* RedHat 6.2 seems to return ENOENT sometimes even though * it *does* exist & stat says so. So, we'll stat it, and, if - * it does exist, sleep a bit & try again. + * it does exist, sleep a bit & try again. */ if ( ++link_retry < LINKBUG_MAX_RETRY ) { rc = globus_l_gass_cache_stat( oldfile, NULL ); if ( GLOBUS_SUCCESS == rc ) { - CACHE_TRACE3( + CACHE_TRACE3( "LINK: link bug encountered; try %d, errno %d", link_retry, errno ); globus_libc_usleep( LINKBUG_SLEEP_USEC ); @@ -1861,7 +1860,7 @@ globus_l_gass_cache_link( const char *oldfile, /* * globus_l_gass_cache_rename() - * + * * Parameters: * * Returns: @@ -1895,7 +1894,7 @@ globus_l_gass_cache_rename( const char *oldfile, /* RedHat 6.2 seems to return ENOENT sometimes even though * it *does* exist & stat says so. So, we'll stat it, and, if - * it does exist, sleep a bit & try again. + * it does exist, sleep a bit & try again. */ if ( ++rename_retry < LINKBUG_MAX_RETRY ) { @@ -1932,7 +1931,7 @@ globus_l_gass_cache_rename( const char *oldfile, /* * globus_l_gass_cache_unlink() - * + * * Parameters: * * Returns: @@ -2017,7 +2016,7 @@ globus_l_gass_cache_scandir_free( struct dirent **list, /* * globus_l_gass_cache_scandir() - * + * * Parameters: * * Returns: @@ -2043,7 +2042,7 @@ globus_l_gass_cache_scandir( const char *directory, int count = 0; int rc = GLOBUS_SUCCESS; - + /* Initialize the count */ *list_count = 0; @@ -2058,7 +2057,7 @@ globus_l_gass_cache_scandir( const char *directory, do { dirptr = opendir( dirname ); - + /* Open the directory for reading.. */ if ( dirptr == NULL ) { @@ -2103,7 +2102,7 @@ globus_l_gass_cache_scandir( const char *directory, /* remove prefix from d_name */ char *p = dir_entry->d_name; char *q = p + prefix_len + 1; /* +1 for the separator */ - + while (*q) { *p++ = *q++; @@ -2122,7 +2121,7 @@ globus_l_gass_cache_scandir( const char *directory, /* Grow our list... */ newlist_size *= 2; - tmp = globus_realloc( + tmp = globus_realloc( newlist, newlist_size * sizeof( struct dirent *) ); if ( NULL == tmp ) @@ -2160,7 +2159,7 @@ globus_l_gass_cache_scandir( const char *directory, /* * globus_l_gass_cache_set_timestamp() - * + * * Parameters: * * Returns: @@ -2202,7 +2201,7 @@ globus_l_gass_cache_set_timestamp( const char *filepath, /* * globus_l_gass_cache_calc_timeskew() - * + * * Parameters: * * Returns: @@ -2260,7 +2259,7 @@ globus_l_gass_cache_calc_timeskew( const char *tmp_file, /* * globus_l_gass_cache_calc_timeskew() - * + * * Parameters: * * Returns: @@ -2327,7 +2326,7 @@ globus_l_gass_cache_calc_file_age( const char *tmp_file, /* * globus_l_gass_cache_make_dirtree() - * + * * Parameters: * - filepath -- the directory to create * - cache_type -- one of DIRECTORY_TYPE_NORMAL or DIRECTORY_TYPE_FLAT @@ -2487,7 +2486,7 @@ globus_l_gass_cache_make_dirtree( const char *filepath, int cache_type ) * * Select only files which match any file name. Passed as the third * parameter to scandir() - * + * * Parameters: * * Returns: @@ -2512,7 +2511,7 @@ globus_l_gass_cache_scandir_select_uniq(const struct dirent *entry, } p += prefix_len+1; /* +1 for the separator */ } - + /* All uniq files should start with our "data" pattern */ return ( ! strncmp( p, pattern, len ) ); } /* globus_l_gass_cache_scandir_select_uniq() */ @@ -2522,7 +2521,7 @@ globus_l_gass_cache_scandir_select_uniq(const struct dirent *entry, * * Select only files which match any *data* file name. Passed as the * third paramter to scandir() - * + * * Parameters: * * Returns: @@ -2547,7 +2546,7 @@ globus_l_gass_cache_scandir_select_data(const struct dirent *entry, } p += prefix_len+1; /* +1 for the separator */ } - + /* All uniq files should start with our "data" pattern */ return ( ! strncmp( p, pattern, len ) ); } /* globus_l_gass_cache_scandir_select_data() */ @@ -2557,7 +2556,7 @@ globus_l_gass_cache_scandir_select_data(const struct dirent *entry, * * Select only files which match all patterns. Passed as the third * paramter to scandir() - * + * * Parameters: * * Returns: @@ -2604,13 +2603,13 @@ globus_l_gass_cache_remove_dirtree_flat( const cache_names_t *names, int rc = GLOBUS_SUCCESS; /* check if subdir is empty */ - rc = globus_l_gass_cache_scandir( + rc = globus_l_gass_cache_scandir( tree, names->cache_type, &list, &list_count, globus_l_gass_cache_scandir_select_all ); - + if (rc != GLOBUS_SUCCESS) { /* nothing to do */ @@ -2655,11 +2654,11 @@ globus_l_gass_cache_remove_dirtree_flat( const cache_names_t *names, RET_ERROR( -1 ); } } - + if (rc==GLOBUS_SUCCESS) { char *q, *p = strdup(tree); - if (!p) + if (!p) { RET_ERROR( -1 ); } @@ -2683,7 +2682,7 @@ globus_l_gass_cache_remove_dirtree_flat( const cache_names_t *names, /* * globus_l_gass_cache_remove_dirtree() - * + * * Parameters: * * Returns: @@ -2706,7 +2705,7 @@ globus_l_gass_cache_remove_dirtree( const cache_names_t *names, { return globus_l_gass_cache_remove_dirtree_flat(names, base, tree); } - + /* Make a local copy of hte full path.. */ fullpath = strdup( tree ); if ( NULL == fullpath ) @@ -2774,7 +2773,7 @@ globus_l_gass_cache_remove_dirtree( const cache_names_t *names, * globus_l_gass_cache_check_global_file() * * Check for the existence of a global file - * + * * Parameters: * * Returns: @@ -2804,7 +2803,7 @@ globus_l_gass_cache_check_global_file( const cache_names_t *names, *num_uniq = 0; } /* Scan the directory; we're looking at *all* of the "data" files */ - rc = globus_l_gass_cache_scandir( + rc = globus_l_gass_cache_scandir( names->global_dir, names->cache_type, &data_list, @@ -2859,7 +2858,7 @@ globus_l_gass_cache_check_global_file( const cache_names_t *names, * * Build a cache filename; can be used to generate either the global * or local file names. Pass tag=NULL for global. - * + * * Parameters: * * Returns: @@ -2886,7 +2885,7 @@ globus_l_gass_cache_create_uniq_global_file( const cache_names_t *names ) # endif /* Create my uniq file */ - rc = globus_l_gass_cache_create( + rc = globus_l_gass_cache_create( names->global_uniq_file, names->global_dir, GLOBUS_L_GASS_CACHE_UNIQFILE_MODE, NULL, 0 ); @@ -2909,7 +2908,7 @@ globus_l_gass_cache_create_uniq_global_file( const cache_names_t *names ) uniq_inode = statbuf.st_ino; /* Scan the directory; we're looking at *all* of the "uniq" files */ - rc = globus_l_gass_cache_scandir( + rc = globus_l_gass_cache_scandir( names->global_dir, names->cache_type, &uniq_list, @@ -2969,7 +2968,7 @@ globus_l_gass_cache_create_uniq_global_file( const cache_names_t *names ) if ( GLOBUS_TRUE == lower_inode_found ) { CACHE_TRACE5( "INODE %d '%s' < %d '%s'; we lose", - TODOinode, TODOname, uniq_inode, + TODOinode, TODOname, uniq_inode, names->global_uniq_file ); free( (void *) TODOname ); rc = globus_l_gass_cache_unlink( names->global_uniq_file ); @@ -2991,7 +2990,7 @@ globus_l_gass_cache_create_uniq_global_file( const cache_names_t *names ) * * Create the global "URL" file * Note: Currently we're not checking the URL for match - * + * * Parameters: * * Returns: @@ -3006,7 +3005,7 @@ globus_l_gass_cache_create_global_url_file( cache_names_t *names ) char *uniq_filename = NULL; /* Build "uniq" file name */ - rc = globus_l_gass_cache_build_filename( + rc = globus_l_gass_cache_build_filename( names->global_dir, names->separator, URL_FILE, @@ -3019,7 +3018,7 @@ globus_l_gass_cache_create_global_url_file( cache_names_t *names ) } /* Write the file */ - rc = globus_l_gass_cache_create( + rc = globus_l_gass_cache_create( uniq_filename, names->global_dir, GLOBUS_L_GASS_CACHE_URLFILE_MODE, names->url, strlen( names->url ) ); if ( GLOBUS_SUCCESS != rc ) @@ -3052,7 +3051,7 @@ globus_l_gass_cache_create_global_url_file( cache_names_t *names ) * * Build a cache filename; can be used to generate either the global * or local file names. Pass tag=NULL for global. - * + * * Parameters: * * Returns: @@ -3073,7 +3072,7 @@ globus_l_gass_cache_create_global_file( cache_names_t *names, /* Build file name */ if ( GLOBUS_SUCCESS == rc ) { - rc = globus_l_gass_cache_build_filename( + rc = globus_l_gass_cache_build_filename( names->global_dir, names->separator, UDATA_FILE, @@ -3087,7 +3086,7 @@ globus_l_gass_cache_create_global_file( cache_names_t *names, } /* Scan the directory */ - rc = globus_l_gass_cache_scandir( + rc = globus_l_gass_cache_scandir( names->global_dir, names->cache_type, &uniq_list, @@ -3135,7 +3134,7 @@ globus_l_gass_cache_create_global_file( cache_names_t *names, * globus_l_gass_cache_make_ready() * * Make the global file "ready". - * + * * Parameters: * * Returns: @@ -3155,7 +3154,7 @@ globus_l_gass_cache_make_ready( cache_names_t *names, /* Build the uniq file name */ if ( GLOBUS_SUCCESS == rc ) { - rc = globus_l_gass_cache_build_filename( + rc = globus_l_gass_cache_build_filename( names->global_dir, names->separator, UDATA_FILE, @@ -3255,7 +3254,7 @@ globus_l_gass_cache_make_ready( cache_names_t *names, * * Build a cache filename; can be used to generate either the global * or local file names. Pass tag=NULL for global. - * + * * Parameters: * * Returns: @@ -3276,7 +3275,7 @@ globus_l_gass_cache_make_unready( cache_names_t *names ) /* Build the name of the uniq file... */ if ( GLOBUS_SUCCESS == rc ) { - rc = globus_l_gass_cache_build_filename( + rc = globus_l_gass_cache_build_filename( names->global_dir, names->separator, UDATA_FILE, @@ -3312,7 +3311,7 @@ globus_l_gass_cache_make_unready( cache_names_t *names ) names->separator, LOCK_FILE, NULL, - NULL, + NULL, &names->globaldir_lock_file ); if ( GLOBUS_SUCCESS != rc ) { @@ -3425,7 +3424,7 @@ globus_l_gass_cache_make_unready( cache_names_t *names ) * globus_l_gass_cache_wait_ready() * * Wait for the global file to become ready. - * + * * Parameters: * * Returns: @@ -3455,7 +3454,7 @@ globus_l_gass_cache_wait_ready( const cache_names_t *names, /* Default to check right away, then we'll wait before further checks */ cur_time = checktime = ( time(NULL) + 0 ); - + /* Run til we're done */ while( 1 ) { @@ -3468,7 +3467,7 @@ globus_l_gass_cache_wait_ready( const cache_names_t *names, } else if ( GLOBUS_SUCCESS == rc ) { - dir_age = globus_l_gass_cache_calc_file_age( + dir_age = globus_l_gass_cache_calc_file_age( NULL, cur_time, statbuf.st_mtime ); } else @@ -3504,7 +3503,7 @@ globus_l_gass_cache_wait_ready( const cache_names_t *names, checktime = ( time(NULL) + NOTREADY_CHECK_SECONDS ); /* Scan the directory; we're looking at *all* of the "uniq" files */ - rc = globus_l_gass_cache_scandir( + rc = globus_l_gass_cache_scandir( names->global_dir, names->cache_type, &uniq_list, @@ -3535,7 +3534,7 @@ globus_l_gass_cache_wait_ready( const cache_names_t *names, for ( uniq_num = 0; uniq_num < uniq_count; uniq_num++ ) { time_t age; /* Age (seconds) of the file */ - + /* Fill in the file name buffer */ rc = globus_l_gass_cache_build_filename( names->global_dir, @@ -3546,12 +3545,12 @@ globus_l_gass_cache_wait_ready( const cache_names_t *names, &cur_statpath ); if (rc != GLOBUS_SUCCESS) - { + { free( cur_statpath ); globus_l_gass_cache_scandir_free( uniq_list, uniq_count ); RET_ERROR( rc ); } - + /* Now, go stat() the file and learn all about it */ rc = globus_l_gass_cache_stat( cur_statpath, &statbuf); @@ -3586,7 +3585,7 @@ globus_l_gass_cache_wait_ready( const cache_names_t *names, /* Done with the list! */ globus_l_gass_cache_scandir_free( uniq_list, uniq_count ); if ( cur_statpath ) - { + { free( cur_statpath ); } @@ -3613,7 +3612,7 @@ globus_l_gass_cache_wait_ready( const cache_names_t *names, * globus_l_gass_cache_find_uniq() * * Find a uniq file - * + * * Parameters: * * Returns: @@ -3635,7 +3634,7 @@ globus_l_gass_cache_find_uniq( const char *dir, /* Scan the directory; we're looking at *all* of the "uniq" files */ *uniq_count = 0; - rc = globus_l_gass_cache_scandir( + rc = globus_l_gass_cache_scandir( dir, cache_type, &uniq_list, @@ -3661,7 +3660,7 @@ globus_l_gass_cache_find_uniq( const char *dir, globus_l_gass_cache_scandir_free( uniq_list, *uniq_count ); /* Done */ - return ( ( NULL == uniq_file ) ? + return ( ( NULL == uniq_file ) ? GLOBUS_GASS_CACHE_ERROR_NO_MEMORY : GLOBUS_SUCCESS ); } /* globus_l_gass_cache_find_uniq() */ @@ -3676,7 +3675,7 @@ globus_l_gass_cache_find_uniq( const char *dir, * * tryno : Attempt number * - * Returns: + * Returns: * * # Of uSec acutal slept */ @@ -3707,7 +3706,7 @@ globus_l_gass_cache_lock_delay( int tryno ) * globus_l_gass_cache_lock_local_dir() * * Lock the local directory - * + * * Parameters: * * Returns: @@ -3741,7 +3740,7 @@ globus_l_gass_cache_lock_local_dir( cache_names_t *names, while( 1 ) { /* Link to the lock file. If it works, we're done */ - rc = globus_l_gass_cache_link( existing_file, + rc = globus_l_gass_cache_link( existing_file, names->localdir_lock_file ); if ( GLOBUS_SUCCESS == rc ) { @@ -3877,7 +3876,7 @@ globus_l_gass_cache_unlock_local_dir( cache_names_t *names, * * Create the local "Tag" file * Note: Currently we're not checking the tag for match - * + * * Parameters: * * Returns: @@ -3892,7 +3891,7 @@ globus_l_gass_cache_create_local_tag_file( cache_names_t *names ) char *uniq_filename = NULL; /* Build "uniq" file name */ - rc = globus_l_gass_cache_build_filename( + rc = globus_l_gass_cache_build_filename( names->tmp_root, names->separator, TAG_FILE, @@ -3905,7 +3904,7 @@ globus_l_gass_cache_create_local_tag_file( cache_names_t *names ) } /* Write the file */ - rc = globus_l_gass_cache_create( + rc = globus_l_gass_cache_create( uniq_filename, names->local_dir, GLOBUS_L_GASS_CACHE_TAGFILE_MODE, names->tag, strlen( names->tag ) ); if ( GLOBUS_SUCCESS != rc ) @@ -3941,7 +3940,7 @@ globus_l_gass_cache_create_local_tag_file( cache_names_t *names ) * * Build a cache filename; can be used to generate either the global * or local file names. Pass tag=NULL for global. - * + * * Parameters: * * Returns: @@ -4003,7 +4002,7 @@ globus_l_gass_cache_make_local_file( cache_names_t *names, /* Link the global file to the local file. */ rc = globus_l_gass_cache_link( global_file, names->local_data_file ); - + /* We're done with the gloal file buffer, so free it right away. */ free( global_file ); @@ -4025,7 +4024,7 @@ globus_l_gass_cache_make_local_file( cache_names_t *names, CLR_ERROR; /* This is ok! */ } else - { + { /* Badness 10000 */ RET_ERROR( rc ); } @@ -4054,7 +4053,7 @@ globus_l_gass_cache_make_local_file( cache_names_t *names, * * Build a cache filename; can be used to generate either the global * or local file names. Pass tag=NULL for global. - * + * * Parameters: * * Returns: @@ -4079,7 +4078,7 @@ globus_l_gass_cache_unlink_local( cache_names_t *names ) /* Find a uniq file to kill... */ rc = globus_l_gass_cache_find_uniq( names->local_dir, names->cache_type, - &uniq_file, + &uniq_file, &uniq_count ); if ( GLOBUS_SUCCESS != rc ) { @@ -4124,7 +4123,7 @@ globus_l_gass_cache_unlink_local( cache_names_t *names ) if ( 1 == uniq_count ) { rc = globus_l_gass_cache_unlink( names->local_data_file ); - if ( ( GLOBUS_SUCCESS != rc ) && + if ( ( GLOBUS_SUCCESS != rc ) && ( GLOBUS_L_ENOENT != rc ) ) { (void) globus_l_gass_cache_unlock_local_dir( names, NULL ); @@ -4148,7 +4147,7 @@ globus_l_gass_cache_unlink_local( cache_names_t *names ) /* Kill the local data file */ rc = globus_l_gass_cache_unlink( names->local_data_file ); - if ( ( GLOBUS_SUCCESS != rc ) && + if ( ( GLOBUS_SUCCESS != rc ) && ( GLOBUS_L_ENOENT != rc ) ) { RET_ERROR( rc ); @@ -4159,7 +4158,7 @@ globus_l_gass_cache_unlink_local( cache_names_t *names ) names->local_root, names->local_mangle_root, names->local_dir ); - + /* >0 is ok: remove_dirtree() is oportunistic... */ if ( rc < 0 ) { @@ -4207,7 +4206,7 @@ globus_l_gass_cache_unlink_local( cache_names_t *names ) * globus_l_gass_cache_unlink_global() * * Unlink the global data & URL file, remove the global directory if empty. - * + * * Parameters: * names - File & dir name * @@ -4230,7 +4229,7 @@ globus_l_gass_cache_unlink_global( cache_names_t *names, if ( is_locked ) { /* Make sure that the uniq file name is valid */ - rc = globus_l_gass_cache_build_filename( + rc = globus_l_gass_cache_build_filename( names->global_dir, names->separator, UDATA_FILE, @@ -4314,7 +4313,7 @@ globus_l_gass_cache_list_all_urls_flat( globus_gass_cache_t cache_handle, int table_size = 16; /* Scan the directory; we're looking at *all* of the "uniq" files */ - rc = globus_l_gass_cache_scandir( + rc = globus_l_gass_cache_scandir( search_dir, cache_handle->cache_type, &dirent_list, @@ -4347,11 +4346,11 @@ globus_l_gass_cache_list_all_urls_flat( globus_gass_cache_t cache_handle, globus_l_gass_cache_scandir_free( dirent_list, dirent_count ); RET_ERROR( rc ); } - + /* Walk through the matches... */ for ( dirent_num = 0; dirent_num < dirent_count; dirent_num++ ) { - const char *name = dirent_list[dirent_num]->d_name; + char *name = dirent_list[dirent_num]->d_name; char *p; url_list_elem_t *elem; @@ -4360,11 +4359,11 @@ globus_l_gass_cache_list_all_urls_flat( globus_gass_cache_t cache_handle, { continue; } - + /* remove the {separator}data.* part of the file. 'name' now holds the mangled url!!! */ if ( p > name) - { + { *(p-1) = '\0'; } @@ -4390,7 +4389,7 @@ globus_l_gass_cache_list_all_urls_flat( globus_gass_cache_t cache_handle, elem->next = url_list->head; globus_hashtable_insert(&table, elem->mangled, elem); - + url_list->head = elem; url_list->count++; } @@ -4409,7 +4408,7 @@ globus_l_gass_cache_list_all_urls_flat( globus_gass_cache_t cache_handle, * * Build a cache filename; can be used to generate either the global * or local file names. Pass tag=NULL for global. - * + * * Parameters: * * Returns: @@ -4440,11 +4439,11 @@ globus_l_gass_cache_list_all_urls( globus_gass_cache_t cache_handle, search_dir, url_list); } - + separator = directory_separator[cache_handle->cache_type]; /* Scan the directory; we're looking at *all* of the "uniq" files */ - rc = globus_l_gass_cache_scandir( + rc = globus_l_gass_cache_scandir( search_dir, cache_handle->cache_type, &dirent_list, @@ -4479,7 +4478,7 @@ globus_l_gass_cache_list_all_urls( globus_gass_cache_t cache_handle, strcpy( name_path, search_dir ); strcat( name_path, separator ); strcat( name_path, name ); - + /* Stat it to find out what it is... */ rc = globus_l_gass_cache_stat( name_path, &statbuf ); @@ -4529,7 +4528,7 @@ globus_l_gass_cache_list_all_urls( globus_gass_cache_t cache_handle, /* Add myself to the list */ if ( data_count ) { - url_list_elem_t *new_url_elem = + url_list_elem_t *new_url_elem = malloc( sizeof( url_list_elem_t ) ); if ( NULL == new_url_elem ) { @@ -4554,7 +4553,7 @@ globus_l_gass_cache_list_all_urls( globus_gass_cache_t cache_handle, * * Build a cache filename; can be used to generate either the global * or local file names. Pass tag=NULL for global. - * + * * Parameters: * * Returns: @@ -4605,7 +4604,7 @@ globus_l_gass_cache_delete( cache_names_t *names, /* Set the file's timestamp (if the we're passed one) */ else if ( ( GLOBUS_SUCCESS == rc ) && ( NULL != timestamp ) ) { - rc = globus_l_gass_cache_set_timestamp( + rc = globus_l_gass_cache_set_timestamp( names->global_data_file, *timestamp ); if ( GLOBUS_SUCCESS != rc ) { @@ -4627,7 +4626,7 @@ globus_l_gass_cache_delete( cache_names_t *names, /****************************************************************************** PUBLIC FUNCTIONS - + ******************************************************************************/ /** @@ -4635,7 +4634,7 @@ globus_l_gass_cache_delete( cache_names_t *names, * @ingroup globus_gass_cache * @details * Open the cache specified by the cache_directory_path argument, and return - * a cache handle that can be used in subsequent cache calls. + * a cache handle that can be used in subsequent cache calls. * * If cache_directory_path is NULL, then use the value contained in the * GLOBUS_GASS_CACHE_DEFAULT environment variable if it is defined, @@ -4655,7 +4654,7 @@ globus_l_gass_cache_delete( cache_names_t *names, * (see globus_gass_gache.h) Some files are also opened: * globus_gass_cache_close() must be called subsequently to close those * files. This parameter is modified by the globus_gass_cache_open() - * + * * @retval GLOBUS_SUCCESS * Success * @retval GLOBUS_GASS_CACHE_ERROR_CACHE_ALREADY_OPENED @@ -4665,7 +4664,7 @@ globus_l_gass_cache_delete( cache_names_t *names, * @retval GLOBUS_GASS_CACHE_ERROR_NO_HOME * Can't find home directory for default cache path */ -int +int globus_gass_cache_open(const char *cache_directory_path, globus_gass_cache_t *cache_handlep) @@ -4709,12 +4708,12 @@ globus_gass_cache_open(const char *cache_directory_path, gettimeofday( &tv, NULL ); srandom( tv.tv_usec ); } - + /* look for the correct directory path */ /* if cache_directory_path empty (""), behave as if NULL */ - if ( cache_directory_path != NULL) - { + if ( cache_directory_path != NULL) + { f_name_length=strlen(cache_directory_path); if ( f_name_length == 0 ) { @@ -4737,7 +4736,7 @@ globus_gass_cache_open(const char *cache_directory_path, if ( NULL == pt ) { - GLOBUS_L_GASS_CACHE_LG2( "'%s' is empty", + GLOBUS_L_GASS_CACHE_LG2( "'%s' is empty", GLOBUS_L_GASS_CACHE_DEFAULT_DIR_ENV_VAR ); /* cache directory still not defined; use the defaults */ /* "$HOME/.globus_gass_cache" */ @@ -4747,7 +4746,7 @@ globus_gass_cache_open(const char *cache_directory_path, if ( f_name_length > 0) pt = homedir; } - + if ( NULL == pt ) { /* $HOME not defined or null ! this should not happen */ @@ -4784,11 +4783,11 @@ globus_gass_cache_open(const char *cache_directory_path, GLOBUS_L_DOT_GLOBUS_DIR_NAME ); strcat(cache_handle->cache_directory_path, GLOBUS_L_GASS_CACHE_DEFAULT_DIR_NAME); - cache_handle->global_dir_len = + cache_handle->global_dir_len = strlen( cache_handle->cache_directory_path ); /* Build & verify the whole tree */ - rc = globus_l_gass_cache_make_dirtree( + rc = globus_l_gass_cache_make_dirtree( cache_handle->cache_directory_path, DIRECTORY_TYPE_NORMAL); if ( GLOBUS_L_ENOTDIR == rc ) @@ -4831,7 +4830,7 @@ globus_gass_cache_open(const char *cache_directory_path, LOG_ERROR(0); return ( GLOBUS_GASS_CACHE_ERROR_NAME_TOO_LONG); } - cache_handle->cache_directory_path = + cache_handle->cache_directory_path = strdup( cache_directory_path ); if ( NULL == cache_handle->cache_directory_path ) { @@ -4845,7 +4844,7 @@ globus_gass_cache_open(const char *cache_directory_path, /* here, *cache_handle.cache_directory_path should be defined */ /* let see if it exists, and create it if it does not */ - rc = globus_l_gass_cache_make_dirtree( + rc = globus_l_gass_cache_make_dirtree( cache_handle->cache_directory_path, DIRECTORY_TYPE_NORMAL); if ( GLOBUS_L_ENOTDIR == rc ) @@ -4968,8 +4967,8 @@ globus_gass_cache_open(const char *cache_directory_path, if ( write_config & WRITE_CONFIG_TYPE ) { fprintf( - fp, - "%s=%s\n", + fp, + "%s=%s\n", GLOBUS_L_GASS_CACHE_CONFIG_KEY_TYPE, directory_type_values[cache_handle->cache_type]); } @@ -5085,7 +5084,7 @@ globus_gass_cache_open(const char *cache_directory_path, if ( GLOBUS_SUCCESS == rc ) { char *skew_file = NULL; - rc = globus_l_gass_cache_build_filename( + rc = globus_l_gass_cache_build_filename( cache_handle->tmp_directory_path, separator, NULL, @@ -5099,7 +5098,7 @@ globus_gass_cache_open(const char *cache_directory_path, return GLOBUS_GASS_CACHE_ERROR_NO_MEMORY; } (void) globus_l_gass_cache_calc_file_age( skew_file, - time(NULL), + time(NULL), time(NULL) ); free( skew_file ); } @@ -5142,20 +5141,20 @@ globus_gass_cache_open(const char *cache_directory_path, * @ingroup globus_gass_cache * @details * Close (NOT delete) a previously opened cache: - * - close the opened files and + * - close the opened files and * - free the memory allocated for the cache_handle. * - mark the handle as "not initialized". * - * Parameters: - * cache_handle: Handle to the opened cache directory to use. - * + * Parameters: + * cache_handle: Handle to the opened cache directory to use. + * * cache_handle->is_init set to "not initialized" and all the - * files opened bu globus_gass_cache_open are closed . + * files opened bu globus_gass_cache_open are closed . * * Returns: * GLOBUS_SUCCESS or error code: * GLOBUS_GASS_CACHE_ERROR_CACHE_NOT_OPENED - * + * */ int globus_gass_cache_close( @@ -5183,7 +5182,7 @@ globus_gass_cache_close( { struct stat statbuf; int rc; - rc = globus_l_gass_cache_stat( + rc = globus_l_gass_cache_stat( cache_handle->log_file_name, &statbuf ); if ( GLOBUS_SUCCESS == rc ) { @@ -5204,7 +5203,7 @@ globus_gass_cache_close( free( cache_handle->tmp_directory_path ); free( *cache_handlep ); - + GLOBUS_L_GASS_CACHE_LG("Cache Closed"); return(GLOBUS_SUCCESS); } @@ -5232,12 +5231,12 @@ globus_gass_cache_close( * return GLOBUS_GASS_CACHE_ADD_NEW. * * If the URL is not in the cache, and create==GLOBUS_FALSE, then do not - * add it to the cache, and return GLOBUS_GASS_CACHE_URL_NOT_FOUND. + * add it to the cache, and return GLOBUS_GASS_CACHE_URL_NOT_FOUND. * * If this function returns GLOBUS_GASS_CACHE_ADD_EXISTS or * GLOBUS_GASS_CACHE_ADD_NEW, then globus_gass_cache_add_done() or * globus_gass_cache_delete() must be subsequently - * called to unlock the cache entry. + * called to unlock the cache entry. * * Subsequent calls to globus_gass_cache_add() and * globus_gass_cache_delete_start() on the same cache and url, made either @@ -5256,7 +5255,7 @@ globus_gass_cache_close( * * @note the local_filename MUST be free by the user in a * subsequent operation, using free() - * + * * @param cache_handle * Handle to the opened cache directory to use. * @param url @@ -5276,15 +5275,15 @@ globus_gass_cache_close( * @param local_filename * Path the the local file caching the file * specified by "url". NULL if "url" not yet cached and - * creation not requested (create false). + * creation not requested (create false). * - * @return + * @return * - GLOBUS_GASS_CACHE_URL_NOT_FOUND * - GLOBUS_GASS_CACHE_ADD_NEW * - GLOBUS_GASS_CACHE_ADD_EXISTS * - or any of the defined gass error code. */ -extern +extern int globus_gass_cache_add( globus_gass_cache_t cache_handle, @@ -5307,7 +5306,7 @@ globus_gass_cache_add( /* simply check if the cache has been opened */ CHECK_CACHE_IS_INIT(cache_handle); CLR_ERROR; - + /* Timestamp is unknown for now, no filename, ... */ *timestamp = GLOBUS_GASS_CACHE_TIMESTAMP_UNKNOWN; *local_filename = NULL; @@ -5322,7 +5321,7 @@ globus_gass_cache_add( return rc; } - /* I want to do every thing again and again until the data file + /* I want to do every thing again and again until the data file is ready */ while ( 1 ) { @@ -5391,7 +5390,7 @@ globus_gass_cache_add( /* Ok. We've created the global "uniq" file. Now, make * the local. Don't wait for it to become ready - we * created it!! */ - rc = globus_l_gass_cache_make_local_file( + rc = globus_l_gass_cache_make_local_file( &names, UDATA_FILE, names.uniq ); @@ -5471,7 +5470,7 @@ globus_gass_cache_add( /* Ok; it's ready. Make the local file, then we're done */ TODOgu( NULL, NULL, "Before MLF" ); - rc = globus_l_gass_cache_make_local_file( + rc = globus_l_gass_cache_make_local_file( &names, global_name, global_uniq ); @@ -5515,7 +5514,7 @@ globus_gass_cache_add( return retval; } /* globus_gass_cache_add() */ - + /** * @brief Complete adding a cache entry and unlock it * @ingroup globus_gass_cache @@ -5525,7 +5524,7 @@ globus_gass_cache_add( * cache entry. (The only case it does not need to be called is if * globus_gass_cache_add() has returned GLOBUS_GASS_CACHE_URL_NOT_FOUND, of * course. - * + * * @param cache_handle * Handle to the opened cache directory to use. * @param url @@ -5550,11 +5549,11 @@ globus_gass_cache_add_done( { int rc; /* general purpose return code */ cache_names_t names; - + /* simply check if the cache has been opened */ CHECK_CACHE_IS_INIT(cache_handle); CLR_ERROR; - + /* Generate the local and global filenames */ rc = globus_l_gass_cache_names_init( cache_handle, url, tag, &names ); if ( GLOBUS_SUCCESS != rc ) @@ -5578,7 +5577,7 @@ globus_gass_cache_add_done( { # if ( ! LOCK_ADD_EXISTS ) globus_l_gass_cache_names_free( &names ); - CLR_ERROR; + CLR_ERROR; return GLOBUS_SUCCESS; # else CACHE_TRACE3( "Lost my uniq file '%s' in '%s', data exists", @@ -5655,7 +5654,7 @@ globus_gass_cache_query( /* simply check if the cache has been opened */ CHECK_CACHE_IS_INIT(cache_handle); CLR_ERROR; - + /* Generate the local and global filenames */ rc = globus_l_gass_cache_names_init( cache_handle, url, tag, &names ); @@ -5745,11 +5744,11 @@ globus_gass_cache_delete_start(globus_gass_cache_t cache_handle, { int rc; /* general purpose return code */ cache_names_t names; - + /* simply check if the cache has been opened */ CHECK_CACHE_IS_INIT(cache_handle); CLR_ERROR; - + /* Generate the local and global filenames */ rc = globus_l_gass_cache_names_init( cache_handle, url, tag, &names ); if ( GLOBUS_SUCCESS != rc ) @@ -5806,7 +5805,7 @@ globus_gass_cache_delete_start(globus_gass_cache_t cache_handle, * entry and delete the associated local cache file. * * Otherwise, update the timestamp to the passed value. - * + * * This call will leave the cache entry unlocked. * * If is_locked==GLOBUS_TRUE, then this cache entry was locked during a @@ -5838,7 +5837,7 @@ globus_gass_cache_delete_start(globus_gass_cache_t cache_handle, * globus_gass_cache_delete_start(). * * @return The globus_gass_cache_delete() function returns - * GLOBUS_SUCCESS or any of the defined GASS Cache error codes. + * GLOBUS_SUCCESS or any of the defined GASS Cache error codes. */ extern int @@ -5848,15 +5847,15 @@ globus_gass_cache_delete( const char *tag, unsigned long timestamp, globus_bool_t is_locked ) -{ +{ int rc; /* general purpose return code */ int retval = GLOBUS_SUCCESS; /* Our return value. */ cache_names_t names; double TODOstime = TODOGetTime(); - + /* simply check if the cache has been opened */ CHECK_CACHE_IS_INIT(cache_handle); - + /* Generate the local and global filenames */ rc = globus_l_gass_cache_names_init( cache_handle, url, tag, &names ); @@ -5868,7 +5867,7 @@ globus_gass_cache_delete( } /* Do the actual delete... */ - rc = globus_l_gass_cache_delete( + rc = globus_l_gass_cache_delete( &names, ×tamp, is_locked ); /* Free up name buffers */ @@ -5903,7 +5902,7 @@ globus_gass_cache_delete( * function, then the entry is unlocked after removing the tags. * Otherwise, the cache entry's lock is left untouched. * - * This function does not block on a locked reference. + * This function does not block on a locked reference. * * @note The GLOBUS_GRAM job manager will automatically call this function * with a tag of getenv("GLOBUS_GRAM_JOB_CONTACT") upon completion of a job. @@ -5918,7 +5917,7 @@ globus_gass_cache_delete( * is usually the GLOBUS_GRAM_JOB_CONTACT. Can be NULL or empty; the * tag "null" is then used. * @return The globus_gass_cache_cleanup_tag() function returns - * GLOBUS_SUCCESS or any of the defined GASS Cache error codes. + * GLOBUS_SUCCESS or any of the defined GASS Cache error codes. */ extern int @@ -5931,10 +5930,10 @@ globus_gass_cache_cleanup_tag( cache_names_t names; double TODOstime = TODOGetTime(); int TODOnum = 0; - + /* simply check if the cache has been opened */ CHECK_CACHE_IS_INIT(cache_handle); - + /* Generate the local and global filenames */ rc = globus_l_gass_cache_names_init( cache_handle, url, tag, &names ); @@ -5966,7 +5965,7 @@ globus_gass_cache_cleanup_tag( CACHE_TRACE( buf ); } return rc; - + } /* globus_gass_cache_add_cleanup_tag() */ @@ -5995,7 +5994,7 @@ globus_gass_cache_cleanup_tag( * tag "null" is then used. * * @return The globus_gass_cache_cleanup_tag_all() function returns - * GLOBUS_SUCCESS or any of the defined GASS Cache error codes. + * GLOBUS_SUCCESS or any of the defined GASS Cache error codes. */ extern int @@ -6011,10 +6010,10 @@ globus_gass_cache_cleanup_tag_all( url_list_head_t url_list; url_list_elem_t *url_elem, *url_next; int data_num; - + /* simply check if the cache has been opened */ CHECK_CACHE_IS_INIT(cache_handle); - + /* Build the base local directory to use. */ rc = globus_l_gass_cache_names_init( cache_handle, NULL, tag, &names ); @@ -6048,7 +6047,7 @@ globus_gass_cache_cleanup_tag_all( { RET_ERROR( rc ); } - CACHE_TRACE4( "cleanup: scanned '%s' (tag '%s'), found %d", + CACHE_TRACE4( "cleanup: scanned '%s' (tag '%s'), found %d", base_local_dir, tag, url_list.count ); /* Walk through 'em all */ @@ -6074,7 +6073,7 @@ globus_gass_cache_cleanup_tag_all( /* Loop through all of the "data" links found */ for( data_num = 0; data_num < url_elem->data_count; data_num++ ) { - rc = globus_l_gass_cache_delete( &names, NULL, + rc = globus_l_gass_cache_delete( &names, NULL, GLOBUS_FALSE); if ( GLOBUS_SUCCESS != rc ) { @@ -6123,7 +6122,7 @@ globus_gass_cache_cleanup_tag_all( * Mangles the given URL into a chunk suitable for using as a file / * path name. This is exported for use in the globus_gass_cache * program. - * + * * @param cache_handle * Handle to the opened cache directory to use. * @param url @@ -6167,7 +6166,7 @@ globus_gass_cache_mangle_url( const globus_gass_cache_t cache_handle, * Mangles the given tag into a chunk suitable for using as a file / * path name. This is exported for use in the globus_gass_cache * program. - * + * * @param cache_handle * Handle to the opened cache directory to use. * @param tag @@ -6211,7 +6210,7 @@ globus_gass_cache_mangle_tag( const globus_gass_cache_t cache_handle, * @details * Get a the root cache of directory. This is exported for use in the * globus_gass_cache program. - * + * * @param cache_handle * Handle to the opened cache directory to use. * @param cache_dir @@ -6253,7 +6252,7 @@ globus_gass_cache_get_cache_dir( const globus_gass_cache_t cache_handle, * @details * Gets a bunch of directories. This is exported for use in the * globus_gass_cache program. - * + * * @param cache_handle * Handle to the opened cache directory to use. * @param url @@ -6318,10 +6317,10 @@ globus_gass_cache_get_dirs( const globus_gass_cache_t cache_handle, { *local_dir = NULL; } - + /* simply check if the cache has been opened */ CHECK_CACHE_IS_INIT(cache_handle); - + /* Generate the local and global filenames */ rc = globus_l_gass_cache_names_init( cache_handle, url, tag, &names ); @@ -6387,7 +6386,7 @@ globus_gass_cache_get_dirs( const globus_gass_cache_t cache_handle, * @ingroup globus_gass_cache * @details * Get a string which describes the cache type ("normal" or "flat") - * + * * @param cache_handle * Handle to the opened cache directory to use. * @param cache_type @@ -6433,7 +6432,7 @@ globus_gass_cache_get_cache_type_string( const globus_gass_cache_t cache_h * @param error_code * error code returned by a previously called globus_gass_cache function. * - * @return The globus_gass_cache_error_string() function returns a + * @return The globus_gass_cache_error_string() function returns a * pointer to an error message, or NULL if error_code is invalid. */ extern diff --git a/gass/copy/source/configure.ac b/gass/copy/source/configure.ac index eaf7e6c862..6c11a27c80 100644 --- a/gass/copy/source/configure.ac +++ b/gass/copy/source/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ([2.60]) -AC_INIT([globus_gass_copy],[10.13],[https://github.com/gridcf/gct/issues]) +AC_INIT([globus_gass_copy],[10.14],[https://github.com/gridcf/gct/issues]) AC_CONFIG_MACRO_DIR([m4]) AC_SUBST([MAJOR_VERSION], [${PACKAGE_VERSION%%.*}]) AC_SUBST([MINOR_VERSION], [${PACKAGE_VERSION##*.}]) diff --git a/gass/copy/source/globus_gass_copy.c b/gass/copy/source/globus_gass_copy.c index 264ed28e8e..61365d1cc7 100644 --- a/gass/copy/source/globus_gass_copy.c +++ b/gass/copy/source/globus_gass_copy.c @@ -94,7 +94,7 @@ globus_result_t globus_l_gass_copy_state_free_targets( globus_gass_copy_state_t * state); -static +static globus_result_t globus_l_gass_copy_verify_cksm( globus_gass_copy_handle_t * copy_handle, @@ -118,7 +118,7 @@ globus_l_gass_copy_verify_cksm( globus_object_t *tmp_err; \ tmp_err = globus_error_get(result); \ handle->err = globus_object_copy(tmp_err); \ - result = globus_error_put(tmp_err); \ + result = globus_error_put(tmp_err); \ } \ } @@ -153,30 +153,30 @@ globus_l_gass_copy_activate(void) rc = globus_module_activate(GLOBUS_GASS_TRANSFER_MODULE); if (rc != GLOBUS_SUCCESS) { - return(rc); + return(rc); } rc = globus_module_activate(GLOBUS_COMMON_MODULE); if (rc != GLOBUS_SUCCESS) { - return(rc); + return(rc); } rc = globus_module_activate(GLOBUS_IO_MODULE); if (rc != GLOBUS_SUCCESS) { - return(rc); + return(rc); } rc = globus_module_activate(GLOBUS_FTP_CLIENT_MODULE); if (rc != GLOBUS_SUCCESS) { - return(rc); + return(rc); } rc = globus_module_activate(GLOBUS_FTP_CLIENT_THROUGHPUT_PLUGIN_MODULE); if (rc != GLOBUS_SUCCESS) { - return(rc); + return(rc); } return 0; @@ -197,7 +197,7 @@ globus_l_gass_copy_deactivate(void) if (rc != GLOBUS_SUCCESS) { - return(rc); + return(rc); } #ifdef GLOBUS_I_GASS_COPY_DEBUG @@ -207,7 +207,7 @@ globus_l_gass_copy_deactivate(void) rc = globus_module_deactivate(GLOBUS_COMMON_MODULE); if (rc != GLOBUS_SUCCESS) { - return(rc); + return(rc); } #ifdef GLOBUS_I_GASS_COPY_DEBUG @@ -217,7 +217,7 @@ globus_l_gass_copy_deactivate(void) rc = globus_module_deactivate(GLOBUS_IO_MODULE); if (rc != GLOBUS_SUCCESS) { - return(rc); + return(rc); } #ifdef GLOBUS_I_GASS_COPY_DEBUG @@ -227,7 +227,7 @@ globus_l_gass_copy_deactivate(void) rc = globus_module_deactivate(GLOBUS_GASS_TRANSFER_MODULE); if (rc != GLOBUS_SUCCESS) { - return(rc); + return(rc); } #ifdef GLOBUS_I_GASS_COPY_DEBUG globus_libc_fprintf(stderr,"GASS_COPY: done globus_module_deactivate(GLOBUS_GASS_TRANSFER_MODULE) \n"); @@ -236,7 +236,7 @@ globus_l_gass_copy_deactivate(void) rc = globus_module_deactivate(GLOBUS_FTP_CLIENT_THROUGHPUT_PLUGIN_MODULE); if (rc != GLOBUS_SUCCESS) { - return(rc); + return(rc); } return 0; } /* globus_i_gass_copy_deactivate() */ @@ -259,8 +259,8 @@ globus_l_gass_copy_monitor_callback( monitor->done = GLOBUS_TRUE; if(error != GLOBUS_NULL) { - monitor->err = globus_object_copy(error); - monitor->use_err = GLOBUS_TRUE; + monitor->err = globus_object_copy(error); + monitor->use_err = GLOBUS_TRUE; } globus_cond_signal(&monitor->cond); globus_mutex_unlock(&monitor->mutex); @@ -315,13 +315,13 @@ globus_gass_copy_handle_init( if(handle != GLOBUS_NULL) { - globus_ftp_client_handleattr_t * ftp_attr; + globus_ftp_client_handleattr_t * ftp_attr; - ftp_attr = (attr && attr->ftp_attr) ? attr->ftp_attr : GLOBUS_NULL; + ftp_attr = (attr && attr->ftp_attr) ? attr->ftp_attr : GLOBUS_NULL; result = globus_ftp_client_handle_init(&handle->ftp_handle_2, ftp_attr); - + if (result != GLOBUS_SUCCESS) return result; @@ -350,13 +350,13 @@ globus_gass_copy_handle_init( } else { - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: BAD_PARAMETER, handle is NULL", - myname); + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: BAD_PARAMETER, handle is NULL", + myname); - return globus_error_put(err); + return globus_error_put(err); } } @@ -395,7 +395,7 @@ globus_gass_copy_handle_destroy( result = globus_ftp_client_handle_destroy(&handle->ftp_handle); - if(handle->err != GLOBUS_NULL) + if(handle->err != GLOBUS_NULL) globus_object_free(handle->err); handle->err = GLOBUS_NULL; @@ -408,24 +408,24 @@ globus_gass_copy_handle_destroy( globus_free(handle->performance); handle->performance = GLOBUS_NULL; } - + if(handle->state) { globus_l_gass_copy_state_free(handle->state); handle->state = GLOBUS_NULL; } - + return result; } else { - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: BAD_PARAMETER, handle is NULL", - myname); + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: BAD_PARAMETER, handle is NULL", + myname); - return globus_error_put(err); + return globus_error_put(err); } } @@ -438,19 +438,19 @@ globus_gass_copy_handleattr_init( if(handle_attr) { - handle_attr->ftp_attr = GLOBUS_NULL; + handle_attr->ftp_attr = GLOBUS_NULL; - return GLOBUS_SUCCESS; + return GLOBUS_SUCCESS; } else { - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: BAD_PARAMETER, handle_attr is NULL", - myname); + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: BAD_PARAMETER, handle_attr is NULL", + myname); - return globus_error_put(err); + return globus_error_put(err); } } @@ -463,19 +463,19 @@ globus_gass_copy_handleattr_destroy( if(handle_attr != GLOBUS_NULL) { - handle_attr->ftp_attr = GLOBUS_NULL; + handle_attr->ftp_attr = GLOBUS_NULL; return GLOBUS_SUCCESS; } else { - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: BAD_PARAMETER, handle_attr is NULL", - myname); + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: BAD_PARAMETER, handle_attr is NULL", + myname); - return globus_error_put(err); + return globus_error_put(err); } } @@ -489,19 +489,19 @@ globus_gass_copy_handleattr_set_ftp_attr( if(handle_attr != GLOBUS_NULL) { - handle_attr->ftp_attr = ftp_attr; + handle_attr->ftp_attr = ftp_attr; return GLOBUS_SUCCESS; } else { - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: BAD_PARAMETER, handle_attr is NULL", - myname); + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: BAD_PARAMETER, handle_attr is NULL", + myname); - return globus_error_put(err); + return globus_error_put(err); } } @@ -532,18 +532,18 @@ globus_gass_copy_set_buffer_length( static char * myname="globus_gass_copy_set_buffer_length"; if (handle) { - handle->buffer_length = length; - return GLOBUS_SUCCESS; + handle->buffer_length = length; + return GLOBUS_SUCCESS; } else { - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: BAD_PARAMETER, handle is NULL", - myname); + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: BAD_PARAMETER, handle is NULL", + myname); - return globus_error_put(err); + return globus_error_put(err); } } /* globus_gass_copy_set_buffer_length() */ @@ -572,18 +572,18 @@ globus_gass_copy_get_buffer_length( static char * myname="globus_gass_copy_get_buffer_length"; if (handle) { - *length = handle->buffer_length; - return GLOBUS_SUCCESS; + *length = handle->buffer_length; + return GLOBUS_SUCCESS; } else { - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: BAD_PARAMETER, handle is NULL", - myname); + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: BAD_PARAMETER, handle is NULL", + myname); - return globus_error_put(err); + return globus_error_put(err); } } /* globus_gass_copy_get_buffer_length() */ @@ -620,29 +620,29 @@ globus_gass_copy_set_no_third_party_transfers( if(current_status == GLOBUS_GASS_COPY_STATUS_PENDING) { - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: Cannot change the value of no_third_party_transfers," + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: Cannot change the value of no_third_party_transfers," "\tthere is a transfer currently pending on this handle", - myname); - return globus_error_put(err); + myname); + return globus_error_put(err); } else { - handle->no_third_party_transfers = no_third_party_transfers; - return GLOBUS_SUCCESS; + handle->no_third_party_transfers = no_third_party_transfers; + return GLOBUS_SUCCESS; } } else { - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: BAD_PARAMETER, handle is NULL", - myname); + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: BAD_PARAMETER, handle is NULL", + myname); - return globus_error_put(err); + return globus_error_put(err); } } /* globus_gass_copy_set_no_third_party_transfers() */ @@ -674,18 +674,18 @@ globus_gass_copy_get_no_third_party_transfers( static char * myname="globus_gass_copy_get_no_third_party_transfers"; if (handle) { - *no_third_party_transfers = handle->no_third_party_transfers; - return GLOBUS_SUCCESS; + *no_third_party_transfers = handle->no_third_party_transfers; + return GLOBUS_SUCCESS; } else { - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: BAD_PARAMETER, handle is NULL", - myname); + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: BAD_PARAMETER, handle is NULL", + myname); - return globus_error_put(err); + return globus_error_put(err); } } /* globus_gass_copy_get_no_third_party_transfers() */ @@ -700,7 +700,7 @@ globus_gass_copy_set_allocate( globus_bool_t send_allo) { handle->send_allo = send_allo; - + return GLOBUS_SUCCESS; } @@ -714,20 +714,20 @@ globus_gass_copy_set_stat_on_expand( globus_bool_t always_stat) { handle->always_stat_on_expand = always_stat; - + return GLOBUS_SUCCESS; } /** - * @brief Stores the checksum algorithm to use with all + * @brief Stores the checksum algorithm to use with all * checksum operations. * @ingroup globus_gass_copy * @details - * This function sets the checksum algorithm and the handle + * This function sets the checksum algorithm and the handle * to be used for checksum calculations to the passed in handle. - * + * * @param handle - * This is the handle to which the checksum algorithm and + * This is the handle to which the checksum algorithm and * handle are set. * @param algo * This is the algorithm to set in the handle. @@ -737,7 +737,7 @@ globus_gass_copy_set_stat_on_expand( * @return * This function always returns GLOBUS_SUCCESS */ -globus_result_t +globus_result_t globus_gass_copy_set_checksum_algo( globus_gass_copy_handle_t * handle, char * algo, @@ -757,19 +757,19 @@ globus_gass_copy_set_checksum_algo( * @brief Copies the checksum to the handle's checksum parameter. * @ingroup globus_gass_copy * @details - * This function frees any existing checksum value stored in the + * This function frees any existing checksum value stored in the * handle, then copies the passed in checksum to the handle. - * + * * @param handle - * The handle to the object to which the checksum shall be set. + * The handle to the object to which the checksum shall be set. * @param cksm * The checksum string to be set to the handle. * @return * This function always returns GLOBUS_SUCCESS */ -globus_result_t +globus_result_t globus_gass_copy_set_checksum( - globus_gass_copy_handle_t * handle, + globus_gass_copy_handle_t * handle, char * cksm) { if(handle->state->checksum != GLOBUS_NULL) @@ -811,20 +811,20 @@ globus_gass_copy_set_partial_offsets( static char * myname="globus_gass_copy_set_partial_offsets"; if (handle) { - handle->partial_offset = offset; - handle->partial_end_offset = end_offset; - - return GLOBUS_SUCCESS; + handle->partial_offset = offset; + handle->partial_end_offset = end_offset; + + return GLOBUS_SUCCESS; } else { - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: BAD_PARAMETER, handle is NULL", - myname); + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: BAD_PARAMETER, handle is NULL", + myname); - return globus_error_put(err); + return globus_error_put(err); } } /* globus_gass_copy_set_partial_offsets() */ @@ -857,19 +857,19 @@ globus_gass_copy_get_partial_offsets( static char * myname="globus_gass_copy_get_partial_offsets"; if (handle) { - *offset = handle->partial_offset; - *end_offset = handle->partial_end_offset; - return GLOBUS_SUCCESS; + *offset = handle->partial_offset; + *end_offset = handle->partial_end_offset; + return GLOBUS_SUCCESS; } else { - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: BAD_PARAMETER, handle is NULL", - myname); + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: BAD_PARAMETER, handle is NULL", + myname); - return globus_error_put(err); + return globus_error_put(err); } } /* globus_gass_copy_get_partial_offsets() */ @@ -932,19 +932,19 @@ globus_gass_copy_attr_init( static char * myname="globus_gass_copy_attr_init"; if(attr!=GLOBUS_NULL) { - attr->ftp_attr = GLOBUS_NULL; - attr->io = GLOBUS_NULL; - attr->gass_requestattr = GLOBUS_NULL; - return GLOBUS_SUCCESS; + attr->ftp_attr = GLOBUS_NULL; + attr->io = GLOBUS_NULL; + attr->gass_requestattr = GLOBUS_NULL; + return GLOBUS_SUCCESS; } else { - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: BAD_PARAMETER, attr is NULL", - myname); - return globus_error_put(err); + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: BAD_PARAMETER, attr is NULL", + myname); + return globus_error_put(err); } } @@ -983,17 +983,17 @@ globus_gass_copy_attr_set_ftp( if(attr != GLOBUS_NULL) { - attr->ftp_attr = ftp_attr; - return GLOBUS_SUCCESS; + attr->ftp_attr = ftp_attr; + return GLOBUS_SUCCESS; } else { - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: BAD_PARAMETER, attr is NULL", - myname); - return globus_error_put(err); + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: BAD_PARAMETER, attr is NULL", + myname); + return globus_error_put(err); } } /* globus_gass_copy_attr_set_ftp() */ @@ -1031,17 +1031,17 @@ globus_gass_copy_attr_set_io( static char * myname="globus_gass_copy_attr_set_io"; if(attr != GLOBUS_NULL) { - attr->io = io_attr; - return GLOBUS_SUCCESS; + attr->io = io_attr; + return GLOBUS_SUCCESS; } else { - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: BAD_PARAMETER, attr is NULL", - myname); - return globus_error_put(err); + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: BAD_PARAMETER, attr is NULL", + myname); + return globus_error_put(err); } } /* globus_gass_copy_attr_set_io() */ @@ -1080,24 +1080,24 @@ globus_gass_copy_attr_set_gass( static char * myname="globus_gass_copy_attr_set_gass"; if(attr != GLOBUS_NULL) { - attr->gass_requestattr = gass_attr; - return GLOBUS_SUCCESS; + attr->gass_requestattr = gass_attr; + return GLOBUS_SUCCESS; } else { - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: BAD_PARAMETER, attr is NULL", - myname); - return globus_error_put(err); + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: BAD_PARAMETER, attr is NULL", + myname); + return globus_error_put(err); } } /** - * @brief Get URL scheme + * @brief Get URL scheme * @ingroup globus_gass_copy * @details * This function enables the user to determine what protocol will be used to @@ -1131,37 +1131,37 @@ globus_gass_copy_get_url_mode( if ((rc = globus_url_parse(url, &url_info)) != GLOBUS_SUCCESS) { #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, "copy_url_mode(): globus_url_parse returned !GLOBUS_SUCCESS for url: %s\n", url); + globus_libc_fprintf(stderr, "copy_url_mode(): globus_url_parse returned !GLOBUS_SUCCESS for url: %s\n", url); #endif - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: globus_url_parse returned error code: %d for url: %s", - myname, - rc, - url); + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: globus_url_parse returned error code: %d for url: %s", + myname, + rc, + url); - return globus_error_put(err); + return globus_error_put(err); } if ( (url_info.scheme_type == GLOBUS_URL_SCHEME_FTP) || - (url_info.scheme_type == GLOBUS_URL_SCHEME_SSHFTP) || - (url_info.scheme_type == GLOBUS_URL_SCHEME_GSIFTP) ) + (url_info.scheme_type == GLOBUS_URL_SCHEME_SSHFTP) || + (url_info.scheme_type == GLOBUS_URL_SCHEME_GSIFTP) ) { - *mode = GLOBUS_GASS_COPY_URL_MODE_FTP; + *mode = GLOBUS_GASS_COPY_URL_MODE_FTP; } else if ( (url_info.scheme_type == GLOBUS_URL_SCHEME_HTTP) || (url_info.scheme_type == GLOBUS_URL_SCHEME_HTTPS) ) { - *mode = GLOBUS_GASS_COPY_URL_MODE_GASS; + *mode = GLOBUS_GASS_COPY_URL_MODE_GASS; } else if ( url_info.scheme_type == GLOBUS_URL_SCHEME_FILE) { - *mode = GLOBUS_GASS_COPY_URL_MODE_IO; + *mode = GLOBUS_GASS_COPY_URL_MODE_IO; } else { - *mode = GLOBUS_GASS_COPY_URL_MODE_UNSUPPORTED; + *mode = GLOBUS_GASS_COPY_URL_MODE_UNSUPPORTED; } globus_url_destroy(&url_info); @@ -1207,23 +1207,23 @@ globus_gass_copy_register_performance_cb( if(handle == GLOBUS_NULL) { - return globus_error_put( - globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: BAD_PARAMETER, handle is NULL", - myname)); + return globus_error_put( + globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: BAD_PARAMETER, handle is NULL", + myname)); } if(handle->status > GLOBUS_GASS_COPY_STATUS_NONE && handle->status < GLOBUS_GASS_COPY_STATUS_DONE_SUCCESS) { return globus_error_put( - globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: There is a transfer active on this handle", - myname)); + globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: There is a transfer active on this handle", + myname)); } if(callback == GLOBUS_NULL) @@ -1248,11 +1248,11 @@ globus_gass_copy_register_performance_cb( if(handle->performance == GLOBUS_NULL) { return globus_error_put( - globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: Memory allocation error", - myname)); + globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: Memory allocation error", + myname)); } handle->performance->copy_handle = handle; @@ -1303,7 +1303,7 @@ globus_l_gass_copy_perf_local_cb( long usecs; globus_gass_copy_handle_t * handle; globus_gass_copy_performance_cb_t callback; - + perf_info = (globus_gass_copy_perf_info_t *) user_arg; globus_mutex_lock(&perf_info->lock); @@ -1311,37 +1311,37 @@ globus_l_gass_copy_perf_local_cb( GlobusTimeAbstimeGetCurrent(timebuf); GlobusTimeAbstimeGet(timebuf, secs, usecs); time_now = secs + (usecs / 1000000.0); - + bytes_now = perf_info->live_bytes; - + time_elapsed = time_now - perf_info->prev_time; if(time_elapsed < 0.1) { /* shouldnt be possible (callback delay is 2 secs) */ time_elapsed = 0.1; } - + instantaneous_throughput = (bytes_now - perf_info->prev_bytes) / time_elapsed; - + time_elapsed = time_now - perf_info->start_time; if(time_elapsed < 0.1) { /* shouldnt be possible (callback delay is 2 secs) */ time_elapsed = 0.1; } - + avg_throughput = bytes_now / time_elapsed; - + perf_info->prev_time = time_now; perf_info->prev_bytes = bytes_now; - + handle = perf_info->copy_handle; user_arg = perf_info->user_arg; - + callback = perf_info->callback; } globus_mutex_unlock(&perf_info->lock); @@ -1385,11 +1385,11 @@ globus_l_gass_copy_perf_setup_local_callback( globus_abstime_t timebuf; long secs; long usecs; - + GlobusTimeAbstimeGetCurrent(timebuf); GlobusTimeAbstimeGet(timebuf, secs, usecs); perf_info->start_time = secs + (usecs / 1000000.0); - + perf_info->prev_time = perf_info->start_time; perf_info->prev_bytes = 0; perf_info->live_bytes = 0; @@ -1513,7 +1513,7 @@ globus_l_gass_copy_ftp_read_callback( globus_byte_t * bytes, globus_size_t nbytes, globus_off_t offset, - globus_bool_t eof); + globus_bool_t eof); globus_result_t globus_l_gass_copy_io_setup_get( @@ -1535,13 +1535,13 @@ void globus_l_gass_copy_ftp_get_done_callback( void * callback_arg, globus_ftp_client_handle_t * handle, - globus_object_t * error); + globus_object_t * error); void globus_l_gass_copy_ftp_put_done_callback( void * callback_arg, globus_ftp_client_handle_t * handle, - globus_object_t * error); + globus_object_t * error); void globus_l_gass_copy_io_cancel_callback( @@ -1587,7 +1587,7 @@ globus_l_gass_copy_ftp_write_callback( globus_byte_t * bytes, globus_size_t nbytes, globus_off_t offset, - globus_bool_t eof); + globus_bool_t eof); globus_result_t globus_i_gass_copy_attr_duplicate(globus_gass_copy_attr_t ** attr); @@ -1661,50 +1661,50 @@ globus_gass_copy_get_status( static char * myname="globus_gass_copy_get_status"; if(handle != GLOBUS_NULL) { - switch(handle->status) - { - case GLOBUS_GASS_COPY_STATUS_NONE: - *status = GLOBUS_GASS_COPY_STATUS_NONE; - break; - case GLOBUS_GASS_COPY_STATUS_INITIAL: - case GLOBUS_GASS_COPY_STATUS_SOURCE_READY: - *status = GLOBUS_GASS_COPY_STATUS_PENDING; - break; - case GLOBUS_GASS_COPY_STATUS_TRANSFER_IN_PROGRESS: - case GLOBUS_GASS_COPY_STATUS_READ_COMPLETE: - case GLOBUS_GASS_COPY_STATUS_WRITE_COMPLETE: - case GLOBUS_GASS_COPY_STATUS_DONE: - *status = GLOBUS_GASS_COPY_STATUS_TRANSFER_IN_PROGRESS; - break; - case GLOBUS_GASS_COPY_STATUS_FAILURE: - *status = GLOBUS_GASS_COPY_STATUS_FAILURE; - break; - case GLOBUS_GASS_COPY_STATUS_CANCEL: - *status = GLOBUS_GASS_COPY_STATUS_CANCEL; - break; - case GLOBUS_GASS_COPY_STATUS_DONE_SUCCESS: - *status = GLOBUS_GASS_COPY_STATUS_DONE_SUCCESS; - break; - case GLOBUS_GASS_COPY_STATUS_DONE_FAILURE: - *status = GLOBUS_GASS_COPY_STATUS_DONE_FAILURE; - break; - case GLOBUS_GASS_COPY_STATUS_DONE_CANCELLED: - *status = GLOBUS_GASS_COPY_STATUS_DONE_CANCELLED; - break; - default: - break; - } - return GLOBUS_SUCCESS; + switch(handle->status) + { + case GLOBUS_GASS_COPY_STATUS_NONE: + *status = GLOBUS_GASS_COPY_STATUS_NONE; + break; + case GLOBUS_GASS_COPY_STATUS_INITIAL: + case GLOBUS_GASS_COPY_STATUS_SOURCE_READY: + *status = GLOBUS_GASS_COPY_STATUS_PENDING; + break; + case GLOBUS_GASS_COPY_STATUS_TRANSFER_IN_PROGRESS: + case GLOBUS_GASS_COPY_STATUS_READ_COMPLETE: + case GLOBUS_GASS_COPY_STATUS_WRITE_COMPLETE: + case GLOBUS_GASS_COPY_STATUS_DONE: + *status = GLOBUS_GASS_COPY_STATUS_TRANSFER_IN_PROGRESS; + break; + case GLOBUS_GASS_COPY_STATUS_FAILURE: + *status = GLOBUS_GASS_COPY_STATUS_FAILURE; + break; + case GLOBUS_GASS_COPY_STATUS_CANCEL: + *status = GLOBUS_GASS_COPY_STATUS_CANCEL; + break; + case GLOBUS_GASS_COPY_STATUS_DONE_SUCCESS: + *status = GLOBUS_GASS_COPY_STATUS_DONE_SUCCESS; + break; + case GLOBUS_GASS_COPY_STATUS_DONE_FAILURE: + *status = GLOBUS_GASS_COPY_STATUS_DONE_FAILURE; + break; + case GLOBUS_GASS_COPY_STATUS_DONE_CANCELLED: + *status = GLOBUS_GASS_COPY_STATUS_DONE_CANCELLED; + break; + default: + break; + } + return GLOBUS_SUCCESS; } else { - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: BAD_PARAMETER, handle is NULL", - myname); + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: BAD_PARAMETER, handle is NULL", + myname); - return globus_error_put(err); + return globus_error_put(err); } } /* globus_gass_copy_get_status() */ @@ -1765,7 +1765,7 @@ static char * } else { - return "[globus_gass_copy_get_status_string]: BAD_PARAMETER, handle is NULL"; + return "[globus_gass_copy_get_status_string]: BAD_PARAMETER, handle is NULL"; } } @@ -1781,7 +1781,7 @@ globus_i_gass_copy_ftp_client_op_done_callback( globus_i_gass_copy_monitor_t * monitor; monitor = (globus_i_gass_copy_monitor_t *) user_arg; - + globus_mutex_lock(&monitor->mutex); if (err && !monitor->err) { @@ -1790,7 +1790,7 @@ globus_i_gass_copy_ftp_client_op_done_callback( monitor->done = GLOBUS_TRUE; globus_cond_signal(&monitor->cond); globus_mutex_unlock(&monitor->mutex); - + return; } @@ -1803,19 +1803,19 @@ globus_l_gass_copy_size_ftp( { globus_i_gass_copy_monitor_t monitor; globus_result_t result; - + memset(&monitor, 0, sizeof(globus_i_gass_copy_monitor_t)); globus_cond_init(&monitor.cond, GLOBUS_NULL); globus_mutex_init(&monitor.mutex, GLOBUS_NULL); - + result = globus_ftp_client_size( &handle->ftp_handle, url, attr->ftp_attr, out_size, globus_i_gass_copy_ftp_client_op_done_callback, - &monitor); + &monitor); if(result != GLOBUS_SUCCESS) { goto error; @@ -1833,7 +1833,7 @@ globus_l_gass_copy_size_ftp( result = globus_error_put(monitor.err); monitor.err = GLOBUS_NULL; } - + if(result != GLOBUS_SUCCESS) { goto error; @@ -1862,7 +1862,7 @@ globus_l_gass_copy_size_file( globus_url_t parsed_url; globus_result_t result; struct stat stat_buf; - + rc = globus_url_parse(url, &parsed_url); if(rc != 0) { @@ -1876,7 +1876,7 @@ globus_l_gass_copy_size_file( rc)); goto error_url; } - + if(parsed_url.url_path == GLOBUS_NULL) { result = globus_error_put( @@ -1888,7 +1888,7 @@ globus_l_gass_copy_size_file( myname)); goto error_null_path; } - + rc = stat(parsed_url.url_path, &stat_buf); if(rc != 0) { @@ -1902,20 +1902,20 @@ globus_l_gass_copy_size_file( rc)); goto error_stat; } - + *out_size = stat_buf.st_size; - - globus_url_destroy(&parsed_url); + + globus_url_destroy(&parsed_url); return GLOBUS_SUCCESS; -error_stat: +error_stat: error_null_path: globus_url_destroy(&parsed_url); - + error_url: return result; - + } @@ -1929,13 +1929,13 @@ globus_i_gass_copy_size( static char * myname="globus_i_gass_copy_size"; globus_result_t result; globus_gass_copy_url_mode_t url_mode; - + result = globus_gass_copy_get_url_mode(url, &url_mode); if(result != GLOBUS_SUCCESS) { goto error_exit; } - + if(url_mode == GLOBUS_GASS_COPY_URL_MODE_FTP) { result = globus_l_gass_copy_size_ftp(handle, url, attr, out_size); @@ -1964,9 +1964,9 @@ globus_i_gass_copy_size( url)); goto error_exit; } - + return GLOBUS_SUCCESS; - + error_exit: return result; } @@ -1995,91 +1995,91 @@ globus_l_gass_copy_target_populate( if(attr == GLOBUS_NULL) { - target->free_attr = GLOBUS_TRUE; - tmp_attr = (globus_gass_copy_attr_t *) + target->free_attr = GLOBUS_TRUE; + tmp_attr = (globus_gass_copy_attr_t *) globus_libc_malloc(sizeof(globus_gass_copy_attr_t)); - if(tmp_attr == GLOBUS_NULL) - { - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: failed malloc a globus_gass_copy_attr_t structure successfully", - myname); - return globus_error_put(err); - } + if(tmp_attr == GLOBUS_NULL) + { + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: failed malloc a globus_gass_copy_attr_t structure successfully", + myname); + return globus_error_put(err); + } - globus_gass_copy_attr_init(tmp_attr); + globus_gass_copy_attr_init(tmp_attr); - attr = tmp_attr; + attr = tmp_attr; } else - target->free_attr = GLOBUS_FALSE; + target->free_attr = GLOBUS_FALSE; target->mode = *url_mode; switch (target->mode) { case GLOBUS_GASS_COPY_URL_MODE_FTP: - /* will be set to false once I start an operation that will get a - completion callback */ - target->data.ftp.completed = GLOBUS_TRUE; - target->url = globus_libc_strdup(url); - target->attr = attr; - /* FIXX n_simultaneous should be pulled from attributes, or something */ - if(attr->ftp_attr) - { - globus_ftp_control_parallelism_t tmp_parallelism; - globus_ftp_client_operationattr_get_parallelism(attr->ftp_attr, &tmp_parallelism); - if(tmp_parallelism.mode == GLOBUS_FTP_CONTROL_PARALLELISM_FIXED) - { -#ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, "tmp_parallelism.mode== GLOBUS_FTP_CONTROL_PARALLELISM_FIXED, tmp_parallelism.fixed.size = %d\n", tmp_parallelism.fixed.size); -#endif - target->n_simultaneous = tmp_parallelism.fixed.size; - /*target->n_simultaneous = 1;*/ - } - else - target->n_simultaneous = 1; - } - else - { - target->n_simultaneous = 1; - /*globus_libc_fprintf(stderr, "**** target->n_simultaneous: %d\n",target->n_simultaneous); */ - } - break; + /* will be set to false once I start an operation that will get a + completion callback */ + target->data.ftp.completed = GLOBUS_TRUE; + target->url = globus_libc_strdup(url); + target->attr = attr; + /* FIXX n_simultaneous should be pulled from attributes, or something */ + if(attr->ftp_attr) + { + globus_ftp_control_parallelism_t tmp_parallelism; + globus_ftp_client_operationattr_get_parallelism(attr->ftp_attr, &tmp_parallelism); + if(tmp_parallelism.mode == GLOBUS_FTP_CONTROL_PARALLELISM_FIXED) + { +#ifdef GLOBUS_I_GASS_COPY_DEBUG + globus_libc_fprintf(stderr, "tmp_parallelism.mode== GLOBUS_FTP_CONTROL_PARALLELISM_FIXED, tmp_parallelism.fixed.size = %d\n", tmp_parallelism.fixed.size); +#endif + target->n_simultaneous = tmp_parallelism.fixed.size; + /*target->n_simultaneous = 1;*/ + } + else + target->n_simultaneous = 1; + } + else + { + target->n_simultaneous = 1; + /*globus_libc_fprintf(stderr, "**** target->n_simultaneous: %d\n",target->n_simultaneous); */ + } + break; case GLOBUS_GASS_COPY_URL_MODE_GASS: - /*target->mode = GLOBUS_I_GASS_COPY_TARGET_MODE_GASS; */ - target->url = globus_libc_strdup(url); - target->attr = attr; - target->n_simultaneous = 1; - break; + /*target->mode = GLOBUS_I_GASS_COPY_TARGET_MODE_GASS; */ + target->url = globus_libc_strdup(url); + target->attr = attr; + target->n_simultaneous = 1; + break; case GLOBUS_GASS_COPY_URL_MODE_IO: - /*target->mode = GLOBUS_I_GASS_COPY_TARGET_MODE_IO;*/ - target->url = globus_libc_strdup(url); - target->attr = attr; - target->data.io.free_handle = GLOBUS_TRUE; - target->data.io.seekable = GLOBUS_TRUE; - target->data.io.handle = GLOBUS_NULL; - target->n_simultaneous = 1; + /*target->mode = GLOBUS_I_GASS_COPY_TARGET_MODE_IO;*/ + target->url = globus_libc_strdup(url); + target->attr = attr; + target->data.io.free_handle = GLOBUS_TRUE; + target->data.io.seekable = GLOBUS_TRUE; + target->data.io.handle = GLOBUS_NULL; + target->n_simultaneous = 1; - break; + break; case GLOBUS_GASS_COPY_URL_MODE_UNSUPPORTED: - /* something went horribly wrong */ - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: %s: GLOBUS_GASS_COPY_URL_MODE_UNSUPPORTED", - myname, - url); - return globus_error_put(err); - - break; + /* something went horribly wrong */ + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: %s: GLOBUS_GASS_COPY_URL_MODE_UNSUPPORTED", + myname, + url); + return globus_error_put(err); + + break; default: break; } @@ -2088,12 +2088,12 @@ globus_l_gass_copy_target_populate( */ if (globus_fifo_init(&(target->queue)) != GLOBUS_SUCCESS) { - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: failed to initialize fifo successfully", - myname); - return globus_error_put(err); + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: failed to initialize fifo successfully", + myname); + return globus_error_put(err); } return GLOBUS_SUCCESS; @@ -2124,30 +2124,30 @@ globus_l_gass_copy_io_target_populate( if(globus_io_get_handle_type(io_handle) == GLOBUS_IO_HANDLE_TYPE_FILE) { /* test file handle for seekable as it may be a pipe */ - if(globus_io_file_seek(io_handle, 0, GLOBUS_IO_SEEK_CUR) + if(globus_io_file_seek(io_handle, 0, GLOBUS_IO_SEEK_CUR) == GLOBUS_SUCCESS) { - target->data.io.seekable = GLOBUS_TRUE; - } - else - { - target->data.io.seekable = GLOBUS_FALSE; - } + target->data.io.seekable = GLOBUS_TRUE; + } + else + { + target->data.io.seekable = GLOBUS_FALSE; + } } else - target->data.io.seekable = GLOBUS_FALSE; + target->data.io.seekable = GLOBUS_FALSE; target->n_simultaneous = 1; /* setup the queue */ if (globus_fifo_init(&(target->queue)) != GLOBUS_SUCCESS) { - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: failed to initialize fifo successfully", - myname); - return globus_error_put(err); + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: failed to initialize fifo successfully", + myname); + return globus_error_put(err); } return GLOBUS_SUCCESS; @@ -2166,9 +2166,9 @@ globus_l_gass_copy_target_destroy( /* empty and free the queue */ while(!globus_fifo_empty(&(target->queue))) { - buffer_entry = globus_fifo_dequeue(&(target->queue)); - globus_libc_free(buffer_entry->bytes); - globus_libc_free(buffer_entry); + buffer_entry = globus_fifo_dequeue(&(target->queue)); + globus_libc_free(buffer_entry->bytes); + globus_libc_free(buffer_entry); } globus_fifo_destroy(&(target->queue)); /* clean up the mutex */ @@ -2177,44 +2177,44 @@ globus_l_gass_copy_target_destroy( if(target->free_attr == GLOBUS_TRUE) { #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, "target_destroy(): freeing the target attr\n"); + globus_libc_fprintf(stderr, "target_destroy(): freeing the target attr\n"); #endif - if(target->mode == GLOBUS_GASS_COPY_URL_MODE_FTP && - target->free_ftp_attr == GLOBUS_TRUE) - globus_libc_free(target->attr->ftp_attr); - globus_libc_free(target->attr); + if(target->mode == GLOBUS_GASS_COPY_URL_MODE_FTP && + target->free_ftp_attr == GLOBUS_TRUE) + globus_libc_free(target->attr->ftp_attr); + globus_libc_free(target->attr); } switch(target->mode) { case GLOBUS_GASS_COPY_URL_MODE_FTP: - /* once parallel reads/writes are possible, will have to potentially + /* once parallel reads/writes are possible, will have to potentially * free the attr, if parallelism is turned off by the library */ - globus_libc_free((target->url)); - break; + globus_libc_free((target->url)); + break; case GLOBUS_GASS_COPY_URL_MODE_GASS: - globus_libc_free((target->url)); - break; + globus_libc_free((target->url)); + break; case GLOBUS_GASS_COPY_URL_MODE_IO: - if(target->data.io.free_handle == GLOBUS_TRUE) - { - if(target->data.io.handle) - { - globus_libc_free((target->data.io.handle)); - } - globus_libc_free((target->url)); - - } - break; + if(target->data.io.free_handle == GLOBUS_TRUE) + { + if(target->data.io.handle) + { + globus_libc_free((target->data.io.handle)); + } + globus_libc_free((target->url)); + + } + break; default: break; } memset(target, 0, sizeof(globus_i_gass_copy_target_t)); - + return GLOBUS_SUCCESS; } /* gloubs_l_gass_copy_target_destroy() */ @@ -2315,7 +2315,7 @@ globus_l_gass_copy_state_free_targets( /* clean up the destination target */ globus_l_gass_copy_target_destroy(&(state->dest)); - + return GLOBUS_SUCCESS; } /* globus_l_gass_copy_state_free_targets() */ @@ -2356,69 +2356,69 @@ globus_l_gass_copy_transfer_start( #endif if ( (state->source.mode - == GLOBUS_GASS_COPY_URL_MODE_FTP) - && ( ( (state->dest.mode - == GLOBUS_GASS_COPY_URL_MODE_GASS) ) - || ( (state->dest.mode - == GLOBUS_GASS_COPY_URL_MODE_IO) - && (!state->dest.data.io.seekable) ) ) ) - { - /* - * If the source stream is ftp, this means it is capable - * of supporting multiple data channels and handing back - * data block in an arbitrary order. - * - * If the destination stream can only handle sequential - * writes of the data, then disable the multiple data - * channel support in ftp - */ - if(state->source.attr->ftp_attr != GLOBUS_NULL) - { - globus_ftp_control_parallelism_t tmp_parallelism; - - globus_ftp_client_operationattr_get_parallelism(state->source.attr->ftp_attr, &tmp_parallelism); - - if(tmp_parallelism.mode != GLOBUS_FTP_CONTROL_PARALLELISM_NONE) - { - globus_gass_copy_attr_t * new_attr; - globus_ftp_client_operationattr_t * new_ftp_attr; - - new_attr = (globus_gass_copy_attr_t *) - globus_libc_malloc(sizeof(globus_gass_copy_attr_t)); - globus_gass_copy_attr_init(new_attr); - - new_ftp_attr = (globus_ftp_client_operationattr_t *) - globus_libc_malloc(sizeof(globus_ftp_client_operationattr_t)); - - globus_ftp_client_operationattr_copy(new_ftp_attr, (state->source.attr->ftp_attr)); - tmp_parallelism.mode = GLOBUS_FTP_CONTROL_PARALLELISM_NONE; - globus_ftp_client_operationattr_set_parallelism(new_ftp_attr, &tmp_parallelism); - - globus_gass_copy_attr_set_ftp(new_attr, new_ftp_attr); - - state->source.attr = new_attr; - - state->source.free_attr = GLOBUS_TRUE; - state->source.free_ftp_attr = GLOBUS_TRUE; - } /* if(tmp_parallelism.mode != GLOBUS_FTP_CONTROL_PARALLELISM_NONE) */ - } /* if(state->source.attr->ftp_attr != GLOBUS_NULL) */ - /* - state->source.attr.parallelism_info.mode = - GLOBUS_GSIFTP_CONTROL_PARALLELISM_NONE; - state->source.attr.striping_info.mode = - GLOBUS_GSIFTP_CONTROL_STRIPING_NONE; - */ - /* - * ftp -> gass_transfer: - * turn off both parallel & striping - * ftp -> io: - * globus_io_file_seek() can be used to deal with out of - * order blocks - * gass_transfer, io -> * - * The source data is serialized anyway, so do don't need - * to worry about the destination. An ftp destination can - * use parallelism and/or striping if desired - */ + == GLOBUS_GASS_COPY_URL_MODE_FTP) + && ( ( (state->dest.mode + == GLOBUS_GASS_COPY_URL_MODE_GASS) ) + || ( (state->dest.mode + == GLOBUS_GASS_COPY_URL_MODE_IO) + && (!state->dest.data.io.seekable) ) ) ) + { + /* + * If the source stream is ftp, this means it is capable + * of supporting multiple data channels and handing back + * data block in an arbitrary order. + * + * If the destination stream can only handle sequential + * writes of the data, then disable the multiple data + * channel support in ftp + */ + if(state->source.attr->ftp_attr != GLOBUS_NULL) + { + globus_ftp_control_parallelism_t tmp_parallelism; + + globus_ftp_client_operationattr_get_parallelism(state->source.attr->ftp_attr, &tmp_parallelism); + + if(tmp_parallelism.mode != GLOBUS_FTP_CONTROL_PARALLELISM_NONE) + { + globus_gass_copy_attr_t * new_attr; + globus_ftp_client_operationattr_t * new_ftp_attr; + + new_attr = (globus_gass_copy_attr_t *) + globus_libc_malloc(sizeof(globus_gass_copy_attr_t)); + globus_gass_copy_attr_init(new_attr); + + new_ftp_attr = (globus_ftp_client_operationattr_t *) + globus_libc_malloc(sizeof(globus_ftp_client_operationattr_t)); + + globus_ftp_client_operationattr_copy(new_ftp_attr, (state->source.attr->ftp_attr)); + tmp_parallelism.mode = GLOBUS_FTP_CONTROL_PARALLELISM_NONE; + globus_ftp_client_operationattr_set_parallelism(new_ftp_attr, &tmp_parallelism); + + globus_gass_copy_attr_set_ftp(new_attr, new_ftp_attr); + + state->source.attr = new_attr; + + state->source.free_attr = GLOBUS_TRUE; + state->source.free_ftp_attr = GLOBUS_TRUE; + } /* if(tmp_parallelism.mode != GLOBUS_FTP_CONTROL_PARALLELISM_NONE) */ + } /* if(state->source.attr->ftp_attr != GLOBUS_NULL) */ + /* + state->source.attr.parallelism_info.mode = + GLOBUS_GSIFTP_CONTROL_PARALLELISM_NONE; + state->source.attr.striping_info.mode = + GLOBUS_GSIFTP_CONTROL_STRIPING_NONE; + */ + /* + * ftp -> gass_transfer: + * turn off both parallel & striping + * ftp -> io: + * globus_io_file_seek() can be used to deal with out of + * order blocks + * gass_transfer, io -> * + * The source data is serialized anyway, so do don't need + * to worry about the destination. An ftp destination can + * use parallelism and/or striping if desired + */ } /* source.mode == GLOBUS_GASS_COPY_URL_MODE_FTP, and dest is not seekable */ /* depending on the mode, call the appropriate routine to start the @@ -2428,12 +2428,12 @@ globus_l_gass_copy_transfer_start( { case GLOBUS_GASS_COPY_URL_MODE_FTP: - state->source.data.ftp.n_channels = 0; - state->source.data.ftp.n_reads_posted = 0; - - if(state->dest.mode == GLOBUS_GASS_COPY_URL_MODE_FTP) - { - /* doing a third party transfer, dest side is using main handle */ + state->source.data.ftp.n_channels = 0; + state->source.data.ftp.n_reads_posted = 0; + + if(state->dest.mode == GLOBUS_GASS_COPY_URL_MODE_FTP) + { + /* doing a third party transfer, dest side is using main handle */ state->source.data.ftp.handle = &handle->ftp_handle_2; } else @@ -2443,53 +2443,53 @@ globus_l_gass_copy_transfer_start( result = globus_l_gass_copy_ftp_setup_get(handle); - break; + break; case GLOBUS_GASS_COPY_URL_MODE_GASS: #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, "transfer_start(): about to call globus_gass_transfer_register_get()\n"); + globus_libc_fprintf(stderr, "transfer_start(): about to call globus_gass_transfer_register_get()\n"); #endif - rc = globus_gass_transfer_register_get( - &(state->source.data.gass.request), - (state->source.attr->gass_requestattr), - state->source.url, - globus_l_gass_copy_gass_setup_callback, - (void *) handle); + rc = globus_gass_transfer_register_get( + &(state->source.data.gass.request), + (state->source.attr->gass_requestattr), + state->source.url, + globus_l_gass_copy_gass_setup_callback, + (void *) handle); /* FIXX - what happens if this is a referral? */ - if (rc != GLOBUS_SUCCESS) - { + if (rc != GLOBUS_SUCCESS) + { #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, "transfer_start(): globus_gass_transfer_register_get returned !GLOBUS_SUCCESS\n"); + globus_libc_fprintf(stderr, "transfer_start(): globus_gass_transfer_register_get returned !GLOBUS_SUCCESS\n"); #endif - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: %s globus_gass_transfer_register_get returned an error code of: %d", - myname, - state->source.url, - rc); - globus_i_gass_copy_set_error(handle, err); + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: %s globus_gass_transfer_register_get returned an error code of: %d", + myname, + state->source.url, + rc); + globus_i_gass_copy_set_error(handle, err); - result = globus_error_put(err); - } - break; + result = globus_error_put(err); + } + break; case GLOBUS_GASS_COPY_URL_MODE_IO: - result = globus_l_gass_copy_io_setup_get(handle); + result = globus_l_gass_copy_io_setup_get(handle); - break; + break; default: break; } if(result != GLOBUS_SUCCESS) { - globus_i_gass_copy_set_error_from_result(handle, result); - handle->status = GLOBUS_GASS_COPY_STATUS_FAILURE; - return result; + globus_i_gass_copy_set_error_from_result(handle, result); + handle->status = GLOBUS_GASS_COPY_STATUS_FAILURE; + return result; } /* wait for ok from the source */ @@ -2500,40 +2500,40 @@ globus_l_gass_copy_transfer_start( while(state->source.status == GLOBUS_I_GASS_COPY_TARGET_INITIAL) { globus_cond_wait(&state->monitor.cond, - &state->monitor.mutex); + &state->monitor.mutex); } globus_mutex_unlock(&state->monitor.mutex); if(handle->err) { - handle->status = GLOBUS_GASS_COPY_STATUS_FAILURE; - err = handle->err; - handle->err = GLOBUS_NULL; + handle->status = GLOBUS_GASS_COPY_STATUS_FAILURE; + err = handle->err; + handle->err = GLOBUS_NULL; /* clean up the source side since it was already opened..... */ - globus_mutex_init(&monitor.mutex, GLOBUS_NULL); - globus_cond_init(&monitor.cond, GLOBUS_NULL); - monitor.done = GLOBUS_FALSE; - monitor.err = GLOBUS_NULL; - monitor.use_err = GLOBUS_FALSE; + globus_mutex_init(&monitor.mutex, GLOBUS_NULL); + globus_cond_init(&monitor.cond, GLOBUS_NULL); + monitor.done = GLOBUS_FALSE; + monitor.err = GLOBUS_NULL; + monitor.use_err = GLOBUS_FALSE; handle->user_callback = GLOBUS_NULL; globus_gass_copy_cancel( - handle, - globus_l_gass_copy_monitor_callback, - (void *) &monitor); - /* wait for the cancel to complete before returning to user */ - globus_mutex_lock(&monitor.mutex); - { - while(!monitor.done) - { - globus_cond_wait(&monitor.cond, &monitor.mutex); - } - } - globus_mutex_unlock(&monitor.mutex); - globus_mutex_destroy(&monitor.mutex); - globus_cond_destroy(&monitor.cond); - - return globus_error_put(err); + handle, + globus_l_gass_copy_monitor_callback, + (void *) &monitor); + /* wait for the cancel to complete before returning to user */ + globus_mutex_lock(&monitor.mutex); + { + while(!monitor.done) + { + globus_cond_wait(&monitor.cond, &monitor.mutex); + } + } + globus_mutex_unlock(&monitor.mutex); + globus_mutex_destroy(&monitor.mutex); + globus_cond_destroy(&monitor.cond); + + return globus_error_put(err); } handle->status = GLOBUS_GASS_COPY_STATUS_SOURCE_READY; @@ -2560,48 +2560,48 @@ globus_l_gass_copy_transfer_start( { case GLOBUS_GASS_COPY_URL_MODE_FTP: - state->dest.data.ftp.n_channels = 0; - state->dest.data.ftp.n_reads_posted = 0; + state->dest.data.ftp.n_channels = 0; + state->dest.data.ftp.n_reads_posted = 0; state->dest.data.ftp.handle = &handle->ftp_handle; - result = globus_l_gass_copy_ftp_setup_put(handle); - break; + result = globus_l_gass_copy_ftp_setup_put(handle); + break; case GLOBUS_GASS_COPY_URL_MODE_GASS: #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, "transfer_start(): about to call globus_gass_transfer_register_put()\n"); + globus_libc_fprintf(stderr, "transfer_start(): about to call globus_gass_transfer_register_put()\n"); #endif rc = globus_gass_transfer_register_put( - &(state->dest.data.gass.request), - (state->dest.attr->gass_requestattr), - state->dest.url, - 0, - globus_l_gass_copy_gass_setup_callback, - (void *) handle); - - if (rc != GLOBUS_SUCCESS) - { - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: %s globus_gass_transfer_register_put returned an error code of: %d", - myname, - state->dest.url, - rc); - globus_i_gass_copy_set_error(handle, err); - - result = globus_error_put(err); - } - - break; + &(state->dest.data.gass.request), + (state->dest.attr->gass_requestattr), + state->dest.url, + 0, + globus_l_gass_copy_gass_setup_callback, + (void *) handle); + + if (rc != GLOBUS_SUCCESS) + { + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: %s globus_gass_transfer_register_put returned an error code of: %d", + myname, + state->dest.url, + rc); + globus_i_gass_copy_set_error(handle, err); + + result = globus_error_put(err); + } + + break; case GLOBUS_GASS_COPY_URL_MODE_IO: #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, "transfer_start(): about to call globus_l_gass_copy_io_setup_put()\n"); + globus_libc_fprintf(stderr, "transfer_start(): about to call globus_l_gass_copy_io_setup_put()\n"); #endif - result = globus_l_gass_copy_io_setup_put(handle); + result = globus_l_gass_copy_io_setup_put(handle); - break; + break; default: break; } @@ -2620,36 +2620,36 @@ globus_l_gass_copy_transfer_start( } } - handle->status = GLOBUS_GASS_COPY_STATUS_FAILURE; + handle->status = GLOBUS_GASS_COPY_STATUS_FAILURE; #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, "transfer_start(): error with setting up the dest\n"); + globus_libc_fprintf(stderr, "transfer_start(): error with setting up the dest\n"); #endif /* clean up the source side since it was already opened..... */ - globus_mutex_init(&monitor.mutex, GLOBUS_NULL); - globus_cond_init(&monitor.cond, GLOBUS_NULL); - monitor.done = GLOBUS_FALSE; - monitor.err = GLOBUS_NULL; - monitor.use_err = GLOBUS_FALSE; + globus_mutex_init(&monitor.mutex, GLOBUS_NULL); + globus_cond_init(&monitor.cond, GLOBUS_NULL); + monitor.done = GLOBUS_FALSE; + monitor.err = GLOBUS_NULL; + monitor.use_err = GLOBUS_FALSE; handle->user_callback = GLOBUS_NULL; globus_gass_copy_cancel( - handle, - globus_l_gass_copy_monitor_callback, - (void *) &monitor); - /* wait for the cancel to complete before returning to user */ - globus_mutex_lock(&monitor.mutex); - { - while(!monitor.done) - { - globus_cond_wait(&monitor.cond, &monitor.mutex); - } - } - globus_mutex_unlock(&monitor.mutex); - globus_mutex_destroy(&monitor.mutex); - globus_cond_destroy(&monitor.cond); - - return result; + handle, + globus_l_gass_copy_monitor_callback, + (void *) &monitor); + /* wait for the cancel to complete before returning to user */ + globus_mutex_lock(&monitor.mutex); + { + while(!monitor.done) + { + globus_cond_wait(&monitor.cond, &monitor.mutex); + } + } + globus_mutex_unlock(&monitor.mutex); + globus_mutex_destroy(&monitor.mutex); + globus_cond_destroy(&monitor.cond); + + return result; } /* wait for ok from the dest */ globus_mutex_lock(&(state->monitor.mutex)); @@ -2661,39 +2661,39 @@ globus_l_gass_copy_transfer_start( while(state->dest.status == GLOBUS_I_GASS_COPY_TARGET_INITIAL) { globus_cond_wait(&state->monitor.cond, - &state->monitor.mutex); + &state->monitor.mutex); } globus_mutex_unlock(&state->monitor.mutex); if(handle->err) { - handle->status = GLOBUS_GASS_COPY_STATUS_FAILURE; - err = handle->err; - handle->err = GLOBUS_NULL; + handle->status = GLOBUS_GASS_COPY_STATUS_FAILURE; + err = handle->err; + handle->err = GLOBUS_NULL; /* clean up the source side since it was already opened..... */ - globus_mutex_init(&monitor.mutex, GLOBUS_NULL); - globus_cond_init(&monitor.cond, GLOBUS_NULL); - monitor.done = GLOBUS_FALSE; - monitor.err = GLOBUS_NULL; - monitor.use_err = GLOBUS_FALSE; + globus_mutex_init(&monitor.mutex, GLOBUS_NULL); + globus_cond_init(&monitor.cond, GLOBUS_NULL); + monitor.done = GLOBUS_FALSE; + monitor.err = GLOBUS_NULL; + monitor.use_err = GLOBUS_FALSE; handle->user_callback = GLOBUS_NULL; globus_gass_copy_cancel( - handle, - globus_l_gass_copy_monitor_callback, - (void *) &monitor); - /* wait for the cancel to complete before returning to user */ - globus_mutex_lock(&monitor.mutex); - { - while(!monitor.done) - { - globus_cond_wait(&monitor.cond, &monitor.mutex); - } - } - globus_mutex_unlock(&monitor.mutex); - globus_mutex_destroy(&monitor.mutex); - globus_cond_destroy(&monitor.cond); - return globus_error_put(err); + handle, + globus_l_gass_copy_monitor_callback, + (void *) &monitor); + /* wait for the cancel to complete before returning to user */ + globus_mutex_lock(&monitor.mutex); + { + while(!monitor.done) + { + globus_cond_wait(&monitor.cond, &monitor.mutex); + } + } + globus_mutex_unlock(&monitor.mutex); + globus_mutex_destroy(&monitor.mutex); + globus_cond_destroy(&monitor.cond); + return globus_error_put(err); } #ifdef GLOBUS_I_GASS_COPY_DEBUG globus_libc_fprintf(stderr, "transfer_start(): dest is ready, let's get goin'\n"); @@ -2722,36 +2722,36 @@ globus_l_gass_copy_read_from_queue( do { - do_the_read = GLOBUS_FALSE; - buffer_entry = GLOBUS_NULL; - buffer = GLOBUS_NULL; + do_the_read = GLOBUS_FALSE; + buffer_entry = GLOBUS_NULL; + buffer = GLOBUS_NULL; - globus_mutex_lock(&(state->source.mutex)); - { + globus_mutex_lock(&(state->source.mutex)); + { #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, "read_from_queue(): n_pending= %d n_simultaneous= %d\n", state->source.n_pending, state->source.n_simultaneous); #endif - if(state->source.status == GLOBUS_I_GASS_COPY_TARGET_READY) - { - if (((state->source.n_pending < - state->source.n_simultaneous) && - !state->cancel)) - { - if(!globus_fifo_empty(&(state->source.queue))) - { - state->source.n_pending++; - buffer_entry = + if(state->source.status == GLOBUS_I_GASS_COPY_TARGET_READY) + { + if (((state->source.n_pending < + state->source.n_simultaneous) && + !state->cancel)) + { + if(!globus_fifo_empty(&(state->source.queue))) + { + state->source.n_pending++; + buffer_entry = globus_fifo_dequeue(&(state->source.queue)); - buffer = buffer_entry->bytes; - globus_libc_free(buffer_entry); - do_the_read = GLOBUS_TRUE; - } - else - { + buffer = buffer_entry->bytes; + globus_libc_free(buffer_entry); + do_the_read = GLOBUS_TRUE; + } + else + { globus_mutex_lock(&(state->mutex)); if(state->n_buffers < state->max_buffers) { @@ -2760,9 +2760,9 @@ globus_l_gass_copy_read_from_queue( do_the_read = GLOBUS_TRUE; } globus_mutex_unlock(&(state->mutex)); - } - } - + } + } + if(do_the_read) { if(!buffer) @@ -2779,14 +2779,14 @@ globus_l_gass_copy_read_from_queue( result = globus_error_put(err); } } - + if(buffer) { result = globus_l_gass_copy_register_read( handle, buffer); } - + if (result != GLOBUS_SUCCESS) { state->cancel = GLOBUS_I_GASS_COPY_CANCEL_TRUE; @@ -2800,9 +2800,9 @@ globus_l_gass_copy_read_from_queue( globus_mutex_unlock(&(state->source.mutex)); } while(do_the_read); - + #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, "read_from_queue(): returning\n"); + globus_libc_fprintf(stderr, "read_from_queue(): returning\n"); #endif } /* globus_l_gass_copy_read_from_queue() */ @@ -2845,48 +2845,48 @@ globus_l_gass_copy_register_read( { case GLOBUS_GASS_COPY_URL_MODE_FTP: #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, "register_read(): calling globus_ftp_client_register_read()\n"); + globus_libc_fprintf(stderr, "register_read(): calling globus_ftp_client_register_read()\n"); #endif - result = globus_ftp_client_register_read( - state->source.data.ftp.handle, - buffer, - handle->buffer_length, - globus_l_gass_copy_ftp_read_callback, - (void *) handle); + result = globus_ftp_client_register_read( + state->source.data.ftp.handle, + buffer, + handle->buffer_length, + globus_l_gass_copy_ftp_read_callback, + (void *) handle); - break; + break; case GLOBUS_GASS_COPY_URL_MODE_GASS: #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, "register_read(): calling globus_gass_transfer_receive_bytes()\n"); -#endif - rc = globus_gass_transfer_receive_bytes( - state->source.data.gass.request, - buffer, - handle->buffer_length, - handle->buffer_length, - globus_l_gass_copy_gass_read_callback, - (void *) handle); - - if (rc != GLOBUS_SUCCESS) - { - /* figure out what the error is, and pass it back through the result */ - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: globus_gass_transfer_receive_bytes returned error code: %d", - myname, - rc); - result = globus_error_put(err); - } - else result = GLOBUS_SUCCESS; - - break; + globus_libc_fprintf(stderr, "register_read(): calling globus_gass_transfer_receive_bytes()\n"); +#endif + rc = globus_gass_transfer_receive_bytes( + state->source.data.gass.request, + buffer, + handle->buffer_length, + handle->buffer_length, + globus_l_gass_copy_gass_read_callback, + (void *) handle); + + if (rc != GLOBUS_SUCCESS) + { + /* figure out what the error is, and pass it back through the result */ + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: globus_gass_transfer_receive_bytes returned error code: %d", + myname, + rc); + result = globus_error_put(err); + } + else result = GLOBUS_SUCCESS; + + break; case GLOBUS_GASS_COPY_URL_MODE_IO: - if(handle->partial_end_offset != -1) + if(handle->partial_end_offset != -1) { - read_len = + read_len = (handle->buffer_length < handle->partial_bytes_remaining) ? handle->buffer_length : handle->partial_bytes_remaining; handle->partial_bytes_remaining -= read_len; @@ -2895,23 +2895,23 @@ globus_l_gass_copy_register_read( { read_len = handle->buffer_length; } - result = globus_io_register_read( - state->source.data.io.handle, - buffer, - read_len, - read_len, - globus_l_gass_copy_io_read_callback, - (void *) handle); - - break; + result = globus_io_register_read( + state->source.data.io.handle, + buffer, + read_len, + read_len, + globus_l_gass_copy_io_read_callback, + (void *) handle); + + break; case GLOBUS_GASS_COPY_URL_MODE_UNSUPPORTED: default: - result = globus_error_put(globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: %s: GLOBUS_GASS_COPY_URL_MODE_UNSUPPORTED", - myname, - state->source.url)); + result = globus_error_put(globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: %s: GLOBUS_GASS_COPY_URL_MODE_UNSUPPORTED", + myname, + state->source.url)); break; } @@ -2945,7 +2945,7 @@ globus_l_gass_copy_gass_setup_callback( static char * myname="globus_l_gass_copy_gass_setup_callback"; globus_gass_copy_handle_t * handle - = (globus_gass_copy_handle_t *) callback_arg; + = (globus_gass_copy_handle_t *) callback_arg; globus_gass_copy_state_t * state = handle->state; @@ -2959,183 +2959,183 @@ globus_l_gass_copy_gass_setup_callback( { case GLOBUS_GASS_TRANSFER_REQUEST_REFERRED: #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, "request status == GLOBUS_GASS_TRANSFER_REQUEST_REFERRED\n"); #endif - globus_gass_transfer_request_get_referral(request, &referral); - globus_gass_transfer_request_destroy(request); - - if (handle->status == GLOBUS_GASS_COPY_STATUS_INITIAL) - { - /* first setup the source with the register get - */ -#ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, "REQUEST_REFERRED: STATE_INITIAL\n"); -#endif - current_url = globus_libc_strdup(state->source.url); - globus_libc_free(state->source.url); - state->source.url =globus_libc_strdup( - globus_gass_transfer_referral_get_url(&referral, 0)); - -#ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, "REQUEST_REFERRED: about to globus_gass_transfer_register_get() again with: %s\n",state->source.url); -#endif - if ( (rc = globus_gass_transfer_register_get( - &(state->source.data.gass.request), - (state->source.attr->gass_requestattr), - state->source.url, - globus_l_gass_copy_gass_setup_callback, - (void *) handle)) != GLOBUS_SUCCESS ) - {/* there was an error */ - globus_mutex_lock(&state->monitor.mutex); -#ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, "gass_setup_callback(): transfer_register_get() returned: %d\n", rc); - if(rc==GLOBUS_GASS_TRANSFER_ERROR_BAD_URL) - globus_libc_fprintf(stderr, "rc == GLOBUS_GASS_ERROR_BAD_URL\n"); -#endif - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: the original source url: %s was referred to: %s, for which globus_gass_transfer_register_get returned an error code of: %d", - myname, - current_url, - state->source.url, - rc); - globus_i_gass_copy_set_error(handle, err); - globus_libc_free(current_url); - globus_gass_transfer_referral_destroy(&referral); - goto wakeup_state; - } - globus_gass_transfer_referral_destroy(&referral); - } - else - { - /* if the state is not INITIAL then assume the source is ready - * and that we are now setting up the destination with the register put - */ - current_url = globus_libc_strdup(state->dest.url); - globus_libc_free(state->dest.url); - state->dest.url =globus_libc_strdup( - globus_gass_transfer_referral_get_url(&referral, 0)); - - globus_gass_transfer_referral_destroy(&referral); - - if ( (rc = globus_gass_transfer_register_put( - &request, - (state->dest.attr->gass_requestattr), - state->dest.url, - 0, - globus_l_gass_copy_gass_setup_callback, - (void *) handle)) != GLOBUS_SUCCESS ) - { /* there was an error */ - globus_mutex_lock(&state->monitor.mutex); - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: the original destination url: %s was referred to: %s, for which globus_gass_transfer_register_get returned an error code of: %d", - myname, - current_url, - state->dest.url, - rc); - globus_i_gass_copy_set_error(handle, err); - globus_libc_free(current_url); - globus_gass_transfer_referral_destroy(&referral); - goto wakeup_state; - } - globus_gass_transfer_referral_destroy(&referral); - } - globus_libc_free(current_url); - break; + globus_gass_transfer_request_get_referral(request, &referral); + globus_gass_transfer_request_destroy(request); + + if (handle->status == GLOBUS_GASS_COPY_STATUS_INITIAL) + { + /* first setup the source with the register get + */ +#ifdef GLOBUS_I_GASS_COPY_DEBUG + globus_libc_fprintf(stderr, "REQUEST_REFERRED: STATE_INITIAL\n"); +#endif + current_url = globus_libc_strdup(state->source.url); + globus_libc_free(state->source.url); + state->source.url =globus_libc_strdup( + globus_gass_transfer_referral_get_url(&referral, 0)); + +#ifdef GLOBUS_I_GASS_COPY_DEBUG + globus_libc_fprintf(stderr, "REQUEST_REFERRED: about to globus_gass_transfer_register_get() again with: %s\n",state->source.url); +#endif + if ( (rc = globus_gass_transfer_register_get( + &(state->source.data.gass.request), + (state->source.attr->gass_requestattr), + state->source.url, + globus_l_gass_copy_gass_setup_callback, + (void *) handle)) != GLOBUS_SUCCESS ) + {/* there was an error */ + globus_mutex_lock(&state->monitor.mutex); +#ifdef GLOBUS_I_GASS_COPY_DEBUG + globus_libc_fprintf(stderr, "gass_setup_callback(): transfer_register_get() returned: %d\n", rc); + if(rc==GLOBUS_GASS_TRANSFER_ERROR_BAD_URL) + globus_libc_fprintf(stderr, "rc == GLOBUS_GASS_ERROR_BAD_URL\n"); +#endif + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: the original source url: %s was referred to: %s, for which globus_gass_transfer_register_get returned an error code of: %d", + myname, + current_url, + state->source.url, + rc); + globus_i_gass_copy_set_error(handle, err); + globus_libc_free(current_url); + globus_gass_transfer_referral_destroy(&referral); + goto wakeup_state; + } + globus_gass_transfer_referral_destroy(&referral); + } + else + { + /* if the state is not INITIAL then assume the source is ready + * and that we are now setting up the destination with the register put + */ + current_url = globus_libc_strdup(state->dest.url); + globus_libc_free(state->dest.url); + state->dest.url =globus_libc_strdup( + globus_gass_transfer_referral_get_url(&referral, 0)); + + globus_gass_transfer_referral_destroy(&referral); + + if ( (rc = globus_gass_transfer_register_put( + &request, + (state->dest.attr->gass_requestattr), + state->dest.url, + 0, + globus_l_gass_copy_gass_setup_callback, + (void *) handle)) != GLOBUS_SUCCESS ) + { /* there was an error */ + globus_mutex_lock(&state->monitor.mutex); + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: the original destination url: %s was referred to: %s, for which globus_gass_transfer_register_get returned an error code of: %d", + myname, + current_url, + state->dest.url, + rc); + globus_i_gass_copy_set_error(handle, err); + globus_libc_free(current_url); + globus_gass_transfer_referral_destroy(&referral); + goto wakeup_state; + } + globus_gass_transfer_referral_destroy(&referral); + } + globus_libc_free(current_url); + break; case GLOBUS_GASS_TRANSFER_REQUEST_PENDING: #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, "request status == GLOBUS_GASS_TRANSFER_REQUEST_PENDING, should signal the monitor\n"); -#endif - if (handle->status == GLOBUS_GASS_COPY_STATUS_INITIAL) - { - globus_mutex_lock(&state->monitor.mutex); - state->source.status = GLOBUS_I_GASS_COPY_TARGET_READY; - globus_cond_signal(&state->monitor.cond); - globus_mutex_unlock(&state->monitor.mutex); - } - else - { - globus_mutex_lock(&state->monitor.mutex); - state->dest.status = GLOBUS_I_GASS_COPY_TARGET_READY; - globus_cond_signal(&state->monitor.cond); - globus_mutex_unlock(&state->monitor.mutex); - } - break; + globus_libc_fprintf(stderr, "request status == GLOBUS_GASS_TRANSFER_REQUEST_PENDING, should signal the monitor\n"); +#endif + if (handle->status == GLOBUS_GASS_COPY_STATUS_INITIAL) + { + globus_mutex_lock(&state->monitor.mutex); + state->source.status = GLOBUS_I_GASS_COPY_TARGET_READY; + globus_cond_signal(&state->monitor.cond); + globus_mutex_unlock(&state->monitor.mutex); + } + else + { + globus_mutex_lock(&state->monitor.mutex); + state->dest.status = GLOBUS_I_GASS_COPY_TARGET_READY; + globus_cond_signal(&state->monitor.cond); + globus_mutex_unlock(&state->monitor.mutex); + } + break; case GLOBUS_GASS_TRANSFER_REQUEST_DONE: #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, "request status == GLOBUS_GASS_TRANSFER_REQUEST_DONE\n"); + globus_libc_fprintf(stderr, "request status == GLOBUS_GASS_TRANSFER_REQUEST_DONE\n"); #endif - globus_mutex_lock(&state->monitor.mutex); - if (handle->status == GLOBUS_GASS_COPY_STATUS_INITIAL) - current_url = state->source.url; - else - current_url = state->dest.url; + globus_mutex_lock(&state->monitor.mutex); + if (handle->status == GLOBUS_GASS_COPY_STATUS_INITIAL) + current_url = state->source.url; + else + current_url = state->dest.url; - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: we're just getting set up, but the status of url %s is GLOBUS_GASS_TRANSFER_REQUEST_DONE", - myname, - current_url); - globus_i_gass_copy_set_error(handle, err); + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: we're just getting set up, but the status of url %s is GLOBUS_GASS_TRANSFER_REQUEST_DONE", + myname, + current_url); + globus_i_gass_copy_set_error(handle, err); - goto wakeup_state; - break; + goto wakeup_state; + break; case GLOBUS_GASS_TRANSFER_REQUEST_DENIED: #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, "request status == GLOBUS_GASS_TRANSFER_REQUEST_DENIED\n"); #endif - globus_mutex_lock(&state->monitor.mutex); - if (handle->status == GLOBUS_GASS_COPY_STATUS_INITIAL) - current_url = state->source.url; - else - current_url = state->dest.url; + globus_mutex_lock(&state->monitor.mutex); + if (handle->status == GLOBUS_GASS_COPY_STATUS_INITIAL) + current_url = state->source.url; + else + current_url = state->dest.url; - denial_reason = globus_gass_transfer_request_get_denial_reason(request); - denial_message = + denial_reason = globus_gass_transfer_request_get_denial_reason(request); + denial_message = globus_gass_transfer_request_get_denial_message(request); - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: url: %s request was DENIED, for reason: %d, %s", - myname, - current_url, - denial_reason, - denial_message); - globus_i_gass_copy_set_error(handle, err); - - goto wakeup_state; - break; + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: url: %s request was DENIED, for reason: %d, %s", + myname, + current_url, + denial_reason, + denial_message); + globus_i_gass_copy_set_error(handle, err); + + goto wakeup_state; + break; case GLOBUS_GASS_TRANSFER_REQUEST_FAILED: #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, "request status == GLOBUS_GASS_TRANSFER_REQUEST_FAILED\n"); #endif - globus_mutex_lock(&state->monitor.mutex); - if (handle->status == GLOBUS_GASS_COPY_STATUS_INITIAL) - current_url = state->source.url; - else - current_url = state->dest.url; - - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: url: %s request FAILED", - myname, - current_url); - globus_i_gass_copy_set_error(handle, err); - - goto wakeup_state; - break; + globus_mutex_lock(&state->monitor.mutex); + if (handle->status == GLOBUS_GASS_COPY_STATUS_INITIAL) + current_url = state->source.url; + else + current_url = state->dest.url; + + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: url: %s request FAILED", + myname, + current_url); + globus_i_gass_copy_set_error(handle, err); + + goto wakeup_state; + break; default: break; } /* switch */ @@ -3146,9 +3146,9 @@ globus_l_gass_copy_gass_setup_callback( * assume mutex has already been locked by above calls */ if (handle->status == GLOBUS_GASS_COPY_STATUS_INITIAL) - state->source.status = GLOBUS_I_GASS_COPY_TARGET_FAILED; + state->source.status = GLOBUS_I_GASS_COPY_TARGET_FAILED; else - state->dest.status = GLOBUS_I_GASS_COPY_TARGET_FAILED; + state->dest.status = GLOBUS_I_GASS_COPY_TARGET_FAILED; handle->status = GLOBUS_GASS_COPY_STATUS_FAILURE; state->monitor.done = 1; @@ -3170,61 +3170,61 @@ globus_l_gass_copy_io_setup_get( if (state->source.data.io.free_handle) { - globus_url_parse(state->source.url, &parsed_url); - state->source.data.io.handle =(globus_io_handle_t *) - globus_libc_malloc(sizeof(globus_io_handle_t)); - - if(state->source.data.io.handle == GLOBUS_NULL) - { - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: failed to malloc a globus_io_handle_t successfully", - myname); - return globus_error_put(err); - } - result = globus_io_file_open( - parsed_url.url_path, - GLOBUS_IO_FILE_RDONLY, - GLOBUS_IO_FILE_IRUSR, - state->source.attr->io, - state->source.data.io.handle); + globus_url_parse(state->source.url, &parsed_url); + state->source.data.io.handle =(globus_io_handle_t *) + globus_libc_malloc(sizeof(globus_io_handle_t)); + + if(state->source.data.io.handle == GLOBUS_NULL) + { + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: failed to malloc a globus_io_handle_t successfully", + myname); + return globus_error_put(err); + } + result = globus_io_file_open( + parsed_url.url_path, + GLOBUS_IO_FILE_RDONLY, + GLOBUS_IO_FILE_IRUSR, + state->source.attr->io, + state->source.data.io.handle); if(result == GLOBUS_SUCCESS && handle->partial_offset != -1) { if(handle->partial_end_offset != -1) { - handle->partial_bytes_remaining = + handle->partial_bytes_remaining = handle->partial_end_offset - handle->partial_offset; } result = globus_io_file_seek( state->source.data.io.handle, handle->partial_offset, - SEEK_SET); + SEEK_SET); } - if(result==GLOBUS_SUCCESS) - { + if(result==GLOBUS_SUCCESS) + { - state->source.status = GLOBUS_I_GASS_COPY_TARGET_READY; + state->source.status = GLOBUS_I_GASS_COPY_TARGET_READY; #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, "io_setup_get(): SUCCESS opening %s\n",parsed_url.url_path); - } - else - { - globus_libc_fprintf(stderr, + } + else + { + globus_libc_fprintf(stderr, "io_setup_get(): FAILURE opening %s\n",parsed_url.url_path); #endif - } + } globus_url_destroy(&parsed_url); - + } else { #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, "io_setup_get(): handle should already have been opened by the user\n"); + globus_libc_fprintf(stderr, "io_setup_get(): handle should already have been opened by the user\n"); #endif state->source.status = GLOBUS_I_GASS_COPY_TARGET_READY; result=GLOBUS_SUCCESS; @@ -3248,62 +3248,62 @@ globus_l_gass_copy_io_setup_put( globus_url_parse(state->dest.url, &parsed_url); state->dest.data.io.handle = (globus_io_handle_t *) globus_libc_malloc(sizeof(globus_io_handle_t)); - if(state->dest.data.io.handle == GLOBUS_NULL) - { + if(state->dest.data.io.handle == GLOBUS_NULL) + { #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, "io_setup_put(): error mallocing io_handle_t\n"); + globus_libc_fprintf(stderr, "io_setup_put(): error mallocing io_handle_t\n"); #endif - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: failed to malloc a globus_io_handle_t successfully", - myname); - return globus_error_put(err); - } + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: failed to malloc a globus_io_handle_t successfully", + myname); + return globus_error_put(err); + } result = globus_io_file_open( - parsed_url.url_path, - (handle->partial_offset == -1) ? - (GLOBUS_IO_FILE_WRONLY|GLOBUS_IO_FILE_CREAT|GLOBUS_IO_FILE_TRUNC) : - (GLOBUS_IO_FILE_WRONLY|GLOBUS_IO_FILE_CREAT), - (GLOBUS_IO_FILE_IRUSR|GLOBUS_IO_FILE_IWUSR| - GLOBUS_IO_FILE_IRGRP|GLOBUS_IO_FILE_IWGRP| - GLOBUS_IO_FILE_IROTH|GLOBUS_IO_FILE_IWOTH), - state->dest.attr->io, - state->dest.data.io.handle); + parsed_url.url_path, + (handle->partial_offset == -1) ? + (GLOBUS_IO_FILE_WRONLY|GLOBUS_IO_FILE_CREAT|GLOBUS_IO_FILE_TRUNC) : + (GLOBUS_IO_FILE_WRONLY|GLOBUS_IO_FILE_CREAT), + (GLOBUS_IO_FILE_IRUSR|GLOBUS_IO_FILE_IWUSR| + GLOBUS_IO_FILE_IRGRP|GLOBUS_IO_FILE_IWGRP| + GLOBUS_IO_FILE_IROTH|GLOBUS_IO_FILE_IWOTH), + state->dest.attr->io, + state->dest.data.io.handle); if(result == GLOBUS_SUCCESS && handle->partial_offset != -1) { result = globus_io_file_seek( state->dest.data.io.handle, handle->partial_offset, - SEEK_SET); + SEEK_SET); } - if(result==GLOBUS_SUCCESS) - { - state->dest.status = GLOBUS_I_GASS_COPY_TARGET_READY; + if(result==GLOBUS_SUCCESS) + { + state->dest.status = GLOBUS_I_GASS_COPY_TARGET_READY; #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, "io_setup_put(): SUCCESS opening %s\n",parsed_url.url_path); - } - else - { - globus_libc_fprintf(stderr, + } + else + { + globus_libc_fprintf(stderr, "io_setup_put(): FAILED opening %s\n",parsed_url.url_path); #endif - } + } globus_url_destroy(&parsed_url); } else { #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, "io_setup_put(): handle should already have been opened by the user\n"); + globus_libc_fprintf(stderr, "io_setup_put(): handle should already have been opened by the user\n"); #endif - state->dest.status = GLOBUS_I_GASS_COPY_TARGET_READY; - result=GLOBUS_SUCCESS; + state->dest.status = GLOBUS_I_GASS_COPY_TARGET_READY; + result=GLOBUS_SUCCESS; } return result; @@ -3326,7 +3326,7 @@ globus_l_gass_copy_ftp_setup_get( GLOBUS_NULL, globus_l_gass_copy_ftp_get_done_callback, (void *) handle); - } + } else { result = globus_ftp_client_partial_get( @@ -3335,29 +3335,29 @@ globus_l_gass_copy_ftp_setup_get( state->source.attr->ftp_attr, GLOBUS_NULL, handle->partial_offset, - handle->partial_end_offset, + handle->partial_end_offset, globus_l_gass_copy_ftp_get_done_callback, (void *) handle); } - + if(result==GLOBUS_SUCCESS) { - state->source.status = GLOBUS_I_GASS_COPY_TARGET_READY; - state->source.data.ftp.completed = GLOBUS_FALSE; - + state->source.status = GLOBUS_I_GASS_COPY_TARGET_READY; + state->source.data.ftp.completed = GLOBUS_FALSE; + #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, "ftp_setup_get(): SUCCESS opening %s\n", + globus_libc_fprintf(stderr, "ftp_setup_get(): SUCCESS opening %s\n", state->source.url); } else { - globus_libc_fprintf(stderr, "ftp_setup_get(): FAILURE opening %s\n", + globus_libc_fprintf(stderr, "ftp_setup_get(): FAILURE opening %s\n", state->source.url); #endif } return result; - + } /* globus_l_gass_copy_ftp_setup_get() */ globus_result_t @@ -3368,7 +3368,7 @@ globus_l_gass_copy_ftp_setup_put( globus_result_t result; if(handle->partial_offset == -1) - { + { result = globus_ftp_client_put( state->dest.data.ftp.handle, state->dest.url, @@ -3385,18 +3385,18 @@ globus_l_gass_copy_ftp_setup_put( state->dest.attr->ftp_attr, GLOBUS_NULL, handle->partial_offset, - handle->partial_end_offset, + handle->partial_end_offset, globus_l_gass_copy_ftp_put_done_callback, (void *) handle); } - + if(result==GLOBUS_SUCCESS) { - state->dest.status = GLOBUS_I_GASS_COPY_TARGET_READY; - state->dest.data.ftp.completed = GLOBUS_FALSE; - + state->dest.status = GLOBUS_I_GASS_COPY_TARGET_READY; + state->dest.data.ftp.completed = GLOBUS_FALSE; + #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, "ftp_setup_put(): SUCCESS opening %s\n",state->dest.url); } else @@ -3406,7 +3406,7 @@ globus_l_gass_copy_ftp_setup_put( globus_l_gass_copy_perf_cancel_ftp_callback(handle->performance); } - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, "ftp_setup_put(): FAILURE opening %s\n",state->dest.url); #endif } @@ -3419,15 +3419,15 @@ globus_l_gass_copy_ftp_setup_put( void globus_l_gass_copy_ftp_transfer_callback( - void * user_arg, + void * user_arg, globus_ftp_client_handle_t * handle, - globus_object_t * error) + globus_object_t * error) { globus_object_t * err = GLOBUS_NULL; globus_result_t result; globus_gass_copy_handle_t * copy_handle - = (globus_gass_copy_handle_t *) user_arg; + = (globus_gass_copy_handle_t *) user_arg; #ifdef GLOBUS_I_GASS_COPY_DEBUG globus_libc_fprintf(stderr, "ftp_transfer_callback(): called\n"); @@ -3435,17 +3435,17 @@ globus_l_gass_copy_ftp_transfer_callback( if(error != GLOBUS_SUCCESS) { - /* do some error handling */ - /* copy_handle->err = globus_copy_error(error);*/ + /* do some error handling */ + /* copy_handle->err = globus_copy_error(error);*/ if (copy_handle->status != GLOBUS_GASS_COPY_STATUS_CANCEL) { - globus_i_gass_copy_set_error(copy_handle, error); - copy_handle->status = GLOBUS_GASS_COPY_STATUS_FAILURE; + globus_i_gass_copy_set_error(copy_handle, error); + copy_handle->status = GLOBUS_GASS_COPY_STATUS_FAILURE; } #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, "ftp_transfer_callback(): !GLOBUS_SUCESS, error= %d\n", + globus_libc_fprintf(stderr, "ftp_transfer_callback(): !GLOBUS_SUCESS, error= %d\n", error); #endif } @@ -3453,7 +3453,7 @@ globus_l_gass_copy_ftp_transfer_callback( { copy_handle->status = GLOBUS_GASS_COPY_STATUS_DONE; #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, "ftp_transfer_callback(): GLOBUS_SUCCESS\n"); + globus_libc_fprintf(stderr, "ftp_transfer_callback(): GLOBUS_SUCCESS\n"); #endif } @@ -3468,26 +3468,26 @@ globus_l_gass_copy_ftp_transfer_callback( switch(copy_handle->status) { case GLOBUS_GASS_COPY_STATUS_DONE: - copy_handle->status = GLOBUS_GASS_COPY_STATUS_DONE_SUCCESS; - break; + copy_handle->status = GLOBUS_GASS_COPY_STATUS_DONE_SUCCESS; + break; case GLOBUS_GASS_COPY_STATUS_FAILURE: - copy_handle->status = GLOBUS_GASS_COPY_STATUS_DONE_FAILURE; - break; + copy_handle->status = GLOBUS_GASS_COPY_STATUS_DONE_FAILURE; + break; case GLOBUS_GASS_COPY_STATUS_CANCEL: - copy_handle->status = GLOBUS_GASS_COPY_STATUS_DONE_CANCELLED; - break; + copy_handle->status = GLOBUS_GASS_COPY_STATUS_DONE_CANCELLED; + break; default: - break; + break; } /* checksum verify */ - if(copy_handle->status == GLOBUS_GASS_COPY_STATUS_DONE_SUCCESS && err == GLOBUS_NULL && + if(copy_handle->status == GLOBUS_GASS_COPY_STATUS_DONE_SUCCESS && err == GLOBUS_NULL && copy_handle->state->cksm_handle != GLOBUS_NULL && copy_handle->state->checksum != GLOBUS_NULL) { globus_assert_string(copy_handle->state->dest.free_attr != GLOBUS_TRUE, "Checksum verification requires ftp attributes."); result = globus_l_gass_copy_verify_cksm( copy_handle, copy_handle->state->dest.attr, copy_handle->state->dest.url); - if(result != GLOBUS_SUCCESS) + if(result != GLOBUS_SUCCESS) { err = globus_error_get(result); copy_handle->status = GLOBUS_GASS_COPY_STATUS_DONE_FAILURE; @@ -3502,11 +3502,11 @@ globus_l_gass_copy_ftp_transfer_callback( } if(copy_handle->user_callback != GLOBUS_NULL) - copy_handle->user_callback( - copy_handle->callback_arg, - copy_handle, - err); - + copy_handle->user_callback( + copy_handle->callback_arg, + copy_handle, + err); + if(err) { globus_object_free(err); @@ -3517,27 +3517,27 @@ void globus_l_gass_copy_ftp_get_done_callback( void * callback_arg, globus_ftp_client_handle_t * handle, - globus_object_t * error) + globus_object_t * error) { globus_gass_copy_handle_t * copy_handle - = (globus_gass_copy_handle_t *) callback_arg; + = (globus_gass_copy_handle_t *) callback_arg; globus_i_gass_copy_cancel_t * cancel_info = GLOBUS_NULL; #ifdef GLOBUS_I_GASS_COPY_DEBUG globus_libc_fprintf(stderr, "ftp_get_done_callback(): starting\n"); #endif - + globus_mutex_lock(©_handle->state->mutex); { copy_handle->state->source.data.ftp.completed = GLOBUS_TRUE; } globus_mutex_unlock(©_handle->state->mutex); - + if ((copy_handle->status == GLOBUS_GASS_COPY_STATUS_CANCEL) || (copy_handle->status == GLOBUS_GASS_COPY_STATUS_FAILURE)) { /* prefer this error over a data error */ - if(copy_handle->err && + if(copy_handle->err && copy_handle->err == copy_handle->state->source.data.ftp.data_err) { globus_object_free(copy_handle->err); @@ -3545,7 +3545,7 @@ globus_l_gass_copy_ftp_get_done_callback( copy_handle->state->source.data.ftp.data_err = NULL; globus_i_gass_copy_set_error(copy_handle, error); } - + cancel_info = (globus_i_gass_copy_cancel_t *) globus_libc_malloc(sizeof(globus_i_gass_copy_cancel_t)); cancel_info->handle = copy_handle; @@ -3558,7 +3558,7 @@ globus_l_gass_copy_ftp_get_done_callback( if (error != GLOBUS_SUCCESS) { #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, "ftp_get_done_callback(): called with error\n"); + globus_libc_fprintf(stderr, "ftp_get_done_callback(): called with error\n"); #endif copy_handle->state->source.status = GLOBUS_I_GASS_COPY_TARGET_FAILED; copy_handle->status = GLOBUS_GASS_COPY_STATUS_FAILURE; @@ -3583,27 +3583,27 @@ void globus_l_gass_copy_ftp_put_done_callback( void * callback_arg, globus_ftp_client_handle_t * handle, - globus_object_t * error) + globus_object_t * error) { globus_gass_copy_handle_t * copy_handle - = (globus_gass_copy_handle_t *) callback_arg; + = (globus_gass_copy_handle_t *) callback_arg; globus_i_gass_copy_cancel_t * cancel_info = GLOBUS_NULL; #ifdef GLOBUS_I_GASS_COPY_DEBUG globus_libc_fprintf(stderr, "ftp_put_done_callback(): starting\n"); #endif - + globus_mutex_lock(©_handle->state->mutex); { copy_handle->state->dest.data.ftp.completed = GLOBUS_TRUE; } globus_mutex_unlock(©_handle->state->mutex); - + if ((copy_handle->status == GLOBUS_GASS_COPY_STATUS_CANCEL) || (copy_handle->status == GLOBUS_GASS_COPY_STATUS_FAILURE)) { /* prefer this error over a data error */ - if(copy_handle->err && + if(copy_handle->err && copy_handle->err == copy_handle->state->dest.data.ftp.data_err) { globus_object_free(copy_handle->err); @@ -3668,28 +3668,28 @@ globus_l_gass_copy_generic_read_callback( #ifdef GLOBUS_I_GASS_COPY_DEBUG globus_libc_fprintf(stderr, "generic_read_callback(): read %d bytes, offset: %"GLOBUS_OFF_T_FORMAT", last_data: %d\n", - nbytes, offset, last_data); + nbytes, offset, last_data); #endif if(state->cancel == GLOBUS_I_GASS_COPY_CANCEL_TRUE) { #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, "generic_read_callback(): there was an error\n"); #endif - globus_mutex_lock(&(state->source.mutex)); - state->source.n_pending--; - globus_mutex_unlock(&(state->source.mutex)); + globus_mutex_lock(&(state->source.mutex)); + state->source.n_pending--; + globus_mutex_unlock(&(state->source.mutex)); globus_gass_copy_cancel(handle, NULL, NULL); - return; + return; } /* * - if it's the last_data, set TARGET_DONE to prevent more reads * - a buffer entry with last_data = GLOBUS_TRUE is only sent if we * have already received eof and there are no pending callbacks - * - we only allow zero byte writes if we have already received eof + * - we only allow zero byte writes if we have already received eof * and there are no pending callbacks */ globus_mutex_lock(&(state->source.mutex)); @@ -3699,7 +3699,7 @@ globus_l_gass_copy_generic_read_callback( { state->source.status = GLOBUS_I_GASS_COPY_TARGET_DONE; } - + if(state->source.status == GLOBUS_I_GASS_COPY_TARGET_DONE && state->source.n_pending == 0) { @@ -3711,26 +3711,26 @@ globus_l_gass_copy_generic_read_callback( { push_write = GLOBUS_FALSE; } - + last_data = GLOBUS_FALSE; } } globus_mutex_unlock(&(state->source.mutex)); - + /* push the write */ buffer_entry = (globus_i_gass_copy_buffer_t *) globus_libc_malloc(sizeof(globus_i_gass_copy_buffer_t)); - + if(buffer_entry == GLOBUS_NULL) { /* out of memory error */ err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: failed to malloc a buffer structure successfully", - myname); + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: failed to malloc a buffer structure successfully", + myname); globus_i_gass_copy_set_error(handle, err); - + #ifdef GLOBUS_I_GASS_COPY_DEBUG globus_libc_fprintf(stderr, "generic_read_callback(): malloc failed\n"); @@ -3738,14 +3738,14 @@ globus_l_gass_copy_generic_read_callback( globus_gass_copy_cancel(handle, NULL, NULL); return; } /* if(buffer_entry == GLOBUS_NULL) */ - + if(push_write) { buffer_entry->bytes = bytes; buffer_entry->nbytes = nbytes; buffer_entry->offset = offset; buffer_entry->last_data = last_data; - + globus_mutex_lock(&(state->dest.mutex)); { /* put this read buffer entry onto the write queue */ @@ -3762,22 +3762,22 @@ globus_l_gass_copy_generic_read_callback( } globus_mutex_unlock(&(state->source.mutex)); } - + /* start the next write if there isn't already one outstanding */ if(handle->state->active) - globus_l_gass_copy_write_from_queue(handle); + globus_l_gass_copy_write_from_queue(handle); #ifdef GLOBUS_I_GASS_COPY_DEBUG else - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, "generic_read_callback(): handle->state == GLOBUS_NULL\n"); #endif /* if we haven't read everything from the source, read again */ if(handle->state->active) - globus_l_gass_copy_read_from_queue(handle); + globus_l_gass_copy_read_from_queue(handle); #ifdef GLOBUS_I_GASS_COPY_DEBUG else - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, "generic_read_callback(): handle->state == GLOBUS_NULL\n"); #endif @@ -3792,10 +3792,10 @@ globus_l_gass_copy_ftp_read_callback( globus_byte_t * bytes, globus_size_t nbytes, globus_off_t offset, - globus_bool_t eof) + globus_bool_t eof) { globus_gass_copy_handle_t * copy_handle - = (globus_gass_copy_handle_t *) callback_arg; + = (globus_gass_copy_handle_t *) callback_arg; globus_gass_copy_state_t * state = copy_handle->state; @@ -3803,55 +3803,55 @@ globus_l_gass_copy_ftp_read_callback( #ifdef GLOBUS_I_GASS_COPY_DEBUG globus_libc_fprintf(stderr, - "ftp_read_callback(): start, n_pending: %d, nbytes: %d, offset: %"GLOBUS_OFF_T_FORMAT", eof: %d\n", - state->source.n_pending, nbytes, offset, eof); + "ftp_read_callback(): start, n_pending: %d, nbytes: %d, offset: %"GLOBUS_OFF_T_FORMAT", eof: %d\n", + state->source.n_pending, nbytes, offset, eof); #endif if(error == GLOBUS_SUCCESS) /* no error occurred */ { - last_data = eof; - if(eof) - { + last_data = eof; + if(eof) + { #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, - "ftp_read_callback(): source TARGET_DONE, nbytes: %d, offset: %"GLOBUS_OFF_T_FORMAT", eof: %d\n", - nbytes, offset, eof); + globus_libc_fprintf(stderr, + "ftp_read_callback(): source TARGET_DONE, nbytes: %d, offset: %"GLOBUS_OFF_T_FORMAT", eof: %d\n", + nbytes, offset, eof); #endif - /* - globus_mutex_lock(&(state->source.mutex)); - { - state->source.status = GLOBUS_I_GASS_COPY_TARGET_DONE; - } + /* + globus_mutex_lock(&(state->source.mutex)); + { + state->source.status = GLOBUS_I_GASS_COPY_TARGET_DONE; + } - globus_mutex_unlock(&(state->source.mutex)); - */ - if((copy_handle->status != GLOBUS_GASS_COPY_STATUS_FAILURE) && - (copy_handle->status < GLOBUS_GASS_COPY_STATUS_READ_COMPLETE)) - copy_handle->status = GLOBUS_GASS_COPY_STATUS_READ_COMPLETE; - } + globus_mutex_unlock(&(state->source.mutex)); + */ + if((copy_handle->status != GLOBUS_GASS_COPY_STATUS_FAILURE) && + (copy_handle->status < GLOBUS_GASS_COPY_STATUS_READ_COMPLETE)) + copy_handle->status = GLOBUS_GASS_COPY_STATUS_READ_COMPLETE; + } } else /* there was an error */ { #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, "ftp_read_callback: was passed an ERROR\n"); + globus_libc_fprintf(stderr, "ftp_read_callback: was passed an ERROR\n"); #endif - { - if(!state->cancel) /* cancel has not been set already */ - { - globus_i_gass_copy_set_error(copy_handle, error); - state->cancel = GLOBUS_I_GASS_COPY_CANCEL_TRUE; - copy_handle->status = GLOBUS_GASS_COPY_STATUS_FAILURE; + { + if(!state->cancel) /* cancel has not been set already */ + { + globus_i_gass_copy_set_error(copy_handle, error); + state->cancel = GLOBUS_I_GASS_COPY_CANCEL_TRUE; + copy_handle->status = GLOBUS_GASS_COPY_STATUS_FAILURE; state->source.data.ftp.data_err = copy_handle->err; - } - else - { - globus_mutex_lock(&(state->source.mutex)); - state->source.n_pending--; - globus_mutex_unlock(&(state->source.mutex)); - return; - } - - } + } + else + { + globus_mutex_lock(&(state->source.mutex)); + state->source.n_pending--; + globus_mutex_unlock(&(state->source.mutex)); + return; + } + + } } /* else (there was an error) */ @@ -3860,7 +3860,7 @@ globus_l_gass_copy_ftp_read_callback( bytes, nbytes, offset, - last_data); + last_data); } /* globus_l_gass_copy_ftp_read_callback() */ void @@ -3877,7 +3877,7 @@ globus_l_gass_copy_gass_read_callback( static char * myname="globus_l_gass_copy_gass_read_callback"; globus_gass_copy_handle_t * handle - = (globus_gass_copy_handle_t *) callback_arg; + = (globus_gass_copy_handle_t *) callback_arg; globus_gass_copy_state_t * state = handle->state; req_status = globus_gass_transfer_request_get_status(request); #ifdef GLOBUS_I_GASS_COPY_DEBUG @@ -3888,60 +3888,60 @@ globus_l_gass_copy_gass_read_callback( if(req_status == GLOBUS_GASS_TRANSFER_REQUEST_DONE || req_status == GLOBUS_GASS_TRANSFER_REQUEST_PENDING) { /* all is well */ - if(last_data) - { /* this was the last read. set READ_COMPLETE and free the request */ - /* - globus_mutex_lock(&(state->source.mutex)); - { - state->source.status = GLOBUS_I_GASS_COPY_TARGET_DONE; - } - globus_mutex_unlock(&(state->source.mutex)); - */ - handle->status = GLOBUS_GASS_COPY_STATUS_READ_COMPLETE; + if(last_data) + { /* this was the last read. set READ_COMPLETE and free the request */ + /* + globus_mutex_lock(&(state->source.mutex)); + { + state->source.status = GLOBUS_I_GASS_COPY_TARGET_DONE; + } + globus_mutex_unlock(&(state->source.mutex)); + */ + handle->status = GLOBUS_GASS_COPY_STATUS_READ_COMPLETE; /* req_status = globus_gass_transfer_request_get_status(request); */ - if(req_status == GLOBUS_GASS_TRANSFER_REQUEST_DONE) - { + if(req_status == GLOBUS_GASS_TRANSFER_REQUEST_DONE) + { #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, "gass_read_callback(): GLOBUS_GASS_TRANSFER_REQUEST_DONE\n"); #endif - globus_gass_transfer_request_destroy(request); - } - else - { - /* there's an error, tell someone who cares */ + globus_gass_transfer_request_destroy(request); + } + else + { + /* there's an error, tell someone who cares */ #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, "gass_read_callback(): this was last_data, but status !=GLOBUS_GASS_TRANSFER_REQUEST_DONE\n"); + globus_libc_fprintf(stderr, "gass_read_callback(): this was last_data, but status !=GLOBUS_GASS_TRANSFER_REQUEST_DONE\n"); #endif - } - }/* if(last_data) */ + } + }/* if(last_data) */ } /* all is well */ else { /* all is NOT well, deal with error */ - { - if(!state->cancel) /* cancel has not been set already */ - { - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: gass_transfer_request_status: %d", - myname, - req_status); - globus_i_gass_copy_set_error(handle, err); - state->cancel = GLOBUS_I_GASS_COPY_CANCEL_TRUE; - handle->status = GLOBUS_GASS_COPY_STATUS_FAILURE; - } - else - { - globus_mutex_lock(&(state->source.mutex)); - state->source.n_pending--; - globus_mutex_unlock(&(state->source.mutex)); - return; - } - } + { + if(!state->cancel) /* cancel has not been set already */ + { + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: gass_transfer_request_status: %d", + myname, + req_status); + globus_i_gass_copy_set_error(handle, err); + state->cancel = GLOBUS_I_GASS_COPY_CANCEL_TRUE; + handle->status = GLOBUS_GASS_COPY_STATUS_FAILURE; + } + else + { + globus_mutex_lock(&(state->source.mutex)); + state->source.n_pending--; + globus_mutex_unlock(&(state->source.mutex)); + return; + } + } } /* else (there was an error) */ /*offset = state->source.n_complete * handle->buffer_length; */ @@ -3951,7 +3951,7 @@ globus_l_gass_copy_gass_read_callback( bytes, nbytes, offset, - last_data); + last_data); state->source.n_complete++; } /* globus_l_gass_copy_gass_read_callback() */ @@ -3967,15 +3967,15 @@ globus_l_gass_copy_io_read_callback( globus_object_t * err = GLOBUS_NULL; globus_bool_t last_data=GLOBUS_FALSE; globus_gass_copy_handle_t * handle - = (globus_gass_copy_handle_t *) callback_arg; + = (globus_gass_copy_handle_t *) callback_arg; globus_gass_copy_state_t * state = handle->state; #ifdef GLOBUS_I_GASS_COPY_DEBUG if(result== GLOBUS_SUCCESS) - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, "io_read_callback(): result == GLOBUS_SUCCESS\n"); else - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, "io_read_callback(): result != GLOBUS_SUCCESS\n"); globus_libc_fprintf(stderr, @@ -3993,41 +3993,41 @@ globus_l_gass_copy_io_read_callback( if(result != GLOBUS_SUCCESS) { - err = globus_error_peek(result); - last_data=globus_io_eof(err); + err = globus_error_peek(result); + last_data=globus_io_eof(err); #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, "io_read_callback(): last_data == %d\n", last_data); #endif - if(last_data) - { /* this was the last read. set READ_COMPLETE */ - /* - globus_mutex_lock(&(state->source.mutex)); - { - state->source.status = GLOBUS_I_GASS_COPY_TARGET_DONE; - } - globus_mutex_unlock(&(state->source.mutex)); - */ - handle->status = GLOBUS_GASS_COPY_STATUS_READ_COMPLETE; + if(last_data) + { /* this was the last read. set READ_COMPLETE */ + /* + globus_mutex_lock(&(state->source.mutex)); + { + state->source.status = GLOBUS_I_GASS_COPY_TARGET_DONE; + } + globus_mutex_unlock(&(state->source.mutex)); + */ + handle->status = GLOBUS_GASS_COPY_STATUS_READ_COMPLETE; #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, "io_read_callback(): this was the last READ, source.status == GLOBUS_I_GASS_COPY_TARGET_DONE\n"); + globus_libc_fprintf(stderr, "io_read_callback(): this was the last READ, source.status == GLOBUS_I_GASS_COPY_TARGET_DONE\n"); #endif - if(state->source.data.io.free_handle) - { - globus_io_close(io_handle); + if(state->source.data.io.free_handle) + { + globus_io_close(io_handle); #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, "io_read_callback(): handle closed\n"); #endif - /* thinking that this should go in the + /* thinking that this should go in the * globus_l_gass_copy_state_free() - * globus_libc_free(handle); - */ - } - }/* if(last_data) */ - else /* there was an error */ - { + * globus_libc_free(handle); + */ + } + }/* if(last_data) */ + else /* there was an error */ + { if(!state->cancel) /* cancel has not been set already */ { globus_i_gass_copy_set_error(handle, err); @@ -4041,7 +4041,7 @@ globus_l_gass_copy_io_read_callback( globus_mutex_unlock(&(state->source.mutex)); return; } - } /* else (there was an error) */ + } /* else (there was an error) */ } /* cast to 64 bits if available, otherwise bad things happen */ @@ -4053,7 +4053,7 @@ globus_l_gass_copy_io_read_callback( bytes, nbytes, offset, - last_data); + last_data); state->source.n_complete++; } /* globus_l_gass_copy_io_read_callback() */ @@ -4088,11 +4088,11 @@ globus_l_gass_copy_generic_write_callback( if(state->cancel == GLOBUS_I_GASS_COPY_CANCEL_TRUE) { #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, "generic_write_callback(): there was an error\n"); #endif globus_gass_copy_cancel(handle, NULL, NULL); - return; + return; } @@ -4103,24 +4103,24 @@ globus_l_gass_copy_generic_write_callback( /* push the buffer on the read queue and start another read */ buffer_entry = (globus_i_gass_copy_buffer_t *) - globus_libc_malloc(sizeof(globus_i_gass_copy_buffer_t)); + globus_libc_malloc(sizeof(globus_i_gass_copy_buffer_t)); if(buffer_entry == GLOBUS_NULL) { - /* out of memory error */ - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: failed to malloc a buffer structure successfully", - myname); - globus_i_gass_copy_set_error(handle, err); + /* out of memory error */ + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: failed to malloc a buffer structure successfully", + myname); + globus_i_gass_copy_set_error(handle, err); #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, "generic_write_callback(): malloc failed\n"); #endif globus_gass_copy_cancel(handle, NULL, NULL); - return; + return; } buffer_entry->bytes = bytes; @@ -4132,10 +4132,10 @@ globus_l_gass_copy_generic_write_callback( "generic_write_callback(): calling read_from_queue()\n"); #endif if(handle->state->active) - globus_l_gass_copy_read_from_queue(handle); + globus_l_gass_copy_read_from_queue(handle); #ifdef GLOBUS_I_GASS_COPY_DEBUG else - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, "generic_write_callback(): handle->state == GLOBUS_NULL\n"); #endif @@ -4145,10 +4145,10 @@ globus_l_gass_copy_generic_write_callback( "generic_write_callback(): calling write_from_queue()\n"); #endif if(handle->state->active) - globus_l_gass_copy_write_from_queue(handle); + globus_l_gass_copy_write_from_queue(handle); #ifdef GLOBUS_I_GASS_COPY_DEBUG else - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, "generic_write_callback(): handle->state == GLOBUS_NULL\n"); #endif @@ -4182,33 +4182,33 @@ typedef struct * @ingroup globus_gass_copy * @details * @param callback_arg - * Paramter expected to contain a globus_l_gass_cksm_info_t updated by + * Paramter expected to contain a globus_l_gass_cksm_info_t updated by * globus_gass_copy_cksm_async(). * @param handle * Unused handle to globus_gass_copy_handle_t * @param error - * Indicates an error from globus_gass_copy_cksm_async(), will be NULL if + * Indicates an error from globus_gass_copy_cksm_async(), will be NULL if * no error occurred. * * @return - * This function does not directly return a value, however it does - * signal the calling function to indicate the asynchronous checksum - * has completed. This signifies that the checksum is accessable + * This function does not directly return a value, however it does + * signal the calling function to indicate the asynchronous checksum + * has completed. This signifies that the checksum is accessable * through the "checksum" member (or it's NULL if there was an error) * @see globus_gass_copy_cksm_async() */ -static +static void globus_l_gass_cksm_cb( void * callback_arg, globus_gass_copy_handle_t * handle, globus_object_t * error) -{ +{ globus_l_gass_cksm_info_t * cksm_info; cksm_info = (globus_l_gass_cksm_info_t *) callback_arg; #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr,"%s: %s() callback_arg %p\n\n", + globus_libc_fprintf(stderr,"%s: %s() callback_arg %p\n\n", __FILE__, __func__, callback_arg); #endif if(error) @@ -4222,7 +4222,7 @@ globus_l_gass_cksm_cb( cksm_info->done = GLOBUS_TRUE; globus_cond_signal(&cksm_info->monitor->cond); } - globus_mutex_unlock(&cksm_info->monitor->mutex); + globus_mutex_unlock(&cksm_info->monitor->mutex); #ifdef GLOBUS_I_GASS_COPY_DEBUG globus_libc_fprintf(stderr,"\n\n%s: %s() checksum is %s\n\n", __FILE__, __func__, cksm_info->urlinfo->checksum); #endif @@ -4237,13 +4237,13 @@ globus_l_gass_cksm_cb( * @param copy_handle * The handle used to perform access the file for the checksum operation. * @param cksm_attr - * Attributes describing the connection used to access the file for the + * Attributes describing the connection used to access the file for the * checksum operation. * @param url * The URL to the destination file to be checksummed. * * @return - * This function returns GLOBUS_SUCCESS if the checksum on the source + * This function returns GLOBUS_SUCCESS if the checksum on the source * and destination files match, or a result pointing to an * object of one of the the following error types: * @retval GLOBUS_GASS_COPY_ERROR_TYPE_NULL_PARAMETER @@ -4252,7 +4252,7 @@ globus_l_gass_cksm_cb( * * @see globus_gass_copy_url_to_handle() globus_gass_copy_handle_to_url() */ -static +static globus_result_t globus_l_gass_copy_verify_cksm( globus_gass_copy_handle_t * copy_handle, @@ -4304,10 +4304,10 @@ globus_l_gass_copy_verify_cksm( globus_mutex_lock(&cksm_monitor.mutex); while(!dst_cksm_info.done) { - globus_cond_wait(&cksm_monitor.cond, &cksm_monitor.mutex); + globus_cond_wait(&cksm_monitor.cond, &cksm_monitor.mutex); } globus_mutex_unlock(&cksm_monitor.mutex); - + if(dst_cksm_info.error) { result = globus_error_put(dst_cksm_info.error); @@ -4358,83 +4358,83 @@ globus_l_gass_copy_write_from_queue( while(1) { - do_the_write = GLOBUS_FALSE; + do_the_write = GLOBUS_FALSE; - globus_mutex_lock(&(state->dest.mutex)); - { - if(state->dest.status == GLOBUS_I_GASS_COPY_TARGET_READY) - { /* if the dest is READY (and not DONE), see if we should + globus_mutex_lock(&(state->dest.mutex)); + { + if(state->dest.status == GLOBUS_I_GASS_COPY_TARGET_READY) + { /* if the dest is READY (and not DONE), see if we should * register a write */ #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, "write_from_queue(): dest.status == TARGET_READY, n_pending= %d, n_simultaneous= %d\n", state->dest.n_pending, state->dest.n_simultaneous); + globus_libc_fprintf(stderr, "write_from_queue(): dest.status == TARGET_READY, n_pending= %d, n_simultaneous= %d\n", state->dest.n_pending, state->dest.n_simultaneous); #endif - if((state->dest.n_pending < - state->dest.n_simultaneous) && - !state->cancel) - { /* if there aren't too many writes outstanding, and we + if((state->dest.n_pending < + state->dest.n_simultaneous) && + !state->cancel) + { /* if there aren't too many writes outstanding, and we * haven't canceled */ #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, "write_from_queue: gonna check the queue\n"); #endif - if ((buffer_entry=globus_fifo_dequeue(&(state->dest.queue))) - != GLOBUS_NULL) - { - state->dest.n_pending++; - do_the_write = GLOBUS_TRUE; + if ((buffer_entry=globus_fifo_dequeue(&(state->dest.queue))) + != GLOBUS_NULL) + { + state->dest.n_pending++; + do_the_write = GLOBUS_TRUE; #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, "write_from_queue: got a buffer from the queue\n"); #endif - }/* if (buffer_entry != GLOBUS_NULL), there is a buffer + }/* if (buffer_entry != GLOBUS_NULL), there is a buffer * in the write queue */ - else - { + else + { #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, "write_from_queue: NO buffers in the queue\n"); #endif - } - } /* (n_pending < n_simulatneous) && !cancel */ - } /* if(state->dest.status == GLOBUS_I_GASS_COPY_TARGET_READY) */ - } /* lock state->dest */ - globus_mutex_unlock(&(state->dest.mutex)); + } + } /* (n_pending < n_simulatneous) && !cancel */ + } /* if(state->dest.status == GLOBUS_I_GASS_COPY_TARGET_READY) */ + } /* lock state->dest */ + globus_mutex_unlock(&(state->dest.mutex)); #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, "write_from_queue: unlocking the dest mutex\n"); #endif - if(do_the_write) - { + if(do_the_write) + { #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, "write_from_queue(): about to call register_write()\n"); - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, "\t\t\t nbytes= %d, offset= %"GLOBUS_OFF_T_FORMAT", last_data= %d\n", buffer_entry->nbytes, - buffer_entry->offset, - buffer_entry->last_data); + buffer_entry->offset, + buffer_entry->last_data); #endif - result = globus_l_gass_copy_register_write( - handle, - buffer_entry); + result = globus_l_gass_copy_register_write( + handle, + buffer_entry); - if (result != GLOBUS_SUCCESS) - { - state->cancel = GLOBUS_I_GASS_COPY_CANCEL_TRUE; + if (result != GLOBUS_SUCCESS) + { + state->cancel = GLOBUS_I_GASS_COPY_CANCEL_TRUE; #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, "write_from_queue(): there was an ERROR trying to register a write, call cancel\n"); + globus_libc_fprintf(stderr, "write_from_queue(): there was an ERROR trying to register a write, call cancel\n"); #endif globus_i_gass_copy_set_error_from_result(handle, result); globus_gass_copy_cancel(handle, NULL, NULL); return; - } - } /* if(do_the_write) */ - else - break; + } + } /* if(do_the_write) */ + else + break; } /* while(1) */ /* if there are no writes to do, and no writes pending, clean up and call @@ -4443,25 +4443,25 @@ globus_l_gass_copy_write_from_queue( if(handle->state->active) { globus_mutex_lock(&state->mutex); - + if(state->source.status == GLOBUS_I_GASS_COPY_TARGET_DONE && state->dest.status == GLOBUS_I_GASS_COPY_TARGET_DONE && state->dest.n_pending == 0 && state->source.n_pending == 0 && - (state->dest.mode != GLOBUS_GASS_COPY_URL_MODE_FTP || + (state->dest.mode != GLOBUS_GASS_COPY_URL_MODE_FTP || state->dest.data.ftp.completed) && - (state->source.mode != GLOBUS_GASS_COPY_URL_MODE_FTP || + (state->source.mode != GLOBUS_GASS_COPY_URL_MODE_FTP || state->source.data.ftp.completed) && handle->status != GLOBUS_GASS_COPY_STATUS_DONE) { globus_gass_copy_callback_t callback; - + #ifdef GLOBUS_I_GASS_COPY_DEBUG globus_libc_fprintf(stderr, "write_from_queue(): source and dest status == TARGET_DONE\n"); #endif handle->status = GLOBUS_GASS_COPY_STATUS_DONE; /* do cleanup */ - + if(handle->performance) { if(state->dest.mode == GLOBUS_GASS_COPY_URL_MODE_FTP) @@ -4473,7 +4473,7 @@ globus_l_gass_copy_write_from_queue( globus_l_gass_copy_perf_cancel_local_callback(handle->performance); } } - + #ifdef GLOBUS_I_GASS_COPY_DEBUG if(!handle->state->active) globus_libc_fprintf(stderr, " handle->state == GLOBUS_NULL\n"); @@ -4482,7 +4482,7 @@ globus_l_gass_copy_write_from_queue( #endif err = handle->err; handle->err = GLOBUS_NULL; - + /* set the final status of the transfer */ switch(handle->status) { @@ -4496,17 +4496,17 @@ globus_l_gass_copy_write_from_queue( handle->status = GLOBUS_GASS_COPY_STATUS_DONE_CANCELLED; break; default: - break; + break; } /* checksum verify */ - if(handle->status == GLOBUS_GASS_COPY_STATUS_DONE_SUCCESS && err == GLOBUS_NULL && + if(handle->status == GLOBUS_GASS_COPY_STATUS_DONE_SUCCESS && err == GLOBUS_NULL && handle->state->cksm_handle != GLOBUS_NULL && handle->state->checksum != GLOBUS_NULL) { globus_assert_string(state->dest.free_attr != GLOBUS_TRUE, "Checksum verification requires ftp attributes."); result = globus_l_gass_copy_verify_cksm( handle, state->dest.attr, state->dest.url); - if(result != GLOBUS_SUCCESS) + if(result != GLOBUS_SUCCESS) { err = globus_error_get(result); handle->status = GLOBUS_GASS_COPY_STATUS_DONE_FAILURE; @@ -4559,18 +4559,18 @@ globus_l_gass_copy_register_write( switch (state->dest.mode) { case GLOBUS_GASS_COPY_URL_MODE_FTP: - /* check the offset to see if its what we are expecting */ + /* check the offset to see if its what we are expecting */ #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, "register_write(): calling globus_ftp_client_register_write()\n"); - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, "\t\t\t nbytes= %d, offset= %"GLOBUS_OFF_T_FORMAT", last_data= %d\n", buffer_entry->nbytes, - buffer_entry->offset, - buffer_entry->last_data); + buffer_entry->offset, + buffer_entry->last_data); #endif - if(handle->partial_offset != -1 && + if(handle->partial_offset != -1 && state->source.mode != GLOBUS_GASS_COPY_URL_MODE_FTP) { tmp_offset = buffer_entry->offset + handle->partial_offset; @@ -4587,67 +4587,67 @@ globus_l_gass_copy_register_write( buffer_entry->last_data, globus_l_gass_copy_ftp_write_callback, (void *) handle); - - break; + + break; case GLOBUS_GASS_COPY_URL_MODE_GASS: #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, "register_write(): send_bytes -- %d bytes (last_data==%d)\n", buffer_entry->nbytes, buffer_entry->last_data); #endif - /* check the offset to see if its what we are expecting */ - rc = globus_gass_transfer_send_bytes( - state->dest.data.gass.request, - buffer_entry->bytes, - buffer_entry->nbytes, - buffer_entry->last_data, - globus_l_gass_copy_gass_write_callback, - (void *) handle); - - if (rc != GLOBUS_SUCCESS) - { - /* figure out what the error is, and pass it back through the + /* check the offset to see if its what we are expecting */ + rc = globus_gass_transfer_send_bytes( + state->dest.data.gass.request, + buffer_entry->bytes, + buffer_entry->nbytes, + buffer_entry->last_data, + globus_l_gass_copy_gass_write_callback, + (void *) handle); + + if (rc != GLOBUS_SUCCESS) + { + /* figure out what the error is, and pass it back through the * result */ - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: globus_gass_transfer_send_bytes returned error code: %d", - myname, - rc); - globus_i_gass_copy_set_error(handle, err); - result = globus_error_put(err); - } - else result = GLOBUS_SUCCESS; - - break; + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: globus_gass_transfer_send_bytes returned error code: %d", + myname, + rc); + globus_i_gass_copy_set_error(handle, err); + result = globus_error_put(err); + } + else result = GLOBUS_SUCCESS; + + break; case GLOBUS_GASS_COPY_URL_MODE_IO: - if (state->dest.data.io.seekable && - state->source.mode == GLOBUS_GASS_COPY_URL_MODE_FTP) - { - result = globus_io_file_seek( - state->dest.data.io.handle, - buffer_entry->offset, - GLOBUS_IO_SEEK_SET); - } - - if(result == GLOBUS_SUCCESS) - { - result = globus_io_register_write( - state->dest.data.io.handle, - buffer_entry->bytes, - buffer_entry->nbytes, - globus_l_gass_copy_io_write_callback, - (void *) handle); - } - - break; + if (state->dest.data.io.seekable && + state->source.mode == GLOBUS_GASS_COPY_URL_MODE_FTP) + { + result = globus_io_file_seek( + state->dest.data.io.handle, + buffer_entry->offset, + GLOBUS_IO_SEEK_SET); + } + + if(result == GLOBUS_SUCCESS) + { + result = globus_io_register_write( + state->dest.data.io.handle, + buffer_entry->bytes, + buffer_entry->nbytes, + globus_l_gass_copy_io_write_callback, + (void *) handle); + } + + break; default: - break; + break; }/* switch (state->dest.mode) */ globus_libc_free(buffer_entry); @@ -4663,61 +4663,61 @@ globus_l_gass_copy_ftp_write_callback( globus_byte_t * bytes, globus_size_t nbytes, globus_off_t offset, - globus_bool_t eof) + globus_bool_t eof) { globus_gass_copy_handle_t * copy_handle - = (globus_gass_copy_handle_t *) callback_arg; + = (globus_gass_copy_handle_t *) callback_arg; globus_gass_copy_state_t * state = copy_handle->state; #ifdef GLOBUS_I_GASS_COPY_DEBUG globus_libc_fprintf(stderr, "ftp_write_callback(): has been called, nbytes: %d, offset= %"GLOBUS_OFF_T_FORMAT", eof= %d\n", - nbytes, offset, eof); + nbytes, offset, eof); #endif if(error == GLOBUS_SUCCESS) /* no error occurred */ { - if(eof) - { + if(eof) + { #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, - "ftp_write_callback(): about to set dest TARGET_DONE, nbytes: %d, offset= %"GLOBUS_OFF_T_FORMAT", eof= %d\n", - nbytes, offset, eof); + globus_libc_fprintf(stderr, + "ftp_write_callback(): about to set dest TARGET_DONE, nbytes: %d, offset= %"GLOBUS_OFF_T_FORMAT", eof= %d\n", + nbytes, offset, eof); #endif - globus_mutex_lock(&(state->dest.mutex)); - { - state->dest.status = GLOBUS_I_GASS_COPY_TARGET_DONE; - } - globus_mutex_unlock(&(state->dest.mutex)); - if((copy_handle->status != GLOBUS_GASS_COPY_STATUS_FAILURE) && - (copy_handle->status < GLOBUS_GASS_COPY_STATUS_WRITE_COMPLETE)) - copy_handle->status = GLOBUS_GASS_COPY_STATUS_WRITE_COMPLETE; - } + globus_mutex_lock(&(state->dest.mutex)); + { + state->dest.status = GLOBUS_I_GASS_COPY_TARGET_DONE; + } + globus_mutex_unlock(&(state->dest.mutex)); + if((copy_handle->status != GLOBUS_GASS_COPY_STATUS_FAILURE) && + (copy_handle->status < GLOBUS_GASS_COPY_STATUS_WRITE_COMPLETE)) + copy_handle->status = GLOBUS_GASS_COPY_STATUS_WRITE_COMPLETE; + } } else /* there was an error */ { - { - if(!state->cancel) /* cancel has not been set already */ - { + { + if(!state->cancel) /* cancel has not been set already */ + { #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, "ftp_write_callback(): there was an ERROR, throw cancel flag\n"); + globus_libc_fprintf(stderr, "ftp_write_callback(): there was an ERROR, throw cancel flag\n"); #endif - globus_i_gass_copy_set_error(copy_handle, error); - state->cancel = GLOBUS_I_GASS_COPY_CANCEL_TRUE; - copy_handle->status = GLOBUS_GASS_COPY_STATUS_FAILURE; + globus_i_gass_copy_set_error(copy_handle, error); + state->cancel = GLOBUS_I_GASS_COPY_CANCEL_TRUE; + copy_handle->status = GLOBUS_GASS_COPY_STATUS_FAILURE; state->dest.data.ftp.data_err = copy_handle->err; - } - else - { - globus_mutex_lock(&(state->dest.mutex)); - state->dest.n_pending--; - globus_mutex_unlock(&(state->dest.mutex)); - return; - } + } + else + { + globus_mutex_lock(&(state->dest.mutex)); + state->dest.n_pending--; + globus_mutex_unlock(&(state->dest.mutex)); + return; + } - } + } } /* else (there was an error) */ globus_l_gass_copy_generic_write_callback( @@ -4741,7 +4741,7 @@ globus_l_gass_copy_gass_write_callback( static char * myname="globus_l_gass_copy_gass_write_callback"; globus_gass_copy_handle_t * handle - = (globus_gass_copy_handle_t *) callback_arg; + = (globus_gass_copy_handle_t *) callback_arg; globus_gass_copy_state_t * state = handle->state; req_status = globus_gass_transfer_request_get_status(request); @@ -4754,59 +4754,59 @@ globus_l_gass_copy_gass_write_callback( if(req_status == GLOBUS_GASS_TRANSFER_REQUEST_DONE || req_status == GLOBUS_GASS_TRANSFER_REQUEST_PENDING) { /* all is well */ - if(last_data) - { /* this was the last write. set WRITE_COMPLETE and free the request */ + if(last_data) + { /* this was the last write. set WRITE_COMPLETE and free the request */ #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, "gass_write_callback(): THIS WAS THE LAST WRITE\n"); #endif - globus_mutex_lock(&(state->dest.mutex)); - { - state->dest.status = GLOBUS_I_GASS_COPY_TARGET_DONE; - } - globus_mutex_unlock(&(state->dest.mutex)); - handle->status = GLOBUS_GASS_COPY_STATUS_WRITE_COMPLETE; + globus_mutex_lock(&(state->dest.mutex)); + { + state->dest.status = GLOBUS_I_GASS_COPY_TARGET_DONE; + } + globus_mutex_unlock(&(state->dest.mutex)); + handle->status = GLOBUS_GASS_COPY_STATUS_WRITE_COMPLETE; - if(req_status == GLOBUS_GASS_TRANSFER_REQUEST_DONE) - { + if(req_status == GLOBUS_GASS_TRANSFER_REQUEST_DONE) + { #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, "gass_write_callback(): GLOBUS_GASS_TRANSFER_REQUEST_DONE\n"); #endif - globus_gass_transfer_request_destroy(request); - } - else - { - /* there's an error, tell someone who cares */ + globus_gass_transfer_request_destroy(request); + } + else + { + /* there's an error, tell someone who cares */ #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, "gass_write_callback(): this was last_data, but status !=GLOBUS_GASS_TRANSFER_REQUEST_DONE\n"); + globus_libc_fprintf(stderr, "gass_write_callback(): this was last_data, but status !=GLOBUS_GASS_TRANSFER_REQUEST_DONE\n"); #endif - } - } /* if (last_data) */ + } + } /* if (last_data) */ } /*all is well */ else { /* all is NOT well, deal with error */ - { - if(!state->cancel) /* cancel has not been set already */ - { - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: gass_transfer_request_status: %d", - myname, - req_status); - globus_i_gass_copy_set_error(handle, err); - state->cancel = GLOBUS_I_GASS_COPY_CANCEL_TRUE; - handle->status = GLOBUS_GASS_COPY_STATUS_FAILURE; - } - else - { - globus_mutex_lock(&(state->dest.mutex)); - state->dest.n_pending--; - globus_mutex_unlock(&(state->dest.mutex)); - return; - } - } + { + if(!state->cancel) /* cancel has not been set already */ + { + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: gass_transfer_request_status: %d", + myname, + req_status); + globus_i_gass_copy_set_error(handle, err); + state->cancel = GLOBUS_I_GASS_COPY_CANCEL_TRUE; + handle->status = GLOBUS_GASS_COPY_STATUS_FAILURE; + } + else + { + globus_mutex_lock(&(state->dest.mutex)); + state->dest.n_pending--; + globus_mutex_unlock(&(state->dest.mutex)); + return; + } + } } /* else (there was an error) */ globus_l_gass_copy_generic_write_callback( @@ -4825,96 +4825,96 @@ globus_l_gass_copy_io_write_callback( globus_size_t nbytes) { globus_gass_copy_handle_t * handle - = (globus_gass_copy_handle_t *) callback_arg; + = (globus_gass_copy_handle_t *) callback_arg; globus_gass_copy_state_t * state = handle->state; globus_bool_t close_handle = GLOBUS_FALSE; - + /* * used this to simulate a io write error * globus_object_t * err; err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[STU]: STU, forcing io write callback fault"); + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[STU]: STU, forcing io write callback fault"); result=globus_error_put(err); */ if(result==GLOBUS_SUCCESS) { #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, "io_write_callback(): result == GLOBUS_SUCCESS\n"); #endif - globus_mutex_lock(&(state->source.mutex)); - { - if(state->source.status == GLOBUS_I_GASS_COPY_TARGET_DONE && - state->source.n_pending == 0) - { + globus_mutex_lock(&(state->source.mutex)); + { + if(state->source.status == GLOBUS_I_GASS_COPY_TARGET_DONE && + state->source.n_pending == 0) + { #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, "io_write_callback(): THIS WAS THE LAST WRITE\n"); #endif - globus_mutex_lock(&(state->dest.mutex)); - { - if(globus_fifo_empty(&(state->dest.queue))) - { - state->dest.status = GLOBUS_I_GASS_COPY_TARGET_DONE; + globus_mutex_lock(&(state->dest.mutex)); + { + if(globus_fifo_empty(&(state->dest.queue))) + { + state->dest.status = GLOBUS_I_GASS_COPY_TARGET_DONE; - handle->status = GLOBUS_GASS_COPY_STATUS_WRITE_COMPLETE; + handle->status = GLOBUS_GASS_COPY_STATUS_WRITE_COMPLETE; - if(state->dest.data.io.free_handle) - { - close_handle = GLOBUS_TRUE; + if(state->dest.data.io.free_handle) + { + close_handle = GLOBUS_TRUE; #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, "io_write_callback(): handle closed\n"); #endif - } /* if(state->dest.data.io.free_handle) */ - } /* if write queue is empty */ - } - globus_mutex_unlock(&(state->dest.mutex)); + } /* if(state->dest.data.io.free_handle) */ + } /* if write queue is empty */ + } + globus_mutex_unlock(&(state->dest.mutex)); + + } /* end if last write */ + } + globus_mutex_unlock(&(state->source.mutex)); - } /* end if last write */ - } - globus_mutex_unlock(&(state->source.mutex)); - - if(close_handle) - { - globus_io_close(io_handle); - } + if(close_handle) + { + globus_io_close(io_handle); + } } else /* there was an error */ { #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, "io_write_callback(): result != GLOBUS_SUCCESS\n"); #endif - { - if(!state->cancel) /* cancel has not been set already */ - { + { + if(!state->cancel) /* cancel has not been set already */ + { #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, "io_write_callback(): cancel has not been set\n"); #endif - globus_i_gass_copy_set_error_from_result(handle, result); - state->cancel = GLOBUS_I_GASS_COPY_CANCEL_TRUE; - handle->status = GLOBUS_GASS_COPY_STATUS_FAILURE; - } - else - { + globus_i_gass_copy_set_error_from_result(handle, result); + state->cancel = GLOBUS_I_GASS_COPY_CANCEL_TRUE; + handle->status = GLOBUS_GASS_COPY_STATUS_FAILURE; + } + else + { #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, "io_write_callback(): cancel has already been set\n"); #endif - globus_mutex_lock(&(state->dest.mutex)); - state->dest.n_pending--; - globus_mutex_unlock(&(state->dest.mutex)); - return; - } - } + globus_mutex_lock(&(state->dest.mutex)); + state->dest.n_pending--; + globus_mutex_unlock(&(state->dest.mutex)); + return; + } + } } /* else (there was an error) */ globus_l_gass_copy_generic_write_callback( @@ -4932,7 +4932,7 @@ globus_l_gass_copy_io_write_callback( /** * @brief Blocking Transfer between URLs - * @ingroup globus_gass_transfer + * @ingroup globus_gass_copy * @details * @param handle * The handle to perform the copy operation @@ -4974,18 +4974,18 @@ globus_gass_copy_url_to_url( if(handle == GLOBUS_NULL) { - bad_param = 1; - goto error_exit; + bad_param = 1; + goto error_exit; } if(source_url == GLOBUS_NULL) { - bad_param = 2; - goto error_exit; + bad_param = 2; + goto error_exit; } if(dest_url == GLOBUS_NULL) { - bad_param = 4; - goto error_exit; + bad_param = 4; + goto error_exit; } /* return an error if a transfer is already in progress */ @@ -4993,10 +4993,10 @@ globus_gass_copy_url_to_url( handle->status < GLOBUS_GASS_COPY_STATUS_DONE_SUCCESS) { err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: There is a transfer already active on this handle", - myname); + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: There is a transfer already active on this handle", + myname); return globus_error_put(err); } @@ -5007,20 +5007,20 @@ globus_gass_copy_url_to_url( monitor.use_err = GLOBUS_FALSE; result = globus_gass_copy_register_url_to_url( - handle, - source_url, - source_attr, - dest_url, - dest_attr, - globus_l_gass_copy_monitor_callback, - (void *) &monitor); + handle, + source_url, + source_attr, + dest_url, + dest_attr, + globus_l_gass_copy_monitor_callback, + (void *) &monitor); if(result != GLOBUS_SUCCESS) { - globus_mutex_destroy(&monitor.mutex); - globus_cond_destroy(&monitor.cond); - handle->status = GLOBUS_GASS_COPY_STATUS_DONE_FAILURE; - return(result); + globus_mutex_destroy(&monitor.mutex); + globus_cond_destroy(&monitor.cond); + handle->status = GLOBUS_GASS_COPY_STATUS_DONE_FAILURE; + return(result); } /* wait on cond_wait() for completion */ globus_mutex_lock(&monitor.mutex); @@ -5048,14 +5048,14 @@ globus_gass_copy_url_to_url( error_exit: err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: BAD_PARAMETER, argument %d cannot be NULL", - myname, - bad_param); + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: BAD_PARAMETER, argument %d cannot be NULL", + myname, + bad_param); if(handle) - handle->status = GLOBUS_GASS_COPY_STATUS_DONE_FAILURE; + handle->status = GLOBUS_GASS_COPY_STATUS_DONE_FAILURE; return globus_error_put(err); @@ -5069,7 +5069,7 @@ globus_gass_copy_url_to_url( /** * @brief Blocking Transfer from an URL to an IO handle - * @ingroup globus_gass_transfer + * @ingroup globus_gass_copy * @details * @param handle * The handle to perform the copy operation @@ -5109,18 +5109,18 @@ globus_gass_copy_url_to_handle( /* Check arguments for validity */ if(handle == GLOBUS_NULL) { - bad_param=1; - goto error_exit; + bad_param=1; + goto error_exit; } if(source_url == GLOBUS_NULL) { - bad_param=2; - goto error_exit; + bad_param=2; + goto error_exit; } if(dest_handle == GLOBUS_NULL) { - bad_param=4; - goto error_exit; + bad_param=4; + goto error_exit; } /* return an error if a transfer is already in progress */ @@ -5128,10 +5128,10 @@ globus_gass_copy_url_to_handle( handle->status < GLOBUS_GASS_COPY_STATUS_DONE_SUCCESS) { err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: There is a transfer already active on this handle", - myname); + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: There is a transfer already active on this handle", + myname); return globus_error_put(err); } @@ -5142,19 +5142,19 @@ globus_gass_copy_url_to_handle( monitor.use_err = GLOBUS_FALSE; result = globus_gass_copy_register_url_to_handle( - handle, - source_url, - source_attr, - dest_handle, - globus_l_gass_copy_monitor_callback, - (void *) &monitor); + handle, + source_url, + source_attr, + dest_handle, + globus_l_gass_copy_monitor_callback, + (void *) &monitor); if(result != GLOBUS_SUCCESS) { - globus_mutex_destroy(&monitor.mutex); - globus_cond_destroy(&monitor.cond); - handle->status = GLOBUS_GASS_COPY_STATUS_DONE_FAILURE; - return(result); + globus_mutex_destroy(&monitor.mutex); + globus_cond_destroy(&monitor.cond); + handle->status = GLOBUS_GASS_COPY_STATUS_DONE_FAILURE; + return(result); } /* wait on cond_wait() for completion */ @@ -5162,7 +5162,7 @@ globus_gass_copy_url_to_handle( while(!monitor.done) { - globus_cond_wait(&monitor.cond, &monitor.mutex); + globus_cond_wait(&monitor.cond, &monitor.mutex); } globus_mutex_unlock(&monitor.mutex); @@ -5184,14 +5184,14 @@ globus_gass_copy_url_to_handle( error_exit: err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: BAD_PARAMETER, argument %d cannot be NULL", - myname, - bad_param); + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: BAD_PARAMETER, argument %d cannot be NULL", + myname, + bad_param); if(handle) - handle->status = GLOBUS_GASS_COPY_STATUS_DONE_FAILURE; + handle->status = GLOBUS_GASS_COPY_STATUS_DONE_FAILURE; return globus_error_put(err); } /* globus_gass_copy_url_to_handle() */ @@ -5199,7 +5199,7 @@ globus_gass_copy_url_to_handle( /** * @brief Blocking transfer from an IO handle to an URL - * @ingroup globus_gass_transfer + * @ingroup globus_gass_copy * @details * @param handle * The handle to perform the copy operation @@ -5241,18 +5241,18 @@ globus_gass_copy_handle_to_url( /* Check arguments for validity */ if(handle == GLOBUS_NULL) { - bad_param=1; - goto error_exit; + bad_param=1; + goto error_exit; } if(source_handle == GLOBUS_NULL) { - bad_param=2; - goto error_exit; + bad_param=2; + goto error_exit; } if(dest_url == GLOBUS_NULL) { - bad_param=3; - goto error_exit; + bad_param=3; + goto error_exit; } /* return an error if a transfer is already in progress */ @@ -5260,10 +5260,10 @@ globus_gass_copy_handle_to_url( handle->status < GLOBUS_GASS_COPY_STATUS_DONE_SUCCESS) { err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: There is a transfer already active on this handle", - myname); + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: There is a transfer already active on this handle", + myname); return globus_error_put(err); } @@ -5274,26 +5274,26 @@ globus_gass_copy_handle_to_url( monitor.use_err = GLOBUS_FALSE; result = globus_gass_copy_register_handle_to_url( - handle, - source_handle, - dest_url, - dest_attr, - globus_l_gass_copy_monitor_callback, - (void *) &monitor); + handle, + source_handle, + dest_url, + dest_attr, + globus_l_gass_copy_monitor_callback, + (void *) &monitor); if(result != GLOBUS_SUCCESS) { - globus_mutex_destroy(&monitor.mutex); - globus_cond_destroy(&monitor.cond); - handle->status = GLOBUS_GASS_COPY_STATUS_DONE_FAILURE; - return(result); + globus_mutex_destroy(&monitor.mutex); + globus_cond_destroy(&monitor.cond); + handle->status = GLOBUS_GASS_COPY_STATUS_DONE_FAILURE; + return(result); } /* wait on cond_wait() for completion */ globus_mutex_lock(&monitor.mutex); while(!monitor.done) { - globus_cond_wait(&monitor.cond, &monitor.mutex); + globus_cond_wait(&monitor.cond, &monitor.mutex); } globus_mutex_unlock(&monitor.mutex); @@ -5305,24 +5305,24 @@ globus_gass_copy_handle_to_url( if(monitor.use_err) { - return globus_error_put(monitor.err); + return globus_error_put(monitor.err); } else { - return GLOBUS_SUCCESS; + return GLOBUS_SUCCESS; } error_exit: err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: BAD_PARAMETER, argument %d cannot be NULL", - myname, - bad_param); + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: BAD_PARAMETER, argument %d cannot be NULL", + myname, + bad_param); if(handle) - handle->status = GLOBUS_GASS_COPY_STATUS_DONE_FAILURE; + handle->status = GLOBUS_GASS_COPY_STATUS_DONE_FAILURE; return globus_error_put(err); @@ -5334,7 +5334,7 @@ globus_gass_copy_handle_to_url( /** * Nonblocking Transfer between URLs - * @ingroup globus_gass_transfer + * @ingroup globus_gass_copy * @details * This functions initiates a transfer from source URL to destination URL, * then returns immediately. @@ -5394,29 +5394,29 @@ globus_gass_copy_register_url_to_url( if(handle == GLOBUS_NULL) { #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, "register_url_to_url(): handle was GLOBUS_NULL\n"); #endif - bad_param = 1; - goto error_exit; + bad_param = 1; + goto error_exit; } if(source_url == GLOBUS_NULL) { #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, "register_url_to_url(): source_url was GLOBUS_NULL\n"); #endif - bad_param = 2; - goto error_exit; + bad_param = 2; + goto error_exit; } if(dest_url == GLOBUS_NULL) { #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, "register_url_to_url(): dest_url was GLOBUS_NULL\n"); #endif - bad_param = 4; - goto error_exit; + bad_param = 4; + goto error_exit; } /* return an error if a transfer is already in progress */ @@ -5424,47 +5424,47 @@ globus_gass_copy_register_url_to_url( handle->status < GLOBUS_GASS_COPY_STATUS_DONE_SUCCESS) { err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: There is a transfer already active on this handle", - myname); + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: There is a transfer already active on this handle", + myname); return globus_error_put(err); } - + result = globus_gass_copy_get_url_mode( - source_url, - &source_url_mode); + source_url, + &source_url_mode); if(result != GLOBUS_SUCCESS) { #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, "register_url_to_url(): copy_url_mode returned ! GLOBUS_SUCCESS for source_url\n"); + globus_libc_fprintf(stderr, "register_url_to_url(): copy_url_mode returned ! GLOBUS_SUCCESS for source_url\n"); #endif - goto error_result_exit; + goto error_result_exit; } result = globus_gass_copy_get_url_mode( - dest_url, - &dest_url_mode); + dest_url, + &dest_url_mode); if(result != GLOBUS_SUCCESS) { #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, "register_url_to_url(): copy_url_mode returned ! GLOBUS_SUCCESS for dest_url\n"); + globus_libc_fprintf(stderr, "register_url_to_url(): copy_url_mode returned ! GLOBUS_SUCCESS for dest_url\n"); #endif - goto error_result_exit; + goto error_result_exit; } if ( (source_url_mode == GLOBUS_GASS_COPY_URL_MODE_UNSUPPORTED) - || (dest_url_mode == GLOBUS_GASS_COPY_URL_MODE_UNSUPPORTED) ) + || (dest_url_mode == GLOBUS_GASS_COPY_URL_MODE_UNSUPPORTED) ) { - char src_msg[256]; - char dest_msg[256]; + char src_msg[256]; + char dest_msg[256]; #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, "register_url_to_url(): source or dest is URL_MODE_UNSUPPORTED\n"); #endif - if(source_url_mode == GLOBUS_GASS_COPY_URL_MODE_UNSUPPORTED) - { - sprintf(src_msg, " %s, GLOBUS_GASS_COPY_URL_MODE_UNSUPPORTED.", + if(source_url_mode == GLOBUS_GASS_COPY_URL_MODE_UNSUPPORTED) + { + sprintf(src_msg, " %s, GLOBUS_GASS_COPY_URL_MODE_UNSUPPORTED.", source_url); } else @@ -5472,9 +5472,9 @@ globus_gass_copy_register_url_to_url( *src_msg = '\0'; } - if(dest_url_mode == GLOBUS_GASS_COPY_URL_MODE_UNSUPPORTED) - { - sprintf(dest_msg, " %s, GLOBUS_GASS_COPY_URL_MODE_UNSUPPORTED.", + if(dest_url_mode == GLOBUS_GASS_COPY_URL_MODE_UNSUPPORTED) + { + sprintf(dest_msg, " %s, GLOBUS_GASS_COPY_URL_MODE_UNSUPPORTED.", dest_url); } else @@ -5482,16 +5482,16 @@ globus_gass_copy_register_url_to_url( *dest_msg = '\0'; } - handle->status = GLOBUS_GASS_COPY_STATUS_DONE_FAILURE; - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: %s%s", - myname, - src_msg, - dest_msg); + handle->status = GLOBUS_GASS_COPY_STATUS_DONE_FAILURE; + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: %s%s", + myname, + src_msg, + dest_msg); - return globus_error_put(err); + return globus_error_put(err); } /* reinitialize the state for this transfer */ @@ -5505,22 +5505,22 @@ globus_gass_copy_register_url_to_url( handle->callback_arg = callback_arg; result = globus_l_gass_copy_target_populate( - handle, - &(state->source), - &source_url_mode, - source_url, - source_attr); + handle, + &(state->source), + &source_url_mode, + source_url, + source_attr); if(result != GLOBUS_SUCCESS) goto error_result_exit; #ifdef GLOBUS_I_GASS_COPY_DEBUG globus_libc_fprintf(stderr, "source target populated\n"); #endif result = globus_l_gass_copy_target_populate( - handle, - &(state->dest), - &dest_url_mode, - dest_url, - dest_attr); + handle, + &(state->dest), + &dest_url_mode, + dest_url, + dest_attr); if(result != GLOBUS_SUCCESS) goto error_result_exit; #ifdef GLOBUS_I_GASS_COPY_DEBUG @@ -5530,8 +5530,8 @@ globus_gass_copy_register_url_to_url( if(dest_url_mode == GLOBUS_GASS_COPY_URL_MODE_FTP && handle->send_allo) { globus_off_t source_size = 0; - - + + if(handle->partial_end_offset != -1) { source_size = handle->partial_end_offset; @@ -5555,11 +5555,11 @@ globus_gass_copy_register_url_to_url( state->dest.attr->ftp_attr, source_size); } - } - + } + if ( (source_url_mode == GLOBUS_GASS_COPY_URL_MODE_FTP) && - (dest_url_mode == GLOBUS_GASS_COPY_URL_MODE_FTP) && - !handle->no_third_party_transfers ) + (dest_url_mode == GLOBUS_GASS_COPY_URL_MODE_FTP) && + !handle->no_third_party_transfers ) { #ifdef GLOBUS_I_GASS_COPY_DEBUG @@ -5585,16 +5585,16 @@ globus_gass_copy_register_url_to_url( mode != GLOBUS_FTP_CONTROL_MODE_EXTENDED_BLOCK) { new_ftp_attr = (globus_ftp_client_operationattr_t *) - globus_libc_malloc(sizeof(globus_ftp_client_operationattr_t)); + globus_libc_malloc(sizeof(globus_ftp_client_operationattr_t)); - globus_ftp_client_operationattr_copy(new_ftp_attr, - state->dest.attr->ftp_attr); + globus_ftp_client_operationattr_copy(new_ftp_attr, + state->dest.attr->ftp_attr); } } else { new_ftp_attr = (globus_ftp_client_operationattr_t *) - globus_libc_malloc(sizeof(globus_ftp_client_operationattr_t)); + globus_libc_malloc(sizeof(globus_ftp_client_operationattr_t)); globus_ftp_client_operationattr_init(new_ftp_attr); } @@ -5622,16 +5622,16 @@ globus_gass_copy_register_url_to_url( mode != GLOBUS_FTP_CONTROL_MODE_EXTENDED_BLOCK) { new_ftp_attr = (globus_ftp_client_operationattr_t *) - globus_libc_malloc(sizeof(globus_ftp_client_operationattr_t)); + globus_libc_malloc(sizeof(globus_ftp_client_operationattr_t)); - globus_ftp_client_operationattr_copy(new_ftp_attr, - state->source.attr->ftp_attr); + globus_ftp_client_operationattr_copy(new_ftp_attr, + state->source.attr->ftp_attr); } } else { new_ftp_attr = (globus_ftp_client_operationattr_t *) - globus_libc_malloc(sizeof(globus_ftp_client_operationattr_t)); + globus_libc_malloc(sizeof(globus_ftp_client_operationattr_t)); globus_ftp_client_operationattr_init(new_ftp_attr); } @@ -5663,7 +5663,7 @@ globus_gass_copy_register_url_to_url( globus_l_gass_copy_ftp_transfer_callback, (void *) handle); } - else + else { result = globus_ftp_client_partial_third_party_transfer( &handle->ftp_handle, @@ -5677,54 +5677,54 @@ globus_gass_copy_register_url_to_url( globus_l_gass_copy_ftp_transfer_callback, (void *) handle); } - - if (result != GLOBUS_SUCCESS) - { - /* do some error handling */ + + if (result != GLOBUS_SUCCESS) + { + /* do some error handling */ #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, "third_party_transfer() was not GLOBUS_SUCCESS! it returned %d\n", result); #endif - goto error_result_exit; - } - else - { - handle->status = GLOBUS_GASS_COPY_STATUS_TRANSFER_IN_PROGRESS; + goto error_result_exit; + } + else + { + handle->status = GLOBUS_GASS_COPY_STATUS_TRANSFER_IN_PROGRESS; #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, "third_party_transfer() returned GLOBUS_SUCCESS\n"); #endif - } + } } else { /* At least one of the urls is not ftp, (or thirdparty transfers * have been turned off) so we have to do the copy ourselves. */ - result = globus_l_gass_copy_transfer_start(handle); - if (result != GLOBUS_SUCCESS) - { - /* free the state */ - if(handle->state->active) - { - globus_l_gass_copy_state_free_targets(handle->state); - } - goto error_result_exit; - } + result = globus_l_gass_copy_transfer_start(handle); + if (result != GLOBUS_SUCCESS) + { + /* free the state */ + if(handle->state->active) + { + globus_l_gass_copy_state_free_targets(handle->state); + } + goto error_result_exit; + } } return GLOBUS_SUCCESS; error_exit: if(handle) - handle->status = GLOBUS_GASS_COPY_STATUS_DONE_FAILURE; + handle->status = GLOBUS_GASS_COPY_STATUS_DONE_FAILURE; err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: BAD_PARAMETER, argument %d cannot be NULL", - myname, - bad_param); + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: BAD_PARAMETER, argument %d cannot be NULL", + myname, + bad_param); return globus_error_put(err); error_result_exit: @@ -5734,7 +5734,7 @@ globus_gass_copy_register_url_to_url( /** * @brief Nonblocking transfer from an URL to an IO handle - * @ingroup globus_gass_transfer + * @ingroup globus_gass_copy * @details * This functions initiates a transfer from source URL to an IO handle, * then returns immediately. @@ -5790,18 +5790,18 @@ globus_gass_copy_register_url_to_handle( /* Check arguments for validity */ if(handle == GLOBUS_NULL) { - bad_param=1; - goto error_exit; + bad_param=1; + goto error_exit; } if(source_url == GLOBUS_NULL) { - bad_param=2; - goto error_exit; + bad_param=2; + goto error_exit; } if(dest_handle == GLOBUS_NULL) { - bad_param=4; - goto error_exit; + bad_param=4; + goto error_exit; } /* return an error if a transfer is already in progress */ @@ -5809,32 +5809,32 @@ globus_gass_copy_register_url_to_handle( handle->status < GLOBUS_GASS_COPY_STATUS_DONE_SUCCESS) { err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: There is a transfer already active on this handle", - myname); + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: There is a transfer already active on this handle", + myname); return globus_error_put(err); } result = globus_gass_copy_get_url_mode( - source_url, - &source_url_mode); + source_url, + &source_url_mode); if(result != GLOBUS_SUCCESS) goto error_result_exit; if ( source_url_mode == GLOBUS_GASS_COPY_URL_MODE_UNSUPPORTED) { - handle->status = GLOBUS_GASS_COPY_STATUS_FAILURE; - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: %s, GLOBUS_GASS_COPY_URL_MODE_UNSUPPORTED", - myname, - source_url); + handle->status = GLOBUS_GASS_COPY_STATUS_FAILURE; + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: %s, GLOBUS_GASS_COPY_URL_MODE_UNSUPPORTED", + myname, + source_url); - handle->status = GLOBUS_GASS_COPY_STATUS_DONE_FAILURE; + handle->status = GLOBUS_GASS_COPY_STATUS_DONE_FAILURE; - return globus_error_put(err); + return globus_error_put(err); } /* reinitialize the state for this transfer */ @@ -5848,19 +5848,19 @@ globus_gass_copy_register_url_to_handle( handle->callback_arg = callback_arg; result = globus_l_gass_copy_target_populate( - handle, - &(state->source), - &source_url_mode, - source_url, - source_attr); + handle, + &(state->source), + &source_url_mode, + source_url, + source_attr); if(result != GLOBUS_SUCCESS) goto error_result_exit; #ifdef GLOBUS_I_GASS_COPY_DEBUG globus_libc_fprintf(stderr, "source target populated\n"); #endif result = globus_l_gass_copy_io_target_populate( - handle, - &(state->dest), - dest_handle); + handle, + &(state->dest), + dest_handle); if(result != GLOBUS_SUCCESS) goto error_result_exit; #ifdef GLOBUS_I_GASS_COPY_DEBUG @@ -5870,20 +5870,20 @@ globus_gass_copy_register_url_to_handle( result = globus_l_gass_copy_transfer_start(handle); if (result != GLOBUS_SUCCESS) { - goto error_result_exit; + goto error_result_exit; } return GLOBUS_SUCCESS; error_exit: if(handle) - handle->status = GLOBUS_GASS_COPY_STATUS_DONE_FAILURE; + handle->status = GLOBUS_GASS_COPY_STATUS_DONE_FAILURE; err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: BAD_PARAMETER, argument %d cannot be NULL", - myname, - bad_param); + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: BAD_PARAMETER, argument %d cannot be NULL", + myname, + bad_param); return globus_error_put(err); error_result_exit: @@ -5894,7 +5894,7 @@ globus_gass_copy_register_url_to_handle( /** * Nonblocking Transfer From an IO handle to an URL - * @ingroup globus_gass_transfer + * @ingroup globus_gass_copy * @details * This functions initiates a transfer from an IO handle to destination URL, * then returns immediately. @@ -5950,18 +5950,18 @@ globus_gass_copy_register_handle_to_url( /* Check arguments for validity */ if(handle == GLOBUS_NULL) { - bad_param=1; - goto error_exit; + bad_param=1; + goto error_exit; } if(source_handle == GLOBUS_NULL) { - bad_param=2; - goto error_exit; + bad_param=2; + goto error_exit; } if(dest_url == GLOBUS_NULL) { - bad_param=3; - goto error_exit; + bad_param=3; + goto error_exit; } /* return an error if a transfer is already in progress */ @@ -5969,30 +5969,30 @@ globus_gass_copy_register_handle_to_url( handle->status < GLOBUS_GASS_COPY_STATUS_DONE_SUCCESS) { err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: There is a transfer already active on this handle", - myname); + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: There is a transfer already active on this handle", + myname); return globus_error_put(err); } result = globus_gass_copy_get_url_mode( - dest_url, - &dest_url_mode); + dest_url, + &dest_url_mode); if(result != GLOBUS_SUCCESS) goto error_result_exit; if ( dest_url_mode == GLOBUS_GASS_COPY_URL_MODE_UNSUPPORTED) { - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: %s, GLOBUS_GASS_COPY_URL_MODE_UNSUPPORTED", - myname, - dest_url); + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: %s, GLOBUS_GASS_COPY_URL_MODE_UNSUPPORTED", + myname, + dest_url); - handle->status = GLOBUS_GASS_COPY_STATUS_DONE_FAILURE; + handle->status = GLOBUS_GASS_COPY_STATUS_DONE_FAILURE; - return globus_error_put(err); + return globus_error_put(err); } /* reinitialize the state for this transfer */ @@ -6006,19 +6006,19 @@ globus_gass_copy_register_handle_to_url( handle->callback_arg = callback_arg; result = globus_l_gass_copy_io_target_populate( - handle, - &(state->source), - source_handle); + handle, + &(state->source), + source_handle); if(result != GLOBUS_SUCCESS) goto error_result_exit; #ifdef GLOBUS_I_GASS_COPY_DEBUG globus_libc_fprintf(stderr, "source target populated\n"); #endif result = globus_l_gass_copy_target_populate( - handle, - &(state->dest), - &dest_url_mode, - dest_url, - dest_attr); + handle, + &(state->dest), + &dest_url_mode, + dest_url, + dest_attr); if(result != GLOBUS_SUCCESS) goto error_result_exit; #ifdef GLOBUS_I_GASS_COPY_DEBUG @@ -6027,20 +6027,20 @@ globus_gass_copy_register_handle_to_url( result = globus_l_gass_copy_transfer_start(handle); if (result != GLOBUS_SUCCESS) { - goto error_result_exit; + goto error_result_exit; } return GLOBUS_SUCCESS; error_exit: if(handle) - handle->status = GLOBUS_GASS_COPY_STATUS_DONE_FAILURE; + handle->status = GLOBUS_GASS_COPY_STATUS_DONE_FAILURE; err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: BAD_PARAMETER, argument %d cannot be NULL", - myname, - bad_param); + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: BAD_PARAMETER, argument %d cannot be NULL", + myname, + bad_param); return globus_error_put(err); error_result_exit: handle->status = GLOBUS_GASS_COPY_STATUS_DONE_FAILURE; @@ -6053,7 +6053,7 @@ globus_gass_copy_register_handle_to_url( /** * @brief Cache connections to an FTP or GridFTP server - * @ingroup globus_gass_transfer + * @ingroup globus_gass_copy * @details * Explicitly cache connections to URL server. When * an URL is cached, the connection @@ -6081,42 +6081,42 @@ globus_gass_copy_cache_url_state( if(handle != GLOBUS_NULL) { - globus_url_parse(url, &url_info); - if ( (strcmp(url_info.scheme, "ftp") == 0) - || (strcmp(url_info.scheme, "gsiftp") == 0) ) - { - result = globus_ftp_client_handle_cache_url_state( - &handle->ftp_handle_2, - url); + globus_url_parse(url, &url_info); + if ( (strcmp(url_info.scheme, "ftp") == 0) + || (strcmp(url_info.scheme, "gsiftp") == 0) ) + { + result = globus_ftp_client_handle_cache_url_state( + &handle->ftp_handle_2, + url); if (result == GLOBUS_SUCCESS) { - result = globus_ftp_client_handle_cache_url_state( + result = globus_ftp_client_handle_cache_url_state( &handle->ftp_handle, url); - } - } - else - { - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, + } + } + else + { + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, "[%s]: BAD_URL_SCHEME, url: %s, only ftp or gsiftp can be cached", - myname, - url); - return globus_error_put(err); - } + myname, + url); + return globus_error_put(err); + } globus_url_destroy(&url_info); } else { /* handle == GLOBUS_NULL */ - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: BAD_PARAMETER, handle is NULL", - myname); - return globus_error_put(err); + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: BAD_PARAMETER, handle is NULL", + myname); + return globus_error_put(err); } return result; @@ -6124,8 +6124,8 @@ globus_gass_copy_cache_url_state( } /* globus_gass_copy_cache_url_state() */ /** - * @brief Remove an FTP or GridFTP cached connection - * @ingroup globus_gass_transfer + * @brief Remove an FTP or GridFTP cached connection + * @ingroup globus_gass_copy * @details * Explicitly remove a cached connection to an FTP or GSIFTP server. * If an idle connection to an FTP server exists, it will be closed. @@ -6151,42 +6151,42 @@ globus_gass_copy_flush_url_state( if(handle != GLOBUS_NULL) { - globus_url_parse(url, &url_info); - if ( (strcmp(url_info.scheme, "ftp") == 0) - || (strcmp(url_info.scheme, "gsiftp") == 0) ) - { - result = globus_ftp_client_handle_flush_url_state( - &handle->ftp_handle_2, - url); + globus_url_parse(url, &url_info); + if ( (strcmp(url_info.scheme, "ftp") == 0) + || (strcmp(url_info.scheme, "gsiftp") == 0) ) + { + result = globus_ftp_client_handle_flush_url_state( + &handle->ftp_handle_2, + url); if (result == GLOBUS_SUCCESS) { result = globus_ftp_client_handle_flush_url_state( &handle->ftp_handle, url); } - } - else - { - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: BAD_URL_SCHEME, url: %s, only ftp or gsiftp can be cached", - myname, - url); - return globus_error_put(err); - } + } + else + { + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: BAD_URL_SCHEME, url: %s, only ftp or gsiftp can be cached", + myname, + url); + return globus_error_put(err); + } globus_url_destroy(&url_info); } else { /* handle == GLOBUS_NULL */ - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: BAD_PARAMETER, handle is NULL", - myname); - return globus_error_put(err); + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: BAD_PARAMETER, handle is NULL", + myname); + return globus_error_put(err); } return result; } /* globus_gass_copy_flush_url_state() */ @@ -6198,7 +6198,7 @@ globus_gass_copy_flush_url_state( /** * @brief Set the user pointer in a handle - * @ingroup globus_gass_transfer + * @ingroup globus_gass_copy */ globus_result_t globus_gass_copy_set_user_pointer( @@ -6210,23 +6210,23 @@ globus_gass_copy_set_user_pointer( if(handle) { - handle->user_pointer = user_pointer; - return GLOBUS_SUCCESS; + handle->user_pointer = user_pointer; + return GLOBUS_SUCCESS; } else { - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: BAD_PARAMETER, handle is NULL", - myname); - return globus_error_put(err); + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: BAD_PARAMETER, handle is NULL", + myname); + return globus_error_put(err); } } /* globus_gass_copy_set_user_pointer() */ /** * @brief Get the user pointer in a handle - * @ingroup globus_gass_transfer + * @ingroup globus_gass_copy */ globus_result_t globus_gass_copy_get_user_pointer( @@ -6238,23 +6238,23 @@ globus_gass_copy_get_user_pointer( if (handle) { - *user_data = handle->user_pointer; - return GLOBUS_SUCCESS; + *user_data = handle->user_pointer; + return GLOBUS_SUCCESS; } else { - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: BAD_PARAMETER, handle is NULL", - myname); - return globus_error_put(err); + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: BAD_PARAMETER, handle is NULL", + myname); + return globus_error_put(err); } } /** * @brief Cancel a transfer - * @ingroup globus_gass_transfer + * @ingroup globus_gass_copy */ globus_result_t globus_gass_copy_cancel( @@ -6271,27 +6271,27 @@ globus_gass_copy_cancel( static char * myname="globus_gass_copy_cancel"; #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, "starting globus_gass_copy_cancel()\n"); + globus_libc_fprintf(stderr, "starting globus_gass_copy_cancel()\n"); #endif if (handle->status == GLOBUS_GASS_COPY_STATUS_NONE) { - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: No transfers have been initiated using this handle", - myname); + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: No transfers have been initiated using this handle", + myname); return globus_error_put(err); } if (handle->status == GLOBUS_GASS_COPY_STATUS_DONE) { - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: The last transfer has already completed.", - myname); + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: The last transfer has already completed.", + myname); return globus_error_put(err); } @@ -6303,33 +6303,33 @@ globus_gass_copy_cancel( GLOBUS_NULL, "[%s]: The last transfer has already ended.", myname); - + return globus_error_put(err); } if (handle->state->cancel == GLOBUS_I_GASS_COPY_CANCEL_CALLED) { - if(handle->status == GLOBUS_GASS_COPY_STATUS_CANCEL) - { - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: The last transfer has already been canceled.", - myname); + if(handle->status == GLOBUS_GASS_COPY_STATUS_CANCEL) + { + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: The last transfer has already been canceled.", + myname); - return globus_error_put(err); - } + return globus_error_put(err); + } - if(handle->status == GLOBUS_GASS_COPY_STATUS_FAILURE) - { - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: A failure has already been detected in the last transfer.", - myname); + if(handle->status == GLOBUS_GASS_COPY_STATUS_FAILURE) + { + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: A failure has already been detected in the last transfer.", + myname); - return globus_error_put(err); - } + return globus_error_put(err); + } } handle->state->cancel = GLOBUS_I_GASS_COPY_CANCEL_CALLED; @@ -6352,41 +6352,41 @@ globus_gass_copy_cancel( } else { - source_cancel_info = (globus_i_gass_copy_cancel_t *) - globus_libc_malloc(sizeof(globus_i_gass_copy_cancel_t)); - source_cancel_info->handle = handle; - source_cancel_info->canceling_source = GLOBUS_TRUE; + source_cancel_info = (globus_i_gass_copy_cancel_t *) + globus_libc_malloc(sizeof(globus_i_gass_copy_cancel_t)); + source_cancel_info->handle = handle; + source_cancel_info->canceling_source = GLOBUS_TRUE; - dest_cancel_info = (globus_i_gass_copy_cancel_t *) - globus_libc_malloc(sizeof(globus_i_gass_copy_cancel_t)); - dest_cancel_info->handle = handle; - dest_cancel_info->canceling_source = GLOBUS_FALSE; + dest_cancel_info = (globus_i_gass_copy_cancel_t *) + globus_libc_malloc(sizeof(globus_i_gass_copy_cancel_t)); + dest_cancel_info->handle = handle; + dest_cancel_info->canceling_source = GLOBUS_FALSE; - if(handle->state->source.status != GLOBUS_I_GASS_COPY_TARGET_DONE && - handle->state->source.status != GLOBUS_I_GASS_COPY_TARGET_INITIAL) - source_result = globus_l_gass_copy_target_cancel(source_cancel_info); + if(handle->state->source.status != GLOBUS_I_GASS_COPY_TARGET_DONE && + handle->state->source.status != GLOBUS_I_GASS_COPY_TARGET_INITIAL) + source_result = globus_l_gass_copy_target_cancel(source_cancel_info); if (handle->state->active) { if(handle->state->dest.status != GLOBUS_I_GASS_COPY_TARGET_DONE && handle->state->dest.status != GLOBUS_I_GASS_COPY_TARGET_INITIAL) { - dest_result = globus_l_gass_copy_target_cancel(dest_cancel_info); + dest_result = globus_l_gass_copy_target_cancel(dest_cancel_info); } } - if(source_result != GLOBUS_SUCCESS) - { - result = source_result; - } - else if(dest_result != GLOBUS_SUCCESS) - { - result = dest_result; - } - else - { - result = GLOBUS_SUCCESS; - } + if(source_result != GLOBUS_SUCCESS) + { + result = source_result; + } + else if(dest_result != GLOBUS_SUCCESS) + { + result = dest_result; + } + else + { + result = GLOBUS_SUCCESS; + } /* globus_libc_free(dest_cancel_info); globus_libc_free(source_cancel_info); @@ -6394,7 +6394,7 @@ globus_gass_copy_cancel( } #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, "leaving globus_gass_copy_cancel()\n"); + globus_libc_fprintf(stderr, "leaving globus_gass_copy_cancel()\n"); #endif return result; @@ -6430,16 +6430,16 @@ globus_l_gass_copy_target_cancel( if (cancel_info->canceling_source) { #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, "_target_cancel(): cancelling source\n"); + globus_libc_fprintf(stderr, "_target_cancel(): cancelling source\n"); #endif target = &(cancel_info->handle->state->source); } else { #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, "_target_cancel(): cancelling dest\n"); + globus_libc_fprintf(stderr, "_target_cancel(): cancelling dest\n"); #endif - target = &(cancel_info->handle->state->dest); + target = &(cancel_info->handle->state->dest); } switch (target->mode) @@ -6458,8 +6458,8 @@ globus_l_gass_copy_target_cancel( #ifdef GLOBUS_I_GASS_COPY_DEBUG globus_libc_fprintf(stderr, "target_cancel(): _ftp_client_abort() returned an error\n"); - globus_libc_fprintf(stderr, "target_cancel(): error = %s\n", - globus_object_printable_to_string(globus_error_peek(result))); + globus_libc_fprintf(stderr, "target_cancel(): error = %s\n", + globus_object_printable_to_string(globus_error_peek(result))); globus_libc_fprintf(stderr, " resetting to SUCCESS\n"); #endif result = GLOBUS_SUCCESS; @@ -6468,42 +6468,42 @@ globus_l_gass_copy_target_cancel( break; case GLOBUS_GASS_COPY_URL_MODE_GASS: - req_status = - globus_gass_transfer_request_get_status(target->data.gass.request); + req_status = + globus_gass_transfer_request_get_status(target->data.gass.request); #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, "target_cancel: gass_request_status = %d\n", req_status); #endif - if(req_status != GLOBUS_GASS_TRANSFER_REQUEST_FAILED && + if(req_status != GLOBUS_GASS_TRANSFER_REQUEST_FAILED && req_status != GLOBUS_GASS_TRANSFER_REQUEST_DENIED) { - rc = globus_gass_transfer_fail( + rc = globus_gass_transfer_fail( target->data.gass.request, globus_l_gass_copy_gass_transfer_cancel_callback, cancel_info); - if (rc != GLOBUS_SUCCESS) - { - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: %s globus_gass_transfer_request_fail returned an error code of: %d", - myname, - target->url, - rc); - globus_i_gass_copy_set_error(cancel_info->handle, err); - - result = globus_error_put(err); - } - else - { - globus_l_gass_copy_generic_cancel(cancel_info); - } - } - else - { - globus_gass_transfer_request_destroy(target->data.gass.request); - globus_l_gass_copy_generic_cancel(cancel_info); - } + if (rc != GLOBUS_SUCCESS) + { + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: %s globus_gass_transfer_request_fail returned an error code of: %d", + myname, + target->url, + rc); + globus_i_gass_copy_set_error(cancel_info->handle, err); + + result = globus_error_put(err); + } + else + { + globus_l_gass_copy_generic_cancel(cancel_info); + } + } + else + { + globus_gass_transfer_request_destroy(target->data.gass.request); + globus_l_gass_copy_generic_cancel(cancel_info); + } break; case GLOBUS_GASS_COPY_URL_MODE_IO: @@ -6514,11 +6514,11 @@ globus_l_gass_copy_target_cancel( cancel_info); break; default: - break; + break; } #ifdef GLOBUS_I_GASS_COPY_DEBUG if(result != GLOBUS_SUCCESS) - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, "[%s]: error trying to cancel one of the targets\n", myname); #endif @@ -6533,10 +6533,10 @@ globus_l_gass_copy_gass_transfer_cancel_callback( globus_gass_transfer_request_status_t status; globus_object_t * err; globus_i_gass_copy_cancel_t * cancel_info - = (globus_i_gass_copy_cancel_t *) callback_arg; + = (globus_i_gass_copy_cancel_t *) callback_arg; #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, "starting _gass_transfer_cancel_callback()\n"); #endif @@ -6566,7 +6566,7 @@ globus_l_gass_copy_io_cancel_callback( = (globus_i_gass_copy_cancel_t *) callback_arg; #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, "starting _io_cancel_callback()\n"); + globus_libc_fprintf(stderr, "starting _io_cancel_callback()\n"); #endif /* what to do if we get an error ?? @@ -6588,18 +6588,18 @@ globus_l_gass_copy_generic_cancel( globus_gass_copy_callback_t cancel_callback; #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, "starting _gass_copy_generic_cancel()\n"); + globus_libc_fprintf(stderr, "starting _gass_copy_generic_cancel()\n"); #endif globus_mutex_lock(&(state->mutex)); - + if (cancel_info->canceling_source) { #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, "_generic_cancel() source\n"); + globus_libc_fprintf(stderr, "_generic_cancel() source\n"); #endif - handle->state->source.status = GLOBUS_I_GASS_COPY_TARGET_DONE; + handle->state->source.status = GLOBUS_I_GASS_COPY_TARGET_DONE; if (handle->state->dest.status == GLOBUS_I_GASS_COPY_TARGET_DONE || - handle->state->dest.status == GLOBUS_I_GASS_COPY_TARGET_INITIAL) + handle->state->dest.status == GLOBUS_I_GASS_COPY_TARGET_INITIAL) { all_done = GLOBUS_TRUE; } @@ -6607,11 +6607,11 @@ globus_l_gass_copy_generic_cancel( else { #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, "_generic_cancel() dest\n"); + globus_libc_fprintf(stderr, "_generic_cancel() dest\n"); #endif - handle->state->dest.status = GLOBUS_I_GASS_COPY_TARGET_DONE; + handle->state->dest.status = GLOBUS_I_GASS_COPY_TARGET_DONE; if (handle->state->source.status == GLOBUS_I_GASS_COPY_TARGET_DONE || - handle->state->source.status == GLOBUS_I_GASS_COPY_TARGET_INITIAL) + handle->state->source.status == GLOBUS_I_GASS_COPY_TARGET_INITIAL) { all_done = GLOBUS_TRUE; } @@ -6621,16 +6621,16 @@ globus_l_gass_copy_generic_cancel( globus_l_gass_copy_perf_cancel_local_callback(handle->performance); } } - + if (all_done && ((handle->state->dest.mode == GLOBUS_GASS_COPY_URL_MODE_FTP && !handle->state->dest.data.ftp.completed) || - (handle->state->source.mode == GLOBUS_GASS_COPY_URL_MODE_FTP && + (handle->state->source.mode == GLOBUS_GASS_COPY_URL_MODE_FTP && !handle->state->source.data.ftp.completed))) { all_done = GLOBUS_FALSE; } - + if(all_done) { user_callback = handle->user_callback; @@ -6644,64 +6644,64 @@ globus_l_gass_copy_generic_cancel( globus_gass_copy_cancel(handle, NULL, NULL); } globus_mutex_unlock(&(state->mutex)); - + #ifdef GLOBUS_I_GASS_COPY_DEBUG globus_libc_fprintf(stderr, "_generic_cancel() before all done\n"); #endif if (all_done) { - globus_l_gass_copy_state_free_targets(state); + globus_l_gass_copy_state_free_targets(state); #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, "globus_l_gass_copy_generic_cancel():\n"); - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, "globus_l_gass_copy_generic_cancel():\n"); + globus_libc_fprintf(stderr, " ...check to call user/cancel callbacks.\n"); #endif - /* set the final status of the transfer */ - switch(handle->status) - { - case GLOBUS_GASS_COPY_STATUS_FAILURE: - handle->status = GLOBUS_GASS_COPY_STATUS_DONE_FAILURE; - break; - case GLOBUS_GASS_COPY_STATUS_CANCEL: - handle->status = GLOBUS_GASS_COPY_STATUS_DONE_CANCELLED; - break; - default: - break; - } + /* set the final status of the transfer */ + switch(handle->status) + { + case GLOBUS_GASS_COPY_STATUS_FAILURE: + handle->status = GLOBUS_GASS_COPY_STATUS_DONE_FAILURE; + break; + case GLOBUS_GASS_COPY_STATUS_CANCEL: + handle->status = GLOBUS_GASS_COPY_STATUS_DONE_CANCELLED; + break; + default: + break; + } err = handle->err; - handle->err = GLOBUS_NULL; - - if(cancel_callback != GLOBUS_NULL) + handle->err = GLOBUS_NULL; + + if(cancel_callback != GLOBUS_NULL) { #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, " ...calling user cancel callback.\n"); #endif - cancel_callback( - handle->cancel_callback_arg, - handle, - err); + cancel_callback( + handle->cancel_callback_arg, + handle, + err); } - if(user_callback != GLOBUS_NULL) + if(user_callback != GLOBUS_NULL) { #ifdef GLOBUS_I_GASS_COPY_DEBUG - globus_libc_fprintf(stderr, " ...calling user callback.\n"); + globus_libc_fprintf(stderr, " ...calling user callback.\n"); #endif - user_callback( - handle->callback_arg, - handle, - err); + user_callback( + handle->callback_arg, + handle, + err); } - /* if an error object was created, free it */ + /* if an error object was created, free it */ if (err) { - globus_object_free(err); + globus_object_free(err); } } /* if (all_done) */ @@ -6716,7 +6716,7 @@ globus_l_gass_copy_generic_cancel( #ifdef USE_FTP_ATTRS /** * @brief Set TCP buffer/window size - * @ingroup globus_gass_transfer + * @ingroup globus_gass_copy */ globus_result_t globus_gass_copy_attr_set_tcpbuffer( @@ -6761,7 +6761,7 @@ globus_gass_copy_attr_set_tcpbuffer( /** * @brief Set parallelism info - * @ingroup globus_gass_transfer + * @ingroup globus_gass_copy */ globus_result_t globus_gass_copy_attr_set_parallelism( @@ -6773,7 +6773,7 @@ globus_gass_copy_attr_set_parallelism( /** * @brief Set striping info - * @ingroup globus_gass_transfer + * @ingroup globus_gass_copy */ globus_result_t globus_gass_copy_attr_set_striping( @@ -6785,7 +6785,7 @@ globus_gass_copy_attr_set_striping( /** * @brief Set authorization info - * @ingroup globus_gass_transfer + * @ingroup globus_gass_copy */ globus_result_t globus_gass_copy_attr_set_authorization( @@ -6797,7 +6797,7 @@ globus_gass_copy_attr_set_authorization( /** * @brief Set secure channel info - * @ingroup globus_gass_transfer + * @ingroup globus_gass_copy */ globus_result_t globus_gass_copy_attr_set_secure_channel( @@ -6824,21 +6824,21 @@ globus_i_gass_copy_attr_duplicate(globus_gass_copy_attr_t ** attr) if ( (attr == GLOBUS_NULL) || (*attr == GLOBUS_NULL) ) { - err = globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "[%s]: BAD_PARAMETER, attr==GLOBUS_NULL, or *attr==GLOBUS_NULL", - myname); + err = globus_error_construct_string( + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "[%s]: BAD_PARAMETER, attr==GLOBUS_NULL, or *attr==GLOBUS_NULL", + myname); - return globus_error_put(err); + return globus_error_put(err); } new_attr = (globus_gass_copy_attr_t *) - globus_libc_malloc(sizeof(globus_gass_copy_attr_t)); + globus_libc_malloc(sizeof(globus_gass_copy_attr_t)); globus_gass_copy_attr_init(new_attr); new_ftp_attr = (globus_ftp_client_operationattr_t *) - globus_libc_malloc(sizeof(globus_ftp_client_operationattr_t)); + globus_libc_malloc(sizeof(globus_ftp_client_operationattr_t)); globus_ftp_cient_attr_copy(new_ftp_attr, *(attr)->ftp_attr); /* new_attr = *attr; */ diff --git a/gass/copy/source/globus_gass_copy_glob.c b/gass/copy/source/globus_gass_copy_glob.c index 7fa0c1cf30..7fbe7c7983 100644 --- a/gass/copy/source/globus_gass_copy_glob.c +++ b/gass/copy/source/globus_gass_copy_glob.c @@ -295,7 +295,6 @@ globus_l_gass_copy_glob_expand_file_url( globus_result_t result; int retval; globus_url_t parsed_url; - int i; struct stat stat_buf; char unique_id[256]; globus_gass_copy_glob_entry_t type; @@ -375,9 +374,7 @@ globus_l_gass_copy_glob_expand_file_url( goto error_open; } - for(i = 0; - globus_libc_readdir_r(dir, &dir_entry) == 0 && dir_entry; - i++) + while(globus_libc_readdir_r(dir, &dir_entry) == 0 && dir_entry) { char path[MAXPATHLEN]; diff --git a/gass/copy/source/globus_url_copy.c b/gass/copy/source/globus_url_copy.c index c40d459b6b..7f7274cdb6 100644 --- a/gass/copy/source/globus_url_copy.c +++ b/gass/copy/source/globus_url_copy.c @@ -88,7 +88,7 @@ int guc_mkcert(X509 **x509p, EVP_PKEY **pkeyp, int bits, int serial, int days) X509_gmtime_adj(X509_get_notAfter(x),(long)60*60*24*days); X509_set_pubkey(x,pk); - name = X509_get_subject_name(x); + name = X509_NAME_dup(X509_get_subject_name(x)); /* This function creates and adds the entry, working out the * correct string type and performing checks on its length. @@ -102,7 +102,9 @@ int guc_mkcert(X509 **x509p, EVP_PKEY **pkeyp, int bits, int serial, int days) /* Its self signed so set the issuer name to be the same as the * subject. */ + X509_set_subject_name(x,name); X509_set_issuer_name(x,name); + X509_NAME_free(name); if (!X509_sign(x,pk,EVP_md5())) goto err; @@ -121,7 +123,7 @@ int guc_gencert(gss_buffer_desc * buf) EVP_PKEY *pkey = NULL; BIO *bio; char *ptr; - + guc_mkcert(&x509, &pkey, 2048, 0, 100); bio = BIO_new(BIO_s_mem()); @@ -132,17 +134,17 @@ int guc_gencert(gss_buffer_desc * buf) X509_free(x509); EVP_PKEY_free(pkey); - + buf->length = BIO_get_mem_data(bio, &ptr); buf->value = strdup(ptr); BIO_free(bio); return 0; } - - - + + + #define GUC_URL_ENC_CHAR "#;:=+ ," /****************************************************************************** @@ -159,7 +161,7 @@ typedef struct volatile globus_bool_t done; } globus_l_guc_monitor_t; -typedef struct +typedef struct { globus_gass_copy_glob_entry_t type; char * url; @@ -169,7 +171,7 @@ typedef struct char * checksum; } globus_l_guc_url_info_t; -typedef struct +typedef struct { char * src_url; char * dst_url; @@ -184,14 +186,14 @@ typedef struct globus_l_guc_handle_s globus_gass_copy_handle_t cksm_gass_copy_handle; globus_gass_copy_attr_t source_gass_copy_attr; - globus_gass_copy_attr_t dest_gass_copy_attr; - + globus_gass_copy_attr_t dest_gass_copy_attr; + globus_ftp_client_operationattr_t source_ftp_attr; globus_ftp_client_operationattr_t dest_ftp_attr; globus_gass_transfer_requestattr_t source_gass_attr; globus_gass_transfer_requestattr_t dest_gass_attr; - + void * guc_info; void * current_transfer; globus_l_guc_src_dst_pair_t * pipeline_free_pair; @@ -199,7 +201,7 @@ typedef struct globus_l_guc_handle_s int id; } globus_l_guc_handle_t; -typedef struct +typedef struct { globus_fifo_t user_url_list; globus_fifo_t expanded_url_list; @@ -234,11 +236,11 @@ typedef struct int restart_timeout; int stall_timeout; globus_size_t stripe_bs; - globus_bool_t striped; - globus_bool_t rfc1738; - globus_bool_t create_dest; - globus_off_t partial_offset; - globus_off_t partial_length; + globus_bool_t striped; + globus_bool_t rfc1738; + globus_bool_t create_dest; + globus_off_t partial_offset; + globus_off_t partial_length; globus_bool_t list_uses_data_mode; globus_bool_t udt; globus_bool_t nl_bottleneck; @@ -265,7 +267,7 @@ typedef struct char * dst_authz_assert; globus_bool_t cache_src_authz_assert; globus_bool_t cache_dst_authz_assert; - + gss_cred_id_t src_cred; gss_cred_id_t dst_cred; gss_cred_id_t data_cred; @@ -283,7 +285,7 @@ typedef struct globus_l_guc_handle_t ** handles; globus_bool_t comp_checksum; char * checksum_algo; - + } globus_l_guc_info_t; typedef struct globus_l_guc_transfer_s @@ -310,7 +312,7 @@ enum GLOBUS_L_GUC_DATE = 2, GLOBUS_L_GUC_CKSM = 3 } globus_l_guc_sync_level_t; - + static globus_hashtable_t guc_l_alias_table; static globus_bool_t guc_l_aliases = GLOBUS_FALSE; @@ -323,7 +325,7 @@ static gss_buffer_desc auto_data = GSS_C_EMPTY_BUFFER; Module specific prototypes *****************************************************************************/ -static +static void globus_l_url_copy_monitor_callback(void * callback_arg, globus_gass_copy_handle_t * handle, @@ -351,13 +353,13 @@ globus_l_guc_dest_entry_cb( const char * url, const globus_gass_copy_glob_stat_t * info_stat, void * user_arg); - + static globus_result_t globus_l_guc_file_to_string( char * filename, char ** str); - + static int globus_l_guc_parse_arguments( @@ -390,7 +392,7 @@ static int globus_l_guc_init_gass_copy_handle( globus_gass_copy_handle_t * gass_copy_handle, - globus_l_guc_info_t * guc_info, + globus_l_guc_info_t * guc_info, int id); static @@ -414,18 +416,18 @@ static void globus_l_guc_info_destroy( globus_l_guc_info_t * guc_info); - + static void globus_l_guc_destroy_url_list( globus_fifo_t * url_list); -static +static void globus_l_guc_hashtable_element_free( void * datum); -static +static void globus_l_guc_url_info_free( void * datum); @@ -496,23 +498,23 @@ const char * long_usage = " Convert the file to/from ASCII format to/from local file format\n" " -b | -binary\n" " Do not apply any conversion to the files. *default*\n" -" -f \n" +" -f \n" " Read a list of url pairs from filename. Each line should contain\n" " \n" " Enclose URLs with spaces in double quotes (\").\n" " Blank lines and lines beginning with # will be ignored.\n" -" -cd | -create-dest\n" +" -cd | -create-dest\n" " Create destination directory if needed\n" -" -r | -recurse\n" +" -r | -recurse\n" " Copy files in subdirectories\n" - -" -fast\n" + +" -fast\n" " Recommended when using GridFTP servers. Use MODE E for all data\n" " transfers, including reusing data channels between list and transfer\n" " operations.\n" " -t \n" " Run the transfer for this number of seconds and then end.\n" -" Useful for performance testing or forced restart loops.\n" +" Useful for performance testing or forced restart loops.\n" " -q | -quiet \n" " Suppress all output for successful operation\n" " -v | -verbose \n" @@ -533,7 +535,7 @@ const char * long_usage = " The interval in seconds to wait after a failure before retrying\n" " the transfer. Use 0 for an exponential back off. Default is 0.\n" " -rst-timeout \n" -" Maximum time after a failure to keep retrying. Use 0 for no\n" +" Maximum time after a failure to keep retrying. Use 0 for no\n" " timeout. Default is 0.\n" " -stall-timeout | -st \n" " How long before canceling/restarting a transfer with no data\n" @@ -555,7 +557,7 @@ const char * long_usage = " user's starting directory on the server. By default, all paths are\n" " root-relative. When this flag is set, the path portion of the ftp url\n" " must start with %%2F if it designates a root-relative path.\n" - + " -s | -subject \n" " Use this subject to match with both the source and dest servers\n" " -ss | -source-subject \n" @@ -570,7 +572,7 @@ const char * long_usage = " underlying transfer methods\n" " -p | -parallel \n" " specify the number of parallel data connections should be used.\n" - + " -notpt | -no-third-party-transfers\n" " turn third-party transfers off (on by default)\n" " -nodcau | -no-data-channel-authentication\n" @@ -579,7 +581,7 @@ const char * long_usage = " set data channel protection mode to SAFE\n" " -dcpriv | -data-channel-private\n" " set data channel protection mode to PRIVATE\n" - + " -off | -partial-offset\n" " offset for partial ftp file transfers, defaults to 0\n" " -len | -partial-length\n" @@ -596,7 +598,7 @@ const char * long_usage = " -ipv6\n" " use ipv6 when available (EXPERIMENTAL)\n" " -udt\n" -" Use UDT, a reliable udp based transport protocol, for data transfers\n" +" Use UDT, a reliable udp based transport protocol, for data transfers\n" " -no-g2 | -nogridftp2\n" " disable use of GridFTP v2 protocol enhancements\n" " -dp | -delayed-pasv\n" @@ -621,13 +623,13 @@ const char * long_usage = " in a GridFTP transfer\n" " -aa | -authz-assert \n" " Use the assertions in this file to authorize the access with both\n" -" source and dest servers\n" +" source and dest servers\n" " -saa | -src-authz-assert \n" " Use the assertions in this file to authorize the access with source\n" -" server\n" +" server\n" " -daa | -dst-authz-assert \n" " Use the assertions in this file to authorize the access with dest\n" -" server\n" +" server\n" " -cache-aa | -cache-authz-assert\n" " Cache the authz assertion for subsequent transfers\n" " -cache-saa | -cache-src-authz-assert\n" @@ -680,7 +682,7 @@ const char * long_usage = " Set the credentials to use for source, destination, \n" " or both ftp connections.\n" " -data-cred \n" -" Set the credential to use for data connection. A value of 'auto' will\n" +" Set the credential to use for data connection. A value of 'auto' will\n" " generate a temporary self-signed credential. This may be used with\n" " any authentication method, but the server must support the DCSC command.\n" " -af | -alias-file \n" @@ -747,7 +749,7 @@ this feature has not yet been implemented. exit(1); \ } -static +static int test_integer( char * value, void * ignored, @@ -759,11 +761,11 @@ test_integer( char * value, return res; } -enum -{ - arg_a = 1, - arg_b, - arg_c, +enum +{ + arg_a = 1, + arg_b, + arg_c, arg_ext, arg_plugin, arg_mc, @@ -775,25 +777,25 @@ enum arg_src_modargs, arg_dst_modname, arg_dst_modargs, - arg_s, - arg_t, - arg_p, - arg_f, + arg_s, + arg_t, + arg_p, + arg_f, arg_vb, - arg_q, - arg_v, - arg_debugftp, + arg_q, + arg_v, + arg_debugftp, arg_restart, - arg_rst_retries, - arg_rst_interval, - arg_rst_timeout, + arg_rst_retries, + arg_rst_interval, + arg_rst_timeout, arg_stall_timeout, - arg_ss, - arg_ds, + arg_ss, + arg_ds, arg_tcp_bs, - arg_bs, + arg_bs, arg_conc, - arg_notpt, + arg_notpt, arg_nodcau, arg_data_safe, arg_data_private, @@ -854,7 +856,7 @@ static char * listname(id)[] = { alias1, alias2, GLOBUS_NULL } #define flagdef(id,alias1,alias2) \ namedef(id,alias1,alias2); \ static globus_args_option_descriptor_t defname(id) = { id, listname(id), 0, \ - GLOBUS_NULL, GLOBUS_NULL } + GLOBUS_NULL, GLOBUS_NULL } #define funcname(x) x##_predicate_test #define paramsname(x) x##_predicate_params @@ -1001,19 +1003,19 @@ static globus_args_option_descriptor_t args_options[arg_num]; setupopt(arg_nodcau); \ setupopt(arg_data_safe); \ setupopt(arg_data_private); \ - setupopt(arg_recurse); \ - setupopt(arg_partial_offset); \ - setupopt(arg_partial_length); \ - setupopt(arg_rfc1738); \ + setupopt(arg_recurse); \ + setupopt(arg_partial_offset); \ + setupopt(arg_partial_length); \ + setupopt(arg_rfc1738); \ setupopt(arg_create_dest); \ - setupopt(arg_fast); \ - setupopt(arg_list); \ + setupopt(arg_fast); \ + setupopt(arg_list); \ setupopt(arg_udt); \ setupopt(arg_nl_bottleneck); \ setupopt(arg_nl_interval); \ - setupopt(arg_ipv6); \ + setupopt(arg_ipv6); \ setupopt(arg_gridftp2_off); \ - setupopt(arg_gridftp2); \ + setupopt(arg_gridftp2); \ setupopt(arg_src_pipe_str); \ setupopt(arg_dst_pipe_str); \ setupopt(arg_pipe_str); \ @@ -1037,13 +1039,13 @@ static globus_args_option_descriptor_t args_options[arg_num]; setupopt(arg_dump_only); \ setupopt(arg_preserve); \ setupopt(arg_perms); \ - setupopt(arg_allo); \ - setupopt(arg_noallo); \ - setupopt(arg_cred); \ - setupopt(arg_src_cred); \ - setupopt(arg_dst_cred); \ - setupopt(arg_data_cred); \ - setupopt(arg_stripe_bs); \ + setupopt(arg_allo); \ + setupopt(arg_noallo); \ + setupopt(arg_cred); \ + setupopt(arg_src_cred); \ + setupopt(arg_dst_cred); \ + setupopt(arg_data_cred); \ + setupopt(arg_stripe_bs); \ setupopt(arg_striped); \ setupopt(arg_checksum); \ setupopt(arg_checksum_algo); @@ -1116,7 +1118,7 @@ globus_l_guc_glob_list_cb( } globus_url_destroy(&url_info); } - + static void globus_l_guc_ext_interrupt_handler( @@ -1285,7 +1287,7 @@ globus_l_guc_ext( error: fprintf(stderr, "%s\n", globus_error_print_friendly(err)); - + return 1; } /* END CRFT STUFF */ @@ -1338,7 +1340,7 @@ globus_l_guc_url_replace_host( char * ptr; char * tmp; char * end; - + tmp = globus_libc_strdup(in_url); ptr = strstr(tmp, "ftp://"); if(ptr == NULL) @@ -1353,15 +1355,15 @@ globus_l_guc_url_replace_host( { goto skip; } - + out = globus_common_create_string("%s/%s%s", tmp, host, end); globus_free(tmp); - + return out; - + skip: globus_free(tmp); - return NULL; + return NULL; } static @@ -1375,20 +1377,20 @@ globus_l_guc_dequeue_pair( globus_l_guc_alias_t * dst_alias = NULL; char * new_src; char * new_dst; - + pair = (globus_l_guc_src_dst_pair_t *) globus_fifo_dequeue(q); - + if(guc_l_aliases) { /* - src_alias = (globus_l_guc_alias_t *) + src_alias = (globus_l_guc_alias_t *) globus_hashtable_lookup(&guc_l_alias_table, (void *) "source"); - dst_alias = (globus_l_guc_alias_t *) + dst_alias = (globus_l_guc_alias_t *) globus_hashtable_lookup(&guc_l_alias_table, (void *) "destination"); */ src_alias = guc_l_src_alias_ent; dst_alias = guc_l_dst_alias_ent; - + if(src_alias && src_alias->entries > 0) { new_src = globus_l_guc_url_replace_host( @@ -1399,7 +1401,7 @@ globus_l_guc_dequeue_pair( pair->src_url = new_src; } } - + if(dst_alias && dst_alias->entries > 0) { new_dst = globus_l_guc_url_replace_host( @@ -1411,7 +1413,7 @@ globus_l_guc_dequeue_pair( } } } - + if(!g_ssh_print_connect && !g_all_quiet && strncmp(pair->src_url, "sshftp://", 9) == 0 && strncmp(pair->dst_url, "sshftp://", 9) == 0) @@ -1443,13 +1445,13 @@ globus_l_guc_print_url_line( char * pre; char * statstr = NULL; char * tmpstr = NULL; - + pre = prefix ? prefix : ""; - + statstr = globus_libc_strdup(""); if(info) - { + { if(info->size >= 0 && info->type == GLOBUS_GASS_COPY_GLOB_ENTRY_FILE) { tmpstr = globus_common_create_string( @@ -1479,31 +1481,31 @@ globus_l_guc_print_url_line( statstr = tmpstr; } } - + if(length > -1) { rc = fprintf( - fp, + fp, "%s\"%s\" \"%s\" %"GLOBUS_OFF_T_FORMAT",%"GLOBUS_OFF_T_FORMAT" %s\n", - pre, src_url, dst_url, offset, length, statstr); + pre, src_url, dst_url, offset, length, statstr); } else if(offset > -1) - { + { rc = fprintf( - fp, - "%s\"%s\" \"%s\" %"GLOBUS_OFF_T_FORMAT" %s\n", + fp, + "%s\"%s\" \"%s\" %"GLOBUS_OFF_T_FORMAT" %s\n", pre, src_url, dst_url, offset, statstr); } else if(tmpstr) { - rc = fprintf(fp, "%s\"%s\" \"%s\" 0,-1 %s\n", + rc = fprintf(fp, "%s\"%s\" \"%s\" 0,-1 %s\n", pre, src_url, dst_url, statstr); - } + } else { - rc = fprintf(fp, "%s\"%s\" \"%s\"\n", + rc = fprintf(fp, "%s\"%s\" \"%s\"\n", pre, src_url, dst_url); - } + } globus_free(statstr); return rc; @@ -1527,7 +1529,7 @@ globus_l_guc_dump_urls( globus_l_guc_transfer_t * transfer_info; guc_info = (globus_l_guc_info_t *) user_arg; - + globus_mutex_lock(&g_monitor.mutex); if(guc_info->dumpfile) @@ -1550,10 +1552,10 @@ globus_l_guc_dump_urls( unlink(dumptmp); return; } - + for(i = 0; i < guc_info->conc; i++) { - transfer_info = (globus_l_guc_transfer_t *) + transfer_info = (globus_l_guc_transfer_t *) guc_info->handles[i]->current_transfer; if(transfer_info) { @@ -1563,7 +1565,7 @@ globus_l_guc_dump_urls( globus_off_t end_offset = 0; globus_off_t off = transfer_info->urls->offset; globus_off_t len = transfer_info->urls->length; - + globus_gass_copy_get_ftp_handle( &guc_info->handles[i]->gass_copy_handle, &ftp_handle); globus_ftp_client_handle_get_restart_marker( @@ -1571,15 +1573,15 @@ globus_l_guc_dump_urls( globus_ftp_client_restart_marker_get_first_block( &marker, &start_offset, &end_offset); globus_ftp_client_restart_marker_destroy(&marker); - + if(transfer_info->urls->length > -1) { off = transfer_info->urls->offset + end_offset; - len = transfer_info->urls->length - (end_offset - start_offset); + len = transfer_info->urls->length - (end_offset - start_offset); } else if(end_offset > 0 || transfer_info->urls->offset > -1) - { - off = end_offset > transfer_info->urls->offset ? + { + off = end_offset > transfer_info->urls->offset ? end_offset : transfer_info->urls->offset; } @@ -1591,18 +1593,18 @@ globus_l_guc_dump_urls( len, transfer_info->urls->src_info, NULL); - } + } } - + if(!globus_fifo_empty(&guc_info->expanded_url_list)) { tmp_fifo = globus_fifo_copy(&guc_info->expanded_url_list); - + while(!globus_fifo_empty(tmp_fifo)) { - url_pair = + url_pair = (globus_l_guc_src_dst_pair_t *) globus_fifo_dequeue(tmp_fifo); - + globus_l_guc_print_url_line( dumpfile, url_pair->src_url, @@ -1614,16 +1616,16 @@ globus_l_guc_dump_urls( } globus_fifo_destroy(tmp_fifo); } - + if(!globus_fifo_empty(&guc_info->user_url_list)) { tmp_fifo = globus_fifo_copy(&guc_info->user_url_list); - + while(!globus_fifo_empty(tmp_fifo)) { - url_pair = + url_pair = (globus_l_guc_src_dst_pair_t *) globus_fifo_dequeue(tmp_fifo); - + globus_l_guc_print_url_line( dumpfile, url_pair->src_url, @@ -1635,7 +1637,7 @@ globus_l_guc_dump_urls( } globus_fifo_destroy(tmp_fifo); } - + fclose(dumpfile); if(rename(dumptmp, guc_info->dumpfile) < 0) { @@ -1643,7 +1645,7 @@ globus_l_guc_dump_urls( } globus_free(dumptmp); } - + if(guc_info->dump_only_file && guc_info->dump_only_fp == NULL) { dumptmp = globus_common_create_string("%s.XXXXXX", guc_info->dump_only_file); @@ -1663,20 +1665,20 @@ globus_l_guc_dump_urls( close(dumpfd); unlink(dumptmp); return; - } - + } + if(!globus_fifo_empty(&guc_info->dump_url_list)) { tmp_fifo = globus_fifo_copy(&guc_info->dump_url_list); - + while(!globus_fifo_empty(tmp_fifo)) { char * is_dir; - - url_pair = + + url_pair = (globus_l_guc_src_dst_pair_t *) globus_fifo_dequeue(tmp_fifo); - - is_dir = + + is_dir = url_pair->src_url[strlen(url_pair->src_url) - 1] == '/' ? "#" : NULL; @@ -1698,8 +1700,8 @@ globus_l_guc_dump_urls( unlink(dumptmp); } globus_free(dumptmp); - - } + + } globus_mutex_unlock(&g_monitor.mutex); @@ -1718,14 +1720,14 @@ globus_l_guc_transfer_kickout( globus_bool_t expanded = GLOBUS_FALSE; globus_bool_t expand = GLOBUS_FALSE; globus_object_t * err = NULL; - + transfer_info = (globus_l_guc_transfer_t * ) user_arg; globus_mutex_lock(&g_monitor.mutex); - { + { if(!g_monitor.done && !transfer_info->guc_info->cancelled && !globus_fifo_empty(&transfer_info->guc_info->expanded_url_list)) - { + { globus_l_guc_url_pair_free(transfer_info->urls); transfer_info->urls = globus_l_guc_dequeue_pair( &transfer_info->guc_info->expanded_url_list, @@ -1737,19 +1739,19 @@ globus_l_guc_transfer_kickout( } else if(!g_monitor.done && !transfer_info->guc_info->cancelled && !globus_fifo_empty(&transfer_info->guc_info->user_url_list)) - { + { globus_l_guc_url_pair_free(transfer_info->urls); transfer_info->urls = globus_l_guc_dequeue_pair( &transfer_info->guc_info->user_url_list, transfer_info->handle->id); - + transfer_info->guc_info->conc_outstanding++; transfer_info->handle->current_transfer = transfer_info; if(transfer_info->guc_info->create_dest) { transfer_info->needs_mkdir = GLOBUS_TRUE; } - + expand = GLOBUS_TRUE; } else @@ -1766,21 +1768,21 @@ globus_l_guc_transfer_kickout( retry = GLOBUS_TRUE; } } - + } globus_mutex_unlock(&g_monitor.mutex); - + if(expanded) - { + { result = globus_l_guc_transfer(transfer_info); if(result != GLOBUS_SUCCESS && !g_continue) - { + { globus_mutex_lock(&g_monitor.mutex); { g_monitor.done = GLOBUS_TRUE; g_monitor.use_err = GLOBUS_TRUE; g_monitor.err = globus_error_peek(result); - + if(transfer_info->guc_info->conc_outstanding == 0) { globus_cond_signal(&g_monitor.cond); @@ -1810,13 +1812,13 @@ globus_l_guc_transfer_kickout( GLOBUS_FALSE, GLOBUS_TRUE); } - + result = globus_l_guc_expand_single_url(transfer_info); if(result != GLOBUS_SUCCESS) { err = globus_error_peek(result); } - + result = GLOBUS_SUCCESS; globus_l_url_copy_monitor_callback( transfer_info, &transfer_info->handle->gass_copy_handle, err); @@ -1865,7 +1867,7 @@ main(int argc, char **argv) err = globus_module_activate(GLOBUS_GASS_COPY_MODULE); if( err != GLOBUS_SUCCESS ) { - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, _GASCSL("Error %d, activating gass copy module\n"), err); return 1; @@ -1873,7 +1875,7 @@ main(int argc, char **argv) err = globus_module_activate(GLOBUS_FTP_CLIENT_DEBUG_PLUGIN_MODULE); if( err != GLOBUS_SUCCESS ) { - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, _GASCSL("Error %d, activating ftp debug plugin module\n"), err); return 1; @@ -1881,7 +1883,7 @@ main(int argc, char **argv) err = globus_module_activate(GLOBUS_FTP_CLIENT_RESTART_PLUGIN_MODULE); if( err != GLOBUS_SUCCESS ) { - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, _GASCSL("Error %d, activating ftp restart plugin module\n"), err); return 1; @@ -1889,7 +1891,7 @@ main(int argc, char **argv) err = globus_module_activate(GLOBUS_GSI_GSSAPI_MODULE); if( err != GLOBUS_SUCCESS ) { - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, _GASCSL("Error %d, activating ftp restart plugin module\n"), err); return 1; @@ -1908,22 +1910,22 @@ main(int argc, char **argv) { return 1; } - + /* crft interception */ if(g_ext != NULL) { return globus_l_guc_ext(&guc_info); } - - guc_info.handles = (globus_l_guc_handle_t **) + + guc_info.handles = (globus_l_guc_handle_t **) globus_calloc(guc_info.conc, sizeof(globus_l_guc_handle_t *)); for(i = 0; i < guc_info.conc; i++) { - guc_info.handles[i] = (globus_l_guc_handle_t *) + guc_info.handles[i] = (globus_l_guc_handle_t *) globus_calloc(1, sizeof(globus_l_guc_handle_t)); - + guc_info.handles[i]->guc_info = &guc_info; - + globus_gass_copy_attr_init( &guc_info.handles[i]->source_gass_copy_attr); globus_gass_copy_attr_init( @@ -1951,11 +1953,11 @@ main(int argc, char **argv) &guc_info.handles[i]->cksm_gass_copy_handle); } } - + globus_mutex_init(&g_monitor.mutex, NULL); globus_cond_init(&g_monitor.cond, NULL); g_monitor.was_error = 0; - + if(guc_info.list_url != NULL) { globus_fifo_enqueue(&guc_info.expanded_url_list, @@ -1999,7 +2001,7 @@ main(int argc, char **argv) globus_l_guc_interrupt_handler, NULL); } - + if(guc_info.dumpfile || guc_info.dump_only_file) { GlobusTimeReltimeSet(delay, 60, 0); @@ -2020,10 +2022,10 @@ main(int argc, char **argv) g_err_msg = globus_error_print_friendly( globus_error_peek(result)); fprintf(stderr, _GASCSL("\nerror: %s"), g_err_msg); - globus_free(g_err_msg); + globus_free(g_err_msg); ret_val = 1; } - + if(guc_info.dumpfile || guc_info.dump_only_file) { globus_callback_unregister(dumpfile_handle, NULL, NULL, NULL); @@ -2039,7 +2041,7 @@ main(int argc, char **argv) raise(SIGINT); #endif } - + /* make sure the timer doesn't go off after a cancel. setting this to true makes the handler ignore everything if it hasn't fired yet */ globus_mutex_lock(&g_monitor.mutex); @@ -2056,7 +2058,7 @@ main(int argc, char **argv) { globus_libc_fprintf(stdout, "\n"); } - + if(guc_info.udt) { /* sidestep udt shutdown issues */ @@ -2068,17 +2070,17 @@ main(int argc, char **argv) &guc_info.handles[i]->gass_copy_handle); globus_gass_copy_handle_destroy( &guc_info.handles[i]->cksm_gass_copy_handle); - + globus_free(guc_info.handles[i]); } globus_free(guc_info.handles); guc_info.handles = NULL; - + globus_mutex_destroy(&g_monitor.mutex); globus_cond_destroy(&g_monitor.cond); globus_l_guc_info_destroy(&guc_info); - + globus_module_deactivate(GLOBUS_GSI_GSSAPI_MODULE); /* XXX fix hang globus_module_deactivate_all(); */ @@ -2095,17 +2097,17 @@ Function: globus_l_url_copy_monitor_callback() Returns: ******************************************************************************/ -static +static void globus_l_url_copy_monitor_callback( void * callback_arg, globus_gass_copy_handle_t * handle, globus_object_t * error) -{ +{ globus_l_guc_transfer_t * transfer_info; - + transfer_info = (globus_l_guc_transfer_t *) callback_arg; - + globus_mutex_lock(&g_monitor.mutex); { if(error != NULL) @@ -2113,17 +2115,17 @@ globus_l_url_copy_monitor_callback( if(!g_continue) { globus_l_guc_enqueue_pair( - &transfer_info->guc_info->user_url_list, + &transfer_info->guc_info->user_url_list, transfer_info->urls); - + transfer_info->urls = NULL; - + g_monitor.done = GLOBUS_TRUE; g_monitor.use_err = GLOBUS_TRUE; g_monitor.err = globus_object_copy(error); } else - { + { char * msg; g_monitor.was_error++; msg = globus_error_print_friendly(error); @@ -2132,12 +2134,12 @@ globus_l_url_copy_monitor_callback( } } - + transfer_info->guc_info->conc_outstanding--; transfer_info->handle->current_transfer = NULL; globus_l_guc_url_pair_free(transfer_info->urls); transfer_info->urls = NULL; - + if(transfer_info->handle->source_ftp_attr) { globus_ftp_client_operationattr_destroy( @@ -2149,16 +2151,16 @@ globus_l_url_copy_monitor_callback( globus_ftp_client_operationattr_destroy( &transfer_info->handle->dest_ftp_attr); transfer_info->handle->dest_ftp_attr = NULL; - } + } } globus_mutex_unlock(&g_monitor.mutex); - + globus_callback_register_oneshot( NULL, NULL, globus_l_guc_transfer_kickout, transfer_info); - + return; } /* globus_l_url_copy_monitor_callback() */ @@ -2178,7 +2180,7 @@ globus_l_gass_copy_performance_cb( float avg_throughput) { globus_libc_fprintf(stdout, - " %12" GLOBUS_OFF_T_FORMAT + " %12" GLOBUS_OFF_T_FORMAT " bytes %12.2f MB/sec avg %12.2f MB/sec inst\r", total_bytes, avg_throughput / (1024 * 1024), @@ -2244,14 +2246,14 @@ globus_l_guc_entry_cb( char * tmp_unique; globus_bool_t seen = GLOBUS_FALSE; int retval; - globus_l_guc_transfer_t * transfer_info; + globus_l_guc_transfer_t * transfer_info; globus_l_guc_url_info_t * urlinfo; - + transfer_info = (globus_l_guc_transfer_t *) user_arg; guc_info = transfer_info->guc_info; globus_mutex_lock(&g_monitor.mutex); - + if(guc_info->recurse && info_stat && info_stat->type == GLOBUS_GASS_COPY_GLOB_ENTRY_DIR && info_stat->unique_id && *info_stat->unique_id) @@ -2261,19 +2263,19 @@ globus_l_guc_entry_cb( &guc_info->recurse_hash, tmp_unique, tmp_unique); - + if(retval != 0) { globus_free(tmp_unique); seen = GLOBUS_TRUE; } } - + if(!seen) { - urlinfo = (globus_l_guc_url_info_t *) + urlinfo = (globus_l_guc_url_info_t *) globus_calloc(sizeof(globus_l_guc_url_info_t), 1); - + urlinfo->url = globus_libc_strdup(url); urlinfo->mode = info_stat->mode; urlinfo->mdtm = info_stat->mdtm; @@ -2284,11 +2286,11 @@ globus_l_guc_entry_cb( &transfer_info->matched_url_list, urlinfo); } - + globus_mutex_unlock(&g_monitor.mutex); - - return; -} + + return; +} static void @@ -2299,50 +2301,50 @@ globus_l_guc_dest_entry_cb( { globus_l_guc_info_t * guc_info; int retval; - globus_l_guc_transfer_t * transfer_info; + globus_l_guc_transfer_t * transfer_info; globus_l_guc_url_info_t * urlinfo; - + transfer_info = (globus_l_guc_transfer_t *) user_arg; guc_info = transfer_info->guc_info; globus_mutex_lock(&g_monitor.mutex); - + if(info_stat && info_stat->type != GLOBUS_GASS_COPY_GLOB_ENTRY_DIR) { - urlinfo = (globus_l_guc_url_info_t *) + urlinfo = (globus_l_guc_url_info_t *) globus_calloc(sizeof(globus_l_guc_url_info_t), 1); - + urlinfo->url = globus_libc_strdup(url); urlinfo->mode = info_stat->mode; urlinfo->mdtm = info_stat->mdtm; urlinfo->size = info_stat->size; urlinfo->type = info_stat->type; - + retval = globus_hashtable_insert( &guc_info->dest_hash, urlinfo->url, urlinfo); - + if(retval != 0) { globus_free(urlinfo->url); globus_free(urlinfo); } } - + globus_mutex_unlock(&g_monitor.mutex); - - return; -} -static + return; +} + +static void globus_l_guc_info_destroy( globus_l_guc_info_t * guc_info) { OM_uint32 min_stat; - + if(guc_info->source_subject) { globus_free(guc_info->source_subject); @@ -2416,7 +2418,7 @@ static int globus_l_guc_parse_file( globus_l_guc_info_t * guc_info, - char * file_name, + char * file_name, globus_fifo_t * user_url_list) { FILE * fptr; @@ -2446,7 +2448,7 @@ globus_l_guc_parse_file( url_len = 0; offset = guc_info->partial_offset; length = guc_info->partial_length; - + while(*p && isspace(*p)) { p++; @@ -2460,7 +2462,7 @@ globus_l_guc_parse_file( { continue; } - + if(*p == '"') { rc = sscanf(p, "\"%[^\"]\"", src_url); @@ -2469,16 +2471,16 @@ globus_l_guc_parse_file( else { rc = sscanf(p, "%s", src_url); - } - + } + if(rc != 1) - { + { goto error_parse; } - + url_len += strlen(src_url); p = p + url_len; - + url_len = 0; while(*p && isspace(*p)) { @@ -2493,16 +2495,16 @@ globus_l_guc_parse_file( else { rc = sscanf(p, "%s", dst_url); - } + } if(rc != 1) - { + { goto error_parse; } - + url_len += strlen(dst_url); p = p + url_len; - + while(*p && isspace(*p)) { p++; @@ -2512,7 +2514,7 @@ globus_l_guc_parse_file( rc = sscanf(p, "%"GLOBUS_OFF_T_FORMAT",%"GLOBUS_OFF_T_FORMAT, &offset, &length); if(rc < 1 || offset < -1 || length < -1) - { + { goto error_parse; } } @@ -2548,7 +2550,7 @@ globus_l_guc_parse_file( } return 0; - + error_parse: if(fptr != stdin) { @@ -2556,7 +2558,7 @@ globus_l_guc_parse_file( } fprintf(stderr, _GASCSL("Problem parsing url list: line %d\n"), line_num); return -2; - + } static @@ -2592,7 +2594,7 @@ globus_l_guc_load_alias_file( { line_num++; p = line; - + while(*p && isspace(*p)) { p++; @@ -2601,28 +2603,28 @@ globus_l_guc_load_alias_file( { continue; } - + if(*p == '@') { newalias = GLOBUS_TRUE; rc = sscanf(p, "@%s", buf); if(rc != 1) - { + { goto error_parse; } } else { if(!alias_ent) - { + { goto error_parse; } rc = sscanf(p, "%s", buf); if(rc != 1) - { + { goto error_parse; } - } + } if(newalias) { @@ -2638,7 +2640,7 @@ globus_l_guc_load_alias_file( if(rc != 0) { goto error_parse; - } + } newalias = GLOBUS_FALSE; } else @@ -2649,21 +2651,21 @@ globus_l_guc_load_alias_file( } fclose(fptr); - + guc_l_aliases = GLOBUS_TRUE; - guc_l_src_alias_ent = (globus_l_guc_alias_t *) + guc_l_src_alias_ent = (globus_l_guc_alias_t *) globus_hashtable_lookup(&guc_l_alias_table, (void *) "source"); - guc_l_dst_alias_ent = (globus_l_guc_alias_t *) + guc_l_dst_alias_ent = (globus_l_guc_alias_t *) globus_hashtable_lookup(&guc_l_alias_table, (void *) "destination"); return 0; - + error_parse: fclose(fptr); - fprintf(stderr, + fprintf(stderr, "Problem parsing alias file %s: line %d\n", file_name, line_num); return -2; - + } @@ -2698,14 +2700,14 @@ globus_l_guc_transfer( source_io_handle = globus_l_guc_get_io_handle(src_url, fileno(stdin)); dest_io_handle = globus_l_guc_get_io_handle(dst_url, fileno(stdout)); - if(guc_info->comp_checksum) + if(guc_info->comp_checksum) { /* * Associate the source checksum with the transfer handle * so that the destination checksum can be verified after * the successful transfer. - */ - globus_gass_copy_set_checksum(&handle->gass_copy_handle, + */ + globus_gass_copy_set_checksum(&handle->gass_copy_handle, transfer_info->urls->src_info->checksum); } @@ -2724,7 +2726,7 @@ globus_l_guc_transfer( src_url, GLOBUS_TRUE, GLOBUS_FALSE); - } + } if(dest_io_handle == NULL) { globus_l_guc_gass_attr_init( @@ -2737,12 +2739,12 @@ globus_l_guc_transfer( GLOBUS_FALSE); } - /* setting offsets should have been an attr option in gass_copy but + /* setting offsets should have been an attr option in gass_copy but since we only run one operation per handle this will be ok. */ globus_gass_copy_set_partial_offsets( - &handle->gass_copy_handle, + &handle->gass_copy_handle, transfer_info->urls->offset, - (transfer_info->urls->length == -1) ? + (transfer_info->urls->length == -1) ? -1 : transfer_info->urls->offset + transfer_info->urls->length); if(source_io_handle) @@ -2769,18 +2771,18 @@ globus_l_guc_transfer( { if(dst_url[strlen(dst_url) - 1] == '/') { - dst_is_dir = GLOBUS_TRUE; + dst_is_dir = GLOBUS_TRUE; } else { dst_is_dir = GLOBUS_FALSE; - } - + } + if(!g_quiet_flag) { if(dst_is_dir) { - src_filename = strrchr(src_url, '/'); + src_filename = strrchr(src_url, '/'); while(src_filename > src_url && *src_filename == '/') { src_filename--; @@ -2790,8 +2792,8 @@ globus_l_guc_transfer( src_filename--; } src_filename++; - - dst_filename = strrchr(dst_url, '/'); + + dst_filename = strrchr(dst_url, '/'); while(dst_filename > dst_url && *dst_filename == '/') { dst_filename--; @@ -2809,16 +2811,16 @@ globus_l_guc_transfer( { src_filename = src_url; } - + dst_filename = strrchr(dst_url, '/'); if(!dst_filename++) { dst_filename = dst_url; } } - - - if(src_url_base == GLOBUS_NULL || + + + if(src_url_base == GLOBUS_NULL || src_filename - src_url != src_url_base_len || strncmp(src_url, src_url_base, src_filename - src_url)) { @@ -2827,7 +2829,7 @@ globus_l_guc_transfer( globus_free(src_url_base); } src_url_base = globus_libc_strdup(src_url); - + src_url_base_len = src_filename - src_url; src_url_base[src_url_base_len] = '\0'; new_url = GLOBUS_TRUE; @@ -2836,8 +2838,8 @@ globus_l_guc_transfer( { new_url = GLOBUS_FALSE; } - - if(dst_url_base == GLOBUS_NULL || + + if(dst_url_base == GLOBUS_NULL || dst_filename - dst_url != dst_url_base_len || strncmp(dst_url, dst_url_base, dst_filename - dst_url)) { @@ -2846,12 +2848,12 @@ globus_l_guc_transfer( globus_free(dst_url_base); } dst_url_base = globus_libc_strdup(dst_url); - + dst_url_base_len = dst_filename - dst_url; dst_url_base[dst_url_base_len] = '\0'; new_url = GLOBUS_TRUE; } - + if(new_url) { globus_guc_transfer_update( @@ -2860,7 +2862,7 @@ globus_l_guc_transfer( globus_guc_transfer_update( NULL, NULL, src_filename, dst_filename); } - + if(dst_is_dir) { if(guc_info->dump_only_file) @@ -2870,16 +2872,16 @@ globus_l_guc_transfer( globus_l_guc_src_dst_pair_t * url_pair; url_pair = (globus_l_guc_src_dst_pair_t *) globus_malloc(sizeof(globus_l_guc_src_dst_pair_t)); - + url_pair->src_url = globus_libc_strdup(transfer_info->urls->src_url); url_pair->dst_url = globus_libc_strdup(transfer_info->urls->dst_url); url_pair->offset = transfer_info->urls->offset; url_pair->length = transfer_info->urls->length; url_pair->src_info = transfer_info->urls->src_info; transfer_info->urls->src_info = NULL; - + globus_l_guc_enqueue_pair( - &guc_info->dump_url_list, + &guc_info->dump_url_list, url_pair); } result = GLOBUS_SUCCESS; @@ -2914,10 +2916,10 @@ globus_l_guc_transfer( GLOBUS_FALSE, GLOBUS_TRUE); } - + result = globus_l_guc_expand_single_url(transfer_info); if(result != GLOBUS_SUCCESS) - { + { err = globus_error_peek(result); } result = GLOBUS_SUCCESS; @@ -2944,22 +2946,22 @@ globus_l_guc_transfer( globus_l_guc_src_dst_pair_t * url_pair; url_pair = (globus_l_guc_src_dst_pair_t *) globus_malloc(sizeof(globus_l_guc_src_dst_pair_t)); - + url_pair->src_url = globus_libc_strdup(transfer_info->urls->src_url); url_pair->dst_url = globus_libc_strdup(transfer_info->urls->dst_url); url_pair->offset = transfer_info->urls->offset; url_pair->length = transfer_info->urls->length; url_pair->src_info = transfer_info->urls->src_info; - transfer_info->urls->src_info = NULL; - + transfer_info->urls->src_info = NULL; + globus_l_guc_enqueue_pair( - &guc_info->dump_url_list, + &guc_info->dump_url_list, url_pair); } result = GLOBUS_SUCCESS; - + globus_l_url_copy_monitor_callback( - transfer_info, &handle->gass_copy_handle, NULL); + transfer_info, &handle->gass_copy_handle, NULL); } } } @@ -2983,11 +2985,11 @@ globus_l_guc_transfer( { globus_free(dst_url_base); } - - return result; + + return result; } - + static globus_result_t globus_l_guc_transfer_files( @@ -3010,7 +3012,7 @@ globus_l_guc_transfer_files( g_monitor.use_err = GLOBUS_FALSE; guc_info->cancelled = GLOBUS_FALSE; guc_info->conc_outstanding = 0; - + for(i = 0; i < guc_info->conc; i++) { transfer_info = (globus_l_guc_transfer_t *) @@ -3021,10 +3023,10 @@ globus_l_guc_transfer_files( transfer_info->guc_info = guc_info; transfer_info->needs_mkdir = GLOBUS_FALSE; globus_fifo_init(&transfer_info->matched_url_list); - + globus_l_guc_transfer_kickout(transfer_info); } - + globus_mutex_lock(&g_monitor.mutex); while(!g_monitor.done || guc_info->conc_outstanding > 0) @@ -3036,27 +3038,27 @@ globus_l_guc_transfer_files( { fprintf(stderr, "%s", _GASCSL("\nCancelling copy...\n")); guc_info->cancelled = GLOBUS_TRUE; - + if(guc_info->dumpfile || guc_info->dump_only_file) { globus_l_guc_dump_urls(guc_info); } for(i = 0; i < guc_info->conc; i++) - { + { globus_gass_copy_cancel( - &guc_info->handles[i]->gass_copy_handle, - GLOBUS_NULL, + &guc_info->handles[i]->gass_copy_handle, + GLOBUS_NULL, GLOBUS_NULL); } globus_l_globus_url_copy_ctrlc_handled = GLOBUS_TRUE; - + globus_callback_unregister_signal_handler( GLOBUS_SIGNAL_INTERRUPT, GLOBUS_NULL, GLOBUS_NULL); } } globus_mutex_unlock(&g_monitor.mutex); - + if(g_monitor.use_err) { @@ -3080,7 +3082,7 @@ globus_l_guc_transfer_files( { goto error_transfer; } - + if(!globus_l_globus_url_copy_ctrlc_handled) { globus_callback_unregister_signal_handler( @@ -3104,7 +3106,7 @@ globus_l_guc_transfer_files( globus_error_construct_string( GLOBUS_NULL, GLOBUS_NULL, - _GASCSL("There were errors with %d transfers.\n"), + _GASCSL("There were errors with %d transfers.\n"), g_monitor.was_error)); } else @@ -3115,8 +3117,8 @@ globus_l_guc_transfer_files( GLOBUS_NULL, _GASCSL("There was an error with 1 transfer.\n"))); } - - } + + } return result; error_transfer: @@ -3129,13 +3131,13 @@ globus_l_guc_transfer_files( { globus_free(dest_io_handle); } - + if(!globus_l_globus_url_copy_ctrlc_handled) { globus_callback_unregister_signal_handler( GLOBUS_SIGNAL_INTERRUPT, GLOBUS_NULL, GLOBUS_NULL); } - + return result; } @@ -3168,23 +3170,23 @@ globus_l_guc_file_to_string( error_memory: result = globus_error_put( - globus_error_construct_string( - GLOBUS_NULL, - GLOBUS_NULL, - _GASCSL("Could not open file: %s\n"), - filename)); + globus_error_construct_string( + GLOBUS_NULL, + GLOBUS_NULL, + _GASCSL("Could not open file: %s\n"), + filename)); fclose(fp); error_open: if(result == GLOBUS_SUCCESS) - { - result = globus_error_put( - globus_error_construct_string( - GLOBUS_NULL, - GLOBUS_NULL, - _GASCSL("Could not allocate memory.\n"))); + { + result = globus_error_put( + globus_error_construct_string( + GLOBUS_NULL, + GLOBUS_NULL, + _GASCSL("Could not allocate memory.\n"))); } return result; -} +} #if 0 static @@ -3448,14 +3450,14 @@ guc_l_convert_file_url( return globus_libc_strdup(in_url); } dir_ptr = globus_url_string_hex_encode(tmp_path, ""); - + /* In windows, absolute paths don't begin with / */ tmp_ptr = globus_common_create_string("file://%s%s", dir_ptr[0] == '/' ? "" : "/", dir_ptr); - + globus_free(dir_ptr); globus_free(tmp_path); - + return tmp_ptr; } @@ -3540,13 +3542,13 @@ globus_l_guc_load_cred( guc_gencert(&buf); auto_data.length = buf.length; auto_data.value = buf.value; - return result; + return result; } else - { + { buf.value = globus_common_create_string("X509_USER_PROXY=%s", path); buf.length = strlen(buf.value); - + maj_stat = gss_import_cred( &min_stat, &cred, @@ -3559,7 +3561,7 @@ globus_l_guc_load_cred( { goto error; } - + globus_free(buf.value); } } @@ -3588,18 +3590,18 @@ globus_l_guc_load_cred( { goto error; } - + maj_stat = gss_display_name(&min_stat, name, &buf, NULL); if(maj_stat != GSS_S_COMPLETE) { goto error; } - + *out_subject = buf.value; - + gss_release_name(&min_stat, &name); } - + if(out_cred) { *out_cred = cred; @@ -3610,7 +3612,7 @@ globus_l_guc_load_cred( } return result; - + error: result = globus_error_put(globus_error_construct_gssapi_error( NULL, NULL, maj_stat, min_stat)); @@ -3703,7 +3705,7 @@ globus_l_guc_parse_arguments( /* determine the program name */ - + program = strrchr(argv[0],'/'); if(!program) { @@ -3711,7 +3713,7 @@ globus_l_guc_parse_arguments( } else { - program++; + program++; } globus_url_copy_i_args_init(); @@ -3730,7 +3732,7 @@ globus_l_guc_parse_arguments( { return -1; } - + for(list = options_found; !globus_list_empty(list); list = globus_list_rest(list)) @@ -3828,7 +3830,7 @@ globus_l_guc_parse_arguments( globus_url_copy_l_args_error( "invalid value for block size"); return -1; - } + } guc_info->block_size = (globus_size_t) tmp_off; break; case arg_f: @@ -3841,7 +3843,7 @@ globus_l_guc_parse_arguments( globus_url_copy_l_args_error( "invalid value for tcp buffer size"); return -1; - } + } guc_info->tcp_buffer_size = (globus_size_t) tmp_off; break; case arg_s: @@ -3854,7 +3856,7 @@ globus_l_guc_parse_arguments( globus_url_copy_l_args_error( "Invalid value to -t. Must be an integer"); return -1; - } + } break; case arg_ss: guc_info->source_subject = globus_libc_strdup(instance->values[0]); @@ -3910,7 +3912,7 @@ globus_l_guc_parse_arguments( break; case arg_create_dest: guc_info->create_dest = GLOBUS_TRUE; - break; + break; case arg_stripe_bs: rc = globus_args_bytestr_to_num(instance->values[0], &tmp_off); if(rc != 0) @@ -3918,19 +3920,19 @@ globus_l_guc_parse_arguments( globus_url_copy_l_args_error( "invalid value for stripe blocksize"); return -1; - } + } guc_info->stripe_bs = (globus_size_t) tmp_off; - break; - case arg_striped: - guc_info->striped = GLOBUS_TRUE; - break; - case arg_udt: - guc_info->udt = GLOBUS_TRUE; - break; - case arg_nl_bottleneck: - guc_info->nl_bottleneck = GLOBUS_TRUE; + break; + case arg_striped: + guc_info->striped = GLOBUS_TRUE; + break; + case arg_udt: + guc_info->udt = GLOBUS_TRUE; + break; + case arg_nl_bottleneck: + guc_info->nl_bottleneck = GLOBUS_TRUE; guc_info->nl_level = 15; - break; + break; case arg_nl_interval: guc_info->nl_bottleneck = GLOBUS_TRUE; @@ -3942,19 +3944,19 @@ globus_l_guc_parse_arguments( _GASCSL("Error: Argument to nl-bottleneck must be a 4 bit mask" "\n")); return -1; - } + } break; - case arg_ipv6: - guc_info->ipv6 = GLOBUS_TRUE; - break; - case arg_gridftp2: - guc_info->gridftp2 = GLOBUS_TRUE; - break; - case arg_gridftp2_off: - guc_info->gridftp2 = GLOBUS_FALSE; - break; + case arg_ipv6: + guc_info->ipv6 = GLOBUS_TRUE; + break; + case arg_gridftp2: + guc_info->gridftp2 = GLOBUS_TRUE; + break; + case arg_gridftp2_off: + guc_info->gridftp2 = GLOBUS_FALSE; + break; case arg_src_pipe_str: guc_info->src_pipe_str = @@ -3972,31 +3974,31 @@ globus_l_guc_parse_arguments( break; case arg_src_net_stack_str: - guc_info->src_net_stack_str = + guc_info->src_net_stack_str = globus_libc_strdup(instance->values[0]); break; case arg_src_disk_stack_str: - guc_info->src_disk_stack_str = + guc_info->src_disk_stack_str = globus_libc_strdup(instance->values[0]); break; case arg_dst_net_stack_str: - guc_info->dst_net_stack_str = + guc_info->dst_net_stack_str = globus_libc_strdup(instance->values[0]); break; case arg_dst_disk_stack_str: - guc_info->dst_disk_stack_str = + guc_info->dst_disk_stack_str = globus_libc_strdup(instance->values[0]); break; case arg_net_stack_str: - guc_info->src_net_stack_str = + guc_info->src_net_stack_str = globus_libc_strdup(instance->values[0]); - guc_info->dst_net_stack_str = + guc_info->dst_net_stack_str = globus_libc_strdup(instance->values[0]); break; case arg_disk_stack_str: - guc_info->src_disk_stack_str = + guc_info->src_disk_stack_str = globus_libc_strdup(instance->values[0]); - guc_info->dst_disk_stack_str = + guc_info->dst_disk_stack_str = globus_libc_strdup(instance->values[0]); break; case arg_authz_assert: @@ -4004,31 +4006,31 @@ globus_l_guc_parse_arguments( instance->values[0], &authz_assert); if(result != GLOBUS_SUCCESS) { - fprintf(stderr, + fprintf(stderr, _GASCSL("Error: Unable to read authz assertion %s\n"), - globus_error_print_friendly(globus_error_peek(result))); + globus_error_print_friendly(globus_error_peek(result))); return -1; } break; case arg_src_authz_assert: result = globus_l_guc_file_to_string( - instance->values[0], &guc_info->src_authz_assert); + instance->values[0], &guc_info->src_authz_assert); if(result != GLOBUS_SUCCESS) { - fprintf(stderr, + fprintf(stderr, _GASCSL("Error: Unable to read src authz assertion %s\n"), - globus_error_print_friendly(globus_error_peek(result))); + globus_error_print_friendly(globus_error_peek(result))); return -1; } break; case arg_dst_authz_assert: result = globus_l_guc_file_to_string( - instance->values[0], &guc_info->dst_authz_assert); + instance->values[0], &guc_info->dst_authz_assert); if(result != GLOBUS_SUCCESS) { - fprintf(stderr, + fprintf(stderr, _GASCSL("Error: Unable to read dst authz assertion %s\n"), - globus_error_print_friendly(globus_error_peek(result))); + globus_error_print_friendly(globus_error_peek(result))); return -1; } break; @@ -4047,8 +4049,8 @@ globus_l_guc_parse_arguments( break; case arg_src_cred: result = globus_l_guc_load_cred( - instance->values[0], - &guc_info->src_cred, + instance->values[0], + &guc_info->src_cred, &guc_info->src_cred_subj); if(result != GLOBUS_SUCCESS) { @@ -4060,7 +4062,7 @@ globus_l_guc_parse_arguments( break; case arg_dst_cred: result = globus_l_guc_load_cred( - instance->values[0], + instance->values[0], &guc_info->dst_cred, &guc_info->dst_cred_subj); if(result != GLOBUS_SUCCESS) @@ -4073,7 +4075,7 @@ globus_l_guc_parse_arguments( break; case arg_data_cred: result = globus_l_guc_load_cred( - instance->values[0], + instance->values[0], &guc_info->data_cred, &guc_info->data_cred_subj); if(result != GLOBUS_SUCCESS) @@ -4084,75 +4086,75 @@ globus_l_guc_parse_arguments( return -1; } break; - case arg_delayed_pasv: - guc_info->delayed_pasv = GLOBUS_TRUE; - break; - case arg_pipeline: - guc_info->pipeline = GLOBUS_TRUE; - break; - case arg_pipelineq: - guc_info->pipeline = GLOBUS_TRUE; - guc_info->pipelineq = atoi(instance->values[0]); - break; - case arg_sync: - guc_info->sync = GLOBUS_TRUE; - break; - case arg_sync_level: - guc_info->sync_level = atoi(instance->values[0]); - break; - case arg_checksum: - guc_info->comp_checksum = GLOBUS_TRUE; - break; - case arg_checksum_algo: - guc_info->checksum_algo = globus_libc_strdup(instance->values[0]); - break; - case arg_dump_only: - guc_info->dump_only_file = globus_libc_strdup(instance->values[0]); - break; - case arg_preserve: - case arg_perms: - guc_info->perms = GLOBUS_TRUE; - break; - case arg_allo: - guc_info->allo = GLOBUS_TRUE; - break; - case arg_noallo: - guc_info->allo = GLOBUS_FALSE; - break; - case arg_partial_offset: + case arg_delayed_pasv: + guc_info->delayed_pasv = GLOBUS_TRUE; + break; + case arg_pipeline: + guc_info->pipeline = GLOBUS_TRUE; + break; + case arg_pipelineq: + guc_info->pipeline = GLOBUS_TRUE; + guc_info->pipelineq = atoi(instance->values[0]); + break; + case arg_sync: + guc_info->sync = GLOBUS_TRUE; + break; + case arg_sync_level: + guc_info->sync_level = atoi(instance->values[0]); + break; + case arg_checksum: + guc_info->comp_checksum = GLOBUS_TRUE; + break; + case arg_checksum_algo: + guc_info->checksum_algo = globus_libc_strdup(instance->values[0]); + break; + case arg_dump_only: + guc_info->dump_only_file = globus_libc_strdup(instance->values[0]); + break; + case arg_preserve: + case arg_perms: + guc_info->perms = GLOBUS_TRUE; + break; + case arg_allo: + guc_info->allo = GLOBUS_TRUE; + break; + case arg_noallo: + guc_info->allo = GLOBUS_FALSE; + break; + case arg_partial_offset: rc = globus_args_bytestr_to_num(instance->values[0], &tmp_off); if(rc != 0) { globus_url_copy_l_args_error( "invalid value for offset"); return -1; - } + } guc_info->partial_offset = tmp_off; - break; - case arg_partial_length: + break; + case arg_partial_length: rc = globus_args_bytestr_to_num(instance->values[0], &tmp_off); if(rc != 0) { globus_url_copy_l_args_error( "invalid value for length"); return -1; - } + } guc_info->partial_length = tmp_off; if(guc_info->partial_offset == -1) { guc_info->partial_offset = 0; } - break; - case arg_fast: - guc_info->list_uses_data_mode = GLOBUS_TRUE; - if(guc_info->num_streams < 1) - { + break; + case arg_fast: + guc_info->list_uses_data_mode = GLOBUS_TRUE; + if(guc_info->num_streams < 1) + { guc_info->num_streams = 1; } - break; + break; - case arg_list: + case arg_list: guc_info->list_url = globus_libc_strdup(instance->values[0]); break; @@ -4174,7 +4176,7 @@ globus_l_guc_parse_arguments( { if(guc_info->src_disk_stack_str) { - tmp_str = globus_common_create_string("%s,%s", + tmp_str = globus_common_create_string("%s,%s", guc_info->src_pipe_str, guc_info->src_disk_stack_str); free(guc_info->src_disk_stack_str); guc_info->src_disk_stack_str = tmp_str; @@ -4188,7 +4190,7 @@ globus_l_guc_parse_arguments( { if(guc_info->dst_disk_stack_str) { - tmp_str = globus_common_create_string("%s,%s", + tmp_str = globus_common_create_string("%s,%s", guc_info->dst_pipe_str, guc_info->dst_disk_stack_str); free(guc_info->dst_disk_stack_str); guc_info->dst_disk_stack_str = tmp_str; @@ -4199,7 +4201,7 @@ globus_l_guc_parse_arguments( "%s,ordering", guc_info->dst_pipe_str); } } - /* if we are doing multicast allow no dest option by adding the first + /* if we are doing multicast allow no dest option by adding the first url in the file */ if(guc_info->mc_file != NULL) { @@ -4243,12 +4245,12 @@ globus_l_guc_parse_arguments( } rc = -1; - if(guc_info->dump_only_file && guc_info->dump_only_file[0] == '-' && + if(guc_info->dump_only_file && guc_info->dump_only_file[0] == '-' && guc_info->dump_only_file[1] == '\0') { guc_info->dump_only_fp = stdout; } - + if(guc_info->dumpfile) { if(guc_info->dump_only_file && !guc_info->dump_only_fp) @@ -4263,7 +4265,7 @@ globus_l_guc_parse_arguments( rc = globus_l_guc_parse_file( guc_info, guc_info->dumpfile, &guc_info->user_url_list); - + if(rc == 0 && globus_fifo_empty(&guc_info->user_url_list)) { printf("Dumpfile exists and is empty. Nothing to do."); @@ -4275,14 +4277,14 @@ globus_l_guc_parse_arguments( } } - + if(rc == 0) { if(g_verbose_flag) { printf("Reading URLs from dumpfile\n"); } - } + } else if(file_name != NULL) { /* get source dest pairs */ @@ -4307,8 +4309,8 @@ globus_l_guc_parse_arguments( else if(guc_info->list_url == NULL) /* only if we are not listing */ { /* there must be 2 additional unflagged arguments: - * the source and destination URL's - */ + * the source and destination URL's + */ if(argc > 3) { globus_url_copy_l_args_error("too many url strings specified"); @@ -4328,7 +4330,7 @@ globus_l_guc_parse_arguments( return -1; } else - { + { ent = (globus_l_guc_src_dst_pair_t *) globus_malloc(sizeof(globus_l_guc_src_dst_pair_t)); @@ -4337,10 +4339,10 @@ globus_l_guc_parse_arguments( ent->offset = guc_info->partial_offset; ent->length = guc_info->partial_length; ent->src_info = NULL; - + globus_fifo_enqueue(&guc_info->user_url_list, ent); } - + } globus_l_guc_load_alias_file(guc_info->alias_file); @@ -4350,7 +4352,7 @@ globus_l_guc_parse_arguments( if(guc_info->src_cred == GSS_C_NO_CREDENTIAL) { result = globus_l_guc_load_cred( - cred_path, + cred_path, &guc_info->src_cred, &guc_info->src_cred_subj); if(result != GLOBUS_SUCCESS) @@ -4364,7 +4366,7 @@ globus_l_guc_parse_arguments( if(guc_info->dst_cred == GSS_C_NO_CREDENTIAL) { result = globus_l_guc_load_cred( - cred_path, + cred_path, &guc_info->dst_cred, &guc_info->dst_cred_subj); if(result != GLOBUS_SUCCESS) @@ -4375,15 +4377,15 @@ globus_l_guc_parse_arguments( return -1; } } - + globus_free(cred_path); } - - if(guc_info->src_cred != GSS_C_NO_CREDENTIAL && + + if(guc_info->src_cred != GSS_C_NO_CREDENTIAL && guc_info->dst_cred == GSS_C_NO_CREDENTIAL) { result = globus_l_guc_load_cred( - NULL, + NULL, &guc_info->dst_cred, &guc_info->dst_cred_subj); if(result != GLOBUS_SUCCESS) @@ -4394,11 +4396,11 @@ globus_l_guc_parse_arguments( return -1; } } - if(guc_info->src_cred == GSS_C_NO_CREDENTIAL && + if(guc_info->src_cred == GSS_C_NO_CREDENTIAL && guc_info->dst_cred != GSS_C_NO_CREDENTIAL) { result = globus_l_guc_load_cred( - NULL, + NULL, &guc_info->src_cred, &guc_info->src_cred_subj); if(result != GLOBUS_SUCCESS) @@ -4457,7 +4459,7 @@ globus_l_guc_parse_arguments( globus_fifo_peek(&guc_info->user_url_list); /* we must verify that we are doing a 3pt. this means that - both src and dst url must be ftp:// or gsiftp:// + both src and dst url must be ftp:// or gsiftp:// obviously this doesnt work for the case where there is a file full or url transfers and the first is 3pt fpt transfers but the remainder are not. that case is a PITA. For now @@ -4556,7 +4558,7 @@ globus_l_guc_parse_arguments( globus_free(net_netlog_str); globus_free(disk_netlog_str); } - + /* check arguemnt validity */ if((guc_info->options & GLOBUS_URL_COPY_ARG_ASCII) && (guc_info->options & GLOBUS_URL_COPY_ARG_BINARY) ) @@ -4573,7 +4575,7 @@ globus_l_guc_parse_arguments( return -1; } return 0; - + } @@ -4592,7 +4594,7 @@ globus_l_guc_create_dir( globus_url_t parsed_url; globus_list_t * mkdir_urls = GLOBUS_NULL; char * dst_filename; - + rc = globus_url_parse(url, &parsed_url); if(rc != 0) { @@ -4624,10 +4626,10 @@ globus_l_guc_create_dir( save_url[dst_filename - dst_mkurl + 1] = '\0'; globus_list_insert(&mkdir_urls, save_url); - - *dst_filename = '\0'; + + *dst_filename = '\0'; } - + globus_url_destroy(&parsed_url); rc = globus_url_parse(dst_mkurl, &parsed_url); } @@ -4636,7 +4638,7 @@ globus_l_guc_create_dir( globus_url_destroy(&parsed_url); } globus_free(dst_mkurl); - + dst_mkurl = globus_libc_strdup(url); dst_filename = strrchr(dst_mkurl, '/'); if(dst_filename && *(++dst_filename)) @@ -4646,12 +4648,12 @@ globus_l_guc_create_dir( globus_list_insert(&mkdir_urls, dst_mkurl); while(!done_create_dest && !globus_list_empty(mkdir_urls)) - { + { globus_bool_t inserted = GLOBUS_FALSE; char * already_exists = NULL; - + dst_mkurl = globus_list_remove(&mkdir_urls, mkdir_urls); - + already_exists = globus_hashtable_lookup( &guc_info->mkdir_hash, dst_mkurl); @@ -4680,7 +4682,7 @@ globus_l_guc_create_dir( { done_create_dest = GLOBUS_TRUE; } - + if(result == GLOBUS_SUCCESS || !first_attempt) { globus_mutex_lock(&g_monitor.mutex); @@ -4700,22 +4702,22 @@ globus_l_guc_create_dir( &handle->dest_ftp_attr); handle->dest_ftp_attr = NULL; } - + first_attempt = GLOBUS_FALSE; if(!inserted) { globus_free(dst_mkurl); } } - + while(!globus_list_empty(mkdir_urls)) { dst_mkurl = globus_list_remove(&mkdir_urls, mkdir_urls); globus_free(dst_mkurl); } - + return GLOBUS_SUCCESS; - + error: return result; } @@ -4740,7 +4742,7 @@ globus_l_guc_expand_urls( 256, globus_hashtable_string_hash, globus_hashtable_string_keyeq); - + globus_hashtable_init( &guc_info->dest_hash, 256, @@ -4760,19 +4762,19 @@ globus_l_guc_expand_urls( src_url = user_url_pair->src_url; dst_url = user_url_pair->dst_url; - + no_expand = GLOBUS_FALSE; if(strcmp("-", src_url) == 0) { expanded_url_pair = (globus_l_guc_src_dst_pair_t *) globus_malloc(sizeof(globus_l_guc_src_dst_pair_t)); - + expanded_url_pair->src_url = globus_libc_strdup(src_url); expanded_url_pair->dst_url = globus_libc_strdup(dst_url); expanded_url_pair->offset = user_url_pair->offset; expanded_url_pair->length = user_url_pair->length; expanded_url_pair->src_info = NULL; - + if(guc_info->create_dest && !guc_info->dump_only_file) { result = globus_l_guc_create_dir( @@ -4784,11 +4786,11 @@ globus_l_guc_expand_urls( } globus_fifo_enqueue( - &guc_info->expanded_url_list, + &guc_info->expanded_url_list, expanded_url_pair); no_expand = GLOBUS_TRUE; } - + globus_l_guc_gass_attr_init( &handle->source_gass_copy_attr, &handle->source_gass_attr, @@ -4810,7 +4812,7 @@ globus_l_guc_expand_urls( } if(!no_expand) - { + { globus_l_guc_transfer_t transfer_info; transfer_info.urls = user_url_pair; globus_fifo_init(&transfer_info.matched_url_list); @@ -4830,17 +4832,17 @@ globus_l_guc_expand_urls( if(result != GLOBUS_SUCCESS) { if(!g_continue) - { + { globus_fifo_enqueue( - &transfer_info.guc_info->user_url_list, + &transfer_info.guc_info->user_url_list, transfer_info.urls); transfer_info.urls = NULL; } - + globus_l_guc_url_pair_free(transfer_info.urls); goto error_expand; - + } } globus_ftp_client_operationattr_destroy(&handle->source_ftp_attr); @@ -4850,18 +4852,18 @@ globus_l_guc_expand_urls( globus_ftp_client_operationattr_destroy(&handle->dest_ftp_attr); handle->dest_ftp_attr = NULL; } - + globus_l_guc_url_pair_free(user_url_pair); } - if(!globus_fifo_empty(&guc_info->expanded_url_list) || + if(!globus_fifo_empty(&guc_info->expanded_url_list) || guc_info->sync || guc_info->dump_only_fp) { no_matches = GLOBUS_FALSE; } result = globus_l_guc_transfer_files(guc_info); - + if(globus_l_globus_url_copy_ctrlc_handled) { goto error_transfer; @@ -4874,14 +4876,14 @@ globus_l_guc_expand_urls( goto error_transfer; } } - + if(no_matches && result == GLOBUS_SUCCESS) { result = globus_error_put( globus_error_construct_string( GLOBUS_NULL, GLOBUS_NULL, - _GASCSL("No files matched the source url.\n"))); + _GASCSL("No files matched the source url.\n"))); } if(was_error && result == GLOBUS_SUCCESS) { @@ -4910,15 +4912,15 @@ globus_l_guc_expand_urls( handle->dest_ftp_attr = NULL; } -error_transfer: +error_transfer: globus_hashtable_destroy_all(&guc_info->recurse_hash, globus_l_guc_hashtable_element_free); globus_hashtable_destroy_all(&guc_info->dest_hash, globus_l_guc_url_info_free); globus_hashtable_destroy_all(&guc_info->mkdir_hash, globus_l_guc_hashtable_element_free); - - return result; + + return result; } typedef struct @@ -4932,17 +4934,17 @@ typedef struct } globus_l_guc_cksm_info_t; -static +static void globus_l_guc_cksm_cb( void * callback_arg, globus_gass_copy_handle_t * handle, globus_object_t * error) -{ +{ globus_l_guc_cksm_info_t * cksm_info; cksm_info = (globus_l_guc_cksm_info_t *) callback_arg; - + if(error) { globus_free(cksm_info->urlinfo->checksum); @@ -4954,7 +4956,7 @@ globus_l_guc_cksm_cb( cksm_info->done = GLOBUS_TRUE; globus_cond_signal(&cksm_info->monitor->cond); } - globus_mutex_unlock(&cksm_info->monitor->mutex); + globus_mutex_unlock(&cksm_info->monitor->mutex); } @@ -4970,7 +4972,7 @@ globus_l_guc_check_sync( globus_bool_t retval = GLOBUS_TRUE; globus_result_t result = GLOBUS_SUCCESS; globus_l_guc_url_info_t * dest_urlinfo; - + globus_mutex_lock(&g_monitor.mutex); dest_urlinfo = globus_hashtable_remove(&guc_info->dest_hash, dst_url); globus_mutex_unlock(&g_monitor.mutex); @@ -4988,13 +4990,13 @@ globus_l_guc_check_sync( globus_mutex_init(&cksm_monitor.mutex, NULL); globus_cond_init(&cksm_monitor.cond, NULL); - + src_urlinfo->checksum = malloc(CKSM_SIZE); src_cksm_info.urlinfo = src_urlinfo; src_cksm_info.done = GLOBUS_FALSE; src_cksm_info.monitor = &cksm_monitor; src_cksm_info.error = NULL; - + result = globus_gass_copy_cksm_async( &handle->gass_copy_handle, src_urlinfo->url, @@ -5013,20 +5015,20 @@ globus_l_guc_check_sync( } globus_ftp_client_handle_t real_ftp_handle; globus_ftp_client_handle_t cksm_ftp_handle; - + dest_urlinfo->checksum = malloc(CKSM_SIZE); dst_cksm_info.urlinfo = dest_urlinfo; dst_cksm_info.done = GLOBUS_FALSE; dst_cksm_info.monitor = &cksm_monitor; dst_cksm_info.error = NULL; - + globus_gass_copy_get_ftp_handle( &handle->gass_copy_handle, &real_ftp_handle); globus_gass_copy_get_ftp_handle( &handle->cksm_gass_copy_handle, &cksm_ftp_handle); globus_ftp_client_handle_borrow_connection( &real_ftp_handle, GLOBUS_FALSE, &cksm_ftp_handle, GLOBUS_TRUE); - + result = globus_gass_copy_cksm_async( &handle->cksm_gass_copy_handle, dest_urlinfo->url, @@ -5046,7 +5048,7 @@ globus_l_guc_check_sync( goto error; } - + globus_mutex_lock(&cksm_monitor.mutex); while(!src_cksm_info.done || !dst_cksm_info.done) { @@ -5054,7 +5056,7 @@ globus_l_guc_check_sync( &cksm_monitor.cond, &cksm_monitor.mutex); } globus_mutex_unlock(&cksm_monitor.mutex); - + if(src_cksm_info.error) { result = globus_error_put(src_cksm_info.error); @@ -5071,7 +5073,7 @@ globus_l_guc_check_sync( goto error; } - + if(src_urlinfo->checksum && dest_urlinfo->checksum && strcmp(src_urlinfo->checksum, dest_urlinfo->checksum) == 0) { @@ -5086,7 +5088,7 @@ globus_l_guc_check_sync( break; case GLOBUS_L_GUC_DATE: - if(dest_urlinfo->mdtm >= src_urlinfo->mdtm && + if(dest_urlinfo->mdtm >= src_urlinfo->mdtm && src_urlinfo->mdtm != -1 && dest_urlinfo->size == src_urlinfo->size && src_urlinfo->size != -1) @@ -5094,7 +5096,7 @@ globus_l_guc_check_sync( retval = GLOBUS_FALSE; } break; - + case GLOBUS_L_GUC_SIZE: if(dest_urlinfo->size == src_urlinfo->size && src_urlinfo->size != -1) @@ -5109,14 +5111,14 @@ globus_l_guc_check_sync( retval = GLOBUS_FALSE; } break; - + default: break; } globus_l_guc_url_info_free(dest_urlinfo); } - + *mismatch = retval; return GLOBUS_SUCCESS; @@ -5142,41 +5144,41 @@ globus_l_guc_expand_single_url( globus_result_t result; globus_bool_t dst_is_file; globus_bool_t matched_is_dir; - int files_matched; + int files_matched; globus_l_guc_info_t * guc_info; globus_l_guc_handle_t * handle; globus_bool_t do_transfer = GLOBUS_TRUE; - int rc; - + int rc; + src_url = transfer_info->urls->src_url; dst_url = transfer_info->urls->dst_url; handle = transfer_info->handle; guc_info = transfer_info->guc_info; - + result = globus_gass_copy_glob_expand_url( &handle->gass_copy_handle, src_url, &handle->source_gass_copy_attr, globus_l_guc_entry_cb, transfer_info); - + if(result != GLOBUS_SUCCESS) { result = globus_error_put( - globus_error_construct_error( - GLOBUS_NULL, - globus_error_peek(result), - 0, - __FILE__, - GLOBUS_NULL, - __LINE__, - "Unable to list url %s:", + globus_error_construct_error( + GLOBUS_NULL, + globus_error_peek(result), + 0, + __FILE__, + GLOBUS_NULL, + __LINE__, + "Unable to list url %s:", src_url)); - goto error_expand; + goto error_expand; } - + url_len = strlen(dst_url); - + if(dst_url[url_len - 1] == '/') { dst_is_file = GLOBUS_FALSE; @@ -5189,7 +5191,7 @@ globus_l_guc_expand_single_url( if(guc_info->sync) { globus_gass_copy_glob_stat_t stat_info; - + result = globus_gass_copy_stat( &handle->gass_copy_handle, dst_url, @@ -5202,7 +5204,7 @@ globus_l_guc_expand_single_url( char * tmp_dst; tmp_dst = globus_libc_strdup(dst_url); - + globus_mutex_lock(&g_monitor.mutex); rc = globus_hashtable_insert( &guc_info->mkdir_hash, @@ -5241,7 +5243,7 @@ globus_l_guc_expand_single_url( globus_l_guc_dest_entry_cb( dst_url, &stat_info, transfer_info); } - + if(stat_info.symlink_target) { globus_free(stat_info.symlink_target); @@ -5256,7 +5258,7 @@ globus_l_guc_expand_single_url( char * tmp_errstr; globus_object_t * tmp_err; char * tmp_ptr; - + tmp_err = globus_error_peek(result); tmp_errstr = globus_error_print_friendly(tmp_err); for(tmp_ptr = tmp_errstr; *tmp_ptr != '\0'; tmp_ptr++) @@ -5288,17 +5290,17 @@ globus_l_guc_expand_single_url( globus_free(tmp_errstr); } } - + files_matched = 0; base_url_len = strrchr(src_url, '/') - src_url + 1; - + while(!globus_fifo_empty(&transfer_info->matched_url_list)) { - matched_src_urlinfo = (globus_l_guc_url_info_t *) + matched_src_urlinfo = (globus_l_guc_url_info_t *) globus_fifo_dequeue(&transfer_info->matched_url_list); - + matched_file = matched_src_urlinfo->url + base_url_len; - + matched_is_dir = GLOBUS_FALSE; if(matched_src_urlinfo->url[strlen(matched_src_urlinfo->url) - 1] == '/') { @@ -5314,7 +5316,7 @@ globus_l_guc_expand_single_url( goto error_too_many_matches; } } - + if(dst_is_file && ++files_matched > 1) { globus_l_guc_url_info_free(matched_src_urlinfo); @@ -5325,11 +5327,11 @@ globus_l_guc_expand_single_url( { matched_dest_url = globus_libc_strdup(dst_url); } - else - { + else + { matched_dest_url = (char *) globus_malloc( (url_len + strlen(matched_file) + 1) * sizeof(char)); - + sprintf(matched_dest_url, "%s%s", dst_url, matched_file); } if(guc_info->sync) @@ -5341,34 +5343,34 @@ globus_l_guc_expand_single_url( goto error_expand; } } - + if(do_transfer) { /* * See if a post transfer checksum comparison has been requested - */ + */ - if(guc_info->comp_checksum) + if(guc_info->comp_checksum) { if(matched_src_urlinfo->checksum == GLOBUS_NULL) { /* * If a checksum hasn't been taken on the source yet, take it now. */ - + globus_l_guc_cksm_info_t src_cksm_info; globus_l_guc_monitor_t cksm_monitor; - + globus_mutex_init(&cksm_monitor.mutex, NULL); globus_cond_init(&cksm_monitor.cond, NULL); - + matched_src_urlinfo->checksum = malloc(CKSM_SIZE); src_cksm_info.urlinfo = matched_src_urlinfo; src_cksm_info.done = GLOBUS_FALSE; src_cksm_info.monitor = &cksm_monitor; src_cksm_info.error = NULL; - + result = globus_gass_copy_cksm_async( &handle->gass_copy_handle, matched_src_urlinfo->url, @@ -5392,7 +5394,7 @@ globus_l_guc_expand_single_url( &cksm_monitor.cond, &cksm_monitor.mutex); } globus_mutex_unlock(&cksm_monitor.mutex); - + if(src_cksm_info.error) { result = globus_error_put(src_cksm_info.error); @@ -5400,7 +5402,7 @@ globus_l_guc_expand_single_url( } } } - + if(guc_info->create_dest && !guc_info->dump_only_file) { result = globus_l_guc_create_dir( @@ -5410,7 +5412,7 @@ globus_l_guc_expand_single_url( goto error_mkdir; } } - + if(guc_info->dump_only_fp) { globus_l_guc_print_url_line( @@ -5422,7 +5424,7 @@ globus_l_guc_expand_single_url( matched_src_urlinfo, matched_is_dir ? "#" : NULL); } - + expanded_url_pair = (globus_l_guc_src_dst_pair_t *) globus_malloc(sizeof(globus_l_guc_src_dst_pair_t)); @@ -5431,13 +5433,13 @@ globus_l_guc_expand_single_url( expanded_url_pair->offset = transfer_info->urls->offset; expanded_url_pair->length = transfer_info->urls->length; expanded_url_pair->src_info = matched_src_urlinfo; - + matched_src_urlinfo->url = NULL; - + if(!guc_info->dump_only_fp || matched_is_dir) { globus_l_guc_enqueue_pair( - &guc_info->expanded_url_list, + &guc_info->expanded_url_list, expanded_url_pair); } else @@ -5451,9 +5453,9 @@ globus_l_guc_expand_single_url( globus_free(matched_dest_url); } } - + return GLOBUS_SUCCESS; - + error_too_many_matches: result = globus_error_put( globus_error_construct_string( @@ -5461,15 +5463,15 @@ globus_l_guc_expand_single_url( GLOBUS_NULL, _GASCSL("Multiple source urls must be transferred to a directory " "destination url:\n%s\n"), - dst_url)); + dst_url)); error_mkdir: error_expand: error_checksum: - return result; + return result; } static -void +void globus_l_guc_pipeline( globus_ftp_client_handle_t * ftp_handle, char ** source_url, @@ -5480,47 +5482,47 @@ globus_l_guc_pipeline( globus_l_guc_info_t * guc_info; globus_l_guc_src_dst_pair_t * pair; globus_bool_t none = GLOBUS_FALSE; - + handle = (globus_l_guc_handle_t *) user_arg; guc_info = handle->guc_info; - + *source_url = NULL; *dest_url = NULL; - + globus_mutex_lock(&g_monitor.mutex); - globus_l_guc_url_pair_free(handle->pipeline_free_pair); + globus_l_guc_url_pair_free(handle->pipeline_free_pair); handle->pipeline_free_pair = NULL; - + if(!g_monitor.done && !globus_fifo_empty(&guc_info->expanded_url_list)) { pair = (globus_l_guc_src_dst_pair_t *) globus_fifo_peek(&guc_info->expanded_url_list); - + if(pair->dst_url[strlen(pair->dst_url) - 1] == '/') { none = GLOBUS_TRUE; } - - if(strncmp(pair->src_url, "file:/", 5) == 0 || + + if(strncmp(pair->src_url, "file:/", 5) == 0 || strncmp(pair->src_url, "http", 4) == 0 || - strncmp(pair->dst_url, "file:/", 5) == 0 || - strncmp(pair->dst_url, "http", 4) == 0) + strncmp(pair->dst_url, "file:/", 5) == 0 || + strncmp(pair->dst_url, "http", 4) == 0) { none = GLOBUS_TRUE; } - + if(!none) { char idstr[16]; - + sprintf(idstr, "%u", handle->pipeline_id++); *source_url = pair->src_url; *dest_url = pair->dst_url; - + handle->pipeline_free_pair = globus_fifo_dequeue( &guc_info->expanded_url_list); - + if(!g_quiet_flag) { globus_libc_fprintf(stdout, @@ -5531,7 +5533,7 @@ globus_l_guc_pipeline( globus_mutex_unlock(&g_monitor.mutex); - + } @@ -5574,7 +5576,7 @@ globus_l_guc_init_gass_copy_handle( return -1; } - + ver_str = globus_common_create_string( "%d.%d (%s, %d-%d) [%s]", local_version.major, @@ -5611,7 +5613,7 @@ globus_l_guc_init_gass_copy_handle( { fprintf(stderr, "Failed to load extension %s\n", plugin_name); } - + func_name = globus_common_create_string("%s_funcs", plugin_name); funcs = (globus_guc_client_plugin_funcs_t *) globus_extension_lookup( @@ -5673,13 +5675,13 @@ globus_l_guc_init_gass_copy_handle( if(g_use_restart) { GlobusTimeReltimeSet(interval, guc_info->restart_interval, 0); - + if(guc_info->restart_timeout) { GlobusTimeAbstimeSet(timeout, guc_info->restart_timeout, 0); timeout_p = &timeout; } - + result = globus_ftp_client_restart_plugin_init( &restart_plugin, guc_info->restart_retries, /* retry times 0=forever */ @@ -5692,7 +5694,7 @@ globus_l_guc_init_gass_copy_handle( return -1; } - + if(guc_info->stall_timeout) { result = globus_ftp_client_restart_plugin_set_stall_timeout( @@ -5701,7 +5703,7 @@ globus_l_guc_init_gass_copy_handle( { fprintf(stderr, _GASCSL("Error: Unable to init debug plugin %s\n"), globus_error_print_friendly(globus_error_peek(result))); - + return -1; } } @@ -5718,12 +5720,12 @@ globus_l_guc_init_gass_copy_handle( } } else if(guc_info->stall_timeout) - { + { GlobusTimeAbstimeSet(timeout, 0, 1); timeout_p = &timeout; result = globus_ftp_client_restart_plugin_init( - &restart_plugin, 0, NULL, timeout_p); + &restart_plugin, 0, NULL, timeout_p); if(result != GLOBUS_SUCCESS) { fprintf(stderr, _GASCSL("Error: Unable to init debug plugin %s\n"), @@ -5731,7 +5733,7 @@ globus_l_guc_init_gass_copy_handle( return -1; } - + result = globus_ftp_client_restart_plugin_set_stall_timeout( &restart_plugin, guc_info->stall_timeout); if(result != GLOBUS_SUCCESS) @@ -5752,7 +5754,7 @@ globus_l_guc_init_gass_copy_handle( return -1; } - } + } if(guc_info->rfc1738) { @@ -5765,7 +5767,7 @@ globus_l_guc_init_gass_copy_handle( return -1; } - } + } result = globus_ftp_client_handleattr_set_gridftp2( &ftp_handleattr, guc_info->gridftp2); @@ -5790,15 +5792,15 @@ globus_l_guc_init_gass_copy_handle( return -1; } - } - + } + globus_gass_copy_handleattr_set_ftp_attr( &gass_copy_handleattr, &ftp_handleattr); globus_gass_copy_handle_init(gass_copy_handle, &gass_copy_handleattr); if(guc_info->block_size > 0) { - globus_gass_copy_set_buffer_length(gass_copy_handle, + globus_gass_copy_set_buffer_length(gass_copy_handle, guc_info->block_size); } @@ -5807,17 +5809,17 @@ globus_l_guc_init_gass_copy_handle( globus_gass_copy_set_no_third_party_transfers(gass_copy_handle, GLOBUS_TRUE); } - + if(!guc_info->pipeline) { globus_gass_copy_set_allocate(gass_copy_handle, guc_info->allo); } - + if(guc_info->sync) { globus_gass_copy_set_stat_on_expand(gass_copy_handle, GLOBUS_TRUE); } - + if(g_verbose_flag) { result = globus_gass_copy_register_performance_cb( @@ -5827,7 +5829,7 @@ globus_l_guc_init_gass_copy_handle( if(result != GLOBUS_SUCCESS) { - fprintf(stderr, + fprintf(stderr, _GASCSL("Error: Unable to register performance handler %s\n"), globus_error_print_friendly(globus_error_peek(result))); @@ -5893,14 +5895,14 @@ globus_l_guc_gass_attr_init( char * dcau_subj = NULL; if(src) - { + { subject = guc_info->source_subject; module_name = guc_info->src_module_name; module_args = guc_info->src_module_args; authz_assert = guc_info->src_authz_assert, cache_authz_assert = guc_info->cache_src_authz_assert; cred = guc_info->src_cred; - if(guc_info->src_cred_subj && guc_info->dst_cred_subj && + if(guc_info->src_cred_subj && guc_info->dst_cred_subj && strcmp(guc_info->src_cred_subj, guc_info->dst_cred_subj)) { dcau_subj = guc_info->dst_cred_subj; @@ -5914,20 +5916,20 @@ globus_l_guc_gass_attr_init( authz_assert = guc_info->dst_authz_assert, cache_authz_assert = guc_info->cache_dst_authz_assert; cred = guc_info->dst_cred; - if(guc_info->src_cred_subj && guc_info->dst_cred_subj && + if(guc_info->src_cred_subj && guc_info->dst_cred_subj && strcmp(guc_info->src_cred_subj, guc_info->dst_cred_subj)) { dcau_subj = guc_info->src_cred_subj; } } - + globus_url_parse(url, &url_info); globus_gass_copy_get_url_mode(url, &url_mode); /* * setup the ftp attr */ if(url_mode == GLOBUS_GASS_COPY_URL_MODE_FTP) - { + { globus_ftp_client_operationattr_init(ftp_attr); if(guc_info->tcp_buffer_size > 0) @@ -5949,49 +5951,49 @@ globus_l_guc_gass_attr_init( parallelism.fixed.size = guc_info->num_streams; globus_ftp_client_operationattr_set_parallelism( ftp_attr, - ¶llelism); - + ¶llelism); + globus_ftp_client_operationattr_set_list_uses_data_mode( ftp_attr, guc_info->list_uses_data_mode); - } + } - if(guc_info->striped) - { - memset(&layout, '\0', sizeof(globus_ftp_control_layout_t)); + if(guc_info->striped) + { + memset(&layout, '\0', sizeof(globus_ftp_control_layout_t)); switch(guc_info->stripe_bs) { case -1: - layout.mode = + layout.mode = GLOBUS_FTP_CONTROL_STRIPING_NONE; break; case 0: - layout.mode = + layout.mode = GLOBUS_FTP_CONTROL_STRIPING_PARTITIONED; break; default: - layout.mode = + layout.mode = GLOBUS_FTP_CONTROL_STRIPING_BLOCKED_ROUND_ROBIN; layout.round_robin.block_size = guc_info->stripe_bs; } globus_ftp_client_operationattr_set_mode( ftp_attr, GLOBUS_FTP_CONTROL_MODE_EXTENDED_BLOCK); - globus_ftp_client_operationattr_set_striped(ftp_attr, GLOBUS_TRUE); + globus_ftp_client_operationattr_set_striped(ftp_attr, GLOBUS_TRUE); globus_ftp_client_operationattr_set_layout(ftp_attr, &layout); - } + } - if(guc_info->delayed_pasv) - { + if(guc_info->delayed_pasv) + { globus_ftp_client_operationattr_set_delayed_pasv( - ftp_attr, GLOBUS_TRUE); - } + ftp_attr, GLOBUS_TRUE); + } - if(guc_info->ipv6) - { + if(guc_info->ipv6) + { globus_ftp_client_operationattr_set_allow_ipv6( - ftp_attr, GLOBUS_TRUE); - } + ftp_attr, GLOBUS_TRUE); + } if(module_name != NULL) { @@ -6039,15 +6041,15 @@ globus_l_guc_gass_attr_init( else if(auto_data.length > 0) { globus_ftp_client_operationattr_set_data_security( - ftp_attr, 'p', &auto_data); + ftp_attr, 'p', &auto_data); } - else if(url_info.scheme_type == GLOBUS_URL_SCHEME_SSHFTP && + else if(url_info.scheme_type == GLOBUS_URL_SCHEME_SSHFTP && (guc_info->data_private || guc_info->data_safe)) { fprintf(stderr, "\nERROR: Data protection with sshftp requires a credential. Try '-data-cred auto'.\n\n"); exit(EXIT_FAILURE); } - + if(guc_info->no_dcau) { dcau.mode = GLOBUS_FTP_CONTROL_DCAU_NONE; @@ -6065,13 +6067,13 @@ globus_l_guc_gass_attr_init( ftp_attr, &dcau); } - + if(url_info.scheme_type == GLOBUS_URL_SCHEME_GSIFTP) { gsi_driver_str = "gsi"; } } - + if(guc_info->data_private) { globus_ftp_client_operationattr_set_data_protection( @@ -6084,7 +6086,7 @@ globus_l_guc_gass_attr_init( ftp_attr, GLOBUS_FTP_CONTROL_PROTECTION_SAFE); } - + if(src) { tmp_net_str = guc_info->src_net_stack_str; @@ -6165,7 +6167,7 @@ globus_l_guc_gass_attr_init( } globus_gass_copy_attr_set_ftp(gass_copy_attr, ftp_attr); - + } /* * setup the gass copy attr @@ -6198,8 +6200,8 @@ globus_l_guc_gass_attr_init( globus_gass_copy_attr_set_gass(gass_copy_attr, gass_t_attr); } - globus_url_destroy(&url_info); - + globus_url_destroy(&url_info); + return 0; } @@ -6220,7 +6222,7 @@ globus_l_guc_get_io_handle( { return NULL; } - + io_handle =(globus_io_handle_t *) globus_libc_malloc(sizeof(globus_io_handle_t)); @@ -6249,7 +6251,7 @@ globus_l_guc_url_pair_free( globus_l_guc_url_info_free(url_pair->src_info); globus_free(url_pair); } -} +} static void @@ -6263,38 +6265,38 @@ globus_l_guc_destroy_url_list( url_pair = (globus_l_guc_src_dst_pair_t *) globus_fifo_dequeue(url_list); globus_l_guc_url_pair_free(url_pair); - } + } globus_fifo_destroy(url_list); -} +} -static +static void globus_l_guc_hashtable_element_free( void * datum) { char * string; - + string = (char *) datum; if(string != GLOBUS_NULL) - { + { globus_free(string); } - + return; } -static +static void globus_l_guc_url_info_free( void * datum) { globus_l_guc_url_info_t * info; - + info = (globus_l_guc_url_info_t *) datum; if(info != NULL) - { + { if(info->url) { globus_free(info->url); @@ -6305,6 +6307,6 @@ globus_l_guc_url_info_free( } globus_free(info); } - + return; } diff --git a/gass/transfer/source/configure.ac b/gass/transfer/source/configure.ac index 840358b801..71fcbaf6ba 100644 --- a/gass/transfer/source/configure.ac +++ b/gass/transfer/source/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ([2.60]) -AC_INIT([globus_gass_transfer],[9.5],[https://github.com/gridcf/gct/issues]) +AC_INIT([globus_gass_transfer],[9.6],[https://github.com/gridcf/gct/issues]) AC_CONFIG_MACRO_DIR([m4]) AC_SUBST([MAJOR_VERSION], [${PACKAGE_VERSION%%.*}]) AC_SUBST([MINOR_VERSION], [${PACKAGE_VERSION##*.}]) diff --git a/gass/transfer/source/library/globus_gass_transfer.c b/gass/transfer/source/library/globus_gass_transfer.c index 122e12187e..92809209e5 100644 --- a/gass/transfer/source/library/globus_gass_transfer.c +++ b/gass/transfer/source/library/globus_gass_transfer.c @@ -57,8 +57,8 @@ globus_module_descriptor_t globus_i_gass_transfer_module = static void globus_l_gass_transfer_listener_close_callback( - void * user_arg, - globus_gass_transfer_listener_t request); + void * user_arg, + globus_gass_transfer_listener_t request); static int @@ -67,9 +67,9 @@ globus_l_gass_transfer_activate(void) globus_module_activate(GLOBUS_COMMON_MODULE); globus_hashtable_init(&globus_i_gass_transfer_protocols, - 16, - globus_hashtable_string_hash, - globus_hashtable_string_keyeq); + 16, + globus_hashtable_string_hash, + globus_hashtable_string_keyeq); globus_handle_table_init( &globus_i_gass_transfer_request_handles, @@ -85,25 +85,25 @@ globus_l_gass_transfer_activate(void) */ globus_module_activate(GLOBUS_I_GASS_TRANSFER_FTP_MODULE); #endif - + globus_gass_transfer_proto_register_protocol( - &globus_i_gass_transfer_http_descriptor); + &globus_i_gass_transfer_http_descriptor); globus_gass_transfer_proto_register_protocol( - &globus_i_gass_transfer_https_descriptor); + &globus_i_gass_transfer_https_descriptor); #if 0 /* we don't want to build this in */ globus_gass_transfer_proto_register_protocol( - &globus_i_gass_transfer_ftp_descriptor); + &globus_i_gass_transfer_ftp_descriptor); globus_gass_transfer_proto_register_protocol( - &globus_i_gass_transfer_gsiftp_descriptor); + &globus_i_gass_transfer_gsiftp_descriptor); #endif - + globus_mutex_init(&globus_i_gass_transfer_mutex, GLOBUS_NULL); globus_cond_init(&globus_i_gass_transfer_shutdown_cond, - GLOBUS_NULL); + GLOBUS_NULL); return GLOBUS_SUCCESS; } @@ -113,40 +113,40 @@ static int globus_l_gass_transfer_deactivate(void) { - globus_list_t * rest; + globus_list_t * rest; globus_i_gass_transfer_lock(); globus_i_gass_transfer_deactivating = GLOBUS_TRUE; - + #if DEBUG_GASS_TRANSFER printf(_GTSL("Entering globus_l_gass_transfer_deactivate()\n")); #endif - + rest = globus_i_gass_transfer_requests; - + while(!globus_list_empty(rest)) { - globus_gass_transfer_request_t tmp; - globus_gass_transfer_request_struct_t * req; - int rc; + globus_gass_transfer_request_t tmp; + globus_gass_transfer_request_struct_t * req; + int rc; + + tmp = (globus_gass_transfer_request_t) (intptr_t) + globus_list_first(rest); - tmp = (globus_gass_transfer_request_t) (intptr_t) - globus_list_first(rest); + rest = globus_list_rest(rest); - rest = globus_list_rest(rest); + req = globus_handle_table_lookup( + &globus_i_gass_transfer_request_handles, + tmp); - req = globus_handle_table_lookup( - &globus_i_gass_transfer_request_handles, - tmp); - #if DEBUG_GASS_TRANSFER - printf(_GTSL("failing: %s\n"), req->url); + printf(_GTSL("failing: %s\n"), req->url); #endif - rc = globus_i_gass_transfer_fail( - tmp, - req, - globus_i_gass_transfer_deactivate_callback, - GLOBUS_NULL); + rc = globus_i_gass_transfer_fail( + tmp, + req, + globus_i_gass_transfer_deactivate_callback, + GLOBUS_NULL); if (rc == GLOBUS_GASS_TRANSFER_ERROR_DONE) { @@ -159,51 +159,50 @@ globus_l_gass_transfer_deactivate(void) while(!globus_list_empty(rest)) { - globus_gass_transfer_listener_t tmp; - globus_gass_transfer_listener_struct_t *l; - int rc; - - tmp = (globus_gass_transfer_listener_t) (intptr_t) - globus_list_first(rest); - - rest = globus_list_rest(rest); - - l = globus_handle_table_lookup( - &globus_i_gass_transfer_listener_handles, - tmp); - - rc = globus_i_gass_transfer_close_listener( - tmp, - l, - globus_l_gass_transfer_listener_close_callback, - GLOBUS_NULL); + globus_gass_transfer_listener_t tmp; + globus_gass_transfer_listener_struct_t *l; + + tmp = (globus_gass_transfer_listener_t) (intptr_t) + globus_list_first(rest); + + rest = globus_list_rest(rest); + + l = globus_handle_table_lookup( + &globus_i_gass_transfer_listener_handles, + tmp); + + globus_i_gass_transfer_close_listener( + tmp, + l, + globus_l_gass_transfer_listener_close_callback, + GLOBUS_NULL); } - + while((!globus_list_empty(globus_i_gass_transfer_requests)) || - (!globus_list_empty(globus_i_gass_transfer_listeners))) + (!globus_list_empty(globus_i_gass_transfer_listeners))) { #if DEBUG_GASS_TRANSFER - printf(_GTSL("waiting for requests\n")); + printf(_GTSL("waiting for requests\n")); #endif - globus_cond_wait(&globus_i_gass_transfer_shutdown_cond, - &globus_i_gass_transfer_mutex); + globus_cond_wait(&globus_i_gass_transfer_shutdown_cond, + &globus_i_gass_transfer_mutex); } #if 0 /* we don't want to build this in */ globus_gass_transfer_proto_unregister_protocol( - &globus_i_gass_transfer_ftp_descriptor); + &globus_i_gass_transfer_ftp_descriptor); globus_gass_transfer_proto_unregister_protocol( - &globus_i_gass_transfer_gsiftp_descriptor); + &globus_i_gass_transfer_gsiftp_descriptor); #endif - + globus_gass_transfer_proto_unregister_protocol( - &globus_i_gass_transfer_http_descriptor); + &globus_i_gass_transfer_http_descriptor); globus_gass_transfer_proto_unregister_protocol( - &globus_i_gass_transfer_https_descriptor); + &globus_i_gass_transfer_https_descriptor); + - #if 0 /* we don't want to build this in */ @@ -211,13 +210,13 @@ globus_l_gass_transfer_deactivate(void) #endif globus_i_gass_transfer_unlock(); - + globus_module_deactivate(GLOBUS_I_GASS_TRANSFER_HTTP_MODULE); - + globus_handle_table_destroy(&globus_i_gass_transfer_listener_handles); globus_handle_table_destroy(&globus_i_gass_transfer_request_handles); - + globus_hashtable_destroy(&globus_i_gass_transfer_protocols); #if !defined(BUILD_LITE) @@ -236,8 +235,8 @@ globus_l_gass_transfer_deactivate(void) void globus_i_gass_transfer_deactivate_callback( - void * user_arg, - globus_gass_transfer_request_t request) + void * user_arg, + globus_gass_transfer_request_t request) { globus_i_gass_transfer_request_destroy(request); } @@ -245,8 +244,8 @@ globus_i_gass_transfer_deactivate_callback( static void globus_l_gass_transfer_listener_close_callback( - void * user_arg, - globus_gass_transfer_listener_t request) + void * user_arg, + globus_gass_transfer_listener_t request) { return; } diff --git a/gass/transfer/source/library/globus_gass_transfer.h b/gass/transfer/source/library/globus_gass_transfer.h index e0fb783f7e..617df87e27 100644 --- a/gass/transfer/source/library/globus_gass_transfer.h +++ b/gass/transfer/source/library/globus_gass_transfer.h @@ -58,7 +58,7 @@ extern "C" { * The GASS Transfer API is easily extensible to support different remote * data access protocols. The standard Globus distribution includes client-side * support for the http, and https protocols, as well as - * server-side support for the http and https protocols. + * server-side support for the http and https protocols. * An application which requires additional * protocol support may add this through the @link * globus_gass_transfer_protocol protocol module interface@endlink. @@ -92,17 +92,17 @@ extern "C" { * globus_module_deactivate(GLOBUS_GASS_TRANSFER_MODULE); * @endcode */ -extern globus_module_descriptor_t globus_i_gass_transfer_module; +extern globus_module_descriptor_t globus_i_gass_transfer_module; /** Module descriptor * @ingroup globus_gass_transfer_activation * @hideinitializer */ -#define GLOBUS_GASS_TRANSFER_MODULE (&globus_i_gass_transfer_module) +#define GLOBUS_GASS_TRANSFER_MODULE (&globus_i_gass_transfer_module) #define _GTSL(s) globus_common_i18n_get_string( \ - GLOBUS_GASS_TRANSFER_MODULE, \ - s) + GLOBUS_GASS_TRANSFER_MODULE, \ + s) /** * @struct globus_gass_transfer_request_t * @ingroup globus_gass_transfer_request @@ -175,10 +175,10 @@ typedef enum * GLOBUS_GASS_TRANSFER_REQUEST_INVALID * GLOBUS_GASS_TRANSFER_REQUEST_STARTING * GLOBUS_GASS_TRANSFER_REQUEST_PENDING (PENDING, ACTING, - * ACTING_TO_PENDING) + * ACTING_TO_PENDING) * GLOBUS_GASS_TRANSFER_REQUEST_FAILED (FAILED, USER_FAIL, ACTING_TO_FAIL) * GLOBUS_GASS_TRANSFER_REQUEST_REFERRED (REFERRING, ACTING_TO_REFERRING, - * ACTING_TO_REFERRING2) + * ACTING_TO_REFERRING2) * GLOBUS_GASS_TRANSFER_REQUEST_DENIED * GLOBUS_GASS_TRANSFER_REQUEST_DONE */ @@ -191,45 +191,45 @@ typedef enum GLOBUS_GASS_TRANSFER_REQUEST_INVALID, /**< Handle is no longer valid */ GLOBUS_GASS_TRANSFER_REQUEST_STARTING, /**< Initial connection and authorization is not yet - completed */ + completed */ GLOBUS_GASS_TRANSFER_REQUEST_PENDING, /**< Request is authorized. */ GLOBUS_GASS_TRANSFER_REQUEST_FAILED, /**< Request failed due to protocol error or client or server - aborting the request */ + aborting the request */ GLOBUS_GASS_TRANSFER_REQUEST_REFERRED, /**< Request can not be processed by this server, referred to - another URL or URLs */ + another URL or URLs */ GLOBUS_GASS_TRANSFER_REQUEST_DENIED, /**< The server denied this request */ GLOBUS_GASS_TRANSFER_REQUEST_DONE, /**< All callbacks have completed */ #ifndef GLOBUS_DONT_DOCUMENT_INTERNAL GLOBUS_GASS_TRANSFER_REQUEST_ACCEPTING,/**< for listener-created requests, - the state before starting, - after the user has called - register_accept, but before the - callback is done */ + the state before starting, + after the user has called + register_accept, but before the + callback is done */ GLOBUS_GASS_TRANSFER_REQUEST_ACTING, /* op passed to request */ GLOBUS_GASS_TRANSFER_REQUEST_ACTING_TO_PENDING, /* calling back to user */ GLOBUS_GASS_TRANSFER_REQUEST_ACTING_TO_FAILING, /* op passed to request, and - user called fail */ + user called fail */ GLOBUS_GASS_TRANSFER_REQUEST_FAILING, /* user called fail, or op - completed, user callback - started */ + completed, user callback + started */ GLOBUS_GASS_TRANSFER_REQUEST_USER_FAIL, /* user called fail before - ready/referred/denied */ - GLOBUS_GASS_TRANSFER_REQUEST_REFERRING, /* proto called referred, - callback pending */ + ready/referred/denied */ + GLOBUS_GASS_TRANSFER_REQUEST_REFERRING, /* proto called referred, + callback pending */ GLOBUS_GASS_TRANSFER_REQUEST_ACTING_TO_REFERRING, /* proto called referred, - op in progress */ + op in progress */ GLOBUS_GASS_TRANSFER_REQUEST_FINISHING, /* op completed successfully, - with last data, user callback - started*/ + with last data, user callback + started*/ GLOBUS_GASS_TRANSFER_REQUEST_SERVER_FAIL1, /* user called fail before - new_listener_request */ + new_listener_request */ GLOBUS_GASS_TRANSFER_REQUEST_SERVER_FAIL2, /* user called fail before - authorize/refer/deny */ + authorize/refer/deny */ GLOBUS_GASS_TRANSFER_REQUEST_SERVER_FAIL3, /* user called fail before - request_ready */ + request_ready */ GLOBUS_GASS_TRANSFER_REQUEST_STARTING2, /* server not authorized/denied/failed */ GLOBUS_GASS_TRANSFER_REQUEST_STARTING3 /* server not authorized/denied/failed */ #endif @@ -240,19 +240,19 @@ typedef enum GLOBUS_GASS_TRANSFER_LISTENER_INVALID, /* handle no longer valid */ GLOBUS_GASS_TRANSFER_LISTENER_STARTING, /* new listener called */ GLOBUS_GASS_TRANSFER_LISTENER_LISTENING, /* register listen/ - proto->register listen */ + proto->register listen */ GLOBUS_GASS_TRANSFER_LISTENER_READY, /* proto calls listener_ready */ GLOBUS_GASS_TRANSFER_LISTENER_ACCEPTING, /* register_accept() */ GLOBUS_GASS_TRANSFER_LISTENER_CLOSING1, /* close_listener before - listener_ready called */ + listener_ready called */ GLOBUS_GASS_TRANSFER_LISTENER_CLOSING2, /* close listener before - new_request */ + new_request */ GLOBUS_GASS_TRANSFER_LISTENER_CLOSED /* listener is closed */ } globus_gass_transfer_listener_status_t; /** * GASS error codes - * @ingroup globus_gass_constants + * @ingroup globus_gass_transfer */ enum { @@ -293,7 +293,7 @@ enum }; /** - * @ingroup globus_gass_constants + * @ingroup globus_gass_transfer * * Default buffer length for the globus_gass_transfer_assist library. * @@ -305,7 +305,7 @@ enum }; /** - * @ingroup globus_gass_constants + * @ingroup globus_gass_transfer * * Value for files we don't know the length of. * @@ -314,7 +314,7 @@ enum #define GLOBUS_GASS_TRANSFER_LENGTH_UNKNOWN 0UL /** - * @ingroup globus_gass_constants + * @ingroup globus_gass_transfer * * Value for timestamps we don't know the value of. * @@ -324,8 +324,8 @@ enum typedef void (* globus_gass_transfer_callback_t)( - void * arg, - globus_gass_transfer_request_t request); + void * arg, + globus_gass_transfer_request_t request); /* Client Interface */ /** * @brief GASS Transfer Client Operations @@ -350,49 +350,49 @@ typedef void */ int globus_gass_transfer_register_get( - globus_gass_transfer_request_t * request, - globus_gass_transfer_requestattr_t * attr, - char * url, - globus_gass_transfer_callback_t callback, - void * user_arg); + globus_gass_transfer_request_t * request, + globus_gass_transfer_requestattr_t * attr, + char * url, + globus_gass_transfer_callback_t callback, + void * user_arg); int globus_gass_transfer_get( - globus_gass_transfer_request_t * request, - globus_gass_transfer_requestattr_t * attr, - char * url); + globus_gass_transfer_request_t * request, + globus_gass_transfer_requestattr_t * attr, + char * url); int globus_gass_transfer_register_put( - globus_gass_transfer_request_t * request, - globus_gass_transfer_requestattr_t * attr, - char * url, - globus_size_t length, - globus_gass_transfer_callback_t callback, - void * user_arg); + globus_gass_transfer_request_t * request, + globus_gass_transfer_requestattr_t * attr, + char * url, + globus_size_t length, + globus_gass_transfer_callback_t callback, + void * user_arg); int globus_gass_transfer_put( - globus_gass_transfer_request_t * request, - globus_gass_transfer_requestattr_t * attr, - char * url, - globus_size_t length); + globus_gass_transfer_request_t * request, + globus_gass_transfer_requestattr_t * attr, + char * url, + globus_size_t length); int globus_gass_transfer_register_append( - globus_gass_transfer_request_t * request, - globus_gass_transfer_requestattr_t * attr, - char * url, - globus_size_t length, - globus_gass_transfer_callback_t callback, - void * user_arg); + globus_gass_transfer_request_t * request, + globus_gass_transfer_requestattr_t * attr, + char * url, + globus_size_t length, + globus_gass_transfer_callback_t callback, + void * user_arg); int globus_gass_transfer_append( - globus_gass_transfer_request_t * request, - globus_gass_transfer_requestattr_t * attr, - char * url, - globus_size_t length); + globus_gass_transfer_request_t * request, + globus_gass_transfer_requestattr_t * attr, + char * url, + globus_size_t length); /** * @brief GASS Server Implementation @@ -404,7 +404,7 @@ globus_gass_transfer_append( * Another mode of using the GASS Transfer API is to implement * data servers. The primary difference between the client and * server parts of the GASS Transfer API are how requests are generated. - * + * * To implement a server, the user would call * globus_gass_transfer_create_listener() to create a new server port on * which a specific protocol will be used to request file transfer operations. @@ -432,8 +432,8 @@ globus_gass_transfer_append( */ typedef void (* globus_gass_transfer_close_callback_t)( - void * callback_arg, - globus_gass_transfer_listener_t listener); + void * callback_arg, + globus_gass_transfer_listener_t listener); /** * Listen callback. @@ -443,68 +443,68 @@ typedef void */ typedef void (* globus_gass_transfer_listen_callback_t)( - void * callback_arg, - globus_gass_transfer_listener_t listener); + void * callback_arg, + globus_gass_transfer_listener_t listener); int globus_gass_transfer_create_listener( - globus_gass_transfer_listener_t * listener, - globus_gass_transfer_listenerattr_t * attr, - char * scheme); + globus_gass_transfer_listener_t * listener, + globus_gass_transfer_listenerattr_t * attr, + char * scheme); int globus_gass_transfer_close_listener( - globus_gass_transfer_listener_t listener, - globus_gass_transfer_close_callback_t callback, - void * user_arg); + globus_gass_transfer_listener_t listener, + globus_gass_transfer_close_callback_t callback, + void * user_arg); int globus_gass_transfer_register_listen( - globus_gass_transfer_listener_t listener, - globus_gass_transfer_listen_callback_t callback, - void * user_arg); + globus_gass_transfer_listener_t listener, + globus_gass_transfer_listen_callback_t callback, + void * user_arg); int globus_gass_transfer_register_accept( - globus_gass_transfer_request_t * request, - globus_gass_transfer_requestattr_t * attr, - globus_gass_transfer_listener_t listener, - globus_gass_transfer_callback_t callback, - void * user_arg); + globus_gass_transfer_request_t * request, + globus_gass_transfer_requestattr_t * attr, + globus_gass_transfer_listener_t listener, + globus_gass_transfer_callback_t callback, + void * user_arg); int globus_gass_transfer_refer( - globus_gass_transfer_request_t request, - char ** urls, - globus_size_t num_urls); + globus_gass_transfer_request_t request, + char ** urls, + globus_size_t num_urls); int globus_gass_transfer_authorize( - globus_gass_transfer_request_t request, - globus_size_t total_length); + globus_gass_transfer_request_t request, + globus_size_t total_length); int globus_gass_transfer_deny( - globus_gass_transfer_request_t request, - int reason, - char * message); + globus_gass_transfer_request_t request, + int reason, + char * message); char * globus_gass_transfer_listener_get_base_url( - globus_gass_transfer_listener_t listener); + globus_gass_transfer_listener_t listener); void * globus_gass_transfer_listener_get_user_pointer( - globus_gass_transfer_listener_t listener); + globus_gass_transfer_listener_t listener); int globus_gass_transfer_listener_set_user_pointer( - globus_gass_transfer_listener_t listener, - void * user_pointer); + globus_gass_transfer_listener_t listener, + void * user_pointer); /** * @defgroup globus_gass_transfer_data Sending and Receiving Data - * @ingroup globus_gass_tansfer + * @ingroup globus_gass_transfer * @brief Sending and Receiving Data */ @@ -529,35 +529,35 @@ globus_gass_transfer_listener_set_user_pointer( */ typedef void (* globus_gass_transfer_bytes_callback_t)( - void * arg, - globus_gass_transfer_request_t request, - globus_byte_t * bytes, - globus_size_t length, - globus_bool_t last_data); + void * arg, + globus_gass_transfer_request_t request, + globus_byte_t * bytes, + globus_size_t length, + globus_bool_t last_data); int globus_gass_transfer_send_bytes( - globus_gass_transfer_request_t request, - globus_byte_t * bytes, - globus_size_t send_length, - globus_bool_t last_data, - globus_gass_transfer_bytes_callback_t callback, - void * user_arg); + globus_gass_transfer_request_t request, + globus_byte_t * bytes, + globus_size_t send_length, + globus_bool_t last_data, + globus_gass_transfer_bytes_callback_t callback, + void * user_arg); int globus_gass_transfer_receive_bytes( - globus_gass_transfer_request_t request, - globus_byte_t * bytes, - globus_size_t max_length, - globus_size_t wait_for_length, - globus_gass_transfer_bytes_callback_t callback, - void * user_arg); + globus_gass_transfer_request_t request, + globus_byte_t * bytes, + globus_size_t max_length, + globus_size_t wait_for_length, + globus_gass_transfer_bytes_callback_t callback, + void * user_arg); int globus_gass_transfer_fail( - globus_gass_transfer_request_t request, - globus_gass_transfer_callback_t callback, - void * user_arg); + globus_gass_transfer_request_t request, + globus_gass_transfer_callback_t callback, + void * user_arg); /** * @brief GASS Referrals * @@ -579,23 +579,23 @@ globus_gass_transfer_fail( #ifndef DOXYGEN typedef struct { - char ** url; - globus_size_t count; + char ** url; + globus_size_t count; } globus_gass_transfer_referral_t; globus_size_t globus_gass_transfer_referral_get_count( - globus_gass_transfer_referral_t * referral); + globus_gass_transfer_referral_t * referral); char * globus_gass_transfer_referral_get_url( - globus_gass_transfer_referral_t * referral, - globus_size_t index); + globus_gass_transfer_referral_t * referral, + globus_size_t index); int globus_gass_transfer_referral_destroy( - globus_gass_transfer_referral_t * referral); + globus_gass_transfer_referral_t * referral); #endif @@ -631,64 +631,64 @@ globus_gass_transfer_referral_destroy( #ifndef DOXYGEN globus_gass_transfer_request_type_t globus_gass_transfer_request_get_type( - globus_gass_transfer_request_t request); + globus_gass_transfer_request_t request); globus_gass_transfer_request_status_t globus_gass_transfer_request_get_status( - globus_gass_transfer_request_t request); + globus_gass_transfer_request_t request); char * globus_gass_transfer_request_get_subject( - globus_gass_transfer_request_t request); + globus_gass_transfer_request_t request); int globus_gass_transfer_request_set_subject( - globus_gass_transfer_request_t request, - char * subject); + globus_gass_transfer_request_t request, + char * subject); int globus_gass_transfer_request_get_referral( - globus_gass_transfer_request_t request, - globus_gass_transfer_referral_t * referral); + globus_gass_transfer_request_t request, + globus_gass_transfer_referral_t * referral); char * globus_gass_transfer_request_get_url( - globus_gass_transfer_request_t request); + globus_gass_transfer_request_t request); int globus_gass_transfer_request_set_url( - globus_gass_transfer_request_t request, - char * url); + globus_gass_transfer_request_t request, + char * url); globus_size_t globus_gass_transfer_request_get_length( - globus_gass_transfer_request_t request); + globus_gass_transfer_request_t request); int globus_gass_transfer_request_get_denial_reason( - globus_gass_transfer_request_t request); + globus_gass_transfer_request_t request); char * globus_gass_transfer_request_get_denial_message( - globus_gass_transfer_request_t request); + globus_gass_transfer_request_t request); void * globus_gass_transfer_request_get_user_pointer( - globus_gass_transfer_request_t request); + globus_gass_transfer_request_t request); int globus_gass_transfer_request_set_user_pointer( - globus_gass_transfer_request_t request, - void * user_pointer); + globus_gass_transfer_request_t request, + void * user_pointer); int globus_gass_transfer_request_destroy( - globus_gass_transfer_request_t request); + globus_gass_transfer_request_t request); int globus_gass_transfer_request_set_type( - globus_gass_transfer_request_t request, - globus_gass_transfer_request_type_t type); + globus_gass_transfer_request_t request, + globus_gass_transfer_request_type_t type); #endif @@ -703,106 +703,106 @@ globus_gass_transfer_request_set_type( #ifndef DOXYGEN int globus_gass_transfer_requestattr_init( - globus_gass_transfer_requestattr_t * attr, - char * url_scheme); + globus_gass_transfer_requestattr_t * attr, + char * url_scheme); int globus_gass_transfer_requestattr_destroy( - globus_gass_transfer_requestattr_t * attr); + globus_gass_transfer_requestattr_t * attr); int globus_gass_transfer_listenerattr_init( - globus_gass_transfer_listenerattr_t * attr, - char * url_scheme); + globus_gass_transfer_listenerattr_t * attr, + char * url_scheme); int globus_gass_transfer_listenerattr_destroy( - globus_gass_transfer_listenerattr_t * attr); + globus_gass_transfer_listenerattr_t * attr); /* Base Attribute Accessors */ int globus_gass_transfer_requestattr_set_proxy_url( - globus_gass_transfer_requestattr_t * attr, - char * proxy_url); + globus_gass_transfer_requestattr_t * attr, + char * proxy_url); int globus_gass_transfer_requestattr_get_proxy_url( - globus_gass_transfer_requestattr_t * attr, - char ** proxy_url); + globus_gass_transfer_requestattr_t * attr, + char ** proxy_url); int globus_gass_transfer_requestattr_set_block_size( - globus_gass_transfer_requestattr_t * attr, - globus_size_t block_size); + globus_gass_transfer_requestattr_t * attr, + globus_size_t block_size); int globus_gass_transfer_requestattr_get_block_size( - globus_gass_transfer_requestattr_t * attr, - globus_size_t * block_size); + globus_gass_transfer_requestattr_t * attr, + globus_size_t * block_size); int globus_gass_transfer_requestattr_set_file_mode( - globus_gass_transfer_requestattr_t * attr, - globus_gass_transfer_file_mode_t file_mode); + globus_gass_transfer_requestattr_t * attr, + globus_gass_transfer_file_mode_t file_mode); int globus_gass_transfer_requestattr_get_file_mode( - globus_gass_transfer_requestattr_t * attr, - globus_gass_transfer_file_mode_t * file_mode); + globus_gass_transfer_requestattr_t * attr, + globus_gass_transfer_file_mode_t * file_mode); int globus_gass_transfer_requestattr_set_connection_reuse( - globus_gass_transfer_requestattr_t * attr, - globus_bool_t connection_reuse); + globus_gass_transfer_requestattr_t * attr, + globus_bool_t connection_reuse); int globus_gass_transfer_requestattr_get_connection_reuse( - globus_gass_transfer_requestattr_t * attr, - globus_bool_t * connection_reuse); + globus_gass_transfer_requestattr_t * attr, + globus_bool_t * connection_reuse); /* Socket Attribute Accessors */ int globus_gass_transfer_requestattr_set_socket_sndbuf( - globus_gass_transfer_requestattr_t * attr, - int sndbuf); + globus_gass_transfer_requestattr_t * attr, + int sndbuf); int globus_gass_transfer_requestattr_get_socket_sndbuf( - globus_gass_transfer_requestattr_t * attr, - int * sndbuf); + globus_gass_transfer_requestattr_t * attr, + int * sndbuf); int globus_gass_transfer_requestattr_set_socket_rcvbuf( - globus_gass_transfer_requestattr_t * attr, - int rcvbuf); + globus_gass_transfer_requestattr_t * attr, + int rcvbuf); int globus_gass_transfer_requestattr_get_socket_rcvbuf( - globus_gass_transfer_requestattr_t * attr, - int * rcvbuf); + globus_gass_transfer_requestattr_t * attr, + int * rcvbuf); int globus_gass_transfer_requestattr_set_socket_nodelay( - globus_gass_transfer_requestattr_t * attr, - globus_bool_t nodelay); + globus_gass_transfer_requestattr_t * attr, + globus_bool_t nodelay); int globus_gass_transfer_requestattr_get_socket_nodelay( - globus_gass_transfer_requestattr_t * attr, - globus_bool_t * nodelay); + globus_gass_transfer_requestattr_t * attr, + globus_bool_t * nodelay); /* Security attribute accessors */ int globus_gass_transfer_secure_requestattr_set_authorization( - globus_gass_transfer_requestattr_t * attr, - globus_gass_transfer_authorization_t mode, - char * subject); + globus_gass_transfer_requestattr_t * attr, + globus_gass_transfer_authorization_t mode, + char * subject); int globus_gass_transfer_secure_requestattr_get_authorization( - globus_gass_transfer_requestattr_t * attr, - globus_gass_transfer_authorization_t * mode, - char ** subject); + globus_gass_transfer_requestattr_t * attr, + globus_gass_transfer_authorization_t * mode, + char ** subject); #endif /** @@ -813,23 +813,23 @@ globus_gass_transfer_secure_requestattr_get_authorization( #ifndef DOXYGEN int globus_gass_transfer_listenerattr_set_backlog( - globus_gass_transfer_listenerattr_t * attr, - int backlog); + globus_gass_transfer_listenerattr_t * attr, + int backlog); int globus_gass_transfer_listenerattr_get_backlog( - globus_gass_transfer_listenerattr_t * attr, - int * backlog); + globus_gass_transfer_listenerattr_t * attr, + int * backlog); int globus_gass_transfer_listenerattr_set_port( - globus_gass_transfer_listenerattr_t * attr, - unsigned short port); + globus_gass_transfer_listenerattr_t * attr, + unsigned short port); int globus_gass_transfer_listenerattr_get_port( - globus_gass_transfer_listenerattr_t * attr, - unsigned short * port); + globus_gass_transfer_listenerattr_t * attr, + unsigned short * port); #endif /** @@ -841,64 +841,64 @@ extern const globus_object_type_t GLOBUS_GASS_OBJECT_TYPE_REQUESTATTR_DEFINITION; #define GLOBUS_GASS_OBJECT_TYPE_REQUESTATTR \ - (&GLOBUS_GASS_OBJECT_TYPE_REQUESTATTR_DEFINITION) + (&GLOBUS_GASS_OBJECT_TYPE_REQUESTATTR_DEFINITION) globus_object_t * globus_gass_transfer_requestattr_initialize( - globus_object_t * obj, - char * proxy_url, - globus_size_t block_size, - globus_gass_transfer_file_mode_t file_mode, - globus_bool_t connection_reuse); + globus_object_t * obj, + char * proxy_url, + globus_size_t block_size, + globus_gass_transfer_file_mode_t file_mode, + globus_bool_t connection_reuse); extern const globus_object_type_t GLOBUS_GASS_OBJECT_TYPE_SOCKET_REQUESTATTR_DEFINITION; #define GLOBUS_GASS_OBJECT_TYPE_SOCKET_REQUESTATTR \ - (&GLOBUS_GASS_OBJECT_TYPE_SOCKET_REQUESTATTR_DEFINITION) + (&GLOBUS_GASS_OBJECT_TYPE_SOCKET_REQUESTATTR_DEFINITION) globus_object_t * globus_gass_transfer_socket_requestattr_initialize( - globus_object_t * obj, - char * proxy_url, - globus_size_t block_size, - globus_gass_transfer_file_mode_t file_mode, - globus_bool_t connection_reuse, - int sndbuf, - int rcvbuf, - globus_bool_t nodelay); + globus_object_t * obj, + char * proxy_url, + globus_size_t block_size, + globus_gass_transfer_file_mode_t file_mode, + globus_bool_t connection_reuse, + int sndbuf, + int rcvbuf, + globus_bool_t nodelay); extern const globus_object_type_t GLOBUS_GASS_OBJECT_TYPE_SECURE_REQUESTATTR_DEFINITION; #define GLOBUS_GASS_OBJECT_TYPE_SECURE_REQUESTATTR \ - (&GLOBUS_GASS_OBJECT_TYPE_SECURE_REQUESTATTR_DEFINITION) + (&GLOBUS_GASS_OBJECT_TYPE_SECURE_REQUESTATTR_DEFINITION) globus_object_t * globus_gass_transfer_secure_requestattr_initialize( - globus_object_t * obj, - char * proxy_url, - globus_size_t block_size, - globus_gass_transfer_file_mode_t file_mode, - globus_bool_t connection_reuse, - int sndbuf, - int rcvbuf, - globus_bool_t nodelay, - globus_gass_transfer_authorization_t authorization, - char * subject); + globus_object_t * obj, + char * proxy_url, + globus_size_t block_size, + globus_gass_transfer_file_mode_t file_mode, + globus_bool_t connection_reuse, + int sndbuf, + int rcvbuf, + globus_bool_t nodelay, + globus_gass_transfer_authorization_t authorization, + char * subject); /* Listener Attribute Object Types */ extern const globus_object_type_t GLOBUS_GASS_OBJECT_TYPE_LISTENERATTR_DEFINITION; #define GLOBUS_GASS_OBJECT_TYPE_LISTENERATTR \ - (&GLOBUS_GASS_OBJECT_TYPE_LISTENERATTR_DEFINITION) + (&GLOBUS_GASS_OBJECT_TYPE_LISTENERATTR_DEFINITION) globus_object_t * globus_gass_transfer_listenerattr_initialize( - globus_object_t * obj, - int backlog, - unsigned short port); + globus_object_t * obj, + int backlog, + unsigned short port); #ifdef __cplusplus } diff --git a/gass/transfer/source/library/globus_gass_transfer_http.c b/gass/transfer/source/library/globus_gass_transfer_http.c index 9cf0b17d19..926e485042 100644 --- a/gass/transfer/source/library/globus_gass_transfer_http.c +++ b/gass/transfer/source/library/globus_gass_transfer_http.c @@ -43,7 +43,7 @@ typedef struct { - globus_gass_transfer_http_listener_proto_t * l_proto; + globus_gass_transfer_http_listener_proto_t * l_proto; globus_gass_transfer_request_t request; } globus_l_gass_transfer_failed_kickout_closure_t; @@ -69,23 +69,23 @@ static int globus_l_gass_lock_line=0; static int globus_l_gass_lock_tmp=0; #define MYNAME(x) static char * myname=#x #define globus_l_gass_transfer_http_lock() \ - printf(strchr(globus_l_gass_transfer_http_debug_level,'9') ? "Thread [%d] acquiring mutex at %s:%d\n" : "", \ + printf(strchr(globus_l_gass_transfer_http_debug_level,'9') ? "Thread [%d] acquiring mutex at %s:%d\n" : "", \ (int) globus_thread_self(), \ - __FILE__, \ - __LINE__), \ - fflush(stdout), \ - globus_l_gass_lock_tmp = \ - globus_mutex_lock(&globus_l_gass_transfer_http_mutex), \ - globus_l_gass_lock_line=__LINE__, \ - globus_l_gass_lock_tmp + __FILE__, \ + __LINE__), \ + fflush(stdout), \ + globus_l_gass_lock_tmp = \ + globus_mutex_lock(&globus_l_gass_transfer_http_mutex), \ + globus_l_gass_lock_line=__LINE__, \ + globus_l_gass_lock_tmp #define globus_l_gass_transfer_http_unlock() \ printf(strchr(globus_l_gass_transfer_http_debug_level, '9') ? "Thread [%d] releasing mutex at %s:%d\n" : "", \ (int) globus_thread_self(), \ - __FILE__, \ - __LINE__), \ - fflush(stdout), \ - globus_l_gass_lock_line = 0, \ - globus_mutex_unlock(&globus_l_gass_transfer_http_mutex) + __FILE__, \ + __LINE__), \ + fflush(stdout), \ + globus_l_gass_lock_line = 0, \ + globus_mutex_unlock(&globus_l_gass_transfer_http_mutex) #else #define debug_printf(level, fmt) #define MYNAME(x) @@ -101,14 +101,14 @@ static volatile int globus_l_gass_transfer_http_closing; int globus_l_gass_transfer_http_activate(void) { - OM_uint32 maj_stat; - OM_uint32 min_stat; - gss_name_t name; - gss_cred_id_t globus_l_gass_transfer_http_credential = + OM_uint32 maj_stat; + OM_uint32 min_stat; + gss_name_t name; + gss_cred_id_t globus_l_gass_transfer_http_credential = GSS_C_NO_CREDENTIAL; - gss_buffer_desc name_buffer; + gss_buffer_desc name_buffer; MYNAME(globus_l_gass_transfer_http_activate); - + globus_l_gass_transfer_http_closing = 0; name_buffer.value = GLOBUS_NULL; name_buffer.length = 0; @@ -116,66 +116,66 @@ globus_l_gass_transfer_http_activate(void) # if defined(DEBUG_GASS_TRANSFER) { globus_l_gass_transfer_http_debug_level = - globus_module_getenv("GLOBUS_GASS_TRANSFER_HTTP_DEBUG_LEVEL"); + globus_module_getenv("GLOBUS_GASS_TRANSFER_HTTP_DEBUG_LEVEL"); - if(globus_l_gass_transfer_http_debug_level == GLOBUS_NULL) - { - globus_l_gass_transfer_http_debug_level = ""; - } + if(globus_l_gass_transfer_http_debug_level == GLOBUS_NULL) + { + globus_l_gass_transfer_http_debug_level = ""; + } } # endif - + debug_printf(1, (_GTSL("Entering %s()\n"),myname)); globus_module_activate(GLOBUS_COMMON_MODULE); globus_module_activate(GLOBUS_GSI_GSS_ASSIST_MODULE); globus_module_activate(GLOBUS_IO_MODULE); globus_mutex_init(&globus_l_gass_transfer_http_mutex, - GLOBUS_NULL); + GLOBUS_NULL); globus_cond_init(&globus_l_gass_transfer_http_cond, - GLOBUS_NULL); + GLOBUS_NULL); maj_stat = globus_gss_assist_acquire_cred( - &min_stat, - GSS_C_BOTH, - &globus_l_gass_transfer_http_credential); + &min_stat, + GSS_C_BOTH, + &globus_l_gass_transfer_http_credential); if (maj_stat != GSS_S_COMPLETE) { - goto error_exit; + goto error_exit; } maj_stat = gss_inquire_cred( - &min_stat, - globus_l_gass_transfer_http_credential, - &name, - GLOBUS_NULL, - GLOBUS_NULL, - GLOBUS_NULL); + &min_stat, + globus_l_gass_transfer_http_credential, + &name, + GLOBUS_NULL, + GLOBUS_NULL, + GLOBUS_NULL); if (maj_stat != GSS_S_COMPLETE) { - goto error_exit; + goto error_exit; } maj_stat = gss_display_name( - &min_stat, - name, - &name_buffer, - GLOBUS_NULL); + &min_stat, + name, + &name_buffer, + GLOBUS_NULL); if (maj_stat != GSS_S_COMPLETE) { - goto error_exit; + goto error_exit; } maj_stat = gss_release_name( - &min_stat, - &name); + &min_stat, + &name); if (maj_stat != GSS_S_COMPLETE) { - goto error_exit; + goto error_exit; } - + globus_l_gass_transfer_http_subject_name = name_buffer.value; if (globus_l_gass_transfer_http_credential != GSS_C_NO_CREDENTIAL) @@ -184,7 +184,7 @@ globus_l_gass_transfer_http_activate(void) } debug_printf(1, (_GTSL("Exiting %s()\n"),myname)); - + return GLOBUS_SUCCESS; error_exit: @@ -207,7 +207,7 @@ globus_l_gass_transfer_http_deactivate(void) globus_l_gass_transfer_http_lock(); while(globus_l_gass_transfer_http_closing > 0) { - globus_l_gass_transfer_http_wait(); + globus_l_gass_transfer_http_wait(); } globus_l_gass_transfer_http_unlock(); globus_module_deactivate(GLOBUS_IO_MODULE); @@ -263,27 +263,27 @@ globus_i_gass_transfer_https_descriptor = /* * Function: globus_l_gass_transfer_http_send() - * + * * Description: Send a byte array to an HTTP server - * - * Parameters: - * - * Returns: + * + * Parameters: + * + * Returns: */ static void globus_l_gass_transfer_http_send( - globus_gass_transfer_request_proto_t * proto, - globus_gass_transfer_request_t request, - globus_byte_t * buffer, - globus_size_t buffer_length, - globus_bool_t last_data) + globus_gass_transfer_request_proto_t * proto, + globus_gass_transfer_request_t request, + globus_byte_t * buffer, + globus_size_t buffer_length, + globus_bool_t last_data) { - globus_result_t result; - globus_gass_transfer_http_request_proto_t * new_proto; + globus_result_t result; + globus_gass_transfer_http_request_proto_t * new_proto; globus_reltime_t delay_time; MYNAME(globus_l_gass_transfer_http_send); - + debug_printf(1, (_GTSL("Entering %s()\n"),myname)); globus_l_gass_transfer_http_lock(); new_proto = (globus_gass_transfer_http_request_proto_t *) proto; @@ -304,77 +304,77 @@ globus_l_gass_transfer_http_send( */ if(new_proto->failure_occurred) { - goto fail_exit; + goto fail_exit; } /* Register the send of the data */ if(new_proto->chunked) { - globus_size_t num_iovecs; - - /* send chunk header and footer as an iovec array */ - sprintf((char *) new_proto->iov[0].iov_base, - "%zx%s", - new_proto->user_buflen, - CRLF); - new_proto->iov[0].iov_len = strlen((char *) new_proto->iov[0].iov_base); - - new_proto->iov[1].iov_base = (void *) new_proto->user_buffer; - new_proto->iov[1].iov_len = new_proto->user_buflen; - - new_proto->iov[2].iov_base = CRLF; - new_proto->iov[2].iov_len = 2; - - if(last_data && new_proto->user_buflen != 0) - { - /* last data, need to append a zero-length chunk to - * indicate this - */ - num_iovecs = 4; - } - else if(last_data && new_proto->user_buflen == 0) - { - /* last data, with a zero-length chunk from the user */ - new_proto->iov[1].iov_base = CRLF; - new_proto->iov[1].iov_len = 2; - num_iovecs = 2; - } - else - { - /* normal chunk */ - num_iovecs = 3; - } - - debug_printf(4, (_GTSL("%s(): Registering writev\n"), myname)); - result = globus_io_register_writev( - &new_proto->handle, - new_proto->iov, - num_iovecs /* 3 iovecs header, body, final CRLF */, - globus_l_gass_transfer_http_writev_callback, - new_proto); + globus_size_t num_iovecs; + + /* send chunk header and footer as an iovec array */ + sprintf((char *) new_proto->iov[0].iov_base, + "%zx%s", + new_proto->user_buflen, + CRLF); + new_proto->iov[0].iov_len = strlen((char *) new_proto->iov[0].iov_base); + + new_proto->iov[1].iov_base = (void *) new_proto->user_buffer; + new_proto->iov[1].iov_len = new_proto->user_buflen; + + new_proto->iov[2].iov_base = CRLF; + new_proto->iov[2].iov_len = 2; + + if(last_data && new_proto->user_buflen != 0) + { + /* last data, need to append a zero-length chunk to + * indicate this + */ + num_iovecs = 4; + } + else if(last_data && new_proto->user_buflen == 0) + { + /* last data, with a zero-length chunk from the user */ + new_proto->iov[1].iov_base = CRLF; + new_proto->iov[1].iov_len = 2; + num_iovecs = 2; + } + else + { + /* normal chunk */ + num_iovecs = 3; + } + + debug_printf(4, (_GTSL("%s(): Registering writev\n"), myname)); + result = globus_io_register_writev( + &new_proto->handle, + new_proto->iov, + num_iovecs /* 3 iovecs header, body, final CRLF */, + globus_l_gass_transfer_http_writev_callback, + new_proto); } else { - /* send data raw */ - debug_printf(4, (_GTSL("%s(): Registering writev\n"), myname)); - result = globus_io_register_write( - &new_proto->handle, - new_proto->user_buffer, - new_proto->user_buflen, - globus_l_gass_transfer_http_write_callback, - new_proto); + /* send data raw */ + debug_printf(4, (_GTSL("%s(): Registering writev\n"), myname)); + result = globus_io_register_write( + &new_proto->handle, + new_proto->user_buffer, + new_proto->user_buflen, + globus_l_gass_transfer_http_write_callback, + new_proto); } if(result == GLOBUS_SUCCESS) { - /* - * Registration succeeded. Callback to GASS occurs when I/O - * completes. - */ - globus_l_gass_transfer_http_unlock(); + /* + * Registration succeeded. Callback to GASS occurs when I/O + * completes. + */ + globus_l_gass_transfer_http_unlock(); - debug_printf(1, (_GTSL("exiting %s()\n"),myname)); - return; + debug_printf(1, (_GTSL("exiting %s()\n"),myname)); + return; } fail_exit: @@ -391,9 +391,9 @@ globus_l_gass_transfer_http_send( debug_printf(4, (_GTSL("%s(): Registering oneshot\n"), myname)); globus_callback_register_oneshot( GLOBUS_NULL, - &delay_time, - globus_l_gass_transfer_http_callback_send_callback, - (void *) new_proto); + &delay_time, + globus_l_gass_transfer_http_callback_send_callback, + (void *) new_proto); globus_l_gass_transfer_http_unlock(); debug_printf(1, (_GTSL("exiting %s()\n"),myname)); @@ -403,29 +403,29 @@ globus_l_gass_transfer_http_send( /* * Function: globus_l_gass_transfer_http_receive() - * + * * Description: Schedule the next block of data from the http server * to end up in the provided byte array - * - * Parameters: - * - * Returns: + * + * Parameters: + * + * Returns: */ static void globus_l_gass_transfer_http_receive( - globus_gass_transfer_request_proto_t * proto, - globus_gass_transfer_request_t request, - globus_byte_t * buffer, - globus_size_t buffer_length, - globus_size_t wait_for_length) + globus_gass_transfer_request_proto_t * proto, + globus_gass_transfer_request_t request, + globus_byte_t * buffer, + globus_size_t buffer_length, + globus_size_t wait_for_length) { - globus_gass_transfer_http_request_proto_t * new_proto; + globus_gass_transfer_http_request_proto_t * new_proto; globus_reltime_t delay_time; MYNAME(globus_l_gass_transfer_http_receive); - + debug_printf(1, (_GTSL("Entering %s()\n"),myname)); - + globus_l_gass_transfer_http_lock(); new_proto = (globus_gass_transfer_http_request_proto_t *) proto; @@ -446,9 +446,9 @@ globus_l_gass_transfer_http_receive( debug_printf(4, (_GTSL("%s(): Registering oneshot\n"), myname)); globus_callback_register_oneshot( GLOBUS_NULL, - &delay_time, - globus_l_gass_transfer_http_callback_read_buffered_callback, - (void *) new_proto); + &delay_time, + globus_l_gass_transfer_http_callback_read_buffered_callback, + (void *) new_proto); globus_l_gass_transfer_http_unlock(); debug_printf(1, (_GTSL("exiting %s()\n"),myname)); @@ -457,21 +457,21 @@ globus_l_gass_transfer_http_receive( /* * Function: globus_l_gass_transfer_http_fail() - * + * * Description: Cause the given request to fail for client-caused reasons - * - * Parameters: - * - * Returns: + * + * Parameters: + * + * Returns: */ static void globus_l_gass_transfer_http_fail( - globus_gass_transfer_request_proto_t * proto, - globus_gass_transfer_request_t request) + globus_gass_transfer_request_proto_t * proto, + globus_gass_transfer_request_t request) { - globus_gass_transfer_http_request_proto_t * new_proto; - globus_bool_t signalled; + globus_gass_transfer_http_request_proto_t * new_proto; + globus_bool_t signalled; globus_result_t result; MYNAME(globus_l_gass_transfer_http_fail); @@ -484,42 +484,42 @@ globus_l_gass_transfer_http_fail( signalled = GLOBUS_FALSE; while(!signalled) { - switch(new_proto->state) - { - case GLOBUS_GASS_TRANSFER_HTTP_STATE_PENDING: - if(new_proto->oneshot_registered == GLOBUS_TRUE) - { - new_proto->failure_occurred = GLOBUS_TRUE; - signalled = GLOBUS_TRUE; - - break; - } - else if(new_proto->oneshot_active) - { - new_proto->failure_occurred = GLOBUS_TRUE; - while(new_proto->state == - GLOBUS_GASS_TRANSFER_HTTP_STATE_PENDING) - { - globus_l_gass_transfer_http_wait(); - } - break; - } + switch(new_proto->state) + { + case GLOBUS_GASS_TRANSFER_HTTP_STATE_PENDING: + if(new_proto->oneshot_registered == GLOBUS_TRUE) + { + new_proto->failure_occurred = GLOBUS_TRUE; + signalled = GLOBUS_TRUE; + + break; + } + else if(new_proto->oneshot_active) + { + new_proto->failure_occurred = GLOBUS_TRUE; + while(new_proto->state == + GLOBUS_GASS_TRANSFER_HTTP_STATE_PENDING) + { + globus_l_gass_transfer_http_wait(); + } + break; + } case GLOBUS_GASS_TRANSFER_HTTP_STATE_CONNECTING: case GLOBUS_GASS_TRANSFER_HTTP_STATE_IDLE: - /* We will transition to the closing state, signalling the failure, - * and registering the close (which will transition us to the - * done state). - */ - signalled = GLOBUS_TRUE; - new_proto->failure_occurred = GLOBUS_TRUE; + /* We will transition to the closing state, signalling the failure, + * and registering the close (which will transition us to the + * done state). + */ + signalled = GLOBUS_TRUE; + new_proto->failure_occurred = GLOBUS_TRUE; - result = globus_l_gass_transfer_http_register_close(new_proto); + result = globus_l_gass_transfer_http_register_close(new_proto); if (result != GLOBUS_SUCCESS) { globus_l_gass_transfer_http_close(new_proto); } - break; + break; case GLOBUS_GASS_TRANSFER_HTTP_STATE_CLOSING: case GLOBUS_GASS_TRANSFER_HTTP_STATE_DONE: @@ -527,9 +527,9 @@ globus_l_gass_transfer_http_fail( case GLOBUS_GASS_TRANSFER_HTTP_STATE_RESPONDING: case GLOBUS_GASS_TRANSFER_HTTP_STATE_REFERRED: case GLOBUS_GASS_TRANSFER_HTTP_STATE_DENIED: - signalled = GLOBUS_TRUE; - new_proto->failure_occurred = GLOBUS_TRUE; - break; + signalled = GLOBUS_TRUE; + new_proto->failure_occurred = GLOBUS_TRUE; + break; } } globus_l_gass_transfer_http_unlock(); @@ -540,13 +540,13 @@ globus_l_gass_transfer_http_fail( static void globus_l_gass_transfer_http_write_callback( - void * callback_arg, - globus_io_handle_t * handle, - globus_result_t result, - globus_byte_t * buf, - globus_size_t nbytes) + void * callback_arg, + globus_io_handle_t * handle, + globus_result_t result, + globus_byte_t * buf, + globus_size_t nbytes) { - globus_gass_transfer_http_request_proto_t * proto; + globus_gass_transfer_http_request_proto_t * proto; MYNAME(globus_l_gass_transfer_http_write_callback); debug_printf(3, (_GTSL("Entering %s()\n"),myname)); @@ -555,113 +555,113 @@ globus_l_gass_transfer_http_write_callback( globus_l_gass_transfer_http_lock(); if(result != GLOBUS_SUCCESS || - proto->failure_occurred || - proto->parse_error) + proto->failure_occurred || + proto->parse_error) { - proto->last_data = GLOBUS_TRUE; + proto->last_data = GLOBUS_TRUE; } if(proto->last_data) { - proto->user_offset = nbytes; - if((proto->type == GLOBUS_GASS_TRANSFER_REQUEST_TYPE_PUT || - proto->type == GLOBUS_GASS_TRANSFER_REQUEST_TYPE_APPEND) && - (!proto->failure_occurred && !proto->parse_error)) - { - if(proto->got_response) - { - globus_byte_t * buffer; - globus_size_t offset; - globus_gass_transfer_request_t request = proto->request; + proto->user_offset = nbytes; + if((proto->type == GLOBUS_GASS_TRANSFER_REQUEST_TYPE_PUT || + proto->type == GLOBUS_GASS_TRANSFER_REQUEST_TYPE_APPEND) && + (!proto->failure_occurred && !proto->parse_error)) + { + if(proto->got_response) + { + globus_byte_t * buffer; + globus_size_t offset; + globus_gass_transfer_request_t request = proto->request; - int failed = proto->failure_occurred; + int failed = proto->failure_occurred; - proto->failure_occurred = GLOBUS_TRUE; - buffer = proto->user_buffer; - offset = proto->user_offset; + proto->failure_occurred = GLOBUS_TRUE; + buffer = proto->user_buffer; + offset = proto->user_offset; - result = globus_l_gass_transfer_http_register_close(proto); + result = globus_l_gass_transfer_http_register_close(proto); if (result != GLOBUS_SUCCESS) { globus_l_gass_transfer_http_close(proto); } - globus_l_gass_transfer_http_unlock(); - globus_gass_transfer_proto_send_complete(request, - buffer, - offset, - failed, - GLOBUS_TRUE); - debug_printf(3, (_GTSL("Exiting %s()\n"),myname)); - return; - } - else - { - /* the callback to read the response is registered at - * the beginning of the send, so we do nothing here, - * and wait for the response - */ - proto->waiting_for_response = GLOBUS_TRUE; - globus_l_gass_transfer_http_unlock(); - - debug_printf(3, (_GTSL("Exiting %s()\n"),myname)); - return; - } - } - else - { - globus_gass_transfer_request_t request; - globus_byte_t * buf; - globus_size_t nbytes_sent; - globus_bool_t fail; - - request = proto->request; - buf = proto->user_buffer; - nbytes_sent = proto->user_offset; - fail = proto->failure_occurred; - - - /* need to register the close, and callback to the user */ - result = globus_l_gass_transfer_http_register_close(proto); + globus_l_gass_transfer_http_unlock(); + globus_gass_transfer_proto_send_complete(request, + buffer, + offset, + failed, + GLOBUS_TRUE); + debug_printf(3, (_GTSL("Exiting %s()\n"),myname)); + return; + } + else + { + /* the callback to read the response is registered at + * the beginning of the send, so we do nothing here, + * and wait for the response + */ + proto->waiting_for_response = GLOBUS_TRUE; + globus_l_gass_transfer_http_unlock(); + + debug_printf(3, (_GTSL("Exiting %s()\n"),myname)); + return; + } + } + else + { + globus_gass_transfer_request_t request; + globus_byte_t * buf; + globus_size_t nbytes_sent; + globus_bool_t fail; + + request = proto->request; + buf = proto->user_buffer; + nbytes_sent = proto->user_offset; + fail = proto->failure_occurred; + + + /* need to register the close, and callback to the user */ + result = globus_l_gass_transfer_http_register_close(proto); if (result != GLOBUS_SUCCESS) { globus_l_gass_transfer_http_close(proto); } - - globus_l_gass_transfer_http_unlock(); - globus_gass_transfer_proto_send_complete( - request, - buf, - nbytes_sent, - fail, - GLOBUS_TRUE); - debug_printf(3, (_GTSL("Exiting %s()\n"),myname)); + globus_l_gass_transfer_http_unlock(); + + globus_gass_transfer_proto_send_complete( + request, + buf, + nbytes_sent, + fail, + GLOBUS_TRUE); + debug_printf(3, (_GTSL("Exiting %s()\n"),myname)); - return; - } + return; + } } else { - globus_gass_transfer_request_t request; - globus_byte_t * buf; - globus_bool_t fail; - globus_bool_t last_data; - - proto->state = GLOBUS_GASS_TRANSFER_HTTP_STATE_IDLE; - - request = proto->request; - buf = proto->user_buffer; - fail = proto->failure_occurred; - last_data = proto->last_data; - - - globus_l_gass_transfer_http_unlock(); - globus_gass_transfer_proto_send_complete(request, - buf, - nbytes, - fail, - last_data); + globus_gass_transfer_request_t request; + globus_byte_t * buf; + globus_bool_t fail; + globus_bool_t last_data; + + proto->state = GLOBUS_GASS_TRANSFER_HTTP_STATE_IDLE; + + request = proto->request; + buf = proto->user_buffer; + fail = proto->failure_occurred; + last_data = proto->last_data; + + + globus_l_gass_transfer_http_unlock(); + globus_gass_transfer_proto_send_complete(request, + buf, + nbytes, + fail, + last_data); } debug_printf(3, (_GTSL("Exiting %s()\n"),myname)); return; @@ -671,14 +671,14 @@ globus_l_gass_transfer_http_write_callback( static void globus_l_gass_transfer_http_writev_callback( - void * callback_arg, - globus_io_handle_t * handle, - globus_result_t result, - struct iovec * iov, - globus_size_t iovcnt, - globus_size_t nbytes) + void * callback_arg, + globus_io_handle_t * handle, + globus_result_t result, + struct iovec * iov, + globus_size_t iovcnt, + globus_size_t nbytes) { - globus_gass_transfer_http_request_proto_t * proto; + globus_gass_transfer_http_request_proto_t * proto; MYNAME(globus_l_gass_transfer_http_writev_callback); debug_printf(3, (_GTSL("Entering %s()\n"),myname)); @@ -687,132 +687,132 @@ globus_l_gass_transfer_http_writev_callback( globus_l_gass_transfer_http_lock(); if(result != GLOBUS_SUCCESS || - proto->failure_occurred || - proto->parse_error) + proto->failure_occurred || + proto->parse_error) { - proto->last_data = GLOBUS_TRUE; + proto->last_data = GLOBUS_TRUE; } if(proto->last_data) { - proto->user_offset = nbytes - iov[0].iov_len - iov[2].iov_len; + proto->user_offset = nbytes - iov[0].iov_len - iov[2].iov_len; - if((proto->type == GLOBUS_GASS_TRANSFER_REQUEST_TYPE_PUT || - proto->type == GLOBUS_GASS_TRANSFER_REQUEST_TYPE_APPEND) && - (!proto->failure_occurred && !proto->parse_error)) - { - if(proto->got_response) - { - globus_byte_t * buffer; - globus_size_t offset; - int failed = proto->failure_occurred; - globus_gass_transfer_request_t request = proto->request; + if((proto->type == GLOBUS_GASS_TRANSFER_REQUEST_TYPE_PUT || + proto->type == GLOBUS_GASS_TRANSFER_REQUEST_TYPE_APPEND) && + (!proto->failure_occurred && !proto->parse_error)) + { + if(proto->got_response) + { + globus_byte_t * buffer; + globus_size_t offset; + int failed = proto->failure_occurred; + globus_gass_transfer_request_t request = proto->request; - buffer = proto->user_buffer; - offset = proto->user_offset; + buffer = proto->user_buffer; + offset = proto->user_offset; - result = globus_l_gass_transfer_http_register_close(proto); + result = globus_l_gass_transfer_http_register_close(proto); if (result != GLOBUS_SUCCESS) { globus_l_gass_transfer_http_close(proto); } - globus_l_gass_transfer_http_unlock(); - globus_gass_transfer_proto_send_complete(request, - buffer, - offset, - failed, - GLOBUS_TRUE); - debug_printf(3, (_GTSL("Exiting %s()\n"),myname)); - return; - } - else - { - /* the callback to read the response is registered at - * the beginning of the send, so we do nothing here, - * and wait for the response - */ - proto->waiting_for_response = GLOBUS_TRUE; - globus_l_gass_transfer_http_unlock(); - - debug_printf(3, (_GTSL("Exiting %s()\n"),myname)); - return; - } - } - else - { - globus_gass_transfer_request_t request; - globus_byte_t *buf; - globus_size_t nbytes_sent; - globus_bool_t fail; - - request = proto->request; - buf = proto->user_buffer; - nbytes_sent = proto->user_offset; - fail = proto->failure_occurred; - - /* need to register the close, and callback to the user */ - result = globus_l_gass_transfer_http_register_close(proto); + globus_l_gass_transfer_http_unlock(); + globus_gass_transfer_proto_send_complete(request, + buffer, + offset, + failed, + GLOBUS_TRUE); + debug_printf(3, (_GTSL("Exiting %s()\n"),myname)); + return; + } + else + { + /* the callback to read the response is registered at + * the beginning of the send, so we do nothing here, + * and wait for the response + */ + proto->waiting_for_response = GLOBUS_TRUE; + globus_l_gass_transfer_http_unlock(); + + debug_printf(3, (_GTSL("Exiting %s()\n"),myname)); + return; + } + } + else + { + globus_gass_transfer_request_t request; + globus_byte_t *buf; + globus_size_t nbytes_sent; + globus_bool_t fail; + + request = proto->request; + buf = proto->user_buffer; + nbytes_sent = proto->user_offset; + fail = proto->failure_occurred; + + /* need to register the close, and callback to the user */ + result = globus_l_gass_transfer_http_register_close(proto); if (result != GLOBUS_SUCCESS) { globus_l_gass_transfer_http_close(proto); } - globus_l_gass_transfer_http_unlock(); - globus_gass_transfer_proto_send_complete( - request, - buf, - nbytes_sent, - fail, - GLOBUS_TRUE); - debug_printf(3, (_GTSL("Exiting %s()\n"),myname)); - return; - } + globus_l_gass_transfer_http_unlock(); + globus_gass_transfer_proto_send_complete( + request, + buf, + nbytes_sent, + fail, + GLOBUS_TRUE); + debug_printf(3, (_GTSL("Exiting %s()\n"),myname)); + return; + } } else { - globus_gass_transfer_request_t request; - globus_byte_t *buf; - globus_size_t nbytes_sent; - globus_bool_t fail; - - request = proto->request; - buf = proto->user_buffer; - nbytes_sent = nbytes - iov[0].iov_len - iov[2].iov_len, - fail = proto->failure_occurred; - - proto->state = GLOBUS_GASS_TRANSFER_HTTP_STATE_IDLE; - - globus_l_gass_transfer_http_unlock(); - globus_gass_transfer_proto_send_complete(request, - buf, - nbytes_sent, - fail, - GLOBUS_FALSE); - debug_printf(3, (_GTSL("Exiting %s()\n"),myname)); - return; + globus_gass_transfer_request_t request; + globus_byte_t *buf; + globus_size_t nbytes_sent; + globus_bool_t fail; + + request = proto->request; + buf = proto->user_buffer; + nbytes_sent = nbytes - iov[0].iov_len - iov[2].iov_len, + fail = proto->failure_occurred; + + proto->state = GLOBUS_GASS_TRANSFER_HTTP_STATE_IDLE; + + globus_l_gass_transfer_http_unlock(); + globus_gass_transfer_proto_send_complete(request, + buf, + nbytes_sent, + fail, + GLOBUS_FALSE); + debug_printf(3, (_GTSL("Exiting %s()\n"),myname)); + return; } } /* globus_l_gass_transfer_http_writev_callback() */ /* * Function: globus_l_gass_transfer_http_read_callack() - * + * * Description: Callback when the read of from the connection to the active * buffer has completed or failed. - * - * Parameters: - * - * Returns: + * + * Parameters: + * + * Returns: */ static void globus_l_gass_transfer_http_read_callback( - void * callback_arg, - globus_io_handle_t * handle, - globus_result_t result, - globus_byte_t * buf, - globus_size_t nbytes) + void * callback_arg, + globus_io_handle_t * handle, + globus_result_t result, + globus_byte_t * buf, + globus_size_t nbytes) { globus_object_t * err = GLOBUS_NULL; globus_gass_transfer_http_request_proto_t * proto; @@ -820,21 +820,21 @@ globus_l_gass_transfer_http_read_callback( globus_bool_t last_data = GLOBUS_FALSE; globus_bool_t failure = GLOBUS_FALSE; globus_size_t offset = 0; - + MYNAME(globus_l_gass_transfer_http_read_callback); - + debug_printf(3, (_GTSL("Entering %s()\n"),myname)); - + proto = (globus_gass_transfer_http_request_proto_t *) callback_arg; if(result != GLOBUS_SUCCESS) { char * tmpstr; - err = globus_error_get(result); - tmpstr = globus_object_printable_to_string(err); - debug_printf(5, (_GTSL("%s(): Error: %s\n"), myname, tmpstr)); - globus_libc_free(tmpstr); + err = globus_error_get(result); + tmpstr = globus_object_printable_to_string(err); + debug_printf(5, (_GTSL("%s(): Error: %s\n"), myname, tmpstr)); + globus_libc_free(tmpstr); } globus_l_gass_transfer_http_lock(); @@ -843,111 +843,111 @@ globus_l_gass_transfer_http_read_callback( proto->handled += nbytes; if(nbytes > proto->user_waitlen) { - proto->user_waitlen = 0; + proto->user_waitlen = 0; } else { - proto->user_waitlen -= nbytes; + proto->user_waitlen -= nbytes; } if(proto->chunked) { - proto->chunk_left -= nbytes; + proto->chunk_left -= nbytes; } if(result != GLOBUS_SUCCESS && globus_io_eof(err)) { - proto->eof_read = GLOBUS_TRUE; + proto->eof_read = GLOBUS_TRUE; } else if(result != GLOBUS_SUCCESS || - proto->failure_occurred || - proto->parse_error) + proto->failure_occurred || + proto->parse_error) { - proto->recv_state = GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_ERROR; + proto->recv_state = GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_ERROR; } if(proto->recv_state == GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_UNTIL_EOF && proto->eof_read == GLOBUS_TRUE) { - proto->recv_state = GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_EOF; + proto->recv_state = GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_EOF; } else if(proto->recv_state == - GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_UNTIL_LENGTH && - proto->handled == proto->length) + GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_UNTIL_LENGTH && + proto->handled == proto->length) { - proto->recv_state = GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_EOF; + proto->recv_state = GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_EOF; } else if(proto->recv_state == - GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_UNTIL_LENGTH && - proto->eof_read == GLOBUS_TRUE && - proto->handled < proto->length) + GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_UNTIL_LENGTH && + proto->eof_read == GLOBUS_TRUE && + proto->handled < proto->length) { - proto->recv_state = GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_ERROR; + proto->recv_state = GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_ERROR; } else if(nbytes==0 && proto->eof_read) { proto->failure_occurred = GLOBUS_TRUE; - proto->recv_state = GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_ERROR; + proto->recv_state = GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_ERROR; } if((proto->type == GLOBUS_GASS_TRANSFER_REQUEST_TYPE_PUT || proto->type == GLOBUS_GASS_TRANSFER_REQUEST_TYPE_APPEND) && proto->recv_state == GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_EOF) { - char * response; - globus_size_t response_len=0; - globus_size_t offset; - - - response_len += 1; - response_len += strlen(GLOBUS_L_GENERIC_RESPONSE); - response_len += 3; - response_len += strlen(GLOBUS_L_OK); - response_len += 2; - response = globus_malloc(response_len); - - proto->state = GLOBUS_GASS_TRANSFER_HTTP_STATE_RESPONDING; - offset = sprintf(response, - GLOBUS_L_GENERIC_RESPONSE, - 0, - 200, - GLOBUS_L_OK); - offset += sprintf(response + offset, - CRLF); - - debug_printf(4,(_GTSL("%s(): Registering write\n"),myname)); - globus_io_register_write(&proto->handle, - (globus_byte_t *) response, - strlen(response), - globus_l_gass_transfer_http_write_response, - proto); + char * response; + globus_size_t response_len=0; + globus_size_t offset; + + + response_len += 1; + response_len += strlen(GLOBUS_L_GENERIC_RESPONSE); + response_len += 3; + response_len += strlen(GLOBUS_L_OK); + response_len += 2; + response = globus_malloc(response_len); + + proto->state = GLOBUS_GASS_TRANSFER_HTTP_STATE_RESPONDING; + offset = sprintf(response, + GLOBUS_L_GENERIC_RESPONSE, + 0, + 200, + GLOBUS_L_OK); + offset += sprintf(response + offset, + CRLF); + + debug_printf(4,(_GTSL("%s(): Registering write\n"),myname)); + globus_io_register_write(&proto->handle, + (globus_byte_t *) response, + strlen(response), + globus_l_gass_transfer_http_write_response, + proto); } /* Register the socket for closing if we're done reading from it */ else if(proto->recv_state == GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_EOF || proto->recv_state == GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_ERROR) { - failure = proto->failure_occurred; - buf = proto->user_buffer; - offset = proto->user_offset; - request = proto->request; + failure = proto->failure_occurred; + buf = proto->user_buffer; + offset = proto->user_offset; + request = proto->request; last_data = GLOBUS_TRUE; - if(proto->state != GLOBUS_GASS_TRANSFER_HTTP_STATE_CLOSING) - { - result = globus_l_gass_transfer_http_register_close(proto); + if(proto->state != GLOBUS_GASS_TRANSFER_HTTP_STATE_CLOSING) + { + result = globus_l_gass_transfer_http_register_close(proto); if (result != GLOBUS_SUCCESS) { globus_l_gass_transfer_http_close(proto); } - } - globus_l_gass_transfer_http_unlock(); - debug_printf(2, (_GTSL("calling globus_gass_transfer_proto_receive_complete()"))); - globus_gass_transfer_proto_receive_complete(request, - buf, - offset, - failure, - last_data); + } + globus_l_gass_transfer_http_unlock(); + debug_printf(2, (_GTSL("calling globus_gass_transfer_proto_receive_complete()"))); + globus_gass_transfer_proto_receive_complete(request, + buf, + offset, + failure, + last_data); goto out; } @@ -955,44 +955,44 @@ globus_l_gass_transfer_http_read_callback( proto->recv_state == GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_EOF || proto->recv_state == GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_ERROR) { - /* - * Received the required minimum of data from connection, an - * error, or the end-of file, signal this to GASS - */ - if(proto->state == GLOBUS_GASS_TRANSFER_HTTP_STATE_PENDING) - { - proto->state = GLOBUS_GASS_TRANSFER_HTTP_STATE_IDLE; - } - if(proto->recv_state == GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_EOF || - proto->recv_state == GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_ERROR) - { - last_data = GLOBUS_TRUE; - } - - failure = proto->failure_occurred; - buf = proto->user_buffer; - offset = proto->user_offset; - request = proto->request; - - globus_l_gass_transfer_http_unlock(); - debug_printf(2, (_GTSL("calling globus_gass_transfer_proto_receive_complete()"))); - globus_gass_transfer_proto_receive_complete(request, - buf, - offset, - failure, - last_data); + /* + * Received the required minimum of data from connection, an + * error, or the end-of file, signal this to GASS + */ + if(proto->state == GLOBUS_GASS_TRANSFER_HTTP_STATE_PENDING) + { + proto->state = GLOBUS_GASS_TRANSFER_HTTP_STATE_IDLE; + } + if(proto->recv_state == GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_EOF || + proto->recv_state == GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_ERROR) + { + last_data = GLOBUS_TRUE; + } + + failure = proto->failure_occurred; + buf = proto->user_buffer; + offset = proto->user_offset; + request = proto->request; + + globus_l_gass_transfer_http_unlock(); + debug_printf(2, (_GTSL("calling globus_gass_transfer_proto_receive_complete()"))); + globus_gass_transfer_proto_receive_complete(request, + buf, + offset, + failure, + last_data); } else { - result = globus_l_gass_transfer_http_register_read(proto); + result = globus_l_gass_transfer_http_register_read(proto); - globus_l_gass_transfer_http_unlock(); + globus_l_gass_transfer_http_unlock(); } out: if(err) { - globus_object_free(err); + globus_object_free(err); } debug_printf(3, (_GTSL("Exiting %s()\n"),myname)); @@ -1002,25 +1002,25 @@ globus_l_gass_transfer_http_read_callback( /* * Function: globus_l_gass_transfer_http_read_buffered_callack() - * + * * Description: Callback when the read of from the http to the * response buffer has completed or failed. - * - * Parameters: - * - * Returns: + * + * Parameters: + * + * Returns: */ static void globus_l_gass_transfer_http_read_buffered_callback( - void * callback_arg, - globus_io_handle_t * handle, - globus_result_t result, - globus_byte_t * buf, - globus_size_t nbytes) + void * callback_arg, + globus_io_handle_t * handle, + globus_result_t result, + globus_byte_t * buf, + globus_size_t nbytes) { - globus_object_t * err = GLOBUS_NULL; - globus_gass_transfer_http_request_proto_t * proto; + globus_object_t * err = GLOBUS_NULL; + globus_gass_transfer_http_request_proto_t * proto; MYNAME(globus_l_gass_transfer_http_read_buffered_callback); debug_printf(3, (_GTSL("Entering %s()\n"),myname)); @@ -1031,10 +1031,10 @@ globus_l_gass_transfer_http_read_buffered_callback( { char * tmpstr; - err = globus_error_get(result); - tmpstr = globus_object_printable_to_string(err); - debug_printf(5, (_GTSL("%s(): %s\n"), myname, tmpstr)); - globus_libc_free(tmpstr); + err = globus_error_get(result); + tmpstr = globus_object_printable_to_string(err); + debug_printf(5, (_GTSL("%s(): %s\n"), myname, tmpstr)); + globus_libc_free(tmpstr); } globus_l_gass_transfer_http_lock(); @@ -1044,11 +1044,11 @@ globus_l_gass_transfer_http_read_buffered_callback( if(result != GLOBUS_SUCCESS && globus_io_eof(err)) { - proto->eof_read = GLOBUS_TRUE; + proto->eof_read = GLOBUS_TRUE; } else if(result != GLOBUS_SUCCESS) { - proto->recv_state = GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_ERROR; + proto->recv_state = GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_ERROR; } /* @@ -1060,106 +1060,106 @@ globus_l_gass_transfer_http_read_buffered_callback( if(proto->failure_occurred) { - proto->recv_state = GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_ERROR; + proto->recv_state = GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_ERROR; } /* successful read for server, send response */ if((proto->type == GLOBUS_GASS_TRANSFER_REQUEST_TYPE_PUT || - proto->type == GLOBUS_GASS_TRANSFER_REQUEST_TYPE_APPEND) && + proto->type == GLOBUS_GASS_TRANSFER_REQUEST_TYPE_APPEND) && proto->recv_state == GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_EOF && proto->recv_state != GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_ERROR) { - char * response; - globus_size_t response_len=0; - globus_size_t offset; - - - response_len += 1; - response_len += strlen(GLOBUS_L_GENERIC_RESPONSE); - response_len += 3; - response_len += strlen(GLOBUS_L_OK); - response_len += 2; - response = globus_malloc(response_len); - - proto->state = GLOBUS_GASS_TRANSFER_HTTP_STATE_RESPONDING; - offset = sprintf(response, - GLOBUS_L_GENERIC_RESPONSE, - 0, - 200, - GLOBUS_L_OK); - offset += sprintf(response + offset, - CRLF); - - debug_printf(4,(_GTSL("%s(): Registering write\n"),myname)); - globus_io_register_write(&proto->handle, - (globus_byte_t *) response, - strlen(response), - globus_l_gass_transfer_http_write_response, - proto); + char * response; + globus_size_t response_len=0; + globus_size_t offset; + + + response_len += 1; + response_len += strlen(GLOBUS_L_GENERIC_RESPONSE); + response_len += 3; + response_len += strlen(GLOBUS_L_OK); + response_len += 2; + response = globus_malloc(response_len); + + proto->state = GLOBUS_GASS_TRANSFER_HTTP_STATE_RESPONDING; + offset = sprintf(response, + GLOBUS_L_GENERIC_RESPONSE, + 0, + 200, + GLOBUS_L_OK); + offset += sprintf(response + offset, + CRLF); + + debug_printf(4,(_GTSL("%s(): Registering write\n"),myname)); + globus_io_register_write(&proto->handle, + (globus_byte_t *) response, + strlen(response), + globus_l_gass_transfer_http_write_response, + proto); } /* Register the socket for closing if we're done reading from it */ else if(proto->recv_state == GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_EOF || - proto->recv_state == GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_ERROR) + proto->recv_state == GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_ERROR) { - if(proto->state != GLOBUS_GASS_TRANSFER_HTTP_STATE_CLOSING) - { - result = globus_l_gass_transfer_http_register_close(proto); + if(proto->state != GLOBUS_GASS_TRANSFER_HTTP_STATE_CLOSING) + { + result = globus_l_gass_transfer_http_register_close(proto); if (result != GLOBUS_SUCCESS) { globus_l_gass_transfer_http_close(proto); } - } + } } if(proto->user_waitlen == 0 || proto->recv_state == GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_EOF || proto->recv_state == GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_ERROR) { - globus_gass_transfer_request_t request; - globus_bool_t last_data = GLOBUS_FALSE; - globus_bool_t failure ; - globus_byte_t * buf; - globus_size_t offset; - /* - * Received the required minimum of data from connection, an - * error, or the end-of file, signal this to GASS - */ - if(proto->state == GLOBUS_GASS_TRANSFER_HTTP_STATE_PENDING) - { - proto->state = GLOBUS_GASS_TRANSFER_HTTP_STATE_IDLE; - } - if(proto->recv_state == GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_EOF || - proto->recv_state == GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_ERROR) - { - last_data = GLOBUS_TRUE; - } - - if(err) - { - globus_object_free(err); - err = GLOBUS_NULL; - } - - proto->oneshot_active = GLOBUS_FALSE; - failure = proto->failure_occurred; - buf = proto->user_buffer; - offset = proto->user_offset; - request = proto->request; - - globus_l_gass_transfer_http_signal(); - globus_l_gass_transfer_http_unlock(); - - debug_printf(2, (_GTSL("calling globus_gass_transfer_proto_receive_complete()\n"))); - globus_gass_transfer_proto_receive_complete(request, - buf, - offset, - failure, - last_data); + globus_gass_transfer_request_t request; + globus_bool_t last_data = GLOBUS_FALSE; + globus_bool_t failure ; + globus_byte_t * buf; + globus_size_t offset; + /* + * Received the required minimum of data from connection, an + * error, or the end-of file, signal this to GASS + */ + if(proto->state == GLOBUS_GASS_TRANSFER_HTTP_STATE_PENDING) + { + proto->state = GLOBUS_GASS_TRANSFER_HTTP_STATE_IDLE; + } + if(proto->recv_state == GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_EOF || + proto->recv_state == GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_ERROR) + { + last_data = GLOBUS_TRUE; + } + + if(err) + { + globus_object_free(err); + err = GLOBUS_NULL; + } + + proto->oneshot_active = GLOBUS_FALSE; + failure = proto->failure_occurred; + buf = proto->user_buffer; + offset = proto->user_offset; + request = proto->request; + + globus_l_gass_transfer_http_signal(); + globus_l_gass_transfer_http_unlock(); + + debug_printf(2, (_GTSL("calling globus_gass_transfer_proto_receive_complete()\n"))); + globus_gass_transfer_proto_receive_complete(request, + buf, + offset, + failure, + last_data); debug_printf(3, (_GTSL("Exiting %s()\n"),myname)); - return; + return; } else { - result = globus_l_gass_transfer_http_register_read(proto); + result = globus_l_gass_transfer_http_register_read(proto); } if(result != GLOBUS_SUCCESS) @@ -1172,7 +1172,7 @@ globus_l_gass_transfer_http_read_buffered_callback( globus_l_gass_transfer_http_unlock(); if(err) { - globus_object_free(err); + globus_object_free(err); } debug_printf(3, (_GTSL("Exiting %s()\n"),myname)); return; @@ -1183,35 +1183,35 @@ globus_l_gass_transfer_http_read_buffered_callback( proto->oneshot_active = GLOBUS_FALSE; proto->oneshot_active = GLOBUS_FALSE; - + result = globus_l_gass_transfer_http_register_close(proto); if(err) { - globus_object_free(err); + globus_object_free(err); } { - globus_gass_transfer_request_t request; - globus_byte_t *buf; - globus_size_t offset; + globus_gass_transfer_request_t request; + globus_byte_t *buf; + globus_size_t offset; - request = proto->request; - buf = proto->user_buffer; - offset = proto->user_offset; + request = proto->request; + buf = proto->user_buffer; + offset = proto->user_offset; /* register close failed, act as though it was closed */ if (result != GLOBUS_SUCCESS) { globus_l_gass_transfer_http_close(proto); } - globus_l_gass_transfer_http_unlock(); - debug_printf(2, (_GTSL("calling globus_gass_transfer_proto_receive_complete()"))); - globus_gass_transfer_proto_receive_complete(request, - buf, - offset, - GLOBUS_TRUE, - GLOBUS_TRUE); + globus_l_gass_transfer_http_unlock(); + debug_printf(2, (_GTSL("calling globus_gass_transfer_proto_receive_complete()"))); + globus_gass_transfer_proto_receive_complete(request, + buf, + offset, + GLOBUS_TRUE, + GLOBUS_TRUE); } debug_printf(3, (_GTSL("Exiting %s()\n"),myname)); return; @@ -1233,11 +1233,11 @@ globus_l_gass_transfer_http_read_buffered_callback( static void globus_l_gass_transfer_http_close_callback( - void * callback_arg, - globus_io_handle_t * handle, - globus_result_t result) + void * callback_arg, + globus_io_handle_t * handle, + globus_result_t result) { - globus_gass_transfer_http_request_proto_t * proto; + globus_gass_transfer_http_request_proto_t * proto; MYNAME(globus_l_gass_transfer_http_close_callback); debug_printf(3, (_GTSL("Entering %s()\n"),myname)); @@ -1262,13 +1262,13 @@ globus_l_gass_transfer_http_close_callback( static void globus_l_gass_transfer_http_close( - globus_gass_transfer_http_request_proto_t * proto) + globus_gass_transfer_http_request_proto_t * proto) { proto->state = GLOBUS_GASS_TRANSFER_HTTP_STATE_DONE; if(proto->destroy_called) { - globus_l_gass_transfer_http_proto_destroy(proto); + globus_l_gass_transfer_http_proto_destroy(proto); } globus_l_gass_transfer_http_closing--; @@ -1289,20 +1289,20 @@ globus_l_gass_transfer_http_close( static globus_result_t globus_l_gass_transfer_http_register_close( - globus_gass_transfer_http_request_proto_t * proto) + globus_gass_transfer_http_request_proto_t * proto) { globus_result_t result; MYNAME(globus_l_gass_transfer_http_register_close); - + proto->state = GLOBUS_GASS_TRANSFER_HTTP_STATE_CLOSING; globus_l_gass_transfer_http_closing++; - + debug_printf(4,(_GTSL("%s(): registering close on %p\n"), myname, &proto->handle)); result = globus_io_register_close( - &proto->handle, - globus_l_gass_transfer_http_close_callback, - proto); + &proto->handle, + globus_l_gass_transfer_http_close_callback, + proto); return result; } @@ -1320,12 +1320,12 @@ globus_l_gass_transfer_http_register_close( static void globus_l_gass_transfer_http_listener_close_callback( - void * callback_arg, - globus_io_handle_t * handle, - globus_result_t result) + void * callback_arg, + globus_io_handle_t * handle, + globus_result_t result) { globus_gass_transfer_http_listener_proto_t * - proto; + proto; MYNAME(globus_l_gass_transfer_http_listener_close_callback); debug_printf(3, (_GTSL("Entering %s()\n"),myname)); @@ -1334,7 +1334,7 @@ globus_l_gass_transfer_http_listener_close_callback( globus_l_gass_transfer_http_lock(); globus_l_gass_transfer_http_listener_close(proto); globus_l_gass_transfer_http_unlock(); - debug_printf(3, (_GTSL("Exiting %s()\n"),myname)); + debug_printf(3, (_GTSL("Exiting %s()\n"),myname)); } /* globus_l_gass_transfer_http_listener_close_callback() */ @@ -1356,7 +1356,7 @@ globus_l_gass_transfer_http_listener_close( if(proto->destroy_called) { - globus_l_gass_transfer_http_listener_proto_destroy(proto); + globus_l_gass_transfer_http_listener_proto_destroy(proto); } globus_l_gass_transfer_http_closing--; @@ -1375,19 +1375,19 @@ globus_l_gass_transfer_http_register_listener_close( debug_printf(4,(_GTSL("%s(): registering close on %p\n"), myname, &proto->handle)); result = globus_io_register_close( - &proto->handle, - globus_l_gass_transfer_http_listener_close_callback, - proto); + &proto->handle, + globus_l_gass_transfer_http_listener_close_callback, + proto); globus_assert(result == GLOBUS_SUCCESS); if(result != GLOBUS_SUCCESS) { - globus_l_gass_transfer_http_listener_close(proto); + globus_l_gass_transfer_http_listener_close(proto); } } /* globus_l_gass_transfer_http_register_listener_close() */ - + /* * Function: globus_l_gass_transfer_http_listener_proto_destroy() * @@ -1401,7 +1401,7 @@ static void globus_l_gass_transfer_http_listener_proto_destroy( globus_gass_transfer_http_listener_proto_t * - proto) + proto) { globus_free(proto); } @@ -1419,10 +1419,10 @@ globus_l_gass_transfer_http_listener_proto_destroy( static void globus_l_gass_transfer_http_destroy( - globus_gass_transfer_request_proto_t * proto, - globus_gass_transfer_request_t request) + globus_gass_transfer_request_proto_t * proto, + globus_gass_transfer_request_t request) { - globus_gass_transfer_http_request_proto_t * new_proto; + globus_gass_transfer_http_request_proto_t * new_proto; MYNAME(globus_l_gass_transfer_http_destroy); debug_printf(1, (_GTSL("entering %s()\n"),myname)); @@ -1434,11 +1434,11 @@ globus_l_gass_transfer_http_destroy( new_proto->state == GLOBUS_GASS_TRANSFER_HTTP_STATE_RESPONDING || new_proto->state == GLOBUS_GASS_TRANSFER_HTTP_STATE_DENIED) { - new_proto->destroy_called=GLOBUS_TRUE; + new_proto->destroy_called=GLOBUS_TRUE; } else if(new_proto->state == GLOBUS_GASS_TRANSFER_HTTP_STATE_DONE) { - globus_l_gass_transfer_http_proto_destroy(new_proto); + globus_l_gass_transfer_http_proto_destroy(new_proto); } globus_l_gass_transfer_http_unlock(); debug_printf(1, (_GTSL("exiting %s()\n"),myname)); @@ -1457,8 +1457,8 @@ globus_l_gass_transfer_http_destroy( static void globus_l_gass_transfer_http_listener_destroy( - globus_gass_transfer_listener_proto_t * proto, - globus_gass_transfer_listener_t listener) + globus_gass_transfer_listener_proto_t * proto, + globus_gass_transfer_listener_t listener) { globus_gass_transfer_http_listener_proto_t *new_proto; MYNAME(globus_l_gass_transfer_http_listener_destroy); @@ -1469,11 +1469,11 @@ globus_l_gass_transfer_http_listener_destroy( globus_l_gass_transfer_http_lock(); if(new_proto->state != GLOBUS_GASS_TRANSFER_HTTP_LISTENER_CLOSED) { - new_proto->destroy_called=GLOBUS_TRUE; + new_proto->destroy_called=GLOBUS_TRUE; } else { - globus_l_gass_transfer_http_listener_proto_destroy(new_proto); + globus_l_gass_transfer_http_listener_proto_destroy(new_proto); } globus_l_gass_transfer_http_unlock(); debug_printf(1, (_GTSL("exiting %s()\n"),myname)); @@ -1492,11 +1492,11 @@ globus_l_gass_transfer_http_listener_destroy( static void globus_l_gass_transfer_http_listen( - globus_gass_transfer_listener_proto_t * proto, - globus_gass_transfer_listener_t listener) + globus_gass_transfer_listener_proto_t * proto, + globus_gass_transfer_listener_t listener) { globus_gass_transfer_http_listener_proto_t *new_proto; - globus_result_t result; + globus_result_t result; globus_reltime_t delay_time; MYNAME(globus_l_gass_transfer_http_listen); @@ -1506,28 +1506,28 @@ globus_l_gass_transfer_http_listen( globus_l_gass_transfer_http_lock(); debug_printf(4,(_GTSL("%s(): registering listen on %p\n"), - myname, - &new_proto->handle)); + myname, + &new_proto->handle)); result = globus_io_tcp_register_listen( - &new_proto->handle, - globus_l_gass_transfer_http_listen_callback, - (void *) new_proto); + &new_proto->handle, + globus_l_gass_transfer_http_listen_callback, + (void *) new_proto); if(result != GLOBUS_SUCCESS) { GlobusTimeReltimeSet(delay_time, 0, 0); - debug_printf(4,(_GTSL("%s(): registering oneshot because listen failed\n"), - myname)); - globus_callback_register_oneshot( - GLOBUS_NULL, - &delay_time, - globus_l_gass_transfer_http_callback_listen_callback, - (void *) new_proto); - + debug_printf(4,(_GTSL("%s(): registering oneshot because listen failed\n"), + myname)); + globus_callback_register_oneshot( + GLOBUS_NULL, + &delay_time, + globus_l_gass_transfer_http_callback_listen_callback, + (void *) new_proto); + } else { - new_proto->state = GLOBUS_GASS_TRANSFER_HTTP_LISTENER_LISTENING; + new_proto->state = GLOBUS_GASS_TRANSFER_HTTP_LISTENER_LISTENING; } globus_l_gass_transfer_http_unlock(); debug_printf(1, (_GTSL("exiting %s()\n"),myname)); @@ -1537,15 +1537,15 @@ globus_l_gass_transfer_http_listen( static void globus_l_gass_transfer_http_listen_callback( - void * callback_arg, - globus_io_handle_t * handle, - globus_result_t result) + void * callback_arg, + globus_io_handle_t * handle, + globus_result_t result) { globus_gass_transfer_http_listener_proto_t *proto; - globus_gass_transfer_listener_t listener; + globus_gass_transfer_listener_t listener; MYNAME(globus_l_gass_transfer_http_listen_callback); - - debug_printf(3, (_GTSL("Entering %s()\n"),myname)); + + debug_printf(3, (_GTSL("Entering %s()\n"),myname)); proto = (globus_gass_transfer_http_listener_proto_t *) callback_arg; globus_l_gass_transfer_http_lock(); @@ -1553,19 +1553,19 @@ globus_l_gass_transfer_http_listen_callback( switch(proto->state) { case GLOBUS_GASS_TRANSFER_HTTP_LISTENER_LISTENING: - proto->state = GLOBUS_GASS_TRANSFER_HTTP_LISTENER_READY; - break; + proto->state = GLOBUS_GASS_TRANSFER_HTTP_LISTENER_READY; + break; case GLOBUS_GASS_TRANSFER_HTTP_LISTENER_CLOSING1: case GLOBUS_GASS_TRANSFER_HTTP_LISTENER_CLOSED: - break; + break; case GLOBUS_GASS_TRANSFER_HTTP_LISTENER_STARTING: case GLOBUS_GASS_TRANSFER_HTTP_LISTENER_ACCEPTING: case GLOBUS_GASS_TRANSFER_HTTP_LISTENER_READY: case GLOBUS_GASS_TRANSFER_HTTP_LISTENER_CLOSING2: - globus_assert(proto->state != GLOBUS_GASS_TRANSFER_HTTP_LISTENER_STARTING); - globus_assert(proto->state != GLOBUS_GASS_TRANSFER_HTTP_LISTENER_ACCEPTING); - globus_assert(proto->state != GLOBUS_GASS_TRANSFER_HTTP_LISTENER_READY); - globus_assert(proto->state != GLOBUS_GASS_TRANSFER_HTTP_LISTENER_CLOSING2); + globus_assert(proto->state != GLOBUS_GASS_TRANSFER_HTTP_LISTENER_STARTING); + globus_assert(proto->state != GLOBUS_GASS_TRANSFER_HTTP_LISTENER_ACCEPTING); + globus_assert(proto->state != GLOBUS_GASS_TRANSFER_HTTP_LISTENER_READY); + globus_assert(proto->state != GLOBUS_GASS_TRANSFER_HTTP_LISTENER_CLOSING2); } listener = proto->listener; @@ -1580,13 +1580,13 @@ globus_l_gass_transfer_http_listen_callback( static void globus_l_gass_transfer_http_accept_callback( - void * callback_arg, - globus_io_handle_t * handle, - globus_result_t result) + void * callback_arg, + globus_io_handle_t * handle, + globus_result_t result) { globus_gass_transfer_http_listener_proto_t *l; MYNAME(globus_l_gass_transfer_http_accept_callback); - + debug_printf(3, (_GTSL("Entering %s()\n"),myname)); globus_l_gass_transfer_http_lock(); @@ -1597,84 +1597,82 @@ globus_l_gass_transfer_http_accept_callback( switch(l->state) { case GLOBUS_GASS_TRANSFER_HTTP_LISTENER_ACCEPTING: - l->request->response_buffer = globus_malloc(GLOBUS_L_GASS_RESPONSE_LEN * - sizeof(globus_byte_t)); - l->request->response_buflen = GLOBUS_L_GASS_RESPONSE_LEN; - l->request->response_offset = 0; - l->request->parsed_offset = 0; - - if(result != GLOBUS_SUCCESS) - { - globus_l_gass_transfer_http_unlock(); - globus_l_gass_transfer_http_request_callback( - l, - &l->request->handle, - result, - l->request->response_buffer, - 0); - debug_printf(3, (_GTSL("Exiting globus_l_gass_transfer_http_accept_callback()\n"))); - return; - } - else - { + l->request->response_buffer = globus_malloc(GLOBUS_L_GASS_RESPONSE_LEN * + sizeof(globus_byte_t)); + l->request->response_buflen = GLOBUS_L_GASS_RESPONSE_LEN; + l->request->response_offset = 0; + l->request->parsed_offset = 0; + + if(result != GLOBUS_SUCCESS) + { + globus_l_gass_transfer_http_unlock(); + globus_l_gass_transfer_http_request_callback( + l, + &l->request->handle, + result, + l->request->response_buffer, + 0); + debug_printf(3, (_GTSL("Exiting globus_l_gass_transfer_http_accept_callback()\n"))); + return; + } + else + { debug_printf(4, (_GTSL("%s(): Registering read on %p\n"), - myname, - &l->request->handle)); - globus_io_register_read(&l->request->handle, - l->request->response_buffer, - l->request->response_buflen, - 1, - globus_l_gass_transfer_http_request_callback, - l); - } - break; + myname, + &l->request->handle)); + globus_io_register_read(&l->request->handle, + l->request->response_buffer, + l->request->response_buflen, + 1, + globus_l_gass_transfer_http_request_callback, + l); + } + break; case GLOBUS_GASS_TRANSFER_HTTP_LISTENER_CLOSING2: case GLOBUS_GASS_TRANSFER_HTTP_LISTENER_CLOSED: - globus_l_gass_transfer_http_unlock(); - globus_gass_transfer_proto_new_listener_request(l->listener, - l->request->request, - GLOBUS_NULL); - globus_l_gass_transfer_http_lock(); - /* should destroy the proto->request here? */ - break; + globus_l_gass_transfer_http_unlock(); + globus_gass_transfer_proto_new_listener_request(l->listener, + l->request->request, + GLOBUS_NULL); + globus_l_gass_transfer_http_lock(); + /* should destroy the proto->request here? */ + break; case GLOBUS_GASS_TRANSFER_HTTP_LISTENER_STARTING: case GLOBUS_GASS_TRANSFER_HTTP_LISTENER_LISTENING: case GLOBUS_GASS_TRANSFER_HTTP_LISTENER_READY: case GLOBUS_GASS_TRANSFER_HTTP_LISTENER_CLOSING1: - globus_assert(l->state != GLOBUS_GASS_TRANSFER_HTTP_LISTENER_STARTING); - globus_assert(l->state != GLOBUS_GASS_TRANSFER_HTTP_LISTENER_LISTENING); - globus_assert(l->state != GLOBUS_GASS_TRANSFER_HTTP_LISTENER_READY); - globus_assert(l->state != GLOBUS_GASS_TRANSFER_HTTP_LISTENER_CLOSING1); + globus_assert(l->state != GLOBUS_GASS_TRANSFER_HTTP_LISTENER_STARTING); + globus_assert(l->state != GLOBUS_GASS_TRANSFER_HTTP_LISTENER_LISTENING); + globus_assert(l->state != GLOBUS_GASS_TRANSFER_HTTP_LISTENER_READY); + globus_assert(l->state != GLOBUS_GASS_TRANSFER_HTTP_LISTENER_CLOSING1); } globus_l_gass_transfer_http_unlock(); - debug_printf(3, (_GTSL("Exiting %s()\n"), myname)); + debug_printf(3, (_GTSL("Exiting %s()\n"), myname)); } /* globus_l_gass_transfer_http_accept_callback() */ static void globus_l_gass_transfer_http_request_refer( - globus_gass_transfer_request_proto_t * rproto, - globus_gass_transfer_request_t request) + globus_gass_transfer_request_proto_t * rproto, + globus_gass_transfer_request_t request) { - globus_gass_transfer_http_request_proto_t * proto; - globus_gass_transfer_referral_t referral; - int rc; - char * referral_string; - globus_size_t referral_count; - globus_size_t body_count=0; /* :) */ - globus_size_t offset; - globus_size_t x; - globus_size_t i; - globus_size_t digits = 0; + globus_gass_transfer_http_request_proto_t * proto; + globus_gass_transfer_referral_t referral; + char * referral_string; + globus_size_t referral_count; + globus_size_t body_count=0; /* :) */ + globus_size_t offset; + globus_size_t x; + globus_size_t i; + globus_size_t digits = 0; MYNAME(globus_l_gass_transfer_http_request_refer); - + globus_l_gass_transfer_http_lock(); proto = (globus_gass_transfer_http_request_proto_t *) rproto; - rc = globus_gass_transfer_request_get_referral(request, - &referral); + globus_gass_transfer_request_get_referral(request, &referral); /* HTTP/1.1 302 Document Moved CRLF * Location: referral.url[0] CRLF @@ -1701,17 +1699,17 @@ globus_l_gass_transfer_http_request_refer( body_count += strlen(GLOBUS_L_HTML_REFERRAL_BODY_TAIL); for(i = 0 ; i < referral.count; i++) { - body_count += strlen(GLOBUS_L_HTML_HREF); - body_count += strlen(referral.url[i]); - body_count += strlen(referral.url[i]); + body_count += strlen(GLOBUS_L_HTML_HREF); + body_count += strlen(referral.url[i]); + body_count += strlen(referral.url[i]); } /* count the number of decimal digits in the body */ x=body_count; do { - digits++; - x /= 10; + digits++; + x /= 10; } while(x > 0); referral_count += digits; @@ -1719,43 +1717,43 @@ globus_l_gass_transfer_http_request_refer( referral_string = globus_malloc(referral_count + body_count); offset = sprintf(referral_string, - GLOBUS_L_REFER_RESPONSE); + GLOBUS_L_REFER_RESPONSE); offset += sprintf(referral_string + offset, - GLOBUS_L_LOCATION_HEADER, - referral.url[0]); + GLOBUS_L_LOCATION_HEADER, + referral.url[0]); offset += sprintf(referral_string + offset, - GLOBUS_L_HTML_HEADER); + GLOBUS_L_HTML_HEADER); offset += sprintf(referral_string + offset, - GLOBUS_L_CONTENT_LENGTH_HEADER, - body_count); + GLOBUS_L_CONTENT_LENGTH_HEADER, + body_count); offset += sprintf(referral_string + offset, - CRLF); + CRLF); offset += sprintf(referral_string + offset, - GLOBUS_L_HTML_REFERRAL_BODY_HEAD); + GLOBUS_L_HTML_REFERRAL_BODY_HEAD); for(i = 0 ; i < referral.count; i++) { - offset += sprintf(referral_string + offset, - GLOBUS_L_HTML_HREF, - referral.url[i], - referral.url[i]); + offset += sprintf(referral_string + offset, + GLOBUS_L_HTML_HREF, + referral.url[i], + referral.url[i]); } offset += sprintf(referral_string + offset, - GLOBUS_L_HTML_REFERRAL_BODY_TAIL); + GLOBUS_L_HTML_REFERRAL_BODY_TAIL); proto->state = GLOBUS_GASS_TRANSFER_HTTP_STATE_REFERRED; globus_gass_transfer_referral_destroy(&referral); debug_printf(4, (_GTSL("%s(): Registering write on %p\n"), - myname, - &proto->handle)); + myname, + &proto->handle)); globus_io_register_write(&proto->handle, - (globus_byte_t *) referral_string, - strlen(referral_string), - globus_l_gass_transfer_http_write_response, - proto); + (globus_byte_t *) referral_string, + strlen(referral_string), + globus_l_gass_transfer_http_write_response, + proto); globus_l_gass_transfer_http_unlock(); } @@ -1764,20 +1762,20 @@ globus_l_gass_transfer_http_request_refer( static void globus_l_gass_transfer_http_request_deny( - globus_gass_transfer_request_proto_t * rproto, - globus_gass_transfer_request_t request) + globus_gass_transfer_request_proto_t * rproto, + globus_gass_transfer_request_t request) { - globus_gass_transfer_http_request_proto_t * proto; - char * deny_string; - globus_size_t deny_count; - globus_size_t body_count=0; /* :) */ - globus_size_t offset; - globus_size_t x; - globus_size_t digits = 0; - int reason; - char * message; + globus_gass_transfer_http_request_proto_t * proto; + char * deny_string; + globus_size_t deny_count; + globus_size_t body_count=0; /* :) */ + globus_size_t offset; + globus_size_t x; + globus_size_t digits = 0; + int reason; + char * message; MYNAME(globus_l_gass_transfer_http_request_deny); - + globus_l_gass_transfer_http_lock(); proto = (globus_gass_transfer_http_request_proto_t *) rproto; @@ -1786,16 +1784,16 @@ globus_l_gass_transfer_http_request_deny( if(reason < 400 || reason >= 600) { - reason = 500; - message = globus_libc_strdup(GLOBUS_L_DEFAULT_DENIAL_MESSAGE); + reason = 500; + message = globus_libc_strdup(GLOBUS_L_DEFAULT_DENIAL_MESSAGE); } else { - message = globus_gass_transfer_request_get_denial_message(request); - if(message == GLOBUS_NULL) - { - message = globus_libc_strdup(GLOBUS_L_DEFAULT_DENIAL_MESSAGE); - } + message = globus_gass_transfer_request_get_denial_message(request); + if(message == GLOBUS_NULL) + { + message = globus_libc_strdup(GLOBUS_L_DEFAULT_DENIAL_MESSAGE); + } } /* HTTP/1.1 %d %s CRLF @@ -1822,8 +1820,8 @@ globus_l_gass_transfer_http_request_deny( x=body_count; do { - digits++; - x /= 10; + digits++; + x /= 10; } while(x > 0); deny_count += digits; @@ -1831,36 +1829,36 @@ globus_l_gass_transfer_http_request_deny( deny_string = globus_malloc(deny_count + body_count); offset = sprintf(deny_string, - GLOBUS_L_DENIAL_RESPONSE, - reason, - message); + GLOBUS_L_DENIAL_RESPONSE, + reason, + message); offset += sprintf(deny_string + offset, - GLOBUS_L_HTML_HEADER); + GLOBUS_L_HTML_HEADER); offset += sprintf(deny_string + offset, - GLOBUS_L_CONTENT_LENGTH_HEADER, - body_count); + GLOBUS_L_CONTENT_LENGTH_HEADER, + body_count); offset += sprintf(deny_string + offset, - CRLF); + CRLF); offset += sprintf(deny_string + offset, - GLOBUS_L_HTML_DENIAL_BODY, - reason, - message, - reason, - message); + GLOBUS_L_HTML_DENIAL_BODY, + reason, + message, + reason, + message); proto->state = GLOBUS_GASS_TRANSFER_HTTP_STATE_DENIED; globus_free(message); debug_printf(4, (_GTSL("%s(): Registering write on %p\n"), - myname, - &proto->handle)); + myname, + &proto->handle)); globus_io_register_write(&proto->handle, - (globus_byte_t *) deny_string, - strlen(deny_string), - globus_l_gass_transfer_http_write_response, - proto); + (globus_byte_t *) deny_string, + strlen(deny_string), + globus_l_gass_transfer_http_write_response, + proto); globus_l_gass_transfer_http_unlock(); } @@ -1869,117 +1867,117 @@ globus_l_gass_transfer_http_request_deny( static void globus_l_gass_transfer_http_request_authorize( - globus_gass_transfer_request_proto_t * rproto, - globus_gass_transfer_request_t request) + globus_gass_transfer_request_proto_t * rproto, + globus_gass_transfer_request_t request) { - globus_gass_transfer_http_request_proto_t * proto; - char * authorize_string; - globus_size_t authorize_count=0; - globus_size_t offset; - globus_size_t length; + globus_gass_transfer_http_request_proto_t * proto; + char * authorize_string; + globus_size_t authorize_count=0; + globus_size_t offset; + globus_size_t length; globus_reltime_t delay_time; MYNAME(globus_l_gass_transfer_http_request_authorize); - + globus_l_gass_transfer_http_lock(); proto = (globus_gass_transfer_http_request_proto_t *) rproto; switch(proto->type) { case GLOBUS_GASS_TRANSFER_REQUEST_TYPE_GET: - /* Let's always send an HTTP/1.0 response, to make things easier */ - length = globus_gass_transfer_request_get_length(proto->request); - - if(length != 0) - { - globus_size_t x = length; - globus_size_t digits = 0; - - /* count the number of decimal digits in length */ - do - { - digits++; - x /= 10; - } while(x > 0); - - /* Send a content-length field */ - authorize_count += strlen(GLOBUS_L_CONTENT_LENGTH_HEADER); - authorize_count += digits; - } - - authorize_count += 1; - authorize_count += strlen(GLOBUS_L_GENERIC_RESPONSE); - authorize_count += 3; - authorize_count += strlen(GLOBUS_L_OK); - authorize_count += 2; - - if(proto->text_mode) - { - authorize_count += strlen(GLOBUS_L_TEXT_HEADER); - authorize_string = globus_malloc(authorize_count); - offset = sprintf(authorize_string, - GLOBUS_L_GENERIC_RESPONSE, - 0, - 200, - GLOBUS_L_OK); - offset += sprintf(authorize_string + offset, - GLOBUS_L_TEXT_HEADER); - } - else - { - authorize_count += strlen(GLOBUS_L_BINARY_HEADER); - authorize_string = globus_malloc(authorize_count); - offset = sprintf(authorize_string, - GLOBUS_L_GENERIC_RESPONSE, - 0, - 200, - GLOBUS_L_OK); - offset += sprintf(authorize_string + offset, - GLOBUS_L_BINARY_HEADER); - } - - if(length != 0) - { - offset += sprintf(authorize_string + offset, - GLOBUS_L_CONTENT_LENGTH_HEADER, - length); - } - offset += sprintf(authorize_string + offset, - CRLF); - break; + /* Let's always send an HTTP/1.0 response, to make things easier */ + length = globus_gass_transfer_request_get_length(proto->request); + + if(length != 0) + { + globus_size_t x = length; + globus_size_t digits = 0; + + /* count the number of decimal digits in length */ + do + { + digits++; + x /= 10; + } while(x > 0); + + /* Send a content-length field */ + authorize_count += strlen(GLOBUS_L_CONTENT_LENGTH_HEADER); + authorize_count += digits; + } + + authorize_count += 1; + authorize_count += strlen(GLOBUS_L_GENERIC_RESPONSE); + authorize_count += 3; + authorize_count += strlen(GLOBUS_L_OK); + authorize_count += 2; + + if(proto->text_mode) + { + authorize_count += strlen(GLOBUS_L_TEXT_HEADER); + authorize_string = globus_malloc(authorize_count); + offset = sprintf(authorize_string, + GLOBUS_L_GENERIC_RESPONSE, + 0, + 200, + GLOBUS_L_OK); + offset += sprintf(authorize_string + offset, + GLOBUS_L_TEXT_HEADER); + } + else + { + authorize_count += strlen(GLOBUS_L_BINARY_HEADER); + authorize_string = globus_malloc(authorize_count); + offset = sprintf(authorize_string, + GLOBUS_L_GENERIC_RESPONSE, + 0, + 200, + GLOBUS_L_OK); + offset += sprintf(authorize_string + offset, + GLOBUS_L_BINARY_HEADER); + } + + if(length != 0) + { + offset += sprintf(authorize_string + offset, + GLOBUS_L_CONTENT_LENGTH_HEADER, + length); + } + offset += sprintf(authorize_string + offset, + CRLF); + break; case GLOBUS_GASS_TRANSFER_REQUEST_TYPE_PUT: case GLOBUS_GASS_TRANSFER_REQUEST_TYPE_APPEND: - /* send nothing back yet */ - break; + /* send nothing back yet */ + break; default: - globus_assert(GLOBUS_FALSE); + globus_assert(GLOBUS_FALSE); } if(authorize_count != 0) { - proto->state = GLOBUS_GASS_TRANSFER_HTTP_STATE_RESPONDING; + proto->state = GLOBUS_GASS_TRANSFER_HTTP_STATE_RESPONDING; - debug_printf(4, (_GTSL("%s(): registering write on %p\n"), - myname, - &proto->handle)); + debug_printf(4, (_GTSL("%s(): registering write on %p\n"), + myname, + &proto->handle)); - globus_io_register_write(&proto->handle, - (globus_byte_t *) authorize_string, - strlen(authorize_string), - globus_l_gass_transfer_http_write_response, - proto); + globus_io_register_write(&proto->handle, + (globus_byte_t *) authorize_string, + strlen(authorize_string), + globus_l_gass_transfer_http_write_response, + proto); } else { - proto->state = GLOBUS_GASS_TRANSFER_HTTP_STATE_IDLE; - + proto->state = GLOBUS_GASS_TRANSFER_HTTP_STATE_IDLE; + GlobusTimeReltimeSet(delay_time, 0, 0); - debug_printf(4, (_GTSL("%s(): registering oneshot\n"), - myname)); - globus_callback_register_oneshot( - GLOBUS_NULL, - &delay_time, - globus_l_gass_transfer_http_callback_ready_callback, - (void *) proto); + debug_printf(4, (_GTSL("%s(): registering oneshot\n"), + myname)); + globus_callback_register_oneshot( + GLOBUS_NULL, + &delay_time, + globus_l_gass_transfer_http_callback_ready_callback, + (void *) proto); } @@ -1990,14 +1988,14 @@ globus_l_gass_transfer_http_request_authorize( static void globus_l_gass_transfer_http_write_response( - void * arg, - globus_io_handle_t * handle, - globus_result_t result, - globus_byte_t * buf, - globus_size_t nbytes) + void * arg, + globus_io_handle_t * handle, + globus_result_t result, + globus_byte_t * buf, + globus_size_t nbytes) { globus_gass_transfer_http_request_proto_t * proto; - globus_gass_transfer_request_t request; + globus_gass_transfer_request_t request; globus_free(buf); @@ -2008,28 +2006,28 @@ globus_l_gass_transfer_http_write_response( switch(proto->state) { case GLOBUS_GASS_TRANSFER_HTTP_STATE_RESPONDING: - if(proto->type == GLOBUS_GASS_TRANSFER_REQUEST_TYPE_GET) - { - proto->state = GLOBUS_GASS_TRANSFER_HTTP_STATE_IDLE; - globus_l_gass_transfer_http_unlock(); - - request = proto->request; - - debug_printf(2, (_GTSL("calling globus_gass_transfer_proto_request_ready"))); - globus_gass_transfer_proto_request_ready(request, - (globus_gass_transfer_request_proto_t *) proto); - return; - } - /* other types fall through */ + if(proto->type == GLOBUS_GASS_TRANSFER_REQUEST_TYPE_GET) + { + proto->state = GLOBUS_GASS_TRANSFER_HTTP_STATE_IDLE; + globus_l_gass_transfer_http_unlock(); + + request = proto->request; + + debug_printf(2, (_GTSL("calling globus_gass_transfer_proto_request_ready"))); + globus_gass_transfer_proto_request_ready(request, + (globus_gass_transfer_request_proto_t *) proto); + return; + } + /* other types fall through */ default: - result = globus_l_gass_transfer_http_register_close(proto); + result = globus_l_gass_transfer_http_register_close(proto); if (result != GLOBUS_SUCCESS) { globus_l_gass_transfer_http_close(proto); } - globus_l_gass_transfer_http_unlock(); - return; + globus_l_gass_transfer_http_unlock(); + return; } } /* globus_l_gass_transfer_http_write_response() */ @@ -2037,14 +2035,14 @@ globus_l_gass_transfer_http_write_response( static globus_bool_t globus_l_gass_transfer_http_authorization_callback( - void * arg, - globus_io_handle_t * handle, - globus_result_t result, - char * identity, - gss_ctx_id_t context_handle) + void * arg, + globus_io_handle_t * handle, + globus_result_t result, + char * identity, + gss_ctx_id_t context_handle) { globus_gass_transfer_http_listener_proto_t *proto; - int rc = GLOBUS_FALSE; + int rc = GLOBUS_FALSE; MYNAME(globus_l_gass_transfer_http_authorization_callback); debug_printf(3, (_GTSL("Entering %s()\n"),myname)); @@ -2056,33 +2054,33 @@ globus_l_gass_transfer_http_authorization_callback( switch(proto->request->authorization_mode) { case GLOBUS_GASS_TRANSFER_AUTHORIZE_SELF: - if(strcmp(identity, globus_l_gass_transfer_http_subject_name) == 0) - { - rc = GLOBUS_TRUE; - goto finish; - } - else - { - rc = GLOBUS_FALSE; - goto finish; - } + if(strcmp(identity, globus_l_gass_transfer_http_subject_name) == 0) + { + rc = GLOBUS_TRUE; + goto finish; + } + else + { + rc = GLOBUS_FALSE; + goto finish; + } case GLOBUS_GASS_TRANSFER_AUTHORIZE_HOST: - rc = GLOBUS_FALSE; - goto finish; + rc = GLOBUS_FALSE; + goto finish; case GLOBUS_GASS_TRANSFER_AUTHORIZE_SUBJECT: - if(strcmp(identity, proto->request->authorized_subject) == 0) - { - rc = GLOBUS_TRUE; - goto finish; - } - else - { - rc = GLOBUS_FALSE; - goto finish; - } + if(strcmp(identity, proto->request->authorized_subject) == 0) + { + rc = GLOBUS_TRUE; + goto finish; + } + else + { + rc = GLOBUS_FALSE; + goto finish; + } case GLOBUS_GASS_TRANSFER_AUTHORIZE_CALLBACK: - rc = GLOBUS_TRUE; - goto finish; + rc = GLOBUS_TRUE; + goto finish; } finish: @@ -2096,15 +2094,15 @@ globus_l_gass_transfer_http_authorization_callback( static void globus_l_gass_transfer_http_proto_destroy( - globus_gass_transfer_http_request_proto_t * proto) + globus_gass_transfer_http_request_proto_t * proto) { if(proto->response_buffer != GLOBUS_NULL) { - globus_free(proto->response_buffer); + globus_free(proto->response_buffer); } if(proto->reason != GLOBUS_NULL) { - globus_free(proto->reason); + globus_free(proto->reason); } if(proto->connected_subject != GLOBUS_NULL) { @@ -2112,21 +2110,21 @@ globus_l_gass_transfer_http_proto_destroy( } if(proto->client_side) { - globus_url_destroy(&proto->url); + globus_url_destroy(&proto->url); } else { - if(proto->method) - { - globus_free(proto->method); - } - if(proto->uri) - { - globus_free(proto->uri); - } + if(proto->method) + { + globus_free(proto->method); + } + if(proto->uri) + { + globus_free(proto->uri); + } } globus_i_gass_transfer_keyvalue_destroy( - &proto->headers); + &proto->headers); globus_free(proto); } /* globus_l_gass_transfer_http_proto_destroy() */ @@ -2143,266 +2141,266 @@ globus_l_gass_transfer_http_proto_destroy( static void globus_l_gass_transfer_http_new_request( - globus_gass_transfer_request_t request, - globus_gass_transfer_requestattr_t * attr) + globus_gass_transfer_request_t request, + globus_gass_transfer_requestattr_t * attr) { - int rc=GLOBUS_SUCCESS; - char * proxy=GLOBUS_NULL; - globus_gass_transfer_file_mode_t file_mode=GLOBUS_GASS_TRANSFER_FILE_MODE_BINARY; - globus_io_attr_t tcp_attr; - globus_result_t result; - globus_gass_transfer_http_request_proto_t * proto; - int sndbuf; - int rcvbuf; - int nodelay; + int rc=GLOBUS_SUCCESS; + char * proxy=GLOBUS_NULL; + globus_gass_transfer_file_mode_t file_mode=GLOBUS_GASS_TRANSFER_FILE_MODE_BINARY; + globus_io_attr_t tcp_attr; + globus_result_t result; + globus_gass_transfer_http_request_proto_t * proto; + int sndbuf; + int rcvbuf; + int nodelay; globus_reltime_t delay_time; MYNAME(globus_l_gass_transfer_http_new_request); - + debug_printf(1, (_GTSL("Entering %s()\n"),myname)); switch(globus_gass_transfer_request_get_type(request)) { case GLOBUS_GASS_TRANSFER_REQUEST_TYPE_GET: case GLOBUS_GASS_TRANSFER_REQUEST_TYPE_PUT: case GLOBUS_GASS_TRANSFER_REQUEST_TYPE_APPEND: - break; + break; default: - goto error_exit; + goto error_exit; } /* Allocate proto instance */ - proto = (globus_gass_transfer_http_request_proto_t *) - globus_malloc(sizeof(globus_gass_transfer_http_request_proto_t)); + proto = (globus_gass_transfer_http_request_proto_t *) + globus_malloc(sizeof(globus_gass_transfer_http_request_proto_t)); if(proto == GLOBUS_NULL) { - goto error_exit; + goto error_exit; } result = globus_io_tcpattr_init(&tcp_attr); if(result != GLOBUS_SUCCESS) { - goto proto_error; + goto proto_error; } globus_io_attr_set_socket_keepalive(&tcp_attr, GLOBUS_TRUE); if(*attr != GLOBUS_NULL) { - /* Check attributes we care about */ - globus_gass_transfer_requestattr_get_proxy_url(attr, - &proxy); - - rc = globus_gass_transfer_requestattr_get_socket_sndbuf( - attr, - &sndbuf); - if(rc != GLOBUS_SUCCESS) - { - goto tcpattr_error; - } - else - { - if(sndbuf != 0) - { - globus_io_attr_set_socket_sndbuf(&tcp_attr, - sndbuf); - } - } - - rc = globus_gass_transfer_requestattr_get_socket_rcvbuf( - attr, - &rcvbuf); - if(rc != GLOBUS_SUCCESS) - { - goto tcpattr_error; - } - else - { - if(rcvbuf != 0) - { - globus_io_attr_set_socket_rcvbuf(&tcp_attr, - rcvbuf); - } - } - - rc = globus_gass_transfer_requestattr_get_socket_nodelay( - attr, - &nodelay); - if(rc != GLOBUS_SUCCESS) - { - goto tcpattr_error; - } - else - { - globus_io_attr_set_tcp_nodelay(&tcp_attr, - nodelay); - } - - /* File mode is important on Windows */ - rc = globus_gass_transfer_requestattr_get_file_mode(attr, - &file_mode); - if(rc != GLOBUS_SUCCESS) - { - goto tcpattr_error; - } - rc = globus_gass_transfer_requestattr_get_block_size(attr, - &proto->block_size); - if(rc != GLOBUS_SUCCESS) - { - goto tcpattr_error; - } + /* Check attributes we care about */ + globus_gass_transfer_requestattr_get_proxy_url(attr, + &proxy); + + rc = globus_gass_transfer_requestattr_get_socket_sndbuf( + attr, + &sndbuf); + if(rc != GLOBUS_SUCCESS) + { + goto tcpattr_error; + } + else + { + if(sndbuf != 0) + { + globus_io_attr_set_socket_sndbuf(&tcp_attr, + sndbuf); + } + } + + rc = globus_gass_transfer_requestattr_get_socket_rcvbuf( + attr, + &rcvbuf); + if(rc != GLOBUS_SUCCESS) + { + goto tcpattr_error; + } + else + { + if(rcvbuf != 0) + { + globus_io_attr_set_socket_rcvbuf(&tcp_attr, + rcvbuf); + } + } + + rc = globus_gass_transfer_requestattr_get_socket_nodelay( + attr, + &nodelay); + if(rc != GLOBUS_SUCCESS) + { + goto tcpattr_error; + } + else + { + globus_io_attr_set_tcp_nodelay(&tcp_attr, + nodelay); + } + + /* File mode is important on Windows */ + rc = globus_gass_transfer_requestattr_get_file_mode(attr, + &file_mode); + if(rc != GLOBUS_SUCCESS) + { + goto tcpattr_error; + } + rc = globus_gass_transfer_requestattr_get_block_size(attr, + &proto->block_size); + if(rc != GLOBUS_SUCCESS) + { + goto tcpattr_error; + } } /* Verify URL */ if(proxy) { - rc = globus_url_parse(proxy, - &proto->proxy_url); - if(rc != GLOBUS_SUCCESS) - { - goto tcpattr_error; - } - if(strcmp(proto->proxy_url.scheme, "http") != 0 && - strcmp(proto->proxy_url.scheme, "https") != 0) - { - goto proxy_error; - } + rc = globus_url_parse(proxy, + &proto->proxy_url); + if(rc != GLOBUS_SUCCESS) + { + goto tcpattr_error; + } + if(strcmp(proto->proxy_url.scheme, "http") != 0 && + strcmp(proto->proxy_url.scheme, "https") != 0) + { + goto proxy_error; + } } proto->url_string = globus_gass_transfer_request_get_url(request); rc = globus_url_parse(proto->url_string, - &proto->url); + &proto->url); if(rc != GLOBUS_SUCCESS) { - goto proxy_error; + goto proxy_error; } if(proto->url.url_path == GLOBUS_NULL) { - proto->url.url_path = globus_libc_strdup("/"); + proto->url.url_path = globus_libc_strdup("/"); } if(strcmp(proto->url.scheme, "http") != 0 && strcmp(proto->url.scheme, "https") != 0) { - goto url_error; + goto url_error; } /* If https, set security attributes of TCP handle */ if(strcmp(proto->url.scheme, "https")== 0) { - globus_io_secure_authorization_data_t data; - globus_gass_transfer_authorization_t mode; - char * subject; - globus_result_t result; - - - globus_io_secure_authorization_data_initialize(&data); - result = globus_io_attr_set_secure_authentication_mode( - &tcp_attr, - GLOBUS_IO_SECURE_AUTHENTICATION_MODE_MUTUAL, - GLOBUS_NULL); - - if(result != GLOBUS_SUCCESS) - { - goto url_error; - } - result = globus_io_attr_set_secure_channel_mode( - &tcp_attr, - GLOBUS_IO_SECURE_CHANNEL_MODE_SSL_WRAP); - if(result != GLOBUS_SUCCESS) - { - goto url_error; - } - if(*attr != GLOBUS_NULL) - { - rc = globus_gass_transfer_secure_requestattr_get_authorization( - attr, - &mode, - &subject); - if(rc != GLOBUS_SUCCESS) - { - goto url_error; - } - } - else - { - mode = GLOBUS_GASS_TRANSFER_AUTHORIZE_SELF; - } - - switch(mode) - { - case GLOBUS_GASS_TRANSFER_AUTHORIZE_SELF: - globus_io_attr_set_secure_authorization_mode( - &tcp_attr, - GLOBUS_IO_SECURE_AUTHORIZATION_MODE_SELF, - GLOBUS_NULL); - break; - case GLOBUS_GASS_TRANSFER_AUTHORIZE_HOST: - subject = globus_malloc(strlen(proto->url.host) + - strlen("/CN=") - +1); - sprintf(subject, - "/CN=%s", - proto->url.host); - - globus_io_secure_authorization_data_set_identity( - &data, - subject); - globus_io_attr_set_secure_authorization_mode( - &tcp_attr, - GLOBUS_IO_SECURE_AUTHORIZATION_MODE_IDENTITY, - &data); - globus_io_secure_authorization_data_destroy(&data); - globus_free(subject); - break; - case GLOBUS_GASS_TRANSFER_AUTHORIZE_SUBJECT: - globus_io_secure_authorization_data_set_identity( - &data, - subject); - globus_io_attr_set_secure_authorization_mode( - &tcp_attr, - GLOBUS_IO_SECURE_AUTHORIZATION_MODE_IDENTITY, - &data); - globus_io_secure_authorization_data_destroy(&data); - break; - case GLOBUS_GASS_TRANSFER_AUTHORIZE_CALLBACK: - globus_assert(mode != GLOBUS_GASS_TRANSFER_AUTHORIZE_CALLBACK); - goto url_error; - } + globus_io_secure_authorization_data_t data; + globus_gass_transfer_authorization_t mode; + char * subject; + globus_result_t result; + + + globus_io_secure_authorization_data_initialize(&data); + result = globus_io_attr_set_secure_authentication_mode( + &tcp_attr, + GLOBUS_IO_SECURE_AUTHENTICATION_MODE_MUTUAL, + GLOBUS_NULL); + + if(result != GLOBUS_SUCCESS) + { + goto url_error; + } + result = globus_io_attr_set_secure_channel_mode( + &tcp_attr, + GLOBUS_IO_SECURE_CHANNEL_MODE_SSL_WRAP); + if(result != GLOBUS_SUCCESS) + { + goto url_error; + } + if(*attr != GLOBUS_NULL) + { + rc = globus_gass_transfer_secure_requestattr_get_authorization( + attr, + &mode, + &subject); + if(rc != GLOBUS_SUCCESS) + { + goto url_error; + } + } + else + { + mode = GLOBUS_GASS_TRANSFER_AUTHORIZE_SELF; + } + + switch(mode) + { + case GLOBUS_GASS_TRANSFER_AUTHORIZE_SELF: + globus_io_attr_set_secure_authorization_mode( + &tcp_attr, + GLOBUS_IO_SECURE_AUTHORIZATION_MODE_SELF, + GLOBUS_NULL); + break; + case GLOBUS_GASS_TRANSFER_AUTHORIZE_HOST: + subject = globus_malloc(strlen(proto->url.host) + + strlen("/CN=") + +1); + sprintf(subject, + "/CN=%s", + proto->url.host); + + globus_io_secure_authorization_data_set_identity( + &data, + subject); + globus_io_attr_set_secure_authorization_mode( + &tcp_attr, + GLOBUS_IO_SECURE_AUTHORIZATION_MODE_IDENTITY, + &data); + globus_io_secure_authorization_data_destroy(&data); + globus_free(subject); + break; + case GLOBUS_GASS_TRANSFER_AUTHORIZE_SUBJECT: + globus_io_secure_authorization_data_set_identity( + &data, + subject); + globus_io_attr_set_secure_authorization_mode( + &tcp_attr, + GLOBUS_IO_SECURE_AUTHORIZATION_MODE_IDENTITY, + &data); + globus_io_secure_authorization_data_destroy(&data); + break; + case GLOBUS_GASS_TRANSFER_AUTHORIZE_CALLBACK: + globus_assert(mode != GLOBUS_GASS_TRANSFER_AUTHORIZE_CALLBACK); + goto url_error; + } } if(proto == GLOBUS_NULL) { - goto url_error; + goto url_error; } /* Initialize the proto instance */ - proto->send_buffer = globus_l_gass_transfer_http_send; - proto->recv_buffer = globus_l_gass_transfer_http_receive; - proto->fail = globus_l_gass_transfer_http_fail; - proto->deny = GLOBUS_NULL; - proto->refer = GLOBUS_NULL; - proto->authorize = GLOBUS_NULL; - proto->destroy = globus_l_gass_transfer_http_destroy; - proto->text_mode = (file_mode == GLOBUS_GASS_TRANSFER_FILE_MODE_TEXT); - proto->line_mode = GLOBUS_L_LINE_MODE_UNKNOWN; - proto->state = GLOBUS_GASS_TRANSFER_HTTP_STATE_CONNECTING; - proto->request = request; - proto->type = globus_gass_transfer_request_get_type(request); - proto->code = 0; - proto->reason = 0; - proto->parse_error = GLOBUS_FALSE; + proto->send_buffer = globus_l_gass_transfer_http_send; + proto->recv_buffer = globus_l_gass_transfer_http_receive; + proto->fail = globus_l_gass_transfer_http_fail; + proto->deny = GLOBUS_NULL; + proto->refer = GLOBUS_NULL; + proto->authorize = GLOBUS_NULL; + proto->destroy = globus_l_gass_transfer_http_destroy; + proto->text_mode = (file_mode == GLOBUS_GASS_TRANSFER_FILE_MODE_TEXT); + proto->line_mode = GLOBUS_L_LINE_MODE_UNKNOWN; + proto->state = GLOBUS_GASS_TRANSFER_HTTP_STATE_CONNECTING; + proto->request = request; + proto->type = globus_gass_transfer_request_get_type(request); + proto->code = 0; + proto->reason = 0; + proto->parse_error = GLOBUS_FALSE; proto->destroy_called = GLOBUS_FALSE; - proto->headers = GLOBUS_NULL; + proto->headers = GLOBUS_NULL; proto->response_buffer = GLOBUS_NULL; - proto->length = 0; - proto->handled = 0; - proto->chunked = GLOBUS_FALSE; - proto->chunk_left = 0; + proto->length = 0; + proto->handled = 0; + proto->chunked = GLOBUS_FALSE; + proto->chunk_left = 0; proto->failure_occurred = GLOBUS_FALSE; proto->oneshot_registered = GLOBUS_FALSE; proto->oneshot_active = GLOBUS_FALSE; - proto->eof_read = GLOBUS_FALSE; - proto->client_side = GLOBUS_TRUE; - proto->connected_subject = GLOBUS_NULL; + proto->eof_read = GLOBUS_FALSE; + proto->client_side = GLOBUS_TRUE; + proto->connected_subject = GLOBUS_NULL; proto->proxy_connect = proxy ? GLOBUS_TRUE : GLOBUS_FALSE; proto->got_response = GLOBUS_FALSE; proto->waiting_for_response = GLOBUS_FALSE; @@ -2410,58 +2408,58 @@ globus_l_gass_transfer_http_new_request( /* Open the handle */ if(proxy) { - if(proto->proxy_url.scheme_type == GLOBUS_URL_SCHEME_HTTP && - proto->proxy_url.port == 0) - { - proto->proxy_url.port = GLOBUS_L_DEFAULT_HTTP_PORT; - } - else if(proto->proxy_url.scheme_type == GLOBUS_URL_SCHEME_HTTPS && - proto->proxy_url.port == 0) - { - proto->proxy_url.port = GLOBUS_L_DEFAULT_HTTPS_PORT; - } - debug_printf(4,(_GTSL("%s(): Registering connect to %s\n"), - myname, - proto->proxy_url.host)); - result = globus_io_tcp_register_connect( - proto->proxy_url.host, - proto->proxy_url.port, - &tcp_attr, - globus_l_gass_transfer_http_connect_callback, - proto, - &proto->handle); + if(proto->proxy_url.scheme_type == GLOBUS_URL_SCHEME_HTTP && + proto->proxy_url.port == 0) + { + proto->proxy_url.port = GLOBUS_L_DEFAULT_HTTP_PORT; + } + else if(proto->proxy_url.scheme_type == GLOBUS_URL_SCHEME_HTTPS && + proto->proxy_url.port == 0) + { + proto->proxy_url.port = GLOBUS_L_DEFAULT_HTTPS_PORT; + } + debug_printf(4,(_GTSL("%s(): Registering connect to %s\n"), + myname, + proto->proxy_url.host)); + result = globus_io_tcp_register_connect( + proto->proxy_url.host, + proto->proxy_url.port, + &tcp_attr, + globus_l_gass_transfer_http_connect_callback, + proto, + &proto->handle); } else { - if(proto->url.scheme_type == GLOBUS_URL_SCHEME_HTTP && - proto->url.port == 0) - { - proto->url.port = GLOBUS_L_DEFAULT_HTTP_PORT; - } - else if(proto->url.scheme_type == GLOBUS_URL_SCHEME_HTTPS && - proto->url.port == 0) - { - proto->url.port = GLOBUS_L_DEFAULT_HTTPS_PORT; - } - debug_printf(4,(_GTSL("%s(): Registering connect to %s\n"), - myname, - proto->url.host)); - result = globus_io_tcp_register_connect( - proto->url.host, - proto->url.port, - &tcp_attr, - globus_l_gass_transfer_http_connect_callback, - proto, - &proto->handle); - } - if(proxy) - { - globus_url_destroy(&proto->proxy_url); + if(proto->url.scheme_type == GLOBUS_URL_SCHEME_HTTP && + proto->url.port == 0) + { + proto->url.port = GLOBUS_L_DEFAULT_HTTP_PORT; + } + else if(proto->url.scheme_type == GLOBUS_URL_SCHEME_HTTPS && + proto->url.port == 0) + { + proto->url.port = GLOBUS_L_DEFAULT_HTTPS_PORT; + } + debug_printf(4,(_GTSL("%s(): Registering connect to %s\n"), + myname, + proto->url.host)); + result = globus_io_tcp_register_connect( + proto->url.host, + proto->url.port, + &tcp_attr, + globus_l_gass_transfer_http_connect_callback, + proto, + &proto->handle); + } + if(proxy) + { + globus_url_destroy(&proto->proxy_url); } if(result != GLOBUS_SUCCESS) { - goto url_error; + goto url_error; } /* Success! */ globus_io_tcpattr_destroy(&tcp_attr); @@ -2473,22 +2471,22 @@ globus_l_gass_transfer_http_new_request( proxy_error: if(proxy) { - globus_url_destroy(&proto->proxy_url); + globus_url_destroy(&proto->proxy_url); } tcpattr_error: globus_io_tcpattr_destroy(&tcp_attr); proto_error: globus_free(proto); error_exit: - + GlobusTimeReltimeSet(delay_time, 0, 0); debug_printf(4,(_GTSL("%s(): Registering oneshot\n"), - myname)); + myname)); globus_callback_register_oneshot( GLOBUS_NULL, - &delay_time, - globus_l_gass_transfer_http_callback_denied, - (void *) (intptr_t) request); + &delay_time, + globus_l_gass_transfer_http_callback_denied, + (void *) (intptr_t) request); debug_printf(1, (_GTSL("Exiting %s()\n"),myname)); } @@ -2509,48 +2507,48 @@ globus_object_t * globus_l_gass_transfer_http_new_requestattr( char * url_scheme) { - globus_object_t * obj; + globus_object_t * obj; MYNAME(globus_l_gass_transfer_http_new_requestattr); debug_printf(1, (_GTSL("Entering %s()\n"),myname)); if(strcmp(url_scheme, "https") == 0) { - obj = globus_object_construct(GLOBUS_GASS_OBJECT_TYPE_SECURE_REQUESTATTR); - - debug_printf(1, (_GTSL("Exiting %s()\n"),myname)); - return - globus_gass_transfer_secure_requestattr_initialize( - obj, - GLOBUS_NULL, - 0, - GLOBUS_GASS_TRANSFER_FILE_MODE_BINARY, - GLOBUS_FALSE, - 0, - 0, - GLOBUS_FALSE, - GLOBUS_GASS_TRANSFER_AUTHORIZE_HOST, - GLOBUS_NULL); + obj = globus_object_construct(GLOBUS_GASS_OBJECT_TYPE_SECURE_REQUESTATTR); + + debug_printf(1, (_GTSL("Exiting %s()\n"),myname)); + return + globus_gass_transfer_secure_requestattr_initialize( + obj, + GLOBUS_NULL, + 0, + GLOBUS_GASS_TRANSFER_FILE_MODE_BINARY, + GLOBUS_FALSE, + 0, + 0, + GLOBUS_FALSE, + GLOBUS_GASS_TRANSFER_AUTHORIZE_HOST, + GLOBUS_NULL); } else if(strcmp(url_scheme, "http") == 0) { - obj = globus_object_construct(GLOBUS_GASS_OBJECT_TYPE_SOCKET_REQUESTATTR); + obj = globus_object_construct(GLOBUS_GASS_OBJECT_TYPE_SOCKET_REQUESTATTR); - debug_printf(1, (_GTSL("Exiting %s()\n"), myname)); - return - globus_gass_transfer_socket_requestattr_initialize( - obj, - GLOBUS_NULL, - 0, - GLOBUS_GASS_TRANSFER_FILE_MODE_BINARY, - GLOBUS_FALSE, - 0, - 0, - GLOBUS_FALSE); + debug_printf(1, (_GTSL("Exiting %s()\n"), myname)); + return + globus_gass_transfer_socket_requestattr_initialize( + obj, + GLOBUS_NULL, + 0, + GLOBUS_GASS_TRANSFER_FILE_MODE_BINARY, + GLOBUS_FALSE, + 0, + 0, + GLOBUS_FALSE); } else { - debug_printf(1, (_GTSL("Exiting %s()\n"), myname)); - return GLOBUS_NULL; + debug_printf(1, (_GTSL("Exiting %s()\n"), myname)); + return GLOBUS_NULL; } } /* globus_l_gass_transfer_http_new_requestattr() */ @@ -2570,26 +2568,26 @@ globus_object_t * globus_l_gass_transfer_http_new_listenerattr( char * url_scheme) { - globus_object_t * obj; + globus_object_t * obj; MYNAME(globus_l_gass_transfer_http_new_listenerattr); - + debug_printf(1, (_GTSL("Entering %s()\n"), myname)); if(strcmp(url_scheme, "https") == 0 || strcmp(url_scheme, "http") == 0) { - obj = globus_object_construct(GLOBUS_GASS_OBJECT_TYPE_LISTENERATTR); + obj = globus_object_construct(GLOBUS_GASS_OBJECT_TYPE_LISTENERATTR); - debug_printf(1, (_GTSL("Exiting %s()\n"),myname)); - return - globus_gass_transfer_listenerattr_initialize( - obj, - -1, - 0); + debug_printf(1, (_GTSL("Exiting %s()\n"),myname)); + return + globus_gass_transfer_listenerattr_initialize( + obj, + -1, + 0); } else { - debug_printf(1, (_GTSL("Exiting %s()\n"),myname)); - return GLOBUS_NULL; + debug_printf(1, (_GTSL("Exiting %s()\n"),myname)); + return GLOBUS_NULL; } } /* globus_l_gass_transfer_http_new_listenerattr() */ @@ -2607,24 +2605,24 @@ globus_l_gass_transfer_http_new_listenerattr( static int globus_l_gass_transfer_http_new_listener( - globus_gass_transfer_listener_t listener, - globus_gass_transfer_listenerattr_t * attr, - char * scheme, - char ** base_url, - globus_gass_transfer_listener_proto_t ** ret_proto) + globus_gass_transfer_listener_t listener, + globus_gass_transfer_listenerattr_t * attr, + char * scheme, + char ** base_url, + globus_gass_transfer_listener_proto_t ** ret_proto) { globus_gass_transfer_http_listener_proto_t * - proto; - globus_io_attr_t tcpattr; - globus_io_secure_authorization_data_t data; - globus_result_t result; - int rc; - unsigned short port=0; - int backlog=-1; - char hostname[MAXHOSTNAMELEN]; - globus_size_t url_size; + proto; + globus_io_attr_t tcpattr; + globus_io_secure_authorization_data_t data; + globus_result_t result; + int rc; + unsigned short port=0; + int backlog=-1; + char hostname[MAXHOSTNAMELEN]; + globus_size_t url_size; MYNAME(globus_l_gass_transfer_http_new_listener); - + debug_printf(1, (_GTSL("Entering %s()\n"),myname)); globus_io_tcpattr_init(&tcpattr); @@ -2632,11 +2630,11 @@ globus_l_gass_transfer_http_new_listener( /* Allocate proto instance */ proto = (globus_gass_transfer_http_listener_proto_t *) - globus_malloc(sizeof(globus_gass_transfer_http_listener_proto_t)); + globus_malloc(sizeof(globus_gass_transfer_http_listener_proto_t)); if(proto == GLOBUS_NULL) { - goto free_tcpattr; + goto free_tcpattr; } proto->close_listener = globus_l_gass_transfer_http_close_listener; @@ -2648,103 +2646,103 @@ globus_l_gass_transfer_http_new_listener( proto->destroy_called = GLOBUS_FALSE; if(strcmp(scheme, "http") == 0) { - proto->url_scheme = GLOBUS_URL_SCHEME_HTTP; + proto->url_scheme = GLOBUS_URL_SCHEME_HTTP; } else if(strcmp(scheme, "https") == 0) { - result = globus_io_attr_set_secure_authentication_mode( - &tcpattr, - GLOBUS_IO_SECURE_AUTHENTICATION_MODE_MUTUAL, - GLOBUS_NULL); - if(result != GLOBUS_SUCCESS) - { - goto free_proto; - } - - result = globus_io_attr_set_secure_channel_mode( - &tcpattr, - GLOBUS_IO_SECURE_CHANNEL_MODE_SSL_WRAP); - - if(result != GLOBUS_SUCCESS) - { - goto free_proto; - } - result = globus_io_secure_authorization_data_initialize(&data); - - if(result != GLOBUS_SUCCESS) - { - goto free_auth_data; - } - - result = globus_io_secure_authorization_data_set_callback( - &data, - globus_l_gass_transfer_http_authorization_callback, - proto); - - if(result != GLOBUS_SUCCESS) - { - goto free_auth_data; - } - - result = globus_io_attr_set_secure_authorization_mode( - &tcpattr, - GLOBUS_IO_SECURE_AUTHORIZATION_MODE_CALLBACK, - &data); - - if(result != GLOBUS_SUCCESS) - { - goto free_auth_data; - } - - globus_io_secure_authorization_data_destroy(&data); - - proto->url_scheme = GLOBUS_URL_SCHEME_HTTPS; + result = globus_io_attr_set_secure_authentication_mode( + &tcpattr, + GLOBUS_IO_SECURE_AUTHENTICATION_MODE_MUTUAL, + GLOBUS_NULL); + if(result != GLOBUS_SUCCESS) + { + goto free_proto; + } + + result = globus_io_attr_set_secure_channel_mode( + &tcpattr, + GLOBUS_IO_SECURE_CHANNEL_MODE_SSL_WRAP); + + if(result != GLOBUS_SUCCESS) + { + goto free_proto; + } + result = globus_io_secure_authorization_data_initialize(&data); + + if(result != GLOBUS_SUCCESS) + { + goto free_auth_data; + } + + result = globus_io_secure_authorization_data_set_callback( + &data, + globus_l_gass_transfer_http_authorization_callback, + proto); + + if(result != GLOBUS_SUCCESS) + { + goto free_auth_data; + } + + result = globus_io_attr_set_secure_authorization_mode( + &tcpattr, + GLOBUS_IO_SECURE_AUTHORIZATION_MODE_CALLBACK, + &data); + + if(result != GLOBUS_SUCCESS) + { + goto free_auth_data; + } + + globus_io_secure_authorization_data_destroy(&data); + + proto->url_scheme = GLOBUS_URL_SCHEME_HTTPS; } else { - goto free_proto; + goto free_proto; } if(attr) { - rc = globus_gass_transfer_listenerattr_get_port(attr, - &port); + rc = globus_gass_transfer_listenerattr_get_port(attr, + &port); - if(rc != GLOBUS_SUCCESS) - { - goto free_proto; - } + if(rc != GLOBUS_SUCCESS) + { + goto free_proto; + } - rc = globus_gass_transfer_listenerattr_get_backlog(attr, - &backlog); - if(rc != GLOBUS_SUCCESS) - { - goto free_proto; - } + rc = globus_gass_transfer_listenerattr_get_backlog(attr, + &backlog); + if(rc != GLOBUS_SUCCESS) + { + goto free_proto; + } } result = globus_io_tcp_create_listener(&port, - backlog, - &tcpattr, - &proto->handle); + backlog, + &tcpattr, + &proto->handle); globus_io_tcpattr_destroy(&tcpattr); if(result != GLOBUS_SUCCESS) { - goto free_proto; + goto free_proto; } url_size = 15; /* https://:65536\0 */ globus_libc_gethostname(hostname, - MAXHOSTNAMELEN); + MAXHOSTNAMELEN); url_size += strlen(hostname); *base_url = globus_malloc(url_size); sprintf(*base_url, - "%s://%s:%d", - proto->url_scheme == GLOBUS_URL_SCHEME_HTTPS ? - "https" : "http", - hostname, - (int) port); + "%s://%s:%d", + proto->url_scheme == GLOBUS_URL_SCHEME_HTTPS ? + "https" : "http", + hostname, + (int) port); proto->state = GLOBUS_GASS_TRANSFER_HTTP_LISTENER_STARTING; @@ -2770,7 +2768,7 @@ globus_l_gass_transfer_http_new_listener( * Description: Called by the GASS system when the user has * requested that a listener be closed. This * may be called at any time, but only once - * per listener. + * per listener. * * Parameters: * @@ -2779,55 +2777,55 @@ globus_l_gass_transfer_http_new_listener( static void globus_l_gass_transfer_http_close_listener( - globus_gass_transfer_listener_proto_t * proto, - globus_gass_transfer_listener_t listener) + globus_gass_transfer_listener_proto_t * proto, + globus_gass_transfer_listener_t listener) { globus_gass_transfer_http_listener_proto_t * - new_proto; + new_proto; MYNAME(globus_l_gass_transfer_http_close_listener); debug_printf(1, (_GTSL("entering %s()\n"),myname)); new_proto = (globus_gass_transfer_http_listener_proto_t *) proto; globus_l_gass_transfer_http_lock(); { - switch(new_proto->state) - { - case GLOBUS_GASS_TRANSFER_HTTP_LISTENER_STARTING: + switch(new_proto->state) + { + case GLOBUS_GASS_TRANSFER_HTTP_LISTENER_STARTING: case GLOBUS_GASS_TRANSFER_HTTP_LISTENER_READY: - /* If the listener is in the "idle" or "ready" state, then - * we can simply register the close, which will free the - * proto. (GASS is not waiting for a callback now. - */ - globus_l_gass_transfer_http_register_listener_close(new_proto); - break; + /* If the listener is in the "idle" or "ready" state, then + * we can simply register the close, which will free the + * proto. (GASS is not waiting for a callback now. + */ + globus_l_gass_transfer_http_register_listener_close(new_proto); + break; case GLOBUS_GASS_TRANSFER_HTTP_LISTENER_LISTENING: - /* - * If we are in the "listening" state, registering the - * close will cause the listen callback to finish, and - * after that calls the user, the close callback will delete - * things - */ - new_proto->state = GLOBUS_GASS_TRANSFER_HTTP_LISTENER_CLOSING1; - globus_l_gass_transfer_http_register_listener_close(new_proto); - break; - case GLOBUS_GASS_TRANSFER_HTTP_LISTENER_ACCEPTING: - /* - * If we are in the "accepting" state, registering the - * close will cause any outstanding listen callbacks to finish, - * from where we can call back to GASS. - */ - new_proto->state = GLOBUS_GASS_TRANSFER_HTTP_LISTENER_CLOSING2; - globus_l_gass_transfer_http_register_listener_close(new_proto); - break; - case GLOBUS_GASS_TRANSFER_HTTP_LISTENER_CLOSING1: - case GLOBUS_GASS_TRANSFER_HTTP_LISTENER_CLOSING2: - case GLOBUS_GASS_TRANSFER_HTTP_LISTENER_CLOSED: - /* should not happen */ - globus_assert(new_proto->state != GLOBUS_GASS_TRANSFER_HTTP_LISTENER_CLOSING1); - globus_assert(new_proto->state != GLOBUS_GASS_TRANSFER_HTTP_LISTENER_CLOSING2); - globus_assert(new_proto->state != GLOBUS_GASS_TRANSFER_HTTP_LISTENER_CLOSED); - break; - } + /* + * If we are in the "listening" state, registering the + * close will cause the listen callback to finish, and + * after that calls the user, the close callback will delete + * things + */ + new_proto->state = GLOBUS_GASS_TRANSFER_HTTP_LISTENER_CLOSING1; + globus_l_gass_transfer_http_register_listener_close(new_proto); + break; + case GLOBUS_GASS_TRANSFER_HTTP_LISTENER_ACCEPTING: + /* + * If we are in the "accepting" state, registering the + * close will cause any outstanding listen callbacks to finish, + * from where we can call back to GASS. + */ + new_proto->state = GLOBUS_GASS_TRANSFER_HTTP_LISTENER_CLOSING2; + globus_l_gass_transfer_http_register_listener_close(new_proto); + break; + case GLOBUS_GASS_TRANSFER_HTTP_LISTENER_CLOSING1: + case GLOBUS_GASS_TRANSFER_HTTP_LISTENER_CLOSING2: + case GLOBUS_GASS_TRANSFER_HTTP_LISTENER_CLOSED: + /* should not happen */ + globus_assert(new_proto->state != GLOBUS_GASS_TRANSFER_HTTP_LISTENER_CLOSING1); + globus_assert(new_proto->state != GLOBUS_GASS_TRANSFER_HTTP_LISTENER_CLOSING2); + globus_assert(new_proto->state != GLOBUS_GASS_TRANSFER_HTTP_LISTENER_CLOSED); + break; + } } globus_l_gass_transfer_http_unlock(); debug_printf(1, (_GTSL("exiting %s()\n"),myname)); @@ -2852,25 +2850,25 @@ globus_l_gass_transfer_http_close_listener( static void globus_l_gass_transfer_http_connect_callback( - void * arg, - globus_io_handle_t * handle, - globus_result_t result) + void * arg, + globus_io_handle_t * handle, + globus_result_t result) { - char * cmd; - globus_gass_transfer_http_request_proto_t * proto; - globus_gass_transfer_request_t request; - int code; - char * msg; + char * cmd; + globus_gass_transfer_http_request_proto_t * proto; + globus_gass_transfer_request_t request; + int code; + char * msg; MYNAME(globus_l_gass_transfer_http_connect_callback); - + debug_printf(3, (_GTSL("Entering %s()\n"), myname)); /* * In this function, we have completed the TCP (and SSL) * connection protocol, and will send our request to the - * server for processing. + * server for processing. */ proto = (globus_gass_transfer_http_request_proto_t *) - arg; + arg; globus_l_gass_transfer_http_lock(); @@ -2878,38 +2876,38 @@ globus_l_gass_transfer_http_connect_callback( if(result != GLOBUS_SUCCESS) { - /* - * TODO: Evaluate error object here, put into - * proto->code and proto->reason - */ - goto deny_exit; + /* + * TODO: Evaluate error object here, put into + * proto->code and proto->reason + */ + goto deny_exit; } cmd = globus_l_gass_transfer_http_construct_request(proto); if(cmd == GLOBUS_NULL) { - goto deny_exit; + goto deny_exit; } /* Send our command to the server */ debug_printf(4,(_GTSL("%s(): Registering write on %p\n"), - myname, - &proto->handle)); - + myname, + &proto->handle)); + result = globus_io_register_write( - &proto->handle, - (globus_byte_t *) cmd, - strlen(cmd) * sizeof(char), - globus_l_gass_transfer_http_command_callback, - proto); + &proto->handle, + (globus_byte_t *) cmd, + strlen(cmd) * sizeof(char), + globus_l_gass_transfer_http_command_callback, + proto); if(result == GLOBUS_SUCCESS) { - proto->state = GLOBUS_GASS_TRANSFER_HTTP_STATE_REQUESTING; - globus_l_gass_transfer_http_unlock(); - debug_printf(3, (_GTSL("Exiting %s()\n"),myname)); - return; + proto->state = GLOBUS_GASS_TRANSFER_HTTP_STATE_REQUESTING; + globus_l_gass_transfer_http_unlock(); + debug_printf(3, (_GTSL("Exiting %s()\n"),myname)); + return; } /* Write registration failed, fall through to deny_exit */ @@ -2917,8 +2915,8 @@ globus_l_gass_transfer_http_connect_callback( /* Give a default error message, if none is generated above */ if(proto->code == 0) { - proto->code = GLOBUS_L_DEFAULT_FAILURE_CODE; - proto->reason = globus_libc_strdup(GLOBUS_L_DEFAULT_FAILURE_REASON); + proto->code = GLOBUS_L_DEFAULT_FAILURE_CODE; + proto->reason = globus_libc_strdup(GLOBUS_L_DEFAULT_FAILURE_REASON); } /* @@ -2944,9 +2942,9 @@ globus_l_gass_transfer_http_connect_callback( /* Signal Denial to the GASS system */ debug_printf(2, (_GTSL("calling globus_gass_transfer_proto_request_denied"))); globus_gass_transfer_proto_request_denied( - request, - code, - msg); + request, + code, + msg); debug_printf(3, (_GTSL("Exiting %s()\n"),myname)); } /* globus_l_gass_transfer_http_connect_callback() */ @@ -2967,20 +2965,20 @@ globus_l_gass_transfer_http_connect_callback( static void globus_l_gass_transfer_http_command_callback( - void * arg, - globus_io_handle_t * handle, - globus_result_t result, - globus_byte_t * buf, - globus_size_t nbytes) + void * arg, + globus_io_handle_t * handle, + globus_result_t result, + globus_byte_t * buf, + globus_size_t nbytes) { globus_gass_transfer_http_request_proto_t * proto; - globus_gass_transfer_request_t request; - int code; - char * reason; + globus_gass_transfer_request_t request; + int code; + char * reason; MYNAME(globus_l_gass_transfer_http_command_callback); - + debug_printf(3, (_GTSL("Entering %s()\n"),myname)); - + /* * In this function, we have completed sending our request * to the server. If there was some sort of error, we @@ -2994,7 +2992,7 @@ globus_l_gass_transfer_http_command_callback( if(result != GLOBUS_SUCCESS) { - goto deny_exit; + goto deny_exit; } /* * Free the request command buffer. @@ -3007,7 +3005,7 @@ globus_l_gass_transfer_http_command_callback( * The buffer may have to grow if there are a lot of headers. */ proto->response_buffer = globus_malloc(GLOBUS_L_GASS_RESPONSE_LEN * - sizeof(globus_byte_t)); + sizeof(globus_byte_t)); proto->response_buflen = GLOBUS_L_GASS_RESPONSE_LEN; proto->response_offset = 0; proto->parsed_offset = 0; @@ -3016,68 +3014,68 @@ globus_l_gass_transfer_http_command_callback( { case GLOBUS_GASS_TRANSFER_REQUEST_TYPE_PUT: case GLOBUS_GASS_TRANSFER_REQUEST_TYPE_APPEND: - /* - * If we are a "put" or "append" request, then we can start - * sending data sort of immediately. So we send an "ready" - * message to the server. A little optimistic, perhaps... - * We will not register for the response message until - * we've sent the last data. - */ - proto->state = GLOBUS_GASS_TRANSFER_HTTP_STATE_IDLE; - - debug_printf(4,(_GTSL("%s(): Registering read on %p\n"), - myname, - &proto->handle)); - - result = globus_io_register_read( - &proto->handle, - proto->response_buffer, - proto->response_buflen, - 1, - globus_l_gass_transfer_http_response_callback, - proto); - if(result != GLOBUS_SUCCESS) - { - proto->failure_occurred = GLOBUS_TRUE; - } - globus_l_gass_transfer_http_unlock(); - - debug_printf(2, (_GTSL("calling globus_gass_transfer_proto_request_ready"))); + /* + * If we are a "put" or "append" request, then we can start + * sending data sort of immediately. So we send an "ready" + * message to the server. A little optimistic, perhaps... + * We will not register for the response message until + * we've sent the last data. + */ + proto->state = GLOBUS_GASS_TRANSFER_HTTP_STATE_IDLE; + + debug_printf(4,(_GTSL("%s(): Registering read on %p\n"), + myname, + &proto->handle)); + + result = globus_io_register_read( + &proto->handle, + proto->response_buffer, + proto->response_buflen, + 1, + globus_l_gass_transfer_http_response_callback, + proto); + if(result != GLOBUS_SUCCESS) + { + proto->failure_occurred = GLOBUS_TRUE; + } + globus_l_gass_transfer_http_unlock(); + + debug_printf(2, (_GTSL("calling globus_gass_transfer_proto_request_ready"))); globus_gass_transfer_proto_request_ready( - proto->request, - (globus_gass_transfer_request_proto_t *) proto); + proto->request, + (globus_gass_transfer_request_proto_t *) proto); debug_printf(3, (_GTSL("Exiting %s()\n"),myname)); - return; + return; case GLOBUS_GASS_TRANSFER_REQUEST_TYPE_GET: - /* - * If we are a "GET" request we can't do anything - * until the server sends us some info, anyway - */ - debug_printf(4,(_GTSL("%s(): Registering read on %p\n"), - myname, - &proto->handle)); - result = globus_io_register_read( - &proto->handle, - proto->response_buffer, - proto->response_buflen, - 1, - globus_l_gass_transfer_http_response_callback, - proto); - if(result != GLOBUS_SUCCESS) - { - /* should interpret the error object */ - goto deny_exit; - } - globus_l_gass_transfer_http_unlock(); + /* + * If we are a "GET" request we can't do anything + * until the server sends us some info, anyway + */ + debug_printf(4,(_GTSL("%s(): Registering read on %p\n"), + myname, + &proto->handle)); + result = globus_io_register_read( + &proto->handle, + proto->response_buffer, + proto->response_buflen, + 1, + globus_l_gass_transfer_http_response_callback, + proto); + if(result != GLOBUS_SUCCESS) + { + /* should interpret the error object */ + goto deny_exit; + } + globus_l_gass_transfer_http_unlock(); debug_printf(3, (_GTSL("Exiting %s()\n"),myname)); - return; + return; default: - globus_assert(proto->type != - GLOBUS_GASS_TRANSFER_REQUEST_TYPE_INVALID); - goto deny_exit; + globus_assert(proto->type != + GLOBUS_GASS_TRANSFER_REQUEST_TYPE_INVALID); + goto deny_exit; } deny_exit: @@ -3089,13 +3087,13 @@ globus_l_gass_transfer_http_command_callback( /* Give a default error message, if none is generated above */ if(proto->code == 0) { - proto->code = GLOBUS_L_DEFAULT_FAILURE_CODE; - proto->reason = globus_libc_strdup(GLOBUS_L_DEFAULT_FAILURE_REASON); + proto->code = GLOBUS_L_DEFAULT_FAILURE_CODE; + proto->reason = globus_libc_strdup(GLOBUS_L_DEFAULT_FAILURE_REASON); } request = proto->request; code = proto->code; - reason = globus_libc_strdup(proto->reason); + reason = globus_libc_strdup(proto->reason); result = globus_l_gass_transfer_http_register_close(proto); @@ -3103,15 +3101,15 @@ globus_l_gass_transfer_http_command_callback( { globus_l_gass_transfer_http_close(proto); } - + globus_l_gass_transfer_http_unlock(); /* Signal Denial to the GASS system */ debug_printf(2, (_GTSL("calling globus_gass_transfer_proto_request_denied"))); globus_gass_transfer_proto_request_denied( - request, - code, - reason); + request, + code, + reason); debug_printf(3, (_GTSL("Exiting %s()\n"),myname)); } /* globus_l_gass_transfer_http_command_callback() */ @@ -3119,15 +3117,15 @@ globus_l_gass_transfer_http_command_callback( static void globus_l_gass_transfer_http_response_callback( - void * arg, - globus_io_handle_t * handle, - globus_result_t result, - globus_byte_t * buf, - globus_size_t nbytes) + void * arg, + globus_io_handle_t * handle, + globus_result_t result, + globus_byte_t * buf, + globus_size_t nbytes) { - globus_gass_transfer_http_request_proto_t * proto; - globus_object_t * err=GLOBUS_NULL; - globus_gass_transfer_request_t request; + globus_gass_transfer_http_request_proto_t * proto; + globus_object_t * err=GLOBUS_NULL; + globus_gass_transfer_request_t request; int code; char * reason; MYNAME(globus_l_gass_transfer_http_response_callback); @@ -3138,10 +3136,10 @@ globus_l_gass_transfer_http_response_callback( { char * tmpstr; - err = globus_error_get(result); - tmpstr = globus_object_printable_to_string(err); - debug_printf(5, (_GTSL("globus_l_gass_transfer_http_read_callback(): %s"), tmpstr)); - globus_libc_free(tmpstr); + err = globus_error_get(result); + tmpstr = globus_object_printable_to_string(err); + debug_printf(5, (_GTSL("globus_l_gass_transfer_http_read_callback(): %s"), tmpstr)); + globus_libc_free(tmpstr); } globus_l_gass_transfer_http_lock(); @@ -3151,13 +3149,13 @@ globus_l_gass_transfer_http_response_callback( if(result != GLOBUS_SUCCESS && !globus_io_eof(err)) { - if(proto->type == GLOBUS_GASS_TRANSFER_REQUEST_TYPE_PUT || - proto->type == GLOBUS_GASS_TRANSFER_REQUEST_TYPE_APPEND) - { - goto put_fail_exit; - } + if(proto->type == GLOBUS_GASS_TRANSFER_REQUEST_TYPE_PUT || + proto->type == GLOBUS_GASS_TRANSFER_REQUEST_TYPE_APPEND) + { + goto put_fail_exit; + } - result = globus_l_gass_transfer_http_register_close(proto); + result = globus_l_gass_transfer_http_register_close(proto); if (result != GLOBUS_SUCCESS) { @@ -3165,22 +3163,22 @@ globus_l_gass_transfer_http_response_callback( } - globus_l_gass_transfer_http_unlock(); + globus_l_gass_transfer_http_unlock(); - /* TODO: Evaluate error object, or response from the server here */ - debug_printf(2, (_GTSL("calling globus_gass_transfer_proto_request_denied"))); - globus_gass_transfer_proto_request_denied( - request, - GLOBUS_L_DEFAULT_FAILURE_CODE, - globus_libc_strdup(GLOBUS_L_DEFAULT_FAILURE_REASON)); + /* TODO: Evaluate error object, or response from the server here */ + debug_printf(2, (_GTSL("calling globus_gass_transfer_proto_request_denied"))); + globus_gass_transfer_proto_request_denied( + request, + GLOBUS_L_DEFAULT_FAILURE_CODE, + globus_libc_strdup(GLOBUS_L_DEFAULT_FAILURE_REASON)); - if(err) - { - globus_object_free(err); - } + if(err) + { + globus_object_free(err); + } - debug_printf(3, (_GTSL("Exiting globus_l_gass_transfer_http_response_callback()\n"))); - return; + debug_printf(3, (_GTSL("Exiting globus_l_gass_transfer_http_response_callback()\n"))); + return; } /* Update our counters */ @@ -3188,418 +3186,418 @@ globus_l_gass_transfer_http_response_callback( do { - /* Parse the buffer that we have */ - if(globus_l_gass_transfer_http_parse_response(proto)) - { - /* returns true, if we need to read some more */ - goto repost_read; - } - - switch(proto->type) - { - case GLOBUS_GASS_TRANSFER_REQUEST_TYPE_GET: - /* If it is a GET request, we need an affirmative - * response, or a continue, or a referral - */ - if(proto->code < 100 || - proto->code >= 400) - { - /* Denied */ - goto deny_exit; - } - else if(proto->code >= 100 && - proto->code < 200) - { - /* - * Continue... Reset our response buffers, - * and get another set of headers - */ - memmove(proto->response_buffer, - proto->response_buffer + proto->parsed_offset, - proto->response_offset - proto->parsed_offset); - - proto->response_offset -= proto->parsed_offset; - proto->parsed_offset = 0; - - if(proto->reason) - { - globus_free(proto->reason); - } - proto->code = 0; - proto->reason = GLOBUS_NULL; - - globus_i_gass_transfer_keyvalue_destroy( - &proto->headers); - - /* - * There may be more headers in our buffer, so - * we should go through the parse loop again, - * maybe - */ - if(proto->response_offset != 0) - { - continue; - } - else - { - goto repost_read; - } - } - else if(proto->code >= 300 && - proto->code < 400) - { - char ** referral; - globus_size_t referral_count; - /* We've got a referral from the server */ - globus_l_gass_transfer_http_extract_referral(proto, - &referral, - &referral_count); - - if(referral == GLOBUS_NULL) - { - goto deny_exit; - } - else - { - /* If this is a get request, then the proto layer - * doesn't have a pointer to this proto yet, - * so we need to act like they've destroyed their - * reference to it - */ - proto->destroy_called = GLOBUS_TRUE; - result = globus_l_gass_transfer_http_register_close(proto); + /* Parse the buffer that we have */ + if(globus_l_gass_transfer_http_parse_response(proto)) + { + /* returns true, if we need to read some more */ + goto repost_read; + } + + switch(proto->type) + { + case GLOBUS_GASS_TRANSFER_REQUEST_TYPE_GET: + /* If it is a GET request, we need an affirmative + * response, or a continue, or a referral + */ + if(proto->code < 100 || + proto->code >= 400) + { + /* Denied */ + goto deny_exit; + } + else if(proto->code >= 100 && + proto->code < 200) + { + /* + * Continue... Reset our response buffers, + * and get another set of headers + */ + memmove(proto->response_buffer, + proto->response_buffer + proto->parsed_offset, + proto->response_offset - proto->parsed_offset); + + proto->response_offset -= proto->parsed_offset; + proto->parsed_offset = 0; + + if(proto->reason) + { + globus_free(proto->reason); + } + proto->code = 0; + proto->reason = GLOBUS_NULL; + + globus_i_gass_transfer_keyvalue_destroy( + &proto->headers); + + /* + * There may be more headers in our buffer, so + * we should go through the parse loop again, + * maybe + */ + if(proto->response_offset != 0) + { + continue; + } + else + { + goto repost_read; + } + } + else if(proto->code >= 300 && + proto->code < 400) + { + char ** referral; + globus_size_t referral_count; + /* We've got a referral from the server */ + globus_l_gass_transfer_http_extract_referral(proto, + &referral, + &referral_count); + + if(referral == GLOBUS_NULL) + { + goto deny_exit; + } + else + { + /* If this is a get request, then the proto layer + * doesn't have a pointer to this proto yet, + * so we need to act like they've destroyed their + * reference to it + */ + proto->destroy_called = GLOBUS_TRUE; + result = globus_l_gass_transfer_http_register_close(proto); if (result != GLOBUS_SUCCESS) { globus_l_gass_transfer_http_close(proto); } - - globus_l_gass_transfer_http_unlock(); - debug_printf(2, (_GTSL("calling globus_gass_transfer_proto_request_referred"))); - globus_gass_transfer_proto_request_referred( - request, - referral, - referral_count); - return; - } - } - else - { - /* - * Successful response for the "get", check for - * interesting headers, and indicate "ready" to - * the GASS system. (note that first read will - * have to deal with the data in - * proto->response_buffer) - */ - char * value; - - /* - * Look to see if there are any headers we - * care about - */ - value = globus_i_gass_transfer_keyvalue_lookup( - &proto->headers, - "transfer-encoding"); - if(value) - { - char * tmp; - - for(tmp = value; *tmp != '\0'; tmp++) - { - if(! isspace(*tmp)) - { - break; - } - } + + globus_l_gass_transfer_http_unlock(); + debug_printf(2, (_GTSL("calling globus_gass_transfer_proto_request_referred"))); + globus_gass_transfer_proto_request_referred( + request, + referral, + referral_count); + return; + } + } + else + { + /* + * Successful response for the "get", check for + * interesting headers, and indicate "ready" to + * the GASS system. (note that first read will + * have to deal with the data in + * proto->response_buffer) + */ + char * value; + + /* + * Look to see if there are any headers we + * care about + */ + value = globus_i_gass_transfer_keyvalue_lookup( + &proto->headers, + "transfer-encoding"); + if(value) + { + char * tmp; + + for(tmp = value; *tmp != '\0'; tmp++) + { + if(! isspace(*tmp)) + { + break; + } + } #ifndef TARGET_ARCH_WIN32 - if(strncasecmp(tmp, "chunked", strlen("chunked")) == 0) + if(strncasecmp(tmp, "chunked", strlen("chunked")) == 0) #else - if(strnicmp(tmp, "chunked", strlen("chunked")) == 0) + if(strnicmp(tmp, "chunked", strlen("chunked")) == 0) #endif - { - proto->recv_buffer = - globus_l_gass_transfer_http_receive; - proto->chunked = GLOBUS_TRUE; - proto->recv_state = - GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_CHUNK_SIZE; - proto->length = 0; - } - } - if(!proto->chunked) - { - /* If both - * Transfer-Encoding: chunked and - * Content-Length: - * are passed, the Content-length should be ignored, - * according to RFC 2068 - */ - value = globus_i_gass_transfer_keyvalue_lookup( - &proto->headers, - "content-length"); - - if(value) - { - int save_errno; - char * tmp; - - for(tmp = value; *tmp != '\0'; tmp++) - { - if(! isspace(*tmp)) - { - break; - } - } - globus_libc_lock(); - errno=0; - proto->length = strtoul(tmp, - GLOBUS_NULL, - 10); - save_errno=errno; - globus_libc_unlock(); - if(save_errno != 0) - { - proto->code = GLOBUS_L_PROTOCOL_FAILURE_CODE; - proto->reason = globus_libc_strdup( - GLOBUS_L_PROTOCOL_FAILURE_REASON); - goto deny_exit; - } - if(proto->length == 0) - { - proto->recv_state = - GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_ERROR; - } - else - { - proto->recv_state = - GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_UNTIL_LENGTH; - } - } - else - { - proto->recv_state = - GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_UNTIL_EOF; - } - - if(!proto->text_mode) - { - globus_gass_transfer_request_set_length(proto->request, - proto->length); - - } - } - /* - * The response buffer's residue may contain some - * entity information, so let's keep it around. - * Also, if we are in text mode, we'll have to copy - * the data anyway (but should use the block_size) - */ - - if(proto->text_mode && - proto->block_size > proto->response_buflen) - { - globus_byte_t * tmp; - - tmp = globus_libc_realloc(proto->response_buffer, - proto->block_size * - sizeof(globus_byte_t)); - if(tmp != GLOBUS_NULL) - { - proto->response_buffer = tmp; - proto->response_buflen = proto->block_size; - } - - } - - proto->state = GLOBUS_GASS_TRANSFER_HTTP_STATE_IDLE; - globus_l_gass_transfer_http_unlock(); - - debug_printf(2, (_GTSL("calling globus_gass_transfer_proto_request_ready"))); globus_gass_transfer_proto_request_ready( - proto->request, - (globus_gass_transfer_request_proto_t *) proto); - } - break; - case GLOBUS_GASS_TRANSFER_REQUEST_TYPE_PUT: - case GLOBUS_GASS_TRANSFER_REQUEST_TYPE_APPEND: - /* If it is a PUT or APPEND request, we don't expect any - * response from the server until we're done sending, - * or the server kills our request - */ - if(proto->code < 100 || - proto->code >= 400) - { - /* Request failed. */ - goto put_fail_exit; - } - else if(proto->code >= 300 && - proto->code < 400) - { - char ** referral; - globus_size_t referral_count; - /* Request referred. */ - globus_l_gass_transfer_http_extract_referral(proto, - &referral, - &referral_count); - if(referral == GLOBUS_NULL) - { - goto put_fail_exit; - } - else if(proto->state == GLOBUS_GASS_TRANSFER_HTTP_STATE_IDLE) - { - result = globus_l_gass_transfer_http_register_close(proto); + { + proto->recv_buffer = + globus_l_gass_transfer_http_receive; + proto->chunked = GLOBUS_TRUE; + proto->recv_state = + GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_CHUNK_SIZE; + proto->length = 0; + } + } + if(!proto->chunked) + { + /* If both + * Transfer-Encoding: chunked and + * Content-Length: + * are passed, the Content-length should be ignored, + * according to RFC 2068 + */ + value = globus_i_gass_transfer_keyvalue_lookup( + &proto->headers, + "content-length"); + + if(value) + { + int save_errno; + char * tmp; + + for(tmp = value; *tmp != '\0'; tmp++) + { + if(! isspace(*tmp)) + { + break; + } + } + globus_libc_lock(); + errno=0; + proto->length = strtoul(tmp, + GLOBUS_NULL, + 10); + save_errno=errno; + globus_libc_unlock(); + if(save_errno != 0) + { + proto->code = GLOBUS_L_PROTOCOL_FAILURE_CODE; + proto->reason = globus_libc_strdup( + GLOBUS_L_PROTOCOL_FAILURE_REASON); + goto deny_exit; + } + if(proto->length == 0) + { + proto->recv_state = + GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_ERROR; + } + else + { + proto->recv_state = + GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_UNTIL_LENGTH; + } + } + else + { + proto->recv_state = + GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_UNTIL_EOF; + } + + if(!proto->text_mode) + { + globus_gass_transfer_request_set_length(proto->request, + proto->length); + + } + } + /* + * The response buffer's residue may contain some + * entity information, so let's keep it around. + * Also, if we are in text mode, we'll have to copy + * the data anyway (but should use the block_size) + */ + + if(proto->text_mode && + proto->block_size > proto->response_buflen) + { + globus_byte_t * tmp; + + tmp = globus_libc_realloc(proto->response_buffer, + proto->block_size * + sizeof(globus_byte_t)); + if(tmp != GLOBUS_NULL) + { + proto->response_buffer = tmp; + proto->response_buflen = proto->block_size; + } + + } + + proto->state = GLOBUS_GASS_TRANSFER_HTTP_STATE_IDLE; + globus_l_gass_transfer_http_unlock(); + + debug_printf(2, (_GTSL("calling globus_gass_transfer_proto_request_ready"))); globus_gass_transfer_proto_request_ready( + proto->request, + (globus_gass_transfer_request_proto_t *) proto); + } + break; + case GLOBUS_GASS_TRANSFER_REQUEST_TYPE_PUT: + case GLOBUS_GASS_TRANSFER_REQUEST_TYPE_APPEND: + /* If it is a PUT or APPEND request, we don't expect any + * response from the server until we're done sending, + * or the server kills our request + */ + if(proto->code < 100 || + proto->code >= 400) + { + /* Request failed. */ + goto put_fail_exit; + } + else if(proto->code >= 300 && + proto->code < 400) + { + char ** referral; + globus_size_t referral_count; + /* Request referred. */ + globus_l_gass_transfer_http_extract_referral(proto, + &referral, + &referral_count); + if(referral == GLOBUS_NULL) + { + goto put_fail_exit; + } + else if(proto->state == GLOBUS_GASS_TRANSFER_HTTP_STATE_IDLE) + { + result = globus_l_gass_transfer_http_register_close(proto); if (result != GLOBUS_SUCCESS) { globus_l_gass_transfer_http_close(proto); } - - globus_l_gass_transfer_http_unlock(); - debug_printf(2, (_GTSL("calling globus_gass_transfer_proto_request_referred"))); - globus_gass_transfer_proto_request_referred(request, - referral, - referral_count); - debug_printf(3, (_GTSL("Exiting globus_l_gass_transfer_http_response_callback()\n"))); - return; - } - else - { - proto->failure_occurred = GLOBUS_TRUE; - - result = globus_l_gass_transfer_http_register_close(proto); + + globus_l_gass_transfer_http_unlock(); + debug_printf(2, (_GTSL("calling globus_gass_transfer_proto_request_referred"))); + globus_gass_transfer_proto_request_referred(request, + referral, + referral_count); + debug_printf(3, (_GTSL("Exiting globus_l_gass_transfer_http_response_callback()\n"))); + return; + } + else + { + proto->failure_occurred = GLOBUS_TRUE; + + result = globus_l_gass_transfer_http_register_close(proto); if (result != GLOBUS_SUCCESS) { globus_l_gass_transfer_http_close(proto); } - - globus_l_gass_transfer_http_unlock(); - - debug_printf(2, (_GTSL("calling globus_gass_transfer_proto_request_referred"))); - globus_gass_transfer_proto_request_referred(request, - referral, - referral_count); - - debug_printf(3, (_GTSL("Exiting globus_l_gass_transfer_http_response_callback()\n"))); - return; - } - } - else if(proto->code >= 100 && - proto->code < 200) - { - /* - * Continue... Reset our response buffers, - * and get another set of headers - */ - memmove(proto->response_buffer, - proto->response_buffer + proto->parsed_offset, - proto->response_offset - proto->parsed_offset); - - proto->response_offset -= proto->parsed_offset; - proto->parsed_offset = 0; - - if(proto->reason) - { - globus_free(proto->reason); - } - proto->code = 0; - proto->reason = GLOBUS_NULL; - - globus_i_gass_transfer_keyvalue_destroy( - &proto->headers); - - /* - * There may be more headers in our buffer, so - * we should go through the parse loop again, - * maybe - */ - if(proto->response_offset != 0) - { - continue; - } - else - { - goto repost_read; - } - } - else - { - goto put_success_exit; - } - case GLOBUS_GASS_TRANSFER_REQUEST_TYPE_INVALID: - default: - globus_assert(proto->type != - GLOBUS_GASS_TRANSFER_REQUEST_TYPE_INVALID); - globus_assert(GLOBUS_FALSE); - debug_printf(3, (_GTSL("Exiting globus_l_gass_transfer_http_response_callback()\n"))); - return; - } + + globus_l_gass_transfer_http_unlock(); + + debug_printf(2, (_GTSL("calling globus_gass_transfer_proto_request_referred"))); + globus_gass_transfer_proto_request_referred(request, + referral, + referral_count); + + debug_printf(3, (_GTSL("Exiting globus_l_gass_transfer_http_response_callback()\n"))); + return; + } + } + else if(proto->code >= 100 && + proto->code < 200) + { + /* + * Continue... Reset our response buffers, + * and get another set of headers + */ + memmove(proto->response_buffer, + proto->response_buffer + proto->parsed_offset, + proto->response_offset - proto->parsed_offset); + + proto->response_offset -= proto->parsed_offset; + proto->parsed_offset = 0; + + if(proto->reason) + { + globus_free(proto->reason); + } + proto->code = 0; + proto->reason = GLOBUS_NULL; + + globus_i_gass_transfer_keyvalue_destroy( + &proto->headers); + + /* + * There may be more headers in our buffer, so + * we should go through the parse loop again, + * maybe + */ + if(proto->response_offset != 0) + { + continue; + } + else + { + goto repost_read; + } + } + else + { + goto put_success_exit; + } + case GLOBUS_GASS_TRANSFER_REQUEST_TYPE_INVALID: + default: + globus_assert(proto->type != + GLOBUS_GASS_TRANSFER_REQUEST_TYPE_INVALID); + globus_assert(GLOBUS_FALSE); + debug_printf(3, (_GTSL("Exiting globus_l_gass_transfer_http_response_callback()\n"))); + return; + } } while(proto->code == 0 || - proto->code == 100); - debug_printf(3, (_GTSL("Exiting globus_l_gass_transfer_http_response_callback()\n"))); + proto->code == 100); + debug_printf(3, (_GTSL("Exiting globus_l_gass_transfer_http_response_callback()\n"))); return; repost_read: if(result != GLOBUS_SUCCESS) { - proto->code = GLOBUS_L_DEFAULT_FAILURE_CODE; - proto->reason = globus_libc_strdup(GLOBUS_L_DEFAULT_FAILURE_REASON); - if(proto->type == GLOBUS_GASS_TRANSFER_REQUEST_TYPE_PUT || - proto->type == GLOBUS_GASS_TRANSFER_REQUEST_TYPE_APPEND) + proto->code = GLOBUS_L_DEFAULT_FAILURE_CODE; + proto->reason = globus_libc_strdup(GLOBUS_L_DEFAULT_FAILURE_REASON); + if(proto->type == GLOBUS_GASS_TRANSFER_REQUEST_TYPE_PUT || + proto->type == GLOBUS_GASS_TRANSFER_REQUEST_TYPE_APPEND) + { + goto put_fail_exit; + } + else { - goto put_fail_exit; - } - else - { - goto deny_exit; - } + goto deny_exit; + } } /* Reallocate a larger buffer, if we need to */ if(proto->response_buflen == proto->response_offset) { - globus_byte_t * tmp; - tmp = globus_libc_realloc(proto->response_buffer, - proto->response_buflen * - 2 * - sizeof(globus_byte_t)); - if(tmp == GLOBUS_NULL) - { - proto->code = GLOBUS_L_MALLOC_FAILURE_CODE; - proto->reason = globus_libc_strdup(GLOBUS_L_MALLOC_FAILURE_REASON); - - goto deny_exit; - } - else - { - proto->response_buffer = tmp; - proto->response_buflen *= 2; - } + globus_byte_t * tmp; + tmp = globus_libc_realloc(proto->response_buffer, + proto->response_buflen * + 2 * + sizeof(globus_byte_t)); + if(tmp == GLOBUS_NULL) + { + proto->code = GLOBUS_L_MALLOC_FAILURE_CODE; + proto->reason = globus_libc_strdup(GLOBUS_L_MALLOC_FAILURE_REASON); + + goto deny_exit; + } + else + { + proto->response_buffer = tmp; + proto->response_buflen *= 2; + } } /* Register another read */ debug_printf(4,(_GTSL("%s(): Registering read on %p\n"), - myname, - &proto->handle)); + myname, + &proto->handle)); result = globus_io_register_read(&proto->handle, - proto->response_buffer + - proto->response_offset, - proto->response_buflen - - proto->response_offset, - 1, - globus_l_gass_transfer_http_response_callback, - proto); + proto->response_buffer + + proto->response_offset, + proto->response_buflen - + proto->response_offset, + 1, + globus_l_gass_transfer_http_response_callback, + proto); if(result != GLOBUS_SUCCESS) { - /* TODO interpret the error object */ - goto deny_exit; + /* TODO interpret the error object */ + goto deny_exit; } globus_l_gass_transfer_http_unlock(); - debug_printf(3, (_GTSL("Exiting globus_l_gass_transfer_http_response_callback()\n"))); + debug_printf(3, (_GTSL("Exiting globus_l_gass_transfer_http_response_callback()\n"))); return; deny_exit: if(err) { - globus_object_free(err); + globus_object_free(err); } /* @@ -3617,50 +3615,50 @@ globus_l_gass_transfer_http_response_callback( { globus_l_gass_transfer_http_close(proto); } - + globus_l_gass_transfer_http_unlock(); debug_printf(2, (_GTSL("calling globus_gass_transfer_proto_request_denied"))); globus_gass_transfer_proto_request_denied(request, - code, - reason); - debug_printf(3, (_GTSL("Exiting globus_l_gass_transfer_http_response_callback()\n"))); + code, + reason); + debug_printf(3, (_GTSL("Exiting globus_l_gass_transfer_http_response_callback()\n"))); return; put_success_exit: { - globus_byte_t * buffer; - globus_size_t offset; - globus_bool_t failure; + globus_byte_t * buffer; + globus_size_t offset; + globus_bool_t failure; + + buffer = proto->user_buffer; + offset = proto->user_offset; + failure = proto->failure_occurred; - buffer = proto->user_buffer; - offset = proto->user_offset; - failure = proto->failure_occurred; - - /* - * success response from a server, signal this to the GASS system - */ - globus_assert(proto->state == GLOBUS_GASS_TRANSFER_HTTP_STATE_PENDING); - result = globus_l_gass_transfer_http_register_close(proto); + /* + * success response from a server, signal this to the GASS system + */ + globus_assert(proto->state == GLOBUS_GASS_TRANSFER_HTTP_STATE_PENDING); + result = globus_l_gass_transfer_http_register_close(proto); if (result != GLOBUS_SUCCESS) { globus_l_gass_transfer_http_close(proto); } - - globus_l_gass_transfer_http_unlock(); - debug_printf(2, (_GTSL("calling globus_gass_transfer_proto_send_complete()"))); - globus_gass_transfer_proto_send_complete(request, - buffer, - offset, - failure, - GLOBUS_TRUE); - debug_printf(3, (_GTSL("Exiting globus_l_gass_transfer_http_response_callback()\n"))); - return; + globus_l_gass_transfer_http_unlock(); + debug_printf(2, (_GTSL("calling globus_gass_transfer_proto_send_complete()"))); + globus_gass_transfer_proto_send_complete(request, + buffer, + offset, + failure, + GLOBUS_TRUE); + + debug_printf(3, (_GTSL("Exiting globus_l_gass_transfer_http_response_callback()\n"))); + return; } put_fail_exit: - /* + /* * request failed after a put or append operation. We * need to signal the failure to the GASS system */ @@ -3669,38 +3667,38 @@ globus_l_gass_transfer_http_response_callback( if(proto->waiting_for_response) { - globus_byte_t * buffer; - globus_size_t offset; - int failed = proto->failure_occurred; - + globus_byte_t * buffer; + globus_size_t offset; + int failed = proto->failure_occurred; - buffer = proto->user_buffer; - offset = proto->user_offset; - result = globus_l_gass_transfer_http_register_close(proto); + buffer = proto->user_buffer; + offset = proto->user_offset; + + result = globus_l_gass_transfer_http_register_close(proto); if (result != GLOBUS_SUCCESS) { globus_l_gass_transfer_http_close(proto); } - - globus_l_gass_transfer_http_unlock(); - debug_printf(2, (_GTSL("calling globus_gass_transfer_proto_send_complete()"))); - globus_gass_transfer_proto_send_complete(request, - buffer, - offset, - failed, - GLOBUS_TRUE); - debug_printf(3, (_GTSL("Exiting globus_l_gass_transfer_http_response_callback()\n"))); - return; + + globus_l_gass_transfer_http_unlock(); + debug_printf(2, (_GTSL("calling globus_gass_transfer_proto_send_complete()"))); + globus_gass_transfer_proto_send_complete(request, + buffer, + offset, + failed, + GLOBUS_TRUE); + debug_printf(3, (_GTSL("Exiting globus_l_gass_transfer_http_response_callback()\n"))); + return; } else { - proto->failure_occurred = GLOBUS_TRUE; - globus_l_gass_transfer_http_unlock(); + proto->failure_occurred = GLOBUS_TRUE; + globus_l_gass_transfer_http_unlock(); } - debug_printf(3, (_GTSL("Exiting globus_l_gass_transfer_http_response_callback()\n"))); + debug_printf(3, (_GTSL("Exiting globus_l_gass_transfer_http_response_callback()\n"))); } /* globus_l_gass_transfer_http_response_callback() */ @@ -3708,17 +3706,17 @@ globus_l_gass_transfer_http_response_callback( static void globus_l_gass_transfer_http_request_callback( - void * arg, - globus_io_handle_t * handle, - globus_result_t result, - globus_byte_t * buf, - globus_size_t nbytes) + void * arg, + globus_io_handle_t * handle, + globus_result_t result, + globus_byte_t * buf, + globus_size_t nbytes) { - globus_gass_transfer_http_request_proto_t * proto; - globus_gass_transfer_http_listener_proto_t * l_proto; - globus_object_t * err=GLOBUS_NULL; - char * value; - globus_gass_transfer_request_t request; + globus_gass_transfer_http_request_proto_t * proto; + globus_gass_transfer_http_listener_proto_t * l_proto; + globus_object_t * err=GLOBUS_NULL; + char * value; + globus_gass_transfer_request_t request; MYNAME(globus_l_gass_transfer_http_request_callback); debug_printf(3, (_GTSL("Entering %s()\n"),myname)); @@ -3729,21 +3727,21 @@ globus_l_gass_transfer_http_request_callback( { char * tmpstr; - err = globus_error_get(result); - tmpstr = globus_object_printable_to_string(err); - debug_printf(5, (_GTSL("globus_l_gass_transfer_http_read_callback(): %s"), tmpstr)); - globus_libc_free(tmpstr); + err = globus_error_get(result); + tmpstr = globus_object_printable_to_string(err); + debug_printf(5, (_GTSL("globus_l_gass_transfer_http_read_callback(): %s"), tmpstr)); + globus_libc_free(tmpstr); } globus_l_gass_transfer_http_lock(); request = proto->request; - + /* Did the read succeed? */ if(result != GLOBUS_SUCCESS && !globus_io_eof(err)) { - goto deny_exit; + goto deny_exit; } /* Update our counters */ @@ -3752,74 +3750,74 @@ globus_l_gass_transfer_http_request_callback( /* Parse the buffer that we have */ if(globus_l_gass_transfer_http_parse_request(proto)) { - /* returns true, if we need to read some more */ - if(proto->parsed_offset == 0 && - proto->response_offset > 0 && - !isupper(proto->response_buffer[0])) - { - goto deny_exit; - } - goto repost_read; + /* returns true, if we need to read some more */ + if(proto->parsed_offset == 0 && + proto->response_offset > 0 && + !isupper(proto->response_buffer[0])) + { + goto deny_exit; + } + goto repost_read; } else if(proto->parse_error) { - goto deny_exit; + goto deny_exit; } else if(strcmp(proto->uri, "*") == 0) { - /* Request we don't handle */ - goto deny_exit; + /* Request we don't handle */ + goto deny_exit; } else if(strcmp(proto->method, "GET") == 0) { - proto->type = GLOBUS_GASS_TRANSFER_REQUEST_TYPE_GET; + proto->type = GLOBUS_GASS_TRANSFER_REQUEST_TYPE_GET; } else if(strcmp(proto->method, "PUT") == 0) { - proto->type = GLOBUS_GASS_TRANSFER_REQUEST_TYPE_PUT; + proto->type = GLOBUS_GASS_TRANSFER_REQUEST_TYPE_PUT; } else if(strcmp(proto->method, "POST") == 0 && - strncmp(proto->uri, - GLOBUS_L_APPEND_URI, - strlen(GLOBUS_L_APPEND_URI)) == 0) + strncmp(proto->uri, + GLOBUS_L_APPEND_URI, + strlen(GLOBUS_L_APPEND_URI)) == 0) { - globus_size_t append_len; - globus_size_t uri_len; + globus_size_t append_len; + globus_size_t uri_len; - append_len = strlen(GLOBUS_L_APPEND_URI); - uri_len = strlen(proto->uri) - strlen(GLOBUS_L_APPEND_URI); + append_len = strlen(GLOBUS_L_APPEND_URI); + uri_len = strlen(proto->uri) - strlen(GLOBUS_L_APPEND_URI); - proto->type = GLOBUS_GASS_TRANSFER_REQUEST_TYPE_APPEND; - memmove(proto->uri, - proto->uri + append_len, - uri_len); - proto->uri[uri_len] = '\0'; + proto->type = GLOBUS_GASS_TRANSFER_REQUEST_TYPE_APPEND; + memmove(proto->uri, + proto->uri + append_len, + uri_len); + proto->uri[uri_len] = '\0'; } else { - /* Unknown/Unsupported method */ - goto deny_exit; + /* Unknown/Unsupported method */ + goto deny_exit; } globus_gass_transfer_request_set_type(proto->request, - proto->type); + proto->type); /* Construct URL for this request */ if(strncmp(proto->uri, "https://", strlen("https://")) == 0 || strncmp(proto->uri, "http://", strlen("http://")) == 0) { - globus_gass_transfer_request_set_url(proto->request, - proto->uri); + globus_gass_transfer_request_set_url(proto->request, + proto->uri); } else { - char * url_base; - char * url; + char * url_base; + char * url; - url_base = globus_gass_transfer_listener_get_base_url(l_proto->listener); - url = globus_malloc(strlen(url_base) + strlen(proto->uri) + 1); - sprintf(url, "%s%s", url_base, proto->uri); - globus_gass_transfer_request_set_url(proto->request, - url); + url_base = globus_gass_transfer_listener_get_base_url(l_proto->listener); + url = globus_malloc(strlen(url_base) + strlen(proto->uri) + 1); + sprintf(url, "%s%s", url_base, proto->uri); + globus_gass_transfer_request_set_url(proto->request, + url); } /* @@ -3827,94 +3825,94 @@ globus_l_gass_transfer_http_request_callback( * care about */ value = globus_i_gass_transfer_keyvalue_lookup( - &proto->headers, - "transfer-encoding"); + &proto->headers, + "transfer-encoding"); if(value) { - char * tmp; + char * tmp; - for(tmp = value; *tmp != '\0'; tmp++) - { - if(! isspace(*tmp)) - { - break; - } - } + for(tmp = value; *tmp != '\0'; tmp++) + { + if(! isspace(*tmp)) + { + break; + } + } #ifndef TARGET_ARCH_WIN32 - if(strncasecmp(tmp, "chunked", strlen("chunked")) == 0) + if(strncasecmp(tmp, "chunked", strlen("chunked")) == 0) #else - if(strnicmp(tmp, "chunked", strlen("chunked")) == 0) + if(strnicmp(tmp, "chunked", strlen("chunked")) == 0) #endif - { - proto->recv_buffer = - globus_l_gass_transfer_http_receive; - proto->chunked = GLOBUS_TRUE; - proto->recv_state = - GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_CHUNK_SIZE; - proto->length = 0; - } + { + proto->recv_buffer = + globus_l_gass_transfer_http_receive; + proto->chunked = GLOBUS_TRUE; + proto->recv_state = + GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_CHUNK_SIZE; + proto->length = 0; + } } if(!proto->chunked) { - /* If both - * Transfer-Encoding: chunked and - * Content-Length: - * are passed, the Content-length should be ignored, - * according to RFC 2068 - */ - value = globus_i_gass_transfer_keyvalue_lookup( - &proto->headers, - "content-length"); - - if(value) - { - int save_errno; - char * tmp; - - for(tmp = value; *tmp != '\0'; tmp++) - { - if(! isspace(*tmp)) - { - break; - } - } - globus_libc_lock(); - errno=0; - proto->length = strtoul(tmp, - GLOBUS_NULL, - 10); - save_errno=errno; - globus_libc_unlock(); - if(save_errno != 0) - { - proto->code = GLOBUS_L_PROTOCOL_FAILURE_CODE; - proto->reason = globus_libc_strdup( - GLOBUS_L_PROTOCOL_FAILURE_REASON); - goto deny_exit; - } - if(proto->length == 0) - { - proto->recv_state = - GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_ERROR; - } - else - { - proto->recv_state = - GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_UNTIL_LENGTH; - } - } - else - { - proto->recv_state = - GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_UNTIL_EOF; - } - - if(!proto->text_mode) - { - globus_gass_transfer_request_set_length(proto->request, - proto->length); - - } + /* If both + * Transfer-Encoding: chunked and + * Content-Length: + * are passed, the Content-length should be ignored, + * according to RFC 2068 + */ + value = globus_i_gass_transfer_keyvalue_lookup( + &proto->headers, + "content-length"); + + if(value) + { + int save_errno; + char * tmp; + + for(tmp = value; *tmp != '\0'; tmp++) + { + if(! isspace(*tmp)) + { + break; + } + } + globus_libc_lock(); + errno=0; + proto->length = strtoul(tmp, + GLOBUS_NULL, + 10); + save_errno=errno; + globus_libc_unlock(); + if(save_errno != 0) + { + proto->code = GLOBUS_L_PROTOCOL_FAILURE_CODE; + proto->reason = globus_libc_strdup( + GLOBUS_L_PROTOCOL_FAILURE_REASON); + goto deny_exit; + } + if(proto->length == 0) + { + proto->recv_state = + GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_ERROR; + } + else + { + proto->recv_state = + GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_UNTIL_LENGTH; + } + } + else + { + proto->recv_state = + GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_UNTIL_EOF; + } + + if(!proto->text_mode) + { + globus_gass_transfer_request_set_length(proto->request, + proto->length); + + } } /* * The response buffer's residue may contain some @@ -3922,20 +3920,20 @@ globus_l_gass_transfer_http_request_callback( * Also, if we are in text mode, we'll have to copy * the data anyway (but should use the block_size) */ - + if(proto->text_mode && proto->block_size > proto->response_buflen) { - globus_byte_t * tmp; + globus_byte_t * tmp; - tmp = globus_libc_realloc(proto->response_buffer, - proto->block_size * - sizeof(globus_byte_t)); - if(tmp != GLOBUS_NULL) - { - proto->response_buffer = tmp; - proto->response_buflen = proto->block_size; - } + tmp = globus_libc_realloc(proto->response_buffer, + proto->block_size * + sizeof(globus_byte_t)); + if(tmp != GLOBUS_NULL) + { + proto->response_buffer = tmp; + proto->response_buflen = proto->block_size; + } } @@ -3944,16 +3942,16 @@ globus_l_gass_transfer_http_request_callback( proto->state = GLOBUS_GASS_TRANSFER_HTTP_STATE_IDLE; if(proto->connected_subject) { - globus_gass_transfer_request_set_subject(proto->request, - globus_libc_strdup(proto->connected_subject)); + globus_gass_transfer_request_set_subject(proto->request, + globus_libc_strdup(proto->connected_subject)); } globus_l_gass_transfer_http_unlock(); globus_gass_transfer_proto_new_listener_request( - l_proto->listener, - proto->request, - (globus_gass_transfer_request_proto_t *) proto); + l_proto->listener, + proto->request, + (globus_gass_transfer_request_proto_t *) proto); debug_printf(3, (_GTSL("Exiting globus_l_gass_transfer_http_request_callback()\n"))); @@ -3962,47 +3960,47 @@ globus_l_gass_transfer_http_request_callback( repost_read: if(result != GLOBUS_SUCCESS) { - goto deny_exit; + goto deny_exit; } /* Reallocate a larger buffer, if we need to */ if(proto->response_buflen == proto->response_offset) { - globus_byte_t * tmp; - tmp = globus_libc_realloc(proto->response_buffer, - proto->response_buflen * - 2 * - sizeof(globus_byte_t)); - if(tmp == GLOBUS_NULL) - { - proto->code = GLOBUS_L_MALLOC_FAILURE_CODE; - proto->reason = globus_libc_strdup(GLOBUS_L_MALLOC_FAILURE_REASON); - - goto deny_exit; - } - else - { - proto->response_buffer = tmp; - proto->response_buflen *= 2; - } + globus_byte_t * tmp; + tmp = globus_libc_realloc(proto->response_buffer, + proto->response_buflen * + 2 * + sizeof(globus_byte_t)); + if(tmp == GLOBUS_NULL) + { + proto->code = GLOBUS_L_MALLOC_FAILURE_CODE; + proto->reason = globus_libc_strdup(GLOBUS_L_MALLOC_FAILURE_REASON); + + goto deny_exit; + } + else + { + proto->response_buffer = tmp; + proto->response_buflen *= 2; + } } /* Register another read */ debug_printf(4,(_GTSL("%s(): Registering read on %p\n"), - myname, - &proto->handle)); + myname, + &proto->handle)); result = globus_io_register_read(&proto->handle, - proto->response_buffer + - proto->response_offset, - proto->response_buflen - - proto->response_offset, - 1, - globus_l_gass_transfer_http_request_callback, - l_proto); + proto->response_buffer + + proto->response_offset, + proto->response_buflen - + proto->response_offset, + 1, + globus_l_gass_transfer_http_request_callback, + l_proto); if(result != GLOBUS_SUCCESS) { - /* TODO interpret the error object */ - goto deny_exit; + /* TODO interpret the error object */ + goto deny_exit; } globus_l_gass_transfer_http_unlock(); @@ -4012,7 +4010,7 @@ globus_l_gass_transfer_http_request_callback( deny_exit: if(err) { - globus_object_free(err); + globus_object_free(err); } /* @@ -4033,13 +4031,13 @@ globus_l_gass_transfer_http_request_callback( { globus_l_gass_transfer_http_close(proto); } - + globus_l_gass_transfer_http_unlock(); globus_gass_transfer_proto_new_listener_request( - l_proto->listener, - request, - (globus_gass_transfer_request_proto_t *) GLOBUS_NULL); + l_proto->listener, + request, + (globus_gass_transfer_request_proto_t *) GLOBUS_NULL); debug_printf(3, (_GTSL("Exiting globus_l_gass_transfer_http_request_callback()\n"))); return; @@ -4049,21 +4047,21 @@ globus_l_gass_transfer_http_request_callback( static void globus_l_gass_transfer_http_callback_send_callback( - void * arg) + void * arg) { - globus_gass_transfer_http_request_proto_t * proto; + globus_gass_transfer_http_request_proto_t * proto; MYNAME(globus_l_gass_transfer_http_callback_send_callback); debug_printf(3, (_GTSL("Entering %s()\n"),myname)); - + proto = (globus_gass_transfer_http_request_proto_t *) arg; debug_printf(2, (_GTSL("calling globus_gass_transfer_proto_send_complete()"))); globus_gass_transfer_proto_send_complete(proto->request, - proto->user_buffer, - proto->user_offset, - proto->failure_occurred, - proto->failure_occurred); + proto->user_buffer, + proto->user_offset, + proto->failure_occurred, + proto->failure_occurred); debug_printf(3, (_GTSL("Exiting globus_l_gass_transfer_http_callback_send_callback()\n"))); } @@ -4071,23 +4069,23 @@ globus_l_gass_transfer_http_callback_send_callback( static void globus_l_gass_transfer_http_callback_ready_callback( - void * arg) + void * arg) { - globus_gass_transfer_http_request_proto_t * proto; + globus_gass_transfer_http_request_proto_t * proto; proto = (globus_gass_transfer_http_request_proto_t *) arg; debug_printf(2, (_GTSL("calling globus_gass_transfer_proto_request_ready"))); globus_gass_transfer_proto_request_ready(proto->request, - (globus_gass_transfer_request_proto_t *) proto); + (globus_gass_transfer_request_proto_t *) proto); } /* globus_l_gass_transfer_http_callback_read_buffered_callback() */ static void globus_l_gass_transfer_http_callback_read_buffered_callback( - void * arg) + void * arg) { - globus_gass_transfer_http_request_proto_t * proto; + globus_gass_transfer_http_request_proto_t * proto; proto = (globus_gass_transfer_http_request_proto_t *) arg; @@ -4099,11 +4097,11 @@ globus_l_gass_transfer_http_callback_read_buffered_callback( globus_l_gass_transfer_http_unlock(); globus_l_gass_transfer_http_read_buffered_callback(arg, - &proto->handle, - GLOBUS_SUCCESS, - proto->response_buffer + - proto->response_offset, - 0); + &proto->handle, + GLOBUS_SUCCESS, + proto->response_buffer + + proto->response_offset, + 0); } /* globus_l_gass_transfer_http_callback_read_buffered_callback() */ @@ -4111,10 +4109,10 @@ globus_l_gass_transfer_http_callback_read_buffered_callback( static void globus_l_gass_transfer_http_callback_listen_callback( - void * arg) + void * arg) { globus_gass_transfer_http_listener_proto_t *proto; - globus_gass_transfer_listener_t listener; + globus_gass_transfer_listener_t listener; proto = (globus_gass_transfer_http_listener_proto_t *) arg; @@ -4122,7 +4120,7 @@ globus_l_gass_transfer_http_callback_listen_callback( if(proto->state == GLOBUS_GASS_TRANSFER_HTTP_LISTENER_LISTENING) { - proto->state = GLOBUS_GASS_TRANSFER_HTTP_LISTENER_READY; + proto->state = GLOBUS_GASS_TRANSFER_HTTP_LISTENER_READY; } listener = proto->listener; @@ -4136,21 +4134,21 @@ globus_l_gass_transfer_http_callback_listen_callback( static void globus_l_gass_transfer_http_accept( - globus_gass_transfer_listener_proto_t * proto, - globus_gass_transfer_listener_t listener, - globus_gass_transfer_request_t request, - globus_gass_transfer_requestattr_t * attr) + globus_gass_transfer_listener_proto_t * proto, + globus_gass_transfer_listener_t listener, + globus_gass_transfer_request_t request, + globus_gass_transfer_requestattr_t * attr) { - globus_result_t result; - globus_io_attr_t tcp_attr; + globus_result_t result; + globus_io_attr_t tcp_attr; globus_gass_transfer_http_listener_proto_t * - l_proto; - int rc; - int sndbuf; - int rcvbuf; - globus_bool_t nodelay; - globus_gass_transfer_file_mode_t file_mode=GLOBUS_GASS_TRANSFER_FILE_MODE_BINARY; - globus_io_secure_authorization_data_t data; + l_proto; + int rc; + int sndbuf; + int rcvbuf; + globus_bool_t nodelay; + globus_gass_transfer_file_mode_t file_mode=GLOBUS_GASS_TRANSFER_FILE_MODE_BINARY; + globus_io_secure_authorization_data_t data; globus_l_gass_transfer_failed_kickout_closure_t *kickout; globus_reltime_t delay_time; MYNAME(globus_l_gass_transfer_http_accept); @@ -4159,193 +4157,193 @@ globus_l_gass_transfer_http_accept( l_proto = (globus_gass_transfer_http_listener_proto_t *) proto; /* Allocate proto instance */ - l_proto->request = (globus_gass_transfer_http_request_proto_t *) - globus_malloc(sizeof(globus_gass_transfer_http_request_proto_t)); + l_proto->request = (globus_gass_transfer_http_request_proto_t *) + globus_malloc(sizeof(globus_gass_transfer_http_request_proto_t)); if(l_proto->request == GLOBUS_NULL) { - goto error_exit; + goto error_exit; } result = globus_io_tcpattr_init(&tcp_attr); if(result != GLOBUS_SUCCESS) { - goto proto_error; + goto proto_error; } globus_io_attr_set_socket_keepalive(&tcp_attr, GLOBUS_TRUE); if(attr != GLOBUS_NULL && *attr != GLOBUS_NULL) { - /* Check attributes we care about */ - rc = globus_gass_transfer_requestattr_get_socket_sndbuf( - attr, - &sndbuf); - if(rc != GLOBUS_SUCCESS) - { - goto tcpattr_error; - } - else - { - if(sndbuf != 0) - { - globus_io_attr_set_socket_sndbuf(&tcp_attr, - sndbuf); - } - } - - rc = globus_gass_transfer_requestattr_get_socket_rcvbuf( - attr, - &rcvbuf); - if(rc != GLOBUS_SUCCESS) - { - goto tcpattr_error; - } - else - { - if(rcvbuf != 0) - { - globus_io_attr_set_socket_rcvbuf(&tcp_attr, - rcvbuf); - } - } - - rc = globus_gass_transfer_requestattr_get_socket_nodelay( - attr, - &nodelay); - if(rc != GLOBUS_SUCCESS) - { - goto tcpattr_error; - } - else - { - globus_io_attr_set_tcp_nodelay(&tcp_attr, - nodelay); - } - - /* File mode is important on Windows */ - rc = globus_gass_transfer_requestattr_get_file_mode(attr, - &file_mode); - if(rc != GLOBUS_SUCCESS) - { - goto tcpattr_error; - } - rc = globus_gass_transfer_requestattr_get_block_size( - attr, - &l_proto->request->block_size); - if(rc != GLOBUS_SUCCESS) - { - goto tcpattr_error; - } + /* Check attributes we care about */ + rc = globus_gass_transfer_requestattr_get_socket_sndbuf( + attr, + &sndbuf); + if(rc != GLOBUS_SUCCESS) + { + goto tcpattr_error; + } + else + { + if(sndbuf != 0) + { + globus_io_attr_set_socket_sndbuf(&tcp_attr, + sndbuf); + } + } + + rc = globus_gass_transfer_requestattr_get_socket_rcvbuf( + attr, + &rcvbuf); + if(rc != GLOBUS_SUCCESS) + { + goto tcpattr_error; + } + else + { + if(rcvbuf != 0) + { + globus_io_attr_set_socket_rcvbuf(&tcp_attr, + rcvbuf); + } + } + + rc = globus_gass_transfer_requestattr_get_socket_nodelay( + attr, + &nodelay); + if(rc != GLOBUS_SUCCESS) + { + goto tcpattr_error; + } + else + { + globus_io_attr_set_tcp_nodelay(&tcp_attr, + nodelay); + } + + /* File mode is important on Windows */ + rc = globus_gass_transfer_requestattr_get_file_mode(attr, + &file_mode); + if(rc != GLOBUS_SUCCESS) + { + goto tcpattr_error; + } + rc = globus_gass_transfer_requestattr_get_block_size( + attr, + &l_proto->request->block_size); + if(rc != GLOBUS_SUCCESS) + { + goto tcpattr_error; + } } /* If https, set security attributes for the request */ if(l_proto->url_scheme == GLOBUS_URL_SCHEME_HTTPS) { - globus_result_t result; - - - globus_io_secure_authorization_data_initialize(&data); - - result = globus_io_attr_set_secure_authentication_mode( - &tcp_attr, - GLOBUS_IO_SECURE_AUTHENTICATION_MODE_MUTUAL, - GLOBUS_NULL); - - if(result != GLOBUS_SUCCESS) - { - goto free_auth_data; - } - result = globus_io_attr_set_secure_channel_mode( - &tcp_attr, - GLOBUS_IO_SECURE_CHANNEL_MODE_SSL_WRAP); - - if(result != GLOBUS_SUCCESS) - { - goto free_auth_data; - } - if(attr != GLOBUS_NULL) - { - if(*attr != GLOBUS_NULL) - { - rc = globus_gass_transfer_secure_requestattr_get_authorization( - attr, - &l_proto->request->authorization_mode, - &l_proto->request->authorized_subject); - - if(rc != GLOBUS_SUCCESS) - { - goto free_auth_data; - } - } - } - result = globus_io_secure_authorization_data_set_callback( - &data, - globus_l_gass_transfer_http_authorization_callback, - proto); - - if(result != GLOBUS_SUCCESS) - { - goto free_auth_data; - } - - result = globus_io_attr_set_secure_authorization_mode( - &tcp_attr, - GLOBUS_IO_SECURE_AUTHORIZATION_MODE_CALLBACK, - &data); - - if(result != GLOBUS_SUCCESS) - { - goto free_auth_data; - } - globus_io_secure_authorization_data_destroy(&data); + globus_result_t result; + + + globus_io_secure_authorization_data_initialize(&data); + + result = globus_io_attr_set_secure_authentication_mode( + &tcp_attr, + GLOBUS_IO_SECURE_AUTHENTICATION_MODE_MUTUAL, + GLOBUS_NULL); + + if(result != GLOBUS_SUCCESS) + { + goto free_auth_data; + } + result = globus_io_attr_set_secure_channel_mode( + &tcp_attr, + GLOBUS_IO_SECURE_CHANNEL_MODE_SSL_WRAP); + + if(result != GLOBUS_SUCCESS) + { + goto free_auth_data; + } + if(attr != GLOBUS_NULL) + { + if(*attr != GLOBUS_NULL) + { + rc = globus_gass_transfer_secure_requestattr_get_authorization( + attr, + &l_proto->request->authorization_mode, + &l_proto->request->authorized_subject); + + if(rc != GLOBUS_SUCCESS) + { + goto free_auth_data; + } + } + } + result = globus_io_secure_authorization_data_set_callback( + &data, + globus_l_gass_transfer_http_authorization_callback, + proto); + + if(result != GLOBUS_SUCCESS) + { + goto free_auth_data; + } + + result = globus_io_attr_set_secure_authorization_mode( + &tcp_attr, + GLOBUS_IO_SECURE_AUTHORIZATION_MODE_CALLBACK, + &data); + + if(result != GLOBUS_SUCCESS) + { + goto free_auth_data; + } + globus_io_secure_authorization_data_destroy(&data); } /* Initialize the proto instance */ l_proto->request->send_buffer= globus_l_gass_transfer_http_send; - l_proto->request->recv_buffer = globus_l_gass_transfer_http_receive; - l_proto->request->fail = globus_l_gass_transfer_http_fail; - l_proto->request->deny = globus_l_gass_transfer_http_request_deny; - l_proto->request->refer = globus_l_gass_transfer_http_request_refer; - l_proto->request->authorize = globus_l_gass_transfer_http_request_authorize; - l_proto->request->destroy = globus_l_gass_transfer_http_destroy; - l_proto->request->text_mode = (file_mode == GLOBUS_GASS_TRANSFER_FILE_MODE_TEXT); - l_proto->request->line_mode = GLOBUS_L_LINE_MODE_UNKNOWN; - l_proto->request->state = GLOBUS_GASS_TRANSFER_HTTP_STATE_CONNECTING; - l_proto->request->request = request; - l_proto->request->type = globus_gass_transfer_request_get_type(request); - l_proto->request->code = 0; - l_proto->request->reason = 0; - l_proto->request->parse_error = GLOBUS_FALSE; - l_proto->request->destroy_called = GLOBUS_FALSE; - l_proto->request->headers = GLOBUS_NULL; - l_proto->request->response_buffer = GLOBUS_NULL; - l_proto->request->length = 0; - l_proto->request->handled = 0; - l_proto->request->chunked = GLOBUS_FALSE; - l_proto->request->chunk_left = 0; - l_proto->request->failure_occurred = GLOBUS_FALSE; + l_proto->request->recv_buffer = globus_l_gass_transfer_http_receive; + l_proto->request->fail = globus_l_gass_transfer_http_fail; + l_proto->request->deny = globus_l_gass_transfer_http_request_deny; + l_proto->request->refer = globus_l_gass_transfer_http_request_refer; + l_proto->request->authorize = globus_l_gass_transfer_http_request_authorize; + l_proto->request->destroy = globus_l_gass_transfer_http_destroy; + l_proto->request->text_mode = (file_mode == GLOBUS_GASS_TRANSFER_FILE_MODE_TEXT); + l_proto->request->line_mode = GLOBUS_L_LINE_MODE_UNKNOWN; + l_proto->request->state = GLOBUS_GASS_TRANSFER_HTTP_STATE_CONNECTING; + l_proto->request->request = request; + l_proto->request->type = globus_gass_transfer_request_get_type(request); + l_proto->request->code = 0; + l_proto->request->reason = 0; + l_proto->request->parse_error = GLOBUS_FALSE; + l_proto->request->destroy_called = GLOBUS_FALSE; + l_proto->request->headers = GLOBUS_NULL; + l_proto->request->response_buffer = GLOBUS_NULL; + l_proto->request->length = 0; + l_proto->request->handled = 0; + l_proto->request->chunked = GLOBUS_FALSE; + l_proto->request->chunk_left = 0; + l_proto->request->failure_occurred = GLOBUS_FALSE; l_proto->request->oneshot_registered = GLOBUS_FALSE; - l_proto->request->oneshot_active = GLOBUS_FALSE; - l_proto->request->eof_read = GLOBUS_FALSE; - l_proto->request->method = GLOBUS_NULL; - l_proto->request->uri = GLOBUS_NULL; - l_proto->request->response_offset = 0; - l_proto->request->parsed_offset = 0; - l_proto->request->client_side = GLOBUS_FALSE; - l_proto->request->connected_subject = GLOBUS_NULL; + l_proto->request->oneshot_active = GLOBUS_FALSE; + l_proto->request->eof_read = GLOBUS_FALSE; + l_proto->request->method = GLOBUS_NULL; + l_proto->request->uri = GLOBUS_NULL; + l_proto->request->response_offset = 0; + l_proto->request->parsed_offset = 0; + l_proto->request->client_side = GLOBUS_FALSE; + l_proto->request->connected_subject = GLOBUS_NULL; /* Register accept with new request */ l_proto->state = GLOBUS_GASS_TRANSFER_HTTP_LISTENER_ACCEPTING; debug_printf(4,(_GTSL("%s(): Registering accept on %p\n"), - myname, - &l_proto->handle)); + myname, + &l_proto->handle)); result = globus_io_tcp_register_accept(&l_proto->handle, - &tcp_attr, - &l_proto->request->handle, - globus_l_gass_transfer_http_accept_callback, - l_proto); + &tcp_attr, + &l_proto->request->handle, + globus_l_gass_transfer_http_accept_callback, + l_proto); if(result != GLOBUS_SUCCESS) { goto tcpattr_error; @@ -4370,7 +4368,7 @@ globus_l_gass_transfer_http_accept( GlobusTimeReltimeSet(delay_time, 0, 0); debug_printf(4,(_GTSL("%s(): Registering oneshot\n"), - myname)); + myname)); kickout = globus_libc_malloc( sizeof(globus_l_gass_transfer_failed_kickout_closure_t)); @@ -4379,9 +4377,9 @@ globus_l_gass_transfer_http_accept( globus_callback_register_oneshot( GLOBUS_NULL, - &delay_time, - globus_l_gass_transfer_http_accept_failed_kickout, - kickout); + &delay_time, + globus_l_gass_transfer_http_accept_failed_kickout, + kickout); debug_printf(1, (_GTSL("exiting %s()\n"),myname)); } @@ -4390,10 +4388,10 @@ globus_l_gass_transfer_http_accept( static globus_result_t globus_l_gass_transfer_http_register_read( - globus_gass_transfer_http_request_proto_t * proto) + globus_gass_transfer_http_request_proto_t * proto) { MYNAME(globus_l_gass_transfer_http_register_read); - + /* * If binary, and some chunk data is unread from the handle, * or we are not chunked, we can read directly into the user's @@ -4401,77 +4399,77 @@ globus_l_gass_transfer_http_register_read( * to the user's buffer. */ if(proto->text_mode == GLOBUS_FALSE && - ( - (proto->chunked && - proto->chunk_left > 0 && - proto->recv_state == GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_CHUNK_BODY) || - (proto->chunked == GLOBUS_FALSE) - ) + ( + (proto->chunked && + proto->chunk_left > 0 && + proto->recv_state == GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_CHUNK_BODY) || + (proto->chunked == GLOBUS_FALSE) + ) ) { - globus_size_t minimum; - globus_size_t maximum; - - minimum = proto->user_waitlen; - - if(minimum > proto->user_buflen - proto->user_offset) - { - minimum = proto->user_buflen - proto->user_offset; - } - if(proto->chunked && minimum > proto->chunk_left) - { - minimum = proto->chunk_left; - } - if(proto->length != 0 && - minimum > proto->length - proto->handled) - { - minimum = proto->length - proto->handled; - } - - maximum = proto->user_buflen - proto->user_offset; - - if(proto->chunked && maximum > proto->chunk_left) - { - maximum = proto->chunk_left; - } - if(proto->length != 0 && - maximum > proto->length - proto->handled) - { - maximum = proto->length - proto->handled; - } - - debug_printf(4,(_GTSL("%s(): Registering read on %p\n"), - myname, - &proto->handle)); - return - globus_io_register_read(&proto->handle, - proto->user_buffer + - proto->user_offset, - maximum, - minimum, - globus_l_gass_transfer_http_read_callback, - proto); - } + globus_size_t minimum; + globus_size_t maximum; + + minimum = proto->user_waitlen; + + if(minimum > proto->user_buflen - proto->user_offset) + { + minimum = proto->user_buflen - proto->user_offset; + } + if(proto->chunked && minimum > proto->chunk_left) + { + minimum = proto->chunk_left; + } + if(proto->length != 0 && + minimum > proto->length - proto->handled) + { + minimum = proto->length - proto->handled; + } + + maximum = proto->user_buflen - proto->user_offset; + + if(proto->chunked && maximum > proto->chunk_left) + { + maximum = proto->chunk_left; + } + if(proto->length != 0 && + maximum > proto->length - proto->handled) + { + maximum = proto->length - proto->handled; + } + + debug_printf(4,(_GTSL("%s(): Registering read on %p\n"), + myname, + &proto->handle)); + return + globus_io_register_read(&proto->handle, + proto->user_buffer + + proto->user_offset, + maximum, + minimum, + globus_l_gass_transfer_http_read_callback, + proto); + } else { - /* - * In text mode or in "chunked" mode, we will have - * to buffer the data and then apply some transformation - * to it upon receiving it. - */ - globus_size_t smaller; + /* + * In text mode or in "chunked" mode, we will have + * to buffer the data and then apply some transformation + * to it upon receiving it. + */ + globus_size_t smaller; - smaller = proto->user_waitlen; + smaller = proto->user_waitlen; if (proto->response_buflen - proto->response_offset == 0) { /* if buffer is full, shift unparsed data to buffer head */ - memmove(proto->response_buffer, - proto->response_buffer + proto->parsed_offset, - proto->response_offset - proto->parsed_offset); - proto->response_offset -= proto->parsed_offset; - proto->parsed_offset = 0; + memmove(proto->response_buffer, + proto->response_buffer + proto->parsed_offset, + proto->response_offset - proto->parsed_offset); + proto->response_offset -= proto->parsed_offset; + proto->parsed_offset = 0; } if (proto->response_buflen - proto->response_offset == 0) { @@ -4491,23 +4489,23 @@ globus_l_gass_transfer_http_register_read( proto->response_buflen *= 2; } } - if(smaller > proto->response_buflen - proto->response_offset) - { - smaller = proto->response_buflen - proto->response_offset; - } - - debug_printf(4,(_GTSL("%s(): Registering read on %p\n"), - myname, - &proto->handle)); - return - globus_io_register_read(&proto->handle, - proto->response_buffer + - proto->response_offset, - proto->response_buflen - - proto->response_offset, - smaller, - globus_l_gass_transfer_http_read_buffered_callback, - proto); + if(smaller > proto->response_buflen - proto->response_offset) + { + smaller = proto->response_buflen - proto->response_offset; + } + + debug_printf(4,(_GTSL("%s(): Registering read on %p\n"), + myname, + &proto->handle)); + return + globus_io_register_read(&proto->handle, + proto->response_buffer + + proto->response_offset, + proto->response_buflen - + proto->response_offset, + smaller, + globus_l_gass_transfer_http_read_buffered_callback, + proto); } } @@ -4554,15 +4552,15 @@ globus_l_gass_transfer_http_hex_escape( static char * globus_l_gass_transfer_http_construct_request( - globus_gass_transfer_http_request_proto_t * proto) + globus_gass_transfer_http_request_proto_t * proto) { - globus_size_t cmd_len; - char * cmd = GLOBUS_NULL; - globus_size_t length; - char * url = GLOBUS_NULL; + globus_size_t cmd_len; + char * cmd = GLOBUS_NULL; + globus_size_t length; + char * url = GLOBUS_NULL; /* Construct the request string to send to the server */ - cmd_len = 3; /* for CRLF\0 termination */ + cmd_len = 3; /* for CRLF\0 termination */ cmd_len += strlen(proto->url.host); /* Required for http/1.1*/ if(proto->proxy_connect) { @@ -4573,7 +4571,7 @@ globus_l_gass_transfer_http_construct_request( return NULL; } - cmd_len += strlen(url); + cmd_len += strlen(url); } else { @@ -4583,242 +4581,242 @@ globus_l_gass_transfer_http_construct_request( { return NULL; } - cmd_len += strlen(url); + cmd_len += strlen(url); } switch(proto->type) { case GLOBUS_GASS_TRANSFER_REQUEST_TYPE_GET: - cmd_len += strlen(GLOBUS_L_GET_COMMAND); - cmd = globus_malloc(cmd_len * sizeof(globus_byte_t)); + cmd_len += strlen(GLOBUS_L_GET_COMMAND); + cmd = globus_malloc(cmd_len * sizeof(globus_byte_t)); - if(cmd == GLOBUS_NULL) - { + if(cmd == GLOBUS_NULL) + { globus_libc_free(url); - return GLOBUS_NULL; - } - - sprintf(cmd, - GLOBUS_L_GET_COMMAND, - url, - proto->url.host); - - strcat(cmd, - CRLF); - + return GLOBUS_NULL; + } + + sprintf(cmd, + GLOBUS_L_GET_COMMAND, + url, + proto->url.host); + + strcat(cmd, + CRLF); + globus_libc_free(url); - return cmd; + return cmd; case GLOBUS_GASS_TRANSFER_REQUEST_TYPE_PUT: - cmd_len += strlen(GLOBUS_L_PUT_COMMAND); - cmd_len += 2; - - if(proto->text_mode == GLOBUS_TRUE) - { - cmd_len += strlen(GLOBUS_L_TEXT_HEADER); - } - else - { - cmd_len += strlen(GLOBUS_L_BINARY_HEADER); - } - - length = globus_gass_transfer_request_get_length(proto->request); - if(length != 0) - { - globus_size_t x = length; - globus_size_t digits = 0; - - /* count the number of decimal digits in length */ - do - { - digits++; - x /= 10; - } while(x > 0); - - cmd_len += strlen(GLOBUS_L_CONTENT_LENGTH_HEADER); - cmd_len += digits; - cmd = globus_malloc(cmd_len * sizeof(globus_byte_t)); - - if(cmd == GLOBUS_NULL) - { + cmd_len += strlen(GLOBUS_L_PUT_COMMAND); + cmd_len += 2; + + if(proto->text_mode == GLOBUS_TRUE) + { + cmd_len += strlen(GLOBUS_L_TEXT_HEADER); + } + else + { + cmd_len += strlen(GLOBUS_L_BINARY_HEADER); + } + + length = globus_gass_transfer_request_get_length(proto->request); + if(length != 0) + { + globus_size_t x = length; + globus_size_t digits = 0; + + /* count the number of decimal digits in length */ + do + { + digits++; + x /= 10; + } while(x > 0); + + cmd_len += strlen(GLOBUS_L_CONTENT_LENGTH_HEADER); + cmd_len += digits; + cmd = globus_malloc(cmd_len * sizeof(globus_byte_t)); + + if(cmd == GLOBUS_NULL) + { globus_libc_free(url); - return GLOBUS_NULL; - } - - sprintf((char *) cmd, - GLOBUS_L_PUT_COMMAND, - url, - proto->url.host); - - sprintf(cmd + strlen(cmd), - GLOBUS_L_CONTENT_LENGTH_HEADER, - length); - } - else - { - cmd_len += strlen(GLOBUS_L_CHUNKED_HEADER); - cmd = globus_malloc(cmd_len * sizeof(globus_byte_t)); - proto->chunked = GLOBUS_TRUE; - - /* hex encoding of globus_size_t: two bytes to encode per 8 bits, - * plus a CRLF to end the chunk header - */ - proto->iov[0].iov_base = (void *) - globus_malloc((sizeof(globus_size_t) * 2) + 2); - /* This never changes */ - proto->iov[2].iov_base = CRLF; - proto->iov[2].iov_len = 2; - proto->iov[3].iov_base = "0" CRLF CRLF; - proto->iov[3].iov_len = strlen("0" CRLF CRLF); - - if(cmd == GLOBUS_NULL) - { + return GLOBUS_NULL; + } + + sprintf((char *) cmd, + GLOBUS_L_PUT_COMMAND, + url, + proto->url.host); + + sprintf(cmd + strlen(cmd), + GLOBUS_L_CONTENT_LENGTH_HEADER, + length); + } + else + { + cmd_len += strlen(GLOBUS_L_CHUNKED_HEADER); + cmd = globus_malloc(cmd_len * sizeof(globus_byte_t)); + proto->chunked = GLOBUS_TRUE; + + /* hex encoding of globus_size_t: two bytes to encode per 8 bits, + * plus a CRLF to end the chunk header + */ + proto->iov[0].iov_base = (void *) + globus_malloc((sizeof(globus_size_t) * 2) + 2); + /* This never changes */ + proto->iov[2].iov_base = CRLF; + proto->iov[2].iov_len = 2; + proto->iov[3].iov_base = "0" CRLF CRLF; + proto->iov[3].iov_len = strlen("0" CRLF CRLF); + + if(cmd == GLOBUS_NULL) + { globus_libc_free(url); - return GLOBUS_NULL; - } - - sprintf((char *) cmd, - GLOBUS_L_PUT_COMMAND, - url, - proto->url.host); - - strcat(cmd, - GLOBUS_L_CHUNKED_HEADER); - } - if(proto->text_mode) - { - strcat(cmd, - GLOBUS_L_TEXT_HEADER); - } - else - { - strcat(cmd, - GLOBUS_L_BINARY_HEADER); - } - strcat(cmd, - CRLF); + return GLOBUS_NULL; + } + + sprintf((char *) cmd, + GLOBUS_L_PUT_COMMAND, + url, + proto->url.host); + + strcat(cmd, + GLOBUS_L_CHUNKED_HEADER); + } + if(proto->text_mode) + { + strcat(cmd, + GLOBUS_L_TEXT_HEADER); + } + else + { + strcat(cmd, + GLOBUS_L_BINARY_HEADER); + } + strcat(cmd, + CRLF); globus_libc_free(url); - return cmd; + return cmd; case GLOBUS_GASS_TRANSFER_REQUEST_TYPE_APPEND: - cmd_len += strlen(GLOBUS_L_APPEND_COMMAND); - cmd_len += 2; - - if(proto->text_mode == GLOBUS_TRUE) - { - cmd_len += strlen(GLOBUS_L_TEXT_HEADER); - } - else - { - cmd_len += strlen(GLOBUS_L_BINARY_HEADER); - } - - length = globus_gass_transfer_request_get_length(proto->request); - if(length != 0) - { - globus_size_t x = length; - globus_size_t digits = 0; - - /* count the number of decimal digits in length */ - do - { - digits++; - x /= 10; - } while(x > 0); - - cmd_len += strlen(GLOBUS_L_CONTENT_LENGTH_HEADER); - cmd_len += digits; - cmd = globus_malloc(cmd_len * sizeof(globus_byte_t)); - - if(cmd == GLOBUS_NULL) - { + cmd_len += strlen(GLOBUS_L_APPEND_COMMAND); + cmd_len += 2; + + if(proto->text_mode == GLOBUS_TRUE) + { + cmd_len += strlen(GLOBUS_L_TEXT_HEADER); + } + else + { + cmd_len += strlen(GLOBUS_L_BINARY_HEADER); + } + + length = globus_gass_transfer_request_get_length(proto->request); + if(length != 0) + { + globus_size_t x = length; + globus_size_t digits = 0; + + /* count the number of decimal digits in length */ + do + { + digits++; + x /= 10; + } while(x > 0); + + cmd_len += strlen(GLOBUS_L_CONTENT_LENGTH_HEADER); + cmd_len += digits; + cmd = globus_malloc(cmd_len * sizeof(globus_byte_t)); + + if(cmd == GLOBUS_NULL) + { globus_libc_free(url); - return GLOBUS_NULL; - } - - sprintf((char *) cmd, - GLOBUS_L_APPEND_COMMAND, - url, - proto->url.host); - sprintf((char *) cmd + strlen(cmd), - GLOBUS_L_CONTENT_LENGTH_HEADER, - length); - } - else - { - cmd_len += strlen(GLOBUS_L_CHUNKED_HEADER); - cmd = globus_malloc(cmd_len * sizeof(globus_byte_t)); - proto->chunked = GLOBUS_TRUE; - - /* hex encoding of globus_size_t: two bytes to encode per 8 bits, - * plus a CRLF to end the chunk header - */ - proto->iov[0].iov_base = (void *) - globus_malloc((sizeof(globus_size_t) * 2) + 2); - /* This never changes */ - proto->iov[2].iov_base = CRLF; - proto->iov[2].iov_len = 2; - proto->iov[3].iov_base = "0" CRLF CRLF; - proto->iov[3].iov_len = 5; - - if(cmd == GLOBUS_NULL) - { + return GLOBUS_NULL; + } + + sprintf((char *) cmd, + GLOBUS_L_APPEND_COMMAND, + url, + proto->url.host); + sprintf((char *) cmd + strlen(cmd), + GLOBUS_L_CONTENT_LENGTH_HEADER, + length); + } + else + { + cmd_len += strlen(GLOBUS_L_CHUNKED_HEADER); + cmd = globus_malloc(cmd_len * sizeof(globus_byte_t)); + proto->chunked = GLOBUS_TRUE; + + /* hex encoding of globus_size_t: two bytes to encode per 8 bits, + * plus a CRLF to end the chunk header + */ + proto->iov[0].iov_base = (void *) + globus_malloc((sizeof(globus_size_t) * 2) + 2); + /* This never changes */ + proto->iov[2].iov_base = CRLF; + proto->iov[2].iov_len = 2; + proto->iov[3].iov_base = "0" CRLF CRLF; + proto->iov[3].iov_len = 5; + + if(cmd == GLOBUS_NULL) + { globus_libc_free(url); - return GLOBUS_NULL; - } - - sprintf((char *) cmd, - GLOBUS_L_APPEND_COMMAND, - proto->url.url_path, - proto->url.host); - - strcat(cmd, - GLOBUS_L_CHUNKED_HEADER); - } - if(proto->text_mode) - { - strcat(cmd, - GLOBUS_L_TEXT_HEADER); - } - else - { - strcat(cmd, - GLOBUS_L_BINARY_HEADER); - } - strcat(cmd, - CRLF); + return GLOBUS_NULL; + } + + sprintf((char *) cmd, + GLOBUS_L_APPEND_COMMAND, + proto->url.url_path, + proto->url.host); + + strcat(cmd, + GLOBUS_L_CHUNKED_HEADER); + } + if(proto->text_mode) + { + strcat(cmd, + GLOBUS_L_TEXT_HEADER); + } + else + { + strcat(cmd, + GLOBUS_L_BINARY_HEADER); + } + strcat(cmd, + CRLF); globus_libc_free(url); - return cmd; + return cmd; case GLOBUS_GASS_TRANSFER_REQUEST_TYPE_INVALID: default: - globus_assert(proto->type != - GLOBUS_GASS_TRANSFER_REQUEST_TYPE_INVALID); - globus_assert(GLOBUS_FALSE); + globus_assert(proto->type != + GLOBUS_GASS_TRANSFER_REQUEST_TYPE_INVALID); + globus_assert(GLOBUS_FALSE); globus_libc_free(url); - return GLOBUS_NULL; - } + return GLOBUS_NULL; + } } #endif /* !parser only */ /* * Function: globus_l_gass_transfer_http_parse_response() - * + * * Description: Parse a byte array containing a (maybe) * partial response from the server. - * + * * Parameters: Protocol module this pertains to - * + * * Returns: GLOBUS_TRUE if more headers must be read. - * + * */ static globus_bool_t globus_l_gass_transfer_http_parse_response( - globus_gass_transfer_http_request_proto_t * proto) + globus_gass_transfer_http_request_proto_t * proto) { /* * Parse the HTTP Response @@ -4834,23 +4832,23 @@ globus_l_gass_transfer_http_parse_response( */ if(proto->reason == GLOBUS_NULL) { - if(globus_l_gass_transfer_http_parse_status_line(proto)) - { - goto repost_read; - } - else if(proto->parse_error) - { - goto parse_error; - } + if(globus_l_gass_transfer_http_parse_status_line(proto)) + { + goto repost_read; + } + else if(proto->parse_error) + { + goto parse_error; + } } if(globus_l_gass_transfer_http_parse_headers(proto)) { - goto repost_read; + goto repost_read; } else if(proto->parse_error) { - goto parse_error; + goto parse_error; } return GLOBUS_FALSE; @@ -4865,7 +4863,7 @@ globus_l_gass_transfer_http_parse_response( static globus_bool_t globus_l_gass_transfer_http_parse_request( - globus_gass_transfer_http_request_proto_t * proto) + globus_gass_transfer_http_request_proto_t * proto) { /* * Parse the HTTP Request @@ -4880,23 +4878,23 @@ globus_l_gass_transfer_http_parse_request( */ if(proto->method == GLOBUS_NULL) { - if(globus_l_gass_transfer_http_parse_request_line(proto)) - { - goto repost_read; - } - else if(proto->parse_error) - { - goto parse_error; - } + if(globus_l_gass_transfer_http_parse_request_line(proto)) + { + goto repost_read; + } + else if(proto->parse_error) + { + goto parse_error; + } } if(globus_l_gass_transfer_http_parse_headers(proto)) { - goto repost_read; + goto repost_read; } else if(proto->parse_error) { - goto parse_error; + goto parse_error; } return GLOBUS_FALSE; @@ -4911,11 +4909,11 @@ globus_l_gass_transfer_http_parse_request( static globus_bool_t globus_l_gass_transfer_http_parse_status_line( - globus_gass_transfer_http_request_proto_t * proto) + globus_gass_transfer_http_request_proto_t * proto) { - globus_size_t offset; - globus_size_t reason_offset; - int r_offset; + globus_size_t offset; + globus_size_t reason_offset; + int r_offset; offset = 0; /* @@ -4923,41 +4921,41 @@ globus_l_gass_transfer_http_parse_status_line( * HTTP-Version = "HTTP" "/" 1*DIGIT "." 1*DIGIT */ if(!globus_l_gass_transfer_http_find_crlf( - proto->response_buffer + proto->parsed_offset, - proto->response_offset - proto->parsed_offset, - &offset)) + proto->response_buffer + proto->parsed_offset, + proto->response_offset - proto->parsed_offset, + &offset)) { - return GLOBUS_TRUE; + return GLOBUS_TRUE; } /* Replace CRLF with NULL */ proto->response_buffer[proto->parsed_offset + offset] = '\0'; if(sscanf((char *) proto->response_buffer + proto->parsed_offset, - "HTTP/%d.%d %d %n", - &proto->major, - &proto->minor, - &proto->code, - &r_offset) != 3) - { - /* Not a HTTP response */ - if(proto->code == 0) - { - proto->code = - GLOBUS_L_PROTOCOL_FAILURE_CODE; - proto->reason = - globus_libc_strdup(GLOBUS_L_PROTOCOL_FAILURE_REASON); - } - proto->parsed_offset += offset; - /* skip the CRLF, as well */ - proto->parsed_offset+=2; - - goto parse_error; + "HTTP/%d.%d %d %n", + &proto->major, + &proto->minor, + &proto->code, + &r_offset) != 3) + { + /* Not a HTTP response */ + if(proto->code == 0) + { + proto->code = + GLOBUS_L_PROTOCOL_FAILURE_CODE; + proto->reason = + globus_libc_strdup(GLOBUS_L_PROTOCOL_FAILURE_REASON); + } + proto->parsed_offset += offset; + /* skip the CRLF, as well */ + proto->parsed_offset+=2; + + goto parse_error; } reason_offset = (globus_size_t) r_offset; proto->reason = globus_libc_strdup((char *) (proto->response_buffer + - proto->parsed_offset + - reason_offset)); + proto->parsed_offset + + reason_offset)); proto->parsed_offset += offset; /* skip the CRLF, as well */ proto->parsed_offset+=2; @@ -4974,9 +4972,9 @@ globus_l_gass_transfer_http_parse_status_line( static globus_bool_t globus_l_gass_transfer_http_parse_request_line( - globus_gass_transfer_http_request_proto_t * proto) + globus_gass_transfer_http_request_proto_t * proto) { - globus_size_t offset; + globus_size_t offset; offset = 0; /* @@ -4993,11 +4991,11 @@ globus_l_gass_transfer_http_parse_request_line( * extension-method = token */ if(!globus_l_gass_transfer_http_find_crlf( - proto->response_buffer + proto->parsed_offset, - proto->response_offset - proto->parsed_offset, - &offset)) + proto->response_buffer + proto->parsed_offset, + proto->response_offset - proto->parsed_offset, + &offset)) { - return GLOBUS_TRUE; + return GLOBUS_TRUE; } /* Replace CRLF with NULL */ proto->response_buffer[proto->parsed_offset + offset] = '\0'; @@ -5006,25 +5004,25 @@ globus_l_gass_transfer_http_parse_request_line( proto->uri = globus_malloc(offset); if(sscanf((char *) proto->response_buffer + proto->parsed_offset, - "%s %s HTTP/%d.%d", - proto->method, - proto->uri, - &proto->major, - &proto->minor) != 4) - { - /* Not a HTTP request */ - if(proto->code == 0) - { - proto->code = - GLOBUS_L_PROTOCOL_FAILURE_CODE; - proto->reason = - globus_libc_strdup(GLOBUS_L_PROTOCOL_FAILURE_REASON); - } - proto->parsed_offset += offset; - /* skip the CRLF, as well */ - proto->parsed_offset+=2; - - goto parse_error; + "%s %s HTTP/%d.%d", + proto->method, + proto->uri, + &proto->major, + &proto->minor) != 4) + { + /* Not a HTTP request */ + if(proto->code == 0) + { + proto->code = + GLOBUS_L_PROTOCOL_FAILURE_CODE; + proto->reason = + globus_libc_strdup(GLOBUS_L_PROTOCOL_FAILURE_REASON); + } + proto->parsed_offset += offset; + /* skip the CRLF, as well */ + proto->parsed_offset+=2; + + goto parse_error; } /* skip the CRLF, as well */ @@ -5041,21 +5039,21 @@ globus_l_gass_transfer_http_parse_request_line( static globus_bool_t globus_l_gass_transfer_http_parse_headers( - globus_gass_transfer_http_request_proto_t * proto) + globus_gass_transfer_http_request_proto_t * proto) { - globus_bool_t all_headers = GLOBUS_FALSE; + globus_bool_t all_headers = GLOBUS_FALSE; while(!all_headers) { - if(globus_l_gass_transfer_http_parse_one_header(proto, - &all_headers)) - { - return GLOBUS_TRUE; - } - else if(proto->parse_error) - { - return GLOBUS_FALSE; - } + if(globus_l_gass_transfer_http_parse_one_header(proto, + &all_headers)) + { + return GLOBUS_TRUE; + } + else if(proto->parse_error) + { + return GLOBUS_FALSE; + } } return GLOBUS_FALSE; } @@ -5064,22 +5062,22 @@ globus_l_gass_transfer_http_parse_headers( static globus_bool_t globus_l_gass_transfer_http_parse_one_header( - globus_gass_transfer_http_request_proto_t * proto, - globus_bool_t * last_header) + globus_gass_transfer_http_request_proto_t * proto, + globus_bool_t * last_header) { - globus_size_t offset; - globus_bool_t end_of_header; - globus_size_t continuation=0; - char * value; - char * new_value; - int i; + globus_size_t offset; + globus_bool_t end_of_header; + globus_size_t continuation=0; + char * value; + char * new_value; + int i; /* * message-header = field-name ":" [ field-value ] CRLF * * field-name = token * field-value = *( field-content | LWS ) - * LWS = [CRLF] 1*( SP | HT ) + * LWS = [CRLF] 1*( SP | HT ) * * field-content = " | "@" * | "," | ";" | ":" | "\" | <"> * | "/" | "[" | "]" | "?" | "=" - * | "{" | "}" | SP | HT + * | "{" | "}" | SP | HT * * This implementation is a little lax on the character restrictions... */ @@ -5100,43 +5098,43 @@ globus_l_gass_transfer_http_parse_one_header( /* Find the complete header (which may span multiple lines) */ while(!end_of_header) { - /* Find the end of this header line */ - if(! globus_l_gass_transfer_http_find_crlf( - proto->response_buffer + - proto->parsed_offset + - continuation, - proto->response_offset - - proto->parsed_offset - - continuation, - &offset)) - { - return GLOBUS_TRUE; - } - else if(offset == 0) - { - end_of_header = GLOBUS_TRUE; - break; - } - /* - * Reached end-of-read data before being able to detect a - * continuation - */ - if(proto->parsed_offset + continuation + offset + 2 >= - proto->response_offset) - { - return GLOBUS_TRUE; - } - /* Check for continuation (LWS) */ - if(islws(proto->response_buffer[proto->parsed_offset + - continuation + offset + 2])) - { - continuation += offset + 2; - } - else - { - /* No continuation, we have a header */ - end_of_header = GLOBUS_TRUE; - } + /* Find the end of this header line */ + if(! globus_l_gass_transfer_http_find_crlf( + proto->response_buffer + + proto->parsed_offset + + continuation, + proto->response_offset - + proto->parsed_offset - + continuation, + &offset)) + { + return GLOBUS_TRUE; + } + else if(offset == 0) + { + end_of_header = GLOBUS_TRUE; + break; + } + /* + * Reached end-of-read data before being able to detect a + * continuation + */ + if(proto->parsed_offset + continuation + offset + 2 >= + proto->response_offset) + { + return GLOBUS_TRUE; + } + /* Check for continuation (LWS) */ + if(islws(proto->response_buffer[proto->parsed_offset + + continuation + offset + 2])) + { + continuation += offset + 2; + } + else + { + /* No continuation, we have a header */ + end_of_header = GLOBUS_TRUE; + } } /* This is the last header if it consists of CRLF only */ @@ -5144,40 +5142,40 @@ globus_l_gass_transfer_http_parse_one_header( proto->response_buffer[proto->parsed_offset + 1] == LF && continuation + offset == 0) { - *last_header = GLOBUS_TRUE; - proto->parsed_offset += 2; + *last_header = GLOBUS_TRUE; + proto->parsed_offset += 2; - return GLOBUS_FALSE; + return GLOBUS_FALSE; } /* Canonical form of header is lower-case */ for(i = proto->parsed_offset; i < proto->parsed_offset + continuation + offset; i++) { - if(proto->response_buffer[i] == ':') - { - break; - } - else - { - proto->response_buffer[i] = - (char) tolower((int) (proto->response_buffer[i])); - } + if(proto->response_buffer[i] == ':') + { + break; + } + else + { + proto->response_buffer[i] = + (char) tolower((int) (proto->response_buffer[i])); + } } if(proto->response_buffer[i] != ':') { - /* The header's name is illegal */ - proto->code = GLOBUS_L_PROTOCOL_FAILURE_CODE; - if(proto->reason != GLOBUS_NULL) - { - globus_free(proto->reason); - } - proto->reason = - globus_libc_strdup(GLOBUS_L_PROTOCOL_FAILURE_REASON); + /* The header's name is illegal */ + proto->code = GLOBUS_L_PROTOCOL_FAILURE_CODE; + if(proto->reason != GLOBUS_NULL) + { + globus_free(proto->reason); + } + proto->reason = + globus_libc_strdup(GLOBUS_L_PROTOCOL_FAILURE_REASON); - proto->parse_error = GLOBUS_TRUE; + proto->parse_error = GLOBUS_TRUE; - return GLOBUS_FALSE; + return GLOBUS_FALSE; } /* NULL-terminate the header's name */ @@ -5189,39 +5187,39 @@ globus_l_gass_transfer_http_parse_one_header( proto->response_buffer[proto->parsed_offset+continuation+offset] = '\0'; /* - * Add header to table. If it already there, append a + * Add header to table. If it already there, append a * comma and the new header's value. */ value = (char *) globus_i_gass_transfer_keyvalue_lookup( - &proto->headers, - (char *) (proto->response_buffer + proto->parsed_offset)); + &proto->headers, + (char *) (proto->response_buffer + proto->parsed_offset)); if(value == GLOBUS_NULL) { - /* New header */ - globus_i_gass_transfer_keyvalue_insert( - &proto->headers, - globus_libc_strdup((char *) (proto->response_buffer + - proto->parsed_offset)), - globus_libc_strdup(new_value)); + /* New header */ + globus_i_gass_transfer_keyvalue_insert( + &proto->headers, + globus_libc_strdup((char *) (proto->response_buffer + + proto->parsed_offset)), + globus_libc_strdup(new_value)); } else { - /* Existing header, append */ - globus_byte_t * new_ptr; + /* Existing header, append */ + globus_byte_t * new_ptr; - new_ptr = globus_libc_realloc(value, - (strlen(value) + - strlen(new_value) + 2) * - sizeof(globus_byte_t)); - strcat((char *) new_ptr, - ","); - strcat((char *) new_ptr, - new_value); - globus_i_gass_transfer_keyvalue_replace( - &proto->headers, - (char *) (proto->response_buffer + proto->parsed_offset), - (char *) new_ptr); + new_ptr = globus_libc_realloc(value, + (strlen(value) + + strlen(new_value) + 2) * + sizeof(globus_byte_t)); + strcat((char *) new_ptr, + ","); + strcat((char *) new_ptr, + new_value); + globus_i_gass_transfer_keyvalue_replace( + &proto->headers, + (char *) (proto->response_buffer + proto->parsed_offset), + (char *) new_ptr); } /* Move the "parsed" pointer to the end of what we've just handled */ @@ -5234,25 +5232,25 @@ globus_l_gass_transfer_http_parse_one_header( static globus_bool_t globus_l_gass_transfer_http_find_crlf( - globus_byte_t * bytes, - globus_size_t len, - globus_size_t * crlf_offset) + globus_byte_t * bytes, + globus_size_t len, + globus_size_t * crlf_offset) { - int i; + int i; if(len == 0) { - return GLOBUS_FALSE; + return GLOBUS_FALSE; } /* See if we can find the end an http meta-information line */ for (i = 0; i < len-1; i++) { - if(bytes[i] == CR && - bytes[i+1] == LF) - { - *crlf_offset = i; - return GLOBUS_TRUE; - } + if(bytes[i] == CR && + bytes[i+1] == LF) + { + *crlf_offset = i; + return GLOBUS_TRUE; + } } return GLOBUS_FALSE; } @@ -5260,74 +5258,74 @@ globus_l_gass_transfer_http_find_crlf( /* * Function: globus_l_gass_transfer_http_copy_text_buffer() - * + * * Description: Copy a text array from an HTTP-message to * a user's buffer, converting end-of-line characters - * to the local host format. Determines the message - * line format based on the first end-of-line it - * reaches if it is unknown. - * - * Parameters: - * - * Returns: + * to the local host format. Determines the message + * line format based on the first end-of-line it + * reaches if it is unknown. + * + * Parameters: + * + * Returns: */ void globus_l_gass_transfer_http_copy_text_buffer( - globus_byte_t * output, - globus_byte_t * input, - globus_gass_transfer_http_line_mode_t * line_mode, - globus_size_t max_input, - globus_size_t max_output, - globus_size_t * input_copied, - globus_size_t * output_copied) + globus_byte_t * output, + globus_byte_t * input, + globus_gass_transfer_http_line_mode_t * line_mode, + globus_size_t max_input, + globus_size_t max_output, + globus_size_t * input_copied, + globus_size_t * output_copied) { - globus_size_t src; - globus_size_t dst; + globus_size_t src; + globus_size_t dst; src = 0; dst = 0; /* Need to determine the line terminator */ if(*line_mode == GLOBUS_L_LINE_MODE_UNKNOWN) { - while(src < max_input-1 && dst < max_output-1) - { + while(src < max_input-1 && dst < max_output-1) + { if(input[src] == CR && (*line_mode) == - GLOBUS_L_LINE_MODE_UNKNOWN) - { - if(input[src+1] == LF) - { - *line_mode = GLOBUS_L_LINE_MODE_CRLF; - break; - } - else - { - *line_mode = GLOBUS_L_LINE_MODE_CR; - break; - } - } - else if(input[src] == LF && (*line_mode) == - GLOBUS_L_LINE_MODE_UNKNOWN) - { - *line_mode = GLOBUS_L_LINE_MODE_LF; - break; - } - else - { - output[dst] = GLOBUS_L_TEXT_BYTE(input[src]); - dst++; - src++; - - continue; - } - } - /* did we finish because we read the end-of-input or output? */ - if(src == max_input-1 || - dst == max_output-1) - { - *input_copied = src; - *output_copied = dst; - return; - } + GLOBUS_L_LINE_MODE_UNKNOWN) + { + if(input[src+1] == LF) + { + *line_mode = GLOBUS_L_LINE_MODE_CRLF; + break; + } + else + { + *line_mode = GLOBUS_L_LINE_MODE_CR; + break; + } + } + else if(input[src] == LF && (*line_mode) == + GLOBUS_L_LINE_MODE_UNKNOWN) + { + *line_mode = GLOBUS_L_LINE_MODE_LF; + break; + } + else + { + output[dst] = GLOBUS_L_TEXT_BYTE(input[src]); + dst++; + src++; + + continue; + } + } + /* did we finish because we read the end-of-input or output? */ + if(src == max_input-1 || + dst == max_output-1) + { + *input_copied = src; + *output_copied = dst; + return; + } } /* @@ -5336,102 +5334,102 @@ globus_l_gass_transfer_http_copy_text_buffer( */ while(src < max_input && dst < max_output) { - if(input[src] == CR && input[src+1] == LF && - *line_mode == GLOBUS_L_LINE_MODE_CRLF) - { - switch(globus_l_gass_transfer_http_line_mode) - { - case GLOBUS_L_LINE_MODE_CR: - /* CRLF to CR */ - output[dst] = CR; - dst++; - src += 2; - break; - case GLOBUS_L_LINE_MODE_CRLF: - /* CRLF to CRLF */ - output[dst]= CR; - dst++; - output[dst]= LF; - dst++; - src += 2; - break; - case GLOBUS_L_LINE_MODE_LF: - /* CRLF to LF */ - output[dst]= LF; - dst++; - src += 2; - break; - case GLOBUS_L_LINE_MODE_UNKNOWN: - globus_assert(globus_l_gass_transfer_http_line_mode != - GLOBUS_L_LINE_MODE_UNKNOWN); - } - } - else if(input[src] == CR && *line_mode == GLOBUS_L_LINE_MODE_CR) - { - switch(globus_l_gass_transfer_http_line_mode) - { - case GLOBUS_L_LINE_MODE_CR: - /* CR to CR */ - output[dst] = CR; - dst++; - src++; - break; - case GLOBUS_L_LINE_MODE_CRLF: - /* CR to CRLF */ - output[dst]= CR; - dst++; - output[dst]= LF; - dst++; - src++; - break; - case GLOBUS_L_LINE_MODE_LF: - /* CRLF to LF */ - output[dst]= LF; - dst++; - src++; - break; - case GLOBUS_L_LINE_MODE_UNKNOWN: - globus_assert(globus_l_gass_transfer_http_line_mode != - GLOBUS_L_LINE_MODE_UNKNOWN); - } - } - else if(input[src] == LF && *line_mode == GLOBUS_L_LINE_MODE_LF) - { - switch(globus_l_gass_transfer_http_line_mode) - { - case GLOBUS_L_LINE_MODE_CR: - /* LF to CR */ - output[dst] = CR; - dst++; - src++; - break; - case GLOBUS_L_LINE_MODE_CRLF: - /* LF to CRLF */ - output[dst]= CR; - dst++; - output[dst]= LF; - dst++; - src++; - break; - case GLOBUS_L_LINE_MODE_LF: - /* LF to LF */ - output[dst]= LF; - dst++; - src++; - break; - case GLOBUS_L_LINE_MODE_UNKNOWN: - globus_assert(globus_l_gass_transfer_http_line_mode != - GLOBUS_L_LINE_MODE_UNKNOWN); - } - } - else - { - output[dst] = GLOBUS_L_TEXT_BYTE(input[src]); - dst++; - src++; - - continue; - } + if(input[src] == CR && input[src+1] == LF && + *line_mode == GLOBUS_L_LINE_MODE_CRLF) + { + switch(globus_l_gass_transfer_http_line_mode) + { + case GLOBUS_L_LINE_MODE_CR: + /* CRLF to CR */ + output[dst] = CR; + dst++; + src += 2; + break; + case GLOBUS_L_LINE_MODE_CRLF: + /* CRLF to CRLF */ + output[dst]= CR; + dst++; + output[dst]= LF; + dst++; + src += 2; + break; + case GLOBUS_L_LINE_MODE_LF: + /* CRLF to LF */ + output[dst]= LF; + dst++; + src += 2; + break; + case GLOBUS_L_LINE_MODE_UNKNOWN: + globus_assert(globus_l_gass_transfer_http_line_mode != + GLOBUS_L_LINE_MODE_UNKNOWN); + } + } + else if(input[src] == CR && *line_mode == GLOBUS_L_LINE_MODE_CR) + { + switch(globus_l_gass_transfer_http_line_mode) + { + case GLOBUS_L_LINE_MODE_CR: + /* CR to CR */ + output[dst] = CR; + dst++; + src++; + break; + case GLOBUS_L_LINE_MODE_CRLF: + /* CR to CRLF */ + output[dst]= CR; + dst++; + output[dst]= LF; + dst++; + src++; + break; + case GLOBUS_L_LINE_MODE_LF: + /* CRLF to LF */ + output[dst]= LF; + dst++; + src++; + break; + case GLOBUS_L_LINE_MODE_UNKNOWN: + globus_assert(globus_l_gass_transfer_http_line_mode != + GLOBUS_L_LINE_MODE_UNKNOWN); + } + } + else if(input[src] == LF && *line_mode == GLOBUS_L_LINE_MODE_LF) + { + switch(globus_l_gass_transfer_http_line_mode) + { + case GLOBUS_L_LINE_MODE_CR: + /* LF to CR */ + output[dst] = CR; + dst++; + src++; + break; + case GLOBUS_L_LINE_MODE_CRLF: + /* LF to CRLF */ + output[dst]= CR; + dst++; + output[dst]= LF; + dst++; + src++; + break; + case GLOBUS_L_LINE_MODE_LF: + /* LF to LF */ + output[dst]= LF; + dst++; + src++; + break; + case GLOBUS_L_LINE_MODE_UNKNOWN: + globus_assert(globus_l_gass_transfer_http_line_mode != + GLOBUS_L_LINE_MODE_UNKNOWN); + } + } + else + { + output[dst] = GLOBUS_L_TEXT_BYTE(input[src]); + dst++; + src++; + + continue; + } } *input_copied = src; *output_copied = dst; @@ -5441,97 +5439,97 @@ globus_l_gass_transfer_http_copy_text_buffer( static void globus_l_gass_transfer_unbuffer_text( - globus_gass_transfer_http_request_proto_t * proto) + globus_gass_transfer_http_request_proto_t * proto) { /* * Copy the text from the proto's response buffer to the * user's buffer */ - globus_size_t input_copied; - globus_size_t output_copied; - globus_size_t src_max; - globus_bool_t redo = GLOBUS_FALSE; + globus_size_t input_copied; + globus_size_t output_copied; + globus_size_t src_max; + globus_bool_t redo = GLOBUS_FALSE; do { - src_max = proto->response_offset - proto->parsed_offset; + src_max = proto->response_offset - proto->parsed_offset; - if(proto->chunked && - (src_max > proto->chunk_left)) - { - src_max = proto->chunk_left; - } + if(proto->chunked && + (src_max > proto->chunk_left)) + { + src_max = proto->chunk_left; + } /* * Copy the text, converting to 7-bit US-ASCII, and * converting the document's end-of-line to be the local * machine's end-of-line character */ - globus_l_gass_transfer_http_copy_text_buffer( - proto->user_buffer + proto->user_offset, - proto->response_buffer + proto->parsed_offset, - &proto->line_mode, - src_max, - proto->user_buflen - proto->user_offset, - &input_copied, - &output_copied); - - proto->user_offset += output_copied; - proto->parsed_offset += input_copied; - proto->handled += input_copied; - if(proto->chunked) - { - proto->chunk_left -= input_copied; - } - - if(output_copied > proto->user_waitlen) - { - proto->user_waitlen = 0; - } - else - { - proto->user_waitlen -= output_copied; - } - if(proto->response_offset - proto->parsed_offset == 1 && - proto->line_mode == GLOBUS_L_LINE_MODE_UNKNOWN) - { - if(proto->response_buffer[proto->parsed_offset] == CR) - { - proto->line_mode = GLOBUS_L_LINE_MODE_CR; - redo = GLOBUS_TRUE; - } - else if (proto->response_buffer[proto->parsed_offset] == LF) - { - proto->line_mode = GLOBUS_L_LINE_MODE_LF; - redo = GLOBUS_TRUE; - } - else - { - /* doesn't matter, since the document contains no newlines */ - proto->line_mode = GLOBUS_L_LINE_MODE_LF; - redo = GLOBUS_TRUE; - } - } - else - { - redo = GLOBUS_FALSE; - } + globus_l_gass_transfer_http_copy_text_buffer( + proto->user_buffer + proto->user_offset, + proto->response_buffer + proto->parsed_offset, + &proto->line_mode, + src_max, + proto->user_buflen - proto->user_offset, + &input_copied, + &output_copied); + + proto->user_offset += output_copied; + proto->parsed_offset += input_copied; + proto->handled += input_copied; + if(proto->chunked) + { + proto->chunk_left -= input_copied; + } + + if(output_copied > proto->user_waitlen) + { + proto->user_waitlen = 0; + } + else + { + proto->user_waitlen -= output_copied; + } + if(proto->response_offset - proto->parsed_offset == 1 && + proto->line_mode == GLOBUS_L_LINE_MODE_UNKNOWN) + { + if(proto->response_buffer[proto->parsed_offset] == CR) + { + proto->line_mode = GLOBUS_L_LINE_MODE_CR; + redo = GLOBUS_TRUE; + } + else if (proto->response_buffer[proto->parsed_offset] == LF) + { + proto->line_mode = GLOBUS_L_LINE_MODE_LF; + redo = GLOBUS_TRUE; + } + else + { + /* doesn't matter, since the document contains no newlines */ + proto->line_mode = GLOBUS_L_LINE_MODE_LF; + redo = GLOBUS_TRUE; + } + } + else + { + redo = GLOBUS_FALSE; + } } while(redo); /* Reset our buffer, if we've read it all */ if(proto->parsed_offset == proto->response_offset) { - proto->parsed_offset = 0; - proto->response_offset = 0; + proto->parsed_offset = 0; + proto->response_offset = 0; } else if(proto->parsed_offset != 0) { - /* This may not be necessary */ - memmove(proto->response_buffer, - proto->response_buffer + proto->parsed_offset, - proto->response_offset - proto->parsed_offset); - proto->response_offset -= proto->parsed_offset; - proto->parsed_offset = 0; + /* This may not be necessary */ + memmove(proto->response_buffer, + proto->response_buffer + proto->parsed_offset, + proto->response_offset - proto->parsed_offset); + proto->response_offset -= proto->parsed_offset; + proto->parsed_offset = 0; } } /* globus_l_gass_transfer_unbuffer_text() */ @@ -5539,58 +5537,58 @@ globus_l_gass_transfer_unbuffer_text( static void globus_l_gass_transfer_unbuffer_binary( - globus_gass_transfer_http_request_proto_t * proto) + globus_gass_transfer_http_request_proto_t * proto) { /* * Copy the binary from the proto's response buffer to the * user's buffer */ - globus_size_t smaller; + globus_size_t smaller; smaller = proto->response_offset - proto->parsed_offset; if(smaller > proto->user_buflen - proto->user_offset) { - smaller = proto->user_buflen - proto->user_offset; + smaller = proto->user_buflen - proto->user_offset; } if(proto->chunked && smaller > proto->chunk_left) { - smaller = proto->chunk_left; + smaller = proto->chunk_left; } memcpy(proto->user_buffer + proto->user_offset, - proto->response_buffer + proto->parsed_offset, - smaller); + proto->response_buffer + proto->parsed_offset, + smaller); proto->user_offset += smaller; proto->parsed_offset += smaller; proto->handled += smaller; if(proto->chunked) { - proto->chunk_left -= smaller; + proto->chunk_left -= smaller; } if(smaller > proto->user_waitlen) { - proto->user_waitlen = 0; + proto->user_waitlen = 0; } else { - proto->user_waitlen -= smaller; + proto->user_waitlen -= smaller; } /* Reset our buffer, if we've read it all */ if(proto->parsed_offset == proto->response_offset) { - proto->parsed_offset = 0; - proto->response_offset = 0; + proto->parsed_offset = 0; + proto->response_offset = 0; } else if(proto->parsed_offset != 0) { - /* This may not be necessary */ - memmove(proto->response_buffer, - proto->response_buffer + proto->parsed_offset, - proto->response_offset - proto->parsed_offset); - proto->response_offset -= proto->parsed_offset; - proto->parsed_offset = 0; + /* This may not be necessary */ + memmove(proto->response_buffer, + proto->response_buffer + proto->parsed_offset, + proto->response_offset - proto->parsed_offset); + proto->response_offset -= proto->parsed_offset; + proto->parsed_offset = 0; } } /* globus_l_gass_transfer_unbuffer_binary() */ @@ -5600,17 +5598,17 @@ globus_l_gass_transfer_unbuffer_binary( static globus_bool_t islws( - char byte) + char byte) { return(byte == ' ' || - byte == '\t'); + byte == '\t'); } /* islws() */ static globus_bool_t ischar( - char byte) + char byte) { return( (unsigned char) byte <= 127 ); } @@ -5619,39 +5617,39 @@ ischar( static globus_bool_t istspecial( - char byte) + char byte) { return (byte == '(' || byte == ')' || byte == '<' || - byte == '>' || byte == '@' || byte == ',' || - byte == ';' || byte == ':' || byte == '\\' || - byte == '"' || byte == '/' || byte == '[' || - byte == ']' || byte == '?' || byte == '=' || - byte == '{' || byte == '}' || byte == ' ' || - byte == '\t'); + byte == '>' || byte == '@' || byte == ',' || + byte == ';' || byte == ':' || byte == '\\' || + byte == '"' || byte == '/' || byte == '[' || + byte == ']' || byte == '?' || byte == '=' || + byte == '{' || byte == '}' || byte == ' ' || + byte == '\t'); } /* istspecial() */ globus_bool_t isctl( - char byte) + char byte) { return ((byte >= (char) 0 && byte <= (char) 31) || - byte == (char) 127); + byte == (char) 127); } static globus_bool_t ishex( - char byte) + char byte) { return (byte == 'A' || byte == 'B' || byte == 'C' || - byte == 'D' || byte == 'E' || byte == 'F' || - byte == 'a' || byte == 'b' || byte == 'c' || - byte == 'd' || byte == 'e' || byte == 'f' || - byte == '0' || byte == '1' || byte == '2' || - byte == '3' || byte == '4' || byte == '5' || - byte == '6' || byte == '7' || byte == '8' || - byte == '9'); + byte == 'D' || byte == 'E' || byte == 'F' || + byte == 'a' || byte == 'b' || byte == 'c' || + byte == 'd' || byte == 'e' || byte == 'f' || + byte == '0' || byte == '1' || byte == '2' || + byte == '3' || byte == '4' || byte == '5' || + byte == '6' || byte == '7' || byte == '8' || + byte == '9'); } /* * all scan and parse functions return GLOBUS_TRUE if more data @@ -5660,11 +5658,11 @@ ishex( static globus_bool_t globus_l_gass_transfer_http_scan_star_lws( - globus_byte_t * input, - globus_size_t max_to_scan, - globus_size_t * end_of_token) + globus_byte_t * input, + globus_size_t max_to_scan, + globus_size_t * end_of_token) { - globus_size_t i; + globus_size_t i; *end_of_token = 0; /* @@ -5689,48 +5687,48 @@ globus_l_gass_transfer_http_scan_star_lws( */ for(i = 0; i < max_to_scan; i++) { - if(input[i] == ' ' || input[i] == '\t') - { - continue; - } - if(input[i] == CR) - { - if(i + 2 >= max_to_scan) - { - /* not enough data */ - return GLOBUS_TRUE; - } - else - { - if(input[i+1] == LF && - (input[i+2] == ' ' || - input[i+2] == '\t')) - { - /* pass over LF */ - i++; - continue; - } - else - { - /* This CR doesn't match our pattern */ - if(i != 0) - { - /* If we've swallowed any whitespace, note it */ - *end_of_token = i; - } - return GLOBUS_FALSE; - } - } - } - else - { - /* end of match */ - if(i != 0) - { - *end_of_token = i; - } - return GLOBUS_FALSE; - } + if(input[i] == ' ' || input[i] == '\t') + { + continue; + } + if(input[i] == CR) + { + if(i + 2 >= max_to_scan) + { + /* not enough data */ + return GLOBUS_TRUE; + } + else + { + if(input[i+1] == LF && + (input[i+2] == ' ' || + input[i+2] == '\t')) + { + /* pass over LF */ + i++; + continue; + } + else + { + /* This CR doesn't match our pattern */ + if(i != 0) + { + /* If we've swallowed any whitespace, note it */ + *end_of_token = i; + } + return GLOBUS_FALSE; + } + } + } + else + { + /* end of match */ + if(i != 0) + { + *end_of_token = i; + } + return GLOBUS_FALSE; + } } /* * If we haven't hit an end of the LWS by the end of input, @@ -5743,11 +5741,11 @@ globus_l_gass_transfer_http_scan_star_lws( static globus_bool_t globus_l_gass_transfer_http_scan_token( - globus_byte_t * input, - globus_size_t max_to_scan, - globus_size_t * end_of_token) + globus_byte_t * input, + globus_size_t max_to_scan, + globus_size_t * end_of_token) { - globus_size_t i; + globus_size_t i; *end_of_token = 0; @@ -5758,20 +5756,20 @@ globus_l_gass_transfer_http_scan_token( * tspecials = "(" | ")" | "<" | ">" | "@" * | "," | ";" | ":" | "\" | <"> * | "/" | "[" | "]" | "?" | "=" - * | "{" | "}" | SP | HT + * | "{" | "}" | SP | HT */ for(i = 0; i < max_to_scan; i++) { - if(!ischar(input[i]) || - isctl(input[i]) || - istspecial(input[i])) - { - if(i != 0) - { - *end_of_token = i; - } - return GLOBUS_FALSE; - } + if(!ischar(input[i]) || + isctl(input[i]) || + istspecial(input[i])) + { + if(i != 0) + { + *end_of_token = i; + } + return GLOBUS_FALSE; + } } return GLOBUS_TRUE; /* need more data */ } @@ -5780,12 +5778,12 @@ globus_l_gass_transfer_http_scan_token( static globus_bool_t globus_l_gass_transfer_http_scan_qdtext( - globus_byte_t * input, - globus_size_t max_to_scan, - globus_size_t * end_of_qdtext) + globus_byte_t * input, + globus_size_t max_to_scan, + globus_size_t * end_of_qdtext) { - globus_size_t i; - globus_size_t j; + globus_size_t i; + globus_size_t j; /* * qdtext = > @@ -5798,54 +5796,54 @@ globus_l_gass_transfer_http_scan_qdtext( for(i = 0; i < max_to_scan; i++) { - /* Always absorb LWS in quotes */ - if(globus_l_gass_transfer_http_scan_star_lws( - input + i, - max_to_scan - i, - &j)) - { - return GLOBUS_TRUE; /* need more to scan */ - } - else if(j != 0) - { - i += j; /* scanned some LWS */ - continue; - } - else if(input[i] == '\\') - { - /* absorb quoted-pair */ - if(i + 1 < max_to_scan) - { - if(ischar(input[i+1])) - { - i++; - - continue; - } - else - { - *end_of_qdtext = i; - return GLOBUS_FALSE; - } - } - else - { - return GLOBUS_TRUE; /* need more to scan */ - } - } - else if(!isctl(input[i])) - { - continue; - } - else if(i != 0) - { - *end_of_qdtext = i; - return GLOBUS_FALSE; - } - else - { - return GLOBUS_FALSE; - } + /* Always absorb LWS in quotes */ + if(globus_l_gass_transfer_http_scan_star_lws( + input + i, + max_to_scan - i, + &j)) + { + return GLOBUS_TRUE; /* need more to scan */ + } + else if(j != 0) + { + i += j; /* scanned some LWS */ + continue; + } + else if(input[i] == '\\') + { + /* absorb quoted-pair */ + if(i + 1 < max_to_scan) + { + if(ischar(input[i+1])) + { + i++; + + continue; + } + else + { + *end_of_qdtext = i; + return GLOBUS_FALSE; + } + } + else + { + return GLOBUS_TRUE; /* need more to scan */ + } + } + else if(!isctl(input[i])) + { + continue; + } + else if(i != 0) + { + *end_of_qdtext = i; + return GLOBUS_FALSE; + } + else + { + return GLOBUS_FALSE; + } } return GLOBUS_TRUE; } @@ -5854,50 +5852,50 @@ globus_l_gass_transfer_http_scan_qdtext( static globus_bool_t globus_l_gass_transfer_http_scan_quoted_string( - globus_byte_t * input, - globus_size_t max_to_scan, - globus_size_t * end_of_qtd_string) + globus_byte_t * input, + globus_size_t max_to_scan, + globus_size_t * end_of_qtd_string) { - globus_size_t i; + globus_size_t i; /* - * quoted-string = ( <"> *(qdtext) <"> ) + * quoted-string = ( <"> *(qdtext) <"> ) */ *end_of_qtd_string = 0; if(max_to_scan == 0) { - return GLOBUS_TRUE; + return GLOBUS_TRUE; } /* quoted text must begin with '"' */ if(input[0] != '"') { - return GLOBUS_FALSE; + return GLOBUS_FALSE; } if(globus_l_gass_transfer_http_scan_qdtext( - input+1, - max_to_scan-1, - &i)) + input+1, + max_to_scan-1, + &i)) { - return GLOBUS_TRUE; /* need more data */ + return GLOBUS_TRUE; /* need more data */ } if(i == max_to_scan - 1) { - return GLOBUS_TRUE; /* need more data */ + return GLOBUS_TRUE; /* need more data */ } /* quoted text must end with '"' */ if(input[i] == '"') { - *end_of_qtd_string = i+1; - return GLOBUS_FALSE; + *end_of_qtd_string = i+1; + return GLOBUS_FALSE; } else { - return GLOBUS_FALSE; + return GLOBUS_FALSE; } } /* globus_l_gass_transfer_http_scan_quoted_string() */ @@ -5906,13 +5904,13 @@ globus_l_gass_transfer_http_scan_quoted_string( static globus_bool_t globus_l_gass_transfer_http_scan_chunk_ext( - globus_byte_t * input, - globus_size_t max_to_scan, - globus_size_t * end_of_chunk_ext) + globus_byte_t * input, + globus_size_t max_to_scan, + globus_size_t * end_of_chunk_ext) { - globus_size_t i; - globus_size_t j; - globus_bool_t semicolon = GLOBUS_FALSE; + globus_size_t i; + globus_size_t j; + globus_bool_t semicolon = GLOBUS_FALSE; /* * chunk-ext = *( ";" chunk-ext-name [ "=" chunk-ext-value ] ) @@ -5925,10 +5923,10 @@ globus_l_gass_transfer_http_scan_chunk_ext( for(;;) { - if(max_to_scan - i == 0) - { - return GLOBUS_TRUE; - } + if(max_to_scan - i == 0) + { + return GLOBUS_TRUE; + } else if (input[i] != CR) { /* Don't scan *LWS if the first character is a newline. Assume that no @@ -5947,125 +5945,125 @@ globus_l_gass_transfer_http_scan_chunk_ext( } } - if(i + 1 >= max_to_scan) - { - return GLOBUS_TRUE; - } - /* - * Only consume LWS if there is a semicolon, - * otherwise, we may consume part of CRLF/message body - */ - if(input[i] != ';' && semicolon) - { - *end_of_chunk_ext = i; - return GLOBUS_FALSE; - } - else if(input[i] != ';') - { - return GLOBUS_FALSE; - } - - semicolon = GLOBUS_TRUE; - - /* pass over ';' */ - i++; - - /* skip any LWS */ - if(globus_l_gass_transfer_http_scan_star_lws( - input + i, - max_to_scan - i, - &j)) - { - return GLOBUS_TRUE; /* more to scan */ - } - else if(j != 0) - { - i += j; /* scanned some LWS */ - } - - /* scan for chunk-ext-name */ - if(globus_l_gass_transfer_http_scan_token( - input + i, - max_to_scan - i, - &j)) - { - return GLOBUS_TRUE; - } - else if(j == 0) /* illegal, ';' but no token */ - { - *end_of_chunk_ext = 0; - return GLOBUS_FALSE; - } - else - { - i += j; - } - - /* skip any LWS */ - if(globus_l_gass_transfer_http_scan_star_lws( - input + i, - max_to_scan - i, - &j)) - { - return GLOBUS_TRUE; /* more to scan */ - } - else if(j != 0) - { - i += j; /* scanned some leading LWS */ - } - - /* check for '=' */ - if(i + 1 >= max_to_scan) - { - return GLOBUS_TRUE; - } - if(input[i] == ';') /* chunk-ext without chunk-ext-value */ - { - continue; - } - else if(input[i] != '=') - { - *end_of_chunk_ext = i; - return GLOBUS_FALSE; - } - /* pass over '=' */ - i++; - - /* skip any LWS */ - if(globus_l_gass_transfer_http_scan_star_lws( - input+i, - max_to_scan-i, - &j)) - { - return GLOBUS_TRUE; /* more to scan */ - } - else if(j != 0) - { - i += j; /* scanned some LWS */ - } - - - /* check for chunk-ext-value, either a token, or a quoted-string */ - if(globus_l_gass_transfer_http_scan_token( - input + i, - max_to_scan - i, - &j)) - { - return GLOBUS_TRUE; /* more to scan */ - } - /* no token, try to scan quoted string */ - else if(j == 0 && - globus_l_gass_transfer_http_scan_quoted_string( - input + i, - max_to_scan - i, - &j)) - { - return GLOBUS_TRUE; /* more to scan */ - } - else - { - i += j; - } + if(i + 1 >= max_to_scan) + { + return GLOBUS_TRUE; + } + /* + * Only consume LWS if there is a semicolon, + * otherwise, we may consume part of CRLF/message body + */ + if(input[i] != ';' && semicolon) + { + *end_of_chunk_ext = i; + return GLOBUS_FALSE; + } + else if(input[i] != ';') + { + return GLOBUS_FALSE; + } + + semicolon = GLOBUS_TRUE; + + /* pass over ';' */ + i++; + + /* skip any LWS */ + if(globus_l_gass_transfer_http_scan_star_lws( + input + i, + max_to_scan - i, + &j)) + { + return GLOBUS_TRUE; /* more to scan */ + } + else if(j != 0) + { + i += j; /* scanned some LWS */ + } + + /* scan for chunk-ext-name */ + if(globus_l_gass_transfer_http_scan_token( + input + i, + max_to_scan - i, + &j)) + { + return GLOBUS_TRUE; + } + else if(j == 0) /* illegal, ';' but no token */ + { + *end_of_chunk_ext = 0; + return GLOBUS_FALSE; + } + else + { + i += j; + } + + /* skip any LWS */ + if(globus_l_gass_transfer_http_scan_star_lws( + input + i, + max_to_scan - i, + &j)) + { + return GLOBUS_TRUE; /* more to scan */ + } + else if(j != 0) + { + i += j; /* scanned some leading LWS */ + } + + /* check for '=' */ + if(i + 1 >= max_to_scan) + { + return GLOBUS_TRUE; + } + if(input[i] == ';') /* chunk-ext without chunk-ext-value */ + { + continue; + } + else if(input[i] != '=') + { + *end_of_chunk_ext = i; + return GLOBUS_FALSE; + } + /* pass over '=' */ + i++; + + /* skip any LWS */ + if(globus_l_gass_transfer_http_scan_star_lws( + input+i, + max_to_scan-i, + &j)) + { + return GLOBUS_TRUE; /* more to scan */ + } + else if(j != 0) + { + i += j; /* scanned some LWS */ + } + + + /* check for chunk-ext-value, either a token, or a quoted-string */ + if(globus_l_gass_transfer_http_scan_token( + input + i, + max_to_scan - i, + &j)) + { + return GLOBUS_TRUE; /* more to scan */ + } + /* no token, try to scan quoted string */ + else if(j == 0 && + globus_l_gass_transfer_http_scan_quoted_string( + input + i, + max_to_scan - i, + &j)) + { + return GLOBUS_TRUE; /* more to scan */ + } + else + { + i += j; + } } } /* globus_l_gass_transfer_http_scan_chunk_ext() */ @@ -6073,11 +6071,11 @@ globus_l_gass_transfer_http_scan_chunk_ext( static globus_bool_t globus_l_gass_transfer_http_scan_chunk_size( - globus_byte_t * input, - globus_size_t max_to_scan, - globus_size_t * end_of_chunk_size) + globus_byte_t * input, + globus_size_t max_to_scan, + globus_size_t * end_of_chunk_size) { - globus_size_t i; + globus_size_t i; /* * hex-no-zero = @@ -6089,28 +6087,28 @@ globus_l_gass_transfer_http_scan_chunk_size( if(i >= max_to_scan) { - return GLOBUS_TRUE; + return GLOBUS_TRUE; } if(input[i] == '0' && i + 1 < max_to_scan) { - *end_of_chunk_size = 1; - return GLOBUS_FALSE; + *end_of_chunk_size = 1; + return GLOBUS_FALSE; } for(; i < max_to_scan; i++) { - if(input[i] == ' ' || - input[i] == '\t') - { - continue; - } - if(!ishex(input[i])) - { - *end_of_chunk_size = i; - return GLOBUS_FALSE; - } + if(input[i] == ' ' || + input[i] == '\t') + { + continue; + } + if(!ishex(input[i])) + { + *end_of_chunk_size = i; + return GLOBUS_FALSE; + } } return GLOBUS_TRUE; } @@ -6118,21 +6116,21 @@ globus_l_gass_transfer_http_scan_chunk_size( /* * Function: globus_l_gass_transfer_http_handle_chunk() - * + * * Description: Parse any chunk header/footer information, and * copy chunk data (with appropriate text-mode * translations) into the user's buffers - * - * Parameters: - * - * Returns: + * + * Parameters: + * + * Returns: */ static globus_bool_t globus_l_gass_transfer_http_handle_chunk( - globus_gass_transfer_http_request_proto_t * proto) + globus_gass_transfer_http_request_proto_t * proto) { - globus_size_t i; + globus_size_t i; if ( proto->response_offset - proto->parsed_offset == 0 ) { @@ -6145,16 +6143,16 @@ globus_l_gass_transfer_http_handle_chunk( switch(proto->recv_state) { case GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_UNTIL_LENGTH: - if (proto->length == proto->handled) - { - proto->recv_state = - GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_EOF; - } - else - { - proto->recv_state = - GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_ERROR; - } + if (proto->length == proto->handled) + { + proto->recv_state = + GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_EOF; + } + else + { + proto->recv_state = + GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_ERROR; + } break; case GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_UNTIL_EOF: @@ -6164,8 +6162,8 @@ globus_l_gass_transfer_http_handle_chunk( default: proto->failure_occurred = GLOBUS_TRUE; - proto->recv_state = - GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_ERROR; + proto->recv_state = + GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_ERROR; break; } return GLOBUS_FALSE; @@ -6174,229 +6172,229 @@ globus_l_gass_transfer_http_handle_chunk( while(proto->response_offset - proto->parsed_offset > 0) { - switch(proto->recv_state) - { - case GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_CHUNK_SIZE: - if(globus_l_gass_transfer_http_scan_chunk_size( - proto->response_buffer + proto->parsed_offset, - proto->response_offset - proto->parsed_offset, - &i)) - { - /* true == need more data */ - return GLOBUS_TRUE; - } - else if(i == 0) - { - proto->recv_state = - GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_ERROR; - proto->failure_occurred = - GLOBUS_TRUE; - return GLOBUS_FALSE; - } - - proto->chunk_left = strtoul((char *) proto->response_buffer + - proto->parsed_offset, - GLOBUS_NULL, - 16); - proto->parsed_offset += i; - if(proto->chunk_left == 0) - { - /* - * last chunk can not be followed by chunk-ext elements, - * but may be followed by a set of footers - */ - proto->recv_state = - GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_CHUNK_FOOTER; - break; - } - else - { - proto->recv_state = - GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_CHUNK_EXT; - } - /* FALLSTHROUGH */ - case GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_CHUNK_EXT: - if(globus_l_gass_transfer_http_scan_chunk_ext( - proto->response_buffer + proto->parsed_offset, - proto->response_offset - proto->parsed_offset, - &i)) - { - /* true == need more data */ - return GLOBUS_TRUE; - } - else - { - proto->parsed_offset += i; - proto->recv_state = - GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_CHUNK_END_HEADER_CR; - /* FALLSTHROUGH */ - } - case GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_CHUNK_END_HEADER_CR: - if(proto->response_offset - proto->parsed_offset > 0) - { - if(proto->response_buffer[proto->parsed_offset] != CR) - { - proto->parse_error=GLOBUS_TRUE; - proto->failure_occurred = GLOBUS_TRUE; - proto->recv_state = - GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_ERROR; - return GLOBUS_FALSE; - } - proto->recv_state = - GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_CHUNK_END_HEADER_LF; - proto->parsed_offset++; - } - else - { - return GLOBUS_TRUE; - } - /* FALLSTHROUGH */ - case GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_CHUNK_END_HEADER_LF: - if(proto->response_offset - proto->parsed_offset > 0) - { - if(proto->response_buffer[proto->parsed_offset] != LF) - { - proto->parse_error=GLOBUS_TRUE; - proto->failure_occurred=GLOBUS_TRUE; - return GLOBUS_FALSE; - } - proto->recv_state = - GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_CHUNK_BODY; - proto->parsed_offset++; - } - else - { - return GLOBUS_TRUE; - } - /* FALLSTHROUGH */ - case GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_CHUNK_BODY: - if(proto->chunk_left == 0) - { - proto->recv_state = - GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_CHUNK_END_BODY_CR; - } - else - { - break; - } - /* FALLSTHROUGH */ - - case GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_CHUNK_END_BODY_CR: - if(proto->response_offset - proto->parsed_offset > 0) - { - if(proto->response_buffer[proto->parsed_offset] != CR) - { - proto->parse_error=GLOBUS_TRUE; - proto->failure_occurred=GLOBUS_TRUE; - proto->recv_state = - GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_ERROR; - return GLOBUS_FALSE; - } - proto->recv_state = - GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_CHUNK_END_BODY_LF; - proto->parsed_offset++; - } - else - { - return GLOBUS_TRUE; - } - /* FALLSTHROUGH */ - - case GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_CHUNK_END_BODY_LF: - if(proto->response_offset - proto->parsed_offset > 0) - { - if(proto->response_buffer[proto->parsed_offset] != LF) - { - proto->parse_error=GLOBUS_TRUE; - proto->failure_occurred=GLOBUS_TRUE; - proto->recv_state = - GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_ERROR; - return GLOBUS_FALSE; - } - proto->recv_state = - GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_CHUNK_SIZE; - proto->parsed_offset++; - break; - } - else - { - return GLOBUS_TRUE; - } - case GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_CHUNK_FOOTER: - if(globus_l_gass_transfer_http_parse_headers(proto)) - { - /* need more data */ - return GLOBUS_TRUE; - } - else if(proto->parse_error) - { - proto->failure_occurred=GLOBUS_TRUE; - proto->recv_state = - GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_ERROR; - return GLOBUS_FALSE; - } - else - { - proto->recv_state = - GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_EOF; - return GLOBUS_FALSE; - } - case GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_UNTIL_EOF: - case GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_UNTIL_LENGTH: - break; - - case GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_ERROR: - case GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_EOF: - return GLOBUS_FALSE; - } - - if(proto->recv_state == - GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_UNTIL_LENGTH || - proto->recv_state == - GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_UNTIL_EOF || - proto->recv_state == - GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_CHUNK_BODY) - { - if(proto->user_buflen > proto->user_offset && - proto->response_offset > proto->parsed_offset) - { - /* some room is in the user's buffer for new data */ - if(proto->text_mode) - { - globus_l_gass_transfer_unbuffer_text(proto); - } - else - { - globus_l_gass_transfer_unbuffer_binary(proto); - } - /* check to see if we've failed/completed because of this */ - if(proto->recv_state == GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_UNTIL_LENGTH && - proto->length == proto->handled) - { - proto->recv_state = - GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_EOF; - } - else if(proto->recv_state == GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_UNTIL_LENGTH && - proto->eof_read && - proto->response_offset - proto->parsed_offset == 0) - { - proto->recv_state = - GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_ERROR; - } - else if(proto->recv_state == GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_UNTIL_EOF && - proto->eof_read && - proto->response_offset - proto->parsed_offset == 0) - { - proto->recv_state = - GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_EOF; - } - - } - else - { - return GLOBUS_FALSE; - } - } + switch(proto->recv_state) + { + case GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_CHUNK_SIZE: + if(globus_l_gass_transfer_http_scan_chunk_size( + proto->response_buffer + proto->parsed_offset, + proto->response_offset - proto->parsed_offset, + &i)) + { + /* true == need more data */ + return GLOBUS_TRUE; + } + else if(i == 0) + { + proto->recv_state = + GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_ERROR; + proto->failure_occurred = + GLOBUS_TRUE; + return GLOBUS_FALSE; + } + + proto->chunk_left = strtoul((char *) proto->response_buffer + + proto->parsed_offset, + GLOBUS_NULL, + 16); + proto->parsed_offset += i; + if(proto->chunk_left == 0) + { + /* + * last chunk can not be followed by chunk-ext elements, + * but may be followed by a set of footers + */ + proto->recv_state = + GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_CHUNK_FOOTER; + break; + } + else + { + proto->recv_state = + GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_CHUNK_EXT; + } + /* FALLSTHROUGH */ + case GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_CHUNK_EXT: + if(globus_l_gass_transfer_http_scan_chunk_ext( + proto->response_buffer + proto->parsed_offset, + proto->response_offset - proto->parsed_offset, + &i)) + { + /* true == need more data */ + return GLOBUS_TRUE; + } + else + { + proto->parsed_offset += i; + proto->recv_state = + GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_CHUNK_END_HEADER_CR; + /* FALLSTHROUGH */ + } + case GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_CHUNK_END_HEADER_CR: + if(proto->response_offset - proto->parsed_offset > 0) + { + if(proto->response_buffer[proto->parsed_offset] != CR) + { + proto->parse_error=GLOBUS_TRUE; + proto->failure_occurred = GLOBUS_TRUE; + proto->recv_state = + GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_ERROR; + return GLOBUS_FALSE; + } + proto->recv_state = + GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_CHUNK_END_HEADER_LF; + proto->parsed_offset++; + } + else + { + return GLOBUS_TRUE; + } + /* FALLSTHROUGH */ + case GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_CHUNK_END_HEADER_LF: + if(proto->response_offset - proto->parsed_offset > 0) + { + if(proto->response_buffer[proto->parsed_offset] != LF) + { + proto->parse_error=GLOBUS_TRUE; + proto->failure_occurred=GLOBUS_TRUE; + return GLOBUS_FALSE; + } + proto->recv_state = + GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_CHUNK_BODY; + proto->parsed_offset++; + } + else + { + return GLOBUS_TRUE; + } + /* FALLSTHROUGH */ + case GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_CHUNK_BODY: + if(proto->chunk_left == 0) + { + proto->recv_state = + GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_CHUNK_END_BODY_CR; + } + else + { + break; + } + /* FALLSTHROUGH */ + + case GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_CHUNK_END_BODY_CR: + if(proto->response_offset - proto->parsed_offset > 0) + { + if(proto->response_buffer[proto->parsed_offset] != CR) + { + proto->parse_error=GLOBUS_TRUE; + proto->failure_occurred=GLOBUS_TRUE; + proto->recv_state = + GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_ERROR; + return GLOBUS_FALSE; + } + proto->recv_state = + GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_CHUNK_END_BODY_LF; + proto->parsed_offset++; + } + else + { + return GLOBUS_TRUE; + } + /* FALLSTHROUGH */ + + case GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_CHUNK_END_BODY_LF: + if(proto->response_offset - proto->parsed_offset > 0) + { + if(proto->response_buffer[proto->parsed_offset] != LF) + { + proto->parse_error=GLOBUS_TRUE; + proto->failure_occurred=GLOBUS_TRUE; + proto->recv_state = + GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_ERROR; + return GLOBUS_FALSE; + } + proto->recv_state = + GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_CHUNK_SIZE; + proto->parsed_offset++; + break; + } + else + { + return GLOBUS_TRUE; + } + case GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_CHUNK_FOOTER: + if(globus_l_gass_transfer_http_parse_headers(proto)) + { + /* need more data */ + return GLOBUS_TRUE; + } + else if(proto->parse_error) + { + proto->failure_occurred=GLOBUS_TRUE; + proto->recv_state = + GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_ERROR; + return GLOBUS_FALSE; + } + else + { + proto->recv_state = + GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_EOF; + return GLOBUS_FALSE; + } + case GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_UNTIL_EOF: + case GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_UNTIL_LENGTH: + break; + + case GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_ERROR: + case GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_EOF: + return GLOBUS_FALSE; + } + + if(proto->recv_state == + GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_UNTIL_LENGTH || + proto->recv_state == + GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_UNTIL_EOF || + proto->recv_state == + GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_CHUNK_BODY) + { + if(proto->user_buflen > proto->user_offset && + proto->response_offset > proto->parsed_offset) + { + /* some room is in the user's buffer for new data */ + if(proto->text_mode) + { + globus_l_gass_transfer_unbuffer_text(proto); + } + else + { + globus_l_gass_transfer_unbuffer_binary(proto); + } + /* check to see if we've failed/completed because of this */ + if(proto->recv_state == GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_UNTIL_LENGTH && + proto->length == proto->handled) + { + proto->recv_state = + GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_EOF; + } + else if(proto->recv_state == GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_UNTIL_LENGTH && + proto->eof_read && + proto->response_offset - proto->parsed_offset == 0) + { + proto->recv_state = + GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_ERROR; + } + else if(proto->recv_state == GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_UNTIL_EOF && + proto->eof_read && + proto->response_offset - proto->parsed_offset == 0) + { + proto->recv_state = + GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_EOF; + } + + } + else + { + return GLOBUS_FALSE; + } + } } return GLOBUS_FALSE; } @@ -6405,37 +6403,37 @@ globus_l_gass_transfer_http_handle_chunk( static void globus_l_gass_transfer_http_extract_referral( - globus_gass_transfer_http_request_proto_t * proto, - char *** referral, - globus_size_t * referral_count) + globus_gass_transfer_http_request_proto_t * proto, + char *** referral, + globus_size_t * referral_count) { - char * location; - char * p; + char * location; + char * p; location = globus_i_gass_transfer_keyvalue_lookup( - &proto->headers, - "location"); + &proto->headers, + "location"); if(location == GLOBUS_NULL) { - *referral = GLOBUS_NULL; - *referral_count = 0; + *referral = GLOBUS_NULL; + *referral_count = 0; } else { - p = location; + p = location; - for(p=location; *p != '\0'; p++) - { - if(!isspace(*p)) - { - break; - } - } + for(p=location; *p != '\0'; p++) + { + if(!isspace(*p)) + { + break; + } + } - *referral = (char **) globus_malloc(sizeof(char *)); - (*referral)[0] = globus_libc_strdup(p); + *referral = (char **) globus_malloc(sizeof(char *)); + (*referral)[0] = globus_libc_strdup(p); - *referral_count = 1; + *referral_count = 1; } return; } @@ -6462,17 +6460,17 @@ globus_l_gass_transfer_http_accept_failed_kickout( static void globus_l_gass_transfer_http_callback_denied( - void * arg) + void * arg) { - globus_gass_transfer_request_t request; + globus_gass_transfer_request_t request; request = (globus_gass_transfer_request_t) (intptr_t) arg; - + debug_printf(2, (_GTSL("calling globus_gass_transfer_proto_request_denied"))); globus_gass_transfer_proto_request_denied( - request, - GLOBUS_L_DEFAULT_FAILURE_CODE, - globus_libc_strdup(GLOBUS_L_DEFAULT_FAILURE_REASON)); + request, + GLOBUS_L_DEFAULT_FAILURE_CODE, + globus_libc_strdup(GLOBUS_L_DEFAULT_FAILURE_REASON)); } #endif /* !GLOBUS_GASS_TRANSFER_HTTP_PARSER_TEST */ #endif /* GLOBUS_DONT_DOCUMENT_INTERNAL */ diff --git a/gass/transfer/source/library/globus_gass_transfer_request.c b/gass/transfer/source/library/globus_gass_transfer_request.c index d025dde9d3..5a7010b0d6 100644 --- a/gass/transfer/source/library/globus_gass_transfer_request.c +++ b/gass/transfer/source/library/globus_gass_transfer_request.c @@ -20,7 +20,7 @@ * @brief GASS Transfer Request * * This module implements the request structure accessors for the - * GASS transfer library + * GASS transfer library */ #endif @@ -41,20 +41,20 @@ */ globus_gass_transfer_request_type_t globus_gass_transfer_request_get_type( - globus_gass_transfer_request_t request) + globus_gass_transfer_request_t request) { - globus_gass_transfer_request_struct_t * req; + globus_gass_transfer_request_struct_t * req; req = - globus_handle_table_lookup(&globus_i_gass_transfer_request_handles, - request); + globus_handle_table_lookup(&globus_i_gass_transfer_request_handles, + request); if(req == GLOBUS_NULL) { - return GLOBUS_GASS_TRANSFER_REQUEST_TYPE_INVALID; + return GLOBUS_GASS_TRANSFER_REQUEST_TYPE_INVALID; } else { - return req->type; + return req->type; } } /* globus_gass_transfer_request_get_type() */ @@ -75,21 +75,21 @@ globus_gass_transfer_request_get_type( */ void * globus_gass_transfer_request_get_user_pointer( - globus_gass_transfer_request_t request) + globus_gass_transfer_request_t request) { - globus_gass_transfer_request_struct_t * req; + globus_gass_transfer_request_struct_t * req; req = - globus_handle_table_lookup(&globus_i_gass_transfer_request_handles, - request); + globus_handle_table_lookup(&globus_i_gass_transfer_request_handles, + request); if(req == GLOBUS_NULL|| req->type == GLOBUS_GASS_TRANSFER_REQUEST_TYPE_INVALID) { - return GLOBUS_NULL; + return GLOBUS_NULL; } else { - return req->user_pointer; + return req->user_pointer; } } /* globus_gass_transfer_request_get_user_pointer() */ @@ -115,22 +115,22 @@ globus_gass_transfer_request_get_user_pointer( */ int globus_gass_transfer_request_set_user_pointer( - globus_gass_transfer_request_t request, - void * user_pointer) + globus_gass_transfer_request_t request, + void * user_pointer) { - globus_gass_transfer_request_struct_t * req; + globus_gass_transfer_request_struct_t * req; req = - globus_handle_table_lookup(&globus_i_gass_transfer_request_handles, - request); + globus_handle_table_lookup(&globus_i_gass_transfer_request_handles, + request); if(req == GLOBUS_NULL) { - return GLOBUS_GASS_TRANSFER_ERROR_INVALID_USE; + return GLOBUS_GASS_TRANSFER_ERROR_INVALID_USE; } else { - req->user_pointer = user_pointer; - return GLOBUS_SUCCESS; + req->user_pointer = user_pointer; + return GLOBUS_SUCCESS; } } /* globus_gass_transfer_request_set_user_pointer() */ @@ -153,46 +153,46 @@ globus_gass_transfer_request_set_user_pointer( */ globus_gass_transfer_request_status_t globus_gass_transfer_request_get_status( - globus_gass_transfer_request_t request) + globus_gass_transfer_request_t request) { - globus_gass_transfer_request_struct_t * req; + globus_gass_transfer_request_struct_t * req; req = - globus_handle_table_lookup(&globus_i_gass_transfer_request_handles, - request); + globus_handle_table_lookup(&globus_i_gass_transfer_request_handles, + request); if(req != GLOBUS_NULL) { - switch(req->status) - { - case GLOBUS_GASS_TRANSFER_REQUEST_STARTING3: - case GLOBUS_GASS_TRANSFER_REQUEST_PENDING: - case GLOBUS_GASS_TRANSFER_REQUEST_ACTING: - case GLOBUS_GASS_TRANSFER_REQUEST_ACTING_TO_PENDING: - case GLOBUS_GASS_TRANSFER_REQUEST_ACCEPTING: - return GLOBUS_GASS_TRANSFER_REQUEST_PENDING; - case GLOBUS_GASS_TRANSFER_REQUEST_ACTING_TO_FAILING: - case GLOBUS_GASS_TRANSFER_REQUEST_FAILING: - case GLOBUS_GASS_TRANSFER_REQUEST_FAILED: - case GLOBUS_GASS_TRANSFER_REQUEST_SERVER_FAIL1: - case GLOBUS_GASS_TRANSFER_REQUEST_SERVER_FAIL2: - case GLOBUS_GASS_TRANSFER_REQUEST_SERVER_FAIL3: - case GLOBUS_GASS_TRANSFER_REQUEST_USER_FAIL: - return GLOBUS_GASS_TRANSFER_REQUEST_FAILED; - case GLOBUS_GASS_TRANSFER_REQUEST_FINISHING: - case GLOBUS_GASS_TRANSFER_REQUEST_DONE: - return GLOBUS_GASS_TRANSFER_REQUEST_DONE; - case GLOBUS_GASS_TRANSFER_REQUEST_STARTING: - case GLOBUS_GASS_TRANSFER_REQUEST_STARTING2: - return GLOBUS_GASS_TRANSFER_REQUEST_STARTING; - case GLOBUS_GASS_TRANSFER_REQUEST_REFERRED: - case GLOBUS_GASS_TRANSFER_REQUEST_ACTING_TO_REFERRING: - case GLOBUS_GASS_TRANSFER_REQUEST_REFERRING: - return GLOBUS_GASS_TRANSFER_REQUEST_REFERRED; - case GLOBUS_GASS_TRANSFER_REQUEST_DENIED: - return GLOBUS_GASS_TRANSFER_REQUEST_DENIED; - case GLOBUS_GASS_TRANSFER_REQUEST_INVALID: - return GLOBUS_GASS_TRANSFER_REQUEST_INVALID; - } + switch(req->status) + { + case GLOBUS_GASS_TRANSFER_REQUEST_STARTING3: + case GLOBUS_GASS_TRANSFER_REQUEST_PENDING: + case GLOBUS_GASS_TRANSFER_REQUEST_ACTING: + case GLOBUS_GASS_TRANSFER_REQUEST_ACTING_TO_PENDING: + case GLOBUS_GASS_TRANSFER_REQUEST_ACCEPTING: + return GLOBUS_GASS_TRANSFER_REQUEST_PENDING; + case GLOBUS_GASS_TRANSFER_REQUEST_ACTING_TO_FAILING: + case GLOBUS_GASS_TRANSFER_REQUEST_FAILING: + case GLOBUS_GASS_TRANSFER_REQUEST_FAILED: + case GLOBUS_GASS_TRANSFER_REQUEST_SERVER_FAIL1: + case GLOBUS_GASS_TRANSFER_REQUEST_SERVER_FAIL2: + case GLOBUS_GASS_TRANSFER_REQUEST_SERVER_FAIL3: + case GLOBUS_GASS_TRANSFER_REQUEST_USER_FAIL: + return GLOBUS_GASS_TRANSFER_REQUEST_FAILED; + case GLOBUS_GASS_TRANSFER_REQUEST_FINISHING: + case GLOBUS_GASS_TRANSFER_REQUEST_DONE: + return GLOBUS_GASS_TRANSFER_REQUEST_DONE; + case GLOBUS_GASS_TRANSFER_REQUEST_STARTING: + case GLOBUS_GASS_TRANSFER_REQUEST_STARTING2: + return GLOBUS_GASS_TRANSFER_REQUEST_STARTING; + case GLOBUS_GASS_TRANSFER_REQUEST_REFERRED: + case GLOBUS_GASS_TRANSFER_REQUEST_ACTING_TO_REFERRING: + case GLOBUS_GASS_TRANSFER_REQUEST_REFERRING: + return GLOBUS_GASS_TRANSFER_REQUEST_REFERRED; + case GLOBUS_GASS_TRANSFER_REQUEST_DENIED: + return GLOBUS_GASS_TRANSFER_REQUEST_DENIED; + case GLOBUS_GASS_TRANSFER_REQUEST_INVALID: + return GLOBUS_GASS_TRANSFER_REQUEST_INVALID; + } } return GLOBUS_GASS_TRANSFER_REQUEST_INVALID; } @@ -224,45 +224,45 @@ globus_gass_transfer_request_get_status( */ int globus_gass_transfer_request_get_referral( - globus_gass_transfer_request_t request, - globus_gass_transfer_referral_t * referral) + globus_gass_transfer_request_t request, + globus_gass_transfer_referral_t * referral) { - globus_gass_transfer_request_struct_t * req; + globus_gass_transfer_request_struct_t * req; /* Sanity check of arguments */ if(referral == GLOBUS_NULL) { - return GLOBUS_GASS_TRANSFER_ERROR_NULL_POINTER; + return GLOBUS_GASS_TRANSFER_ERROR_NULL_POINTER; } /* Check for illegal handle */ req = - globus_handle_table_lookup(&globus_i_gass_transfer_request_handles, - request); + globus_handle_table_lookup(&globus_i_gass_transfer_request_handles, + request); if(req == GLOBUS_NULL) { - return GLOBUS_GASS_TRANSFER_ERROR_INVALID_USE; + return GLOBUS_GASS_TRANSFER_ERROR_INVALID_USE; } else if(req->referral_count == 0) { - referral->url = GLOBUS_NULL; - referral->count = 0; + referral->url = GLOBUS_NULL; + referral->count = 0; - return GLOBUS_SUCCESS; + return GLOBUS_SUCCESS; } else { - globus_size_t i; + globus_size_t i; - referral->url = - globus_malloc(sizeof(char *) * req->referral_count); + referral->url = + globus_malloc(sizeof(char *) * req->referral_count); - for(i = 0; i < req->referral_count; i++) - { - referral->url[i] = globus_libc_strdup(req->referral_url[i]); - } - referral->count = req->referral_count; + for(i = 0; i < req->referral_count; i++) + { + referral->url[i] = globus_libc_strdup(req->referral_url[i]); + } + referral->count = req->referral_count; - return GLOBUS_SUCCESS; + return GLOBUS_SUCCESS; } } /* globus_gass_transfer_request_get_referral() */ @@ -285,20 +285,20 @@ globus_gass_transfer_request_get_referral( */ char * globus_gass_transfer_request_get_url( - globus_gass_transfer_request_t request) + globus_gass_transfer_request_t request) { - globus_gass_transfer_request_struct_t * req; + globus_gass_transfer_request_struct_t * req; req = - globus_handle_table_lookup(&globus_i_gass_transfer_request_handles, - request); + globus_handle_table_lookup(&globus_i_gass_transfer_request_handles, + request); if(req == GLOBUS_NULL) { - return GLOBUS_NULL; + return GLOBUS_NULL; } else { - return req->url; + return req->url; } } /* globus_gass_transfer_request_get_url() */ @@ -320,20 +320,20 @@ globus_gass_transfer_request_get_url( */ globus_size_t globus_gass_transfer_request_get_length( - globus_gass_transfer_request_t request) + globus_gass_transfer_request_t request) { - globus_gass_transfer_request_struct_t * req; + globus_gass_transfer_request_struct_t * req; req = - globus_handle_table_lookup(&globus_i_gass_transfer_request_handles, - request); + globus_handle_table_lookup(&globus_i_gass_transfer_request_handles, + request); if(req == GLOBUS_NULL) { - return GLOBUS_GASS_TRANSFER_LENGTH_UNKNOWN; + return GLOBUS_GASS_TRANSFER_LENGTH_UNKNOWN; } else { - return req->length; + return req->length; } } @@ -361,23 +361,23 @@ globus_gass_transfer_request_get_length( */ int globus_gass_transfer_request_set_type( - globus_gass_transfer_request_t request, - globus_gass_transfer_request_type_t type) + globus_gass_transfer_request_t request, + globus_gass_transfer_request_type_t type) { - globus_gass_transfer_request_struct_t * req; + globus_gass_transfer_request_struct_t * req; req = - globus_handle_table_lookup(&globus_i_gass_transfer_request_handles, - request); + globus_handle_table_lookup(&globus_i_gass_transfer_request_handles, + request); if(req == GLOBUS_NULL|| req->type != GLOBUS_GASS_TRANSFER_REQUEST_TYPE_INVALID) { - return GLOBUS_GASS_TRANSFER_ERROR_INVALID_USE; + return GLOBUS_GASS_TRANSFER_ERROR_INVALID_USE; } else { - req->type = type; - return GLOBUS_SUCCESS; + req->type = type; + return GLOBUS_SUCCESS; } } /* globus_gass_transfer_request_set_type() */ @@ -410,23 +410,23 @@ globus_gass_transfer_request_set_type( */ int globus_gass_transfer_request_set_url( - globus_gass_transfer_request_t request, - char * url) + globus_gass_transfer_request_t request, + char * url) { - globus_gass_transfer_request_struct_t * req; + globus_gass_transfer_request_struct_t * req; req = - globus_handle_table_lookup(&globus_i_gass_transfer_request_handles, - request); + globus_handle_table_lookup(&globus_i_gass_transfer_request_handles, + request); if(req == GLOBUS_NULL || req->url != GLOBUS_NULL) { - return GLOBUS_GASS_TRANSFER_ERROR_INVALID_USE; + return GLOBUS_GASS_TRANSFER_ERROR_INVALID_USE; } else { - req->url = url; - return GLOBUS_SUCCESS; + req->url = url; + return GLOBUS_SUCCESS; } } @@ -445,29 +445,24 @@ globus_gass_transfer_request_set_url( * A handle to the request to modify. * @param length * The length of the file request. - * - * @retval GLOBUS_SUCCESS - * The URL was set for the request handle. - * @retval GLOBUS_GASS_TRANSFER_ERROR_INVALID_USE - * The request handle was invalid, or the URL had already been set. */ void globus_gass_transfer_request_set_length( - globus_gass_transfer_request_t request, - globus_size_t length) + globus_gass_transfer_request_t request, + globus_size_t length) { - globus_gass_transfer_request_struct_t * req; + globus_gass_transfer_request_struct_t * req; req = - globus_handle_table_lookup(&globus_i_gass_transfer_request_handles, - request); + globus_handle_table_lookup(&globus_i_gass_transfer_request_handles, + request); if(req == GLOBUS_NULL) { - return ; + return; } else { - req->length = length; + req->length = length; } } /* globus_gass_transfer_request_set_length() */ @@ -491,20 +486,20 @@ globus_gass_transfer_request_set_length( */ int globus_gass_transfer_request_get_denial_reason( - globus_gass_transfer_request_t request) + globus_gass_transfer_request_t request) { - globus_gass_transfer_request_struct_t * req; + globus_gass_transfer_request_struct_t * req; req = - globus_handle_table_lookup(&globus_i_gass_transfer_request_handles, - request); + globus_handle_table_lookup(&globus_i_gass_transfer_request_handles, + request); if(req == GLOBUS_NULL) { - return 0; + return 0; } else { - return req->denial_reason; + return req->denial_reason; } } @@ -526,20 +521,20 @@ globus_gass_transfer_request_get_denial_reason( */ char * globus_gass_transfer_request_get_denial_message( - globus_gass_transfer_request_t request) + globus_gass_transfer_request_t request) { - globus_gass_transfer_request_struct_t * req; + globus_gass_transfer_request_struct_t * req; req = - globus_handle_table_lookup(&globus_i_gass_transfer_request_handles, - request); + globus_handle_table_lookup(&globus_i_gass_transfer_request_handles, + request); if(req == GLOBUS_NULL) { - return GLOBUS_NULL; + return GLOBUS_NULL; } else { - return globus_libc_strdup(req->denial_message); + return globus_libc_strdup(req->denial_message); } } @@ -548,7 +543,7 @@ globus_gass_transfer_request_get_denial_message( * @ingroup globus_gass_transfer_request * * This function queries a request handle to determine the subject - * identity of the client who initiated the request. + * identity of the client who initiated the request. * The string must not be freed by the caller. * * @param request @@ -560,20 +555,20 @@ globus_gass_transfer_request_get_denial_message( */ char * globus_gass_transfer_request_get_subject( - globus_gass_transfer_request_t request) + globus_gass_transfer_request_t request) { - globus_gass_transfer_request_struct_t * req; + globus_gass_transfer_request_struct_t * req; req = - globus_handle_table_lookup(&globus_i_gass_transfer_request_handles, - request); + globus_handle_table_lookup(&globus_i_gass_transfer_request_handles, + request); if(req == GLOBUS_NULL) { - return GLOBUS_NULL; + return GLOBUS_NULL; } else { - return req->subject; + return req->subject; } } /* globus_gass_transfer_request_get_subject() */ @@ -583,26 +578,26 @@ globus_gass_transfer_request_get_subject( */ int globus_gass_transfer_request_set_subject( - globus_gass_transfer_request_t request, - char * subject) + globus_gass_transfer_request_t request, + char * subject) { - globus_gass_transfer_request_struct_t * req; + globus_gass_transfer_request_struct_t * req; req = - globus_handle_table_lookup(&globus_i_gass_transfer_request_handles, - request); + globus_handle_table_lookup(&globus_i_gass_transfer_request_handles, + request); if(req == GLOBUS_NULL) { - return GLOBUS_GASS_TRANSFER_ERROR_INVALID_USE; + return GLOBUS_GASS_TRANSFER_ERROR_INVALID_USE; } else if(req->subject != GLOBUS_NULL) { - return GLOBUS_GASS_TRANSFER_ERROR_INVALID_USE; + return GLOBUS_GASS_TRANSFER_ERROR_INVALID_USE; } else { - req->subject = subject; - return GLOBUS_SUCCESS; + req->subject = subject; + return GLOBUS_SUCCESS; } } /* globus_gass_transfer_request_set_subject() */ @@ -630,19 +625,19 @@ globus_gass_transfer_request_set_subject( */ int globus_gass_transfer_request_destroy( - globus_gass_transfer_request_t request) + globus_gass_transfer_request_t request) { - globus_gass_transfer_request_struct_t * req; - int rc; + globus_gass_transfer_request_struct_t * req; + int rc; globus_i_gass_transfer_lock(); req = - globus_handle_table_lookup(&globus_i_gass_transfer_request_handles, - request); + globus_handle_table_lookup(&globus_i_gass_transfer_request_handles, + request); if(req == GLOBUS_NULL) { - rc = GLOBUS_GASS_TRANSFER_ERROR_INVALID_USE; - goto finish; + rc = GLOBUS_GASS_TRANSFER_ERROR_INVALID_USE; + goto finish; } if(req->status != GLOBUS_GASS_TRANSFER_REQUEST_FAILED && req->status != GLOBUS_GASS_TRANSFER_REQUEST_DONE && @@ -653,8 +648,8 @@ globus_gass_transfer_request_destroy( req->status != GLOBUS_GASS_TRANSFER_REQUEST_ACTING_TO_FAILING && req->status != GLOBUS_GASS_TRANSFER_REQUEST_DENIED) { - rc = GLOBUS_GASS_TRANSFER_ERROR_INVALID_USE; - goto finish; + rc = GLOBUS_GASS_TRANSFER_ERROR_INVALID_USE; + goto finish; } rc = globus_i_gass_transfer_request_destroy(request); @@ -677,9 +672,9 @@ globus_gass_transfer_request_destroy( * @note This function must be called with the request handle mutex lock. * * @param request - * The request handle to initialize. If this function is successful, + * The request handle to initialize. If this function is successful, * the value pointed to by this will be initialized to the new - * handle id; otherwise, the it will be set to + * handle id; otherwise, the it will be set to * GLOBUS_NULL_HANDLE. * @param attr * The request attributes to use to create the handle. If non-NULL, @@ -706,69 +701,69 @@ globus_i_gass_transfer_request_init( globus_gass_transfer_callback_t callback, void * user_arg) { - globus_gass_transfer_request_struct_t * req; + globus_gass_transfer_request_struct_t * req; req = globus_malloc(sizeof(globus_gass_transfer_request_struct_t)); if(req == GLOBUS_NULL) { - goto error_exit; + goto error_exit; } if(url) { - req->url = globus_libc_strdup(url); + req->url = globus_libc_strdup(url); if(req->url == GLOBUS_NULL) { - goto free_req; + goto free_req; } } else { - req->url = GLOBUS_NULL; - } - req->type = type; - req->status = GLOBUS_GASS_TRANSFER_REQUEST_STARTING; - req->referral_url = GLOBUS_NULL; - req->referral_count = 0; - req->callback = callback; - req->callback_arg = user_arg; - req->proto = GLOBUS_NULL; - req->subject = GLOBUS_NULL; - req->denial_reason = 0; - req->denial_message = GLOBUS_NULL; - req->handled_length = 0; - req->posted_length = 0; - req->fail_callback = GLOBUS_NULL; - req->client_side = GLOBUS_FALSE; - req->user_pointer = GLOBUS_NULL; + req->url = GLOBUS_NULL; + } + req->type = type; + req->status = GLOBUS_GASS_TRANSFER_REQUEST_STARTING; + req->referral_url = GLOBUS_NULL; + req->referral_count = 0; + req->callback = callback; + req->callback_arg = user_arg; + req->proto = GLOBUS_NULL; + req->subject = GLOBUS_NULL; + req->denial_reason = 0; + req->denial_message = GLOBUS_NULL; + req->handled_length = 0; + req->posted_length = 0; + req->fail_callback = GLOBUS_NULL; + req->client_side = GLOBUS_FALSE; + req->user_pointer = GLOBUS_NULL; globus_fifo_init(&req->pending_data); if(attr) { - if(*attr) - { - req->attr = globus_object_copy(*attr); - if(req->attr == GLOBUS_NULL) - { - goto free_fifo; - } - } - else - { - req->attr = GLOBUS_NULL; - } + if(*attr) + { + req->attr = globus_object_copy(*attr); + if(req->attr == GLOBUS_NULL) + { + goto free_fifo; + } + } + else + { + req->attr = GLOBUS_NULL; + } } else { - req->attr = GLOBUS_NULL; + req->attr = GLOBUS_NULL; } *request = globus_handle_table_insert(&globus_i_gass_transfer_request_handles, - (void *) req, - 2); + (void *) req, + 2); globus_list_insert(&globus_i_gass_transfer_requests, - (void *) (intptr_t) (*request)); - + (void *) (intptr_t) (*request)); + return; free_fifo: @@ -804,32 +799,32 @@ globus_i_gass_transfer_request_init( */ int globus_i_gass_transfer_request_destroy( - globus_gass_transfer_request_t request) + globus_gass_transfer_request_t request) { - globus_bool_t referenced; - globus_gass_transfer_request_struct_t * req; + globus_bool_t referenced; + globus_gass_transfer_request_struct_t * req; req = - globus_handle_table_lookup(&globus_i_gass_transfer_request_handles, - request); + globus_handle_table_lookup(&globus_i_gass_transfer_request_handles, + request); if(req == GLOBUS_NULL) { - return GLOBUS_GASS_TRANSFER_ERROR_INVALID_USE; + return GLOBUS_GASS_TRANSFER_ERROR_INVALID_USE; } referenced = - globus_handle_table_decrement_reference(&globus_i_gass_transfer_request_handles, - request); + globus_handle_table_decrement_reference(&globus_i_gass_transfer_request_handles, + request); if(!referenced) { - int i; - globus_list_t * tmp; + int i; + globus_list_t * tmp; + + tmp = globus_list_search(globus_i_gass_transfer_requests, + (void *) (intptr_t) request); - tmp = globus_list_search(globus_i_gass_transfer_requests, - (void *) (intptr_t) request); - #if DEBUG_GASS_TRANSFER - printf(_GTSL("removing from list\n")); + printf(_GTSL("removing from list\n")); #endif if (tmp) { @@ -837,7 +832,7 @@ globus_i_gass_transfer_request_destroy( tmp); globus_cond_signal(&globus_i_gass_transfer_shutdown_cond); - + if(req->attr) { globus_object_free(req->attr); @@ -876,11 +871,11 @@ globus_i_gass_transfer_request_destroy( request = GLOBUS_NULL_HANDLE; } - return GLOBUS_SUCCESS; + return GLOBUS_SUCCESS; } else { - return GLOBUS_SUCCESS; + return GLOBUS_SUCCESS; } } /* globus_i_gass_transfer_request_destroy() */ diff --git a/gram/client/source/configure.ac b/gram/client/source/configure.ac index e8366ddacc..f5e2ac5a05 100644 --- a/gram/client/source/configure.ac +++ b/gram/client/source/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ([2.60]) -AC_INIT([globus_gram_client],[14.7],[https://github.com/gridcf/gct/issues]) +AC_INIT([globus_gram_client],[14.8],[https://github.com/gridcf/gct/issues]) AC_CONFIG_MACRO_DIR([m4]) AC_SUBST([MAJOR_VERSION], [${PACKAGE_VERSION%%.*}]) AC_SUBST([MINOR_VERSION], [${PACKAGE_VERSION##*.}]) diff --git a/gram/client/source/test/activate-test.c b/gram/client/source/test/activate-test.c index 8b272b3522..051e04a11b 100644 --- a/gram/client/source/test/activate-test.c +++ b/gram/client/source/test/activate-test.c @@ -20,15 +20,14 @@ int main(int argc, char *argv[]) { int rc; - int failed = 0; LTDL_SET_PRELOADED_SYMBOLS(); printf("1..2\n"); - failed += rc = !(!globus_module_activate(GLOBUS_GRAM_CLIENT_MODULE)); + rc = !(!globus_module_activate(GLOBUS_GRAM_CLIENT_MODULE)); printf("%s 1 - activate\n", rc==0?"ok":"not ok"); - failed += rc = !(!globus_module_deactivate(GLOBUS_GRAM_CLIENT_MODULE)); + rc = !(!globus_module_deactivate(GLOBUS_GRAM_CLIENT_MODULE)); printf("%s 2 - deactivate\n", rc==0?"ok":"not ok"); return 0; diff --git a/gram/gatekeeper/source/configure.ac b/gram/gatekeeper/source/configure.ac index e717de3a75..367b01bee3 100644 --- a/gram/gatekeeper/source/configure.ac +++ b/gram/gatekeeper/source/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ([2.60]) -AC_INIT([globus_gatekeeper],[11.4],[https://github.com/gridcf/gct/issues]) +AC_INIT([globus_gatekeeper],[11.5],[https://github.com/gridcf/gct/issues]) AC_CONFIG_MACRO_DIR([m4]) AC_SUBST([MAJOR_VERSION], [${PACKAGE_VERSION%%.*}]) AC_SUBST([MINOR_VERSION], [${PACKAGE_VERSION##*.}]) diff --git a/gram/gatekeeper/source/globus_gatekeeper_utils.c b/gram/gatekeeper/source/globus_gatekeeper_utils.c index 5e8b6ec722..341041d417 100644 --- a/gram/gatekeeper/source/globus_gatekeeper_utils.c +++ b/gram/gatekeeper/source/globus_gatekeeper_utils.c @@ -20,20 +20,20 @@ globus_gatekeeper_utils.c Description: - Some common routines used by globus_gatekeeper - and globus_gram_k5.c + Some common routines used by globus_gatekeeper + and globus_gram_k5.c CVS Information: - $Source$ - $Date$ - $Revision$ - $Author$ + $Source$ + $Date$ + $Revision$ + $Author$ ******************************************************************************/ /***************************************************************************** - Include header files + Include header files ******************************************************************************/ #include "globus_config.h" #include "globus_gatekeeper_config.h" @@ -72,226 +72,226 @@ char * fgetscont(char *line, int size, FILE* fd); static char * fgetscont(char * line, int size, FILE* fd) { - int i; - int len; - char * cp; + int i; + int len; + char * cp; - i = 2; - len = size; + i = 2; + len = size; cp = line; - *cp = '\0'; - - while(fgets(cp, len, fd) && - (i = strlen(line)) > 2 && - line[i-1] == '\n' && line[i-2] == '\\') { - len = size - i - 2; - cp = line + i - 2; - } - if (*cp == '\0') { - return NULL; - } - return line; + *cp = '\0'; + + while(fgets(cp, len, fd) && + (i = strlen(line)) > 2 && + line[i-1] == '\n' && line[i-2] == '\\') { + len = size - i - 2; + cp = line + i - 2; + } + if (*cp == '\0') { + return NULL; + } + return line; } /****************************************************************************** Function: globus_gatekeeper_util_globusxmap() Description: - Given a index, find the command to be issued. For example - this could be a service name, or a globusID, or K5 principal + Given a index, find the command to be issued. For example + this could be a service name, or a globusID, or K5 principal Parameters: - index - A pointer to a char *. will strdup with command + index + A pointer to a char *. will strdup with command Returns: ******************************************************************************/ int globus_gatekeeper_util_globusxmap( char * filename, char * index, char ** command) { - FILE * fd; - int rc; - int i; + FILE * fd; + int rc; + int i; int offset; - char f_index[256]; - char line[4096]; + char f_index[256]; + char line[4096]; - *command = NULL; + *command = NULL; - if ((fd = fopen(filename, "r")) != NULL) { + if ((fd = fopen(filename, "r")) != NULL) { - while(fgetscont(line, sizeof(line), fd)) { - i = strlen(line); - if (line[0] != '#') { /* comment line */ - if (line[i - 1] == '\n') { - line[i - 1] = '\0'; - } + while(fgetscont(line, sizeof(line), fd)) { + i = strlen(line); + if (line[0] != '#') { /* comment line */ + if (line[i - 1] == '\n') { + line[i - 1] = '\0'; + } if (!index) { - *command = strdup(line); + *command = strdup(line); + fclose(fd); + return(0); + } + + rc = sscanf(line, " \"%255[^\"]%*c%n %n", + f_index, &offset, &offset); + if (rc != 1) { + rc = sscanf(line, "%255s%n %n", + f_index, &offset, &offset); + } + if (rc == 1) { + if (!strcmp(index, f_index)) { + *command = strdup(&line[offset]); fclose(fd); return(0); + + } } - - rc = sscanf(line, " \"%255[^\"]%*c%n %n", - f_index, &offset, &offset); - if (rc != 1) { - rc = sscanf(line, "%255s%n %n", - f_index, &offset, &offset); - } - if (rc == 1) { - if (!strcmp(index, f_index)) { - *command = strdup(&line[offset]); - fclose(fd); - return(0); - - } - } - } - } - fclose(fd); - return(-1); /* not found */ - } - return(-2); /* open failed */ + } + } + fclose(fd); + return(-1); /* not found */ + } + return(-2); /* open failed */ } /****************************************************************************** Function: globus_gatekeeper_util_tokenize() Description: - Breakup the command in to args, pointing the args array - at the tokens. Replace white space at the end of each - token with a null. A token maybe in quotes. + Breakup the command in to args, pointing the args array + at the tokens. Replace white space at the end of each + token with a null. A token maybe in quotes. Parameters: - The command line to be parsed. - A pointer to an array of pointers to be filled it - Size of the array, on input, and set to size used on output. + The command line to be parsed. + A pointer to an array of pointers to be filled it + Size of the array, on input, and set to size used on output. Returns: - 0 on success. - -1 on to malloc - -2 on to many args - -3 on quote not matched + 0 on success. + -1 on to malloc + -2 on to many args + -3 on quote not matched ******************************************************************************/ int -globus_gatekeeper_util_tokenize(char * command, - char ** args, - int * n, - char * sep) +globus_gatekeeper_util_tokenize(char * command, + char ** args, + int * n, + char * sep) { - int i; - char * cp; - char * pp; - char * qp; - char ** arg; - - arg = args; - i = *n - 1; - - cp = command; - while (*cp) - { - /* skip leading sep characters */ - while (*cp && strchr(sep, *cp)) - { - cp++; - } - pp = NULL; - if (*cp == '\"') - { - cp++; - pp = cp; - if ((qp = strchr(cp,'\"')) == NULL) - { - return -3; - } - cp = qp + 1; - - } - else if (*cp) - { - pp = cp; - if ((qp = strpbrk(cp,sep)) == NULL) - { - qp = strchr(cp,'\0'); - } - cp = qp; - } - if (pp) - { - *arg = (char*)malloc((qp - pp) + 1); - if (*arg == NULL) - { - return -1; - } - memcpy(*arg,pp,qp - pp); - *(*arg + (qp - pp)) = '\0'; - i--; - if (i == 0) - return(-2); /* to many args */ - arg++; - } - } - *arg = (char *) 0; - *n = *n - i - 1; - return(0); + int i; + char * cp; + char * pp; + char * qp; + char ** arg; + + arg = args; + i = *n - 1; + + cp = command; + while (*cp) + { + /* skip leading sep characters */ + while (*cp && strchr(sep, *cp)) + { + cp++; + } + pp = NULL; + if (*cp == '\"') + { + cp++; + pp = cp; + if ((qp = strchr(cp,'\"')) == NULL) + { + return -3; + } + cp = qp + 1; + + } + else if (*cp) + { + pp = cp; + if ((qp = strpbrk(cp,sep)) == NULL) + { + qp = strchr(cp,'\0'); + } + cp = qp; + } + if (pp) + { + *arg = (char*)malloc((qp - pp) + 1); + if (*arg == NULL) + { + return -1; + } + memcpy(*arg,pp,qp - pp); + *(*arg + (qp - pp)) = '\0'; + i--; + if (i == 0) + return(-2); /* to many args */ + arg++; + } + } + *arg = (char *) 0; + *n = *n - i - 1; + return(0); } /****************************************************************************** Function: globus_gatekeeper_util_envsub() Description: - Substitute from environment string like ${text} - into arg. arg will be freed and copied. - Recursion is allowed. + Substitute from environment string like ${text} + into arg. arg will be freed and copied. + Recursion is allowed. Parameters: - arg a pointer to the string pointer. + arg a pointer to the string pointer. Returns: - 0 on success. - -1 on malloc - -3 on env string not found + 0 on success. + -1 on malloc + -3 on env string not found ******************************************************************************/ int globus_gatekeeper_util_envsub(char ** arg) { - char * cp; - char * pp; - char * qp; - char * rp; - char * narg; - - cp = *arg; - while ((pp = strstr(cp,"${"))) /* for editor matching } */ - { - pp+=2; - /* for editor matching { */ - if(!(qp = strstr(pp,"}"))) - { - return -2; /* not terminated */ - } - *(pp-2) = '\0'; /* term the prefix */ - *qp = '\0'; /* term the env name */ - qp++; - if (!(rp = getenv(pp))) - { - return -3; - } - if (!(narg = (char *)malloc(strlen(cp) + - strlen(rp) + - strlen(qp) + 1))) - { - return -1; - } - strcpy(narg,cp); - strcat(narg,rp); - strcat(narg,qp); - free(cp); - cp = narg; - *arg = cp; - } - return 0; + char * cp; + char * pp; + char * qp; + char * rp; + char * narg; + + cp = *arg; + while ((pp = strstr(cp,"${"))) /* for editor matching } */ + { + pp+=2; + /* for editor matching { */ + if(!(qp = strstr(pp,"}"))) + { + return -2; /* not terminated */ + } + *(pp-2) = '\0'; /* term the prefix */ + *qp = '\0'; /* term the env name */ + qp++; + if (!(rp = getenv(pp))) + { + return -3; + } + if (!(narg = (char *)malloc(strlen(cp) + + strlen(rp) + + strlen(qp) + 1))) + { + return -1; + } + strcpy(narg,cp); + strcat(narg,rp); + strcat(narg,qp); + free(cp); + cp = narg; + *arg = cp; + } + return 0; } /****************************************************************************** @@ -301,155 +301,154 @@ Function: globus_gatekeeper_util_exec() Returns: ******************************************************************************/ int -globus_gatekeeper_util_exec(char *args[], - struct passwd *pw, - char * user, - char **errmsgp) +globus_gatekeeper_util_exec(char *args[], + struct passwd *pw, + char * user, + char **errmsgp) { - int pid; - int err; - int rc; - char *path; - char * cp; + int pid; + int rc; + char *path; + char * cp; #define WAIT_USES_INT #ifdef WAIT_USES_INT - int wait_status; + int wait_status; #else /* WAIT_USES_INT */ - union wait wait_status; + union wait wait_status; #endif /* WAIT_USES_INT */ - pid = fork(); - if (pid <0) - return(-1); - - if (pid == 0) { /* child process */ - - /* If need to run child as user */ - if (pw != NULL) { - if ((rc = globus_gatekeeper_util_trans_to_user(pw, user, errmsgp)) != 0) { - /* child failed to transfer to user context */ - fprintf(stderr,"Failed trying to run as user %s: %s\n", - user, *errmsgp); - exit(126); - } - } - - path = strdup(args[0]); - cp = strrchr(path, '/'); - if (cp) - cp++; - else - cp = path; - - args[0] = cp; + pid = fork(); + if (pid <0) + return(-1); + + if (pid == 0) { /* child process */ + + /* If need to run child as user */ + if (pw != NULL) { + if ((rc = globus_gatekeeper_util_trans_to_user(pw, user, errmsgp)) != 0) { + /* child failed to transfer to user context */ + fprintf(stderr,"Failed trying to run as user %s: %s\n", + user, *errmsgp); + exit(126); + } + } + + path = strdup(args[0]); + cp = strrchr(path, '/'); + if (cp) + cp++; + else + cp = path; + + args[0] = cp; #ifdef DEBUG - fprintf(stderr,"EXECING %s args=",path); - { - int n = 0; - while (args[n]) { - fprintf (stderr," %s \n",args[n]); - n++; - } - fprintf(stderr,"\n"); - } + fprintf(stderr,"EXECING %s args=",path); + { + int n = 0; + while (args[n]) { + fprintf (stderr," %s \n",args[n]); + n++; + } + fprintf(stderr,"\n"); + } #endif - execv(path, args); - fprintf(stderr,"Failed to exec the child\n"); - exit(127); /* in case execl fails */ - } + execv(path, args); + fprintf(stderr,"Failed to exec the child\n"); + exit(127); /* in case execl fails */ + } - /* parent, wait for child to finish */ + /* parent, wait for child to finish */ - wait_status = 0; + wait_status = 0; #ifdef HAVE_WAITPID - err = waitpid((pid_t) pid, &wait_status, 0); + waitpid((pid_t) pid, &wait_status, 0); #else /* HAVE_WAITPID */ - err = wait4(pid, &wait_status, 0, (struct rusage *) NULL); + wait4(pid, &wait_status, 0, (struct rusage *) NULL); #endif /* HAVE_WAITPID */ - /* if it worked or failed, continue on. */ - return(wait_status); + /* if it worked or failed, continue on. */ + return(wait_status); } /****************************************************************************** Function: globus_gatekeeper_util_trans_to_user() Description: - Transition the process from root to the user, - doing all the operating system specific stuff. + Transition the process from root to the user, + doing all the operating system specific stuff. Parameters: Returns: - 0 if OK - <0 if errno is set; - >0 if some other error. - 1 if not root - DEE needs work + 0 if OK + <0 if errno is set; + >0 if some other error. + 1 if not root + DEE needs work ******************************************************************************/ int globus_gatekeeper_util_trans_to_user(struct passwd * pw, - char * userid, - char ** errmsg) + char * userid, + char ** errmsg) { - uid_t myuid; - - /* must be root to use this */ - - if ((myuid = getuid()) != 0) - { - if (myuid == pw->pw_uid) - return 0; /* already running as the user */ - else - { - *errmsg = strdup("Can not run as another user"); - return 1; /* can't run as another user */ - } - } - - /* - *DEE If we are root and want to run as root, should we continue - * here or just exit? Some logging might be usefull. - */ - setgid(pw->pw_gid); - initgroups(pw->pw_name, pw->pw_gid); - -# if defined(__hpux) - { - if (setresuid(pw->pw_uid, pw->pw_uid, -1) != 0) - { - *errmsg = strdup("cannot setresuid"); - return -2; - } - } -# elif defined(TARGET_ARCH_SOLARIS) || \ - defined(TARGET_ARCH_BSD) || \ - defined(TARGET_ARCH_CYGWIN) - { - if (setuid(pw->pw_uid) != 0) - { - *errmsg = strdup("cannot setuid"); - return -3; - } - } -# else - { - if (seteuid(0) != 0) - { - *errmsg = strdup("cannot seteuid"); - return -4; - } - - if (setreuid(pw->pw_uid, pw->pw_uid) != 0) - { - *errmsg = strdup("cannot setreuid"); - return -5; - } - } -# endif - - return 0; + uid_t myuid; + + /* must be root to use this */ + + if ((myuid = getuid()) != 0) + { + if (myuid == pw->pw_uid) + return 0; /* already running as the user */ + else + { + *errmsg = strdup("Can not run as another user"); + return 1; /* can't run as another user */ + } + } + + /* + *DEE If we are root and want to run as root, should we continue + * here or just exit? Some logging might be usefull. + */ + setgid(pw->pw_gid); + initgroups(pw->pw_name, pw->pw_gid); + +# if defined(__hpux) + { + if (setresuid(pw->pw_uid, pw->pw_uid, -1) != 0) + { + *errmsg = strdup("cannot setresuid"); + return -2; + } + } +# elif defined(TARGET_ARCH_SOLARIS) || \ + defined(TARGET_ARCH_BSD) || \ + defined(TARGET_ARCH_CYGWIN) + { + if (setuid(pw->pw_uid) != 0) + { + *errmsg = strdup("cannot setuid"); + return -3; + } + } +# else + { + if (seteuid(0) != 0) + { + *errmsg = strdup("cannot seteuid"); + return -4; + } + + if (setreuid(pw->pw_uid, pw->pw_uid) != 0) + { + *errmsg = strdup("cannot setreuid"); + return -5; + } + } +# endif + + return 0; } diff --git a/gram/jobmanager/lrms/lsf/source/configure.ac b/gram/jobmanager/lrms/lsf/source/configure.ac index 3845f72f03..a820383721 100644 --- a/gram/jobmanager/lrms/lsf/source/configure.ac +++ b/gram/jobmanager/lrms/lsf/source/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ([2.60]) -AC_INIT([globus_gram_job_manager_lsf],[3.1],[https://github.com/gridcf/gct/issues]) +AC_INIT([globus_gram_job_manager_lsf],[3.2],[https://github.com/gridcf/gct/issues]) AC_CONFIG_MACRO_DIR([m4]) AC_SUBST([MAJOR_VERSION], [${PACKAGE_VERSION%%.*}]) AC_SUBST([MINOR_VERSION], [${PACKAGE_VERSION##*.}]) diff --git a/gram/jobmanager/lrms/lsf/source/seg/seg_lsf_module.c b/gram/jobmanager/lrms/lsf/source/seg/seg_lsf_module.c index 0c0d6a01a0..9356df5c33 100644 --- a/gram/jobmanager/lrms/lsf/source/seg/seg_lsf_module.c +++ b/gram/jobmanager/lrms/lsf/source/seg/seg_lsf_module.c @@ -122,7 +122,7 @@ enum /** * State of the LSF log file parser. */ -typedef struct +typedef struct { /** * Path to the LSF logdir @@ -333,9 +333,9 @@ globus_l_lsf_module_activate(void) if (result != GLOBUS_SUCCESS) { SEGLsfDebug(SEG_LSF_DEBUG_ERROR, - ("Error retrieving log_path attribute from " + ("Error retrieving log_path attribute from " "${sysconfdir}/globus/globus-lsf.conf\n")); - + goto free_config_path_error; } free(config_path); @@ -439,7 +439,7 @@ globus_l_lsf_module_deactivate(void) * read_cb: * check to see if lsb.events.index file changed---if so, we must relocate * our position in the appropriate log file. - * + * * if we're ok---parse events buffer * * if (!eof) @@ -519,7 +519,7 @@ globus_l_lsf_read_callback( rc = fread(state->buffer + state->buffer_point + state->buffer_valid, 1, max_to_read, state->fp); - + SEGLsfDebug(SEG_LSF_DEBUG_TRACE, ("read %d bytes\n", rc)); @@ -605,9 +605,9 @@ globus_l_lsf_read_callback( /* globus_l_lsf_read_callback() */ /** - * Determine the next available LSF log file name from the + * Determine the next available LSF log file name from the * timestamp stored in the logfile state structure. - * + * * @param state * LSF log state structure. The path field of the structure may be * modified by this function. @@ -721,7 +721,7 @@ globus_l_lsf_find_logfile( /* globus_l_lsf_find_logfile() */ /** - * Move any data in the state buffer to the beginning, to enable reusing + * Move any data in the state buffer to the beginning, to enable reusing * buffer space which has already been parsed. */ static @@ -810,7 +810,6 @@ globus_l_lsf_parse_events( long long tmp_timestamp; char event_type_buffer[64]; char job_id_buffer[32]; - int rc; int job_status; int exit_status; long offset; @@ -871,7 +870,7 @@ globus_l_lsf_parse_events( { if (event_timestamp >= state->start_timestamp) { - rc = globus_scheduler_event_pending(event_timestamp, + globus_scheduler_event_pending(event_timestamp, job_id_buffer); state->start_timestamp = event_timestamp; } @@ -880,7 +879,7 @@ globus_l_lsf_parse_events( { if (event_timestamp >= state->start_timestamp) { - rc = globus_scheduler_event_active(event_timestamp, + globus_scheduler_event_active(event_timestamp, job_id_buffer); state->start_timestamp = event_timestamp; @@ -975,13 +974,13 @@ globus_l_lsf_parse_events( { sscanf(tmp, " %d", &exit_status); exit_status = (exit_status & 0xff00) >> 8; - rc = globus_scheduler_event_done(event_timestamp, + globus_scheduler_event_done(event_timestamp, job_id_buffer, exit_status); } else { - rc = globus_scheduler_event_failed(event_timestamp, + globus_scheduler_event_failed(event_timestamp, job_id_buffer, exit_status); } @@ -994,7 +993,7 @@ globus_l_lsf_parse_events( */ if (event_timestamp >= state->start_timestamp) { - rc = globus_scheduler_event_done(event_timestamp, + globus_scheduler_event_done(event_timestamp, job_id_buffer, 0); state->start_timestamp = event_timestamp; diff --git a/gram/jobmanager/lrms/sge/source/configure.ac b/gram/jobmanager/lrms/sge/source/configure.ac index 37e1703281..a627b5db25 100644 --- a/gram/jobmanager/lrms/sge/source/configure.ac +++ b/gram/jobmanager/lrms/sge/source/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ([2.60]) -AC_INIT([globus_gram_job_manager_sge],[3.3],[https://github.com/gridcf/gct/issues]) +AC_INIT([globus_gram_job_manager_sge],[3.4],[https://github.com/gridcf/gct/issues]) AC_CONFIG_MACRO_DIR([m4]) AC_SUBST([MAJOR_VERSION], [${PACKAGE_VERSION%%.*}]) AC_SUBST([MINOR_VERSION], [${PACKAGE_VERSION##*.}]) diff --git a/gram/jobmanager/lrms/sge/source/seg/seg_sge_module.c b/gram/jobmanager/lrms/sge/source/seg/seg_sge_module.c index e976bc5eb8..f6d510165f 100644 --- a/gram/jobmanager/lrms/sge/source/seg/seg_sge_module.c +++ b/gram/jobmanager/lrms/sge/source/seg/seg_sge_module.c @@ -182,7 +182,7 @@ globus_l_sge_get_file_timestamp( GlobusExtensionDefineModule(globus_seg_sge) = { - "globus_seg_sge", + "globus_seg_sge", globus_l_sge_module_activate, globus_l_sge_module_deactivate, NULL, @@ -859,7 +859,7 @@ globus_l_sge_find_logfile( /* next file */ state->file_number++; - + /** now it;s possible under quick file rotations that no * timestamp is put in the file, thus state->file_timestamp = 0. * In this case, as written above, we'll appropriately skip @@ -998,7 +998,7 @@ globus_l_sge_clean_buffer( } } SEG_SGE_DEBUG(SEG_SGE_DEBUG_INFO, - ("globus_l_sge_clean_buffer() exits\n")); + ("globus_l_sge_clean_buffer() exits\n")); return 0; } /* globus_l_sge_clean_buffer() */ @@ -1014,38 +1014,38 @@ globus_l_sge_clean_buffer( static int globus_l_sge_increase_buffer( - globus_l_sge_logfile_state_t * state) + globus_l_sge_logfile_state_t * state) { char * save = state->buffer; const size_t GLOBUS_SGE_READ_BUFFER_SIZE = 4096; int rc; SEG_SGE_DEBUG(SEG_SGE_DEBUG_INFO, - ("globus_l_sge_increase_buffer() called\n")); + ("globus_l_sge_increase_buffer() called\n")); /* If the buffer is full of valid data, enlarge it! */ if (state->buffer_valid == state->buffer_length) { - state->buffer = globus_libc_realloc(state->buffer, - state->buffer_length + GLOBUS_SGE_READ_BUFFER_SIZE); - if (state->buffer == NULL) - { - SEG_SGE_DEBUG(SEG_SGE_DEBUG_ERROR, ("realloc() failed\n")); + state->buffer = globus_libc_realloc(state->buffer, + state->buffer_length + GLOBUS_SGE_READ_BUFFER_SIZE); + if (state->buffer == NULL) + { + SEG_SGE_DEBUG(SEG_SGE_DEBUG_ERROR, ("realloc() failed\n")); - rc = SEG_SGE_ERROR_OUT_OF_MEMORY; - goto error; - } + rc = SEG_SGE_ERROR_OUT_OF_MEMORY; + goto error; + } } state->buffer_length += GLOBUS_SGE_READ_BUFFER_SIZE; SEG_SGE_DEBUG(SEG_SGE_DEBUG_INFO, - ("globus_l_sge_increase_buffer() exits w/success\n")); + ("globus_l_sge_increase_buffer() exits w/success\n")); return 0; error: SEG_SGE_DEBUG(SEG_SGE_DEBUG_WARN, - ("globus_l_sge_increase_buffer() exits w/failure\n")); + ("globus_l_sge_increase_buffer() exits w/failure\n")); state->buffer = save; return rc; } @@ -1064,20 +1064,19 @@ int globus_l_sge_check_rotated(globus_l_sge_logfile_state_t * state) { - int rc; - struct stat s; + struct stat s; - SEG_SGE_DEBUG(SEG_SGE_DEBUG_INFO, ("globus_l_sge_check_rotated() invoked.\n")); + SEG_SGE_DEBUG(SEG_SGE_DEBUG_INFO, ("globus_l_sge_check_rotated() invoked.\n")); - rc = stat(state->path,&s); - if(s.st_ino != state->file_inode) - { + stat(state->path,&s); + if(s.st_ino != state->file_inode) + { SEG_SGE_DEBUG(SEG_SGE_DEBUG_INFO, ("file has been rotated().\n")); return 1; - } + } - SEG_SGE_DEBUG(SEG_SGE_DEBUG_INFO, ("globus_l_sge_check_rotated() exit.\n")); - return 0; + SEG_SGE_DEBUG(SEG_SGE_DEBUG_INFO, ("globus_l_sge_check_rotated() exit.\n")); + return 0; } /* globus_l_sge_check_rotated */ @@ -1092,7 +1091,7 @@ globus_l_sge_check_rotated(globus_l_sge_logfile_state_t * state) static int globus_l_sge_parse_events( - globus_l_sge_logfile_state_t * state) + globus_l_sge_logfile_state_t * state) { char * eol; char * rp; @@ -1105,52 +1104,52 @@ globus_l_sge_parse_events( int exit_status; int status; SEG_SGE_DEBUG(SEG_SGE_DEBUG_INFO, - ("globus_l_sge_parse_events() called\n")); + ("globus_l_sge_parse_events() called\n")); status = 0; /* Find the next newline */ while ( (status != SEG_SGE_FOUND_FILE_TIMESTAMP) && (eol = memchr(state->buffer + state->buffer_point, - '\n', - state->buffer_valid)) != NULL) + '\n', + state->buffer_valid)) != NULL) { - /* Replace the EOL character with a NULL terminator. */ - *eol = '\0'; + /* Replace the EOL character with a NULL terminator. */ + *eol = '\0'; - SEG_SGE_DEBUG(SEG_SGE_DEBUG_TRACE, - ("parsing line %s\n", state->buffer + state->buffer_point)); + SEG_SGE_DEBUG(SEG_SGE_DEBUG_TRACE, + ("parsing line %s\n", state->buffer + state->buffer_point)); - rc = globus_l_sge_split_into_fields(state, &fields, &nfields); + rc = globus_l_sge_split_into_fields(state, &fields, &nfields); - /* If split_into_fields fails, ignore the line.*/ - if (rc != GLOBUS_SUCCESS) - { - SEG_SGE_DEBUG(SEG_SGE_DEBUG_WARN, - ("Failed to parse line %s\n", - state->buffer + state->buffer_point)); - goto free_fields; - } + /* If split_into_fields fails, ignore the line.*/ + if (rc != GLOBUS_SUCCESS) + { + SEG_SGE_DEBUG(SEG_SGE_DEBUG_WARN, + ("Failed to parse line %s\n", + state->buffer + state->buffer_point)); + goto free_fields; + } - /* If the first character is a '#', ignore the line. */ - if (strstr(fields[0], "#") == fields[0]) { - SEG_SGE_DEBUG(SEG_SGE_DEBUG_TRACE, - ("Line '%s' is a comment, skipping.\n", - state->buffer + state->buffer_point)); - goto free_fields; - } - - /* If the number of fields is < 14, ignore the line. */ - /* This is a safety check -- we will quite happily access fields[13] - * after this point. */ - if (nfields < 14) - { - SEG_SGE_DEBUG(SEG_SGE_DEBUG_TRACE, - ("too few fields, freeing and getting next line\n")); - goto free_fields; - } + /* If the first character is a '#', ignore the line. */ + if (strstr(fields[0], "#") == fields[0]) { + SEG_SGE_DEBUG(SEG_SGE_DEBUG_TRACE, + ("Line '%s' is a comment, skipping.\n", + state->buffer + state->buffer_point)); + goto free_fields; + } - /* Extract the timestamp from the first field. + /* If the number of fields is < 14, ignore the line. */ + /* This is a safety check -- we will quite happily access fields[13] + * after this point. */ + if (nfields < 14) + { + SEG_SGE_DEBUG(SEG_SGE_DEBUG_TRACE, + ("too few fields, freeing and getting next line\n")); + goto free_fields; + } + + /* Extract the timestamp from the first field. * Originally this was seconds since the epoch. Univa changed it * in UGE 8.2.0 to milliseconds since the epoch * @@ -1162,153 +1161,153 @@ globus_l_sge_parse_events( fields[0][10] = '\0'; } /* (rp is a pointer to the char immediately following the timestamp.) */ - rp = strptime(fields[0],"%s", &tm); + rp = strptime(fields[0],"%s", &tm); - if (rp == NULL || (*rp) != '\0') - { - SEG_SGE_DEBUG(SEG_SGE_DEBUG_WARN, - ("Unable to extract timestamp from first field in line '%s'\n", - state->buffer + state->buffer_point)); - goto free_fields; - } - stamp = mktime(&tm); - if (stamp == -1) - { - SEG_SGE_DEBUG(SEG_SGE_DEBUG_WARN, - ("mktime generated invalid timestamp\n")); - goto free_fields; - } + if (rp == NULL || (*rp) != '\0') + { + SEG_SGE_DEBUG(SEG_SGE_DEBUG_WARN, + ("Unable to extract timestamp from first field in line '%s'\n", + state->buffer + state->buffer_point)); + goto free_fields; + } + stamp = mktime(&tm); + if (stamp == -1) + { + SEG_SGE_DEBUG(SEG_SGE_DEBUG_WARN, + ("mktime generated invalid timestamp\n")); + goto free_fields; + } - /* for getting file-timestamp only rjp Jan.2008 */ + /* for getting file-timestamp only rjp Jan.2008 */ if(state->file_timestamp == 0) - { - state->file_timestamp = stamp; - SEG_SGE_DEBUG(SEG_SGE_DEBUG_TRACE, - (" Setting the file timestamp to %d\n",state->file_timestamp)); + { + state->file_timestamp = stamp; + SEG_SGE_DEBUG(SEG_SGE_DEBUG_TRACE, + (" Setting the file timestamp to %d\n",state->file_timestamp)); if(state->need_timestamp) - { + { status = SEG_SGE_FOUND_FILE_TIMESTAMP; /* will kick out of loop */ - goto free_fields; - } - } + goto free_fields; + } + } - when = mktime(&state->start_timestamp); + when = mktime(&state->start_timestamp); - if (stamp < when) - { - /* Skip messages which are before our start timestamp */ - SEG_SGE_DEBUG(SEG_SGE_DEBUG_TRACE, - ("Skipping entry as timestamp %d is before checkpoint %d\n", - stamp, when)); - status = SEG_SGE_SKIP_LINE; - goto free_fields; - } + if (stamp < when) + { + /* Skip messages which are before our start timestamp */ + SEG_SGE_DEBUG(SEG_SGE_DEBUG_TRACE, + ("Skipping entry as timestamp %d is before checkpoint %d\n", + stamp, when)); + status = SEG_SGE_SKIP_LINE; + goto free_fields; + } - /* Batch accounting: resources consumed by the job */ - /* - * UGE reporting file notes that an "extra" acct record is sent to the reporting file at - * midnight for long running jobs. These will be uniquely identified with - * exit_status (fields[14]) = -1 and should be skipped. rjporter 05/2013 - * - */ - if ((strstr(fields[1], "acct") == fields[1]) && !(strstr(fields[14], "-1") == fields[14])) - { + /* Batch accounting: resources consumed by the job */ + /* + * UGE reporting file notes that an "extra" acct record is sent to the reporting file at + * midnight for long running jobs. These will be uniquely identified with + * exit_status (fields[14]) = -1 and should be skipped. rjporter 05/2013 + * + */ + if ((strstr(fields[1], "acct") == fields[1]) && !(strstr(fields[14], "-1") == fields[14])) + { char * job_id; - int failed; - /* From the SGE 'reporting' man page: - * - * failed: - * Indicates the problem which occurred in case a job could not be - * started on the execution host (e.g. because the owner of the job - * did not have a valid account on that machine). If Grid Engine - * tries to start a job multiple times, this may lead to multiple - * entries in the accounting file corresponding to the same job ID. - * - * exit status: - * Exit status of the job script (or Grid Engine specific status in - * case of certain error conditions) - */ - - /* Lookup the exit status of the job. */ - rc = sscanf(fields[13], "%d", &failed); - rc = sscanf(fields[14], "%d", &exit_status); + int failed; + /* From the SGE 'reporting' man page: + * + * failed: + * Indicates the problem which occurred in case a job could not be + * started on the execution host (e.g. because the owner of the job + * did not have a valid account on that machine). If Grid Engine + * tries to start a job multiple times, this may lead to multiple + * entries in the accounting file corresponding to the same job ID. + * + * exit status: + * Exit status of the job script (or Grid Engine specific status in + * case of certain error conditions) + */ + + /* Lookup the exit status of the job. */ + rc = sscanf(fields[13], "%d", &failed); + rc = sscanf(fields[14], "%d", &exit_status); job_id = globus_common_create_string( "%s.%s", fields[7], nfields > 37 ? fields[37] : "0"); - /* Return a job failure event if the exit status is non-zero. */ - if ( failed != 0) - { - SEG_SGE_DEBUG(SEG_SGE_DEBUG_INFO, - ("New event: job %s has failed with exit status %d.\n", - job_id, exit_status)); - rc = globus_scheduler_event_failed(stamp, job_id, failed); - } - else - { - SEG_SGE_DEBUG(SEG_SGE_DEBUG_INFO, - ("New event: job %s has done with exit status %d.\n", - job_id, exit_status)); - rc = globus_scheduler_event_done(stamp, job_id, exit_status); - } + /* Return a job failure event if the exit status is non-zero. */ + if ( failed != 0) + { + SEG_SGE_DEBUG(SEG_SGE_DEBUG_INFO, + ("New event: job %s has failed with exit status %d.\n", + job_id, exit_status)); + rc = globus_scheduler_event_failed(stamp, job_id, failed); + } + else + { + SEG_SGE_DEBUG(SEG_SGE_DEBUG_INFO, + ("New event: job %s has done with exit status %d.\n", + job_id, exit_status)); + rc = globus_scheduler_event_done(stamp, job_id, exit_status); + } free(job_id); - } - else if (strstr(fields[1], "job_log") == fields[1]) - { + } + else if (strstr(fields[1], "job_log") == fields[1]) + { char * job_id; - /* Job state change. */ - if (strstr(fields[3], "pending") == fields[3]) - { + /* Job state change. */ + if (strstr(fields[3], "pending") == fields[3]) + { job_id = globus_common_create_string( "%s.%s", fields[4], fields[5]); - SEG_SGE_DEBUG(SEG_SGE_DEBUG_INFO, - ("New event: job %s now pending at t=%d\n", + SEG_SGE_DEBUG(SEG_SGE_DEBUG_INFO, + ("New event: job %s now pending at t=%d\n", job_id, stamp)); - rc = globus_scheduler_event_pending(stamp, job_id); + rc = globus_scheduler_event_pending(stamp, job_id); free(job_id); - } - else if (strstr(fields[3], "delivered") == fields[3]) - { + } + else if (strstr(fields[3], "delivered") == fields[3]) + { job_id = globus_common_create_string( "%s.%s", fields[4], fields[5]); - SEG_SGE_DEBUG(SEG_SGE_DEBUG_INFO, - ("New event: job %s now active at t=%d\n", + SEG_SGE_DEBUG(SEG_SGE_DEBUG_INFO, + ("New event: job %s now active at t=%d\n", job_id, stamp)); - rc = globus_scheduler_event_active(stamp, job_id); + rc = globus_scheduler_event_active(stamp, job_id); free(job_id); - } - else if (strstr(fields[3], "deleted") == fields[3]) - { + } + else if (strstr(fields[3], "deleted") == fields[3]) + { job_id = globus_common_create_string( "%s.%s", fields[4], fields[5]); - SEG_SGE_DEBUG(SEG_SGE_DEBUG_INFO, - ("New event: job %s now completed at t=%d\n", + SEG_SGE_DEBUG(SEG_SGE_DEBUG_INFO, + ("New event: job %s now completed at t=%d\n", job_id, stamp)); - rc = globus_scheduler_event_done(stamp, job_id, 0); + rc = globus_scheduler_event_done(stamp, job_id, 0); free(job_id); - } - } + } + } free_fields: - if (fields != NULL) - { - SEG_SGE_DEBUG(SEG_SGE_DEBUG_INFO, - ("freeing fields\n")); - globus_libc_free(fields); - fields = NULL; - } + if (fields != NULL) + { + SEG_SGE_DEBUG(SEG_SGE_DEBUG_INFO, + ("freeing fields\n")); + globus_libc_free(fields); + fields = NULL; + } - state->buffer_valid -= eol + 1 - state->buffer - state->buffer_point; - state->buffer_point = eol + 1 - state->buffer; + state->buffer_valid -= eol + 1 - state->buffer - state->buffer_point; + state->buffer_point = eol + 1 - state->buffer; } SEG_SGE_DEBUG(SEG_SGE_DEBUG_INFO, - ("globus_l_sge_parse_events() exits\n")); + ("globus_l_sge_parse_events() exits\n")); return status; } /* globus_l_sge_parse_events() */ @@ -1362,17 +1361,17 @@ globus_l_sge_get_file_timestamp(globus_l_sge_logfile_state_t* state) /* Actually perform the read. */ rc = fread(state->buffer + state->buffer_point + - state->buffer_valid, 1, max_to_read, state->fp); + state->buffer_valid, 1, max_to_read, state->fp); SEG_SGE_DEBUG(SEG_SGE_DEBUG_TRACE, ("Read %d bytes\n", rc)); - /* If we haven't read the most we could, we have either: */ + /* If we haven't read the most we could, we have either: */ - if (rc < max_to_read) - { - /* Reached the end of the file or some other problem - either way assume EOF */ - eof_hit = GLOBUS_TRUE; - } + if (rc < max_to_read) + { + /* Reached the end of the file or some other problem - either way assume EOF */ + eof_hit = GLOBUS_TRUE; + } state->buffer_valid += rc; /* try to find the file timestamp inside the buffer */ @@ -1397,7 +1396,7 @@ globus_l_sge_get_file_timestamp(globus_l_sge_logfile_state_t* state) if(state->file_timestamp == 0 ) { - SEG_SGE_DEBUG(SEG_SGE_DEBUG_TRACE, + SEG_SGE_DEBUG(SEG_SGE_DEBUG_TRACE, (" Could not get timestamp from file ")); return -1; } @@ -1428,9 +1427,9 @@ globus_l_sge_get_file_timestamp(globus_l_sge_logfile_state_t* state) static int globus_l_sge_split_into_fields( - globus_l_sge_logfile_state_t * state, - char *** fields, - size_t * nfields) + globus_l_sge_logfile_state_t * state, + char *** fields, + size_t * nfields) { size_t i = 0; size_t cnt = 1; @@ -1448,11 +1447,11 @@ globus_l_sge_split_into_fields( while (*tmp != '\0') { - if (*tmp == ':') - { - cnt++; - } - tmp++; + if (*tmp == ':') + { + cnt++; + } + tmp++; } SEG_SGE_DEBUG(SEG_SGE_DEBUG_TRACE, ("%u fields\n", cnt)); @@ -1460,8 +1459,8 @@ globus_l_sge_split_into_fields( if (*fields == NULL) { - rc = SEG_SGE_ERROR_OUT_OF_MEMORY; - goto error; + rc = SEG_SGE_ERROR_OUT_OF_MEMORY; + goto error; } *nfields = cnt; @@ -1471,32 +1470,32 @@ globus_l_sge_split_into_fields( while (*tmp != '\0' && i < cnt) { - if (*tmp == ':') - { - (*fields)[i++] = tmp+1; - *tmp = '\0'; - } - tmp++; + if (*tmp == ':') + { + (*fields)[i++] = tmp+1; + *tmp = '\0'; + } + tmp++; } # if BUILD_DEBUG { - for (i = 0; i < cnt; i++) - { - SEG_SGE_DEBUG(SEG_SGE_DEBUG_TRACE, ("field[%u]=%s\n", - i, (*fields)[i])); - } + for (i = 0; i < cnt; i++) + { + SEG_SGE_DEBUG(SEG_SGE_DEBUG_TRACE, ("field[%u]=%s\n", + i, (*fields)[i])); + } } # endif SEG_SGE_DEBUG(SEG_SGE_DEBUG_INFO, - ("globus_l_sge_split_into_fields(): exit success\n")); + ("globus_l_sge_split_into_fields(): exit success\n")); return 0; error: SEG_SGE_DEBUG(SEG_SGE_DEBUG_WARN, - ("globus_l_sge_split_into_fields(): exit failure: %d\n", rc)); + ("globus_l_sge_split_into_fields(): exit failure: %d\n", rc)); return rc;; } /* globus_l_sge_split_into_fields() */ diff --git a/gram/jobmanager/scheduler_event_generator/source/configure.ac b/gram/jobmanager/scheduler_event_generator/source/configure.ac index 3711ca1f1c..d893cdebcb 100644 --- a/gram/jobmanager/scheduler_event_generator/source/configure.ac +++ b/gram/jobmanager/scheduler_event_generator/source/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ([2.60]) -AC_INIT([globus_scheduler_event_generator],[6.6],[https://github.com/gridcf/gct/issues]) +AC_INIT([globus_scheduler_event_generator],[6.7],[https://github.com/gridcf/gct/issues]) AC_CONFIG_MACRO_DIR([m4]) AC_SUBST([MAJOR_VERSION], [${PACKAGE_VERSION%%.*}]) AC_SUBST([MINOR_VERSION], [${PACKAGE_VERSION##*.}]) diff --git a/gram/jobmanager/scheduler_event_generator/source/globus_scheduler_event_generator.c b/gram/jobmanager/scheduler_event_generator/source/globus_scheduler_event_generator.c index 434244833b..bd503ab368 100644 --- a/gram/jobmanager/scheduler_event_generator/source/globus_scheduler_event_generator.c +++ b/gram/jobmanager/scheduler_event_generator/source/globus_scheduler_event_generator.c @@ -92,7 +92,7 @@ globus_l_seg_deactivate(void) /** * Send an arbitrary SEG notification. - * @ingroup seg_api + * @ingroup globus_scheduler_event_generator_api * * @param format * Printf-style format of the SEG notification message @@ -170,7 +170,7 @@ globus_scheduler_event( /** * Send a job pending event to the JobSchedulerMonitor implementation. - * @ingroup seg_api + * @ingroup globus_scheduler_event_generator_api * * @param timestamp * Timestamp to use for the event. If set to 0, the time which @@ -203,7 +203,7 @@ globus_scheduler_event_pending( event.exit_code = 0; event.failure_code = 0; event.raw_event = NULL; - + if (globus_l_seg_event_handler != NULL) { (*globus_l_seg_event_handler)( @@ -217,7 +217,7 @@ globus_scheduler_event_pending( /** * Send a job active event to the JobSchedulerMonitor implementation. - * @ingroup seg_api + * @ingroup globus_scheduler_event_generator_api * * @param timestamp * Timestamp to use for the event. If set to 0, the time which @@ -262,7 +262,7 @@ globus_scheduler_event_active( /** * Send a job failed event to the JobSchedulerMonitor implementation. - * @ingroup seg_api + * @ingroup globus_scheduler_event_generator_api * * @param timestamp * Timestamp to use for the event. If set to 0, the time which @@ -298,7 +298,7 @@ globus_scheduler_event_failed( event.exit_code = 0; event.failure_code = failure_code; event.raw_event = NULL; - + if (globus_l_seg_event_handler != NULL) { (*globus_l_seg_event_handler)( @@ -310,7 +310,7 @@ globus_scheduler_event_failed( /** * Send a job done event to the JobSchedulerMonitor implementation. - * @ingroup seg_api + * @ingroup globus_scheduler_event_generator_api * * @param timestamp * Timestamp to use for the event. If set to 0, the time which @@ -346,7 +346,7 @@ globus_scheduler_event_done( event.exit_code = exit_code; event.failure_code = 0; event.raw_event = NULL; - + if (globus_l_seg_event_handler != NULL) { (*globus_l_seg_event_handler)( @@ -358,7 +358,7 @@ globus_scheduler_event_done( /** * Get the timestamp for the earliest event an SEG module should send. - * @ingroup seg_api + * @ingroup globus_scheduler_event_generator_api * * @param timestamp * Pointer to a time_t which will be set to the timestamp passed to the diff --git a/gram/jobmanager/scheduler_event_generator/source/globus_scheduler_event_generator_stdout.c b/gram/jobmanager/scheduler_event_generator/source/globus_scheduler_event_generator_stdout.c index ae426c0075..d584253e1e 100644 --- a/gram/jobmanager/scheduler_event_generator/source/globus_scheduler_event_generator_stdout.c +++ b/gram/jobmanager/scheduler_event_generator/source/globus_scheduler_event_generator_stdout.c @@ -275,7 +275,7 @@ globus_l_seg_stdout_activate(void) { goto close_out_handle_error; - + } result = globus_xio_open(globus_l_seg_input_handle, "", in_attr); @@ -378,7 +378,7 @@ globus_l_seg_stdout_deactivate(void) /** * Send an arbitrary SEG notification. - * @ingroup seg_api + * @ingroup globus_scheduler_event_generator_api * * @param format * Printf-style format of the SEG notification message @@ -468,7 +468,7 @@ globus_l_xio_read_eof_callback( globus_l_seg_input_buffer_size * 2); globus_assert (tmp != NULL); globus_l_seg_input_buffer = tmp; - + buffer = globus_l_seg_input_buffer + offset; } @@ -493,7 +493,7 @@ globus_l_xio_read_eof_callback( { memmove(globus_l_seg_input_buffer, prev, - end - prev); + end - prev); } if (result == GLOBUS_SUCCESS) diff --git a/gram/jobmanager/scheduler_event_generator/source/test/globus_scheduler_event_generator_stdout.c b/gram/jobmanager/scheduler_event_generator/source/test/globus_scheduler_event_generator_stdout.c index e526c671f9..68a4437fe6 100644 --- a/gram/jobmanager/scheduler_event_generator/source/test/globus_scheduler_event_generator_stdout.c +++ b/gram/jobmanager/scheduler_event_generator/source/test/globus_scheduler_event_generator_stdout.c @@ -269,7 +269,7 @@ globus_l_seg_stdout_activate(void) { goto close_out_handle_error; - + } result = globus_xio_open(globus_l_seg_input_handle, "", in_attr); @@ -369,7 +369,7 @@ globus_l_seg_stdout_deactivate(void) /** * Send an arbitrary SEG notification. - * @ingroup seg_api + * @ingroup globus_scheduler_event_generator_api * * @param format * Printf-style format of the SEG notification message diff --git a/gram/jobmanager/source/configure.ac b/gram/jobmanager/source/configure.ac index 062e7ad142..db45b57988 100644 --- a/gram/jobmanager/source/configure.ac +++ b/gram/jobmanager/source/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ([2.60]) -AC_INIT([globus_gram_job_manager],[15.10],[https://github.com/gridcf/gct/issues]) +AC_INIT([globus_gram_job_manager],[15.11],[https://github.com/gridcf/gct/issues]) AC_CONFIG_MACRO_DIR([m4]) AC_SUBST([MAJOR_VERSION], [${PACKAGE_VERSION%%.*}]) AC_SUBST([MINOR_VERSION], [${PACKAGE_VERSION##*.}]) diff --git a/gram/jobmanager/source/globus_gram_job_manager.c b/gram/jobmanager/source/globus_gram_job_manager.c index b617fe2533..6c03aecf3a 100644 --- a/gram/jobmanager/source/globus_gram_job_manager.c +++ b/gram/jobmanager/source/globus_gram_job_manager.c @@ -364,8 +364,8 @@ globus_gram_job_manager_init( rc = GLOBUS_GRAM_PROTOCOL_ERROR_MALLOC_FAILED; goto event_queue_init_failed; } - manager->usagetracker = - calloc(1, sizeof(globus_i_gram_usage_tracker_t)); + manager->usagetracker = + calloc(1, sizeof(globus_i_gram_usage_tracker_t)); if (manager->usagetracker == NULL) { rc = GLOBUS_GRAM_PROTOCOL_ERROR_MALLOC_FAILED; @@ -408,7 +408,7 @@ globus_gram_job_manager_init( globus_gram_job_manager_validation_destroy( manager->validation_records); manager->validation_records = NULL; - + globus_cond_destroy(&manager->cond); cond_init_failed: GlobusGramJobManagerUnlock(manager); @@ -424,10 +424,10 @@ globus_gram_job_manager_init( /** * Destroy job manager state - * + * * Memory used for runtime processing is freed, the GRAM listener and the SEG * are shut down. - * + * * @param manager * Manager to destroy */ @@ -449,7 +449,7 @@ globus_gram_job_manager_destroy( globus_gram_job_manager_validation_destroy( manager->validation_records); manager->validation_records = NULL; - + globus_hashtable_destroy(&manager->request_hash); globus_hashtable_destroy(&manager->job_id_hash); @@ -458,7 +458,7 @@ globus_gram_job_manager_destroy( while (!globus_list_empty(manager->scripts_per_client)) { globus_gram_job_manager_scripts_t *scripts; - + scripts = globus_list_remove( &manager->scripts_per_client, manager->scripts_per_client); @@ -468,12 +468,12 @@ globus_gram_job_manager_destroy( free(scripts->client_addr); free(scripts); } - + if(manager->usagetracker) { free(manager->usagetracker); } - + return; } /* globus_gram_job_manager_destroy() */ @@ -513,7 +513,7 @@ globus_gram_job_manager_log( va_end(ap); logged = GLOBUS_TRUE; } - + if ((!logged) && (manager && !manager->done)) { /* Hack to write to stderr in the case the error happens before we @@ -615,10 +615,10 @@ globus_gram_job_manager_add_request( { manager->usagetracker->count_current_jobs++; - if(manager->usagetracker->count_peak_jobs < + if(manager->usagetracker->count_peak_jobs < manager->usagetracker->count_current_jobs) { - manager->usagetracker->count_peak_jobs = + manager->usagetracker->count_peak_jobs = manager->usagetracker->count_current_jobs; } } @@ -726,7 +726,7 @@ globus_gram_job_manager_add_request( * Pointer to the reference counter structure that is allocated by * this function. * - * + * * @retval GLOBUS_SUCCESS * Success * @retval GLOBUS_GRAM_PROTOCOL_ERROR_OLD_JM_ALIVE @@ -1148,10 +1148,10 @@ globus_l_gram_job_manager_remove_reference_locked( request->manager->seg_started && request->jobmanager_state != GLOBUS_GRAM_JOB_MANAGER_STATE_STOP) || - (request->jobmanager_state == + (request->jobmanager_state == GLOBUS_GRAM_JOB_MANAGER_STATE_STOP && (manager->stop == GLOBUS_TRUE || - manager->seg_started == GLOBUS_FALSE || + manager->seg_started == GLOBUS_FALSE || request->restart_state == GLOBUS_GRAM_JOB_MANAGER_STATE_TWO_PHASE_END || request->restart_state == GLOBUS_GRAM_JOB_MANAGER_STATE_FAILED_TWO_PHASE))) { @@ -1263,7 +1263,7 @@ globus_gram_job_manager_register_job_id( request->job_contact_path, job_id); - if (manager->config->seg_module != NULL || + if (manager->config->seg_module != NULL || strcmp(manager->config->jobmanager_type, "condor") == 0) { /* If we're using the SEG, split on /,/ so that seg events can be @@ -1959,7 +1959,7 @@ globus_gram_job_manager_set_grace_period_timer( /** * Fake a two-phase commit for jobs that are in a done state, but are older * than their expiration time. - * + * * @param arg * Pointer to the job manager structure for this job. * @return void @@ -2033,11 +2033,11 @@ globus_gram_job_manager_expire_old_jobs( goto oneshot_failed; } } - + expired++; } oneshot_failed: - rc = globus_l_gram_job_manager_remove_reference_locked( + rc = globus_l_gram_job_manager_remove_reference_locked( manager, ref->key, "expire"); @@ -2202,10 +2202,10 @@ globus_gram_job_manager_stop_all_jobs( * Scan the job state directory for jobs to restart * * The globus_gram_job_manager_request_load_all() function scans the - * job state directory named in the job manager configuration and then - * attempts to reload each job found in that directory. If the job is in + * job state directory named in the job manager configuration and then + * attempts to reload each job found in that directory. If the job is in * a state where it will be immediately swapped out (waiting for SEG events) - * then the job is registered for processing + * then the job is registered for processing * * @param manager * Job Manager @@ -2268,7 +2268,7 @@ globus_gram_job_manager_request_load_all( rc = GLOBUS_GRAM_PROTOCOL_ERROR_MALLOC_FAILED; goto state_file_pattern_alloc_failed; } - + hashed_job_dir = globus_common_create_string( "%s/%s/%s/%s", manager->config->job_state_file_dir, @@ -2531,7 +2531,7 @@ globus_l_gram_job_manager_request_load_all_from_dir( /* Optimize the (hopefully) common case. The job is pending * or active in the queue and we will want to wait for * job state changes. In this case, we add the reference to - * the job's LRM job id + * the job's LRM job id */ if ((request->config->seg_module != NULL || strcmp(request->config->jobmanager_type, "fork") == 0 || @@ -2574,7 +2574,7 @@ globus_l_gram_job_manager_request_load_all_from_dir( } /* Add a stub in the job manager's request_hash for this job. The * Reference count will be left at 0, and we will null out the - * ref->request pointer below. This allows queries, SEG events, and + * ref->request pointer below. This allows queries, SEG events, and * the restart code to look up the job ID without the entire * request remaining in memory. */ @@ -2771,7 +2771,6 @@ globus_l_gram_ref_swap_out( globus_gram_job_manager_ref_t * ref = arg; globus_gram_jobmanager_request_t * request; - int rc; globus_gram_job_manager_log( ref->manager, @@ -2883,7 +2882,7 @@ globus_l_gram_ref_swap_out( "No new references to job, writing state and freeing data"); /* Is this needed? */ - rc = globus_gram_job_manager_state_file_write(ref->request); + globus_gram_job_manager_state_file_write(ref->request); globus_gram_job_manager_request_free(ref->request); free(ref->request); @@ -2916,7 +2915,6 @@ globus_l_gram_add_reference_locked( globus_gram_jobmanager_request_t ** request) { int rc = GLOBUS_SUCCESS; - globus_result_t result; globus_gram_job_manager_ref_t * ref; globus_gram_job_manager_log( @@ -2936,7 +2934,7 @@ globus_l_gram_add_reference_locked( if (ref->cleanup_timer != GLOBUS_NULL_HANDLE) { - result = globus_callback_unregister( + globus_callback_unregister( ref->cleanup_timer, NULL, NULL, @@ -2979,16 +2977,16 @@ globus_l_gram_add_reference_locked( ref->request->restart_state == GLOBUS_GRAM_JOB_MANAGER_STATE_POLL_QUERY1 || ref->request->restart_state == - GLOBUS_GRAM_JOB_MANAGER_STATE_POLL_QUERY2) + GLOBUS_GRAM_JOB_MANAGER_STATE_POLL_QUERY2) { - ref->request->jobmanager_state = GLOBUS_GRAM_JOB_MANAGER_STATE_POLL2; - } + ref->request->jobmanager_state = GLOBUS_GRAM_JOB_MANAGER_STATE_POLL2; + } else if (!ref->loaded_only) { ref->request->jobmanager_state = ref->request->restart_state; - } + } ref->loaded_only = GLOBUS_FALSE; - + ref->request->job_stats.status_count += ref->status_count; ref->status_count = 0; } @@ -3263,7 +3261,7 @@ globus_l_gram_script_attr_init( pipe_cmd[3] = "-c"; pipe_cmd[4] = "interactive"; pipe_cmd[5] = "-l"; - result = globus_eval_path( + result = globus_eval_path( "${libdir}", &pipe_cmd[6]); if (result != GLOBUS_SUCCESS || pipe_cmd[6] == NULL) diff --git a/gram/jobmanager/source/globus_gram_job_manager_query.c b/gram/jobmanager/source/globus_gram_job_manager_query.c index 290133116e..4ef5632c17 100644 --- a/gram/jobmanager/source/globus_gram_job_manager_query.c +++ b/gram/jobmanager/source/globus_gram_job_manager_query.c @@ -536,7 +536,6 @@ globus_l_gram_job_manager_cancel( globus_bool_t * reply) { int rc = GLOBUS_SUCCESS; - globus_result_t result; globus_gram_job_manager_query_t * query; globus_reltime_t delay; @@ -561,7 +560,7 @@ globus_l_gram_job_manager_cancel( if(request->poll_timer != GLOBUS_HANDLE_TABLE_NO_HANDLE) { GlobusTimeReltimeSet(delay, 0, 0); - result = globus_callback_adjust_oneshot( + globus_callback_adjust_oneshot( request->poll_timer, &delay); } @@ -584,15 +583,15 @@ globus_l_gram_job_manager_cancel( case GLOBUS_GRAM_JOB_MANAGER_STATE_POLL_QUERY1: case GLOBUS_GRAM_JOB_MANAGER_STATE_POLL_QUERY2: query = calloc(1, sizeof(globus_gram_job_manager_query_t)); - + query->type = GLOBUS_GRAM_JOB_MANAGER_CANCEL; query->handle = handle; query->signal = 0; query->signal_arg = NULL; - + globus_fifo_enqueue(&request->pending_queries, query); *reply = GLOBUS_FALSE; - + if(request->jobmanager_state == GLOBUS_GRAM_JOB_MANAGER_STATE_POLL2) { request->jobmanager_state = @@ -600,7 +599,7 @@ globus_l_gram_job_manager_cancel( if(request->poll_timer != GLOBUS_HANDLE_TABLE_NO_HANDLE) { GlobusTimeReltimeSet(delay, 0, 0); - result = globus_callback_adjust_oneshot( + globus_callback_adjust_oneshot( request->poll_timer, &delay); } @@ -764,7 +763,7 @@ globus_l_gram_job_manager_renew( -rc, msg, globus_gram_protocol_error_string(rc)); - + globus_gram_job_manager_remove_reference( request->manager, request->job_contact_path, @@ -794,7 +793,6 @@ globus_l_gram_job_manager_signal( globus_off_t err_size = -1; globus_reltime_t delay; globus_gram_job_manager_query_t * query; - globus_result_t result; globus_gram_job_manager_request_log( request, @@ -816,7 +814,7 @@ globus_l_gram_job_manager_signal( { return GLOBUS_GRAM_PROTOCOL_ERROR_HTTP_UNPACK_FAILED; } - after_signal = strchr(args,' '); + after_signal = (char *) strchr(args,' '); if (after_signal) *after_signal++ = '\0'; @@ -985,7 +983,7 @@ globus_l_gram_job_manager_signal( if(request->poll_timer != GLOBUS_HANDLE_TABLE_NO_HANDLE) { GlobusTimeReltimeSet(delay, 0, 0); - result = globus_callback_adjust_oneshot( + globus_callback_adjust_oneshot( request->poll_timer, &delay); } @@ -1026,7 +1024,7 @@ globus_l_gram_job_manager_signal( } else if(request->jobmanager_state == GLOBUS_GRAM_JOB_MANAGER_STATE_TWO_PHASE || - request->jobmanager_state == + request->jobmanager_state == GLOBUS_GRAM_JOB_MANAGER_STATE_START) { request->jobmanager_state = @@ -1099,7 +1097,7 @@ globus_l_gram_job_manager_signal( if(request->poll_timer != GLOBUS_HANDLE_TABLE_NO_HANDLE) { GlobusTimeReltimeSet(delay, 0, 0); - result = globus_callback_adjust_oneshot( + globus_callback_adjust_oneshot( request->poll_timer, &delay); } @@ -1180,7 +1178,7 @@ globus_l_gram_job_manager_signal( if(request->poll_timer != GLOBUS_HANDLE_TABLE_NO_HANDLE) { GlobusTimeReltimeSet(delay, 0, 0); - result = globus_callback_adjust_oneshot( + globus_callback_adjust_oneshot( request->poll_timer, &delay); } diff --git a/gram/jobmanager/source/globus_gram_job_manager_script.c b/gram/jobmanager/source/globus_gram_job_manager_script.c index 2cf3119263..a37d5fc352 100644 --- a/gram/jobmanager/source/globus_gram_job_manager_script.c +++ b/gram/jobmanager/source/globus_gram_job_manager_script.c @@ -95,11 +95,11 @@ globus_gram_job_manager_script_context_t; static void globus_l_gram_job_manager_script_read( - globus_xio_handle_t handle, + globus_xio_handle_t handle, globus_result_t result, globus_byte_t * buffer, globus_size_t len, - globus_size_t nbytes, + globus_size_t nbytes, globus_xio_data_descriptor_t data_desc, void * user_arg); @@ -197,7 +197,7 @@ globus_l_gram_script_open_callback( static int globus_l_gram_script_register_read_and_write( - globus_gram_job_manager_script_context_t * + globus_gram_job_manager_script_context_t * script_context); static @@ -353,11 +353,11 @@ globus_l_gram_job_manager_script_run( static void globus_l_gram_job_manager_script_read( - globus_xio_handle_t handle, + globus_xio_handle_t handle, globus_result_t result, globus_byte_t * buffer, globus_size_t len, - globus_size_t nbytes, + globus_size_t nbytes, globus_xio_data_descriptor_t data_desc, void * user_arg) { @@ -563,18 +563,18 @@ globus_l_gram_job_manager_script_read( if (sizeof(script_handle->return_buf) > script_handle->return_buf_offset) { - globus_gram_job_manager_request_log( - script_context->request, - GLOBUS_GRAM_JOB_MANAGER_LOG_TRACE, - "event=gram.script_read.info " - "level=TRACE " - "message=\"registering read\" " - "return_buf_offset=%d " - "read_len=%d " - "\n", - (int) script_handle->return_buf_offset, - (int) (sizeof(script_handle->return_buf) - script_handle->return_buf_offset), - p); + globus_gram_job_manager_request_log( + script_context->request, + GLOBUS_GRAM_JOB_MANAGER_LOG_TRACE, + "event=gram.script_read.info " + "level=TRACE " + "message=\"registering read\" " + "return_buf_offset=%d " + "read_len=%d " + "\n", + (int) script_handle->return_buf_offset, + (int) (sizeof(script_handle->return_buf) - script_handle->return_buf_offset), + p); result = globus_xio_register_read( script_handle->handle, &script_handle->return_buf[script_handle->return_buf_offset], @@ -638,7 +638,7 @@ globus_l_gram_job_manager_script_read( globus_list_search_pred( request->manager->scripts_per_client, globus_l_match_script_client_addr, - request->job_stats.client_address + request->job_stats.client_address ? request->job_stats.client_address : (void *) GLOBUS_GRAM_SCRIPT_NO_CLIENT)); @@ -686,7 +686,7 @@ globus_l_gram_job_manager_script_read( * Submit a job request to a local scheduler. * * This function submits the passed job request to the local scheduler - * script. + * script. * * @param request * The request containing the job description and related information. @@ -815,7 +815,7 @@ static void job_contact_strip_port( * Try to poll status of job request using Condor grid_manager_monitor_agent * * If the Condor grid_manager_monitor_agent is running on the machine, this - * function retrieve job request status using that, otherwise it fails. + * function retrieve job request status using that, otherwise it fails. * Expected to be called exclusively from globus_gram_job_manager_script_poll. */ int @@ -1024,7 +1024,7 @@ globus_gram_job_manager_script_poll_fast( return_val = GLOBUS_FAILURE; FAST_POLL_EXIT: - if(grid_monitor_file) + if(grid_monitor_file) fclose(grid_monitor_file); for ( i = 0; grid_monitor_files[i]; i++ ) { free(grid_monitor_files[i]); @@ -1050,7 +1050,7 @@ globus_gram_job_manager_script_poll_fast( * is the same as the result from the value of request's status field. This * field will be updated if the job's status has changed. */ -int +int globus_gram_job_manager_script_poll( globus_gram_jobmanager_request_t * request) { @@ -1066,7 +1066,7 @@ globus_gram_job_manager_script_poll( /* Keep the state file's timestamp up to date so that * anything scrubbing the state files of old and dead * processes leaves it alone - */ + */ if(request->job_state_file) { utime(request->job_state_file, NULL); @@ -1176,7 +1176,7 @@ globus_gram_job_manager_script_signal( } /* globus_gram_job_manager_script_signal() */ -int +int globus_gram_job_manager_script_stage_in( globus_gram_jobmanager_request_t * request) { @@ -1205,7 +1205,7 @@ globus_gram_job_manager_script_stage_in( } /* globus_gram_job_manager_script_stage_in() */ -int +int globus_gram_job_manager_script_stage_out( globus_gram_jobmanager_request_t * request) { @@ -1246,7 +1246,6 @@ globus_l_gram_job_manager_default_done( const char * value) { int script_status; - int rc; GlobusGramJobManagerRequestLock(request); @@ -1258,7 +1257,7 @@ globus_l_gram_job_manager_default_done( { globus_reltime_t delay; GlobusTimeReltimeSet(delay, 0, 0); - rc = globus_gram_job_manager_state_machine_register( + globus_gram_job_manager_state_machine_register( request->manager, request, &delay); @@ -1269,7 +1268,7 @@ globus_l_gram_job_manager_default_done( if(script_status < 0) { - request->failure_code = + request->failure_code = GLOBUS_GRAM_PROTOCOL_ERROR_INVALID_SCRIPT_STATUS; globus_gram_job_manager_request_log( request, @@ -1314,7 +1313,7 @@ globus_l_gram_job_manager_default_done( globus_gram_job_manager_request_set_status(request, GLOBUS_GRAM_PROTOCOL_JOB_STATE_FAILED); if(script_status <= 0) { - request->failure_code = + request->failure_code = GLOBUS_GRAM_PROTOCOL_ERROR_INVALID_SCRIPT_STATUS; globus_gram_job_manager_request_log( request, @@ -1460,7 +1459,7 @@ globus_l_gram_job_manager_default_done( else if(request->jobmanager_state == starting_jobmanager_state) { globus_gram_job_manager_request_set_status(request, GLOBUS_GRAM_PROTOCOL_JOB_STATE_FAILED); - request->failure_code = + request->failure_code = GLOBUS_GRAM_PROTOCOL_ERROR_INVALID_SCRIPT_STATUS; request->unsent_status_change = GLOBUS_TRUE; globus_gram_job_manager_request_log( @@ -1499,7 +1498,6 @@ globus_l_gram_job_manager_query_done( int script_status; globus_gram_job_manager_query_t * query; globus_reltime_t delay; - int rc; query = arg; @@ -1512,7 +1510,7 @@ globus_l_gram_job_manager_query_done( if(!variable) { GlobusTimeReltimeSet(delay, 0, 0); - rc = globus_gram_job_manager_state_machine_register( + globus_gram_job_manager_state_machine_register( request->manager, request, &delay); @@ -1523,7 +1521,7 @@ globus_l_gram_job_manager_query_done( if(script_status <= 0) { - query->failure_code = + query->failure_code = GLOBUS_GRAM_PROTOCOL_ERROR_INVALID_SCRIPT_STATUS; } else @@ -1537,7 +1535,7 @@ globus_l_gram_job_manager_query_done( if(script_status <= 0) { - query->failure_code = + query->failure_code = GLOBUS_GRAM_PROTOCOL_ERROR_INVALID_SCRIPT_STATUS; } else if((query->type == GLOBUS_GRAM_JOB_MANAGER_CANCEL || @@ -1560,7 +1558,7 @@ globus_l_gram_job_manager_query_done( globus_i_gram_job_manager_script_valid_state_change( request, script_status)) - + { globus_gram_job_manager_request_set_status(request, script_status); request->unsent_status_change = GLOBUS_TRUE; @@ -1582,7 +1580,7 @@ globus_l_gram_job_manager_query_done( } else { - query->failure_code = + query->failure_code = GLOBUS_GRAM_PROTOCOL_ERROR_INVALID_SCRIPT_STATUS; } @@ -1726,7 +1724,7 @@ globus_l_gram_enqueue_rsl( { return 0; } - + rc = globus_l_gram_enqueue_string( fifo, " '%s' => ", @@ -2019,7 +2017,7 @@ globus_l_gram_request_validate( -rc, errno, strerror(errno)); - + goto script_path_not_found; } @@ -2088,7 +2086,7 @@ globus_l_gram_request_validate( -rc, errno, strerror(errno)); - + goto lrm_module_not_found; } @@ -2334,7 +2332,7 @@ globus_i_gram_job_manager_script_valid_state_change( /** * Queue and perhaps start a job manager script * - * If the job manager isn't currently running too many simultaneous scripts, + * If the job manager isn't currently running too many simultaneous scripts, * start the script described in the @a context parameter. Otherwise, queue * it in the manager's script fifo and it will start when another one finishes. * @@ -2463,11 +2461,11 @@ globus_l_gram_script_queue( * * For each script context queued in the script fifo, either write its command * to an existing XIO handle or create a new XIO handle to process the script, - * provided there are slots available for running more scripts. + * provided there are slots available for running more scripts. * * The mutex associated with the @a manager parameter must be locked when this * procedure is called. - * + * * @param manager * Job manager state * @param scripts @@ -2517,7 +2515,7 @@ globus_l_gram_process_script_queue_locked( continue; } } - else + else { /* Create a new script if more slots are available */ assert(scripts->script_slots_available > 0); @@ -2605,7 +2603,7 @@ globus_l_gram_script_open_callback( request->job_stats.client_address ? request->job_stats.client_address : (void *) GLOBUS_GRAM_SCRIPT_NO_CLIENT)); - + globus_xio_register_close( handle, NULL, @@ -2640,7 +2638,7 @@ globus_l_gram_script_open_callback( static int globus_l_gram_script_register_read_and_write( - globus_gram_job_manager_script_context_t * + globus_gram_job_manager_script_context_t * script_context) { int i, total_iov_contents; @@ -2648,7 +2646,7 @@ globus_l_gram_script_register_read_and_write( globus_gram_job_manager_t * manager; globus_gram_jobmanager_request_t * request = script_context->request; globus_gram_job_manager_scripts_t * scripts; - + manager = script_context->handle->manager; scripts = globus_list_first( @@ -2796,7 +2794,7 @@ globus_l_gram_fifo_to_iovec( * * @param manager * Job manager state - * + * * @return void */ static diff --git a/gram/jobmanager/source/logging.c b/gram/jobmanager/source/logging.c index 211906edca..f7343f612b 100644 --- a/gram/jobmanager/source/logging.c +++ b/gram/jobmanager/source/logging.c @@ -137,12 +137,12 @@ globus_gram_job_manager_logging_destroy(void) if (globus_i_gram_job_manager_log_sys) { globus_logging_destroy(globus_i_gram_job_manager_log_sys); - globus_i_gram_job_manager_log_sys = NULL; + globus_i_gram_job_manager_log_sys = NULL; } if (globus_i_gram_job_manager_log_stdio) { globus_logging_destroy(globus_i_gram_job_manager_log_stdio); - globus_i_gram_job_manager_log_stdio = NULL; + globus_i_gram_job_manager_log_stdio = NULL; } globus_symboltable_destroy( &globus_l_gram_log_symboltable); @@ -225,7 +225,6 @@ globus_l_gram_logging_write( static char * last_path = NULL; int fd; int flags; - int rc; globus_gram_jobmanager_request_t * request; globus_symboltable_t * symboltable; @@ -269,7 +268,7 @@ globus_l_gram_logging_write( symboltable, DATE_SYMBOL, now_str); - + globus_gram_job_manager_rsl_eval_string( symboltable, log_pattern, @@ -318,7 +317,7 @@ globus_l_gram_logging_write( if (flags >= 0) { flags |= FD_CLOEXEC; - rc = fcntl(fd, F_SETFD, flags); + fcntl(fd, F_SETFD, flags); } } } diff --git a/gram/jobmanager/source/test/client/restart-to-new-url-test.c b/gram/jobmanager/source/test/client/restart-to-new-url-test.c index 55833d6952..c0690f21d2 100644 --- a/gram/jobmanager/source/test/client/restart-to-new-url-test.c +++ b/gram/jobmanager/source/test/client/restart-to-new-url-test.c @@ -131,7 +131,6 @@ test_l_old_accept_callback( globus_gass_transfer_request_t request) { test_monitor_t *monitor = callback_arg; - int rc; globus_mutex_lock(&monitor->mutex); monitor->old_request = request; @@ -141,14 +140,14 @@ test_l_old_accept_callback( request, GLOBUS_GASS_TRANSFER_LENGTH_UNKNOWN); - rc = globus_gass_transfer_receive_bytes( + globus_gass_transfer_receive_bytes( request, monitor->old_output, sizeof(monitor->old_output), 1, test_l_data_callback, monitor); - rc = globus_gass_transfer_register_listen( + globus_gass_transfer_register_listen( monitor->old_listener, test_l_old_listener_callback, monitor); @@ -161,25 +160,24 @@ test_l_new_accept_callback( globus_gass_transfer_request_t request) { test_monitor_t *monitor = callback_arg; - int rc; globus_mutex_lock(&monitor->mutex); monitor->new_request = request; globus_mutex_unlock(&monitor->mutex); - rc = globus_gass_transfer_authorize( + globus_gass_transfer_authorize( request, GLOBUS_GASS_TRANSFER_LENGTH_UNKNOWN); - rc = globus_gass_transfer_receive_bytes( + globus_gass_transfer_receive_bytes( request, monitor->new_output, sizeof(monitor->new_output), 1, test_l_data_callback, monitor); - rc = globus_gass_transfer_register_listen( + globus_gass_transfer_register_listen( monitor->new_listener, test_l_new_listener_callback, monitor); @@ -190,7 +188,6 @@ test_l_old_listener_callback( void * callback_arg, globus_gass_transfer_listener_t listener) { - int rc; globus_gass_transfer_request_t request; globus_gass_transfer_requestattr_t attr; @@ -200,7 +197,7 @@ test_l_old_listener_callback( GLOBUS_GASS_TRANSFER_AUTHORIZE_SELF, "https"); - rc = globus_gass_transfer_register_accept( + globus_gass_transfer_register_accept( &request, &attr, listener, @@ -215,7 +212,6 @@ test_l_new_listener_callback( void * callback_arg, globus_gass_transfer_listener_t listener) { - int rc; globus_gass_transfer_request_t request; globus_gass_transfer_requestattr_t attr; @@ -225,7 +221,7 @@ test_l_new_listener_callback( GLOBUS_GASS_TRANSFER_AUTHORIZE_SELF, "https"); - rc = globus_gass_transfer_register_accept( + globus_gass_transfer_register_accept( &request, &attr, listener, diff --git a/gram/jobmanager/source/test/client/stdio-update-test.c b/gram/jobmanager/source/test/client/stdio-update-test.c index 9c22c1976c..85b2e3118d 100644 --- a/gram/jobmanager/source/test/client/stdio-update-test.c +++ b/gram/jobmanager/source/test/client/stdio-update-test.c @@ -114,7 +114,6 @@ test_l_old_accept_callback( globus_gass_transfer_request_t request) { test_monitor_t *monitor = callback_arg; - int rc; globus_mutex_lock(&monitor->mutex); monitor->old_request = request; @@ -124,14 +123,14 @@ test_l_old_accept_callback( request, GLOBUS_GASS_TRANSFER_LENGTH_UNKNOWN); - rc = globus_gass_transfer_receive_bytes( + globus_gass_transfer_receive_bytes( request, monitor->old_output, sizeof(monitor->old_output), 1, test_l_data_callback, monitor); - rc = globus_gass_transfer_register_listen( + globus_gass_transfer_register_listen( monitor->old_listener, test_l_old_listener_callback, monitor); @@ -144,25 +143,24 @@ test_l_new_accept_callback( globus_gass_transfer_request_t request) { test_monitor_t *monitor = callback_arg; - int rc; globus_mutex_lock(&monitor->mutex); monitor->new_request = request; globus_mutex_unlock(&monitor->mutex); - rc = globus_gass_transfer_authorize( + globus_gass_transfer_authorize( request, GLOBUS_GASS_TRANSFER_LENGTH_UNKNOWN); - rc = globus_gass_transfer_receive_bytes( + globus_gass_transfer_receive_bytes( request, monitor->new_output, sizeof(monitor->new_output), 1, test_l_data_callback, monitor); - rc = globus_gass_transfer_register_listen( + globus_gass_transfer_register_listen( monitor->new_listener, test_l_new_listener_callback, monitor); @@ -173,7 +171,6 @@ test_l_old_listener_callback( void * callback_arg, globus_gass_transfer_listener_t listener) { - int rc; globus_gass_transfer_request_t request; globus_gass_transfer_requestattr_t attr; @@ -183,7 +180,7 @@ test_l_old_listener_callback( GLOBUS_GASS_TRANSFER_AUTHORIZE_SELF, "https"); - rc = globus_gass_transfer_register_accept( + globus_gass_transfer_register_accept( &request, &attr, listener, @@ -198,7 +195,6 @@ test_l_new_listener_callback( void * callback_arg, globus_gass_transfer_listener_t listener) { - int rc; globus_gass_transfer_request_t request; globus_gass_transfer_requestattr_t attr; @@ -208,7 +204,7 @@ test_l_new_listener_callback( GLOBUS_GASS_TRANSFER_AUTHORIZE_SELF, "https"); - rc = globus_gass_transfer_register_accept( + globus_gass_transfer_register_accept( &request, &attr, listener, diff --git a/gram/protocol/source/configure.ac b/gram/protocol/source/configure.ac index 0c40f972ce..2940520619 100644 --- a/gram/protocol/source/configure.ac +++ b/gram/protocol/source/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ([2.60]) -AC_INIT([globus_gram_protocol],[13.6],[https://github.com/gridcf/gct/issues]) +AC_INIT([globus_gram_protocol],[13.7],[https://github.com/gridcf/gct/issues]) AC_CONFIG_MACRO_DIR([m4]) AC_SUBST([MAJOR_VERSION], [${PACKAGE_VERSION%%.*}]) AC_SUBST([MINOR_VERSION], [${PACKAGE_VERSION##*.}]) diff --git a/gram/protocol/source/globus_gram_protocol_io.c b/gram/protocol/source/globus_gram_protocol_io.c index 4dbd3e81c8..5e50b22755 100644 --- a/gram/protocol/source/globus_gram_protocol_io.c +++ b/gram/protocol/source/globus_gram_protocol_io.c @@ -38,159 +38,159 @@ globus_l_gram_protocol_setup_connect_attr( static globus_bool_t globus_l_gram_protocol_authorization_callback( - void * arg, - globus_io_handle_t * handle, - globus_result_t result, - char * identity, - gss_ctx_id_t context_handle); + void * arg, + globus_io_handle_t * handle, + globus_result_t result, + char * identity, + gss_ctx_id_t context_handle); static void globus_l_gram_protocol_listen_callback( - void * callback_arg, - globus_io_handle_t * handle, - globus_result_t result); + void * callback_arg, + globus_io_handle_t * handle, + globus_result_t result); static void globus_l_gram_protocol_accept_callback( - void * callback_arg, - globus_io_handle_t * handle, - globus_result_t result); + void * callback_arg, + globus_io_handle_t * handle, + globus_result_t result); static void globus_l_gram_protocol_close_listener( - void * callback_arg, - globus_io_handle_t * handle, - globus_result_t result); + void * callback_arg, + globus_io_handle_t * handle, + globus_result_t result); static void globus_l_gram_protocol_connect_callback( - void * callback_arg, - globus_io_handle_t * handle, - globus_result_t result); + void * callback_arg, + globus_io_handle_t * handle, + globus_result_t result); static void globus_l_gram_protocol_write_request_callback( - void * callback_arg, - globus_io_handle_t * handle, - globus_result_t result, - globus_byte_t * buf, - globus_size_t nbytes); + void * callback_arg, + globus_io_handle_t * handle, + globus_result_t result, + globus_byte_t * buf, + globus_size_t nbytes); static void globus_l_gram_protocol_read_request_callback( - void * callback_arg, - globus_io_handle_t * handle, - globus_result_t result, - globus_byte_t * buf, - globus_size_t nbytes); + void * callback_arg, + globus_io_handle_t * handle, + globus_result_t result, + globus_byte_t * buf, + globus_size_t nbytes); static void globus_l_gram_protocol_write_reply_callback( - void * callback_arg, - globus_io_handle_t * handle, - globus_result_t result, - globus_byte_t * buf, - globus_size_t nbytes); + void * callback_arg, + globus_io_handle_t * handle, + globus_result_t result, + globus_byte_t * buf, + globus_size_t nbytes); static void globus_l_gram_protocol_read_reply_callback( - void * callback_arg, - globus_io_handle_t * handle, - globus_result_t result, - globus_byte_t * buf, - globus_size_t nbytes); + void * callback_arg, + globus_io_handle_t * handle, + globus_result_t result, + globus_byte_t * buf, + globus_size_t nbytes); static void globus_l_gram_protocol_connection_close_callback( - void * callback_arg, - globus_io_handle_t * handle, - globus_result_t result); + void * callback_arg, + globus_io_handle_t * handle, + globus_result_t result); static int globus_l_gram_protocol_parse_request_header( - const globus_byte_t * buf, - globus_size_t * payload_length, - char ** uri); + const globus_byte_t * buf, + globus_size_t * payload_length, + char ** uri); static int globus_l_gram_protocol_parse_reply_header( - const globus_byte_t * buf, - globus_size_t * payload_length); + const globus_byte_t * buf, + globus_size_t * payload_length); static int globus_l_gram_protocol_reply( - globus_gram_protocol_handle_t handle, - int code, - globus_byte_t * message, - globus_size_t message_size, - gss_OID_set restriction_oids, - gss_buffer_set_t restriction_bufers, - OM_uint32 req_flags, - OM_uint32 time_req, + globus_gram_protocol_handle_t handle, + int code, + globus_byte_t * message, + globus_size_t message_size, + gss_OID_set restriction_oids, + gss_buffer_set_t restriction_bufers, + OM_uint32 req_flags, + OM_uint32 time_req, globus_gram_protocol_delegation_callback_t - callback, - void * arg); + callback, + void * arg); static int globus_l_gram_protocol_post( - const char * url, - globus_gram_protocol_handle_t * handle, - globus_io_attr_t * attr, - globus_byte_t * message, - globus_size_t message_size, - globus_bool_t keep_open, - gss_cred_id_t cred_handle, - gss_OID_set restriction_oids, - gss_buffer_set_t restriction_buffers, - OM_uint32 req_flags, - OM_uint32 time_req, - globus_gram_protocol_callback_t callback, - void * callback_arg); + const char * url, + globus_gram_protocol_handle_t * handle, + globus_io_attr_t * attr, + globus_byte_t * message, + globus_size_t message_size, + globus_bool_t keep_open, + gss_cred_id_t cred_handle, + gss_OID_set restriction_oids, + gss_buffer_set_t restriction_buffers, + OM_uint32 req_flags, + OM_uint32 time_req, + globus_gram_protocol_callback_t callback, + void * callback_arg); static void globus_l_gram_protocol_delegation_read_callback( - void * callback_arg, - globus_io_handle_t * handle, - globus_result_t result, - globus_byte_t * buf, - globus_size_t nbytes); + void * callback_arg, + globus_io_handle_t * handle, + globus_result_t result, + globus_byte_t * buf, + globus_size_t nbytes); static void globus_l_gram_protocol_delegation_write_callback( - void * callback_arg, - globus_io_handle_t * handle, - globus_result_t result, - globus_byte_t * buf, - globus_size_t nbytes); + void * callback_arg, + globus_io_handle_t * handle, + globus_result_t result, + globus_byte_t * buf, + globus_size_t nbytes); static void globus_l_gram_protocol_accept_delegation( globus_i_gram_protocol_connection_t * - connection, - gss_buffer_t input_token); + connection, + gss_buffer_t input_token); static void globus_l_gram_protocol_init_delegation( globus_i_gram_protocol_connection_t * - connection, - gss_buffer_t input_token); + connection, + gss_buffer_t input_token); static void @@ -205,7 +205,7 @@ globus_l_gram_protocol_free_old_credentials(); * * @details * The functions in this section are related to sending and receiving - * GRAM protocol messages. + * GRAM protocol messages. */ /** @@ -213,7 +213,7 @@ globus_l_gram_protocol_free_old_credentials(); * @ingroup globus_gram_protocol_io * * @details - * The globus_gram_protocol_allow_attach() function creates a + * The globus_gram_protocol_allow_attach() function creates a * GRAM protocol listener to which other processes can send GRAM protocol * messages. The listener will automatically accept new connections on it's * TCP/IP port and parse GRAM requests. The requests will be passed to the @@ -226,11 +226,11 @@ globus_l_gram_protocol_free_old_credentials(); * that will hold the URL of the new listener. This URL may be published * or otherwise passed to applications which need to contact this * GRAM protocol server. The URL will be of the form - * @a https://host:port/. + * @a https://host:port/. * @param callback * A pointer to a function to be called when a new request has been * received by this listener. This function will be passed the - * request, which may be unpacked using one of the functions described + * request, which may be unpacked using one of the functions described * in the @link globus_gram_protocol_pack message packing @endlink * section of the documentation. * @param callback_arg @@ -257,17 +257,17 @@ globus_l_gram_protocol_free_old_credentials(); */ int globus_gram_protocol_allow_attach( - char ** url, - globus_gram_protocol_callback_t callback, - void * callback_arg) + char ** url, + globus_gram_protocol_callback_t callback, + void * callback_arg) { - int rc = GLOBUS_SUCCESS; - char hostnamebuf[256]; - unsigned short port; - globus_result_t res; - globus_io_handle_t * handle; - globus_i_gram_protocol_listener_t * listener; - globus_list_t * node; + int rc = GLOBUS_SUCCESS; + char hostnamebuf[256]; + unsigned short port; + globus_result_t res; + globus_io_handle_t * handle; + globus_i_gram_protocol_listener_t * listener; + globus_list_t * node; *url = NULL; @@ -276,7 +276,7 @@ globus_gram_protocol_allow_attach( { rc = GLOBUS_GRAM_PROTOCOL_ERROR_INVALID_REQUEST; - goto error_exit; + goto error_exit; } handle = globus_libc_malloc(sizeof(globus_io_handle_t)); @@ -291,13 +291,13 @@ globus_gram_protocol_allow_attach( res = globus_io_tcp_create_listener(&port, -1, - &globus_i_gram_protocol_default_attr, - handle); + &globus_i_gram_protocol_default_attr, + handle); if(res != GLOBUS_SUCCESS) { rc = GLOBUS_GRAM_PROTOCOL_ERROR_NO_RESOURCES; - goto free_handle_exit; + goto free_handle_exit; } listener = globus_libc_malloc(sizeof(globus_i_gram_protocol_listener_t)); @@ -318,12 +318,12 @@ globus_gram_protocol_allow_attach( res = globus_io_tcp_register_listen(handle, globus_l_gram_protocol_listen_callback, - listener); + listener); if(res != GLOBUS_SUCCESS) { - rc = GLOBUS_GRAM_PROTOCOL_ERROR_NO_RESOURCES; + rc = GLOBUS_GRAM_PROTOCOL_ERROR_NO_RESOURCES; - goto remove_listener_exit; + goto remove_listener_exit; } listener->listen_registered = GLOBUS_TRUE; globus_mutex_unlock(&globus_i_gram_protocol_mutex); @@ -343,7 +343,7 @@ globus_gram_protocol_allow_attach( if(node) { globus_list_remove(&globus_i_gram_protocol_listeners, - node); + node); } globus_libc_free(listener); @@ -351,7 +351,7 @@ globus_gram_protocol_allow_attach( close_handle_exit: res = globus_io_register_close(handle, globus_l_gram_protocol_close_listener, - NULL); + NULL); if(res != GLOBUS_SUCCESS) { free_handle_exit: @@ -387,7 +387,7 @@ globus_gram_protocol_allow_attach( * returns @a GLOBUS_SUCCESS and frees internal state associated with the * listener named by the @a url parameter. If an error occurs, its integer * error code value will be returned and no listener will be affected. - * + * * @retval GLOBUS_SUCCESS * Success * @retval GLOBUS_GRAM_PROTOCOL_ERROR_INVALID_JOB_CONTACT @@ -399,14 +399,14 @@ globus_gram_protocol_allow_attach( */ int globus_gram_protocol_callback_disallow( - char * url) + char * url) { - int rc; - globus_list_t * list; - globus_i_gram_protocol_listener_t * listener; - globus_io_handle_t * handle; - globus_url_t parsed_url; - unsigned short port; + int rc; + globus_list_t * list; + globus_i_gram_protocol_listener_t * listener; + globus_io_handle_t * handle; + globus_url_t parsed_url; + unsigned short port; /* get port number from url---we'll use that as a key * to locate the listener @@ -415,7 +415,7 @@ globus_gram_protocol_callback_disallow( if(rc == GLOBUS_SUCCESS) { port = parsed_url.port; - globus_url_destroy(&parsed_url); + globus_url_destroy(&parsed_url); } else { @@ -431,14 +431,14 @@ globus_gram_protocol_callback_disallow( { listener = globus_list_first(list); - if(listener->port == port) - { - handle = listener->handle; - } - else - { - list = globus_list_rest(list); - } + if(listener->port == port) + { + handle = listener->handle; + } + else + { + list = globus_list_rest(list); + } } if(handle) { @@ -465,7 +465,7 @@ globus_gram_protocol_callback_disallow( * message exchange with a GRAM protocol listener. It returns after framing * the message and initiating the connection. When the message exchange is * complete, the function pointed to by @a callback is invoked either in - * another thread or when a non-threaded application calls the + * another thread or when a non-threaded application calls the * globus_poll() or globus_cond_wait() functions. * * @param url @@ -475,7 +475,7 @@ globus_gram_protocol_callback_disallow( * @param handle * A pointer to a @a globus_gram_protocol_handle_t which * will be initialized with a unique handle identifier. This - * identifier will be passed to the @a callback function to + * identifier will be passed to the @a callback function to * allow the caller to differentiate replies to multiple GRAM Protocol * requests. This pointer may be NULL if the caller will not have * multiple simultaneous requests. @@ -487,13 +487,13 @@ globus_gram_protocol_callback_disallow( * transport, with message integrity). * @param message * A pointer to a message string to be sent to the GRAM server. This is - * normally created by calling one of the GRAM Protocol + * normally created by calling one of the GRAM Protocol * @link globus_gram_protocol_pack pack @endlink functions. This * message need not be NULL terminated as the length is passed in - * the @a message_size parameter. + * the @a message_size parameter. * @param message_size * The length of the @a message string. Typically generated as one of - * the output parameters to one of the GRAM Protocol + * the output parameters to one of the GRAM Protocol * @link globus_gram_protocol_pack pack @endlink functions. * @param callback * A pointer to a function to call when the response to this @@ -543,19 +543,19 @@ globus_gram_protocol_post( void * callback_arg) { return globus_l_gram_protocol_post( - url, - handle, - attr, - message, - message_size, - GLOBUS_FALSE, - GSS_C_NO_CREDENTIAL, - GSS_C_NO_OID_SET, - GSS_C_NO_BUFFER_SET, - 0, - 0, - callback, - callback_arg); + url, + handle, + attr, + message, + message_size, + GLOBUS_FALSE, + GSS_C_NO_CREDENTIAL, + GSS_C_NO_OID_SET, + GSS_C_NO_BUFFER_SET, + 0, + 0, + callback, + callback_arg); } /* globus_gram_protocol_post() */ @@ -582,7 +582,7 @@ globus_gram_protocol_post( * @param handle * A pointer to a @a globus_gram_protocol_handle_t which * will be initialized with a unique handle identifier. This - * identifier will be passed to the @a callback function to + * identifier will be passed to the @a callback function to * allow the caller to differentiate replies to multiple GRAM Protocol * requests. This pointer may be NULL if the caller will not have * multiple simultaneous requests. @@ -594,13 +594,13 @@ globus_gram_protocol_post( * transport, with message integrity). * @param message * A pointer to a message string to be sent to the GRAM server. This is - * normally created by calling one of the GRAM Protocol + * normally created by calling one of the GRAM Protocol * @link globus_gram_protocol_pack pack @endlink functions. This * message need not be NULL terminated as the length is passed in - * the @a message_size parameter. + * the @a message_size parameter. * @param message_size * The length of the @a message string. Typically generated as one of - * the output parameters to one of the GRAM Protocol + * the output parameters to one of the GRAM Protocol * @link globus_gram_protocol_pack pack @endlink functions. * @param cred_handle * Handle to an existing GSSAPI security credential. If this parameter @@ -615,7 +615,7 @@ globus_gram_protocol_post( * A set of binary data buffers which will be included in the delegated * credential. The type of data in these buffers is determined by the * OID values in @a restriction_oids. This parameter may have the value - * GSS_C_EMPTY_BUFFER_SET if there are no extra restrictions to be + * GSS_C_EMPTY_BUFFER_SET if there are no extra restrictions to be * added to the credential. * @param req_flags * A bitwise-or of GSSAPI flag values to use when delegating the @@ -666,33 +666,33 @@ globus_gram_protocol_post( */ int globus_gram_protocol_post_delegation( - const char * url, - globus_gram_protocol_handle_t * handle, - globus_io_attr_t * attr, - globus_byte_t * message, - globus_size_t message_size, - gss_cred_id_t cred_handle, - gss_OID_set restriction_oids, - gss_buffer_set_t restriction_buffers, - OM_uint32 req_flags, - OM_uint32 time_req, - globus_gram_protocol_callback_t callback, - void * callback_arg) + const char * url, + globus_gram_protocol_handle_t * handle, + globus_io_attr_t * attr, + globus_byte_t * message, + globus_size_t message_size, + gss_cred_id_t cred_handle, + gss_OID_set restriction_oids, + gss_buffer_set_t restriction_buffers, + OM_uint32 req_flags, + OM_uint32 time_req, + globus_gram_protocol_callback_t callback, + void * callback_arg) { return globus_l_gram_protocol_post( - url, - handle, - attr, - message, - message_size, - GLOBUS_TRUE, - cred_handle, - restriction_oids, - restriction_buffers, - req_flags, - time_req, - callback, - callback_arg); + url, + handle, + attr, + message, + message_size, + GLOBUS_TRUE, + cred_handle, + restriction_oids, + restriction_buffers, + req_flags, + time_req, + callback, + callback_arg); } /* globus_gram_protocol_post_delegation() */ @@ -703,10 +703,10 @@ globus_gram_protocol_post_delegation( * @details * The @a #globus_gram_protocol_reply() function sends a response message * to a client which initiated a GRAM message exchange. The - * @a #globus_gram_protocol_reply() function composes the message with an + * @a #globus_gram_protocol_reply() function composes the message with an * HTTP message frame and then sends it to the client which initiated the * exchange. - * + * * @param handle * A GRAM protocol handle which is used by this function to determine * the network connection to use for this reply. This must be the same @@ -717,13 +717,13 @@ globus_gram_protocol_post_delegation( * in RFC 2616. * @param message * A pointer to a message string to be sent to the GRAM client. This is - * normally created by calling one of the GRAM Protocol + * normally created by calling one of the GRAM Protocol * @link globus_gram_protocol_pack pack @endlink functions. This * message need not be NULL terminated as the length is passed in - * the @a message_size parameter. + * the @a message_size parameter. * @param message_size * The length of the @a message string. Typically generated as one of - * the output parameters to one of the GRAM Protocol + * the output parameters to one of the GRAM Protocol * @link globus_gram_protocol_pack pack @endlink functions. * * @return @@ -732,7 +732,7 @@ globus_gram_protocol_post_delegation( * message to the client. The caller must not try to use the value of the * @a handle parameter after this function returns. If an error occurs, * its integer error code will be returned. - * + * * @retval GLOBUS_SUCCESS * Success * @retval GLOBUS_GRAM_PROTOCOL_ERROR_INVALID_REQUEST @@ -745,20 +745,20 @@ globus_gram_protocol_post_delegation( int globus_gram_protocol_reply( globus_gram_protocol_handle_t handle, - int code, - globus_byte_t * message, - globus_size_t message_size) + int code, + globus_byte_t * message, + globus_size_t message_size) { return globus_l_gram_protocol_reply(handle, - code, - message, - message_size, - GSS_C_NO_OID_SET, - GSS_C_NO_BUFFER_SET, - 0, - 0, - NULL, - NULL); + code, + message, + message_size, + GSS_C_NO_OID_SET, + GSS_C_NO_BUFFER_SET, + 0, + 0, + NULL, + NULL); } /* globus_gram_protocol_reply() */ @@ -770,7 +770,7 @@ globus_gram_protocol_reply( * The globus_gram_protocol_accept_delegation() function performs the * service side accepting of a GRAM protocol delegation exchange with a GRAM * protocol client. This is performed after the delegation HTTP message has - * been unpacked by the application. + * been unpacked by the application. * * The globus_gram_protocol_accept_delegation() function returns after * processing the GSSAPI handshake, passing the delegated credential or @@ -787,7 +787,7 @@ globus_gram_protocol_reply( * A set of binary data buffers which will be included in the delegated * credential. The type of data in these buffers is determined by the * OID values in @a restriction_oids. This parameter may have the value - * GSS_C_EMPTY_BUFFER_SET if there are no extra restrictions to be + * GSS_C_EMPTY_BUFFER_SET if there are no extra restrictions to be * added to the credential. * @param req_flags * A bitwise-or of GSSAPI flag values to use when delegating the @@ -809,8 +809,8 @@ globus_gram_protocol_reply( * the pointer to establish its context in the callback. * * @return - * Upon success, globus_gram_protocol_accept_delegation() returns - * GLOBUS_SUCCESS and registers the function pointed to by @a callback + * Upon success, globus_gram_protocol_accept_delegation() returns + * GLOBUS_SUCCESS and registers the function pointed to by @a callback * to be called after the delegation completes or fails. If an error * occurs, globus_gram_protocol_accept_delegation() returns an integer * error code and the @a callback function is not registered. @@ -827,35 +827,35 @@ globus_gram_protocol_reply( int globus_gram_protocol_accept_delegation( globus_gram_protocol_handle_t handle, - gss_OID_set restriction_oids, - gss_buffer_set_t restriction_buffers, - OM_uint32 req_flags, - OM_uint32 time_req, + gss_OID_set restriction_oids, + gss_buffer_set_t restriction_buffers, + OM_uint32 req_flags, + OM_uint32 time_req, globus_gram_protocol_delegation_callback_t - callback, - void * arg) + callback, + void * arg) { - int rc; - globus_byte_t * reply; - globus_size_t replysize; + int rc; + globus_byte_t * reply; + globus_size_t replysize; rc = globus_gram_protocol_pack_status_reply( - 0, - 0, - 0, - &reply, - &replysize); + 0, + 0, + 0, + &reply, + &replysize); rc = globus_l_gram_protocol_reply(handle, - 200, - reply, - replysize, - restriction_oids, - restriction_buffers, - req_flags, - time_req, - callback, - arg); + 200, + reply, + replysize, + restriction_oids, + restriction_buffers, + req_flags, + time_req, + callback, + arg); globus_libc_free(reply); return rc; } @@ -897,44 +897,44 @@ globus_gram_protocol_get_sec_context( gss_ctx_id_t * context) { globus_i_gram_protocol_connection_t * - connection; - globus_list_t * list; - int rc; + connection; + globus_list_t * list; + int rc; list = globus_i_gram_protocol_connections; while(list != NULL) { connection = globus_list_first(list); - if(connection->handle == handle) - { - break; - } - list = globus_list_rest(list); + if(connection->handle == handle) + { + break; + } + list = globus_list_rest(list); } if(list == NULL) { - /* No match */ + /* No match */ rc = GLOBUS_GRAM_PROTOCOL_ERROR_INVALID_REQUEST; - goto error_exit; + goto error_exit; } *context = connection->context; if(*context == GSS_C_NO_CONTEXT) { - /* No context */ + /* No context */ rc = GLOBUS_GRAM_PROTOCOL_ERROR_INVALID_REQUEST; - goto error_exit; + goto error_exit; } return GLOBUS_SUCCESS; - + error_exit: return rc; } /* globus_gram_protocol_get_sec_context() */ - + #ifndef GLOBUS_DONT_DOCUMENT_INTERNAL /** * Listen callback. @@ -942,8 +942,8 @@ globus_gram_protocol_get_sec_context( * This function is called when Globus I/O decides that a connection is * ready to be accepted on a listening TCP socket. If the gram protocol module * has not been deactivated, then we create a new connection handle to - * register the accept on. Otherwise, we register the close of this listener. - * + * register the accept on. Otherwise, we register the close of this listener. + * * @param callback_arg * The globus_i_gram_protocol_listener_t associated with this * Globus I/O handle. @@ -957,16 +957,16 @@ globus_gram_protocol_get_sec_context( static void globus_l_gram_protocol_listen_callback( - void * callback_arg, - globus_io_handle_t * handle, - globus_result_t result) + void * callback_arg, + globus_io_handle_t * handle, + globus_result_t result) { - globus_i_gram_protocol_listener_t * listener; + globus_i_gram_protocol_listener_t * listener; globus_i_gram_protocol_connection_t * - connection; - globus_list_t * node; + connection; + globus_list_t * node; globus_io_attr_t accept_attrs; - + listener = callback_arg; listener->listen_registered = GLOBUS_FALSE; @@ -980,8 +980,8 @@ globus_l_gram_protocol_listen_callback( goto error_exit; } connection = globus_libc_calloc( - 1, - sizeof(globus_i_gram_protocol_connection_t)); + 1, + sizeof(globus_i_gram_protocol_connection_t)); if(connection == NULL) { @@ -1007,19 +1007,19 @@ globus_l_gram_protocol_listen_callback( if(result != GLOBUS_SUCCESS) { goto free_io_handle_exit; - } + } if(globus_l_gram_protocol_setup_accept_attr(&accept_attrs, connection)) { goto free_attrs_exit; } - + result = globus_io_tcp_register_accept( listener->handle, - &accept_attrs, - connection->io_handle, - globus_l_gram_protocol_accept_callback, - connection); + &accept_attrs, + connection->io_handle, + globus_l_gram_protocol_accept_callback, + connection); if(result != GLOBUS_SUCCESS) { goto free_attrs_exit; @@ -1053,13 +1053,13 @@ globus_l_gram_protocol_listen_callback( free_attrs_exit: globus_io_tcpattr_destroy(&accept_attrs); - + free_io_handle_exit: listener->connection_count--; node = globus_list_search(globus_i_gram_protocol_connections, connection); if(node) { - globus_list_remove(&globus_i_gram_protocol_connections, node); + globus_list_remove(&globus_i_gram_protocol_connections, node); } globus_libc_free(connection->io_handle); @@ -1109,9 +1109,9 @@ globus_l_gram_protocol_listen_callback( static void globus_l_gram_protocol_close_listener( - void * callback_arg, - globus_io_handle_t * handle, - globus_result_t result) + void * callback_arg, + globus_io_handle_t * handle, + globus_result_t result) { globus_libc_free(handle); @@ -1139,13 +1139,13 @@ globus_l_gram_protocol_close_listener( static void globus_l_gram_protocol_accept_callback( - void * callback_arg, - globus_io_handle_t * handle, - globus_result_t result) + void * callback_arg, + globus_io_handle_t * handle, + globus_result_t result) { globus_i_gram_protocol_connection_t * - connection; - int rc; + connection; + /* int rc; */ connection = callback_arg; @@ -1154,13 +1154,13 @@ globus_l_gram_protocol_accept_callback( if(globus_i_gram_protocol_shutdown_called) { - rc = GLOBUS_GRAM_PROTOCOL_ERROR_INVALID_REQUEST; + /* rc = GLOBUS_GRAM_PROTOCOL_ERROR_INVALID_REQUEST; */ goto error_exit; } if(result) { - rc = GLOBUS_GRAM_PROTOCOL_ERROR_NO_RESOURCES; - goto error_exit; + /* rc = GLOBUS_GRAM_PROTOCOL_ERROR_NO_RESOURCES; */ + goto error_exit; } connection->buf = globus_libc_malloc(GLOBUS_GRAM_PROTOCOL_MAX_MSG_SIZE); @@ -1168,7 +1168,7 @@ globus_l_gram_protocol_accept_callback( if(connection->buf == NULL) { - rc = GLOBUS_GRAM_PROTOCOL_ERROR_MALLOC_FAILED; + /* rc = GLOBUS_GRAM_PROTOCOL_ERROR_MALLOC_FAILED; */ goto error_exit; } connection->replybufsize = GLOBUS_GRAM_PROTOCOL_MAX_MSG_SIZE; @@ -1176,13 +1176,13 @@ globus_l_gram_protocol_accept_callback( result = globus_io_register_read( connection->io_handle, connection->buf, - connection->bufsize, - 1, - globus_l_gram_protocol_read_request_callback, - connection); + connection->bufsize, + 1, + globus_l_gram_protocol_read_request_callback, + connection); if(result) { - rc = GLOBUS_GRAM_PROTOCOL_ERROR_NO_RESOURCES; + /* rc = GLOBUS_GRAM_PROTOCOL_ERROR_NO_RESOURCES; */ goto error_exit; } globus_mutex_unlock(&globus_i_gram_protocol_mutex); @@ -1197,19 +1197,19 @@ globus_l_gram_protocol_accept_callback( */ result = globus_io_register_close( - handle, - globus_l_gram_protocol_connection_close_callback, - callback_arg); + handle, + globus_l_gram_protocol_connection_close_callback, + callback_arg); if(result != GLOBUS_SUCCESS) { /* If we can't close the handle, we'd still like to clean up - * our memory. - */ - globus_l_gram_protocol_connection_close_callback( - callback_arg, - handle, - result); + * our memory. + */ + globus_l_gram_protocol_connection_close_callback( + callback_arg, + handle, + result); } } /* globus_l_gram_protocol_accept_callback() */ @@ -1238,18 +1238,18 @@ globus_l_gram_protocol_accept_callback( static void globus_l_gram_protocol_read_request_callback( - void * callback_arg, - globus_io_handle_t * handle, - globus_result_t result, - globus_byte_t * buf, - globus_size_t nbytes) + void * callback_arg, + globus_io_handle_t * handle, + globus_result_t result, + globus_byte_t * buf, + globus_size_t nbytes) { - globus_object_t * err; + globus_object_t * err; globus_i_gram_protocol_connection_t * - connection; - char * p; - int rc; - globus_size_t header_length; + connection; + const char * p; + int rc; + globus_size_t header_length; connection = callback_arg; @@ -1257,102 +1257,102 @@ globus_l_gram_protocol_read_request_callback( { err = globus_error_get(result); - if(!globus_io_eof(err) || !connection->got_header) - { - globus_object_free(err); + if(!globus_io_eof(err) || !connection->got_header) + { + globus_object_free(err); - goto error_exit; - } + goto error_exit; + } } if(!connection->got_header) { if(connection->n_read == 0 && ((*buf == '0') || (*buf == 'D'))) - { - /* Delegation packet? */ - - goto reregister_read; - } - - connection->n_read += nbytes; - connection->buf[connection->n_read] = '\0'; - - p = strstr((const char *)connection->buf, CRLF CRLF); - header_length = (const char *)p - (const char *)connection->buf; - - if(p) - { - connection->got_header = GLOBUS_TRUE; - - rc = globus_l_gram_protocol_parse_request_header( - connection->buf, - &connection->payload_length, - &connection->uri); - if(rc != GLOBUS_SUCCESS) - { - goto error_exit; - } - /* p + 4 is the beginning of the payload (after CRLF CRLF) */ - memmove(connection->buf, - p + 4, - connection->n_read - header_length - 4); - connection->n_read = connection->n_read - header_length - 4; - connection->buf[connection->n_read] = '\0'; - nbytes = 0; - } - else - { - goto reregister_read; - } + { + /* Delegation packet? */ + + goto reregister_read; + } + + connection->n_read += nbytes; + connection->buf[connection->n_read] = '\0'; + + p = strstr((const char *)connection->buf, CRLF CRLF); + header_length = p - (const char *)connection->buf; + + if(p) + { + connection->got_header = GLOBUS_TRUE; + + rc = globus_l_gram_protocol_parse_request_header( + connection->buf, + &connection->payload_length, + &connection->uri); + if(rc != GLOBUS_SUCCESS) + { + goto error_exit; + } + /* p + 4 is the beginning of the payload (after CRLF CRLF) */ + memmove(connection->buf, + p + 4, + connection->n_read - header_length - 4); + connection->n_read = connection->n_read - header_length - 4; + connection->buf[connection->n_read] = '\0'; + nbytes = 0; + } + else + { + goto reregister_read; + } } if(connection->got_header) { if(connection->n_read < connection->payload_length) - { - goto reregister_read; - } - /* Call user callback... users should not free the - * buffers, unlike the original code. - */ - if(connection->callback) - { - connection->callback(connection->callback_arg, - connection->handle, - connection->buf, - connection->payload_length, - GLOBUS_SUCCESS, - connection->uri); - } + { + goto reregister_read; + } + /* Call user callback... users should not free the + * buffers, unlike the original code. + */ + if(connection->callback) + { + connection->callback(connection->callback_arg, + connection->handle, + connection->buf, + connection->payload_length, + GLOBUS_SUCCESS, + connection->uri); + } } return; reregister_read: result = globus_io_register_read( connection->io_handle, - connection->buf + connection->n_read, - connection->bufsize - connection->n_read, - 1, - globus_l_gram_protocol_read_request_callback, - connection); + connection->buf + connection->n_read, + connection->bufsize - connection->n_read, + 1, + globus_l_gram_protocol_read_request_callback, + connection); if(result == GLOBUS_SUCCESS) { - return; + return; } error_exit: result = globus_io_register_close( connection->io_handle, - globus_l_gram_protocol_connection_close_callback, - connection); + globus_l_gram_protocol_connection_close_callback, + connection); if(result != GLOBUS_SUCCESS) { /* If we can't close the handle, we'd still like to clean up - * our memory. - */ - globus_l_gram_protocol_connection_close_callback( - callback_arg, - handle, - result); + * our memory. + */ + globus_l_gram_protocol_connection_close_callback( + callback_arg, + handle, + result); } } /* globus_l_gram_protocol_read_request_callback() */ @@ -1378,46 +1378,46 @@ globus_l_gram_protocol_read_request_callback( static void globus_l_gram_protocol_connect_callback( - void * callback_arg, - globus_io_handle_t * handle, - globus_result_t result) + void * callback_arg, + globus_io_handle_t * handle, + globus_result_t result) { - globus_object_t * err; - int rc = 0; - char * errstring; + globus_object_t * err; + int rc = 0; + char * errstring; globus_i_gram_protocol_connection_t * - connection; + connection; connection = callback_arg; globus_mutex_lock(&globus_i_gram_protocol_mutex); connection->accepting = GLOBUS_FALSE; if(result != GLOBUS_SUCCESS) { - err = globus_error_get(result); - - if(globus_object_type_match( - globus_object_get_type(err), - GLOBUS_IO_ERROR_TYPE_SECURITY_FAILED)) - { - errstring = globus_error_print_friendly(err); - rc = GLOBUS_GRAM_PROTOCOL_ERROR_AUTHORIZATION; - globus_gram_protocol_error_7_hack_replace_message(errstring); - globus_free(errstring); - } - else - { - rc = GLOBUS_GRAM_PROTOCOL_ERROR_CONNECTION_FAILED; - } - result = globus_error_put(err); + err = globus_error_get(result); + + if(globus_object_type_match( + globus_object_get_type(err), + GLOBUS_IO_ERROR_TYPE_SECURITY_FAILED)) + { + errstring = globus_error_print_friendly(err); + rc = GLOBUS_GRAM_PROTOCOL_ERROR_AUTHORIZATION; + globus_gram_protocol_error_7_hack_replace_message(errstring); + globus_free(errstring); + } + else + { + rc = GLOBUS_GRAM_PROTOCOL_ERROR_CONNECTION_FAILED; + } + result = globus_error_put(err); goto error_exit; } /* Write the framed GRAM request */ result = globus_io_register_write( handle, - connection->buf, - connection->bufsize, - globus_l_gram_protocol_write_request_callback, - connection); + connection->buf, + connection->bufsize, + globus_l_gram_protocol_write_request_callback, + connection); if(result != GLOBUS_SUCCESS) { @@ -1436,28 +1436,28 @@ globus_l_gram_protocol_connect_callback( */ if(connection->callback) { - connection->callback(connection->callback_arg, - connection->handle, - NULL, - 0, - rc, - NULL); + connection->callback(connection->callback_arg, + connection->handle, + NULL, + 0, + rc, + NULL); } - + result = globus_io_register_close( - handle, - globus_l_gram_protocol_connection_close_callback, - callback_arg); - + handle, + globus_l_gram_protocol_connection_close_callback, + callback_arg); + if(result != GLOBUS_SUCCESS) { /* If we can't close the handle, we'd still like to clean up - * our memory. - */ - globus_l_gram_protocol_connection_close_callback( - callback_arg, - handle, - result); + * our memory. + */ + globus_l_gram_protocol_connection_close_callback( + callback_arg, + handle, + result); } return; } @@ -1487,15 +1487,15 @@ globus_l_gram_protocol_connect_callback( static void globus_l_gram_protocol_write_request_callback( - void * callback_arg, - globus_io_handle_t * handle, - globus_result_t result, - globus_byte_t * buf, - globus_size_t nbytes) + void * callback_arg, + globus_io_handle_t * handle, + globus_result_t result, + globus_byte_t * buf, + globus_size_t nbytes) { globus_i_gram_protocol_connection_t * - connection; - int rc; + connection; + int rc; connection = callback_arg; globus_mutex_lock(&globus_i_gram_protocol_mutex); @@ -1504,7 +1504,7 @@ globus_l_gram_protocol_write_request_callback( globus_object_t * err; char * errstring; - err = globus_error_get(result); + err = globus_error_get(result); errstring = globus_error_print_friendly(err); globus_gram_protocol_error_10_hack_replace_message(errstring); @@ -1526,11 +1526,11 @@ globus_l_gram_protocol_write_request_callback( } /* Read reply from server */ result = globus_io_register_read(connection->io_handle, - connection->replybuf, - connection->replybufsize, - 1, - globus_l_gram_protocol_read_reply_callback, - connection); + connection->replybuf, + connection->replybufsize, + 1, + globus_l_gram_protocol_read_reply_callback, + connection); if(result) { @@ -1546,31 +1546,31 @@ globus_l_gram_protocol_write_request_callback( if(connection->callback) { - /* - * Since the user requested the POST with a callback, they - * should get their callback - */ - connection->callback(connection->callback_arg, - connection->handle, - NULL, - 0, - rc, - NULL); + /* + * Since the user requested the POST with a callback, they + * should get their callback + */ + connection->callback(connection->callback_arg, + connection->handle, + NULL, + 0, + rc, + NULL); } result = globus_io_register_close( - handle, - globus_l_gram_protocol_connection_close_callback, - callback_arg); + handle, + globus_l_gram_protocol_connection_close_callback, + callback_arg); if(result != GLOBUS_SUCCESS) { /* If we can't close the handle, we'd still like to clean up - * our memory. - */ - globus_l_gram_protocol_connection_close_callback( - callback_arg, - handle, - result); + * our memory. + */ + globus_l_gram_protocol_connection_close_callback( + callback_arg, + handle, + result); } return; } @@ -1598,72 +1598,72 @@ globus_l_gram_protocol_write_request_callback( * The reply buffer which was sent to the GRAM Protocol server. * @param nbytes * The number of bytes of @a buf written. - * + * */ static void globus_l_gram_protocol_write_reply_callback( - void * callback_arg, - globus_io_handle_t * handle, - globus_result_t result, - globus_byte_t * buf, - globus_size_t nbytes) + void * callback_arg, + globus_io_handle_t * handle, + globus_result_t result, + globus_byte_t * buf, + globus_size_t nbytes) { globus_i_gram_protocol_connection_t * - connection; + connection; connection = callback_arg; if(connection->keep_open) { - if(result == GLOBUS_SUCCESS) - { - if(connection->replybuf == NULL) - { - connection->replybuf = globus_libc_malloc(4096); - connection->replybufsize = 4096; - } - result = globus_io_register_read( - handle, - connection->replybuf, - 4, - 4, - globus_l_gram_protocol_delegation_read_callback, - connection); - - if(result == GLOBUS_SUCCESS) - { - return; - } - } - if(result != GLOBUS_SUCCESS) - { - /* Error occurred. Call callback with error. */ - connection->delegation_callback( - connection->delegation_arg, - connection->handle, - GSS_C_NO_CREDENTIAL, - GLOBUS_GRAM_PROTOCOL_ERROR_DELEGATION_FAILED); - } - } - + if(result == GLOBUS_SUCCESS) + { + if(connection->replybuf == NULL) + { + connection->replybuf = globus_libc_malloc(4096); + connection->replybufsize = 4096; + } + result = globus_io_register_read( + handle, + connection->replybuf, + 4, + 4, + globus_l_gram_protocol_delegation_read_callback, + connection); + + if(result == GLOBUS_SUCCESS) + { + return; + } + } + if(result != GLOBUS_SUCCESS) + { + /* Error occurred. Call callback with error. */ + connection->delegation_callback( + connection->delegation_arg, + connection->handle, + GSS_C_NO_CREDENTIAL, + GLOBUS_GRAM_PROTOCOL_ERROR_DELEGATION_FAILED); + } + } + result = globus_io_register_close( - handle, - globus_l_gram_protocol_connection_close_callback, - callback_arg); + handle, + globus_l_gram_protocol_connection_close_callback, + callback_arg); if(result != GLOBUS_SUCCESS) { /* If we can't close the handle, we'd still like to clean up - * our memory. - */ - globus_l_gram_protocol_connection_close_callback( - callback_arg, - handle, - result); + * our memory. + */ + globus_l_gram_protocol_connection_close_callback( + callback_arg, + handle, + result); } } /* globus_l_gram_protocol_write_reply_callback() */ - + /** * Unpack a reply and call user's callback. * @@ -1671,7 +1671,7 @@ globus_l_gram_protocol_write_reply_callback( * If the entire reply is present, it is unframed and the user's POST * callback is called. If it is not present, then another read is registered * on the connection. - * + * * @param callback_arg * A pointer to the * @link globus_i_gram_protocol_connection_t connection @endlink @@ -1688,17 +1688,17 @@ globus_l_gram_protocol_write_reply_callback( static void globus_l_gram_protocol_read_reply_callback( - void * callback_arg, - globus_io_handle_t * handle, - globus_result_t result, - globus_byte_t * buf, - globus_size_t nbytes) + void * callback_arg, + globus_io_handle_t * handle, + globus_result_t result, + globus_byte_t * buf, + globus_size_t nbytes) { - globus_object_t * err; + globus_object_t * err; globus_i_gram_protocol_connection_t * - connection; - char * p; - globus_size_t header_length; + connection; + const char * p; + globus_size_t header_length; connection = callback_arg; @@ -1706,82 +1706,82 @@ globus_l_gram_protocol_read_reply_callback( { err = globus_error_get(result); - if(!globus_io_eof(err) || !connection->got_header) - { + if(!globus_io_eof(err) || !connection->got_header) + { char * errstring; errstring = globus_error_print_friendly(err); globus_gram_protocol_error_10_hack_replace_message(errstring); globus_free(errstring); - globus_object_free(err); + globus_object_free(err); - connection->rc = GLOBUS_GRAM_PROTOCOL_ERROR_PROTOCOL_FAILED; + connection->rc = GLOBUS_GRAM_PROTOCOL_ERROR_PROTOCOL_FAILED; - goto callback_exit; - } + goto callback_exit; + } } if(!connection->got_header) { if(connection->n_read == 0 && ((*buf == '0') || (*buf == 'D'))) - { - /* Delegation packet?!? */ + { + /* Delegation packet?!? */ globus_gram_protocol_error_10_hack_replace_message( "server sent unexpected delegation protocol message"); - connection->rc = GLOBUS_GRAM_PROTOCOL_ERROR_PROTOCOL_FAILED; - - goto callback_exit; - } - - connection->n_read += nbytes; - connection->replybuf[connection->n_read] = '\0'; - - p = strstr((const char *)connection->replybuf, CRLF CRLF); - header_length = (const char *)p - (const char *)connection->replybuf; - - if(p) - { - connection->got_header = GLOBUS_TRUE; - - connection->rc = globus_l_gram_protocol_parse_reply_header( - connection->replybuf, - &connection->payload_length); - - if(connection->rc != GLOBUS_SUCCESS) - { - goto callback_exit; - } - /* p + 4 is the beginning of the payload (after CRLF CRLF) */ - memmove(connection->replybuf, - p + 4, - connection->n_read - header_length - 4); - connection->n_read = connection->n_read - header_length - 4; - connection->replybuf[connection->n_read] = '\0'; - nbytes = 0; - } + connection->rc = GLOBUS_GRAM_PROTOCOL_ERROR_PROTOCOL_FAILED; + + goto callback_exit; + } + + connection->n_read += nbytes; + connection->replybuf[connection->n_read] = '\0'; + + p = strstr((const char *)connection->replybuf, CRLF CRLF); + header_length = p - (const char *)connection->replybuf; + + if(p) + { + connection->got_header = GLOBUS_TRUE; + + connection->rc = globus_l_gram_protocol_parse_reply_header( + connection->replybuf, + &connection->payload_length); + + if(connection->rc != GLOBUS_SUCCESS) + { + goto callback_exit; + } + /* p + 4 is the beginning of the payload (after CRLF CRLF) */ + memmove(connection->replybuf, + p + 4, + connection->n_read - header_length - 4); + connection->n_read = connection->n_read - header_length - 4; + connection->replybuf[connection->n_read] = '\0'; + nbytes = 0; + } } if(connection->got_header) { if(connection->n_read >= connection->payload_length) - { - /* Got the payload, call back to user now */ - goto callback_exit; - } + { + /* Got the payload, call back to user now */ + goto callback_exit; + } } /* Missing part of the header or payload, register another read */ globus_assert((!connection->got_header) || - (connection->n_read < connection->payload_length)); + (connection->n_read < connection->payload_length)); result = globus_io_register_read( connection->io_handle, - connection->replybuf + connection->n_read, - connection->replybufsize - connection->n_read, - 1, - globus_l_gram_protocol_read_reply_callback, - connection); + connection->replybuf + connection->n_read, + connection->replybufsize - connection->n_read, + 1, + globus_l_gram_protocol_read_reply_callback, + connection); if(result == GLOBUS_SUCCESS) { - return; + return; } /* If we couldn't register the read, the we'll fall through, @@ -1796,42 +1796,42 @@ globus_l_gram_protocol_read_reply_callback( */ if(connection->callback && (connection->rc || !connection->keep_open)) { - connection->callback(connection->callback_arg, - connection->handle, - connection->replybuf, - connection->payload_length, - connection->rc, - NULL); + connection->callback(connection->callback_arg, + connection->handle, + connection->replybuf, + connection->payload_length, + connection->rc, + NULL); } if ((!connection->rc) && connection->keep_open) { - /* In the post delegation case, we get a reply containing no body. - * We then start doing delegation. - */ - connection->got_header = 0; - connection->n_read = 0; + /* In the post delegation case, we get a reply containing no body. + * We then start doing delegation. + */ + connection->got_header = 0; + connection->n_read = 0; - globus_l_gram_protocol_init_delegation(connection, GSS_C_NO_BUFFER); - - return; + globus_l_gram_protocol_init_delegation(connection, GSS_C_NO_BUFFER); + + return; } /* For reply handling, we just need to close up the connection * after we've dispatched the callback. */ result = globus_io_register_close( connection->io_handle, - globus_l_gram_protocol_connection_close_callback, - connection); + globus_l_gram_protocol_connection_close_callback, + connection); if(result != GLOBUS_SUCCESS) { /* If we can't close the handle, we'd still like to clean up - * our memory. - */ - globus_l_gram_protocol_connection_close_callback( - callback_arg, - handle, - result); + * our memory. + */ + globus_l_gram_protocol_connection_close_callback( + callback_arg, + handle, + result); } return; } @@ -1852,13 +1852,13 @@ globus_l_gram_protocol_read_reply_callback( static void globus_l_gram_protocol_connection_close_callback( - void * callback_arg, - globus_io_handle_t * handle, - globus_result_t result) + void * callback_arg, + globus_io_handle_t * handle, + globus_result_t result) { globus_i_gram_protocol_connection_t * - connection; - globus_list_t * node; + connection; + globus_list_t * node; connection = callback_arg; @@ -1867,17 +1867,17 @@ globus_l_gram_protocol_connection_close_callback( if(node) { - globus_list_remove(&globus_i_gram_protocol_connections, node); + globus_list_remove(&globus_i_gram_protocol_connections, node); - if(connection->listener) - { - /* Connection was created by an accept() */ - connection->listener->connection_count--; + if(connection->listener) + { + /* Connection was created by an accept() */ + connection->listener->connection_count--; - if(connection->listener->connection_count == 0) - { - globus_cond_signal(&connection->listener->cond); - } + if(connection->listener->connection_count == 0) + { + globus_cond_signal(&connection->listener->cond); + } if((!globus_i_gram_protocol_shutdown_called) && connection->listener->allow_attach && (!connection->listener->listen_registered) && @@ -1892,54 +1892,54 @@ globus_l_gram_protocol_connection_close_callback( connection->listener->listen_registered = GLOBUS_TRUE; } } - } - else - { - /* Connection was created by POSTing */ - globus_i_gram_protocol_num_connects--; - - if(globus_i_gram_protocol_num_connects == 0) - { - globus_cond_signal(&globus_i_gram_protocol_cond); - } - } - if(connection->buf) - { - globus_libc_free(connection->buf); - } - if(connection->replybuf) - { - globus_libc_free(connection->replybuf); - } - if(connection->io_handle) - { - globus_libc_free(connection->io_handle); - } - if(connection->uri) - { - globus_libc_free(connection->uri); - } - globus_libc_free(connection); - globus_l_gram_protocol_free_old_credentials(); + } + else + { + /* Connection was created by POSTing */ + globus_i_gram_protocol_num_connects--; + + if(globus_i_gram_protocol_num_connects == 0) + { + globus_cond_signal(&globus_i_gram_protocol_cond); + } + } + if(connection->buf) + { + globus_libc_free(connection->buf); + } + if(connection->replybuf) + { + globus_libc_free(connection->replybuf); + } + if(connection->io_handle) + { + globus_libc_free(connection->io_handle); + } + if(connection->uri) + { + globus_libc_free(connection->uri); + } + globus_libc_free(connection); + globus_l_gram_protocol_free_old_credentials(); } globus_mutex_unlock(&globus_i_gram_protocol_mutex); } /* globus_l_gram_protocol_connection_close_callback() */ - + /** * Internal function to close a listener. * * Used by both the deactivation function and the - * globus_gram_protocol_callback_disallow() to close and free a + * globus_gram_protocol_callback_disallow() to close and free a * listener handle. Waits for all connections created by this listener * to be completed... */ int globus_i_gram_protocol_callback_disallow( - globus_i_gram_protocol_listener_t * listener) + globus_i_gram_protocol_listener_t * listener) { - globus_list_t * node; - globus_io_handle_t * handle; + globus_list_t * node; + globus_io_handle_t * handle; handle = listener->handle; @@ -1965,9 +1965,9 @@ globus_i_gram_protocol_callback_disallow( if(node) { globus_list_remove(&globus_i_gram_protocol_listeners, node); - globus_cond_destroy(&listener->cond); - globus_libc_free(handle); - globus_libc_free(listener); + globus_cond_destroy(&listener->cond); + globus_libc_free(handle); + globus_libc_free(listener); } globus_cond_signal(&globus_i_gram_protocol_cond); @@ -1988,46 +1988,46 @@ globus_l_gram_protocol_free_old_credentials() cred_list = globus_i_gram_protocol_old_creds; while(!globus_list_empty(cred_list)) { - globus_list_t *dead_cred = cred_list; - cred = (gss_cred_id_t) globus_list_first(cred_list); + globus_list_t *dead_cred = cred_list; + cred = (gss_cred_id_t) globus_list_first(cred_list); - conn_list = globus_i_gram_protocol_connections; - while(!globus_list_empty(conn_list)) - { - conn = (globus_i_gram_protocol_connection_t *) globus_list_first(conn_list); + conn_list = globus_i_gram_protocol_connections; + while(!globus_list_empty(conn_list)) + { + conn = (globus_i_gram_protocol_connection_t *) globus_list_first(conn_list); if (conn->accepting) { return; } - - if (conn->io_handle != NULL) - { - gss_cred_id_t cur_cred; - - globus_io_tcp_get_credential(conn->io_handle, &cur_cred); - if (cur_cred == cred) + + if (conn->io_handle != NULL) + { + gss_cred_id_t cur_cred; + + globus_io_tcp_get_credential(conn->io_handle, &cur_cred); + if (cur_cred == cred) { dead_cred = NULL; break; } - } + } - conn_list = globus_list_rest(conn_list); - } + conn_list = globus_list_rest(conn_list); + } - cred_list = globus_list_rest(cred_list); + cred_list = globus_list_rest(cred_list); - if (dead_cred != NULL) - { - globus_list_remove(&globus_i_gram_protocol_old_creds, - dead_cred); + if (dead_cred != NULL) + { + globus_list_remove(&globus_i_gram_protocol_old_creds, + dead_cred); - if (cred != GSS_C_NO_CREDENTIAL) - { - OM_uint32 minor_status; - gss_release_cred(&minor_status, &cred); - } - } + if (cred != GSS_C_NO_CREDENTIAL) + { + OM_uint32 minor_status; + gss_release_cred(&minor_status, &cred); + } + } } @@ -2042,7 +2042,7 @@ globus_l_gram_protocol_free_old_credentials() * function returns, the caller must not use the credential, as it may be freed * by GRAM when it is no longer needed. * - * As a side effect, globus_gram_protocol_set_credentials() may free any + * As a side effect, globus_gram_protocol_set_credentials() may free any * credential previously used by GRAM. * * @param new_credentials @@ -2070,17 +2070,17 @@ globus_gram_protocol_set_credentials(gss_cred_id_t new_credentials) globus_i_gram_protocol_credential = new_credentials; globus_io_attr_set_secure_authentication_mode( - &globus_i_gram_protocol_default_attr, - GLOBUS_IO_SECURE_AUTHENTICATION_MODE_GSSAPI, - globus_i_gram_protocol_credential); + &globus_i_gram_protocol_default_attr, + GLOBUS_IO_SECURE_AUTHENTICATION_MODE_GSSAPI, + globus_i_gram_protocol_credential); tmp_list = globus_i_gram_protocol_listeners; while(!globus_list_empty(tmp_list)) { - listener = (globus_i_gram_protocol_listener_t *) globus_list_first(tmp_list); + listener = (globus_i_gram_protocol_listener_t *) globus_list_first(tmp_list); globus_io_tcp_set_credential(listener->handle, new_credentials); - tmp_list = globus_list_rest(tmp_list); + tmp_list = globus_list_rest(tmp_list); } globus_list_insert(&globus_i_gram_protocol_old_creds, old_cred); @@ -2105,14 +2105,14 @@ globus_gram_protocol_set_credentials(gss_cred_id_t new_credentials) static int globus_l_gram_protocol_parse_request_header( - const globus_byte_t * buf, - globus_size_t * payload_length, - char ** uri) + const globus_byte_t * buf, + globus_size_t * payload_length, + char ** uri) { - int rc; - long tmp; - char * tmp_uri; - char * host; + int rc; + long tmp; + char * tmp_uri; + char * host; tmp_uri = (char *) globus_libc_malloc(strlen((char *) buf)); host = (char *) globus_libc_malloc(strlen((char *) buf)); @@ -2120,27 +2120,27 @@ globus_l_gram_protocol_parse_request_header( globus_libc_lock(); rc = sscanf((const char *) buf, GLOBUS_GRAM_HTTP_REQUEST_LINE - GLOBUS_GRAM_HTTP_HOST_LINE - GLOBUS_GRAM_HTTP_CONTENT_TYPE_LINE - GLOBUS_GRAM_HTTP_CONTENT_LENGTH_LINE - CRLF, - tmp_uri, - host, - &tmp); + GLOBUS_GRAM_HTTP_HOST_LINE + GLOBUS_GRAM_HTTP_CONTENT_TYPE_LINE + GLOBUS_GRAM_HTTP_CONTENT_LENGTH_LINE + CRLF, + tmp_uri, + host, + &tmp); globus_libc_unlock(); if(rc != 3) { globus_gram_protocol_error_10_hack_replace_message("GRAM is unable to parse HTTp message" ); - rc = GLOBUS_GRAM_PROTOCOL_ERROR_PROTOCOL_FAILED; + rc = GLOBUS_GRAM_PROTOCOL_ERROR_PROTOCOL_FAILED; - *payload_length = 0; + *payload_length = 0; } else { - *payload_length = tmp; - *uri = strdup(tmp_uri); - rc = GLOBUS_SUCCESS; + *payload_length = tmp; + *uri = strdup(tmp_uri); + rc = GLOBUS_SUCCESS; } globus_free(tmp_uri); globus_free(host); @@ -2155,14 +2155,14 @@ globus_l_gram_protocol_parse_request_header( static int globus_l_gram_protocol_parse_reply_header( - const globus_byte_t * buf, - globus_size_t * payload_length) + const globus_byte_t * buf, + globus_size_t * payload_length) { - int rc; - int code; - int offset; - char * reason; - long tmp; + int rc; + int code; + int offset; + char * reason; + long tmp; reason = (char *) globus_malloc(strlen((char *)buf)); @@ -2170,84 +2170,84 @@ globus_l_gram_protocol_parse_reply_header( globus_libc_lock(); rc = sscanf( (char *) buf, - GLOBUS_GRAM_HTTP_PARSE_REPLY_LINE "%n", - &code, - reason, - &offset); + GLOBUS_GRAM_HTTP_PARSE_REPLY_LINE "%n", + &code, + reason, + &offset); globus_libc_unlock(); if(rc < 2) { - rc = GLOBUS_GRAM_PROTOCOL_ERROR_HTTP_UNFRAME_FAILED; + rc = GLOBUS_GRAM_PROTOCOL_ERROR_HTTP_UNFRAME_FAILED; } else if(code == 200) { - globus_libc_lock(); - rc = sscanf( (char *)buf + offset, - GLOBUS_GRAM_HTTP_CONTENT_TYPE_LINE - GLOBUS_GRAM_HTTP_CONTENT_LENGTH_LINE, - &tmp); - globus_libc_unlock(); - if(rc != 1) - { - rc = GLOBUS_GRAM_PROTOCOL_ERROR_HTTP_UNFRAME_FAILED; - *payload_length = 0; - } - else - { - *payload_length = tmp; - rc = GLOBUS_SUCCESS; - } + globus_libc_lock(); + rc = sscanf( (char *)buf + offset, + GLOBUS_GRAM_HTTP_CONTENT_TYPE_LINE + GLOBUS_GRAM_HTTP_CONTENT_LENGTH_LINE, + &tmp); + globus_libc_unlock(); + if(rc != 1) + { + rc = GLOBUS_GRAM_PROTOCOL_ERROR_HTTP_UNFRAME_FAILED; + *payload_length = 0; + } + else + { + *payload_length = tmp; + rc = GLOBUS_SUCCESS; + } } else if(code==400) /* JM failed to frame reply */ { globus_gram_protocol_error_10_hack_replace_message("job manager failed to frame reply"); - - rc = GLOBUS_GRAM_PROTOCOL_ERROR_PROTOCOL_FAILED; + + rc = GLOBUS_GRAM_PROTOCOL_ERROR_PROTOCOL_FAILED; } else if(code==403) { - rc = GLOBUS_GRAM_PROTOCOL_ERROR_AUTHORIZATION; + rc = GLOBUS_GRAM_PROTOCOL_ERROR_AUTHORIZATION; } else if(code==404) { - rc = GLOBUS_GRAM_PROTOCOL_ERROR_SERVICE_NOT_FOUND; + rc = GLOBUS_GRAM_PROTOCOL_ERROR_SERVICE_NOT_FOUND; } else if(code==500) { - rc = GLOBUS_GRAM_PROTOCOL_ERROR_GATEKEEPER_MISCONFIGURED; + rc = GLOBUS_GRAM_PROTOCOL_ERROR_GATEKEEPER_MISCONFIGURED; } else { - rc = GLOBUS_GRAM_PROTOCOL_ERROR_HTTP_UNFRAME_FAILED; + rc = GLOBUS_GRAM_PROTOCOL_ERROR_HTTP_UNFRAME_FAILED; } globus_free(reason); - return rc; + return rc; } /* globus_l_gram_protocol_parse_reply_header() */ static int globus_l_gram_protocol_reply( - globus_gram_protocol_handle_t handle, - int code, - globus_byte_t * message, - globus_size_t message_size, - gss_OID_set restriction_oids, - gss_buffer_set_t restriction_buffers, - OM_uint32 req_flags, - OM_uint32 time_req, + globus_gram_protocol_handle_t handle, + int code, + globus_byte_t * message, + globus_size_t message_size, + gss_OID_set restriction_oids, + gss_buffer_set_t restriction_buffers, + OM_uint32 req_flags, + OM_uint32 time_req, globus_gram_protocol_delegation_callback_t - callback, - void * arg) + callback, + void * arg) { globus_i_gram_protocol_connection_t * - connection; - globus_list_t * list; - int rc; - globus_result_t result; + connection; + globus_list_t * list; + int rc; + globus_result_t result; /* lookup up connection using handle as key */ globus_mutex_lock(&globus_i_gram_protocol_mutex); @@ -2255,34 +2255,34 @@ globus_l_gram_protocol_reply( while(list != NULL) { connection = globus_list_first(list); - if(connection->handle == handle) - { - break; - } - list = globus_list_rest(list); + if(connection->handle == handle) + { + break; + } + list = globus_list_rest(list); } if(list == NULL) { - /* No match */ + /* No match */ rc = GLOBUS_GRAM_PROTOCOL_ERROR_INVALID_REQUEST; - goto error_exit; + goto error_exit; } if(connection->read_type != GLOBUS_GRAM_PROTOCOL_REQUEST || connection->replybuf != NULL) { rc = GLOBUS_GRAM_PROTOCOL_ERROR_INVALID_REQUEST; - goto error_exit; + goto error_exit; } /* frame reply */ rc = globus_gram_protocol_frame_reply(code, message, - message_size, - &connection->replybuf, - &connection->replybufsize); + message_size, + &connection->replybuf, + &connection->replybufsize); if(rc != GLOBUS_SUCCESS) { goto error_exit; @@ -2290,7 +2290,7 @@ globus_l_gram_protocol_reply( if(callback) { - connection->keep_open = GLOBUS_TRUE; + connection->keep_open = GLOBUS_TRUE; } connection->delegation_callback = callback; connection->delegation_arg = arg; @@ -2302,17 +2302,17 @@ globus_l_gram_protocol_reply( connection->delegation_minor_status = 0; result = globus_io_register_write( - connection->io_handle, - connection->replybuf, - connection->replybufsize, - globus_l_gram_protocol_write_reply_callback, - connection); + connection->io_handle, + connection->replybuf, + connection->replybufsize, + globus_l_gram_protocol_write_reply_callback, + connection); if(result != GLOBUS_SUCCESS) { rc = GLOBUS_GRAM_PROTOCOL_ERROR_NO_RESOURCES; - goto free_reply_exit; + goto free_reply_exit; } globus_mutex_unlock(&globus_i_gram_protocol_mutex); @@ -2332,32 +2332,32 @@ globus_l_gram_protocol_reply( static int globus_l_gram_protocol_post( - const char * url, - globus_gram_protocol_handle_t * handle, - globus_io_attr_t * attr, - globus_byte_t * message, - globus_size_t message_size, - globus_bool_t keep_open, - gss_cred_id_t cred_handle, - gss_OID_set restriction_oids, - gss_buffer_set_t restriction_buffers, - OM_uint32 req_flags, - OM_uint32 time_req, - globus_gram_protocol_callback_t callback, - void * callback_arg) + const char * url, + globus_gram_protocol_handle_t * handle, + globus_io_attr_t * attr, + globus_byte_t * message, + globus_size_t message_size, + globus_bool_t keep_open, + gss_cred_id_t cred_handle, + gss_OID_set restriction_oids, + gss_buffer_set_t restriction_buffers, + OM_uint32 req_flags, + OM_uint32 time_req, + globus_gram_protocol_callback_t callback, + void * callback_arg) { - int rc; + int rc; globus_i_gram_protocol_connection_t * - connection; - globus_byte_t * framed; - globus_size_t framedsize; - globus_result_t res; - globus_url_t parsed_url; - globus_io_attr_t local_attr; - globus_list_t * node; + connection; + globus_byte_t * framed; + globus_size_t framedsize; + globus_result_t res; + globus_url_t parsed_url; + globus_io_attr_t local_attr; + globus_list_t * node; char * local_url = NULL; char * subject = NULL; - + rc = globus_url_parse(url, &parsed_url); if(rc != GLOBUS_SUCCESS) @@ -2383,23 +2383,23 @@ globus_l_gram_protocol_post( } rc = globus_gram_protocol_frame_request(local_url ? local_url : url, - message, - message_size, - &framed, - &framedsize); + message, + message_size, + &framed, + &framedsize); if(rc != GLOBUS_SUCCESS) { goto error_exit; } - + connection = globus_libc_calloc( 1, - sizeof(globus_i_gram_protocol_connection_t)); - + sizeof(globus_i_gram_protocol_connection_t)); + if(connection == NULL) { - rc = GLOBUS_GRAM_PROTOCOL_ERROR_MALLOC_FAILED; - goto free_framed_exit; + rc = GLOBUS_GRAM_PROTOCOL_ERROR_MALLOC_FAILED; + goto free_framed_exit; } connection->callback = callback; connection->callback_arg = callback_arg; @@ -2408,7 +2408,7 @@ globus_l_gram_protocol_post( connection->accepting = GLOBUS_TRUE; if(keep_open) { - connection->keep_open = keep_open; + connection->keep_open = keep_open; } connection->delegation_major_status = GSS_S_CONTINUE_NEEDED; connection->delegation_minor_status = 0; @@ -2423,27 +2423,27 @@ globus_l_gram_protocol_post( if(globus_i_gram_protocol_shutdown_called) { rc = GLOBUS_GRAM_PROTOCOL_ERROR_INVALID_REQUEST; - - goto free_connection_exit; + + goto free_connection_exit; } connection->handle = ++globus_i_gram_protocol_handle; if(handle) { - *handle = connection->handle; + *handle = connection->handle; } connection->io_handle = globus_libc_malloc(sizeof(globus_io_handle_t)); if(connection->io_handle == NULL) { - rc = GLOBUS_GRAM_PROTOCOL_ERROR_MALLOC_FAILED; - goto free_connection_exit; + rc = GLOBUS_GRAM_PROTOCOL_ERROR_MALLOC_FAILED; + goto free_connection_exit; } globus_i_gram_protocol_num_connects++; globus_list_insert(&globus_i_gram_protocol_connections, - connection); + connection); if(!attr && subject) - { - globus_l_gram_protocol_setup_connect_attr(&local_attr, subject); + { + globus_l_gram_protocol_setup_connect_attr(&local_attr, subject); res = globus_io_tcp_register_connect( parsed_url.host, @@ -2470,21 +2470,21 @@ globus_l_gram_protocol_post( { rc = GLOBUS_GRAM_PROTOCOL_ERROR_CONNECTION_FAILED; - goto remove_connection_exit; + goto remove_connection_exit; } - + globus_mutex_unlock(&globus_i_gram_protocol_mutex); globus_url_destroy(&parsed_url); - + return GLOBUS_SUCCESS; - + remove_connection_exit: globus_i_gram_protocol_num_connects--; node = globus_list_search(globus_i_gram_protocol_connections, connection); if(node) { - globus_list_remove(&globus_i_gram_protocol_connections, node); + globus_list_remove(&globus_i_gram_protocol_connections, node); } globus_libc_free(connection->io_handle); free_connection_exit: @@ -2512,47 +2512,47 @@ globus_l_gram_protocol_post( static void globus_l_gram_protocol_delegation_read_callback( - void * callback_arg, - globus_io_handle_t * handle, - globus_result_t result, - globus_byte_t * buf, - globus_size_t nbytes) + void * callback_arg, + globus_io_handle_t * handle, + globus_result_t result, + globus_byte_t * buf, + globus_size_t nbytes) { - gss_buffer_desc input_token; + gss_buffer_desc input_token; globus_i_gram_protocol_connection_t * - connection; + connection; connection = callback_arg; - + if(connection->token_length == 0 && nbytes >= 4) { - connection->token_length = buf[0] << 24; - connection->token_length |= buf[1] << 16; - connection->token_length |= buf[2] << 8; - connection->token_length |= buf[3] ; - - if(connection->replybufsize < connection->token_length) - { - globus_libc_free(connection->replybuf); - connection->replybuf = - globus_libc_malloc(connection->token_length); - connection->replybufsize = connection->token_length; - } - - result = globus_io_register_read( - connection->io_handle, - connection->replybuf, - connection->token_length, - connection->token_length, - globus_l_gram_protocol_delegation_read_callback, - connection); - - if(result == GLOBUS_SUCCESS) - { - return; - } - nbytes = 0; + connection->token_length = buf[0] << 24; + connection->token_length |= buf[1] << 16; + connection->token_length |= buf[2] << 8; + connection->token_length |= buf[3] ; + + if(connection->replybufsize < connection->token_length) + { + globus_libc_free(connection->replybuf); + connection->replybuf = + globus_libc_malloc(connection->token_length); + connection->replybufsize = connection->token_length; + } + + result = globus_io_register_read( + connection->io_handle, + connection->replybuf, + connection->token_length, + connection->token_length, + globus_l_gram_protocol_delegation_read_callback, + connection); + + if(result == GLOBUS_SUCCESS) + { + return; + } + nbytes = 0; } input_token.value = buf; @@ -2563,22 +2563,22 @@ globus_l_gram_protocol_delegation_read_callback( if(result != GLOBUS_SUCCESS) { - connection->delegation_major_status = - GSS_S_DEFECTIVE_TOKEN | GSS_S_CALL_INACCESSIBLE_READ; + connection->delegation_major_status = + GSS_S_DEFECTIVE_TOKEN | GSS_S_CALL_INACCESSIBLE_READ; } if(connection->read_type == GLOBUS_GRAM_PROTOCOL_REQUEST) { - globus_l_gram_protocol_accept_delegation( - connection, - &input_token); + globus_l_gram_protocol_accept_delegation( + connection, + &input_token); } else { - globus_assert(connection->read_type == GLOBUS_GRAM_PROTOCOL_REPLY); - globus_l_gram_protocol_init_delegation( - connection, - &input_token); + globus_assert(connection->read_type == GLOBUS_GRAM_PROTOCOL_REPLY); + globus_l_gram_protocol_init_delegation( + connection, + &input_token); } } /* globus_l_gram_protocol_delegation_read_callback() */ @@ -2586,15 +2586,15 @@ globus_l_gram_protocol_delegation_read_callback( static void globus_l_gram_protocol_delegation_write_callback( - void * callback_arg, - globus_io_handle_t * handle, - globus_result_t result, - globus_byte_t * buf, - globus_size_t nbytes) + void * callback_arg, + globus_io_handle_t * handle, + globus_result_t result, + globus_byte_t * buf, + globus_size_t nbytes) { - gss_buffer_desc input_token; + gss_buffer_desc input_token; globus_i_gram_protocol_connection_t * - connection; + connection; input_token.value = NULL; input_token.length = 0; @@ -2606,21 +2606,21 @@ globus_l_gram_protocol_delegation_write_callback( if(result != GLOBUS_SUCCESS) { - connection->delegation_major_status = - GSS_S_DEFECTIVE_TOKEN | GSS_S_CALL_INACCESSIBLE_READ; + connection->delegation_major_status = + GSS_S_DEFECTIVE_TOKEN | GSS_S_CALL_INACCESSIBLE_READ; } if(connection->read_type == GLOBUS_GRAM_PROTOCOL_REQUEST) { - globus_l_gram_protocol_accept_delegation( - connection, - &input_token); + globus_l_gram_protocol_accept_delegation( + connection, + &input_token); } else { - globus_assert(connection->read_type == GLOBUS_GRAM_PROTOCOL_REPLY); - globus_l_gram_protocol_init_delegation( - connection, - &input_token); + globus_assert(connection->read_type == GLOBUS_GRAM_PROTOCOL_REPLY); + globus_l_gram_protocol_init_delegation( + connection, + &input_token); } } /* globus_l_gram_protocol_delegation_write_callback() */ @@ -2629,12 +2629,12 @@ static void globus_l_gram_protocol_accept_delegation( globus_i_gram_protocol_connection_t * - connection, - gss_buffer_t input_token) + connection, + gss_buffer_t input_token) { - globus_result_t result; - gss_buffer_desc output_token; - unsigned char * output_buffer; + globus_result_t result; + gss_buffer_desc output_token; + unsigned char * output_buffer; output_token.value = NULL; output_token.length = 0; @@ -2642,90 +2642,90 @@ globus_l_gram_protocol_accept_delegation( if(input_token->length != 0) { gss_ctx_id_t context; - + globus_io_tcp_get_security_context(connection->io_handle, &context); - - connection->delegation_major_status = gss_accept_delegation( - &connection->delegation_minor_status, - context, - connection->delegation_restriction_oids, - connection->delegation_restriction_buffers, - input_token, - connection->delegation_req_flags, - connection->delegation_time_req, - NULL, - &connection->delegation_cred, - NULL, - &output_token); - - - if(output_token.length > 0) - { - output_buffer = globus_libc_malloc(output_token.length+4); - output_buffer[0] = (output_token.length >> 24) & 0xff; - output_buffer[1] = (output_token.length >> 16) & 0xff; - output_buffer[2] = (output_token.length >> 8) & 0xff; - output_buffer[3] = (output_token.length ) & 0xff; - memcpy(output_buffer+4, output_token.value, output_token.length); - - result = globus_io_register_write( - connection->io_handle, - output_buffer, - output_token.length+4, - globus_l_gram_protocol_delegation_write_callback, - connection); - globus_libc_free(output_token.value); - - if(result == GLOBUS_SUCCESS) - { - return; - } - else - { - connection->delegation_major_status = - GSS_S_DEFECTIVE_TOKEN | GSS_S_CALL_INACCESSIBLE_READ; - } - } + + connection->delegation_major_status = gss_accept_delegation( + &connection->delegation_minor_status, + context, + connection->delegation_restriction_oids, + connection->delegation_restriction_buffers, + input_token, + connection->delegation_req_flags, + connection->delegation_time_req, + NULL, + &connection->delegation_cred, + NULL, + &output_token); + + + if(output_token.length > 0) + { + output_buffer = globus_libc_malloc(output_token.length+4); + output_buffer[0] = (output_token.length >> 24) & 0xff; + output_buffer[1] = (output_token.length >> 16) & 0xff; + output_buffer[2] = (output_token.length >> 8) & 0xff; + output_buffer[3] = (output_token.length ) & 0xff; + memcpy(output_buffer+4, output_token.value, output_token.length); + + result = globus_io_register_write( + connection->io_handle, + output_buffer, + output_token.length+4, + globus_l_gram_protocol_delegation_write_callback, + connection); + globus_libc_free(output_token.value); + + if(result == GLOBUS_SUCCESS) + { + return; + } + else + { + connection->delegation_major_status = + GSS_S_DEFECTIVE_TOKEN | GSS_S_CALL_INACCESSIBLE_READ; + } + } } if(connection->delegation_major_status & GSS_S_CONTINUE_NEEDED) { - result = globus_io_register_read( - connection->io_handle, - connection->replybuf, - 4, - 4, - globus_l_gram_protocol_delegation_read_callback, - connection); - if(result == GLOBUS_SUCCESS) - { - return; - } - else - { - connection->delegation_major_status = - GSS_S_DEFECTIVE_TOKEN | GSS_S_CALL_INACCESSIBLE_READ; - } + result = globus_io_register_read( + connection->io_handle, + connection->replybuf, + 4, + 4, + globus_l_gram_protocol_delegation_read_callback, + connection); + if(result == GLOBUS_SUCCESS) + { + return; + } + else + { + connection->delegation_major_status = + GSS_S_DEFECTIVE_TOKEN | GSS_S_CALL_INACCESSIBLE_READ; + } } if(GSS_ERROR(connection->delegation_major_status)) { - /* TODO: error 7 hack */ + /* TODO: error 7 hack */ } /* Finished with delegation... callback */ if(connection->replybuf) { - globus_libc_free(connection->replybuf); - connection->replybuf=NULL; - connection->replybufsize=0; + globus_libc_free(connection->replybuf); + connection->replybuf=NULL; + connection->replybufsize=0; } connection->keep_open = GLOBUS_FALSE; connection->delegation_callback( - connection->delegation_arg, - connection->handle, - connection->delegation_cred, - GSS_ERROR(connection->delegation_major_status) - ? GLOBUS_GRAM_PROTOCOL_ERROR_AUTHORIZATION - : GLOBUS_SUCCESS); + connection->delegation_arg, + connection->handle, + connection->delegation_cred, + GSS_ERROR(connection->delegation_major_status) + ? GLOBUS_GRAM_PROTOCOL_ERROR_AUTHORIZATION + : GLOBUS_SUCCESS); } /* globus_l_gram_protocol_accept_delegation() */ @@ -2733,88 +2733,88 @@ static void globus_l_gram_protocol_init_delegation( globus_i_gram_protocol_connection_t * - connection, - gss_buffer_t input_token) + connection, + gss_buffer_t input_token) { - globus_result_t result; - gss_buffer_desc output_token; - unsigned char * output_buffer; + globus_result_t result; + gss_buffer_desc output_token; + unsigned char * output_buffer; output_token.value = NULL; output_token.length = 0; if(connection->delegation_major_status & GSS_S_CONTINUE_NEEDED) { - if((input_token != GSS_C_NO_BUFFER && input_token->length != 0) || - input_token == GSS_C_NO_BUFFER) - { - gss_ctx_id_t context; - - globus_io_tcp_get_security_context( - connection->io_handle, &context); - - connection->delegation_major_status = gss_init_delegation( - &connection->delegation_minor_status, - context, - connection->delegation_cred, - GSS_C_NO_OID, - connection->delegation_restriction_oids, - connection->delegation_restriction_buffers, - input_token, - connection->delegation_req_flags, - connection->delegation_time_req, - &output_token); - } - - - if(output_token.length > 0) - { - output_buffer = globus_libc_malloc(output_token.length+4); - output_buffer[0] = (output_token.length >> 24) & 0xff; - output_buffer[1] = (output_token.length >> 16) & 0xff; - output_buffer[2] = (output_token.length >> 8) & 0xff; - output_buffer[3] = (output_token.length ) & 0xff; - memcpy(output_buffer+4, output_token.value, output_token.length); - - result = globus_io_register_write( - connection->io_handle, - output_buffer, - output_token.length+4, - globus_l_gram_protocol_delegation_write_callback, - connection); - globus_libc_free(output_token.value); - - if(result == GLOBUS_SUCCESS) - { - return; - } - else - { - connection->delegation_major_status = - GSS_S_DEFECTIVE_TOKEN | GSS_S_CALL_INACCESSIBLE_READ; - } - } - - result = globus_io_register_read( - connection->io_handle, - connection->replybuf, - 4, - 4, - globus_l_gram_protocol_delegation_read_callback, - connection); - if(result == GLOBUS_SUCCESS) - { - return; - } - else - { - connection->delegation_major_status = - GSS_S_DEFECTIVE_TOKEN | GSS_S_CALL_INACCESSIBLE_READ; - } + if((input_token != GSS_C_NO_BUFFER && input_token->length != 0) || + input_token == GSS_C_NO_BUFFER) + { + gss_ctx_id_t context; + + globus_io_tcp_get_security_context( + connection->io_handle, &context); + + connection->delegation_major_status = gss_init_delegation( + &connection->delegation_minor_status, + context, + connection->delegation_cred, + GSS_C_NO_OID, + connection->delegation_restriction_oids, + connection->delegation_restriction_buffers, + input_token, + connection->delegation_req_flags, + connection->delegation_time_req, + &output_token); + } + + + if(output_token.length > 0) + { + output_buffer = globus_libc_malloc(output_token.length+4); + output_buffer[0] = (output_token.length >> 24) & 0xff; + output_buffer[1] = (output_token.length >> 16) & 0xff; + output_buffer[2] = (output_token.length >> 8) & 0xff; + output_buffer[3] = (output_token.length ) & 0xff; + memcpy(output_buffer+4, output_token.value, output_token.length); + + result = globus_io_register_write( + connection->io_handle, + output_buffer, + output_token.length+4, + globus_l_gram_protocol_delegation_write_callback, + connection); + globus_libc_free(output_token.value); + + if(result == GLOBUS_SUCCESS) + { + return; + } + else + { + connection->delegation_major_status = + GSS_S_DEFECTIVE_TOKEN | GSS_S_CALL_INACCESSIBLE_READ; + } + } + + result = globus_io_register_read( + connection->io_handle, + connection->replybuf, + 4, + 4, + globus_l_gram_protocol_delegation_read_callback, + connection); + if(result == GLOBUS_SUCCESS) + { + return; + } + else + { + connection->delegation_major_status = + GSS_S_DEFECTIVE_TOKEN | GSS_S_CALL_INACCESSIBLE_READ; + } } if(GSS_ERROR(connection->delegation_major_status)) { - /* TODO: error 7 hack */ + /* TODO: error 7 hack */ } /* Finished with delegation... register read of delegation status */ @@ -2822,53 +2822,53 @@ globus_l_gram_protocol_init_delegation( if(connection->replybufsize < GLOBUS_GRAM_PROTOCOL_MAX_MSG_SIZE) { - globus_libc_free(connection->replybuf); - connection->replybuf = - globus_libc_malloc(GLOBUS_GRAM_PROTOCOL_MAX_MSG_SIZE); - connection->replybufsize = GLOBUS_GRAM_PROTOCOL_MAX_MSG_SIZE; + globus_libc_free(connection->replybuf); + connection->replybuf = + globus_libc_malloc(GLOBUS_GRAM_PROTOCOL_MAX_MSG_SIZE); + connection->replybufsize = GLOBUS_GRAM_PROTOCOL_MAX_MSG_SIZE; } result = globus_io_register_read( - connection->io_handle, - connection->replybuf, - connection->replybufsize, - 1, - globus_l_gram_protocol_read_reply_callback, - connection); + connection->io_handle, + connection->replybuf, + connection->replybufsize, + 1, + globus_l_gram_protocol_read_reply_callback, + connection); if(result == GLOBUS_SUCCESS) { - return; + return; } else { - connection->rc = GLOBUS_GRAM_PROTOCOL_ERROR_NO_RESOURCES; + connection->rc = GLOBUS_GRAM_PROTOCOL_ERROR_NO_RESOURCES; } if(connection->callback && connection->rc) { - connection->callback(connection->callback_arg, - connection->handle, - connection->replybuf, - connection->payload_length, - connection->rc, - NULL); + connection->callback(connection->callback_arg, + connection->handle, + connection->replybuf, + connection->payload_length, + connection->rc, + NULL); } /* For reply handling, we just need to close up the connection * after we've dispatched the callback. */ result = globus_io_register_close( connection->io_handle, - globus_l_gram_protocol_connection_close_callback, - connection); + globus_l_gram_protocol_connection_close_callback, + connection); if(result != GLOBUS_SUCCESS) { /* If we can't close the handle, we'd still like to clean up - * our memory. - */ - globus_l_gram_protocol_connection_close_callback( - connection, - connection->io_handle, - result); + * our memory. + */ + globus_l_gram_protocol_connection_close_callback( + connection, + connection->io_handle, + result); } } /* globus_l_gram_protocol_init_delegation() */ @@ -2877,19 +2877,19 @@ globus_l_gram_protocol_init_delegation( static globus_bool_t globus_l_gram_protocol_authorization_callback( - void * arg, - globus_io_handle_t * handle, - globus_result_t result, - char * identity, - gss_ctx_id_t context_handle) + void * arg, + globus_io_handle_t * handle, + globus_result_t result, + char * identity, + gss_ctx_id_t context_handle) { globus_i_gram_protocol_connection_t * - connection; - + connection; + connection = (globus_i_gram_protocol_connection_t *) arg; connection->context = context_handle; - + return GLOBUS_TRUE; } @@ -2952,33 +2952,33 @@ globus_l_gram_protocol_setup_connect_attr( /* acquire mutex */ if ((res = globus_io_tcpattr_init(attr)) != GLOBUS_SUCCESS) { - rc = GLOBUS_GRAM_PROTOCOL_ERROR_CONNECTION_FAILED; + rc = GLOBUS_GRAM_PROTOCOL_ERROR_CONNECTION_FAILED; goto out; } if ( (res = globus_io_secure_authorization_data_initialize( - &auth_data)) - || (res = globus_io_secure_authorization_data_set_identity( - &auth_data, + &auth_data)) + || (res = globus_io_secure_authorization_data_set_identity( + &auth_data, identity)) - || (res = globus_io_attr_set_secure_authentication_mode( - attr, - GLOBUS_IO_SECURE_AUTHENTICATION_MODE_MUTUAL, - globus_i_gram_protocol_credential)) - || (res = globus_io_attr_set_secure_authorization_mode( - attr, - GLOBUS_IO_SECURE_AUTHORIZATION_MODE_IDENTITY, - &auth_data)) - || (res = globus_io_attr_set_secure_channel_mode( - attr, - GLOBUS_IO_SECURE_CHANNEL_MODE_SSL_WRAP)) + || (res = globus_io_attr_set_secure_authentication_mode( + attr, + GLOBUS_IO_SECURE_AUTHENTICATION_MODE_MUTUAL, + globus_i_gram_protocol_credential)) + || (res = globus_io_attr_set_secure_authorization_mode( + attr, + GLOBUS_IO_SECURE_AUTHORIZATION_MODE_IDENTITY, + &auth_data)) + || (res = globus_io_attr_set_secure_channel_mode( + attr, + GLOBUS_IO_SECURE_CHANNEL_MODE_SSL_WRAP)) || (res = globus_io_attr_set_tcp_allow_ipv6( attr, GLOBUS_TRUE)) ) { globus_io_tcpattr_destroy(attr); - rc = GLOBUS_GRAM_PROTOCOL_ERROR_CONNECTION_FAILED; + rc = GLOBUS_GRAM_PROTOCOL_ERROR_CONNECTION_FAILED; } if (auth_data) diff --git a/gram/protocol/source/globus_gram_protocol_pack.c b/gram/protocol/source/globus_gram_protocol_pack.c index c5524647af..f1f234dcee 100644 --- a/gram/protocol/source/globus_gram_protocol_pack.c +++ b/gram/protocol/source/globus_gram_protocol_pack.c @@ -70,7 +70,7 @@ globus_l_gram_protocol_get_string_attribute( /** * @brief Pack a GRAM Job Request - * @ingroup globus_gram_protocol_pack + * @ingroup globus_gram_protocol_pack * * @details * The globus_gram_protocol_pack_job_request() function combines its @@ -305,7 +305,7 @@ globus_gram_protocol_unpack_job_request( * parameters into a GRAM reply message body. The caller may frame * and send the resulting message by calling globus_gram_protocol_reply() * or just frame it by calling globus_gram_protocol_frame_reply() and send - * it by some other mechanism. The + * it by some other mechanism. The * globus_gram_protocol_pack_job_request_reply() * function returns the packed message by modifying the @a reply parameter to * point to a new string containing the message. The caller is responsible for @@ -380,7 +380,7 @@ globus_gram_protocol_pack_job_request_reply( * The globus_gram_protocol_unpack_job_request_reply() function parses the * reply message packed in the @a reply message and returns copies of * the standard message attributes in the @a status and @a job_contact - * parameters. + * parameters. * * @param reply * The unframed job reply message to parse. @@ -697,7 +697,7 @@ globus_gram_protocol_unpack_job_request_reply_with_extensions( globus_gram_protocol_extension_t * entry = NULL; int rc; - if (reply == NULL || status == NULL || job_contact == NULL || + if (reply == NULL || status == NULL || job_contact == NULL || extensions == NULL) { rc = GLOBUS_GRAM_PROTOCOL_ERROR_NULL_PARAMETER; @@ -741,7 +741,7 @@ globus_gram_protocol_unpack_job_request_reply_with_extensions( if (entry == NULL) { rc = GLOBUS_GRAM_PROTOCOL_ERROR_HTTP_UNPACK_FAILED; - + goto verify_error; } *status = atoi(entry->value); @@ -779,7 +779,7 @@ globus_gram_protocol_unpack_job_request_reply_with_extensions( /** * @brief Pack a GRAM query message - * @ingroup globus_gram_protocol_pack + * @ingroup globus_gram_protocol_pack * * @details * The globus_gram_protocol_pack_status_request() @@ -867,7 +867,7 @@ globus_gram_protocol_pack_status_request( * @param querysize * The length of the query string. * @param status_request - * A pointer to a string to be set to the query + * A pointer to a string to be set to the query * value. The caller must free this string using free(). * * @return @@ -958,7 +958,7 @@ globus_gram_protocol_unpack_status_request( /* globus_gram_protocol_unpack_status_request() */ /** - * @brief Pack a GRAM query reply message + * @brief Pack a GRAM query reply message * @ingroup globus_gram_protocol_pack * * @details @@ -1151,7 +1151,7 @@ globus_gram_protocol_unpack_status_reply( * The error code associated with the job if it has failed. This may * be GLOBUS_SUCCESS if the job has not failed. * @param extensions - * A pointer to a hash table containing the + * A pointer to a hash table containing the * names and values of the protocol extensions to add to this message. * @param reply * An output parameter which will be set to a new @@ -1326,7 +1326,7 @@ globus_gram_protocol_unpack_status_reply_with_extensions( { goto parse_error; } - + /* Check that required attributes are present */ entry = globus_hashtable_lookup( extensions, @@ -1350,7 +1350,7 @@ globus_gram_protocol_unpack_status_reply_with_extensions( if (entry == NULL) { rc = GLOBUS_GRAM_PROTOCOL_ERROR_HTTP_UNPACK_FAILED; - + goto verify_error; } @@ -1480,7 +1480,7 @@ globus_gram_protocol_pack_status_update_message( * The globus_gram_protocol_pack_status_update_message_with_extensions() * function returns the packed message by modifying the @a reply parameter to * point to a new string containing the message. The caller is responsible for - * freeing that string. + * freeing that string. * * @param job_contact * The job contact string associated with the job. @@ -1889,7 +1889,7 @@ globus_gram_protocol_unpack_status_update_message_with_extensions( failure_code == GLOBUS_GRAM_PROTOCOL_ERROR_STAGING_EXECUTABLE || failure_code == GLOBUS_GRAM_PROTOCOL_ERROR_STAGING_STDIN) { - if (failure_type && + if (failure_type && (strcmp(failure_type, "executable") == 0 || strcmp(failure_type, "stdin") == 0)) { @@ -1981,7 +1981,7 @@ globus_l_gram_protocol_extension_destroy( /** * Destroy message attribute hash * @ingroup globus_gram_protocol_unpack - * + * * @param message_hash * Hashtable of globus_gram_protocol_extension_t * values to destroy */ @@ -2002,17 +2002,17 @@ globus_gram_protocol_hash_destroy( /** * Create a GRAM5 protocol extension entry - * @ingroup globus_gram_protocol_extensions + * @ingroup globus_gram_protocol_pack * * Allocates a new GRAM5 protocol extension entry containing an attribute-value * pair. The @a attribute parameter is copied into the extension, and the * @a format parameter is a printf-style format string used to construct the * value of the extension. - * + * * The caller is responsible for freeing the extension when done with it. The * quoting rules described in @ref globus_gram_protocol must be implemented * by the caller in the format string. - * + * * @param attribute * Name of the extension attribute * @param format @@ -2227,7 +2227,7 @@ globus_gram_protocol_unpack_message( /** * @brief Pack a GRAM version request message * @ingroup globus_gram_protocol_pack - * + * * @details * The globus_gram_protocol_pack_job_request() function creates a copy * of the GRAM version request. The caller may frame @@ -2253,7 +2253,7 @@ globus_gram_protocol_unpack_message( * globus_gram_protocol_pack_version_request() returns an integer * error code and the values pointed to by @a request and @a requestsize * are undefined. - * + * * @retval GLOBUS_SUCCESS * Success * @retval GLOBUS_GRAM_PROTOCOL_ERROR_NULL_PARAMETER diff --git a/gram/rsl/source/configure.ac b/gram/rsl/source/configure.ac index 013b43d7d3..b9b05667fd 100644 --- a/gram/rsl/source/configure.ac +++ b/gram/rsl/source/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ([2.60]) -AC_INIT([globus_rsl],[11.4],[https://github.com/gridcf/gct/issues]) +AC_INIT([globus_rsl],[11.5],[https://github.com/gridcf/gct/issues]) AC_CONFIG_MACRO_DIR([m4]) AC_SUBST([MAJOR_VERSION], [${PACKAGE_VERSION%%.*}]) AC_SUBST([MINOR_VERSION], [${PACKAGE_VERSION##*.}]) diff --git a/gram/rsl/source/globus_rsl_assist.c b/gram/rsl/source/globus_rsl_assist.c index 3a3e662cd0..80321bd950 100644 --- a/gram/rsl/source/globus_rsl_assist.c +++ b/gram/rsl/source/globus_rsl_assist.c @@ -66,7 +66,7 @@ int globus_rsl_assist_attributes_canonicalize(globus_rsl_t * rsl) { - + globus_list_t * lists=GLOBUS_NULL; globus_rsl_t * an_rsl; @@ -80,7 +80,7 @@ globus_rsl_assist_attributes_canonicalize(globus_rsl_t * rsl) while (!globus_list_empty(lists)) { an_rsl=globus_list_first(lists); - if (globus_rsl_assist_attributes_canonicalize(an_rsl) + if (globus_rsl_assist_attributes_canonicalize(an_rsl) != GLOBUS_SUCCESS) { return GLOBUS_FAILURE; @@ -145,8 +145,6 @@ globus_rsl_assist_attributes_canonicalize(globus_rsl_t * rsl) * * @param ptr * Pointer to the RSL string to modify in place. - * - * @return void */ void globus_rsl_assist_string_canonicalize(char * ptr) diff --git a/gram/rsl/source/globus_rsl_parser.c b/gram/rsl/source/globus_rsl_parser.c index 0ec64b83cf..49d34f43f0 100644 --- a/gram/rsl/source/globus_rsl_parser.c +++ b/gram/rsl/source/globus_rsl_parser.c @@ -181,7 +181,7 @@ yyerror(YYLTYPE *loc, yyscan_t scanner, struct globus_parse_state_s *parse_state typedef union YYSTYPE #line 61 "../../../../../gram/rsl/source/globus_rsl_parser.y" { - int Int; + int Int; char * String; globus_rsl_t * RSL; @@ -1867,7 +1867,7 @@ yyerror(YYLTYPE * loc, yyscan_t scanner, struct globus_parse_state_s * parse_sta /** * @brief Parse an RSL string - * @ingroup globus_rsl_parse + * @ingroup globus_rsl * @details * The globus_rsl_parse() function parses the string pointed to by * the @a buf parameter into an RSL syntax tree. The caller is responsible diff --git a/gram/rsl/source/globus_rsl_parser.y b/gram/rsl/source/globus_rsl_parser.y index 3659785b0b..86fba9557c 100644 --- a/gram/rsl/source/globus_rsl_parser.y +++ b/gram/rsl/source/globus_rsl_parser.y @@ -59,7 +59,7 @@ yyerror(YYLTYPE *loc, yyscan_t scanner, struct globus_parse_state_s *parse_state %union { - int Int; + int Int; char * String; globus_rsl_t * RSL; @@ -221,7 +221,7 @@ yyerror(YYLTYPE * loc, yyscan_t scanner, struct globus_parse_state_s * parse_sta /** * @brief Parse an RSL string - * @ingroup globus_rsl_parse + * @ingroup globus_rsl * @details * The globus_rsl_parse() function parses the string pointed to by * the @a buf parameter into an RSL syntax tree. The caller is responsible diff --git a/gridftp/client/source/configure.ac b/gridftp/client/source/configure.ac index feeaa43da5..75f7a356f3 100644 --- a/gridftp/client/source/configure.ac +++ b/gridftp/client/source/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ([2.60]) -AC_INIT([globus_ftp_client],[9.9],[https://github.com/gridcf/gct/issues]) +AC_INIT([globus_ftp_client],[9.10],[https://github.com/gridcf/gct/issues]) AC_CONFIG_MACRO_DIR([m4]) AC_SUBST([MAJOR_VERSION], [${PACKAGE_VERSION%%.*}]) AC_SUBST([MINOR_VERSION], [${PACKAGE_VERSION##*.}]) diff --git a/gridftp/client/source/globus_ftp_client.h b/gridftp/client/source/globus_ftp_client.h index 2827d5e95f..83cd73af11 100644 --- a/gridftp/client/source/globus_ftp_client.h +++ b/gridftp/client/source/globus_ftp_client.h @@ -57,7 +57,7 @@ * structure contains context information about FTP operations which are * being executed, a cache of FTP control and data connections, and * information about plugins which are being used. The specifics of the - * connection caching and plugins are found in the + * connection caching and plugins are found in the * @ref globus_ftp_client_handleattr section of this manual. * * Once the handle is created, one may begin transferring files or doing @@ -68,7 +68,7 @@ * commands. All FTP operations may have a set of attributes, defined * in the @ref globus_ftp_client_operationattr section, associated with * them to tune various FTP parameters. The data structures and functions - * needed to restart a file transfer are described in the + * needed to restart a file transfer are described in the * @ref globus_ftp_client_restart_marker section of this manual. For operations * which require the user to send to or receive data from an FTP server * the must call the functions in the @ref globus_ftp_client_data section @@ -137,7 +137,7 @@ typedef enum /** * Restart marker types. - * @ingroup globus_ftp_client_restart_markers + * @ingroup globus_ftp_client_restart_marker * @internal * * This enum defines the different types of restart markers which may be used @@ -153,7 +153,7 @@ globus_ftp_client_restart_type_t; /** * @brief Stream mode restart marker - * @ingroup globus_ftp_client_restart_markers + * @ingroup globus_ftp_client_restart_marker * @internal * * This structure contains all restart marker information from a @@ -167,24 +167,24 @@ typedef struct /** * @internal * Must be GLOBUS_FTP_CLIENT_STREAM - */ - globus_ftp_client_restart_type_t type; + */ + globus_ftp_client_restart_type_t type; /** * @internal * The offset of a binary file transfer. */ - globus_off_t offset; + globus_off_t offset; /** * @internal * The offset of an ASCII file transfer. */ - globus_off_t ascii_offset; + globus_off_t ascii_offset; } globus_ftp_client_restart_stream_t; /** * @brief Extended block mode restart marker - * @ingroup globus_ftp_client_restart_markers + * @ingroup globus_ftp_client_restart_marker * @internal * * This structure contains all restart marker information from an @@ -198,13 +198,13 @@ typedef struct /** * @internal * Must be GLOBUS_FTP_CLIENT_RESTART_EXTENDED_BLOCK - */ - globus_ftp_client_restart_type_t type; + */ + globus_ftp_client_restart_type_t type; /** * @internal * A fifo of globus_i_ftp_client_range_t byte range entries */ - globus_fifo_t ranges; + globus_fifo_t ranges; } globus_ftp_client_restart_extended_block_t; @@ -223,9 +223,9 @@ globus_ftp_client_restart_extended_block_t; */ typedef union { - globus_ftp_client_restart_type_t type; - globus_ftp_client_restart_stream_t stream; - globus_ftp_client_restart_extended_block_t extended_block; + globus_ftp_client_restart_type_t type; + globus_ftp_client_restart_stream_t stream; + globus_ftp_client_restart_extended_block_t extended_block; } globus_ftp_client_restart_marker_t; @@ -280,9 +280,9 @@ typedef struct globus_i_ftp_client_plugin_t * globus_ftp_client_plugin_t; * or GLOBUS_SUCCESS, if the operation completed successfully. */ typedef void (*globus_ftp_client_complete_callback_t) ( - void * user_arg, - globus_ftp_client_handle_t * handle, - globus_object_t * error); + void * user_arg, + globus_ftp_client_handle_t * handle, + globus_object_t * error); /** * Data Callback. @@ -313,13 +313,13 @@ typedef void (*globus_ftp_client_complete_callback_t) ( * GLOBUS_TRUE for multiple callbacks. */ typedef void (*globus_ftp_client_data_callback_t) ( - void * user_arg, - globus_ftp_client_handle_t * handle, - globus_object_t * error, - globus_byte_t * buffer, - globus_size_t length, - globus_off_t offset, - globus_bool_t eof); + void * user_arg, + globus_ftp_client_handle_t * handle, + globus_object_t * error, + globus_byte_t * buffer, + globus_size_t length, + globus_off_t offset, + globus_bool_t eof); /** * @brief Operation Attributes. @@ -366,38 +366,38 @@ typedef struct #ifndef DOXYGEN globus_result_t globus_ftp_client_restart_marker_init( - globus_ftp_client_restart_marker_t * marker); + globus_ftp_client_restart_marker_t * marker); globus_result_t globus_ftp_client_restart_marker_destroy( - globus_ftp_client_restart_marker_t * marker); + globus_ftp_client_restart_marker_t * marker); globus_result_t globus_ftp_client_restart_marker_copy( - globus_ftp_client_restart_marker_t * new_marker, - globus_ftp_client_restart_marker_t * marker); + globus_ftp_client_restart_marker_t * new_marker, + globus_ftp_client_restart_marker_t * marker); globus_result_t globus_ftp_client_restart_marker_insert_range( - globus_ftp_client_restart_marker_t * marker, - globus_off_t offset, - globus_off_t end_offset); + globus_ftp_client_restart_marker_t * marker, + globus_off_t offset, + globus_off_t end_offset); globus_result_t globus_ftp_client_restart_marker_set_offset( - globus_ftp_client_restart_marker_t * marker, - globus_off_t offset); + globus_ftp_client_restart_marker_t * marker, + globus_off_t offset); globus_result_t globus_ftp_client_restart_marker_set_ascii_offset( - globus_ftp_client_restart_marker_t * marker, - globus_off_t offset, - globus_off_t ascii_offset); + globus_ftp_client_restart_marker_t * marker, + globus_off_t offset, + globus_off_t ascii_offset); globus_result_t globus_ftp_client_restart_marker_get_total( - globus_ftp_client_restart_marker_t * marker, - globus_off_t * total_bytes); + globus_ftp_client_restart_marker_t * marker, + globus_off_t * total_bytes); globus_result_t globus_ftp_client_restart_marker_get_first_block( @@ -407,13 +407,13 @@ globus_ftp_client_restart_marker_get_first_block( globus_result_t globus_ftp_client_restart_marker_to_string( - globus_ftp_client_restart_marker_t * marker, - char ** marker_string); + globus_ftp_client_restart_marker_t * marker, + char ** marker_string); globus_result_t globus_ftp_client_restart_marker_from_string( - globus_ftp_client_restart_marker_t * marker, - const char * marker_string); + globus_ftp_client_restart_marker_t * marker, + const char * marker_string); #endif /** @@ -434,39 +434,39 @@ globus_ftp_client_restart_marker_from_string( #ifndef DOXYGEN globus_result_t globus_ftp_client_handle_init( - globus_ftp_client_handle_t * handle, - globus_ftp_client_handleattr_t* attr); + globus_ftp_client_handle_t * handle, + globus_ftp_client_handleattr_t* attr); globus_result_t globus_ftp_client_handle_destroy( - globus_ftp_client_handle_t * handle); + globus_ftp_client_handle_t * handle); globus_result_t globus_ftp_client_handle_borrow_connection( - globus_ftp_client_handle_t * from_handle, + globus_ftp_client_handle_t * from_handle, globus_bool_t from_is_source, - globus_ftp_client_handle_t * to_handle, + globus_ftp_client_handle_t * to_handle, globus_bool_t to_is_source); globus_result_t globus_ftp_client_handle_cache_url_state( - globus_ftp_client_handle_t * handle, - const char * url); + globus_ftp_client_handle_t * handle, + const char * url); globus_result_t globus_ftp_client_handle_flush_url_state( - globus_ftp_client_handle_t * handle, - const char * url); + globus_ftp_client_handle_t * handle, + const char * url); globus_result_t globus_ftp_client_handle_set_user_pointer( - globus_ftp_client_handle_t * handle, - void * user_pointer); + globus_ftp_client_handle_t * handle, + void * user_pointer); globus_result_t globus_ftp_client_handle_get_user_pointer( - const globus_ftp_client_handle_t * handle, - void ** user_pointer); + const globus_ftp_client_handle_t * handle, + void ** user_pointer); globus_result_t globus_ftp_client_handle_get_restart_marker( @@ -475,13 +475,13 @@ globus_ftp_client_handle_get_restart_marker( globus_result_t globus_ftp_client_handle_add_plugin( - globus_ftp_client_handle_t * handle, - globus_ftp_client_plugin_t * plugin); + globus_ftp_client_handle_t * handle, + globus_ftp_client_plugin_t * plugin); globus_result_t globus_ftp_client_handle_remove_plugin( - globus_ftp_client_handle_t * handle, - globus_ftp_client_plugin_t * plugin); + globus_ftp_client_handle_t * handle, + globus_ftp_client_plugin_t * plugin); #endif @@ -502,46 +502,46 @@ globus_ftp_client_handle_remove_plugin( #ifndef DOXYGEN globus_result_t globus_ftp_client_handleattr_init( - globus_ftp_client_handleattr_t * attr); + globus_ftp_client_handleattr_t * attr); globus_result_t globus_ftp_client_handleattr_destroy( - globus_ftp_client_handleattr_t * attr); + globus_ftp_client_handleattr_t * attr); globus_result_t globus_ftp_client_handleattr_copy( - globus_ftp_client_handleattr_t * dest, - globus_ftp_client_handleattr_t * src); + globus_ftp_client_handleattr_t * dest, + globus_ftp_client_handleattr_t * src); globus_result_t globus_ftp_client_handleattr_add_cached_url( - globus_ftp_client_handleattr_t * attr, - const char * url); + globus_ftp_client_handleattr_t * attr, + const char * url); globus_result_t globus_ftp_client_handleattr_remove_cached_url( - globus_ftp_client_handleattr_t * attr, - const char * url); + globus_ftp_client_handleattr_t * attr, + const char * url); globus_result_t globus_ftp_client_handleattr_set_cache_all( - globus_ftp_client_handleattr_t * attr, - globus_bool_t cache_all); + globus_ftp_client_handleattr_t * attr, + globus_bool_t cache_all); globus_result_t globus_ftp_client_handleattr_get_cache_all( - const globus_ftp_client_handleattr_t * attr, - globus_bool_t * cache_all); + const globus_ftp_client_handleattr_t * attr, + globus_bool_t * cache_all); globus_result_t globus_ftp_client_handleattr_set_rfc1738_url( - globus_ftp_client_handleattr_t * attr, - globus_bool_t rfc1738_url); + globus_ftp_client_handleattr_t * attr, + globus_bool_t rfc1738_url); globus_result_t globus_ftp_client_handleattr_get_rfc1738_url( - const globus_ftp_client_handleattr_t * attr, - globus_bool_t * rfc1738_url); + const globus_ftp_client_handleattr_t * attr, + globus_bool_t * rfc1738_url); typedef void (*globus_ftp_client_pipeline_callback_t)( globus_ftp_client_handle_t * handle, @@ -565,18 +565,18 @@ globus_ftp_client_handleattr_get_pipeline( globus_result_t globus_ftp_client_handleattr_set_gridftp2( - globus_ftp_client_handleattr_t * attr, - globus_bool_t gridftp2); + globus_ftp_client_handleattr_t * attr, + globus_bool_t gridftp2); globus_result_t globus_ftp_client_handleattr_get_gridftp2( - const globus_ftp_client_handleattr_t * attr, - globus_bool_t * gridftp2); + const globus_ftp_client_handleattr_t * attr, + globus_bool_t * gridftp2); globus_result_t globus_ftp_client_handleattr_set_netlogger( - globus_ftp_client_handleattr_t * attr, - globus_netlogger_handle_t * nl_handle); + globus_ftp_client_handleattr_t * attr, + globus_netlogger_handle_t * nl_handle); globus_result_t globus_ftp_client_handleattr_set_clientinfo( @@ -601,13 +601,13 @@ globus_ftp_client_handleattr_set_netlogger_ftp_io( globus_result_t globus_ftp_client_handleattr_remove_plugin( - globus_ftp_client_handleattr_t * attr, - globus_ftp_client_plugin_t * plugin); + globus_ftp_client_handleattr_t * attr, + globus_ftp_client_plugin_t * plugin); globus_result_t globus_ftp_client_handleattr_add_plugin( - globus_ftp_client_handleattr_t * attr, - globus_ftp_client_plugin_t * plugin); + globus_ftp_client_handleattr_t * attr, + globus_ftp_client_plugin_t * plugin); #endif /** @@ -624,12 +624,12 @@ globus_ftp_client_handleattr_add_plugin( globus_result_t globus_ftp_client_chmod( - globus_ftp_client_handle_t * u_handle, - const char * url, - int mode, - globus_ftp_client_operationattr_t * attr, - globus_ftp_client_complete_callback_t complete_callback, - void * callback_arg); + globus_ftp_client_handle_t * u_handle, + const char * url, + int mode, + globus_ftp_client_operationattr_t * attr, + globus_ftp_client_complete_callback_t complete_callback, + void * callback_arg); globus_result_t globus_ftp_client_chgrp( @@ -660,63 +660,63 @@ globus_ftp_client_symlink( globus_result_t globus_ftp_client_cksm( - globus_ftp_client_handle_t * handle, - const char * url, - globus_ftp_client_operationattr_t * attr, - char * cksm, + globus_ftp_client_handle_t * handle, + const char * url, + globus_ftp_client_operationattr_t * attr, + char * cksm, globus_off_t offset, globus_off_t length, - const char * algorithm, - globus_ftp_client_complete_callback_t complete_callback, - void * callback_arg); + const char * algorithm, + globus_ftp_client_complete_callback_t complete_callback, + void * callback_arg); globus_result_t globus_ftp_client_delete( - globus_ftp_client_handle_t * handle, - const char * url, - globus_ftp_client_operationattr_t * attr, - globus_ftp_client_complete_callback_t complete_callback, - void * callback_arg); + globus_ftp_client_handle_t * handle, + const char * url, + globus_ftp_client_operationattr_t * attr, + globus_ftp_client_complete_callback_t complete_callback, + void * callback_arg); globus_result_t globus_ftp_client_mkdir( - globus_ftp_client_handle_t * handle, - const char * url, - globus_ftp_client_operationattr_t * attr, - globus_ftp_client_complete_callback_t complete_callback, - void * callback_arg); + globus_ftp_client_handle_t * handle, + const char * url, + globus_ftp_client_operationattr_t * attr, + globus_ftp_client_complete_callback_t complete_callback, + void * callback_arg); globus_result_t globus_ftp_client_rmdir( - globus_ftp_client_handle_t * handle, - const char * url, - globus_ftp_client_operationattr_t * attr, - globus_ftp_client_complete_callback_t complete_callback, - void * callback_arg); + globus_ftp_client_handle_t * handle, + const char * url, + globus_ftp_client_operationattr_t * attr, + globus_ftp_client_complete_callback_t complete_callback, + void * callback_arg); globus_result_t globus_ftp_client_list( - globus_ftp_client_handle_t * handle, - const char * url, - globus_ftp_client_operationattr_t * attr, - globus_ftp_client_complete_callback_t complete_callback, - void * callback_arg); + globus_ftp_client_handle_t * handle, + const char * url, + globus_ftp_client_operationattr_t * attr, + globus_ftp_client_complete_callback_t complete_callback, + void * callback_arg); globus_result_t globus_ftp_client_verbose_list( - globus_ftp_client_handle_t * handle, - const char * url, - globus_ftp_client_operationattr_t * attr, - globus_ftp_client_complete_callback_t complete_callback, - void * callback_arg); + globus_ftp_client_handle_t * handle, + const char * url, + globus_ftp_client_operationattr_t * attr, + globus_ftp_client_complete_callback_t complete_callback, + void * callback_arg); globus_result_t globus_ftp_client_machine_list( - globus_ftp_client_handle_t * handle, - const char * url, - globus_ftp_client_operationattr_t * attr, - globus_ftp_client_complete_callback_t complete_callback, - void * callback_arg); + globus_ftp_client_handle_t * handle, + const char * url, + globus_ftp_client_operationattr_t * attr, + globus_ftp_client_complete_callback_t complete_callback, + void * callback_arg); globus_result_t globus_ftp_client_recursive_list( @@ -728,106 +728,106 @@ globus_ftp_client_recursive_list( globus_result_t globus_ftp_client_mlst( - globus_ftp_client_handle_t * u_handle, - const char * url, - globus_ftp_client_operationattr_t * attr, - globus_byte_t ** mlst_buffer, + globus_ftp_client_handle_t * u_handle, + const char * url, + globus_ftp_client_operationattr_t * attr, + globus_byte_t ** mlst_buffer, globus_size_t * mlst_buffer_length, - globus_ftp_client_complete_callback_t complete_callback, - void * callback_arg); + globus_ftp_client_complete_callback_t complete_callback, + void * callback_arg); globus_result_t globus_ftp_client_cwd( - globus_ftp_client_handle_t * u_handle, - const char * url, - globus_ftp_client_operationattr_t * attr, - globus_byte_t ** cwd_buffer, + globus_ftp_client_handle_t * u_handle, + const char * url, + globus_ftp_client_operationattr_t * attr, + globus_byte_t ** cwd_buffer, globus_size_t * cwd_buffer_length, - globus_ftp_client_complete_callback_t complete_callback, - void * callback_arg); + globus_ftp_client_complete_callback_t complete_callback, + void * callback_arg); globus_result_t globus_ftp_client_stat( - globus_ftp_client_handle_t * u_handle, - const char * url, - globus_ftp_client_operationattr_t * attr, - globus_byte_t ** stat_buffer, + globus_ftp_client_handle_t * u_handle, + const char * url, + globus_ftp_client_operationattr_t * attr, + globus_byte_t ** stat_buffer, globus_size_t * stat_buffer_length, - globus_ftp_client_complete_callback_t complete_callback, - void * callback_arg); + globus_ftp_client_complete_callback_t complete_callback, + void * callback_arg); globus_result_t globus_ftp_client_move( - globus_ftp_client_handle_t * handle, - const char * source_url, - const char * dest_url, - globus_ftp_client_operationattr_t * attr, - globus_ftp_client_complete_callback_t complete_callback, - void * callback_arg); + globus_ftp_client_handle_t * handle, + const char * source_url, + const char * dest_url, + globus_ftp_client_operationattr_t * attr, + globus_ftp_client_complete_callback_t complete_callback, + void * callback_arg); globus_result_t globus_ftp_client_get( - globus_ftp_client_handle_t * handle, - const char * url, - globus_ftp_client_operationattr_t * attr, - globus_ftp_client_restart_marker_t * restart, - globus_ftp_client_complete_callback_t complete_callback, - void * callback_arg); + globus_ftp_client_handle_t * handle, + const char * url, + globus_ftp_client_operationattr_t * attr, + globus_ftp_client_restart_marker_t * restart, + globus_ftp_client_complete_callback_t complete_callback, + void * callback_arg); globus_result_t globus_ftp_client_put( - globus_ftp_client_handle_t * handle, - const char * url, - globus_ftp_client_operationattr_t * attr, - globus_ftp_client_restart_marker_t * restart, - globus_ftp_client_complete_callback_t complete_callback, - void * callback_arg); + globus_ftp_client_handle_t * handle, + const char * url, + globus_ftp_client_operationattr_t * attr, + globus_ftp_client_restart_marker_t * restart, + globus_ftp_client_complete_callback_t complete_callback, + void * callback_arg); globus_result_t globus_ftp_client_third_party_transfer( - globus_ftp_client_handle_t * handle, - const char * source_url, - globus_ftp_client_operationattr_t * source_attr, - const char * dest_url, - globus_ftp_client_operationattr_t * dest_attr, - globus_ftp_client_restart_marker_t * restart, - globus_ftp_client_complete_callback_t complete_callback, - void * callback_arg); + globus_ftp_client_handle_t * handle, + const char * source_url, + globus_ftp_client_operationattr_t * source_attr, + const char * dest_url, + globus_ftp_client_operationattr_t * dest_attr, + globus_ftp_client_restart_marker_t * restart, + globus_ftp_client_complete_callback_t complete_callback, + void * callback_arg); globus_result_t globus_ftp_client_partial_get( - globus_ftp_client_handle_t * handle, - const char * url, - globus_ftp_client_operationattr_t * attr, - globus_ftp_client_restart_marker_t * restart, - globus_off_t partial_offset, - globus_off_t partial_end_offset, - globus_ftp_client_complete_callback_t complete_callback, - void * callback_arg); + globus_ftp_client_handle_t * handle, + const char * url, + globus_ftp_client_operationattr_t * attr, + globus_ftp_client_restart_marker_t * restart, + globus_off_t partial_offset, + globus_off_t partial_end_offset, + globus_ftp_client_complete_callback_t complete_callback, + void * callback_arg); globus_result_t globus_ftp_client_partial_put( - globus_ftp_client_handle_t * handle, - const char * url, - globus_ftp_client_operationattr_t * attr, - globus_ftp_client_restart_marker_t * restart, - globus_off_t partial_offset, - globus_off_t partial_end_offset, - globus_ftp_client_complete_callback_t complete_callback, - void * callback_arg); + globus_ftp_client_handle_t * handle, + const char * url, + globus_ftp_client_operationattr_t * attr, + globus_ftp_client_restart_marker_t * restart, + globus_off_t partial_offset, + globus_off_t partial_end_offset, + globus_ftp_client_complete_callback_t complete_callback, + void * callback_arg); globus_result_t globus_ftp_client_partial_third_party_transfer( - globus_ftp_client_handle_t * handle, - const char * source_url, - globus_ftp_client_operationattr_t * source_attr, - const char * dest_url, - globus_ftp_client_operationattr_t * dest_attr, - globus_ftp_client_restart_marker_t * restart, - globus_off_t partial_offset, - globus_off_t partial_end_offset, - globus_ftp_client_complete_callback_t complete_callback, - void * callback_arg); + globus_ftp_client_handle_t * handle, + const char * source_url, + globus_ftp_client_operationattr_t * source_attr, + const char * dest_url, + globus_ftp_client_operationattr_t * dest_attr, + globus_ftp_client_restart_marker_t * restart, + globus_off_t partial_offset, + globus_off_t partial_end_offset, + globus_ftp_client_complete_callback_t complete_callback, + void * callback_arg); globus_result_t globus_ftp_client_extended_get( @@ -864,33 +864,33 @@ globus_ftp_client_extended_third_party_transfer( globus_result_t globus_ftp_client_abort( - globus_ftp_client_handle_t * handle); + globus_ftp_client_handle_t * handle); globus_result_t globus_ftp_client_modification_time( - globus_ftp_client_handle_t * handle, - const char * url, - globus_ftp_client_operationattr_t * attr, - globus_abstime_t * modification_time, - globus_ftp_client_complete_callback_t complete_callback, - void * callback_arg); + globus_ftp_client_handle_t * handle, + const char * url, + globus_ftp_client_operationattr_t * attr, + globus_abstime_t * modification_time, + globus_ftp_client_complete_callback_t complete_callback, + void * callback_arg); globus_result_t globus_ftp_client_size( - globus_ftp_client_handle_t * handle, - const char * url, - globus_ftp_client_operationattr_t * attr, - globus_off_t * size, - globus_ftp_client_complete_callback_t complete_callback, - void * callback_arg); + globus_ftp_client_handle_t * handle, + const char * url, + globus_ftp_client_operationattr_t * attr, + globus_off_t * size, + globus_ftp_client_complete_callback_t complete_callback, + void * callback_arg); globus_result_t globus_ftp_client_exists( - globus_ftp_client_handle_t * handle, - const char * url, - globus_ftp_client_operationattr_t * attr, - globus_ftp_client_complete_callback_t complete_callback, - void * callback_arg); + globus_ftp_client_handle_t * handle, + const char * url, + globus_ftp_client_operationattr_t * attr, + globus_ftp_client_complete_callback_t complete_callback, + void * callback_arg); #endif /** @@ -905,21 +905,21 @@ globus_ftp_client_exists( #ifndef DOXYGEN globus_result_t globus_ftp_client_operationattr_init( - globus_ftp_client_operationattr_t * attr); + globus_ftp_client_operationattr_t * attr); globus_result_t globus_ftp_client_operationattr_destroy( - globus_ftp_client_operationattr_t * attr); + globus_ftp_client_operationattr_t * attr); globus_result_t globus_ftp_client_operationattr_set_parallelism( - globus_ftp_client_operationattr_t * attr, - const globus_ftp_control_parallelism_t * parallelism); + globus_ftp_client_operationattr_t * attr, + const globus_ftp_control_parallelism_t * parallelism); globus_result_t globus_ftp_client_operationattr_get_parallelism( - const globus_ftp_client_operationattr_t * attr, - globus_ftp_control_parallelism_t * parallelism); + const globus_ftp_client_operationattr_t * attr, + globus_ftp_control_parallelism_t * parallelism); globus_result_t globus_ftp_client_operationattr_set_storage_module( @@ -967,202 +967,202 @@ globus_ftp_client_operationattr_get_authz_assert( globus_result_t globus_ftp_client_operationattr_set_striped( - globus_ftp_client_operationattr_t * attr, - globus_bool_t striped); + globus_ftp_client_operationattr_t * attr, + globus_bool_t striped); globus_result_t globus_ftp_client_operationattr_get_striped( - const globus_ftp_client_operationattr_t * attr, - globus_bool_t * striped); + const globus_ftp_client_operationattr_t * attr, + globus_bool_t * striped); globus_result_t globus_ftp_client_operationattr_set_layout( - globus_ftp_client_operationattr_t * attr, - const globus_ftp_control_layout_t * layout); + globus_ftp_client_operationattr_t * attr, + const globus_ftp_control_layout_t * layout); globus_result_t globus_ftp_client_operationattr_get_layout( - const globus_ftp_client_operationattr_t * attr, - globus_ftp_control_layout_t * layout); + const globus_ftp_client_operationattr_t * attr, + globus_ftp_control_layout_t * layout); globus_result_t globus_ftp_client_operationattr_set_tcp_buffer( - globus_ftp_client_operationattr_t * attr, - const globus_ftp_control_tcpbuffer_t * tcp_buffer); + globus_ftp_client_operationattr_t * attr, + const globus_ftp_control_tcpbuffer_t * tcp_buffer); globus_result_t globus_ftp_client_operationattr_get_tcp_buffer( - const globus_ftp_client_operationattr_t * attr, - globus_ftp_control_tcpbuffer_t * tcp_buffer); + const globus_ftp_client_operationattr_t * attr, + globus_ftp_control_tcpbuffer_t * tcp_buffer); globus_result_t globus_ftp_client_operationattr_set_type( - globus_ftp_client_operationattr_t * attr, - globus_ftp_control_type_t type); + globus_ftp_client_operationattr_t * attr, + globus_ftp_control_type_t type); globus_result_t globus_ftp_client_operationattr_get_type( - const globus_ftp_client_operationattr_t * attr, - globus_ftp_control_type_t * type); + const globus_ftp_client_operationattr_t * attr, + globus_ftp_control_type_t * type); globus_result_t globus_ftp_client_operationattr_set_mode( - globus_ftp_client_operationattr_t * attr, - globus_ftp_control_mode_t mode); + globus_ftp_client_operationattr_t * attr, + globus_ftp_control_mode_t mode); globus_result_t globus_ftp_client_operationattr_get_mode( - const globus_ftp_client_operationattr_t * attr, - globus_ftp_control_mode_t * mode); + const globus_ftp_client_operationattr_t * attr, + globus_ftp_control_mode_t * mode); globus_result_t globus_ftp_client_operationattr_set_list_uses_data_mode( - const globus_ftp_client_operationattr_t * attr, - globus_bool_t list_uses_data_mode); + const globus_ftp_client_operationattr_t * attr, + globus_bool_t list_uses_data_mode); globus_result_t globus_ftp_client_operationattr_get_list_uses_data_mode( - const globus_ftp_client_operationattr_t * attr, - globus_bool_t * list_uses_data_mode); + const globus_ftp_client_operationattr_t * attr, + globus_bool_t * list_uses_data_mode); globus_result_t globus_ftp_client_operationattr_set_delayed_pasv( - const globus_ftp_client_operationattr_t * attr, - globus_bool_t delayed_pasv); + const globus_ftp_client_operationattr_t * attr, + globus_bool_t delayed_pasv); globus_result_t globus_ftp_client_operationattr_get_delayed_pasv( - const globus_ftp_client_operationattr_t * attr, - globus_bool_t * delayed_pasv); + const globus_ftp_client_operationattr_t * attr, + globus_bool_t * delayed_pasv); globus_result_t globus_ftp_client_operationattr_set_dcau( - globus_ftp_client_operationattr_t * attr, - const globus_ftp_control_dcau_t * dcau); + globus_ftp_client_operationattr_t * attr, + const globus_ftp_control_dcau_t * dcau); globus_result_t globus_ftp_client_operationattr_get_dcau( - const globus_ftp_client_operationattr_t * attr, - globus_ftp_control_dcau_t * dcau); + const globus_ftp_client_operationattr_t * attr, + globus_ftp_control_dcau_t * dcau); globus_result_t globus_ftp_client_operationattr_set_data_protection( - globus_ftp_client_operationattr_t * attr, - globus_ftp_control_protection_t protection); + globus_ftp_client_operationattr_t * attr, + globus_ftp_control_protection_t protection); globus_result_t globus_ftp_client_operationattr_get_data_protection( - const globus_ftp_client_operationattr_t * attr, - globus_ftp_control_protection_t * protection); + const globus_ftp_client_operationattr_t * attr, + globus_ftp_control_protection_t * protection); globus_result_t globus_ftp_client_operationattr_set_control_protection( - globus_ftp_client_operationattr_t * attr, - globus_ftp_control_protection_t protection); + globus_ftp_client_operationattr_t * attr, + globus_ftp_control_protection_t protection); globus_result_t globus_ftp_client_operationattr_get_control_protection( - const globus_ftp_client_operationattr_t * attr, - globus_ftp_control_protection_t * protection); - + const globus_ftp_client_operationattr_t * attr, + globus_ftp_control_protection_t * protection); + globus_result_t globus_ftp_client_operationattr_set_data_security( - globus_ftp_client_operationattr_t * attr, + globus_ftp_client_operationattr_t * attr, int type, void * credential); globus_result_t globus_ftp_client_operationattr_get_data_security( - const globus_ftp_client_operationattr_t * attr, + const globus_ftp_client_operationattr_t * attr, int * type, void ** credential); globus_result_t globus_ftp_client_operationattr_set_resume_third_party_transfer( - globus_ftp_client_operationattr_t * attr, - globus_bool_t resume); + globus_ftp_client_operationattr_t * attr, + globus_bool_t resume); globus_result_t globus_ftp_client_operationattr_get_resume_third_party_transfer( - const globus_ftp_client_operationattr_t * attr, - globus_bool_t * resume); + const globus_ftp_client_operationattr_t * attr, + globus_bool_t * resume); globus_result_t globus_ftp_client_operationattr_set_authorization( - globus_ftp_client_operationattr_t * attr, - gss_cred_id_t credential, - const char * user, - const char * password, - const char * account, - const char * subject); + globus_ftp_client_operationattr_t * attr, + gss_cred_id_t credential, + const char * user, + const char * password, + const char * account, + const char * subject); globus_result_t globus_ftp_client_operationattr_get_authorization( - const globus_ftp_client_operationattr_t * attr, - gss_cred_id_t * credential, - char ** user, - char ** password, - char ** account, - char ** subject); + const globus_ftp_client_operationattr_t * attr, + gss_cred_id_t * credential, + char ** user, + char ** password, + char ** account, + char ** subject); globus_result_t globus_ftp_client_operationattr_set_append( - globus_ftp_client_operationattr_t * attr, - globus_bool_t append); + globus_ftp_client_operationattr_t * attr, + globus_bool_t append); globus_result_t globus_ftp_client_operationattr_get_append( - const globus_ftp_client_operationattr_t * attr, - globus_bool_t * append); + const globus_ftp_client_operationattr_t * attr, + globus_bool_t * append); globus_result_t globus_ftp_client_operationattr_set_read_all( - globus_ftp_client_operationattr_t * attr, - globus_bool_t read_all, - globus_ftp_client_data_callback_t intermediate_callbacks, - void * intermediate_callback_arg); + globus_ftp_client_operationattr_t * attr, + globus_bool_t read_all, + globus_ftp_client_data_callback_t intermediate_callbacks, + void * intermediate_callback_arg); globus_result_t globus_ftp_client_operationattr_get_read_all( - const globus_ftp_client_operationattr_t * attr, - globus_bool_t * read_all, - globus_ftp_client_data_callback_t * intermediate_callbacks, - void ** intermediate_callback_arg); + const globus_ftp_client_operationattr_t * attr, + globus_bool_t * read_all, + globus_ftp_client_data_callback_t * intermediate_callbacks, + void ** intermediate_callback_arg); globus_result_t globus_ftp_client_operationattr_set_allow_ipv6( - globus_ftp_client_operationattr_t * attr, - globus_bool_t allow); + globus_ftp_client_operationattr_t * attr, + globus_bool_t allow); globus_result_t globus_ftp_client_operationattr_get_allow_ipv6( - const globus_ftp_client_operationattr_t * attr, - globus_bool_t * allow); + const globus_ftp_client_operationattr_t * attr, + globus_bool_t * allow); globus_result_t globus_ftp_client_operationattr_set_allocate( - globus_ftp_client_operationattr_t * attr, - const globus_off_t allocated_size); - + globus_ftp_client_operationattr_t * attr, + const globus_off_t allocated_size); + globus_result_t globus_ftp_client_operationattr_get_allocate( - const globus_ftp_client_operationattr_t * attr, - globus_off_t * allocated_size); + const globus_ftp_client_operationattr_t * attr, + globus_off_t * allocated_size); globus_result_t globus_ftp_client_operationattr_copy( - globus_ftp_client_operationattr_t * dst, - const globus_ftp_client_operationattr_t * src); + globus_ftp_client_operationattr_t * dst, + const globus_ftp_client_operationattr_t * src); globus_result_t globus_ftp_client_operationattr_set_rfc1738_url( - globus_ftp_client_operationattr_t * attr, - globus_bool_t rfc1738_url); + globus_ftp_client_operationattr_t * attr, + globus_bool_t rfc1738_url); globus_result_t globus_ftp_client_operationattr_get_rfc1738_url( - const globus_ftp_client_operationattr_t * attr, - globus_bool_t * rfc1738_url); + const globus_ftp_client_operationattr_t * attr, + globus_bool_t * rfc1738_url); #endif /** @@ -1174,7 +1174,7 @@ globus_ftp_client_operationattr_get_rfc1738_url( * for reading or writing data to an FTP server. These operations are * globus_ftp_client_get(), globus_ftp_client_partial_get(), * globus_ftp_client_put(), globus_ftp_client_partial_put(), - * globus_ftp_client_list(), globus_ftp_client_machine_list(), + * globus_ftp_client_list(), globus_ftp_client_machine_list(), * globus_ftp_client_recursive_list(), and globus_ftp_client_verbose_list(). * * When doing these operations, the user must pass data buffers @@ -1190,21 +1190,21 @@ globus_ftp_client_operationattr_get_rfc1738_url( #ifndef DOXYGEN globus_result_t globus_ftp_client_register_read( - globus_ftp_client_handle_t * handle, - globus_byte_t * buffer, - globus_size_t buffer_length, - globus_ftp_client_data_callback_t callback, - void * callback_arg); + globus_ftp_client_handle_t * handle, + globus_byte_t * buffer, + globus_size_t buffer_length, + globus_ftp_client_data_callback_t callback, + void * callback_arg); globus_result_t globus_ftp_client_register_write( - globus_ftp_client_handle_t * handle, - globus_byte_t * buffer, - globus_size_t buffer_length, - globus_off_t offset, - globus_bool_t eof, - globus_ftp_client_data_callback_t callback, - void * callback_arg); + globus_ftp_client_handle_t * handle, + globus_byte_t * buffer, + globus_size_t buffer_length, + globus_off_t offset, + globus_bool_t eof, + globus_ftp_client_data_callback_t callback, + void * callback_arg); #endif /** @@ -1212,7 +1212,7 @@ globus_ftp_client_register_write( * @ingroup globus_ftp_client_operations * FALSE and TRUE are known to be fact that a feature does or does not exist * MAYBE means that the feature may exist - */ + */ typedef enum { GLOBUS_FTP_CLIENT_FALSE = GLOBUS_FALSE, @@ -1224,7 +1224,7 @@ globus_ftp_client_tristate_t; /** * Types of features * @ingroup globus_ftp_client_operations - */ + */ typedef enum { /* Buffer-size setting commands; keep these at the beginning of @@ -1239,7 +1239,7 @@ typedef enum GLOBUS_FTP_CLIENT_FEATURE_BUFSIZE, GLOBUS_FTP_CLIENT_FEATURE_SBUF, GLOBUS_FTP_CLIENT_FEATURE_ABUF, - + GLOBUS_FTP_CLIENT_FEATURE_REST_STREAM, GLOBUS_FTP_CLIENT_FEATURE_PARALLELISM, GLOBUS_FTP_CLIENT_FEATURE_DCAU, @@ -1278,7 +1278,7 @@ typedef struct globus_i_ftp_client_features_s * globus_ftp_client_features_t; globus_result_t globus_ftp_client_feat( - globus_ftp_client_handle_t * u_handle, + globus_ftp_client_handle_t * u_handle, char * url, globus_ftp_client_operationattr_t * attr, globus_ftp_client_features_t * u_features, @@ -1300,10 +1300,10 @@ globus_result_t globus_ftp_client_features_destroy( * returns the FTP response code for GLOBUS_ERROR_TYPE_FTP errors. * this function will search the entire chain for the correct type error and * return the code stored in that error. - * + * * @param error * an error object or chain with type GLOBUS_ERROR_TYPE_FTP - * + * * @return * the associated FTP response code if found, 0 otherwise. */ @@ -1313,7 +1313,7 @@ globus_error_ftp_error_get_code( #define GLOBUS_ERROR_TYPE_FTP (&GLOBUS_ERROR_TYPE_FTP_DEFINITION) extern const globus_object_type_t GLOBUS_ERROR_TYPE_FTP_DEFINITION; - + #endif EXTERN_C_END diff --git a/gridftp/client/source/globus_ftp_client_state.c b/gridftp/client/source/globus_ftp_client_state.c index f006707045..ae856ac0a2 100644 --- a/gridftp/client/source/globus_ftp_client_state.c +++ b/gridftp/client/source/globus_ftp_client_state.c @@ -23,8 +23,8 @@ #include "globus_i_ftp_client.h" -#include /* strstr(), strncmp() */ -#include /* isupper() */ +#include /* strstr(), strncmp() */ +#include /* isupper() */ #include #define CRLF "\r\n" @@ -33,77 +33,77 @@ static globus_object_t * globus_l_ftp_client_parse_site_help( - globus_i_ftp_client_target_t * target, - globus_ftp_control_response_t * response); + globus_i_ftp_client_target_t * target, + globus_ftp_control_response_t * response); static void globus_l_ftp_client_parse_feat( - globus_i_ftp_client_target_t * target, - globus_ftp_control_response_t * response); + globus_i_ftp_client_target_t * target, + globus_ftp_control_response_t * response); static void globus_l_ftp_client_parse_pasv( globus_ftp_control_handle_t * handle, - globus_ftp_control_response_t * response, - globus_ftp_control_host_port_t ** host_port, - int * num_pasv_addresses); + globus_ftp_control_response_t * response, + globus_ftp_control_host_port_t ** host_port, + int * num_pasv_addresses); static void globus_l_ftp_client_parse_restart_marker( - globus_i_ftp_client_handle_t * handle, - globus_ftp_control_response_t * response); + globus_i_ftp_client_handle_t * handle, + globus_ftp_control_response_t * response); static char * globus_l_ftp_client_parallelism_string( - globus_i_ftp_client_target_t * target); + globus_i_ftp_client_target_t * target); static char * globus_l_ftp_client_layout_string( - globus_i_ftp_client_target_t * target); + globus_i_ftp_client_target_t * target); static void globus_l_ftp_client_connection_error( - globus_i_ftp_client_handle_t * client_handle, - globus_i_ftp_client_target_t * target, - globus_object_t * error, - globus_ftp_control_response_t * response); + globus_i_ftp_client_handle_t * client_handle, + globus_i_ftp_client_target_t * target, + globus_object_t * error, + globus_ftp_control_response_t * response); static const char * globus_l_ftp_client_guess_buffer_command( - globus_i_ftp_client_handle_t * handle, - globus_i_ftp_client_target_t * target); + globus_i_ftp_client_handle_t * handle, + globus_i_ftp_client_target_t * target); static void globus_l_ftp_client_update_buffer_feature( - globus_i_ftp_client_handle_t * handle, - globus_i_ftp_client_target_t * target, - globus_ftp_client_tristate_t ok); + globus_i_ftp_client_handle_t * handle, + globus_i_ftp_client_target_t * target, + globus_ftp_client_tristate_t ok); static globus_bool_t globus_l_ftp_client_can_cache_data_connection( - globus_i_ftp_client_target_t * target); + globus_i_ftp_client_target_t * target); static void globus_l_ftp_client_data_force_close_callback( - void * callback_arg, - globus_ftp_control_handle_t * control_handle, - globus_object_t * error); + void * callback_arg, + globus_ftp_control_handle_t * control_handle, + globus_object_t * error); static void globus_l_ftp_client_parse_mdtm( - globus_i_ftp_client_handle_t * client_handle, - globus_ftp_control_response_t * response); + globus_i_ftp_client_handle_t * client_handle, + globus_ftp_control_response_t * response); static void @@ -114,20 +114,20 @@ globus_l_ftp_client_parse_cksm( static void globus_l_ftp_client_parse_mlst( - globus_i_ftp_client_handle_t * client_handle, - globus_ftp_control_response_t * response); + globus_i_ftp_client_handle_t * client_handle, + globus_ftp_control_response_t * response); static void globus_l_ftp_client_parse_cwd( - globus_i_ftp_client_handle_t * client_handle, - globus_ftp_control_response_t * response); + globus_i_ftp_client_handle_t * client_handle, + globus_ftp_control_response_t * response); static void globus_l_ftp_client_parse_stat( - globus_i_ftp_client_handle_t * client_handle, - globus_ftp_control_response_t * response); + globus_i_ftp_client_handle_t * client_handle, + globus_ftp_control_response_t * response); static globus_result_t @@ -164,27 +164,27 @@ globus_l_ftp_client_pp_xfer_src_add( static globus_result_t globus_l_ftp_client_use_gridftp2_getput( - globus_i_ftp_client_target_t * target, + globus_i_ftp_client_target_t * target, globus_bool_t * getput); static globus_result_t globus_l_ftp_client_send_get( - globus_i_ftp_client_target_t * target, + globus_i_ftp_client_target_t * target, char * pathname, globus_bool_t pasv); static globus_result_t globus_l_ftp_client_send_put( - globus_i_ftp_client_target_t * target, + globus_i_ftp_client_target_t * target, char * pathname, globus_bool_t pasv); /** * Buffer size command applicability information. * @internal - * + * * This structure is associated with each of the TCP buffer * setting commands to help the client library decide whether * a command is compatible with the operation being done. @@ -193,17 +193,17 @@ globus_l_ftp_client_send_put( * @see globus_l_ftp_client_buffer_cmd_info, * globus_l_ftp_client_guess_buffer_command() */ -typedef struct +typedef struct { /** * The command string. It should match the server's HELP response if * applicable. */ - char * string; + char * string; /** True if this command is usable for STOR */ - globus_bool_t stor_ok; + globus_bool_t stor_ok; /** True if this command is usable for RETR */ - globus_bool_t retr_ok; + globus_bool_t retr_ok; } globus_l_ftp_client_buffer_cmd_info_t; @@ -250,7 +250,7 @@ globus_l_ftp_client_buffer_cmd_info_t globus_l_ftp_client_buffer_cmd_info[] = * The control handle associated with this response. * @param error * A Globus error object or the value GLOBUS_SUCCESS if the - * response was received and parsed without error. + * response was received and parsed without error. * @param response * The parsed response string from the server. This is * interpreted based on the command currently being processed @@ -258,37 +258,37 @@ globus_l_ftp_client_buffer_cmd_info_t globus_l_ftp_client_buffer_cmd_info[] = */ void globus_i_ftp_client_response_callback( - void * user_arg, - globus_ftp_control_handle_t * handle, - globus_object_t * in_error, - globus_ftp_control_response_t * response) + void * user_arg, + globus_ftp_control_handle_t * handle, + globus_object_t * in_error, + globus_ftp_control_response_t * response) { - globus_i_ftp_client_target_t * target; + globus_i_ftp_client_target_t * target; globus_object_t * error; - globus_i_ftp_client_handle_t * client_handle; - globus_result_t result; - globus_bool_t registered=GLOBUS_FALSE; - char * tmpstr = GLOBUS_NULL; - char * argstr = GLOBUS_NULL; - const char * buffer_cmd = GLOBUS_NULL; - char * parallelism_opt = GLOBUS_NULL; - char * layout_opt = GLOBUS_NULL; - char * list_str = GLOBUS_NULL; - unsigned long pbsz = 0; - int rc, oldrc, i; + globus_i_ftp_client_handle_t * client_handle; + globus_result_t result; + globus_bool_t registered=GLOBUS_FALSE; + char * tmpstr = GLOBUS_NULL; + char * argstr = GLOBUS_NULL; + const char * buffer_cmd = GLOBUS_NULL; + char * parallelism_opt = GLOBUS_NULL; + char * layout_opt = GLOBUS_NULL; + char * list_str = GLOBUS_NULL; + unsigned long pbsz = 0; + int rc, oldrc, i; char * pathname; - globus_bool_t gridftp2_getput; + globus_bool_t gridftp2_getput; GlobusFuncName(globus_i_ftp_client_response_callback); - + target = (globus_i_ftp_client_target_t *) user_arg; client_handle = target->owner; - - globus_i_ftp_client_debug_printf(1, (stderr, + + globus_i_ftp_client_debug_printf(1, (stderr, "globus_i_ftp_client_response_callback() entering\n")); globus_i_ftp_client_debug_states(2, client_handle); globus_assert(! GLOBUS_I_FTP_CLIENT_BAD_MAGIC(&client_handle)); - + if(in_error) { error = globus_object_copy(in_error); @@ -297,16 +297,16 @@ globus_i_ftp_client_response_callback( { error = GLOBUS_NULL; } - + globus_i_ftp_client_handle_lock(client_handle); - - - + + + if(response && (response->code == 125 || response->code == 150) && client_handle->attr.pipeline_callback) - { + { globus_i_ftp_client_url_ent_t * url_ent = NULL; - + if(target == client_handle->source) { if(!globus_fifo_empty(&client_handle->src_response_pending_queue)) @@ -341,10 +341,10 @@ globus_i_ftp_client_response_callback( client_handle->dest_url = globus_libc_strdup(url_ent->dest_url); } } - } - - - + } + + + if(response) { globus_i_ftp_client_plugin_notify_response( @@ -358,8 +358,8 @@ globus_i_ftp_client_response_callback( if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART) { - goto finish; - } + goto finish; + } /* The behaviour of several states depends on whether to use the * GFD.47 (a.k.a GridFTP 2) GETPUT extension. @@ -373,579 +373,163 @@ globus_i_ftp_client_response_callback( /* This redo is used to make a second run through the state * machine, which a few states will require. */ - + pathname = target->url.url_path ? target->url.url_path : "/"; - + redo: switch(target->state) { case GLOBUS_FTP_CLIENT_TARGET_CONNECT: - globus_assert( - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_SOURCE_CONNECT || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_DEST_CONNECT); - - if((!error) && - response->response_class == GLOBUS_FTP_POSITIVE_COMPLETION_REPLY) - { - /* Successfully connected. Begin authentication */ - target->state = GLOBUS_FTP_CLIENT_TARGET_AUTHENTICATE; - - globus_i_ftp_client_plugin_notify_authenticate( - client_handle, - target->url_string, - &target->auth_info); - - if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) - { - break; - } - - globus_assert( - client_handle->state==GLOBUS_FTP_CLIENT_HANDLE_SOURCE_CONNECT - || - client_handle->state==GLOBUS_FTP_CLIENT_HANDLE_DEST_CONNECT); - - result = - globus_ftp_control_authenticate( - handle, - &target->attr->auth_info, - target->url.scheme_type==GLOBUS_URL_SCHEME_GSIFTP, - globus_i_ftp_client_response_callback, - user_arg); - - if(result != GLOBUS_SUCCESS) - { - /* - * If authentication fails without registration, notify the - * plugins, then deal with the fault. - */ - goto result_fault; - - } - } - else if(error || response->response_class - != GLOBUS_FTP_POSITIVE_PRELIMINARY_REPLY) - { - /* Connection failed, deal with it (connect_error - * unlocks the handle) - */ - if(!error && response && response->response_buffer) - { - error = GLOBUS_I_FTP_CLIENT_ERROR_RESPONSE(response); - } - goto notify_fault; - } - /* Else, (success + 1yz response), which just means: server will - * get to you in a moment) - */ - break; - case GLOBUS_FTP_CLIENT_TARGET_AUTHENTICATE: - globus_assert( - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_SOURCE_CONNECT || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_DEST_CONNECT); - - if((!error) && - response->response_class == GLOBUS_FTP_POSITIVE_COMPLETION_REPLY) - { -# if BUILD_DEBUG - { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_SITE_FAULT; - } -# else - { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_SITE_HELP; - } -# endif - goto redo; - } - else - { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; - - goto notify_fault; - } - break; -# if BUILD_DEBUG - case GLOBUS_FTP_CLIENT_TARGET_SETUP_SITE_FAULT: - globus_assert( - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_SOURCE_CONNECT || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_DEST_CONNECT); - - target->state = GLOBUS_FTP_CLIENT_TARGET_SITE_FAULT; - target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_INFORMATION; - - tmpstr = getenv("GLOBUS_FTP_CLIENT_FAULT_MODE"); - - if(! tmpstr) - { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_SITE_HELP; - - goto redo; - } - - globus_i_ftp_client_plugin_notify_command( - client_handle, - target->url_string, - target->mask, - "SITE FAULT %s" CRLF, - tmpstr); - - if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) - { - break; - } - - globus_assert( - client_handle->state==GLOBUS_FTP_CLIENT_HANDLE_SOURCE_CONNECT - || - client_handle->state==GLOBUS_FTP_CLIENT_HANDLE_DEST_CONNECT); - - result = - globus_ftp_control_send_command( - handle, - "SITE FAULT %s" CRLF, - globus_i_ftp_client_response_callback, - user_arg, - tmpstr); - - globus_libc_unsetenv("GLOBUS_FTP_CLIENT_FAULT_MODE"); - - if(result != GLOBUS_SUCCESS) - { - goto result_fault; - } - break; + globus_assert( + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_SOURCE_CONNECT || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_DEST_CONNECT); - case GLOBUS_FTP_CLIENT_TARGET_SITE_FAULT: - globus_assert( - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_SOURCE_CONNECT || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_DEST_CONNECT); - - if((!error) && - response->response_class == GLOBUS_FTP_POSITIVE_COMPLETION_REPLY) - { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_SITE_HELP; - goto redo; - } - else - { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; - - goto notify_fault; - } - break; + if((!error) && + response->response_class == GLOBUS_FTP_POSITIVE_COMPLETION_REPLY) + { + /* Successfully connected. Begin authentication */ + target->state = GLOBUS_FTP_CLIENT_TARGET_AUTHENTICATE; -# endif - case GLOBUS_FTP_CLIENT_TARGET_SETUP_SITE_HELP: - globus_assert( - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_SOURCE_CONNECT || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_DEST_CONNECT); + globus_i_ftp_client_plugin_notify_authenticate( + client_handle, + target->url_string, + &target->auth_info); - target->state = GLOBUS_FTP_CLIENT_TARGET_SITE_HELP; - target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_INFORMATION; - - target->features = globus_i_ftp_client_features_init(); - if(!target->features) - { - error = GLOBUS_I_FTP_CLIENT_ERROR_OUT_OF_MEMORY(); - goto notify_fault; - } - - globus_i_ftp_client_plugin_notify_command( - client_handle, - target->url_string, - target->mask, - "SITE HELP" CRLF); - - if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) - { - break; - } - - globus_assert( - client_handle->state==GLOBUS_FTP_CLIENT_HANDLE_SOURCE_CONNECT - || - client_handle->state==GLOBUS_FTP_CLIENT_HANDLE_DEST_CONNECT); - - result = - globus_ftp_control_send_command( - handle, - "SITE HELP" CRLF, - globus_i_ftp_client_response_callback, - user_arg); - - if(result != GLOBUS_SUCCESS) - { - goto result_fault; - } - break; - case GLOBUS_FTP_CLIENT_TARGET_SITE_HELP: - globus_assert( - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_SOURCE_CONNECT || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_DEST_CONNECT); - - if(error != GLOBUS_SUCCESS) - { - goto notify_fault; - } - else if(response->response_class==GLOBUS_FTP_POSITIVE_COMPLETION_REPLY) - { - /* - * Parse the reply to find out what is implemented by this - * server - */ - error = globus_l_ftp_client_parse_site_help(target, response); - if(error != GLOBUS_SUCCESS) + if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) { - goto notify_fault; + break; } - } - - target->state = GLOBUS_FTP_CLIENT_TARGET_FEAT; - target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_INFORMATION; - - globus_i_ftp_client_plugin_notify_command( - client_handle, - target->url_string, - target->mask, - "FEAT" CRLF); - - if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) - { - break; - } - globus_assert( - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_SOURCE_CONNECT || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_DEST_CONNECT); - - result = - globus_ftp_control_send_command( - handle, - "FEAT" CRLF, - globus_i_ftp_client_response_callback, - user_arg); - if(result != GLOBUS_SUCCESS) - { - goto result_fault; - } - break; - case GLOBUS_FTP_CLIENT_TARGET_FEAT: - globus_assert( - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_SOURCE_CONNECT || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_DEST_CONNECT); - - if(error != GLOBUS_SUCCESS) - { - goto notify_fault; - } - if(response->response_class == GLOBUS_FTP_POSITIVE_COMPLETION_REPLY) - { - /* - * Parse the reply to find out what is implemented by this - * server - */ - globus_l_ftp_client_parse_feat(target, response); - } - - globus_i_ftp_client_feature_set( - target->features, - GLOBUS_FTP_CLIENT_FEATURE_CLIENTINFO, - GLOBUS_FTP_CLIENT_MAYBE); - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CLIENTINFO; - if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_SOURCE_CONNECT) - { - client_handle->state = - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION; - } - else - { - client_handle->state = - GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION; - } - goto redo; - - case GLOBUS_FTP_CLIENT_TARGET_SETUP_CLIENTINFO: - target->state = GLOBUS_FTP_CLIENT_TARGET_CLIENTINFO; + globus_assert( + client_handle->state==GLOBUS_FTP_CLIENT_HANDLE_SOURCE_CONNECT + || + client_handle->state==GLOBUS_FTP_CLIENT_HANDLE_DEST_CONNECT); - if(globus_i_ftp_client_feature_get( - target->features, - GLOBUS_FTP_CLIENT_FEATURE_CLIENTINFO) == GLOBUS_FALSE) - { - goto skip_clientinfo; - } + result = + globus_ftp_control_authenticate( + handle, + &target->attr->auth_info, + target->url.scheme_type==GLOBUS_URL_SCHEME_GSIFTP, + globus_i_ftp_client_response_callback, + user_arg); - target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_INFORMATION; - - argstr = globus_common_create_string("scheme=%s;", target->url.scheme); - if(client_handle->attr.clientinfo_app_name) - { - tmpstr = globus_common_create_string( - "%sappname=\"%s\";", argstr, client_handle->attr.clientinfo_app_name); - globus_free(argstr); - argstr = tmpstr; - } - if(client_handle->attr.clientinfo_app_ver) - { - tmpstr = globus_common_create_string( - "%sappver=\"%s\";", argstr, client_handle->attr.clientinfo_app_ver); - globus_free(argstr); - argstr = tmpstr; + if(result != GLOBUS_SUCCESS) + { + /* + * If authentication fails without registration, notify the + * plugins, then deal with the fault. + */ + goto result_fault; + + } } - if(client_handle->attr.clientinfo_other) + else if(error || response->response_class + != GLOBUS_FTP_POSITIVE_PRELIMINARY_REPLY) { - tmpstr = globus_common_create_string( - "%s%s", argstr, client_handle->attr.clientinfo_other); - globus_free(argstr); - argstr = tmpstr; + /* Connection failed, deal with it (connect_error + * unlocks the handle) + */ + if(!error && response && response->response_buffer) + { + error = GLOBUS_I_FTP_CLIENT_ERROR_RESPONSE(response); + } + goto notify_fault; } + /* Else, (success + 1yz response), which just means: server will + * get to you in a moment) + */ + break; + case GLOBUS_FTP_CLIENT_TARGET_AUTHENTICATE: + globus_assert( + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_SOURCE_CONNECT || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_DEST_CONNECT); - if(target->attr->clientinfo_argstr) + if((!error) && + response->response_class == GLOBUS_FTP_POSITIVE_COMPLETION_REPLY) { - globus_free(target->attr->clientinfo_argstr); - } - target->attr->clientinfo_argstr = argstr; - - if(target->clientinfo_argstr && - strcmp(target->clientinfo_argstr, - target->attr->clientinfo_argstr) == 0) - { - goto skip_clientinfo; - } - - globus_i_ftp_client_plugin_notify_command( - client_handle, - target->url_string, - target->mask, - "SITE CLIENTINFO %s", - target->attr->clientinfo_argstr); - - if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) - { - break; - } - globus_assert( - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION - || - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); - - result = globus_ftp_control_send_command( - target->control_handle, - "SITE CLIENTINFO %s" CRLF, - globus_i_ftp_client_response_callback, - target, - target->attr->clientinfo_argstr); - - if(result != GLOBUS_SUCCESS) - { - goto result_fault; - } - - break; - - case GLOBUS_FTP_CLIENT_TARGET_CLIENTINFO: - globus_assert( - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); - - if((!error) && - response->response_class == GLOBUS_FTP_POSITIVE_COMPLETION_REPLY) - { - if(target->clientinfo_argstr) - { - globus_free(target->clientinfo_argstr); - } - target->clientinfo_argstr = - globus_libc_strdup(target->attr->clientinfo_argstr); - } - else if (response) - { - globus_i_ftp_client_feature_set( - target->features, - GLOBUS_FTP_CLIENT_FEATURE_CLIENTINFO, - GLOBUS_FTP_CLIENT_FALSE); - response->response_class = GLOBUS_FTP_POSITIVE_COMPLETION_REPLY; - globus_object_free(error); - error = NULL; +# if BUILD_DEBUG + { + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_SITE_FAULT; + } +# else + { + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_SITE_HELP; + } +# endif + goto redo; } else { - goto notify_fault; - } + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; - skip_clientinfo: - if (client_handle->op == GLOBUS_FTP_CLIENT_FEAT) - { - target->state = GLOBUS_FTP_CLIENT_TARGET_NEED_COMPLETE; - } - else - { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_TYPE; + goto notify_fault; } - goto redo; - - case GLOBUS_FTP_CLIENT_TARGET_SETUP_TYPE: - target->state = GLOBUS_FTP_CLIENT_TARGET_TYPE; - - if(target->attr->type == target->type) - { - goto skip_type; - } - - target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_TRANSFER_PARAMETERS; - - globus_i_ftp_client_plugin_notify_command( - client_handle, - target->url_string, - target->mask, - "TYPE %c", - (char) target->attr->type); - - if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) - { - break; - } - globus_assert( - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION - || - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); - - result = globus_ftp_control_send_command( - target->control_handle, - "TYPE %c" CRLF, - globus_i_ftp_client_response_callback, - target, - (char) target->attr->type); - - if(result != GLOBUS_SUCCESS) - { - goto result_fault; - } - - break; - - case GLOBUS_FTP_CLIENT_TARGET_TYPE: - globus_assert( - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); - - if((!error) && - response->response_class == GLOBUS_FTP_POSITIVE_COMPLETION_REPLY) - { - target->type = target->attr->type; - result = globus_ftp_control_local_type(target->control_handle, - target->type, - 8); - if(result != GLOBUS_SUCCESS) - { - goto result_fault; - } - } - else - { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; - - goto notify_fault; - } + break; +# if BUILD_DEBUG + case GLOBUS_FTP_CLIENT_TARGET_SETUP_SITE_FAULT: + globus_assert( + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_SOURCE_CONNECT || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_DEST_CONNECT); - skip_type: - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_AUTHZ_ASSERT; - goto redo; + target->state = GLOBUS_FTP_CLIENT_TARGET_SITE_FAULT; + target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_INFORMATION; - case GLOBUS_FTP_CLIENT_TARGET_SETUP_AUTHZ_ASSERT: - target->state = GLOBUS_FTP_CLIENT_TARGET_AUTHZ_ASSERT; + tmpstr = getenv("GLOBUS_FTP_CLIENT_FAULT_MODE"); - if (!target->attr->authz_assert) - { - goto skip_authz_assert; - } - if(target->authz_assert && - !strcmp(target->attr->authz_assert, target->authz_assert) && - target->attr->cache_authz_assert) + if(! tmpstr) { - goto skip_authz_assert; - } + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_SITE_HELP; - target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_MISC; + goto redo; + } globus_i_ftp_client_plugin_notify_command( client_handle, target->url_string, target->mask, - "SITE AUTHZ_ASSERT %s", - target->attr->authz_assert); - - if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || + "SITE FAULT %s" CRLF, + tmpstr); + + if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) - { + { break; } + globus_assert( - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION + client_handle->state==GLOBUS_FTP_CLIENT_HANDLE_SOURCE_CONNECT || - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); - - result = globus_ftp_control_send_command( - target->control_handle, - "SITE AUTHZ_ASSERT %s" CRLF, - globus_i_ftp_client_response_callback, - target, - target->attr->authz_assert); - + client_handle->state==GLOBUS_FTP_CLIENT_HANDLE_DEST_CONNECT); + + result = + globus_ftp_control_send_command( + handle, + "SITE FAULT %s" CRLF, + globus_i_ftp_client_response_callback, + user_arg, + tmpstr); + + globus_libc_unsetenv("GLOBUS_FTP_CLIENT_FAULT_MODE"); + if(result != GLOBUS_SUCCESS) - { + { goto result_fault; } - break; - case GLOBUS_FTP_CLIENT_TARGET_AUTHZ_ASSERT: + case GLOBUS_FTP_CLIENT_TARGET_SITE_FAULT: globus_assert( - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_SOURCE_CONNECT || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_DEST_CONNECT); if((!error) && response->response_class == GLOBUS_FTP_POSITIVE_COMPLETION_REPLY) { - if (target->authz_assert) - { - if (strcmp(target->authz_assert, target->attr->authz_assert)) - { - globus_free(target->authz_assert); - target->authz_assert = globus_libc_strdup( - target->attr->authz_assert); - } - } - else - { - target->authz_assert = - globus_libc_strdup(target->attr->authz_assert); - } + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_SITE_HELP; + goto redo; } else { @@ -953,32 +537,29 @@ globus_i_ftp_client_response_callback( goto notify_fault; } + break; - skip_authz_assert: - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_SETNETSTACK; - goto redo; +# endif + case GLOBUS_FTP_CLIENT_TARGET_SETUP_SITE_HELP: + globus_assert( + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_SOURCE_CONNECT || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_DEST_CONNECT); + target->state = GLOBUS_FTP_CLIENT_TARGET_SITE_HELP; + target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_INFORMATION; - case GLOBUS_FTP_CLIENT_TARGET_SETUP_SETNETSTACK: - target->state = GLOBUS_FTP_CLIENT_TARGET_SETNETSTACK; - if(target->attr->net_stack_str == NULL || - (target->net_stack_str != NULL && - strcmp(target->attr->net_stack_str, target->net_stack_str) == 0)) + target->features = globus_i_ftp_client_features_init(); + if(!target->features) { - goto skip_setnetstack; + error = GLOBUS_I_FTP_CLIENT_ERROR_OUT_OF_MEMORY(); + goto notify_fault; } - - memset(&target->cached_data_conn, - '\0', - sizeof(globus_i_ftp_client_data_target_t)); - target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_TRANSFER_PARAMETERS; globus_i_ftp_client_plugin_notify_command( client_handle, target->url_string, target->mask, - "SITE SETNETSTACK %s" CRLF, - target->attr->net_stack_str); + "SITE HELP" CRLF); if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || @@ -988,112 +569,164 @@ globus_i_ftp_client_response_callback( } globus_assert( - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); + client_handle->state==GLOBUS_FTP_CLIENT_HANDLE_SOURCE_CONNECT + || + client_handle->state==GLOBUS_FTP_CLIENT_HANDLE_DEST_CONNECT); + + result = + globus_ftp_control_send_command( + handle, + "SITE HELP" CRLF, + globus_i_ftp_client_response_callback, + user_arg); - result = globus_ftp_control_send_command( - target->control_handle, - "SITE SETNETSTACK %s" CRLF, - globus_i_ftp_client_response_callback, - target, - target->attr->net_stack_str); if(result != GLOBUS_SUCCESS) { goto result_fault; } - break; - - case GLOBUS_FTP_CLIENT_TARGET_SETNETSTACK: + case GLOBUS_FTP_CLIENT_TARGET_SITE_HELP: globus_assert( - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_SOURCE_CONNECT || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_DEST_CONNECT); - if((!error) && - response->response_class == GLOBUS_FTP_POSITIVE_COMPLETION_REPLY) + if(error != GLOBUS_SUCCESS) { - globus_xio_stack_t stack; - - if(target->net_stack_str) + goto notify_fault; + } + else if(response->response_class==GLOBUS_FTP_POSITIVE_COMPLETION_REPLY) + { + /* + * Parse the reply to find out what is implemented by this + * server + */ + error = globus_l_ftp_client_parse_site_help(target, response); + if(error != GLOBUS_SUCCESS) { - globus_free(target->net_stack_str); + goto notify_fault; } - target->net_stack_str = - globus_libc_strdup(target->attr->net_stack_str); - - if(client_handle->op != GLOBUS_FTP_CLIENT_TRANSFER) - { - if(target->net_stack_list) - { - globus_i_ftp_control_unload_xio_drivers( - target->net_stack_list); - target->net_stack_list = GLOBUS_NULL; - } - - result = globus_i_ftp_control_load_xio_drivers( - target->net_stack_str, &target->net_stack_list); - if(result != GLOBUS_SUCCESS) - { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; - - goto result_fault; - } - result = globus_i_ftp_control_create_stack( - target->control_handle, target->net_stack_list, &stack); - if(result != GLOBUS_SUCCESS) - { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; - - goto result_fault; - } - - result = globus_i_ftp_control_data_set_stack( - target->control_handle, stack); - if(result != GLOBUS_SUCCESS) - { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; - - goto result_fault; - } - globus_xio_stack_destroy(stack); - } } - else + + target->state = GLOBUS_FTP_CLIENT_TARGET_FEAT; + target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_INFORMATION; + + globus_i_ftp_client_plugin_notify_command( + client_handle, + target->url_string, + target->mask, + "FEAT" CRLF); + + if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; + break; + } + globus_assert( + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_SOURCE_CONNECT || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_DEST_CONNECT); + + result = + globus_ftp_control_send_command( + handle, + "FEAT" CRLF, + globus_i_ftp_client_response_callback, + user_arg); + if(result != GLOBUS_SUCCESS) + { + goto result_fault; + } + break; + case GLOBUS_FTP_CLIENT_TARGET_FEAT: + globus_assert( + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_SOURCE_CONNECT || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_DEST_CONNECT); + if(error != GLOBUS_SUCCESS) + { goto notify_fault; } + if(response->response_class == GLOBUS_FTP_POSITIVE_COMPLETION_REPLY) + { + /* + * Parse the reply to find out what is implemented by this + * server + */ + globus_l_ftp_client_parse_feat(target, response); + } - skip_setnetstack: - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_SETDISKSTACK; + globus_i_ftp_client_feature_set( + target->features, + GLOBUS_FTP_CLIENT_FEATURE_CLIENTINFO, + GLOBUS_FTP_CLIENT_MAYBE); + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CLIENTINFO; + + if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_SOURCE_CONNECT) + { + client_handle->state = + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION; + } + else + { + client_handle->state = + GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION; + } goto redo; + case GLOBUS_FTP_CLIENT_TARGET_SETUP_CLIENTINFO: + target->state = GLOBUS_FTP_CLIENT_TARGET_CLIENTINFO; - case GLOBUS_FTP_CLIENT_TARGET_SETUP_SETDISKSTACK: - target->state = GLOBUS_FTP_CLIENT_TARGET_SETDISKSTACK; - if(target->attr->disk_stack_str == NULL || - (target->disk_stack_str != NULL && - strcmp(target->attr->disk_stack_str, target->disk_stack_str) == 0)) + if(globus_i_ftp_client_feature_get( + target->features, + GLOBUS_FTP_CLIENT_FEATURE_CLIENTINFO) == GLOBUS_FALSE) { - goto skip_setdiskstack; + goto skip_clientinfo; + } + + target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_INFORMATION; + + argstr = globus_common_create_string("scheme=%s;", target->url.scheme); + if(client_handle->attr.clientinfo_app_name) + { + tmpstr = globus_common_create_string( + "%sappname=\"%s\";", argstr, client_handle->attr.clientinfo_app_name); + globus_free(argstr); + argstr = tmpstr; + } + if(client_handle->attr.clientinfo_app_ver) + { + tmpstr = globus_common_create_string( + "%sappver=\"%s\";", argstr, client_handle->attr.clientinfo_app_ver); + globus_free(argstr); + argstr = tmpstr; + } + if(client_handle->attr.clientinfo_other) + { + tmpstr = globus_common_create_string( + "%s%s", argstr, client_handle->attr.clientinfo_other); + globus_free(argstr); + argstr = tmpstr; + } + + if(target->attr->clientinfo_argstr) + { + globus_free(target->attr->clientinfo_argstr); + } + target->attr->clientinfo_argstr = argstr; + + if(target->clientinfo_argstr && + strcmp(target->clientinfo_argstr, + target->attr->clientinfo_argstr) == 0) + { + goto skip_clientinfo; } - - memset(&target->cached_data_conn, - '\0', - sizeof(globus_i_ftp_client_data_target_t)); - target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_TRANSFER_PARAMETERS; globus_i_ftp_client_plugin_notify_command( client_handle, target->url_string, target->mask, - "SITE SETDISKSTACK %s" CRLF, - target->attr->disk_stack_str); + "SITE CLIENTINFO %s", + target->attr->clientinfo_argstr); if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || @@ -1101,19 +734,20 @@ globus_i_ftp_client_response_callback( { break; } - globus_assert( client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION + || client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); result = globus_ftp_control_send_command( target->control_handle, - "SITE SETDISKSTACK %s" CRLF, + "SITE CLIENTINFO %s" CRLF, globus_i_ftp_client_response_callback, target, - target->attr->disk_stack_str); + target->attr->clientinfo_argstr); + if(result != GLOBUS_SUCCESS) { goto result_fault; @@ -1121,7 +755,7 @@ globus_i_ftp_client_response_callback( break; - case GLOBUS_FTP_CLIENT_TARGET_SETDISKSTACK: + case GLOBUS_FTP_CLIENT_TARGET_CLIENTINFO: globus_assert( client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || @@ -1131,712 +765,1078 @@ globus_i_ftp_client_response_callback( if((!error) && response->response_class == GLOBUS_FTP_POSITIVE_COMPLETION_REPLY) { - if(target->disk_stack_str) + if(target->clientinfo_argstr) { - globus_free(target->disk_stack_str); + globus_free(target->clientinfo_argstr); } - target->disk_stack_str = - globus_libc_strdup(target->attr->disk_stack_str); + target->clientinfo_argstr = + globus_libc_strdup(target->attr->clientinfo_argstr); + } + else if (response) + { + globus_i_ftp_client_feature_set( + target->features, + GLOBUS_FTP_CLIENT_FEATURE_CLIENTINFO, + GLOBUS_FTP_CLIENT_FALSE); + response->response_class = GLOBUS_FTP_POSITIVE_COMPLETION_REPLY; + globus_object_free(error); + error = NULL; } else { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; - goto notify_fault; } - skip_setdiskstack: - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_MODE; + skip_clientinfo: + if (client_handle->op == GLOBUS_FTP_CLIENT_FEAT) + { + target->state = GLOBUS_FTP_CLIENT_TARGET_NEED_COMPLETE; + } + else + { + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_TYPE; + } goto redo; + case GLOBUS_FTP_CLIENT_TARGET_SETUP_TYPE: + target->state = GLOBUS_FTP_CLIENT_TARGET_TYPE; - case GLOBUS_FTP_CLIENT_TARGET_SETUP_MODE: - target->state = GLOBUS_FTP_CLIENT_TARGET_MODE; - if(target->attr->mode == target->mode) - { - goto skip_mode; - } - memset(&target->cached_data_conn, - '\0', - sizeof(globus_i_ftp_client_data_target_t)); - - target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_TRANSFER_PARAMETERS; - globus_i_ftp_client_plugin_notify_command( - client_handle, - target->url_string, - target->mask, - "MODE %c" CRLF, - (char) target->attr->mode); - - if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) - { - break; - } - - globus_assert( - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); - - result = globus_ftp_control_send_command( - target->control_handle, - "MODE %c" CRLF, - globus_i_ftp_client_response_callback, - target, - (char) target->attr->mode); - - if(result != GLOBUS_SUCCESS) - { - goto result_fault; - } - - break; - - case GLOBUS_FTP_CLIENT_TARGET_MODE: - globus_assert( - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); - - if((!error) && - response->response_class == GLOBUS_FTP_POSITIVE_COMPLETION_REPLY) - { - target->mode = target->attr->mode; - - /* disable source pasv */ - if(target->mode == GLOBUS_FTP_CONTROL_MODE_EXTENDED_BLOCK) - { - client_handle->source_pasv = GLOBUS_FALSE; - } - - result = globus_ftp_control_local_mode(target->control_handle, - target->mode); - if(result != GLOBUS_SUCCESS) - { - goto result_fault; - } - } - else - { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; - - goto notify_fault; - } - - skip_mode: - if(client_handle->op == GLOBUS_FTP_CLIENT_CKSM) - { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CKSM; - } - else - { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_SIZE; - } - goto redo; - - case GLOBUS_FTP_CLIENT_TARGET_SETUP_CKSM: - + if(target->attr->type == target->type) + { + goto skip_type; + } - target->state = GLOBUS_FTP_CLIENT_TARGET_NEED_COMPLETE; - - target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_INFORMATION; + target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_TRANSFER_PARAMETERS; - globus_i_ftp_client_plugin_notify_command( + globus_i_ftp_client_plugin_notify_command( client_handle, target->url_string, - target->mask, - "CKSM %s %" GLOBUS_OFF_T_FORMAT " %" GLOBUS_OFF_T_FORMAT " %s" CRLF, - client_handle->checksum_alg, - client_handle->checksum_offset, - client_handle->checksum_length, - pathname); + target->mask, + "TYPE %c", + (char) target->attr->type); - if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || + if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) { break; } - - globus_assert(client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); + globus_assert( + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION + || + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); result = globus_ftp_control_send_command( target->control_handle, - "CKSM %s %" GLOBUS_OFF_T_FORMAT " %" GLOBUS_OFF_T_FORMAT " %s" CRLF, + "TYPE %c" CRLF, globus_i_ftp_client_response_callback, target, - client_handle->checksum_alg, - client_handle->checksum_offset, - client_handle->checksum_length, - pathname); + (char) target->attr->type); if(result != GLOBUS_SUCCESS) { goto result_fault; } - break; - - case GLOBUS_FTP_CLIENT_TARGET_SETUP_SIZE: - /* - * Doing a SIZE isn't necessary but is nice for - * - resuming stream mode 3rd party transfers - * - * Skip if - * - server doesn't do SIZE - * - not interesting - * where interesting is - * - destination of stream mode 3rd party transfer w/ resume - * attr set to true - */ - if(globus_i_ftp_client_feature_get( - target->features, - GLOBUS_FTP_CLIENT_FEATURE_SIZE) == GLOBUS_FALSE - || - (! - ( - (client_handle->op == GLOBUS_FTP_CLIENT_TRANSFER && - target == client_handle->dest && - target->attr->resume_third_party && - target->mode == GLOBUS_FTP_CONTROL_MODE_STREAM) - || - (client_handle->op == GLOBUS_FTP_CLIENT_SIZE) - ) - ) - ) - { - if(client_handle->op == GLOBUS_FTP_CLIENT_SIZE) - { - error = GLOBUS_I_FTP_CLIENT_ERROR_UNSUPPORTED_FEATURE("SIZE"); - - goto notify_fault; - - } - goto skip_size; - } - - if(client_handle->op == GLOBUS_FTP_CLIENT_SIZE) - { - target->state = GLOBUS_FTP_CLIENT_TARGET_NEED_COMPLETE; - } - else - { - target->state = GLOBUS_FTP_CLIENT_TARGET_SIZE; - } - - target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_INFORMATION; - - globus_i_ftp_client_plugin_notify_command( - client_handle, - target->url_string, - target->mask, - "SIZE %s" CRLF, - pathname); - - if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) - { - break; - } - - globus_assert(client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); - - result = globus_ftp_control_send_command( - target->control_handle, - "SIZE %s" CRLF, - globus_i_ftp_client_response_callback, - target, - pathname); - - if(result != GLOBUS_SUCCESS) - { - goto result_fault; - } - break; - - case GLOBUS_FTP_CLIENT_TARGET_SIZE: - globus_assert( - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION - || - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); - - if(error != GLOBUS_SUCCESS) - { - goto notify_fault; - } - if(response->response_class == GLOBUS_FTP_POSITIVE_COMPLETION_REPLY) - { - globus_i_ftp_client_feature_set( - target->features, - GLOBUS_FTP_CLIENT_FEATURE_SIZE, - GLOBUS_FTP_CLIENT_TRUE); - - if(client_handle->source == target) - { - globus_libc_scan_off_t((char *) response->response_buffer+4, - &client_handle->source_size, - GLOBUS_NULL); - } - else - { - globus_byte_t * size; - const globus_byte_t * p; - globus_byte_t *q; - - size = globus_libc_malloc( - strlen((char *) response->response_buffer+3)); - for(p = response->response_buffer+4, q = size; - isdigit(*p); - p++,q++) - { - *q = *p; - } - *q = '\0'; - - if(target->mode == GLOBUS_FTP_CONTROL_MODE_STREAM && - client_handle->restart_marker.type == - GLOBUS_FTP_CLIENT_RESTART_NONE) - { - client_handle->restart_marker.type = - GLOBUS_FTP_CLIENT_RESTART_STREAM; - - globus_libc_scan_off_t( - (char *) size, - &client_handle->restart_marker.stream.offset, - GLOBUS_NULL); - - client_handle->restart_marker.stream.ascii_offset = - client_handle->restart_marker.stream.offset; - } - globus_libc_free(size); - } - - } - else if(response->code / 10 == 50) - { - /* A 500 response means the server doesn't know about SIZE */ - globus_i_ftp_client_feature_set( - target->features, - GLOBUS_FTP_CLIENT_FEATURE_SIZE, - GLOBUS_FTP_CLIENT_FALSE); - - } - else if(response->code == 550 && /* file unavailable */ - client_handle->dest == target) - { - /* - * The file may not exist on the remote side if we're - * restarting. - */ - ; - } - else - { - /* Any other response is not good. */ - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; - if((!client_handle->err) && (!error)) - { - error = GLOBUS_I_FTP_CLIENT_ERROR_RESPONSE(response); - } - goto connection_error; - } - - skip_size: - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_BUFSIZE; - goto redo; - - case GLOBUS_FTP_CLIENT_TARGET_SETUP_BUFSIZE: - target->state = GLOBUS_FTP_CLIENT_TARGET_BUFSIZE; - - /* - * TODO: compare buffer mode/size properly for all instances - * of union components - */ - if(target->attr->buffer.mode == target->tcp_buffer.mode && - target->attr->buffer.fixed.size == target->tcp_buffer.fixed.size) - { - goto skip_bufsize; - } - if(!(client_handle->op == GLOBUS_FTP_CLIENT_GET || - client_handle->op == GLOBUS_FTP_CLIENT_PUT || - client_handle->op == GLOBUS_FTP_CLIENT_LIST || - client_handle->op == GLOBUS_FTP_CLIENT_NLST || - client_handle->op == GLOBUS_FTP_CLIENT_MLSD || - client_handle->op == GLOBUS_FTP_CLIENT_MLSR || - client_handle->op == GLOBUS_FTP_CLIENT_TRANSFER)) - { - goto skip_bufsize; - } - - buffer_cmd = globus_l_ftp_client_guess_buffer_command(client_handle, - target); - if(buffer_cmd == GLOBUS_NULL) - { - error = GLOBUS_I_FTP_CLIENT_ERROR_UNSUPPORTED_FEATURE( - "Adjust socket buffer"); - - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; - - goto notify_fault; - } - - /* Choose the proper string to pass along with the chosen - * buffer size command. - */ - switch(target->attr->buffer.mode) - { - case GLOBUS_FTP_CONTROL_TCPBUFFER_DEFAULT: - target->attr->buffer.fixed.size = 0UL; - case GLOBUS_FTP_CONTROL_TCPBUFFER_FIXED: - break; - case GLOBUS_FTP_CONTROL_TCPBUFFER_AUTOMATIC: - error = GLOBUS_I_FTP_CLIENT_ERROR_UNSUPPORTED_FEATURE("ABUF"); - - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; - - goto notify_fault; - } - target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_TRANSFER_PARAMETERS; - globus_i_ftp_client_plugin_notify_command( - client_handle, - target->url_string, - target->mask, - "%s %lu" CRLF, - buffer_cmd, - target->attr->buffer.fixed.size); - - if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) - { - break; - } - - globus_assert(client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); - - result = globus_ftp_control_send_command( - target->control_handle, - "%s %lu" CRLF, - globus_i_ftp_client_response_callback, - target, - buffer_cmd, - target->attr->buffer.fixed.size); - - if(result != GLOBUS_SUCCESS) - { - goto result_fault; - } - break; - - case GLOBUS_FTP_CLIENT_TARGET_BUFSIZE: - globus_assert( - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); - - if((!error) && - response->response_class == GLOBUS_FTP_POSITIVE_COMPLETION_REPLY) - { - globus_l_ftp_client_update_buffer_feature( - client_handle, target, GLOBUS_FTP_CLIENT_TRUE); - - target->tcp_buffer = target->attr->buffer; - - result = globus_ftp_control_local_tcp_buffer( - target->control_handle, - &target->tcp_buffer); - - if(result != GLOBUS_SUCCESS) - { - goto result_fault; - } - } - else if(error) - { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; - - goto notify_fault; - } - else - { - globus_l_ftp_client_update_buffer_feature( - client_handle, target, GLOBUS_FTP_CLIENT_FALSE); - - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_BUFSIZE; - goto redo; - } - skip_bufsize: - if(target->mode == GLOBUS_FTP_CONTROL_MODE_EXTENDED_BLOCK && - (client_handle->op == GLOBUS_FTP_CLIENT_GET || - client_handle->op == GLOBUS_FTP_CLIENT_MLSD || - client_handle->op == GLOBUS_FTP_CLIENT_MLSR || - client_handle->op == GLOBUS_FTP_CLIENT_LIST || - client_handle->op == GLOBUS_FTP_CLIENT_NLST || - (client_handle->op == GLOBUS_FTP_CLIENT_TRANSFER && - target == client_handle->source))) - { - /* Only send OPTS RETR if the source control handle will - * be used. - */ - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_REMOTE_RETR_OPTS; - } - else if(target->mode == GLOBUS_FTP_CONTROL_MODE_EXTENDED_BLOCK && - client_handle->op == GLOBUS_FTP_CLIENT_PUT) - { - /* Only do local_layout and local_parallelism if we are - * receiving the data (not 3rd party) - */ - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_LOCAL_RETR_OPTS; - } - else - { - goto skip_opts_retr; - } - - goto redo; - - case GLOBUS_FTP_CLIENT_TARGET_SETUP_REMOTE_RETR_OPTS: + break; - parallelism_opt = globus_l_ftp_client_parallelism_string(target); - layout_opt = globus_l_ftp_client_layout_string(target); - - if((!parallelism_opt) && (!layout_opt)) - { - goto skip_opts_retr; - } - - target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_TRANSFER_PARAMETERS; - - globus_i_ftp_client_plugin_notify_command( - client_handle, - target->url_string, - target->mask, - "OPTS RETR %s%s" CRLF, - layout_opt ? layout_opt : "", - parallelism_opt ? parallelism_opt : ""); - - if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) - { - if(parallelism_opt) - { - globus_libc_free(parallelism_opt); - } - if(layout_opt) - { - globus_libc_free(layout_opt); - } - break; - } - result = globus_ftp_control_send_command( - target->control_handle, - "OPTS RETR %s%s" CRLF, - globus_i_ftp_client_response_callback, - target, - layout_opt ? layout_opt : "", - parallelism_opt ? parallelism_opt : ""); - - if(parallelism_opt) - { - globus_libc_free(parallelism_opt); - } - if(layout_opt) - { - globus_libc_free(layout_opt); - } - if(result != GLOBUS_SUCCESS) - { - goto result_fault; - } - - target->state = GLOBUS_FTP_CLIENT_TARGET_REMOTE_RETR_OPTS; - break; + case GLOBUS_FTP_CLIENT_TARGET_TYPE: + globus_assert( + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); - case GLOBUS_FTP_CLIENT_TARGET_SETUP_LOCAL_RETR_OPTS: - - if(target->attr->parallelism.mode == target->parallelism.mode && - (target->parallelism.mode != GLOBUS_FTP_CONTROL_PARALLELISM_FIXED - || target->attr->parallelism.fixed.size == - target->parallelism.fixed.size) && - target->attr->layout.mode == target->layout.mode && - (target->layout.mode != - GLOBUS_FTP_CONTROL_STRIPING_BLOCKED_ROUND_ROBIN - || target->attr->layout.round_robin.block_size == - target->layout.round_robin.block_size)) + if((!error) && + response->response_class == GLOBUS_FTP_POSITIVE_COMPLETION_REPLY) { - goto skip_opts_retr; + target->type = target->attr->type; + result = globus_ftp_control_local_type(target->control_handle, + target->type, + 8); + if(result != GLOBUS_SUCCESS) + { + goto result_fault; + } } - - result = globus_ftp_control_local_parallelism( - target->control_handle, - &target->attr->parallelism); - - if(result) - { - goto result_fault; - } - result = globus_ftp_control_local_layout(target->control_handle, - &target->attr->layout, - 0); - if(result) - { - goto result_fault; - } - - memcpy(&target->parallelism, - &target->attr->parallelism, - sizeof(globus_ftp_control_parallelism_t)); - - memcpy(&target->parallelism, - &target->attr->parallelism, - sizeof(globus_ftp_control_parallelism_t)); - - goto skip_opts_retr; - - case GLOBUS_FTP_CLIENT_TARGET_REMOTE_RETR_OPTS: - globus_assert( - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION - || - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); - - if((!error) && - response->response_class == GLOBUS_FTP_POSITIVE_COMPLETION_REPLY) - { - memcpy(&target->parallelism, - &target->attr->parallelism, - sizeof(globus_ftp_control_parallelism_t)); - memcpy(&target->layout, - &target->attr->layout, - sizeof(globus_ftp_control_layout_t)); - } - else if((!error) && response->code / 10 == 50) - { - globus_i_ftp_client_feature_set( - target->features, - GLOBUS_FTP_CLIENT_FEATURE_PARALLELISM, - GLOBUS_FTP_CLIENT_FALSE); - - if(target->attr->parallelism.mode - == GLOBUS_FTP_CONTROL_PARALLELISM_NONE && - target->attr->layout.mode == GLOBUS_FTP_CONTROL_STRIPING_NONE) - { - memcpy(&target->parallelism, - &target->attr->parallelism, - sizeof(globus_ftp_control_parallelism_t)); - memcpy(&target->layout, - &target->attr->layout, - sizeof(globus_ftp_control_layout_t)); - } - else - { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; - - goto connection_error; - } - } - else - { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; - - goto notify_fault; - } + else + { + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; - skip_opts_retr: - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_DCSC; - goto redo; + goto notify_fault; + } - case GLOBUS_FTP_CLIENT_TARGET_SETUP_DCSC: - target->state = GLOBUS_FTP_CLIENT_TARGET_DCSC; + skip_type: + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_AUTHZ_ASSERT; + goto redo; - if(target->attr->dcsc_type == 0 || - (target->attr->dcsc_type == target->dcsc_type && - target->dcsc_blob && target->attr->dcsc_blob && - strcmp(target->attr->dcsc_blob, target->dcsc_blob) == 0)) - { - goto skip_dcsc; - } + case GLOBUS_FTP_CLIENT_TARGET_SETUP_AUTHZ_ASSERT: + target->state = GLOBUS_FTP_CLIENT_TARGET_AUTHZ_ASSERT; - if(globus_i_ftp_client_feature_get(target->features, - GLOBUS_FTP_CLIENT_FEATURE_DCSC) != GLOBUS_FTP_CLIENT_TRUE && - target->url.scheme_type == GLOBUS_URL_SCHEME_GSIFTP) + if (!target->attr->authz_assert) { - goto skip_dcsc; + goto skip_authz_assert; + } + if(target->authz_assert && + !strcmp(target->attr->authz_assert, target->authz_assert) && + target->attr->cache_authz_assert) + { + goto skip_authz_assert; } - /* changing DCSC forces us to trash our old data connections */ - memset(&target->cached_data_conn, - '\0', - sizeof(globus_i_ftp_client_data_target_t)); - - target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_TRANSFER_PARAMETERS; - globus_i_ftp_client_plugin_notify_command( - client_handle, - target->url_string, - target->mask, - "DCSC %c%s%s" CRLF, - (char) target->attr->dcsc_type, - target->attr->dcsc_type == 'D' ? "" : " ", - target->attr->dcsc_type == 'D' ? "" : target->attr->dcsc_blob); + target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_MISC; - if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || + globus_i_ftp_client_plugin_notify_command( + client_handle, + target->url_string, + target->mask, + "SITE AUTHZ_ASSERT %s", + target->attr->authz_assert); + + if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) + { + break; + } + globus_assert( + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION + || + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); + + result = globus_ftp_control_send_command( + target->control_handle, + "SITE AUTHZ_ASSERT %s" CRLF, + globus_i_ftp_client_response_callback, + target, + target->attr->authz_assert); + + if(result != GLOBUS_SUCCESS) + { + goto result_fault; + } + + break; + + case GLOBUS_FTP_CLIENT_TARGET_AUTHZ_ASSERT: + globus_assert( + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); + + if((!error) && + response->response_class == GLOBUS_FTP_POSITIVE_COMPLETION_REPLY) + { + if (target->authz_assert) + { + if (strcmp(target->authz_assert, target->attr->authz_assert)) + { + globus_free(target->authz_assert); + target->authz_assert = globus_libc_strdup( + target->attr->authz_assert); + } + } + else + { + target->authz_assert = + globus_libc_strdup(target->attr->authz_assert); + } + } + else + { + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; + + goto notify_fault; + } + + skip_authz_assert: + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_SETNETSTACK; + goto redo; + + + case GLOBUS_FTP_CLIENT_TARGET_SETUP_SETNETSTACK: + target->state = GLOBUS_FTP_CLIENT_TARGET_SETNETSTACK; + if(target->attr->net_stack_str == NULL || + (target->net_stack_str != NULL && + strcmp(target->attr->net_stack_str, target->net_stack_str) == 0)) + { + goto skip_setnetstack; + } + + memset(&target->cached_data_conn, + '\0', + sizeof(globus_i_ftp_client_data_target_t)); + + target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_TRANSFER_PARAMETERS; + globus_i_ftp_client_plugin_notify_command( + client_handle, + target->url_string, + target->mask, + "SITE SETNETSTACK %s" CRLF, + target->attr->net_stack_str); + + if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) + { + break; + } + + globus_assert( + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); + + result = globus_ftp_control_send_command( + target->control_handle, + "SITE SETNETSTACK %s" CRLF, + globus_i_ftp_client_response_callback, + target, + target->attr->net_stack_str); + if(result != GLOBUS_SUCCESS) + { + goto result_fault; + } + + break; + + case GLOBUS_FTP_CLIENT_TARGET_SETNETSTACK: + globus_assert( + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); + + if((!error) && + response->response_class == GLOBUS_FTP_POSITIVE_COMPLETION_REPLY) + { + globus_xio_stack_t stack; + + if(target->net_stack_str) + { + globus_free(target->net_stack_str); + } + target->net_stack_str = + globus_libc_strdup(target->attr->net_stack_str); + + if(client_handle->op != GLOBUS_FTP_CLIENT_TRANSFER) + { + if(target->net_stack_list) + { + globus_i_ftp_control_unload_xio_drivers( + target->net_stack_list); + target->net_stack_list = GLOBUS_NULL; + } + + result = globus_i_ftp_control_load_xio_drivers( + target->net_stack_str, &target->net_stack_list); + if(result != GLOBUS_SUCCESS) + { + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; + + goto result_fault; + } + result = globus_i_ftp_control_create_stack( + target->control_handle, target->net_stack_list, &stack); + if(result != GLOBUS_SUCCESS) + { + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; + + goto result_fault; + } + + result = globus_i_ftp_control_data_set_stack( + target->control_handle, stack); + if(result != GLOBUS_SUCCESS) + { + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; + + goto result_fault; + } + globus_xio_stack_destroy(stack); + } + } + else + { + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; + + goto notify_fault; + } + + skip_setnetstack: + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_SETDISKSTACK; + goto redo; + + + case GLOBUS_FTP_CLIENT_TARGET_SETUP_SETDISKSTACK: + target->state = GLOBUS_FTP_CLIENT_TARGET_SETDISKSTACK; + if(target->attr->disk_stack_str == NULL || + (target->disk_stack_str != NULL && + strcmp(target->attr->disk_stack_str, target->disk_stack_str) == 0)) + { + goto skip_setdiskstack; + } + + memset(&target->cached_data_conn, + '\0', + sizeof(globus_i_ftp_client_data_target_t)); + + target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_TRANSFER_PARAMETERS; + globus_i_ftp_client_plugin_notify_command( + client_handle, + target->url_string, + target->mask, + "SITE SETDISKSTACK %s" CRLF, + target->attr->disk_stack_str); + + if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) + { + break; + } + + globus_assert( + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); + + result = globus_ftp_control_send_command( + target->control_handle, + "SITE SETDISKSTACK %s" CRLF, + globus_i_ftp_client_response_callback, + target, + target->attr->disk_stack_str); + if(result != GLOBUS_SUCCESS) + { + goto result_fault; + } + + break; + + case GLOBUS_FTP_CLIENT_TARGET_SETDISKSTACK: + globus_assert( + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); + + if((!error) && + response->response_class == GLOBUS_FTP_POSITIVE_COMPLETION_REPLY) + { + if(target->disk_stack_str) + { + globus_free(target->disk_stack_str); + } + target->disk_stack_str = + globus_libc_strdup(target->attr->disk_stack_str); + } + else + { + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; + + goto notify_fault; + } + + skip_setdiskstack: + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_MODE; + goto redo; + + + case GLOBUS_FTP_CLIENT_TARGET_SETUP_MODE: + target->state = GLOBUS_FTP_CLIENT_TARGET_MODE; + if(target->attr->mode == target->mode) + { + goto skip_mode; + } + memset(&target->cached_data_conn, + '\0', + sizeof(globus_i_ftp_client_data_target_t)); + + target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_TRANSFER_PARAMETERS; + globus_i_ftp_client_plugin_notify_command( + client_handle, + target->url_string, + target->mask, + "MODE %c" CRLF, + (char) target->attr->mode); + + if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) + { + break; + } + + globus_assert( + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); + + result = globus_ftp_control_send_command( + target->control_handle, + "MODE %c" CRLF, + globus_i_ftp_client_response_callback, + target, + (char) target->attr->mode); + + if(result != GLOBUS_SUCCESS) + { + goto result_fault; + } + + break; + + case GLOBUS_FTP_CLIENT_TARGET_MODE: + globus_assert( + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); + + if((!error) && + response->response_class == GLOBUS_FTP_POSITIVE_COMPLETION_REPLY) + { + target->mode = target->attr->mode; + + /* disable source pasv */ + if(target->mode == GLOBUS_FTP_CONTROL_MODE_EXTENDED_BLOCK) + { + client_handle->source_pasv = GLOBUS_FALSE; + } + + result = globus_ftp_control_local_mode(target->control_handle, + target->mode); + if(result != GLOBUS_SUCCESS) + { + goto result_fault; + } + } + else + { + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; + + goto notify_fault; + } + + skip_mode: + if(client_handle->op == GLOBUS_FTP_CLIENT_CKSM) + { + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CKSM; + } + else + { + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_SIZE; + } + goto redo; + + case GLOBUS_FTP_CLIENT_TARGET_SETUP_CKSM: + + + target->state = GLOBUS_FTP_CLIENT_TARGET_NEED_COMPLETE; + + target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_INFORMATION; + + globus_i_ftp_client_plugin_notify_command( + client_handle, + target->url_string, + target->mask, + "CKSM %s %" GLOBUS_OFF_T_FORMAT " %" GLOBUS_OFF_T_FORMAT " %s" CRLF, + client_handle->checksum_alg, + client_handle->checksum_offset, + client_handle->checksum_length, + pathname); + + if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) + { + break; + } + + globus_assert(client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); + + result = globus_ftp_control_send_command( + target->control_handle, + "CKSM %s %" GLOBUS_OFF_T_FORMAT " %" GLOBUS_OFF_T_FORMAT " %s" CRLF, + globus_i_ftp_client_response_callback, + target, + client_handle->checksum_alg, + client_handle->checksum_offset, + client_handle->checksum_length, + pathname); + + if(result != GLOBUS_SUCCESS) + { + goto result_fault; + } + break; + + case GLOBUS_FTP_CLIENT_TARGET_SETUP_SIZE: + /* + * Doing a SIZE isn't necessary but is nice for + * - resuming stream mode 3rd party transfers + * + * Skip if + * - server doesn't do SIZE + * - not interesting + * where interesting is + * - destination of stream mode 3rd party transfer w/ resume + * attr set to true + */ + if(globus_i_ftp_client_feature_get( + target->features, + GLOBUS_FTP_CLIENT_FEATURE_SIZE) == GLOBUS_FALSE + || + (! + ( + (client_handle->op == GLOBUS_FTP_CLIENT_TRANSFER && + target == client_handle->dest && + target->attr->resume_third_party && + target->mode == GLOBUS_FTP_CONTROL_MODE_STREAM) + || + (client_handle->op == GLOBUS_FTP_CLIENT_SIZE) + ) + ) + ) + { + if(client_handle->op == GLOBUS_FTP_CLIENT_SIZE) + { + error = GLOBUS_I_FTP_CLIENT_ERROR_UNSUPPORTED_FEATURE("SIZE"); + + goto notify_fault; + + } + goto skip_size; + } + + if(client_handle->op == GLOBUS_FTP_CLIENT_SIZE) + { + target->state = GLOBUS_FTP_CLIENT_TARGET_NEED_COMPLETE; + } + else + { + target->state = GLOBUS_FTP_CLIENT_TARGET_SIZE; + } + + target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_INFORMATION; + + globus_i_ftp_client_plugin_notify_command( + client_handle, + target->url_string, + target->mask, + "SIZE %s" CRLF, + pathname); + + if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) + { + break; + } + + globus_assert(client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); + + result = globus_ftp_control_send_command( + target->control_handle, + "SIZE %s" CRLF, + globus_i_ftp_client_response_callback, + target, + pathname); + + if(result != GLOBUS_SUCCESS) + { + goto result_fault; + } + break; + + case GLOBUS_FTP_CLIENT_TARGET_SIZE: + globus_assert( + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION + || + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); + + if(error != GLOBUS_SUCCESS) + { + goto notify_fault; + } + if(response->response_class == GLOBUS_FTP_POSITIVE_COMPLETION_REPLY) + { + globus_i_ftp_client_feature_set( + target->features, + GLOBUS_FTP_CLIENT_FEATURE_SIZE, + GLOBUS_FTP_CLIENT_TRUE); + + if(client_handle->source == target) + { + globus_libc_scan_off_t((char *) response->response_buffer+4, + &client_handle->source_size, + GLOBUS_NULL); + } + else + { + globus_byte_t * size; + const globus_byte_t * p; + globus_byte_t *q; + + size = globus_libc_malloc( + strlen((char *) response->response_buffer+3)); + for(p = response->response_buffer+4, q = size; + isdigit(*p); + p++,q++) + { + *q = *p; + } + *q = '\0'; + + if(target->mode == GLOBUS_FTP_CONTROL_MODE_STREAM && + client_handle->restart_marker.type == + GLOBUS_FTP_CLIENT_RESTART_NONE) + { + client_handle->restart_marker.type = + GLOBUS_FTP_CLIENT_RESTART_STREAM; + + globus_libc_scan_off_t( + (char *) size, + &client_handle->restart_marker.stream.offset, + GLOBUS_NULL); + + client_handle->restart_marker.stream.ascii_offset = + client_handle->restart_marker.stream.offset; + } + globus_libc_free(size); + } + + } + else if(response->code / 10 == 50) + { + /* A 500 response means the server doesn't know about SIZE */ + globus_i_ftp_client_feature_set( + target->features, + GLOBUS_FTP_CLIENT_FEATURE_SIZE, + GLOBUS_FTP_CLIENT_FALSE); + + } + else if(response->code == 550 && /* file unavailable */ + client_handle->dest == target) + { + /* + * The file may not exist on the remote side if we're + * restarting. + */ + ; + } + else + { + /* Any other response is not good. */ + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; + if((!client_handle->err) && (!error)) + { + error = GLOBUS_I_FTP_CLIENT_ERROR_RESPONSE(response); + } + goto connection_error; + } + + skip_size: + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_BUFSIZE; + goto redo; + + case GLOBUS_FTP_CLIENT_TARGET_SETUP_BUFSIZE: + target->state = GLOBUS_FTP_CLIENT_TARGET_BUFSIZE; + + /* + * TODO: compare buffer mode/size properly for all instances + * of union components + */ + if(target->attr->buffer.mode == target->tcp_buffer.mode && + target->attr->buffer.fixed.size == target->tcp_buffer.fixed.size) + { + goto skip_bufsize; + } + if(!(client_handle->op == GLOBUS_FTP_CLIENT_GET || + client_handle->op == GLOBUS_FTP_CLIENT_PUT || + client_handle->op == GLOBUS_FTP_CLIENT_LIST || + client_handle->op == GLOBUS_FTP_CLIENT_NLST || + client_handle->op == GLOBUS_FTP_CLIENT_MLSD || + client_handle->op == GLOBUS_FTP_CLIENT_MLSR || + client_handle->op == GLOBUS_FTP_CLIENT_TRANSFER)) + { + goto skip_bufsize; + } + + buffer_cmd = globus_l_ftp_client_guess_buffer_command(client_handle, + target); + if(buffer_cmd == GLOBUS_NULL) + { + error = GLOBUS_I_FTP_CLIENT_ERROR_UNSUPPORTED_FEATURE( + "Adjust socket buffer"); + + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; + + goto notify_fault; + } + + /* Choose the proper string to pass along with the chosen + * buffer size command. + */ + switch(target->attr->buffer.mode) + { + case GLOBUS_FTP_CONTROL_TCPBUFFER_DEFAULT: + target->attr->buffer.fixed.size = 0UL; + case GLOBUS_FTP_CONTROL_TCPBUFFER_FIXED: + break; + case GLOBUS_FTP_CONTROL_TCPBUFFER_AUTOMATIC: + error = GLOBUS_I_FTP_CLIENT_ERROR_UNSUPPORTED_FEATURE("ABUF"); + + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; + + goto notify_fault; + } + target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_TRANSFER_PARAMETERS; + globus_i_ftp_client_plugin_notify_command( + client_handle, + target->url_string, + target->mask, + "%s %lu" CRLF, + buffer_cmd, + target->attr->buffer.fixed.size); + + if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) + { + break; + } + + globus_assert(client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); + + result = globus_ftp_control_send_command( + target->control_handle, + "%s %lu" CRLF, + globus_i_ftp_client_response_callback, + target, + buffer_cmd, + target->attr->buffer.fixed.size); + + if(result != GLOBUS_SUCCESS) + { + goto result_fault; + } + break; + + case GLOBUS_FTP_CLIENT_TARGET_BUFSIZE: + globus_assert( + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); + + if((!error) && + response->response_class == GLOBUS_FTP_POSITIVE_COMPLETION_REPLY) + { + globus_l_ftp_client_update_buffer_feature( + client_handle, target, GLOBUS_FTP_CLIENT_TRUE); + + target->tcp_buffer = target->attr->buffer; + + result = globus_ftp_control_local_tcp_buffer( + target->control_handle, + &target->tcp_buffer); + + if(result != GLOBUS_SUCCESS) + { + goto result_fault; + } + } + else if(error) + { + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; + + goto notify_fault; + } + else + { + globus_l_ftp_client_update_buffer_feature( + client_handle, target, GLOBUS_FTP_CLIENT_FALSE); + + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_BUFSIZE; + goto redo; + } + + skip_bufsize: + if(target->mode == GLOBUS_FTP_CONTROL_MODE_EXTENDED_BLOCK && + (client_handle->op == GLOBUS_FTP_CLIENT_GET || + client_handle->op == GLOBUS_FTP_CLIENT_MLSD || + client_handle->op == GLOBUS_FTP_CLIENT_MLSR || + client_handle->op == GLOBUS_FTP_CLIENT_LIST || + client_handle->op == GLOBUS_FTP_CLIENT_NLST || + (client_handle->op == GLOBUS_FTP_CLIENT_TRANSFER && + target == client_handle->source))) + { + /* Only send OPTS RETR if the source control handle will + * be used. + */ + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_REMOTE_RETR_OPTS; + } + else if(target->mode == GLOBUS_FTP_CONTROL_MODE_EXTENDED_BLOCK && + client_handle->op == GLOBUS_FTP_CLIENT_PUT) + { + /* Only do local_layout and local_parallelism if we are + * receiving the data (not 3rd party) + */ + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_LOCAL_RETR_OPTS; + } + else + { + goto skip_opts_retr; + } + + goto redo; + + case GLOBUS_FTP_CLIENT_TARGET_SETUP_REMOTE_RETR_OPTS: + + parallelism_opt = globus_l_ftp_client_parallelism_string(target); + layout_opt = globus_l_ftp_client_layout_string(target); + + if((!parallelism_opt) && (!layout_opt)) + { + goto skip_opts_retr; + } + + target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_TRANSFER_PARAMETERS; + + globus_i_ftp_client_plugin_notify_command( + client_handle, + target->url_string, + target->mask, + "OPTS RETR %s%s" CRLF, + layout_opt ? layout_opt : "", + parallelism_opt ? parallelism_opt : ""); + + if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) + { + if(parallelism_opt) + { + globus_libc_free(parallelism_opt); + } + if(layout_opt) + { + globus_libc_free(layout_opt); + } + break; + } + result = globus_ftp_control_send_command( + target->control_handle, + "OPTS RETR %s%s" CRLF, + globus_i_ftp_client_response_callback, + target, + layout_opt ? layout_opt : "", + parallelism_opt ? parallelism_opt : ""); + + if(parallelism_opt) + { + globus_libc_free(parallelism_opt); + } + if(layout_opt) + { + globus_libc_free(layout_opt); + } + if(result != GLOBUS_SUCCESS) + { + goto result_fault; + } + + target->state = GLOBUS_FTP_CLIENT_TARGET_REMOTE_RETR_OPTS; + break; + + case GLOBUS_FTP_CLIENT_TARGET_SETUP_LOCAL_RETR_OPTS: + + if(target->attr->parallelism.mode == target->parallelism.mode && + (target->parallelism.mode != GLOBUS_FTP_CONTROL_PARALLELISM_FIXED + || target->attr->parallelism.fixed.size == + target->parallelism.fixed.size) && + target->attr->layout.mode == target->layout.mode && + (target->layout.mode != + GLOBUS_FTP_CONTROL_STRIPING_BLOCKED_ROUND_ROBIN + || target->attr->layout.round_robin.block_size == + target->layout.round_robin.block_size)) + { + goto skip_opts_retr; + } + + result = globus_ftp_control_local_parallelism( + target->control_handle, + &target->attr->parallelism); + + if(result) + { + goto result_fault; + } + result = globus_ftp_control_local_layout(target->control_handle, + &target->attr->layout, + 0); + if(result) + { + goto result_fault; + } + + memcpy(&target->parallelism, + &target->attr->parallelism, + sizeof(globus_ftp_control_parallelism_t)); + + memcpy(&target->parallelism, + &target->attr->parallelism, + sizeof(globus_ftp_control_parallelism_t)); + + goto skip_opts_retr; + + case GLOBUS_FTP_CLIENT_TARGET_REMOTE_RETR_OPTS: + globus_assert( + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION + || + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); + + if((!error) && + response->response_class == GLOBUS_FTP_POSITIVE_COMPLETION_REPLY) + { + memcpy(&target->parallelism, + &target->attr->parallelism, + sizeof(globus_ftp_control_parallelism_t)); + memcpy(&target->layout, + &target->attr->layout, + sizeof(globus_ftp_control_layout_t)); + } + else if((!error) && response->code / 10 == 50) + { + globus_i_ftp_client_feature_set( + target->features, + GLOBUS_FTP_CLIENT_FEATURE_PARALLELISM, + GLOBUS_FTP_CLIENT_FALSE); + + if(target->attr->parallelism.mode + == GLOBUS_FTP_CONTROL_PARALLELISM_NONE && + target->attr->layout.mode == GLOBUS_FTP_CONTROL_STRIPING_NONE) + { + memcpy(&target->parallelism, + &target->attr->parallelism, + sizeof(globus_ftp_control_parallelism_t)); + memcpy(&target->layout, + &target->attr->layout, + sizeof(globus_ftp_control_layout_t)); + } + else + { + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; + + goto connection_error; + } + } + else + { + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; + + goto notify_fault; + } + + skip_opts_retr: + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_DCSC; + goto redo; + + case GLOBUS_FTP_CLIENT_TARGET_SETUP_DCSC: + target->state = GLOBUS_FTP_CLIENT_TARGET_DCSC; + + if(target->attr->dcsc_type == 0 || + (target->attr->dcsc_type == target->dcsc_type && + target->dcsc_blob && target->attr->dcsc_blob && + strcmp(target->attr->dcsc_blob, target->dcsc_blob) == 0)) + { + goto skip_dcsc; + } + + if(globus_i_ftp_client_feature_get(target->features, + GLOBUS_FTP_CLIENT_FEATURE_DCSC) != GLOBUS_FTP_CLIENT_TRUE && + target->url.scheme_type == GLOBUS_URL_SCHEME_GSIFTP) + { + goto skip_dcsc; + } + + /* changing DCSC forces us to trash our old data connections */ + memset(&target->cached_data_conn, + '\0', + sizeof(globus_i_ftp_client_data_target_t)); + + target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_TRANSFER_PARAMETERS; + globus_i_ftp_client_plugin_notify_command( + client_handle, + target->url_string, + target->mask, + "DCSC %c%s%s" CRLF, + (char) target->attr->dcsc_type, + target->attr->dcsc_type == 'D' ? "" : " ", + target->attr->dcsc_type == 'D' ? "" : target->attr->dcsc_blob); + + if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) - { - break; - } - - globus_assert( - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); - - result = globus_ftp_control_send_command( - target->control_handle, - "DCSC %c%s%s" CRLF, - globus_i_ftp_client_response_callback, - target, - (char) target->attr->dcsc_type, - target->attr->dcsc_type == 'D' ? "" : " ", - target->attr->dcsc_type == 'D' ? "" : target->attr->dcsc_blob); - - if(result != GLOBUS_SUCCESS) - { - goto result_fault; - } - - break; + { + break; + } + + globus_assert( + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); + + result = globus_ftp_control_send_command( + target->control_handle, + "DCSC %c%s%s" CRLF, + globus_i_ftp_client_response_callback, + target, + (char) target->attr->dcsc_type, + target->attr->dcsc_type == 'D' ? "" : " ", + target->attr->dcsc_type == 'D' ? "" : target->attr->dcsc_blob); + + if(result != GLOBUS_SUCCESS) + { + goto result_fault; + } + + break; case GLOBUS_FTP_CLIENT_TARGET_DCSC: - globus_assert( - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); - - if((!error) && - response->response_class == GLOBUS_FTP_POSITIVE_COMPLETION_REPLY) - { + globus_assert( + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); + + if((!error) && + response->response_class == GLOBUS_FTP_POSITIVE_COMPLETION_REPLY) + { target->dcsc_type = target->attr->dcsc_type; if(target->dcsc_blob) { @@ -1844,145 +1844,145 @@ globus_i_ftp_client_response_callback( } target->dcsc_blob = globus_libc_strdup(target->attr->dcsc_blob); target->dcsc_p_cred = target->attr->dcsc_p_cred; - } - else - { - error = GLOBUS_I_FTP_CLIENT_ERROR_UNSUPPORTED_FEATURE("DCSC"); - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; + } + else + { + error = GLOBUS_I_FTP_CLIENT_ERROR_UNSUPPORTED_FEATURE("DCSC"); + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; - goto notify_fault; - } + goto notify_fault; + } skip_dcsc: - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_DCAU; - goto redo; + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_DCAU; + goto redo; case GLOBUS_FTP_CLIENT_TARGET_SETUP_DCAU: - target->state = GLOBUS_FTP_CLIENT_TARGET_DCAU; - + target->state = GLOBUS_FTP_CLIENT_TARGET_DCAU; + if(target->dcsc_p_cred != GSS_C_NO_CREDENTIAL) { target->attr->dcau.mode = GLOBUS_FTP_CONTROL_DCAU_SELF; } - if(target->attr->dcau.mode == target->dcau.mode && - target->dcau.mode != GLOBUS_FTP_CONTROL_DCAU_DEFAULT) - { - goto skip_dcau; - } - if(target->attr->dcau.mode == GLOBUS_FTP_CONTROL_DCAU_DEFAULT && - globus_i_ftp_client_feature_get( - target->features, - GLOBUS_FTP_CLIENT_FEATURE_DCAU) != GLOBUS_FTP_CLIENT_TRUE) - { - goto skip_dcau; - } - if(target->attr->dcau.mode == GLOBUS_FTP_CONTROL_DCAU_DEFAULT && - (target->dcau.mode == GLOBUS_FTP_CONTROL_DCAU_SELF || - target->dcau.mode == GLOBUS_FTP_CONTROL_DCAU_DEFAULT)) - { - goto finish_dcau; - } - - /* changing DCAU forces us to trash our old data connections */ - memset(&target->cached_data_conn, - '\0', - sizeof(globus_i_ftp_client_data_target_t)); - - target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_TRANSFER_PARAMETERS; - globus_i_ftp_client_plugin_notify_command( - client_handle, - target->url_string, - target->mask, - "DCAU %c%s%s" CRLF, - (char) target->attr->dcau.mode == GLOBUS_FTP_CONTROL_DCAU_DEFAULT - ? GLOBUS_FTP_CONTROL_DCAU_SELF : target->attr->dcau.mode, - target->attr->dcau.mode == GLOBUS_FTP_CONTROL_DCAU_SUBJECT - ? " " : "", - target->attr->dcau.mode == GLOBUS_FTP_CONTROL_DCAU_SUBJECT - ? target->attr->dcau.subject.subject : ""); - - if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || + if(target->attr->dcau.mode == target->dcau.mode && + target->dcau.mode != GLOBUS_FTP_CONTROL_DCAU_DEFAULT) + { + goto skip_dcau; + } + if(target->attr->dcau.mode == GLOBUS_FTP_CONTROL_DCAU_DEFAULT && + globus_i_ftp_client_feature_get( + target->features, + GLOBUS_FTP_CLIENT_FEATURE_DCAU) != GLOBUS_FTP_CLIENT_TRUE) + { + goto skip_dcau; + } + if(target->attr->dcau.mode == GLOBUS_FTP_CONTROL_DCAU_DEFAULT && + (target->dcau.mode == GLOBUS_FTP_CONTROL_DCAU_SELF || + target->dcau.mode == GLOBUS_FTP_CONTROL_DCAU_DEFAULT)) + { + goto finish_dcau; + } + + /* changing DCAU forces us to trash our old data connections */ + memset(&target->cached_data_conn, + '\0', + sizeof(globus_i_ftp_client_data_target_t)); + + target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_TRANSFER_PARAMETERS; + globus_i_ftp_client_plugin_notify_command( + client_handle, + target->url_string, + target->mask, + "DCAU %c%s%s" CRLF, + (char) target->attr->dcau.mode == GLOBUS_FTP_CONTROL_DCAU_DEFAULT + ? GLOBUS_FTP_CONTROL_DCAU_SELF : target->attr->dcau.mode, + target->attr->dcau.mode == GLOBUS_FTP_CONTROL_DCAU_SUBJECT + ? " " : "", + target->attr->dcau.mode == GLOBUS_FTP_CONTROL_DCAU_SUBJECT + ? target->attr->dcau.subject.subject : ""); + + if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) - { - break; - } - - globus_assert( - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); - - result = globus_ftp_control_send_command( - target->control_handle, - "DCAU %c%s%s" CRLF, - globus_i_ftp_client_response_callback, - target, - (char) target->attr->dcau.mode == GLOBUS_FTP_CONTROL_DCAU_DEFAULT - ? GLOBUS_FTP_CONTROL_DCAU_SELF : target->attr->dcau.mode, - target->attr->dcau.mode == GLOBUS_FTP_CONTROL_DCAU_SUBJECT - ? " " : "", - target->attr->dcau.mode == GLOBUS_FTP_CONTROL_DCAU_SUBJECT - ? target->attr->dcau.subject.subject : ""); - - if(result != GLOBUS_SUCCESS) - { - goto result_fault; - } - - break; + { + break; + } + + globus_assert( + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); + + result = globus_ftp_control_send_command( + target->control_handle, + "DCAU %c%s%s" CRLF, + globus_i_ftp_client_response_callback, + target, + (char) target->attr->dcau.mode == GLOBUS_FTP_CONTROL_DCAU_DEFAULT + ? GLOBUS_FTP_CONTROL_DCAU_SELF : target->attr->dcau.mode, + target->attr->dcau.mode == GLOBUS_FTP_CONTROL_DCAU_SUBJECT + ? " " : "", + target->attr->dcau.mode == GLOBUS_FTP_CONTROL_DCAU_SUBJECT + ? target->attr->dcau.subject.subject : ""); + + if(result != GLOBUS_SUCCESS) + { + goto result_fault; + } + + break; case GLOBUS_FTP_CLIENT_TARGET_DCAU: - globus_assert( - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); - - if((!error) && - response->response_class == GLOBUS_FTP_POSITIVE_COMPLETION_REPLY) - { - - if(target->attr->dcau.mode == GLOBUS_FTP_CONTROL_DCAU_SUBJECT) - { - char * tmp_subj; - tmp_subj = target->dcau.subject.subject; - - target->dcau.subject.subject = - globus_libc_strdup(target->attr->dcau.subject.subject); - if(! target->dcau.subject.subject) - { - error = GLOBUS_I_FTP_CLIENT_ERROR_OUT_OF_MEMORY(); - target->dcau.subject.subject = tmp_subj; - - goto notify_fault; - } - else if(tmp_subj) - { - globus_libc_free(tmp_subj); - } - } - finish_dcau: - if(target->attr->dcau.mode == GLOBUS_FTP_CONTROL_DCAU_DEFAULT) - { - if(!globus_i_ftp_client_feature_get( - target->features, GLOBUS_FTP_CLIENT_FEATURE_DCAU)) - { - target->dcau.mode = GLOBUS_FTP_CONTROL_DCAU_NONE; - } - else - { - target->dcau.mode = GLOBUS_FTP_CONTROL_DCAU_SELF; - } - } - else - { - target->dcau.mode = target->attr->dcau.mode; - } - + globus_assert( + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); + + if((!error) && + response->response_class == GLOBUS_FTP_POSITIVE_COMPLETION_REPLY) + { + + if(target->attr->dcau.mode == GLOBUS_FTP_CONTROL_DCAU_SUBJECT) + { + char * tmp_subj; + tmp_subj = target->dcau.subject.subject; + + target->dcau.subject.subject = + globus_libc_strdup(target->attr->dcau.subject.subject); + if(! target->dcau.subject.subject) + { + error = GLOBUS_I_FTP_CLIENT_ERROR_OUT_OF_MEMORY(); + target->dcau.subject.subject = tmp_subj; + + goto notify_fault; + } + else if(tmp_subj) + { + globus_libc_free(tmp_subj); + } + } + finish_dcau: + if(target->attr->dcau.mode == GLOBUS_FTP_CONTROL_DCAU_DEFAULT) + { + if(!globus_i_ftp_client_feature_get( + target->features, GLOBUS_FTP_CLIENT_FEATURE_DCAU)) + { + target->dcau.mode = GLOBUS_FTP_CONTROL_DCAU_NONE; + } + else + { + target->dcau.mode = GLOBUS_FTP_CONTROL_DCAU_SELF; + } + } + else + { + target->dcau.mode = target->attr->dcau.mode; + } + if(target->dcsc_p_cred != GSS_C_NO_CREDENTIAL) - { + { result = globus_ftp_control_local_dcau( target->control_handle, &target->dcau, @@ -1995,101 +1995,101 @@ globus_i_ftp_client_response_callback( &target->dcau, target->control_handle->cc_handle.auth_info.credential_handle); } - if(result != GLOBUS_SUCCESS) - { - goto result_fault; - } - } - else - { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; + if(result != GLOBUS_SUCCESS) + { + goto result_fault; + } + } + else + { + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; - goto notify_fault; - } + goto notify_fault; + } skip_dcau: - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_PBSZ; - goto redo; + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_PBSZ; + goto redo; case GLOBUS_FTP_CLIENT_TARGET_SETUP_PBSZ: - target->state = GLOBUS_FTP_CLIENT_TARGET_PBSZ; - - if(target->dcau.mode == GLOBUS_FTP_CONTROL_DCAU_NONE) - { - goto skip_pbsz; - } - - result = globus_ftp_control_get_pbsz( - target->control_handle, - &pbsz); - if(result != GLOBUS_SUCCESS) - { - goto result_fault; - } - if(target->pbsz == pbsz) - { - goto skip_pbsz; - } - - /* changing PBSZ forces us to trash our old data connections */ - memset(&target->cached_data_conn, - '\0', - sizeof(globus_i_ftp_client_data_target_t)); - - target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_TRANSFER_PARAMETERS; - globus_i_ftp_client_plugin_notify_command( - client_handle, - target->url_string, - target->mask, - "PBSZ %lu" CRLF, - pbsz); - - if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) - { - break; - } - - globus_assert( - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); - - result = globus_ftp_control_send_command( - target->control_handle, - "PBSZ %lu" CRLF, - globus_i_ftp_client_response_callback, - target, - pbsz); - - if(result != GLOBUS_SUCCESS) - { - goto result_fault; - } - - break; + target->state = GLOBUS_FTP_CLIENT_TARGET_PBSZ; + + if(target->dcau.mode == GLOBUS_FTP_CONTROL_DCAU_NONE) + { + goto skip_pbsz; + } + + result = globus_ftp_control_get_pbsz( + target->control_handle, + &pbsz); + if(result != GLOBUS_SUCCESS) + { + goto result_fault; + } + if(target->pbsz == pbsz) + { + goto skip_pbsz; + } + + /* changing PBSZ forces us to trash our old data connections */ + memset(&target->cached_data_conn, + '\0', + sizeof(globus_i_ftp_client_data_target_t)); + + target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_TRANSFER_PARAMETERS; + globus_i_ftp_client_plugin_notify_command( + client_handle, + target->url_string, + target->mask, + "PBSZ %lu" CRLF, + pbsz); + + if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) + { + break; + } + + globus_assert( + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); + + result = globus_ftp_control_send_command( + target->control_handle, + "PBSZ %lu" CRLF, + globus_i_ftp_client_response_callback, + target, + pbsz); + + if(result != GLOBUS_SUCCESS) + { + goto result_fault; + } + + break; case GLOBUS_FTP_CLIENT_TARGET_PBSZ: - globus_assert( - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); - - if((!error) && - response->response_class == GLOBUS_FTP_POSITIVE_COMPLETION_REPLY) - { - char * s; - + globus_assert( + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); + + if((!error) && + response->response_class == GLOBUS_FTP_POSITIVE_COMPLETION_REPLY) + { + char * s; + pbsz = 0; s = strstr((char *) response->response_buffer, "PBSZ="); if(s) { sscanf(s, "PBSZ=%lu", &pbsz); } - + if(pbsz == 0) { result = globus_ftp_control_get_pbsz( @@ -2100,112 +2100,112 @@ globus_i_ftp_client_response_callback( result = globus_ftp_control_local_pbsz( target->control_handle, pbsz); } - + if(result != GLOBUS_SUCCESS) { goto result_fault; } target->pbsz = pbsz; - } - else - { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; + } + else + { + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; - goto notify_fault; - } + goto notify_fault; + } skip_pbsz: - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_PROT; - goto redo; + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_PROT; + goto redo; case GLOBUS_FTP_CLIENT_TARGET_SETUP_PROT: - target->state = GLOBUS_FTP_CLIENT_TARGET_PROT; - - if(target->dcau.mode == GLOBUS_FTP_CONTROL_DCAU_NONE) - { - goto skip_prot; - } - if(target->attr->data_prot == target->data_prot) - { - goto skip_prot; - } - /* changing PROT forces us to trash our old data connections [true?] */ - memset(&target->cached_data_conn, - '\0', - sizeof(globus_i_ftp_client_data_target_t)); - - target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_TRANSFER_PARAMETERS; - globus_i_ftp_client_plugin_notify_command( - client_handle, - target->url_string, - target->mask, - "PROT %c" CRLF, - (char) target->attr->data_prot); - - if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) - { - break; - } - - globus_assert( - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); - - result = globus_ftp_control_send_command( - target->control_handle, - "PROT %c" CRLF, - globus_i_ftp_client_response_callback, - target, - (char) target->attr->data_prot); - - if(result != GLOBUS_SUCCESS) - { - goto result_fault; - } - - break; + target->state = GLOBUS_FTP_CLIENT_TARGET_PROT; + + if(target->dcau.mode == GLOBUS_FTP_CONTROL_DCAU_NONE) + { + goto skip_prot; + } + if(target->attr->data_prot == target->data_prot) + { + goto skip_prot; + } + /* changing PROT forces us to trash our old data connections [true?] */ + memset(&target->cached_data_conn, + '\0', + sizeof(globus_i_ftp_client_data_target_t)); + + target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_TRANSFER_PARAMETERS; + globus_i_ftp_client_plugin_notify_command( + client_handle, + target->url_string, + target->mask, + "PROT %c" CRLF, + (char) target->attr->data_prot); + + if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) + { + break; + } + + globus_assert( + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); + + result = globus_ftp_control_send_command( + target->control_handle, + "PROT %c" CRLF, + globus_i_ftp_client_response_callback, + target, + (char) target->attr->data_prot); + + if(result != GLOBUS_SUCCESS) + { + goto result_fault; + } + + break; case GLOBUS_FTP_CLIENT_TARGET_PROT: - globus_assert( - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); - - if((!error) && - response->response_class == GLOBUS_FTP_POSITIVE_COMPLETION_REPLY) - { - target->data_prot = target->attr->data_prot; - - result = globus_ftp_control_local_prot(target->control_handle, - target->data_prot); - if(result != GLOBUS_SUCCESS) - { - goto result_fault; - } - } - else - { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; - - goto notify_fault; - } + globus_assert( + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); + + if((!error) && + response->response_class == GLOBUS_FTP_POSITIVE_COMPLETION_REPLY) + { + target->data_prot = target->attr->data_prot; + + result = globus_ftp_control_local_prot(target->control_handle, + target->data_prot); + if(result != GLOBUS_SUCCESS) + { + goto result_fault; + } + } + else + { + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; + + goto notify_fault; + } skip_prot: - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; - goto redo; + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; + goto redo; case GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION: - /* for operations which don't use a data connection, - * skip PASV/PORT */ - if(client_handle->op == GLOBUS_FTP_CLIENT_CHMOD) - { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CHMOD; - } + /* for operations which don't use a data connection, + * skip PASV/PORT */ + if(client_handle->op == GLOBUS_FTP_CLIENT_CHMOD) + { + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CHMOD; + } else if(client_handle->op == GLOBUS_FTP_CLIENT_CHGRP) { target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CHGRP; @@ -2218,39 +2218,39 @@ globus_i_ftp_client_response_callback( { target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_SYMLINK; } - else if(client_handle->op == GLOBUS_FTP_CLIENT_DELETE) - { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_DELETE; - } - else if(client_handle->op == GLOBUS_FTP_CLIENT_MKDIR) - { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_MKDIR; - } - else if(client_handle->op == GLOBUS_FTP_CLIENT_RMDIR) - { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_RMDIR; - } - else if(client_handle->op == GLOBUS_FTP_CLIENT_CWD) - { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CWD; - } - else if(client_handle->op == GLOBUS_FTP_CLIENT_MOVE) - { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_RNFR; - } - else if(client_handle->op == GLOBUS_FTP_CLIENT_MDTM) - { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_MDTM; - } - else if(client_handle->op == GLOBUS_FTP_CLIENT_MLST) - { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_MLST; - } - else if(client_handle->op == GLOBUS_FTP_CLIENT_STAT) - { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_STAT; - } - else if(client_handle->op == GLOBUS_FTP_CLIENT_TRANSFER && + else if(client_handle->op == GLOBUS_FTP_CLIENT_DELETE) + { + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_DELETE; + } + else if(client_handle->op == GLOBUS_FTP_CLIENT_MKDIR) + { + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_MKDIR; + } + else if(client_handle->op == GLOBUS_FTP_CLIENT_RMDIR) + { + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_RMDIR; + } + else if(client_handle->op == GLOBUS_FTP_CLIENT_CWD) + { + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CWD; + } + else if(client_handle->op == GLOBUS_FTP_CLIENT_MOVE) + { + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_RNFR; + } + else if(client_handle->op == GLOBUS_FTP_CLIENT_MDTM) + { + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_MDTM; + } + else if(client_handle->op == GLOBUS_FTP_CLIENT_MLST) + { + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_MLST; + } + else if(client_handle->op == GLOBUS_FTP_CLIENT_STAT) + { + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_STAT; + } + else if(client_handle->op == GLOBUS_FTP_CLIENT_TRANSFER && target == client_handle->source && client_handle->dest && client_handle->dest->state == GLOBUS_FTP_CLIENT_TARGET_SETUP_PASV) { @@ -2263,7 +2263,7 @@ globus_i_ftp_client_response_callback( } /* defaulting to a PASV on the source */ - else if(client_handle->source_pasv && + else if(client_handle->source_pasv && target->mode != GLOBUS_FTP_CONTROL_MODE_EXTENDED_BLOCK) { if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION) @@ -2272,16 +2272,16 @@ globus_i_ftp_client_response_callback( target == client_handle->dest && !client_handle->num_pasv_addresses) { target = client_handle->source; - + error = globus_i_ftp_client_target_activate( client_handle, target, ®istered); - if(registered == GLOBUS_FALSE && + if(registered == GLOBUS_FALSE && client_handle->state != GLOBUS_FTP_CLIENT_HANDLE_ABORT && client_handle->state != GLOBUS_FTP_CLIENT_HANDLE_RESTART) { goto connection_error; } - + break; } else @@ -2289,31 +2289,31 @@ globus_i_ftp_client_response_callback( target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_PORT; } } - + if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION) { target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_PASV; } } - /* Prefer PASV data connections for stream client/server operations */ + /* Prefer PASV data connections for stream client/server operations */ /* unless asked not to via GLOBUS_FTP_CLIENT_NO_SERVER_PASV env var */ - else if(client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION || - (client_handle->op != GLOBUS_FTP_CLIENT_TRANSFER && - target->mode == GLOBUS_FTP_CONTROL_MODE_STREAM && + else if(client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION || + (client_handle->op != GLOBUS_FTP_CLIENT_TRANSFER && + target->mode == GLOBUS_FTP_CONTROL_MODE_STREAM && !getenv("GLOBUS_FTP_CLIENT_NO_SERVER_PASV"))) - { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_PASV; - } - /* In extended block mode, we MUST have RETR/LIST in PORT mode */ - else - { - globus_assert(client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION); - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_PORT; - } - - goto redo; + { + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_PASV; + } + /* In extended block mode, we MUST have RETR/LIST in PORT mode */ + else + { + globus_assert(client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION); + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_PORT; + } + + goto redo; case GLOBUS_FTP_CLIENT_TARGET_OPTS_PASV_DELAYED: globus_assert( @@ -2327,13 +2327,13 @@ globus_i_ftp_client_response_callback( { target->delayed_pasv = target->attr->delayed_pasv; target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_PASV; - + goto redo; } /* XXX need to ignore error */ - + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; - goto notify_fault; + goto notify_fault; case GLOBUS_FTP_CLIENT_TARGET_SETUP_PASV: if(gridftp2_getput == GLOBUS_TRUE) @@ -2341,17 +2341,17 @@ globus_i_ftp_client_response_callback( goto skip_pasv; } - if(globus_i_ftp_client_can_reuse_data_conn(client_handle)) - { - goto skip_pasv; - } - - if(target->delayed_pasv != target->attr->delayed_pasv && - globus_i_ftp_client_feature_get(target->features, + if(globus_i_ftp_client_can_reuse_data_conn(client_handle)) + { + goto skip_pasv; + } + + if(target->delayed_pasv != target->attr->delayed_pasv && + globus_i_ftp_client_feature_get(target->features, GLOBUS_FTP_CLIENT_FEATURE_DELAYED_PASV) == GLOBUS_FTP_CLIENT_TRUE) { - target->state = GLOBUS_FTP_CLIENT_TARGET_OPTS_PASV_DELAYED; - + target->state = GLOBUS_FTP_CLIENT_TARGET_OPTS_PASV_DELAYED; + target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_TRANSFER_PARAMETERS; globus_i_ftp_client_plugin_notify_command( client_handle, @@ -2359,7 +2359,7 @@ globus_i_ftp_client_response_callback( target->mask, "OPTS PASV AllowDelayed=%c;" CRLF, target->attr->delayed_pasv ? '1' : '0'); - + if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) @@ -2371,7 +2371,7 @@ globus_i_ftp_client_response_callback( GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); - + result = globus_ftp_control_send_command( target->control_handle, @@ -2379,67 +2379,67 @@ globus_i_ftp_client_response_callback( globus_i_ftp_client_response_callback, target, target->attr->delayed_pasv ? '1' : '0'); - + if(result != GLOBUS_SUCCESS) { goto result_fault; } - + break; } - if((client_handle->op == GLOBUS_FTP_CLIENT_PUT || - client_handle->op == GLOBUS_FTP_CLIENT_TRANSFER) && - (target->attr->layout.mode != GLOBUS_FTP_CONTROL_STRIPING_NONE || - target->attr->force_striped)) - { - if(target->attr->allow_ipv6) - { - tmpstr = "SPAS 2"; - } - else - { - tmpstr = "SPAS"; - } - } - else if(target->attr->allow_ipv6) - { + if((client_handle->op == GLOBUS_FTP_CLIENT_PUT || + client_handle->op == GLOBUS_FTP_CLIENT_TRANSFER) && + (target->attr->layout.mode != GLOBUS_FTP_CONTROL_STRIPING_NONE || + target->attr->force_striped)) + { + if(target->attr->allow_ipv6) + { + tmpstr = "SPAS 2"; + } + else + { + tmpstr = "SPAS"; + } + } + else if(target->attr->allow_ipv6) + { /* if ipv6 is enabled, ensure we connected to an ipv6 addressed - * source before using EPSV. otherwise, if dest connected on a - * v6 interface we won't have a compatible data address to pass + * source before using EPSV. otherwise, if dest connected on a + * v6 interface we won't have a compatible data address to pass * to the source via eprt/port. - */ - if(client_handle->op == GLOBUS_FTP_CLIENT_TRANSFER && - client_handle->source && target == client_handle->dest) + */ + if(client_handle->op == GLOBUS_FTP_CLIENT_TRANSFER && + client_handle->source && target == client_handle->dest) { globus_ftp_control_host_port_t * host_port; - - /* if source hasn't connected yet, activate it */ - if(client_handle->source->state == GLOBUS_FTP_CLIENT_TARGET_START || + + /* if source hasn't connected yet, activate it */ + if(client_handle->source->state == GLOBUS_FTP_CLIENT_TARGET_START || client_handle->source->state == GLOBUS_FTP_CLIENT_TARGET_CLOSED) { target = client_handle->source; - + error = globus_i_ftp_client_target_activate( client_handle, target, ®istered); - if(registered == GLOBUS_FALSE && + if(registered == GLOBUS_FALSE && client_handle->state != GLOBUS_FTP_CLIENT_HANDLE_ABORT && client_handle->state != GLOBUS_FTP_CLIENT_HANDLE_RESTART) { goto connection_error; } - + break; } host_port = globus_libc_calloc( 1, sizeof(globus_ftp_control_host_port_t)); - + result = globus_ftp_control_client_get_connection_info_ex( client_handle->source->control_handle, - GLOBUS_NULL, + GLOBUS_NULL, host_port); - /* v4mapped addresses can return an error, but we will + /* v4mapped addresses can return an error, but we will correctly use PASV in that case */ if(result == GLOBUS_SUCCESS && host_port->hostlen == 16) { @@ -2455,79 +2455,79 @@ globus_i_ftp_client_response_callback( { tmpstr = "EPSV"; } - } - else - { - tmpstr = "PASV"; - } - - target->state = GLOBUS_FTP_CLIENT_TARGET_PASV; - - target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_DATA_ESTABLISHMENT; - globus_i_ftp_client_plugin_notify_command( - client_handle, - target->url_string, - target->mask, - "%s" CRLF, - tmpstr); - - if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) - { - break; - } - globus_assert( - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); - - result = - globus_ftp_control_send_command( - target->control_handle, - "%s" CRLF, - globus_i_ftp_client_response_callback, - target, - tmpstr); - - if(result != GLOBUS_SUCCESS) - { - goto result_fault; - } - - break; + } + else + { + tmpstr = "PASV"; + } + + target->state = GLOBUS_FTP_CLIENT_TARGET_PASV; + + target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_DATA_ESTABLISHMENT; + globus_i_ftp_client_plugin_notify_command( + client_handle, + target->url_string, + target->mask, + "%s" CRLF, + tmpstr); + + if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) + { + break; + } + globus_assert( + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); + + result = + globus_ftp_control_send_command( + target->control_handle, + "%s" CRLF, + globus_i_ftp_client_response_callback, + target, + tmpstr); + + if(result != GLOBUS_SUCCESS) + { + goto result_fault; + } + + break; case GLOBUS_FTP_CLIENT_TARGET_SETUP_PORT: - if(globus_i_ftp_client_can_reuse_data_conn(client_handle)) - { - goto skip_port; - } - - /* turn off delayed pasv now that we're going to use PORT */ - target->delayed_pasv = GLOBUS_FALSE; - - if(client_handle->op != GLOBUS_FTP_CLIENT_TRANSFER) - { - if(client_handle->pasv_address) - { - globus_free(client_handle->pasv_address); - } - client_handle->pasv_address = - globus_libc_malloc(sizeof(globus_ftp_control_host_port_t)); - client_handle->num_pasv_addresses = 1; - - memset(client_handle->pasv_address, 0, - sizeof(globus_ftp_control_host_port_t)); - - result = globus_ftp_control_local_pasv(target->control_handle, - client_handle->pasv_address); + if(globus_i_ftp_client_can_reuse_data_conn(client_handle)) + { + goto skip_port; + } + + /* turn off delayed pasv now that we're going to use PORT */ + target->delayed_pasv = GLOBUS_FALSE; + + if(client_handle->op != GLOBUS_FTP_CLIENT_TRANSFER) + { + if(client_handle->pasv_address) + { + globus_free(client_handle->pasv_address); + } + client_handle->pasv_address = + globus_libc_malloc(sizeof(globus_ftp_control_host_port_t)); + client_handle->num_pasv_addresses = 1; + + memset(client_handle->pasv_address, 0, + sizeof(globus_ftp_control_host_port_t)); + + result = globus_ftp_control_local_pasv(target->control_handle, + client_handle->pasv_address); if(result == GLOBUS_SUCCESS && !target->attr->allow_ipv6 && client_handle->pasv_address[0].hostlen == 16) { char * cs; globus_sockaddr_t addr; - + /* control channel was made with ipv6, but we must have * disabled ipv6 since and need an ipv4 address now. * just use localhost @@ -2535,7 +2535,7 @@ globus_i_ftp_client_response_callback( GlobusLibcSockaddrSetFamily(addr, AF_INET); GlobusLibcSockaddrSetPort(addr, client_handle->pasv_address[0].port); - + result = globus_libc_addr_to_contact_string( &addr, GLOBUS_LIBC_ADDR_LOCAL | GLOBUS_LIBC_ADDR_NUMERIC | @@ -2550,75 +2550,75 @@ globus_i_ftp_client_response_callback( &client_handle->pasv_address[0].port); } } - - if(result != GLOBUS_SUCCESS) - { - goto result_fault; - } - } + + if(result != GLOBUS_SUCCESS) + { + goto result_fault; + } + } if(gridftp2_getput == GLOBUS_TRUE) { goto skip_port; } - tmpstr = globus_libc_malloc(56 * client_handle->num_pasv_addresses - + 7 /*SPOR|PORT|EPRT\r\n\0*/); - /* ' |2|<45>|<5>|' == 56 */ - if(tmpstr == GLOBUS_NULL) - { - error = GLOBUS_ERROR_NO_INFO; - - goto notify_fault; - } - else - { - rc = oldrc = 0; - if(client_handle->num_pasv_addresses == 1) - { - if(target->attr->allow_ipv6 && - client_handle->pasv_address[0].hostlen == 16) - { - rc += sprintf(tmpstr, "EPRT"); - } - else - { - rc += sprintf(tmpstr, "PORT"); - } - } - else - { - rc += sprintf(tmpstr, "SPOR"); - } - - if(rc == oldrc) - { - error = GLOBUS_ERROR_NO_INFO; - - goto notify_fault; - } - - for(i = 0; i < client_handle->num_pasv_addresses; i++) - { - oldrc = rc; - if(target->attr->allow_ipv6 && - (client_handle->num_pasv_addresses > 1 || - client_handle->pasv_address[0].hostlen == 16)) - { - char buf[50]; - - globus_ftp_control_host_port_get_host( + tmpstr = globus_libc_malloc(56 * client_handle->num_pasv_addresses + + 7 /*SPOR|PORT|EPRT\r\n\0*/); + /* ' |2|<45>|<5>|' == 56 */ + if(tmpstr == GLOBUS_NULL) + { + error = GLOBUS_ERROR_NO_INFO; + + goto notify_fault; + } + else + { + rc = oldrc = 0; + if(client_handle->num_pasv_addresses == 1) + { + if(target->attr->allow_ipv6 && + client_handle->pasv_address[0].hostlen == 16) + { + rc += sprintf(tmpstr, "EPRT"); + } + else + { + rc += sprintf(tmpstr, "PORT"); + } + } + else + { + rc += sprintf(tmpstr, "SPOR"); + } + + if(rc == oldrc) + { + error = GLOBUS_ERROR_NO_INFO; + + goto notify_fault; + } + + for(i = 0; i < client_handle->num_pasv_addresses; i++) + { + oldrc = rc; + if(target->attr->allow_ipv6 && + (client_handle->num_pasv_addresses > 1 || + client_handle->pasv_address[0].hostlen == 16)) + { + char buf[50]; + + globus_ftp_control_host_port_get_host( &client_handle->pasv_address[i], buf); - - rc += sprintf(&tmpstr[oldrc], + + rc += sprintf(&tmpstr[oldrc], " |%d|%s|%d|", client_handle->pasv_address[i].hostlen == 16 ? 2 : 1, buf, (int) client_handle->pasv_address[i].port); - } - else - { + } + else + { rc += sprintf(&tmpstr[oldrc], " %d,%d,%d,%d,%d,%d", client_handle->pasv_address[i].host[0], @@ -2635,490 +2635,490 @@ globus_i_ftp_client_response_callback( goto notify_fault; } - } - - target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_DATA_ESTABLISHMENT; - globus_i_ftp_client_plugin_notify_command( - client_handle, - target->url_string, - target->mask, - "%s" CRLF, - tmpstr); - - if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) - { - globus_libc_free(tmpstr); - break; - } - globus_assert( client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); - - target->state = GLOBUS_FTP_CLIENT_TARGET_PORT; - - result = - globus_ftp_control_send_command( - target->control_handle, - "%s" CRLF, - globus_i_ftp_client_response_callback, - target, - tmpstr); - - globus_libc_free(tmpstr); - } - - if(result != GLOBUS_SUCCESS) - { - goto result_fault; - } - - break; + } + + target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_DATA_ESTABLISHMENT; + globus_i_ftp_client_plugin_notify_command( + client_handle, + target->url_string, + target->mask, + "%s" CRLF, + tmpstr); + + if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) + { + globus_libc_free(tmpstr); + break; + } + globus_assert( client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); + + target->state = GLOBUS_FTP_CLIENT_TARGET_PORT; + + result = + globus_ftp_control_send_command( + target->control_handle, + "%s" CRLF, + globus_i_ftp_client_response_callback, + target, + tmpstr); + + globus_libc_free(tmpstr); + } + + if(result != GLOBUS_SUCCESS) + { + goto result_fault; + } + + break; case GLOBUS_FTP_CLIENT_TARGET_PASV: - globus_assert( - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); - - if((!error) && - response->response_class == GLOBUS_FTP_POSITIVE_COMPLETION_REPLY) - { - if(target->delayed_pasv) - { - goto skip_pasv; - } - - globus_l_ftp_client_parse_pasv( - handle, - response, - &client_handle->pasv_address, - &client_handle->num_pasv_addresses); - - if(client_handle->op != GLOBUS_FTP_CLIENT_TRANSFER) - { - - if(client_handle->num_pasv_addresses == 1) - { - result = - globus_ftp_control_local_port( - handle, - client_handle->pasv_address); - } - else - { - result = - globus_ftp_control_local_spor( - handle, - client_handle->pasv_address, - client_handle->num_pasv_addresses); - } - if(result != GLOBUS_SUCCESS) - { - goto result_fault; - } - } - - /* Store the current data connection in the cache for - * the target associated with this transfer, if the server - * will support it. - */ - if(globus_l_ftp_client_can_cache_data_connection(target)) - { + globus_assert( + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); + + if((!error) && + response->response_class == GLOBUS_FTP_POSITIVE_COMPLETION_REPLY) + { + if(target->delayed_pasv) + { + goto skip_pasv; + } + + globus_l_ftp_client_parse_pasv( + handle, + response, + &client_handle->pasv_address, + &client_handle->num_pasv_addresses); + + if(client_handle->op != GLOBUS_FTP_CLIENT_TRANSFER) + { + + if(client_handle->num_pasv_addresses == 1) + { + result = + globus_ftp_control_local_port( + handle, + client_handle->pasv_address); + } + else + { + result = + globus_ftp_control_local_spor( + handle, + client_handle->pasv_address, + client_handle->num_pasv_addresses); + } + if(result != GLOBUS_SUCCESS) + { + goto result_fault; + } + } + + /* Store the current data connection in the cache for + * the target associated with this transfer, if the server + * will support it. + */ + if(globus_l_ftp_client_can_cache_data_connection(target)) + { if(client_handle->op == GLOBUS_FTP_CLIENT_LIST || client_handle->op == GLOBUS_FTP_CLIENT_NLST || client_handle->op == GLOBUS_FTP_CLIENT_MLSD || client_handle->op == GLOBUS_FTP_CLIENT_MLSR) { - target->cached_data_conn.operation = GLOBUS_FTP_CLIENT_GET; + target->cached_data_conn.operation = GLOBUS_FTP_CLIENT_GET; } else { target->cached_data_conn.operation = client_handle->op; } - - target->cached_data_conn.source = client_handle->source; - target->cached_data_conn.dest = client_handle->dest; - } - /* In a 3rd party transfer, we need to clear the peer's - * data connection cache if we've called passive on the - * destination server. - */ - if(client_handle->op == GLOBUS_FTP_CLIENT_TRANSFER) - { - memset(&client_handle->source->cached_data_conn, - '\0', - sizeof(globus_i_ftp_client_data_target_t)); - } - - skip_pasv: + + target->cached_data_conn.source = client_handle->source; + target->cached_data_conn.dest = client_handle->dest; + } + /* In a 3rd party transfer, we need to clear the peer's + * data connection cache if we've called passive on the + * destination server. + */ + if(client_handle->op == GLOBUS_FTP_CLIENT_TRANSFER) + { + memset(&client_handle->source->cached_data_conn, + '\0', + sizeof(globus_i_ftp_client_data_target_t)); + } + + skip_pasv: if((client_handle->op == GLOBUS_FTP_CLIENT_PUT || - (client_handle->op == GLOBUS_FTP_CLIENT_TRANSFER && - client_handle->dest == target)) && + (client_handle->op == GLOBUS_FTP_CLIENT_TRANSFER && + client_handle->dest == target)) && target->attr->allocated_size > 0) { target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_ALLO; } - else if(client_handle->restart_marker.type != - GLOBUS_FTP_CLIENT_RESTART_NONE) - { - if(target->mode == GLOBUS_FTP_CONTROL_MODE_STREAM) - { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_REST_STREAM; - } - else - { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_REST_EB; - } - } - else - { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_OPERATION; - } - - /* if this was a source pasv, continue setting up the dest */ + else if(client_handle->restart_marker.type != + GLOBUS_FTP_CLIENT_RESTART_NONE) + { + if(target->mode == GLOBUS_FTP_CONTROL_MODE_STREAM) + { + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_REST_STREAM; + } + else + { + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_REST_EB; + } + } + else + { + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_OPERATION; + } + + /* if this was a source pasv, continue setting up the dest */ if(client_handle->op == GLOBUS_FTP_CLIENT_TRANSFER && target == client_handle->source && !target->delayed_pasv) { target = client_handle->dest; - + error = globus_i_ftp_client_target_activate( client_handle, target, ®istered); - if(registered == GLOBUS_FALSE && + if(registered == GLOBUS_FALSE && client_handle->state != GLOBUS_FTP_CLIENT_HANDLE_ABORT && client_handle->state != GLOBUS_FTP_CLIENT_HANDLE_RESTART) { goto connection_error; } - + break; } - } + } else if(!error) - { + { /* try without ipv6 */ - if(target->attr->allow_ipv6) - { - target->attr->allow_ipv6 = GLOBUS_FALSE; - globus_ftp_control_ipv6_allow(handle, GLOBUS_FALSE); - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_PASV; - } + if(target->attr->allow_ipv6) + { + target->attr->allow_ipv6 = GLOBUS_FALSE; + globus_ftp_control_ipv6_allow(handle, GLOBUS_FALSE); + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_PASV; + } /* Try doing a PORT for a client/server transfer */ - else if(client_handle->op != GLOBUS_FTP_CLIENT_TRANSFER && - target->mode != GLOBUS_FTP_CONTROL_MODE_EXTENDED_BLOCK ) - { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_PORT; - } - /* Try the PASV on the other server for a 3rd party transfer */ - else if(client_handle->op == GLOBUS_FTP_CLIENT_TRANSFER && - target->mode != GLOBUS_FTP_CONTROL_MODE_EXTENDED_BLOCK && - !client_handle->tried_both_pasv) - { + else if(client_handle->op != GLOBUS_FTP_CLIENT_TRANSFER && + target->mode != GLOBUS_FTP_CONTROL_MODE_EXTENDED_BLOCK ) + { + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_PORT; + } + /* Try the PASV on the other server for a 3rd party transfer */ + else if(client_handle->op == GLOBUS_FTP_CLIENT_TRANSFER && + target->mode != GLOBUS_FTP_CONTROL_MODE_EXTENDED_BLOCK && + !client_handle->tried_both_pasv) + { client_handle->tried_both_pasv = GLOBUS_TRUE; target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; client_handle->source_pasv = !client_handle->source_pasv; - target = (target == client_handle->source) ? + target = (target == client_handle->source) ? client_handle->dest : client_handle->source; error = globus_i_ftp_client_target_activate( client_handle, target, ®istered); - if(registered == GLOBUS_FALSE && + if(registered == GLOBUS_FALSE && client_handle->state != GLOBUS_FTP_CLIENT_HANDLE_ABORT && client_handle->state != GLOBUS_FTP_CLIENT_HANDLE_RESTART) { goto connection_error; } - + break; - } - else - { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; - goto notify_fault; - } - } - else - { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; - goto notify_fault; - } - - goto redo; + } + else + { + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; + goto notify_fault; + } + } + else + { + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; + goto notify_fault; + } + + goto redo; case GLOBUS_FTP_CLIENT_TARGET_PORT: - globus_assert( - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); - - if((!error) && - response->response_class == GLOBUS_FTP_POSITIVE_COMPLETION_REPLY) - { - if(globus_l_ftp_client_can_cache_data_connection(target)) - { + globus_assert( + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); + + if((!error) && + response->response_class == GLOBUS_FTP_POSITIVE_COMPLETION_REPLY) + { + if(globus_l_ftp_client_can_cache_data_connection(target)) + { if(client_handle->op == GLOBUS_FTP_CLIENT_LIST || client_handle->op == GLOBUS_FTP_CLIENT_NLST || client_handle->op == GLOBUS_FTP_CLIENT_MLSD || client_handle->op == GLOBUS_FTP_CLIENT_MLSR) { - target->cached_data_conn.operation = GLOBUS_FTP_CLIENT_GET; + target->cached_data_conn.operation = GLOBUS_FTP_CLIENT_GET; + } + else + { + target->cached_data_conn.operation = client_handle->op; + } + + target->cached_data_conn.source = client_handle->source; + target->cached_data_conn.dest = client_handle->dest; + } + + skip_port: + if((client_handle->op == GLOBUS_FTP_CLIENT_PUT || + (client_handle->op == GLOBUS_FTP_CLIENT_TRANSFER && + client_handle->dest == target)) && + target->attr->allocated_size > 0) + { + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_ALLO; + } + else if(client_handle->restart_marker.type != + GLOBUS_FTP_CLIENT_RESTART_NONE) + { + if(target->mode == GLOBUS_FTP_CONTROL_MODE_STREAM) + { + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_REST_STREAM; } else { - target->cached_data_conn.operation = client_handle->op; + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_REST_EB; } - - target->cached_data_conn.source = client_handle->source; - target->cached_data_conn.dest = client_handle->dest; - } - - skip_port: - if((client_handle->op == GLOBUS_FTP_CLIENT_PUT || - (client_handle->op == GLOBUS_FTP_CLIENT_TRANSFER && - client_handle->dest == target)) && - target->attr->allocated_size > 0) + } + else { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_ALLO; + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_OPERATION; } - else if(client_handle->restart_marker.type != - GLOBUS_FTP_CLIENT_RESTART_NONE) - { - if(target->mode == GLOBUS_FTP_CONTROL_MODE_STREAM) - { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_REST_STREAM; - } - else - { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_REST_EB; - } - } - else - { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_OPERATION; - } - } - else if(!error && target->attr->allow_ipv6 && - client_handle->op == GLOBUS_FTP_CLIENT_GET) - { - target->attr->allow_ipv6 = GLOBUS_FALSE; - globus_ftp_control_ipv6_allow(handle, GLOBUS_FALSE); - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_PORT; - } - else - { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; - - goto notify_fault; - } - goto redo; + } + else if(!error && target->attr->allow_ipv6 && + client_handle->op == GLOBUS_FTP_CLIENT_GET) + { + target->attr->allow_ipv6 = GLOBUS_FALSE; + globus_ftp_control_ipv6_allow(handle, GLOBUS_FALSE); + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_PORT; + } + else + { + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; + + goto notify_fault; + } + goto redo; case GLOBUS_FTP_CLIENT_TARGET_SETUP_REST_STREAM: - /* - * REST must be the last thing done on the control connection - * before sending the RETR, STOR, ERET, or ESTO command. - */ - globus_assert( - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); - - if(!globus_i_ftp_client_feature_get( - target->features, - GLOBUS_FTP_CLIENT_FEATURE_REST_STREAM)) - { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; - - goto connection_error; - } - target->state = GLOBUS_FTP_CLIENT_TARGET_REST; - target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_TRANSFER_MODIFIERS; - - globus_i_ftp_client_plugin_notify_command( - client_handle, + /* + * REST must be the last thing done on the control connection + * before sending the RETR, STOR, ERET, or ESTO command. + */ + globus_assert( + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); + + if(!globus_i_ftp_client_feature_get( + target->features, + GLOBUS_FTP_CLIENT_FEATURE_REST_STREAM)) + { + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; + + goto connection_error; + } + target->state = GLOBUS_FTP_CLIENT_TARGET_REST; + target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_TRANSFER_MODIFIERS; + + globus_i_ftp_client_plugin_notify_command( + client_handle, target->url_string, - target->mask, - "REST %" GLOBUS_OFF_T_FORMAT CRLF, - target->type == GLOBUS_FTP_CONTROL_TYPE_ASCII - ? client_handle->restart_marker.stream.ascii_offset - : client_handle->restart_marker.stream.offset); - - if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) - { - break; - } - - globus_assert( - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); - - result = globus_ftp_control_send_command( - handle, - "REST %" GLOBUS_OFF_T_FORMAT CRLF, - globus_i_ftp_client_response_callback, - user_arg, - target->type == GLOBUS_FTP_CONTROL_TYPE_ASCII - ? client_handle->restart_marker.stream.ascii_offset - : client_handle->restart_marker.stream.offset); - if(result != GLOBUS_SUCCESS) - { - goto result_fault; - } - break; - + target->mask, + "REST %" GLOBUS_OFF_T_FORMAT CRLF, + target->type == GLOBUS_FTP_CONTROL_TYPE_ASCII + ? client_handle->restart_marker.stream.ascii_offset + : client_handle->restart_marker.stream.offset); + + if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) + { + break; + } + + globus_assert( + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); + + result = globus_ftp_control_send_command( + handle, + "REST %" GLOBUS_OFF_T_FORMAT CRLF, + globus_i_ftp_client_response_callback, + user_arg, + target->type == GLOBUS_FTP_CONTROL_TYPE_ASCII + ? client_handle->restart_marker.stream.ascii_offset + : client_handle->restart_marker.stream.offset); + if(result != GLOBUS_SUCCESS) + { + goto result_fault; + } + break; + case GLOBUS_FTP_CLIENT_TARGET_SETUP_ALLO: - /* - * ALLO is sent before a STOR, REST or STOR is next. - */ - globus_assert( - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); - - target->state = GLOBUS_FTP_CLIENT_TARGET_ALLO; - target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_TRANSFER_MODIFIERS; - - globus_i_ftp_client_plugin_notify_command( - client_handle, + /* + * ALLO is sent before a STOR, REST or STOR is next. + */ + globus_assert( + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); + + target->state = GLOBUS_FTP_CLIENT_TARGET_ALLO; + target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_TRANSFER_MODIFIERS; + + globus_i_ftp_client_plugin_notify_command( + client_handle, target->url_string, - target->mask, - "ALLO %" GLOBUS_OFF_T_FORMAT CRLF, - target->attr->allocated_size); - - if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) - { - break; - } - - globus_assert( - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); - - result = globus_ftp_control_send_command( - handle, - "ALLO %" GLOBUS_OFF_T_FORMAT CRLF, - globus_i_ftp_client_response_callback, - user_arg, - target->attr->allocated_size); - if(result != GLOBUS_SUCCESS) - { - goto result_fault; - } - break; + target->mask, + "ALLO %" GLOBUS_OFF_T_FORMAT CRLF, + target->attr->allocated_size); + + if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) + { + break; + } + + globus_assert( + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); + + result = globus_ftp_control_send_command( + handle, + "ALLO %" GLOBUS_OFF_T_FORMAT CRLF, + globus_i_ftp_client_response_callback, + user_arg, + target->attr->allocated_size); + if(result != GLOBUS_SUCCESS) + { + goto result_fault; + } + break; case GLOBUS_FTP_CLIENT_TARGET_SETUP_REST_EB: - /* - * REST must be the last thing done on the control connection - * before sending the RETR, STOR, ERET, or ESTO command. - */ - globus_assert( - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); - - globus_ftp_client_restart_marker_to_string( + /* + * REST must be the last thing done on the control connection + * before sending the RETR, STOR, ERET, or ESTO command. + */ + globus_assert( + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); + + globus_ftp_client_restart_marker_to_string( &client_handle->restart_marker, &tmpstr); - if(tmpstr) - { - target->state = GLOBUS_FTP_CLIENT_TARGET_REST; - target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_TRANSFER_MODIFIERS; - - globus_i_ftp_client_plugin_notify_command( - client_handle, - target->url_string, - target->mask, - "REST %s" CRLF, - tmpstr); - - if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) - { - break; - } - - globus_assert( - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); - - result = globus_ftp_control_send_command( - handle, - "REST %s" CRLF, - globus_i_ftp_client_response_callback, - user_arg, - tmpstr); - - globus_libc_free(tmpstr); - } - else - { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_OPERATION; - goto redo; - } - if(result != GLOBUS_SUCCESS) - { - goto result_fault; - } - break; + if(tmpstr) + { + target->state = GLOBUS_FTP_CLIENT_TARGET_REST; + target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_TRANSFER_MODIFIERS; + + globus_i_ftp_client_plugin_notify_command( + client_handle, + target->url_string, + target->mask, + "REST %s" CRLF, + tmpstr); + + if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) + { + break; + } + + globus_assert( + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); + + result = globus_ftp_control_send_command( + handle, + "REST %s" CRLF, + globus_i_ftp_client_response_callback, + user_arg, + tmpstr); + + globus_libc_free(tmpstr); + } + else + { + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_OPERATION; + goto redo; + } + if(result != GLOBUS_SUCCESS) + { + goto result_fault; + } + break; case GLOBUS_FTP_CLIENT_TARGET_REST: - globus_assert( - client_handle->state == + globus_assert( + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); - if((!error) && - response->response_class == GLOBUS_FTP_POSITIVE_INTERMEDIATE_REPLY) - { - if(target->mode == GLOBUS_FTP_CONTROL_MODE_STREAM) - { - globus_i_ftp_client_feature_set( + if((!error) && + response->response_class == GLOBUS_FTP_POSITIVE_INTERMEDIATE_REPLY) + { + if(target->mode == GLOBUS_FTP_CONTROL_MODE_STREAM) + { + globus_i_ftp_client_feature_set( target->features, GLOBUS_FTP_CLIENT_FEATURE_REST_STREAM, GLOBUS_FTP_CLIENT_TRUE); - } - } - else - { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; + } + } + else + { + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; - goto notify_fault; - } + goto notify_fault; + } - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_OPERATION; - goto redo; + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_OPERATION; + goto redo; case GLOBUS_FTP_CLIENT_TARGET_ALLO: - globus_assert( - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); - - if((!error) && - response->response_class == GLOBUS_FTP_POSITIVE_COMPLETION_REPLY) - { - } - else - { - /* Don't think we really care about error response here - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; - - goto notify_fault; - */ - } + globus_assert( + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); + + if((!error) && + response->response_class == GLOBUS_FTP_POSITIVE_COMPLETION_REPLY) + { + } + else + { + /* Don't think we really care about error response here + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; + + goto notify_fault; + */ + } if(client_handle->restart_marker.type != GLOBUS_FTP_CLIENT_RESTART_NONE) { @@ -3135,16 +3135,16 @@ globus_i_ftp_client_response_callback( { target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_OPERATION; } - goto redo; + goto redo; case GLOBUS_FTP_CLIENT_TARGET_SETUP_OPERATION: - switch(client_handle->op) - { - case GLOBUS_FTP_CLIENT_LIST: - case GLOBUS_FTP_CLIENT_NLST: - case GLOBUS_FTP_CLIENT_MLSD: + switch(client_handle->op) + { + case GLOBUS_FTP_CLIENT_LIST: + case GLOBUS_FTP_CLIENT_NLST: + case GLOBUS_FTP_CLIENT_MLSD: case GLOBUS_FTP_CLIENT_MLSR: - if(target->attr->cwd_first) + if(target->attr->cwd_first) { target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_LIST_CWD; } @@ -3152,8 +3152,8 @@ globus_i_ftp_client_response_callback( { target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_LIST; } - goto redo; - case GLOBUS_FTP_CLIENT_GET: + goto redo; + case GLOBUS_FTP_CLIENT_GET: if (gridftp2_getput == GLOBUS_TRUE) { target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_GETPUT_GET; @@ -3163,7 +3163,7 @@ globus_i_ftp_client_response_callback( target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_GET; } goto redo; - case GLOBUS_FTP_CLIENT_PUT: + case GLOBUS_FTP_CLIENT_PUT: if (gridftp2_getput == GLOBUS_TRUE) { target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_GETPUT_PUT; @@ -3172,277 +3172,277 @@ globus_i_ftp_client_response_callback( { target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_PUT; } - goto redo; - case GLOBUS_FTP_CLIENT_TRANSFER: - if(client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION) - { + goto redo; + case GLOBUS_FTP_CLIENT_TRANSFER: + if(client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION) + { target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_TRANSFER_DEST; - } - else - { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_TRANSFER_SOURCE; - } - goto redo; - case GLOBUS_FTP_CLIENT_IDLE: - globus_assert(client_handle->op != GLOBUS_FTP_CLIENT_IDLE); - goto finish; - - default:/* No other states should occur */ - globus_assert(0 && "Unexpected state"); - } + } + else + { + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_TRANSFER_SOURCE; + } + goto redo; + case GLOBUS_FTP_CLIENT_IDLE: + globus_assert(client_handle->op != GLOBUS_FTP_CLIENT_IDLE); + goto finish; + + default:/* No other states should occur */ + globus_assert(0 && "Unexpected state"); + } case GLOBUS_FTP_CLIENT_TARGET_SETUP_LIST_CWD: - /* - * CWD before a listing operation. - */ - globus_assert( - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION); - - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_LIST; - target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_FILE_ACTIONS; - - globus_i_ftp_client_plugin_notify_command( - client_handle, + /* + * CWD before a listing operation. + */ + globus_assert( + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION); + + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_LIST; + target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_FILE_ACTIONS; + + globus_i_ftp_client_plugin_notify_command( + client_handle, target->url_string, - target->mask, - "CWD %s" CRLF, - pathname); - - if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) - { - break; - } - - result = globus_ftp_control_send_command( - handle, - "CWD %s" CRLF, - globus_i_ftp_client_response_callback, - user_arg, - pathname); - if(result != GLOBUS_SUCCESS) - { - goto result_fault; - } - break; + target->mask, + "CWD %s" CRLF, + pathname); + + if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) + { + break; + } + + result = globus_ftp_control_send_command( + handle, + "CWD %s" CRLF, + globus_i_ftp_client_response_callback, + user_arg, + pathname); + if(result != GLOBUS_SUCCESS) + { + goto result_fault; + } + break; case GLOBUS_FTP_CLIENT_TARGET_SETUP_LIST: - globus_assert( - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION); + globus_assert( + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION); + + /* if there is a response before this it is probably from a + CWD or NOOP */ + if(response != NULL) + { + if((!error) && + response->response_class == GLOBUS_FTP_POSITIVE_COMPLETION_REPLY) + { + } + else + { + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; + + goto notify_fault; + } + } + + if(!target->delayed_pasv) + { + result = + globus_ftp_control_data_connect_read(target->control_handle, + GLOBUS_NULL, + GLOBUS_NULL); + } + else + { + result = GLOBUS_SUCCESS; + } + + target->state = GLOBUS_FTP_CLIENT_TARGET_LIST; + + if(result != GLOBUS_SUCCESS) + { + goto result_fault; + } + + client_handle->state = + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_LIST; + + target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_FILE_ACTIONS; + + switch(client_handle->op) + { + case GLOBUS_FTP_CLIENT_LIST: + list_str = "LIST"; + break; + + case GLOBUS_FTP_CLIENT_NLST: + list_str = "NLST"; + break; + + case GLOBUS_FTP_CLIENT_MLSD: + list_str = "MLSD"; + break; + + case GLOBUS_FTP_CLIENT_MLSR: + list_str = "MLSR"; + break; + + default: + globus_assert(0 && "Unexpected list op"); + break; + } + + + globus_i_ftp_client_plugin_notify_command( + client_handle, + target->url_string, + target->mask, + "%s %s" CRLF, + list_str, + target->attr->cwd_first ? "" : pathname); - /* if there is a response before this it is probably from a - CWD or NOOP */ - if(response != NULL) + if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) { - if((!error) && - response->response_class == GLOBUS_FTP_POSITIVE_COMPLETION_REPLY) - { - } - else - { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; - - goto notify_fault; - } + break; } - if(!target->delayed_pasv) + globus_assert(client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_LIST); + + result = + globus_ftp_control_send_command( + handle, + "%s %s" CRLF, + globus_i_ftp_client_response_callback, + user_arg, + list_str, + target->attr->cwd_first ? "" : pathname); + if(result != GLOBUS_SUCCESS) { - result = - globus_ftp_control_data_connect_read(target->control_handle, - GLOBUS_NULL, - GLOBUS_NULL); + goto result_fault; } - else + break; + + case GLOBUS_FTP_CLIENT_TARGET_SETUP_MLST: + + target->state = GLOBUS_FTP_CLIENT_TARGET_NEED_COMPLETE; + + target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_FILE_ACTIONS; + + globus_i_ftp_client_plugin_notify_command( + client_handle, + target->url_string, + target->mask, + "MLST %s" CRLF, + pathname); + + if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) { - result = GLOBUS_SUCCESS; + break; } - - target->state = GLOBUS_FTP_CLIENT_TARGET_LIST; - if(result != GLOBUS_SUCCESS) - { - goto result_fault; - } + globus_assert(client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION); - client_handle->state = - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_LIST; + result = + globus_ftp_control_send_command( + handle, + "MLST %s" CRLF, + globus_i_ftp_client_response_callback, + user_arg, + pathname); - target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_FILE_ACTIONS; + if(result != GLOBUS_SUCCESS) + { + goto result_fault; + } + break; - switch(client_handle->op) - { - case GLOBUS_FTP_CLIENT_LIST: - list_str = "LIST"; - break; + case GLOBUS_FTP_CLIENT_TARGET_SETUP_STAT: - case GLOBUS_FTP_CLIENT_NLST: - list_str = "NLST"; - break; + target->state = GLOBUS_FTP_CLIENT_TARGET_NEED_COMPLETE; - case GLOBUS_FTP_CLIENT_MLSD: - list_str = "MLSD"; - break; + target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_FILE_ACTIONS; - case GLOBUS_FTP_CLIENT_MLSR: - list_str = "MLSR"; - break; - - default: - globus_assert(0 && "Unexpected list op"); - break; - } - - - globus_i_ftp_client_plugin_notify_command( - client_handle, - target->url_string, - target->mask, - "%s %s" CRLF, - list_str, - target->attr->cwd_first ? "" : pathname); - - if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) - { - break; - } - - globus_assert(client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_LIST); - - result = - globus_ftp_control_send_command( - handle, - "%s %s" CRLF, - globus_i_ftp_client_response_callback, - user_arg, - list_str, - target->attr->cwd_first ? "" : pathname); - if(result != GLOBUS_SUCCESS) - { - goto result_fault; - } - break; + globus_i_ftp_client_plugin_notify_command( + client_handle, + target->url_string, + target->mask, + "STAT %s" CRLF, + pathname); - case GLOBUS_FTP_CLIENT_TARGET_SETUP_MLST: + if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) + { + break; + } - target->state = GLOBUS_FTP_CLIENT_TARGET_NEED_COMPLETE; - - target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_FILE_ACTIONS; - - globus_i_ftp_client_plugin_notify_command( - client_handle, - target->url_string, - target->mask, - "MLST %s" CRLF, - pathname); - - if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) - { - break; - } - - globus_assert(client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION); - - result = - globus_ftp_control_send_command( - handle, - "MLST %s" CRLF, - globus_i_ftp_client_response_callback, - user_arg, - pathname); - - if(result != GLOBUS_SUCCESS) - { - goto result_fault; - } - break; + globus_assert(client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION); - case GLOBUS_FTP_CLIENT_TARGET_SETUP_STAT: + result = + globus_ftp_control_send_command( + handle, + "STAT %s" CRLF, + globus_i_ftp_client_response_callback, + user_arg, + pathname); - target->state = GLOBUS_FTP_CLIENT_TARGET_NEED_COMPLETE; - - target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_FILE_ACTIONS; - - globus_i_ftp_client_plugin_notify_command( - client_handle, - target->url_string, - target->mask, - "STAT %s" CRLF, - pathname); - - if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) - { - break; - } - - globus_assert(client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION); - - result = - globus_ftp_control_send_command( - handle, - "STAT %s" CRLF, - globus_i_ftp_client_response_callback, - user_arg, - pathname); - - if(result != GLOBUS_SUCCESS) - { - goto result_fault; - } - break; + if(result != GLOBUS_SUCCESS) + { + goto result_fault; + } + break; case GLOBUS_FTP_CLIENT_TARGET_SETUP_CHMOD: - target->state = GLOBUS_FTP_CLIENT_TARGET_NEED_COMPLETE; - - target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_FILE_ACTIONS; - - globus_i_ftp_client_plugin_notify_command( - client_handle, - target->url_string, - target->mask, - "SITE CHMOD %04o %s" CRLF, - client_handle->chmod_file_mode, - pathname); - - if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) - { - break; - } - - globus_assert(client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION); - - result = - globus_ftp_control_send_command( - handle, - "SITE CHMOD %04o %s" CRLF, - globus_i_ftp_client_response_callback, - user_arg, - client_handle->chmod_file_mode, - pathname); - - if(result != GLOBUS_SUCCESS) - { - goto result_fault; - } - break; - + target->state = GLOBUS_FTP_CLIENT_TARGET_NEED_COMPLETE; + + target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_FILE_ACTIONS; + + globus_i_ftp_client_plugin_notify_command( + client_handle, + target->url_string, + target->mask, + "SITE CHMOD %04o %s" CRLF, + client_handle->chmod_file_mode, + pathname); + + if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) + { + break; + } + + globus_assert(client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION); + + result = + globus_ftp_control_send_command( + handle, + "SITE CHMOD %04o %s" CRLF, + globus_i_ftp_client_response_callback, + user_arg, + client_handle->chmod_file_mode, + pathname); + + if(result != GLOBUS_SUCCESS) + { + goto result_fault; + } + break; + case GLOBUS_FTP_CLIENT_TARGET_SETUP_CHGRP: target->state = GLOBUS_FTP_CLIENT_TARGET_NEED_COMPLETE; @@ -3538,19 +3538,19 @@ globus_i_ftp_client_response_callback( globus_ftp_client_handleattr_t handle_attr; char * encoded_url; int spaces; - + handle_attr = &client_handle->attr; - + target->state = GLOBUS_FTP_CLIENT_TARGET_NEED_COMPLETE; - + target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_FILE_ACTIONS; - + result = globus_ftp_client_handleattr_get_rfc1738_url(&handle_attr, &rfc1738_url); if(result != GLOBUS_SUCCESS) { goto result_fault; } - + if(rfc1738_url==GLOBUS_TRUE) { result = (globus_result_t) globus_url_parse_rfc1738(client_handle->dest_url, &dest_url); @@ -3559,17 +3559,17 @@ globus_i_ftp_client_response_callback( { result = (globus_result_t) globus_url_parse(client_handle->dest_url, &dest_url); } - + if(result != GLOBUS_SUCCESS) { goto result_fault; } - + encoded_url = dest_url.url_path; { char * s; char * d; - + for(s = encoded_url, spaces = 0; *s; ++s) { if(*s == ' ') @@ -3577,7 +3577,7 @@ globus_i_ftp_client_response_callback( ++spaces; } } - + if(spaces) { encoded_url = (char *) globus_malloc(strlen(dest_url.url_path) + (2 * spaces) + 1); @@ -3600,345 +3600,345 @@ globus_i_ftp_client_response_callback( *d = '\0'; } } - + + globus_i_ftp_client_plugin_notify_command( + client_handle, + target->url_string, + target->mask, + "SITE SYMLINK %s %s" CRLF, + encoded_url, + pathname); + + if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) + { + globus_url_destroy(&dest_url); + if (spaces) globus_free(encoded_url); + break; + } + + globus_assert(client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION); + + result = + globus_ftp_control_send_command( + handle, + "SITE SYMLINK %s %s" CRLF, + globus_i_ftp_client_response_callback, + user_arg, + encoded_url, + pathname); + + if (spaces) globus_free(encoded_url); + globus_url_destroy(&dest_url); + + if(result != GLOBUS_SUCCESS) + { + goto result_fault; + } + } + break; + + case GLOBUS_FTP_CLIENT_TARGET_SETUP_DELETE: + + target->state = GLOBUS_FTP_CLIENT_TARGET_NEED_COMPLETE; + + target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_FILE_ACTIONS; + + globus_i_ftp_client_plugin_notify_command( + client_handle, + target->url_string, + target->mask, + "DELE %s" CRLF, + pathname); + + if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) + { + break; + } + + globus_assert(client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION); + + result = + globus_ftp_control_send_command( + handle, + "DELE %s" CRLF, + globus_i_ftp_client_response_callback, + user_arg, + pathname); + + if(result != GLOBUS_SUCCESS) + { + goto result_fault; + } + break; + + case GLOBUS_FTP_CLIENT_TARGET_SETUP_RNFR: + + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_RNTO; + + target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_FILE_ACTIONS; + + globus_i_ftp_client_plugin_notify_command( + client_handle, + target->url_string, + target->mask, + "RNFR %s" CRLF, + pathname); + + if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) + { + break; + } + + globus_assert(client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION); + + result = + globus_ftp_control_send_command( + handle, + "RNFR %s" CRLF, + globus_i_ftp_client_response_callback, + user_arg, + pathname); + + if(result != GLOBUS_SUCCESS) + { + goto result_fault; + } + break; + + case GLOBUS_FTP_CLIENT_TARGET_SETUP_RNTO: + { + globus_url_t dest_url; + globus_bool_t rfc1738_url; + globus_ftp_client_handleattr_t handle_attr; + + handle_attr = &client_handle->attr; + + target->state = GLOBUS_FTP_CLIENT_TARGET_NEED_COMPLETE; + + target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_FILE_ACTIONS; + + result = globus_ftp_client_handleattr_get_rfc1738_url(&handle_attr, + &rfc1738_url); + if(result != GLOBUS_SUCCESS) + { + goto result_fault; + } + + if(rfc1738_url==GLOBUS_TRUE) + { + result = (globus_result_t) globus_url_parse_rfc1738(client_handle->dest_url, + &dest_url); + } + else + { + result = (globus_result_t) globus_url_parse(client_handle->dest_url, + &dest_url); + } + + if(result != GLOBUS_SUCCESS) + { + goto result_fault; + } + globus_i_ftp_client_plugin_notify_command( client_handle, target->url_string, target->mask, - "SITE SYMLINK %s %s" CRLF, - encoded_url, - pathname); - + "RNTO %s" CRLF, + dest_url.url_path); + if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) { globus_url_destroy(&dest_url); - if (spaces) globus_free(encoded_url); break; } - + globus_assert(client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION); - - result = - globus_ftp_control_send_command( - handle, - "SITE SYMLINK %s %s" CRLF, - globus_i_ftp_client_response_callback, - user_arg, - encoded_url, - pathname); - - if (spaces) globus_free(encoded_url); + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION); + + { + result = + globus_ftp_control_send_command( + handle, + "RNTO %s" CRLF, + globus_i_ftp_client_response_callback, + user_arg, + dest_url.url_path); + } + globus_url_destroy(&dest_url); - + if(result != GLOBUS_SUCCESS) { goto result_fault; } + break; } - break; + case GLOBUS_FTP_CLIENT_TARGET_SETUP_MKDIR: - case GLOBUS_FTP_CLIENT_TARGET_SETUP_DELETE: + target->state = GLOBUS_FTP_CLIENT_TARGET_NEED_COMPLETE; - target->state = GLOBUS_FTP_CLIENT_TARGET_NEED_COMPLETE; - - target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_FILE_ACTIONS; - - globus_i_ftp_client_plugin_notify_command( - client_handle, - target->url_string, - target->mask, - "DELE %s" CRLF, - pathname); - - if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) - { - break; - } - - globus_assert(client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION); - - result = - globus_ftp_control_send_command( - handle, - "DELE %s" CRLF, - globus_i_ftp_client_response_callback, - user_arg, - pathname); - - if(result != GLOBUS_SUCCESS) - { - goto result_fault; - } - break; + target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_FILE_ACTIONS; - case GLOBUS_FTP_CLIENT_TARGET_SETUP_RNFR: + globus_i_ftp_client_plugin_notify_command( + client_handle, + target->url_string, + target->mask, + "MKD %s" CRLF, + pathname); - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_RNTO; - - target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_FILE_ACTIONS; - - globus_i_ftp_client_plugin_notify_command( - client_handle, - target->url_string, - target->mask, - "RNFR %s" CRLF, - pathname); - - if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) - { - break; - } - - globus_assert(client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION); - - result = - globus_ftp_control_send_command( - handle, - "RNFR %s" CRLF, - globus_i_ftp_client_response_callback, - user_arg, - pathname); - - if(result != GLOBUS_SUCCESS) - { - goto result_fault; - } - break; + if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) + { + break; + } - case GLOBUS_FTP_CLIENT_TARGET_SETUP_RNTO: - { - globus_url_t dest_url; - globus_bool_t rfc1738_url; - globus_ftp_client_handleattr_t handle_attr; - - handle_attr = &client_handle->attr; - - target->state = GLOBUS_FTP_CLIENT_TARGET_NEED_COMPLETE; - - target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_FILE_ACTIONS; - - result = globus_ftp_client_handleattr_get_rfc1738_url(&handle_attr, - &rfc1738_url); - if(result != GLOBUS_SUCCESS) - { - goto result_fault; - } - - if(rfc1738_url==GLOBUS_TRUE) - { - result = (globus_result_t) globus_url_parse_rfc1738(client_handle->dest_url, - &dest_url); - } - else - { - result = (globus_result_t) globus_url_parse(client_handle->dest_url, - &dest_url); - } + globus_assert(client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION); + + result = + globus_ftp_control_send_command( + handle, + "MKD %s" CRLF, + globus_i_ftp_client_response_callback, + user_arg, + pathname); if(result != GLOBUS_SUCCESS) - { - goto result_fault; - } - - globus_i_ftp_client_plugin_notify_command( - client_handle, - target->url_string, - target->mask, - "RNTO %s" CRLF, - dest_url.url_path); - - if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) - { - globus_url_destroy(&dest_url); - break; - } - - globus_assert(client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION); - - { - result = - globus_ftp_control_send_command( - handle, - "RNTO %s" CRLF, - globus_i_ftp_client_response_callback, - user_arg, - dest_url.url_path); - } + { + goto result_fault; + } + break; - globus_url_destroy(&dest_url); + case GLOBUS_FTP_CLIENT_TARGET_SETUP_RMDIR: - if(result != GLOBUS_SUCCESS) - { - goto result_fault; - } - break; - } - case GLOBUS_FTP_CLIENT_TARGET_SETUP_MKDIR: + target->state = GLOBUS_FTP_CLIENT_TARGET_NEED_COMPLETE; - target->state = GLOBUS_FTP_CLIENT_TARGET_NEED_COMPLETE; - - target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_FILE_ACTIONS; - - globus_i_ftp_client_plugin_notify_command( - client_handle, - target->url_string, - target->mask, - "MKD %s" CRLF, - pathname); - - if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) - { - break; - } - - globus_assert(client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION); - - result = - globus_ftp_control_send_command( - handle, - "MKD %s" CRLF, - globus_i_ftp_client_response_callback, - user_arg, - pathname); - - if(result != GLOBUS_SUCCESS) - { - goto result_fault; - } - break; + target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_FILE_ACTIONS; - case GLOBUS_FTP_CLIENT_TARGET_SETUP_RMDIR: + globus_i_ftp_client_plugin_notify_command( + client_handle, + target->url_string, + target->mask, + "RMD %s" CRLF, + pathname); + + if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) + { + break; + } - target->state = GLOBUS_FTP_CLIENT_TARGET_NEED_COMPLETE; - - target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_FILE_ACTIONS; - - globus_i_ftp_client_plugin_notify_command( - client_handle, - target->url_string, - target->mask, - "RMD %s" CRLF, - pathname); - - if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) - { - break; - } - - globus_assert(client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION); - - result = - globus_ftp_control_send_command( - handle, - "RMD %s" CRLF, - globus_i_ftp_client_response_callback, - user_arg, - pathname); - - if(result != GLOBUS_SUCCESS) - { - goto result_fault; - } - break; + globus_assert(client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION); + + result = + globus_ftp_control_send_command( + handle, + "RMD %s" CRLF, + globus_i_ftp_client_response_callback, + user_arg, + pathname); + + if(result != GLOBUS_SUCCESS) + { + goto result_fault; + } + break; case GLOBUS_FTP_CLIENT_TARGET_SETUP_CWD: - target->state = GLOBUS_FTP_CLIENT_TARGET_NEED_COMPLETE; + target->state = GLOBUS_FTP_CLIENT_TARGET_NEED_COMPLETE; - target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_FILE_ACTIONS; + target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_FILE_ACTIONS; /* - globus_i_ftp_client_plugin_notify_command( - client_handle, - target->url_string, - target->mask, - "MLST %s" CRLF, - pathname); + globus_i_ftp_client_plugin_notify_command( + client_handle, + target->url_string, + target->mask, + "MLST %s" CRLF, + pathname); */ - if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) - { - break; - } - - globus_assert(client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION); - - result = - globus_ftp_control_send_command( - handle, - "CWD %s" CRLF, - globus_i_ftp_client_response_callback, - user_arg, - pathname); - - if(result != GLOBUS_SUCCESS) - { - goto result_fault; - } - break; + if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) + { + break; + } + + globus_assert(client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION); + + result = + globus_ftp_control_send_command( + handle, + "CWD %s" CRLF, + globus_i_ftp_client_response_callback, + user_arg, + pathname); + + if(result != GLOBUS_SUCCESS) + { + goto result_fault; + } + break; case GLOBUS_FTP_CLIENT_TARGET_SETUP_MDTM: - target->state = GLOBUS_FTP_CLIENT_TARGET_NEED_COMPLETE; - - target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_FILE_ACTIONS; - - globus_i_ftp_client_plugin_notify_command( - client_handle, - target->url_string, - target->mask, - "MDTM %s" CRLF, - pathname); - - if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) - { - break; - } - - globus_assert(client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION); - - result = - globus_ftp_control_send_command( - handle, - "MDTM %s" CRLF, - globus_i_ftp_client_response_callback, - user_arg, - pathname); - - if(result != GLOBUS_SUCCESS) - { - goto result_fault; - } - break; + target->state = GLOBUS_FTP_CLIENT_TARGET_NEED_COMPLETE; + + target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_FILE_ACTIONS; + + globus_i_ftp_client_plugin_notify_command( + client_handle, + target->url_string, + target->mask, + "MDTM %s" CRLF, + pathname); + + if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) + { + break; + } + + globus_assert(client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION); + + result = + globus_ftp_control_send_command( + handle, + "MDTM %s" CRLF, + globus_i_ftp_client_response_callback, + user_arg, + pathname); + + if(result != GLOBUS_SUCCESS) + { + goto result_fault; + } + break; case GLOBUS_FTP_CLIENT_TARGET_SETUP_GET: - globus_assert( - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION); + globus_assert( + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION); if(!target->delayed_pasv) { @@ -3952,46 +3952,46 @@ globus_i_ftp_client_response_callback( result = GLOBUS_SUCCESS; } - target->state = GLOBUS_FTP_CLIENT_TARGET_RETR; + target->state = GLOBUS_FTP_CLIENT_TARGET_RETR; - if(result != GLOBUS_SUCCESS) - { - goto result_fault; - } + if(result != GLOBUS_SUCCESS) + { + goto result_fault; + } - client_handle->state = - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_RETR_OR_ERET; + client_handle->state = + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_RETR_OR_ERET; - target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_FILE_ACTIONS; + target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_FILE_ACTIONS; if(target->attr->module_alg_str != GLOBUS_NULL) - { - globus_i_ftp_client_plugin_notify_command( - client_handle, - target->url_string, - target->mask, - "ERET %s %s" CRLF, + { + globus_i_ftp_client_plugin_notify_command( + client_handle, + target->url_string, + target->mask, + "ERET %s %s" CRLF, target->attr->module_alg_str, - pathname); - } - else - { - globus_i_ftp_client_plugin_notify_command( - client_handle, - target->url_string, - target->mask, - "RETR %s" CRLF, - pathname); - } - if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) - { - break; - } - - globus_assert(client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_RETR_OR_ERET); + pathname); + } + else + { + globus_i_ftp_client_plugin_notify_command( + client_handle, + target->url_string, + target->mask, + "RETR %s" CRLF, + pathname); + } + if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) + { + break; + } + + globus_assert(client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_RETR_OR_ERET); if(!0) @@ -4017,7 +4017,7 @@ globus_i_ftp_client_response_callback( user_arg, pathname); } - + if(result != GLOBUS_SUCCESS) { goto result_fault; @@ -4027,12 +4027,12 @@ globus_i_ftp_client_response_callback( if(client_handle->attr.pipeline_callback) { globus_bool_t added = GLOBUS_TRUE; - + while(added) { result = globus_l_ftp_client_pp_src_add( client_handle, - handle, + handle, target, &added); if(result != GLOBUS_SUCCESS) @@ -4044,11 +4044,11 @@ globus_i_ftp_client_response_callback( break; case GLOBUS_FTP_CLIENT_TARGET_SETUP_PUT: - globus_assert( - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); + globus_assert( + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); - if(!target->delayed_pasv) + if(!target->delayed_pasv) { result = globus_ftp_control_data_connect_write(target->control_handle, @@ -4060,47 +4060,47 @@ globus_i_ftp_client_response_callback( result = GLOBUS_SUCCESS; } - target->state = GLOBUS_FTP_CLIENT_TARGET_STOR; + target->state = GLOBUS_FTP_CLIENT_TARGET_STOR; - if(result != GLOBUS_SUCCESS) - { - goto result_fault; - } + if(result != GLOBUS_SUCCESS) + { + goto result_fault; + } - client_handle->state = - GLOBUS_FTP_CLIENT_HANDLE_DEST_STOR_OR_ESTO; + client_handle->state = + GLOBUS_FTP_CLIENT_HANDLE_DEST_STOR_OR_ESTO; - target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_FILE_ACTIONS; + target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_FILE_ACTIONS; - if(target->attr->module_alg_str != GLOBUS_NULL) - { - globus_i_ftp_client_plugin_notify_command( - client_handle, - target->url_string, - target->mask, - "ESTO %s %s" CRLF, + if(target->attr->module_alg_str != GLOBUS_NULL) + { + globus_i_ftp_client_plugin_notify_command( + client_handle, + target->url_string, + target->mask, + "ESTO %s %s" CRLF, target->attr->module_alg_str, - pathname); - } - else - { - globus_i_ftp_client_plugin_notify_command( - client_handle, - target->url_string, - target->mask, - "%s %s" CRLF, - target->attr->append ? "APPE" : "STOR", - pathname); - } - if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) - { - break; - } - - globus_assert(client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_DEST_STOR_OR_ESTO); + pathname); + } + else + { + globus_i_ftp_client_plugin_notify_command( + client_handle, + target->url_string, + target->mask, + "%s %s" CRLF, + target->attr->append ? "APPE" : "STOR", + pathname); + } + if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) + { + break; + } + + globus_assert(client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_DEST_STOR_OR_ESTO); if(!0) { @@ -4144,7 +4144,7 @@ globus_i_ftp_client_response_callback( if(client_handle->attr.pipeline_callback) { globus_bool_t added = GLOBUS_TRUE; - + while(added) { result = globus_l_ftp_client_pp_dst_add( @@ -4159,36 +4159,36 @@ globus_i_ftp_client_response_callback( } } - break; + break; case GLOBUS_FTP_CLIENT_TARGET_SETUP_TRANSFER_DEST: - globus_assert( - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); + globus_assert( + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); - /* The destination is prepared first. We send all - * of the commands we need to, including the STOR - * or ESTO, and then turn our attention to the - * source. - */ - target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_FILE_ACTIONS; + /* The destination is prepared first. We send all + * of the commands we need to, including the STOR + * or ESTO, and then turn our attention to the + * source. + */ + target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_FILE_ACTIONS; if(gridftp2_getput) { - result = + result = globus_l_ftp_client_send_put(target, pathname, GLOBUS_TRUE); if(result != GLOBUS_SUCCESS) { goto result_fault; } - + if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) { break; } - + if(globus_i_ftp_client_can_reuse_data_conn(client_handle)) { /* In this case we do not expect a 127 reply. @@ -4198,7 +4198,7 @@ globus_i_ftp_client_response_callback( else { target->state = GLOBUS_FTP_CLIENT_TARGET_GETPUT_PASV_TRANSFER; - + /* In this case we have to wait for the 127 reply * before we can setup the transfer at the source. */ @@ -4226,19 +4226,19 @@ globus_i_ftp_client_response_callback( "STOR %s" CRLF, pathname); } - + if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) { break; } - + globus_assert(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); - + target->state = GLOBUS_FTP_CLIENT_TARGET_STOR; - + if(target->attr->module_alg_str != GLOBUS_NULL) { result = globus_ftp_control_send_command( @@ -4268,7 +4268,7 @@ globus_i_ftp_client_response_callback( int i; globus_bool_t added = GLOBUS_TRUE; globus_i_ftp_client_url_ent_t * url_ent; - + /* add the one we just sent to the response queue */ url_ent = globus_malloc(sizeof(globus_i_ftp_client_url_ent_t)); url_ent->source_url = NULL; @@ -4279,12 +4279,12 @@ globus_i_ftp_client_response_callback( client_handle->attr.rfc1738_url); globus_fifo_enqueue( &client_handle->dst_response_pending_queue, url_ent); - + client_handle->no_callback_count++; client_handle->attr.pipeline_done = GLOBUS_FALSE; - + for( - i = 0; + i = 0; added && i < client_handle->attr.outstanding_commands; i++) { @@ -4301,7 +4301,7 @@ globus_i_ftp_client_response_callback( } } } - + if(!target->delayed_pasv && !client_handle->source->delayed_pasv) { target = client_handle->source; @@ -4322,34 +4322,34 @@ globus_i_ftp_client_response_callback( } } } - break; + break; case GLOBUS_FTP_CLIENT_TARGET_SETUP_TRANSFER_SOURCE: - globus_assert( - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION); + globus_assert( + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION); - client_handle->state = - GLOBUS_FTP_CLIENT_HANDLE_THIRD_PARTY_TRANSFER; + client_handle->state = + GLOBUS_FTP_CLIENT_HANDLE_THIRD_PARTY_TRANSFER; - target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_FILE_ACTIONS; + target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_FILE_ACTIONS; if(gridftp2_getput) { - result = + result = globus_l_ftp_client_send_get(target, pathname, GLOBUS_FALSE); if(result != GLOBUS_SUCCESS) { goto result_fault; } - + if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) { break; } - + target->state = GLOBUS_FTP_CLIENT_TARGET_RETR; } else @@ -4373,7 +4373,7 @@ globus_i_ftp_client_response_callback( "RETR %s" CRLF, pathname); } - + if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) @@ -4382,9 +4382,9 @@ globus_i_ftp_client_response_callback( } globus_assert(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_THIRD_PARTY_TRANSFER); - + target->state = GLOBUS_FTP_CLIENT_TARGET_RETR; - + if(target->attr->module_alg_str) { result = globus_ftp_control_send_command( @@ -4408,13 +4408,13 @@ globus_i_ftp_client_response_callback( { goto result_fault; } - + if(client_handle->attr.pipeline_callback) { int i; globus_bool_t added = GLOBUS_TRUE; globus_i_ftp_client_url_ent_t * url_ent; - + /* add the one we just sent to the response queue */ url_ent = globus_malloc(sizeof(globus_i_ftp_client_url_ent_t)); url_ent->source_url = globus_libc_strdup(target->url_string); @@ -4425,12 +4425,12 @@ globus_i_ftp_client_response_callback( client_handle->attr.rfc1738_url); globus_fifo_enqueue( &client_handle->src_response_pending_queue, url_ent); - + client_handle->no_callback_count++; client_handle->attr.pipeline_done = GLOBUS_FALSE; - + for( - i = 0; + i = 0; added && i < client_handle->attr.outstanding_commands; i++) { @@ -4446,17 +4446,17 @@ globus_i_ftp_client_response_callback( } } } - + break; case GLOBUS_FTP_CLIENT_TARGET_SETUP_GETPUT_GET: - globus_assert( - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION); + globus_assert( + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION); client_handle->state = GLOBUS_FTP_CLIENT_HANDLE_SOURCE_RETR_OR_ERET; - + if(target->mode == GLOBUS_FTP_CONTROL_MODE_EXTENDED_BLOCK || globus_i_ftp_client_can_reuse_data_conn(client_handle)) { @@ -4488,21 +4488,21 @@ globus_i_ftp_client_response_callback( target->state = GLOBUS_FTP_CLIENT_TARGET_GETPUT_PASV_GET; } - target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_FILE_ACTIONS; - if(target->mode == GLOBUS_FTP_CONTROL_MODE_EXTENDED_BLOCK) + target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_FILE_ACTIONS; + if(target->mode == GLOBUS_FTP_CONTROL_MODE_EXTENDED_BLOCK) { /* In extended block mode, we will be the passive * party. GLOBUS_FTP_CLIENT_TARGET_SETUP_PORT has already * filled in client_handle->pasv_address. */ - result = + result = globus_l_ftp_client_send_get(target, pathname, GLOBUS_FALSE); } else { /* In all other cases we prefer to be active. */ - result = + result = globus_l_ftp_client_send_get(target, pathname, GLOBUS_TRUE); } if(result != GLOBUS_SUCCESS) @@ -4512,9 +4512,9 @@ globus_i_ftp_client_response_callback( break; case GLOBUS_FTP_CLIENT_TARGET_SETUP_GETPUT_PUT: - globus_assert( - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); + globus_assert( + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); client_handle->state = GLOBUS_FTP_CLIENT_HANDLE_DEST_STOR_OR_ESTO; @@ -4539,26 +4539,26 @@ globus_i_ftp_client_response_callback( { target->state = GLOBUS_FTP_CLIENT_TARGET_GETPUT_PASV_PUT; } - - target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_FILE_ACTIONS; + + target->mask = GLOBUS_FTP_CLIENT_CMD_MASK_FILE_ACTIONS; result = globus_l_ftp_client_send_put(target, pathname, GLOBUS_TRUE); if(result != GLOBUS_SUCCESS) { goto result_fault; - } + } break; case GLOBUS_FTP_CLIENT_TARGET_GETPUT_PASV_GET: - if((!error) && - response->code == 127) + if((!error) && + response->code == 127) { /* Setup our side of PASV. */ - globus_l_ftp_client_parse_pasv( - handle, - response, - &client_handle->pasv_address, - &client_handle->num_pasv_addresses); + globus_l_ftp_client_parse_pasv( + handle, + response, + &client_handle->pasv_address, + &client_handle->num_pasv_addresses); if(client_handle->num_pasv_addresses == 1) { @@ -4579,7 +4579,7 @@ globus_i_ftp_client_response_callback( { goto result_fault; } - + /* Create the data connection. */ result = @@ -4590,8 +4590,8 @@ globus_i_ftp_client_response_callback( { goto result_fault; } - - target->state = GLOBUS_FTP_CLIENT_TARGET_RETR; + + target->state = GLOBUS_FTP_CLIENT_TARGET_RETR; } else { @@ -4600,17 +4600,17 @@ globus_i_ftp_client_response_callback( } break; - case GLOBUS_FTP_CLIENT_TARGET_GETPUT_PASV_PUT: - if((!error) && - response->code == 127) + case GLOBUS_FTP_CLIENT_TARGET_GETPUT_PASV_PUT: + if((!error) && + response->code == 127) { /* Setup our side of PASV. */ - globus_l_ftp_client_parse_pasv( - handle, - response, - &client_handle->pasv_address, - &client_handle->num_pasv_addresses); + globus_l_ftp_client_parse_pasv( + handle, + response, + &client_handle->pasv_address, + &client_handle->num_pasv_addresses); if(client_handle->num_pasv_addresses == 1) { @@ -4631,7 +4631,7 @@ globus_i_ftp_client_response_callback( { goto result_fault; } - + /* Create the data connection. */ result = @@ -4642,7 +4642,7 @@ globus_i_ftp_client_response_callback( { goto result_fault; } - + target->state = GLOBUS_FTP_CLIENT_TARGET_STOR; } else @@ -4653,14 +4653,14 @@ globus_i_ftp_client_response_callback( break; case GLOBUS_FTP_CLIENT_TARGET_GETPUT_PASV_TRANSFER: - if((!error) && - response->code == 127) + if((!error) && + response->code == 127) { - globus_l_ftp_client_parse_pasv( - handle, - response, - &client_handle->pasv_address, - &client_handle->num_pasv_addresses); + globus_l_ftp_client_parse_pasv( + handle, + response, + &client_handle->pasv_address, + &client_handle->num_pasv_addresses); /* The passive end of a 3rd party transfer is always the * destination. @@ -4698,39 +4698,39 @@ globus_i_ftp_client_response_callback( case GLOBUS_FTP_CLIENT_TARGET_LIST: case GLOBUS_FTP_CLIENT_TARGET_RETR: case GLOBUS_FTP_CLIENT_TARGET_STOR: - globus_assert( - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_LIST || - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_RETR_OR_ERET || - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_DEST_STOR_OR_ESTO || - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_THIRD_PARTY_TRANSFER || - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_THIRD_PARTY_TRANSFER_ONE_COMPLETE || - (client_handle->op == GLOBUS_FTP_CLIENT_TRANSFER && - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION) || - (client_handle->op == GLOBUS_FTP_CLIENT_TRANSFER && - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_SOURCE_CONNECT) || - (target->delayed_pasv && client_handle->op == GLOBUS_FTP_CLIENT_TRANSFER && - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION)); - - if((!error) && - response->response_class == GLOBUS_FTP_POSITIVE_PRELIMINARY_REPLY) - { - if(response->code == 127 || response->code == 129) - { -/* XXX START copy from GLOBUS_FTP_CLIENT_TARGET_PASV */ + globus_assert( + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_LIST || + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_RETR_OR_ERET || + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_DEST_STOR_OR_ESTO || + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_THIRD_PARTY_TRANSFER || + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_THIRD_PARTY_TRANSFER_ONE_COMPLETE || + (client_handle->op == GLOBUS_FTP_CLIENT_TRANSFER && + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION) || + (client_handle->op == GLOBUS_FTP_CLIENT_TRANSFER && + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_SOURCE_CONNECT) || + (target->delayed_pasv && client_handle->op == GLOBUS_FTP_CLIENT_TRANSFER && + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION)); + + if((!error) && + response->response_class == GLOBUS_FTP_POSITIVE_PRELIMINARY_REPLY) + { + if(response->code == 127 || response->code == 129) + { +/* XXX START copy from GLOBUS_FTP_CLIENT_TARGET_PASV */ globus_l_ftp_client_parse_pasv( handle, - response, - &client_handle->pasv_address, + response, + &client_handle->pasv_address, &client_handle->num_pasv_addresses); - + if(client_handle->op != GLOBUS_FTP_CLIENT_TRANSFER) { - + if(client_handle->num_pasv_addresses == 1) { result = @@ -4751,7 +4751,7 @@ globus_i_ftp_client_response_callback( goto result_fault; } } - + /* Store the current data connection in the cache for * the target associated with this transfer, if the server * will support it. @@ -4769,7 +4769,7 @@ globus_i_ftp_client_response_callback( { target->cached_data_conn.operation = client_handle->op; } - + target->cached_data_conn.source = client_handle->source; target->cached_data_conn.dest = client_handle->dest; } @@ -4782,11 +4782,11 @@ globus_i_ftp_client_response_callback( memset(&client_handle->source->cached_data_conn, '\0', sizeof(globus_i_ftp_client_data_target_t)); - } -/* XXX END copy from GLOBUS_FTP_CLIENT_TARGET_PASV */ + } +/* XXX END copy from GLOBUS_FTP_CLIENT_TARGET_PASV */ } - if((target->delayed_pasv && response->code == 125) || + if((target->delayed_pasv && response->code == 125) || response->code == 127 || response->code == 129) { if(client_handle->op != GLOBUS_FTP_CLIENT_TRANSFER) @@ -4813,9 +4813,9 @@ globus_i_ftp_client_response_callback( } else { - target = (target == client_handle->source) ? + target = (target == client_handle->source) ? client_handle->dest : client_handle->source; - + error = globus_i_ftp_client_target_activate(client_handle, target, @@ -4832,93 +4832,93 @@ globus_i_ftp_client_response_callback( goto connection_error; } } - } - } - - if(response->code == 127 || response->code == 129) + } + } + + if(response->code == 127 || response->code == 129) { break; } - /* - * this should be a "connected" or "using existing - * data connection" response - */ - if(client_handle->op == GLOBUS_FTP_CLIENT_LIST || - client_handle->op == GLOBUS_FTP_CLIENT_NLST || - client_handle->op == GLOBUS_FTP_CLIENT_MLSD || + /* + * this should be a "connected" or "using existing + * data connection" response + */ + if(client_handle->op == GLOBUS_FTP_CLIENT_LIST || + client_handle->op == GLOBUS_FTP_CLIENT_NLST || + client_handle->op == GLOBUS_FTP_CLIENT_MLSD || client_handle->op == GLOBUS_FTP_CLIENT_MLSR || - client_handle->op == GLOBUS_FTP_CLIENT_GET || - client_handle->op == GLOBUS_FTP_CLIENT_PUT) - { - target->state = - GLOBUS_FTP_CLIENT_TARGET_READY_FOR_DATA; - - error = - globus_i_ftp_client_data_dispatch_queue(client_handle); - - if(error != GLOBUS_SUCCESS) - { - globus_i_ftp_client_plugin_notify_fault( - client_handle, - target->url_string, - error); - + client_handle->op == GLOBUS_FTP_CLIENT_GET || + client_handle->op == GLOBUS_FTP_CLIENT_PUT) + { + target->state = + GLOBUS_FTP_CLIENT_TARGET_READY_FOR_DATA; + + error = + globus_i_ftp_client_data_dispatch_queue(client_handle); + + if(error != GLOBUS_SUCCESS) + { + globus_i_ftp_client_plugin_notify_fault( + client_handle, + target->url_string, + error); + if(client_handle->err) { - globus_object_free(error); + globus_object_free(error); error = NULL; - } - else - { - client_handle->err = error; - error = GLOBUS_NULL; - } - - if(client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_ABORT || - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_RESTART || - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_FAILURE) - { - break; - } - globus_assert( - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_LIST || - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_DEST_STOR_OR_ESTO || - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_RETR_OR_ERET); - - client_handle->state = GLOBUS_FTP_CLIENT_HANDLE_FAILURE; - target->state = GLOBUS_FTP_CLIENT_TARGET_FAULT; - globus_ftp_control_force_close( - target->control_handle, - globus_i_ftp_client_force_close_callback, - target); - } - } - else - { - /* performance or restart markers are ok for 3rd party */ - if(response->code == 111) - { - globus_l_ftp_client_parse_restart_marker(client_handle, - response); - } - } - } - else if((!error) && - response->response_class - == GLOBUS_FTP_POSITIVE_COMPLETION_REPLY) - { + } + else + { + client_handle->err = error; + error = GLOBUS_NULL; + } + + if(client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_ABORT || + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_RESTART || + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_FAILURE) + { + break; + } + globus_assert( + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_LIST || + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_DEST_STOR_OR_ESTO || + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_RETR_OR_ERET); + + client_handle->state = GLOBUS_FTP_CLIENT_HANDLE_FAILURE; + target->state = GLOBUS_FTP_CLIENT_TARGET_FAULT; + globus_ftp_control_force_close( + target->control_handle, + globus_i_ftp_client_force_close_callback, + target); + } + } + else + { + /* performance or restart markers are ok for 3rd party */ + if(response->code == 111) + { + globus_l_ftp_client_parse_restart_marker(client_handle, + response); + } + } + } + else if((!error) && + response->response_class + == GLOBUS_FTP_POSITIVE_COMPLETION_REPLY) + { if(client_handle->attr.pipeline_callback) - { + { globus_i_ftp_client_url_ent_t * url_ent = NULL; globus_bool_t added = GLOBUS_FALSE; - + client_handle->no_callback_count--; if(target == client_handle->source) { @@ -4939,8 +4939,8 @@ globus_i_ftp_client_response_callback( client_handle->source_url = url_ent->source_url; globus_url_destroy(&url_ent->src_url); globus_free(url_ent); - - target->state = GLOBUS_FTP_CLIENT_TARGET_RETR; + + target->state = GLOBUS_FTP_CLIENT_TARGET_RETR; } else if(target == client_handle->dest) { @@ -4961,24 +4961,24 @@ globus_i_ftp_client_response_callback( client_handle->dest_url = url_ent->dest_url; globus_url_destroy(&url_ent->dst_url); globus_free(url_ent); - + target->state = GLOBUS_FTP_CLIENT_TARGET_STOR; } } - if(client_handle->state == + if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_THIRD_PARTY_TRANSFER) - { + { client_handle->state = GLOBUS_FTP_CLIENT_HANDLE_THIRD_PARTY_TRANSFER_ONE_COMPLETE; } - else if(client_handle->state == + else if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_THIRD_PARTY_TRANSFER_ONE_COMPLETE) - { + { if(client_handle->no_callback_count == 0) { - client_handle->source->state = + client_handle->source->state = GLOBUS_FTP_CLIENT_TARGET_COMPLETED_OPERATION; - client_handle->dest->state = + client_handle->dest->state = GLOBUS_FTP_CLIENT_TARGET_COMPLETED_OPERATION; globus_i_ftp_client_transfer_complete(client_handle); @@ -4989,113 +4989,113 @@ globus_i_ftp_client_response_callback( { goto finish; } - } - else - { - /* this shouldnt really be possible, but handle it */ - target->state = GLOBUS_FTP_CLIENT_TARGET_NEED_COMPLETE; - globus_i_ftp_client_data_flush(client_handle); - memset(&target->cached_data_conn, + } + else + { + /* this shouldnt really be possible, but handle it */ + target->state = GLOBUS_FTP_CLIENT_TARGET_NEED_COMPLETE; + globus_i_ftp_client_data_flush(client_handle); + memset(&target->cached_data_conn, '\0', sizeof(globus_i_ftp_client_data_target_t)); globus_ftp_control_data_force_close( - target->control_handle, - globus_l_ftp_client_data_force_close_callback, - GLOBUS_NULL); - goto redo; - } - } - else - { - if((!client_handle->err) && (!error)) - { - client_handle->err = - GLOBUS_I_FTP_CLIENT_ERROR_RESPONSE(response); - - globus_ftp_control_data_force_close( - target->control_handle, - globus_l_ftp_client_data_force_close_callback, - GLOBUS_NULL); - } - else if(!client_handle->err) - { - client_handle->err = globus_object_copy(error); - } - globus_i_ftp_client_plugin_notify_fault( - client_handle, - target->url_string, - client_handle->err); - - if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) - { - break; - } - - globus_assert( - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_LIST || - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_RETR_OR_ERET || - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_DEST_STOR_OR_ESTO || - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_THIRD_PARTY_TRANSFER || - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_THIRD_PARTY_TRANSFER_ONE_COMPLETE || - (client_handle->op == GLOBUS_FTP_CLIENT_TRANSFER && - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION) || - (client_handle->op == GLOBUS_FTP_CLIENT_TRANSFER && - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_CONNECT) || - (target->delayed_pasv && client_handle->op == GLOBUS_FTP_CLIENT_TRANSFER && + target->control_handle, + globus_l_ftp_client_data_force_close_callback, + GLOBUS_NULL); + goto redo; + } + } + else + { + if((!client_handle->err) && (!error)) + { + client_handle->err = + GLOBUS_I_FTP_CLIENT_ERROR_RESPONSE(response); + + globus_ftp_control_data_force_close( + target->control_handle, + globus_l_ftp_client_data_force_close_callback, + GLOBUS_NULL); + } + else if(!client_handle->err) + { + client_handle->err = globus_object_copy(error); + } + globus_i_ftp_client_plugin_notify_fault( + client_handle, + target->url_string, + client_handle->err); + + if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) + { + break; + } + + globus_assert( + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_LIST || + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_RETR_OR_ERET || + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_DEST_STOR_OR_ESTO || + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_THIRD_PARTY_TRANSFER || + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_THIRD_PARTY_TRANSFER_ONE_COMPLETE || + (client_handle->op == GLOBUS_FTP_CLIENT_TRANSFER && + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION) || + (client_handle->op == GLOBUS_FTP_CLIENT_TRANSFER && + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_CONNECT) || + (target->delayed_pasv && client_handle->op == GLOBUS_FTP_CLIENT_TRANSFER && client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION)); - - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; - + + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; + goto connection_error; - } + } - break; + break; case GLOBUS_FTP_CLIENT_TARGET_READY_FOR_DATA: case GLOBUS_FTP_CLIENT_TARGET_NEED_EMPTY_AND_COMPLETE: - /* - * We've received the callback for this operation, so now we - * just need to wait for the final data callbacks - */ - if(error) - { - if(client_handle->err == GLOBUS_SUCCESS) - { - client_handle->err = globus_object_copy(error); - } - client_handle->state = GLOBUS_FTP_CLIENT_HANDLE_FAILURE; - - goto notify_fault; - } - else if(response->response_class == - GLOBUS_FTP_POSITIVE_PRELIMINARY_REPLY) - { - if(response->code == 111) - { - globus_l_ftp_client_parse_restart_marker(client_handle, - response); - } - break; - } + /* + * We've received the callback for this operation, so now we + * just need to wait for the final data callbacks + */ + if(error) + { + if(client_handle->err == GLOBUS_SUCCESS) + { + client_handle->err = globus_object_copy(error); + } + client_handle->state = GLOBUS_FTP_CLIENT_HANDLE_FAILURE; + + goto notify_fault; + } + else if(response->response_class == + GLOBUS_FTP_POSITIVE_PRELIMINARY_REPLY) + { + if(response->code == 111) + { + globus_l_ftp_client_parse_restart_marker(client_handle, + response); + } + break; + } else { if(response->response_class != GLOBUS_FTP_POSITIVE_COMPLETION_REPLY && client_handle->err == GLOBUS_SUCCESS) { - /* any other response must be a transient error such as + /* any other response must be a transient error such as * 426 data timeout */ - client_handle->err = + client_handle->err = GLOBUS_I_FTP_CLIENT_ERROR_RESPONSE(response); } - + if(target->state == GLOBUS_FTP_CLIENT_TARGET_NEED_EMPTY_AND_COMPLETE) { target->state = GLOBUS_FTP_CLIENT_TARGET_NEED_EMPTY_QUEUE; @@ -5105,72 +5105,72 @@ globus_i_ftp_client_response_callback( target->state = GLOBUS_FTP_CLIENT_TARGET_NEED_LAST_BLOCK; } } - - break; + + break; case GLOBUS_FTP_CLIENT_TARGET_NEED_COMPLETE: - /* Reset the state to setup_connection, so that the url - * caching code knows to keep this one around. - */ - if(!error) - { - if(response->response_class == - GLOBUS_FTP_POSITIVE_PRELIMINARY_REPLY) - { - if(response->code == 111) - { - globus_l_ftp_client_parse_restart_marker(client_handle, - response); - } - break; - } - else - { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; - - if(response->response_class != - GLOBUS_FTP_POSITIVE_COMPLETION_REPLY) - { - if(client_handle->err == GLOBUS_SUCCESS) - { - client_handle->err = - GLOBUS_I_FTP_CLIENT_ERROR_RESPONSE(response); - } - if(client_handle->op != GLOBUS_FTP_CLIENT_MDTM && - client_handle->op != GLOBUS_FTP_CLIENT_SIZE && - client_handle->op != GLOBUS_FTP_CLIENT_FEAT && - client_handle->op != GLOBUS_FTP_CLIENT_CKSM && - client_handle->op != GLOBUS_FTP_CLIENT_MLST && - client_handle->op != GLOBUS_FTP_CLIENT_CWD && - client_handle->op != GLOBUS_FTP_CLIENT_STAT) - { - client_handle->state = - GLOBUS_FTP_CLIENT_HANDLE_FAILURE; - } - } - if(client_handle->op == GLOBUS_FTP_CLIENT_MDTM && - response->code == 213) - { - globus_l_ftp_client_parse_mdtm(client_handle, - response); - } - else if(client_handle->op == GLOBUS_FTP_CLIENT_SIZE && - response->code == 213) - { - globus_libc_scan_off_t((char *) response->response_buffer+4, - client_handle->size_pointer, - GLOBUS_NULL); - } - else if(client_handle->op == GLOBUS_FTP_CLIENT_CKSM && - response->code == 213) - { - globus_l_ftp_client_parse_cksm(client_handle, - response); - - } - else if(client_handle->op == GLOBUS_FTP_CLIENT_FEAT) - { - for(i = 0; i < GLOBUS_FTP_CLIENT_FEATURE_MAX; i++) + /* Reset the state to setup_connection, so that the url + * caching code knows to keep this one around. + */ + if(!error) + { + if(response->response_class == + GLOBUS_FTP_POSITIVE_PRELIMINARY_REPLY) + { + if(response->code == 111) + { + globus_l_ftp_client_parse_restart_marker(client_handle, + response); + } + break; + } + else + { + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; + + if(response->response_class != + GLOBUS_FTP_POSITIVE_COMPLETION_REPLY) + { + if(client_handle->err == GLOBUS_SUCCESS) + { + client_handle->err = + GLOBUS_I_FTP_CLIENT_ERROR_RESPONSE(response); + } + if(client_handle->op != GLOBUS_FTP_CLIENT_MDTM && + client_handle->op != GLOBUS_FTP_CLIENT_SIZE && + client_handle->op != GLOBUS_FTP_CLIENT_FEAT && + client_handle->op != GLOBUS_FTP_CLIENT_CKSM && + client_handle->op != GLOBUS_FTP_CLIENT_MLST && + client_handle->op != GLOBUS_FTP_CLIENT_CWD && + client_handle->op != GLOBUS_FTP_CLIENT_STAT) + { + client_handle->state = + GLOBUS_FTP_CLIENT_HANDLE_FAILURE; + } + } + if(client_handle->op == GLOBUS_FTP_CLIENT_MDTM && + response->code == 213) + { + globus_l_ftp_client_parse_mdtm(client_handle, + response); + } + else if(client_handle->op == GLOBUS_FTP_CLIENT_SIZE && + response->code == 213) + { + globus_libc_scan_off_t((char *) response->response_buffer+4, + client_handle->size_pointer, + GLOBUS_NULL); + } + else if(client_handle->op == GLOBUS_FTP_CLIENT_CKSM && + response->code == 213) + { + globus_l_ftp_client_parse_cksm(client_handle, + response); + + } + else if(client_handle->op == GLOBUS_FTP_CLIENT_FEAT) + { + for(i = 0; i < GLOBUS_FTP_CLIENT_FEATURE_MAX; i++) { globus_i_ftp_client_feature_set( client_handle->features_pointer, @@ -5178,159 +5178,159 @@ globus_i_ftp_client_response_callback( globus_i_ftp_client_feature_get( target->features, i)); } - } - else if(client_handle->op == GLOBUS_FTP_CLIENT_CWD && - response->code == 250) - { - globus_l_ftp_client_parse_cwd(client_handle, - response); - } - else if(client_handle->op == GLOBUS_FTP_CLIENT_MLST && - response->code == 250) - { - globus_l_ftp_client_parse_mlst(client_handle, - response); - } - else if(client_handle->op == GLOBUS_FTP_CLIENT_STAT) - { - globus_l_ftp_client_parse_stat(client_handle, - response); - } - } - } - else - { - target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; - if(client_handle->err == GLOBUS_SUCCESS) - { - client_handle->err = globus_object_copy(error); - } - } - - globus_i_ftp_client_transfer_complete(client_handle); - - goto do_return; - - break; + } + else if(client_handle->op == GLOBUS_FTP_CLIENT_CWD && + response->code == 250) + { + globus_l_ftp_client_parse_cwd(client_handle, + response); + } + else if(client_handle->op == GLOBUS_FTP_CLIENT_MLST && + response->code == 250) + { + globus_l_ftp_client_parse_mlst(client_handle, + response); + } + else if(client_handle->op == GLOBUS_FTP_CLIENT_STAT) + { + globus_l_ftp_client_parse_stat(client_handle, + response); + } + } + } + else + { + target->state = GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION; + if(client_handle->err == GLOBUS_SUCCESS) + { + client_handle->err = globus_object_copy(error); + } + } + + globus_i_ftp_client_transfer_complete(client_handle); + + goto do_return; + + break; case GLOBUS_FTP_CLIENT_TARGET_FAULT: case GLOBUS_FTP_CLIENT_TARGET_CLOSED: - /* - * This state only happens if this is a callback which was a - * result of a force_close. We do nothing, and the force_close - * callback deals with the failure. - */ - break; + /* + * This state only happens if this is a callback which was a + * result of a force_close. We do nothing, and the force_close + * callback deals with the failure. + */ + break; case GLOBUS_FTP_CLIENT_TARGET_NOOP: - globus_assert( - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || - client_handle->state == - GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); - + globus_assert( + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_SOURCE_SETUP_CONNECTION || + client_handle->state == + GLOBUS_FTP_CLIENT_HANDLE_DEST_SETUP_CONNECTION); + /* response will be NULL if the NOOP was faked */ - if((!error) && (!response || - response->response_class == GLOBUS_FTP_POSITIVE_COMPLETION_REPLY)) - { - /* NOOP successful, we can re-use this target */ - target->state = - GLOBUS_FTP_CLIENT_TARGET_SETUP_TYPE; - goto redo; - } - else - { - globus_i_ftp_client_target_t * new_target; - /* - * NOOP failed---This means that the cached target went - * bad. We'll discard this target, and find a new - * one. - */ - globus_assert(client_handle->source == target || - client_handle->dest == target); - - if(client_handle->source == target) - { - error = - globus_i_ftp_client_target_find(client_handle, - client_handle->source_url, - target->attr, - &new_target); - if(error != GLOBUS_SUCCESS) - { - target->state = GLOBUS_FTP_CLIENT_TARGET_FAULT; - - goto notify_fault; - } - client_handle->source = new_target; - } - else if(client_handle->dest == target) - { - error = - globus_i_ftp_client_target_find(client_handle, - client_handle->dest_url, - target->attr, - &new_target); - - if(error != GLOBUS_SUCCESS) - { - target->state = GLOBUS_FTP_CLIENT_TARGET_FAULT; - - goto notify_fault; - } - client_handle->dest = new_target; - } - - /* Mark the old target for destruction... */ - target->state = GLOBUS_FTP_CLIENT_TARGET_FAULT; - /* And release it */ - globus_i_ftp_client_target_release(client_handle, - target); - - /* Start this new target off */ - error = globus_i_ftp_client_target_activate(client_handle, - new_target, - ®istered); - - if(registered == GLOBUS_FALSE) - { - globus_assert(error || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE); - /* - * A restart or abort happened during activation, before any - * callbacks were registered. We must deal with them here. - */ - if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || - client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) - { - break; - } - else if(error != GLOBUS_SUCCESS) - { - globus_i_ftp_client_plugin_notify_fault( - client_handle, - target->url_string, - error); - - goto connection_error; - } - } - } - break; + if((!error) && (!response || + response->response_class == GLOBUS_FTP_POSITIVE_COMPLETION_REPLY)) + { + /* NOOP successful, we can re-use this target */ + target->state = + GLOBUS_FTP_CLIENT_TARGET_SETUP_TYPE; + goto redo; + } + else + { + globus_i_ftp_client_target_t * new_target; + /* + * NOOP failed---This means that the cached target went + * bad. We'll discard this target, and find a new + * one. + */ + globus_assert(client_handle->source == target || + client_handle->dest == target); + + if(client_handle->source == target) + { + error = + globus_i_ftp_client_target_find(client_handle, + client_handle->source_url, + target->attr, + &new_target); + if(error != GLOBUS_SUCCESS) + { + target->state = GLOBUS_FTP_CLIENT_TARGET_FAULT; + + goto notify_fault; + } + client_handle->source = new_target; + } + else if(client_handle->dest == target) + { + error = + globus_i_ftp_client_target_find(client_handle, + client_handle->dest_url, + target->attr, + &new_target); + + if(error != GLOBUS_SUCCESS) + { + target->state = GLOBUS_FTP_CLIENT_TARGET_FAULT; + + goto notify_fault; + } + client_handle->dest = new_target; + } + + /* Mark the old target for destruction... */ + target->state = GLOBUS_FTP_CLIENT_TARGET_FAULT; + /* And release it */ + globus_i_ftp_client_target_release(client_handle, + target); + + /* Start this new target off */ + error = globus_i_ftp_client_target_activate(client_handle, + new_target, + ®istered); + + if(registered == GLOBUS_FALSE) + { + globus_assert(error || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE); + /* + * A restart or abort happened during activation, before any + * callbacks were registered. We must deal with them here. + */ + if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || + client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) + { + break; + } + else if(error != GLOBUS_SUCCESS) + { + globus_i_ftp_client_plugin_notify_fault( + client_handle, + target->url_string, + error); + + goto connection_error; + } + } + } + break; default: - globus_assert(0 && "Invalid state"); + globus_assert(0 && "Invalid state"); } finish: globus_i_ftp_client_handle_unlock(client_handle); - do_return: - + do_return: + if(error) { globus_object_free(error); } - globus_i_ftp_client_debug_printf(1, (stderr, + globus_i_ftp_client_debug_printf(1, (stderr, "globus_i_ftp_client_response_callback() exiting\n")); globus_i_ftp_client_debug_states(2, client_handle); @@ -5344,17 +5344,17 @@ globus_i_ftp_client_response_callback( error = globus_error_get(result); notify_fault: globus_i_ftp_client_plugin_notify_fault( - client_handle, - target->url_string, - error); + client_handle, + target->url_string, + error); connection_error: globus_l_ftp_client_connection_error(client_handle, - target, - error, - response); - + target, + error, + response); + globus_object_free(error); - globus_i_ftp_client_debug_printf(1, (stderr, + globus_i_ftp_client_debug_printf(1, (stderr, "globus_i_ftp_client_response_callback() exiting with error\n")); globus_i_ftp_client_debug_states(2, client_handle); @@ -5387,8 +5387,8 @@ globus_i_ftp_client_response_callback( static globus_object_t * globus_l_ftp_client_parse_site_help( - globus_i_ftp_client_target_t * target, - globus_ftp_control_response_t * response) + globus_i_ftp_client_target_t * target, + globus_ftp_control_response_t * response) { char * p; @@ -5407,7 +5407,7 @@ globus_l_ftp_client_parse_site_help( GLOBUS_FTP_CLIENT_TRUE); } if(((p = strstr((char *) response->response_buffer, "RBUFSIZ")) != 0) && - !isupper(*(p-1))) + !isupper(*(p-1))) { globus_i_ftp_client_feature_set( target->features, @@ -5429,7 +5429,7 @@ globus_l_ftp_client_parse_site_help( GLOBUS_FTP_CLIENT_TRUE); } if(((p = strstr((char *) response->response_buffer, "SBUFSIZ")) != 0) && - !isupper(*(p-1))) + !isupper(*(p-1))) { globus_i_ftp_client_feature_set( target->features, @@ -5437,7 +5437,7 @@ globus_l_ftp_client_parse_site_help( GLOBUS_FTP_CLIENT_TRUE); } if(((p = strstr((char *) response->response_buffer, "BUFSIZE")) != 0) && - !isupper(*(p-1))) + !isupper(*(p-1))) { globus_i_ftp_client_feature_set( target->features, @@ -5445,7 +5445,7 @@ globus_l_ftp_client_parse_site_help( GLOBUS_FTP_CLIENT_TRUE); } if(((p = strstr((char *) response->response_buffer, "CHMOD")) != 0) && - !isupper(*(p-1))) + !isupper(*(p-1))) { globus_i_ftp_client_feature_set( target->features, @@ -5459,7 +5459,7 @@ globus_l_ftp_client_parse_site_help( target->features, GLOBUS_FTP_CLIENT_FEATURE_CHGRP, GLOBUS_FTP_CLIENT_TRUE); - } + } if(((p = strstr((char *) response->response_buffer, "UTIME")) != 0) && !isupper(*(p-1))) { @@ -5467,7 +5467,7 @@ globus_l_ftp_client_parse_site_help( target->features, GLOBUS_FTP_CLIENT_FEATURE_UTIME, GLOBUS_FTP_CLIENT_TRUE); - } + } if(((p = strstr((char *) response->response_buffer, "SYMLINK")) != 0) && !isupper(*(p-1))) { @@ -5475,8 +5475,8 @@ globus_l_ftp_client_parse_site_help( target->features, GLOBUS_FTP_CLIENT_FEATURE_SYMLINK, GLOBUS_FTP_CLIENT_TRUE); - } - if(((p = strstr((char *) response->response_buffer, "AUTHZ_ASSERT")) != 0) + } + if(((p = strstr((char *) response->response_buffer, "AUTHZ_ASSERT")) != 0) && !isupper(*(p-1))) { globus_i_ftp_client_feature_set( @@ -5484,7 +5484,7 @@ globus_l_ftp_client_parse_site_help( GLOBUS_FTP_CLIENT_FEATURE_AUTHZ_ASSERT, GLOBUS_FTP_CLIENT_TRUE); } - if(((p = strstr((char *) response->response_buffer, "CLIENTINFO")) != 0) + if(((p = strstr((char *) response->response_buffer, "CLIENTINFO")) != 0) && !isupper(*(p-1))) { globus_i_ftp_client_feature_set( @@ -5492,8 +5492,8 @@ globus_l_ftp_client_parse_site_help( GLOBUS_FTP_CLIENT_FEATURE_CLIENTINFO, GLOBUS_FTP_CLIENT_TRUE); } - - + + return GLOBUS_SUCCESS; } /* globus_l_ftp_client_parse_site_help() */ @@ -5513,187 +5513,187 @@ globus_l_ftp_client_parse_site_help( static void globus_l_ftp_client_parse_feat( - globus_i_ftp_client_target_t * target, - globus_ftp_control_response_t * response) + globus_i_ftp_client_target_t * target, + globus_ftp_control_response_t * response) { - char * p; - char * pstart; - globus_bool_t first = GLOBUS_TRUE; + char * p; + char * pstart; + globus_bool_t first = GLOBUS_TRUE; + + if(response->code != 211) + { + return; + } + p = globus_libc_strdup((char *) response->response_buffer); + pstart = p; + while(1) + { + char * eol; + eol = strstr(p, CRLF); + if(eol == 0) + { + int i; + /* Last line should contain "211 End" CRLF ONLY */ + globus_libc_free(pstart); + + /* + * If there are any features which are in the unknown state, + * set them to false now. + */ + for(i = GLOBUS_FTP_CLIENT_FIRST_FEAT_FEATURE; + i <= GLOBUS_FTP_CLIENT_LAST_FEAT_FEATURE; + i++) + { + if(globus_i_ftp_client_feature_get( + target->features, i) == GLOBUS_FTP_CLIENT_MAYBE) + { + globus_i_ftp_client_feature_set( + target->features, i, GLOBUS_FTP_CLIENT_FALSE); + } + } + return; + } + else if(first) + { + /* First line contains no feature. */ + p = eol + 2; + first = GLOBUS_FALSE; + continue; + } + else + { + /* An actual feature! */ + char * feature_label; + char * feature_parms; + + *eol = '\0'; + + feature_label = p + 1; + feature_parms = feature_label; + + /* VCHAR (%x21-%7E) */ + while((*feature_parms) >= ((char)0x21) && + (*feature_parms) <= ((char)0x7e)) + { + feature_parms++; + } + if(strncmp(feature_label, "REST", 4) == 0) + { + if(strstr(feature_parms, "STREAM")) + { + globus_i_ftp_client_feature_set( + target->features, + GLOBUS_FTP_CLIENT_FEATURE_REST_STREAM, + GLOBUS_FTP_CLIENT_TRUE); + } + } + else if(strncmp(feature_label, "PARALLEL", 8) == 0) + { + globus_i_ftp_client_feature_set( + target->features, + GLOBUS_FTP_CLIENT_FEATURE_PARALLELISM, + GLOBUS_FTP_CLIENT_TRUE); + } + else if(strncmp(feature_label, "DCAU", 4) == 0) + { + globus_i_ftp_client_feature_set( + target->features, + GLOBUS_FTP_CLIENT_FEATURE_DCAU, + GLOBUS_FTP_CLIENT_TRUE); + /* Per our extensions document, if server publishes + * DCAU feature, it must default to DCAU S(elf) + * if we used RFC 2228 authentication. + * + * gsi-wuftpd 0.5 and below are broken in this regard. + */ + if(target->url.scheme_type == GLOBUS_URL_SCHEME_GSIFTP) + { + target->dcau.mode = GLOBUS_FTP_CONTROL_DCAU_DEFAULT; + } + } + else if(strncmp(feature_label, "DCSC", 4) == 0) + { + globus_i_ftp_client_feature_set( + target->features, + GLOBUS_FTP_CLIENT_FEATURE_DCSC, + GLOBUS_FTP_CLIENT_TRUE); + } + else if(strncmp(feature_label, "ESTO", 4) == 0) + { + globus_i_ftp_client_feature_set( + target->features, + GLOBUS_FTP_CLIENT_FEATURE_ESTO, + GLOBUS_FTP_CLIENT_TRUE); + } + else if(strncmp(feature_label, "ERET", 4) == 0) + { + globus_i_ftp_client_feature_set( + target->features, + GLOBUS_FTP_CLIENT_FEATURE_ERET, + GLOBUS_FTP_CLIENT_TRUE); + } + else if(strncmp(feature_label, "SBUF", 4) == 0) + { + int i; + globus_i_ftp_client_feature_set( + target->features, + GLOBUS_FTP_CLIENT_FEATURE_SBUF, + GLOBUS_FTP_CLIENT_TRUE); + /* If SBUF is supported, then don't bother with other + * buffer size commands + */ - if(response->code != 211) - { - return; - } - p = globus_libc_strdup((char *) response->response_buffer); - pstart = p; - while(1) - { - char * eol; - eol = strstr(p, CRLF); - if(eol == 0) - { - int i; - /* Last line should contain "211 End" CRLF ONLY */ - globus_libc_free(pstart); - - /* - * If there are any features which are in the unknown state, - * set them to false now. - */ - for(i = GLOBUS_FTP_CLIENT_FIRST_FEAT_FEATURE; - i <= GLOBUS_FTP_CLIENT_LAST_FEAT_FEATURE; - i++) - { - if(globus_i_ftp_client_feature_get( - target->features, i) == GLOBUS_FTP_CLIENT_MAYBE) - { - globus_i_ftp_client_feature_set( - target->features, i, GLOBUS_FTP_CLIENT_FALSE); - } - } - return; - } - else if(first) - { - /* First line contains no feature. */ - p = eol + 2; - first = GLOBUS_FALSE; - continue; - } - else - { - /* An actual feature! */ - char * feature_label; - char * feature_parms; - - *eol = '\0'; - - feature_label = p + 1; - feature_parms = feature_label; - - /* VCHAR (%x21-%7E) */ - while((*feature_parms) >= ((char)0x21) && - (*feature_parms) <= ((char)0x7e)) - { - feature_parms++; - } - if(strncmp(feature_label, "REST", 4) == 0) - { - if(strstr(feature_parms, "STREAM")) - { - globus_i_ftp_client_feature_set( - target->features, - GLOBUS_FTP_CLIENT_FEATURE_REST_STREAM, - GLOBUS_FTP_CLIENT_TRUE); - } - } - else if(strncmp(feature_label, "PARALLEL", 8) == 0) - { - globus_i_ftp_client_feature_set( - target->features, - GLOBUS_FTP_CLIENT_FEATURE_PARALLELISM, - GLOBUS_FTP_CLIENT_TRUE); - } - else if(strncmp(feature_label, "DCAU", 4) == 0) - { - globus_i_ftp_client_feature_set( - target->features, - GLOBUS_FTP_CLIENT_FEATURE_DCAU, - GLOBUS_FTP_CLIENT_TRUE); - /* Per our extensions document, if server publishes - * DCAU feature, it must default to DCAU S(elf) - * if we used RFC 2228 authentication. - * - * gsi-wuftpd 0.5 and below are broken in this regard. - */ - if(target->url.scheme_type == GLOBUS_URL_SCHEME_GSIFTP) - { - target->dcau.mode = GLOBUS_FTP_CONTROL_DCAU_DEFAULT; - } - } - else if(strncmp(feature_label, "DCSC", 4) == 0) - { - globus_i_ftp_client_feature_set( - target->features, - GLOBUS_FTP_CLIENT_FEATURE_DCSC, - GLOBUS_FTP_CLIENT_TRUE); - } - else if(strncmp(feature_label, "ESTO", 4) == 0) - { - globus_i_ftp_client_feature_set( - target->features, - GLOBUS_FTP_CLIENT_FEATURE_ESTO, - GLOBUS_FTP_CLIENT_TRUE); - } - else if(strncmp(feature_label, "ERET", 4) == 0) - { - globus_i_ftp_client_feature_set( - target->features, - GLOBUS_FTP_CLIENT_FEATURE_ERET, - GLOBUS_FTP_CLIENT_TRUE); - } - else if(strncmp(feature_label, "SBUF", 4) == 0) - { - int i; - globus_i_ftp_client_feature_set( - target->features, - GLOBUS_FTP_CLIENT_FEATURE_SBUF, - GLOBUS_FTP_CLIENT_TRUE); - /* If SBUF is supported, then don't bother with other - * buffer size commands - */ - - for(i = 0; i < GLOBUS_FTP_CLIENT_FEATURE_SBUF; i++) - { - if(globus_i_ftp_client_feature_get( - target->features, i) == GLOBUS_FTP_CLIENT_MAYBE) - { - globus_i_ftp_client_feature_set( - target->features, i, GLOBUS_FTP_CLIENT_FALSE); - } - } - } - else if(strncmp(feature_label, "ABUF", 4) == 0) - { - globus_i_ftp_client_feature_set( - target->features, - GLOBUS_FTP_CLIENT_FEATURE_ABUF, - GLOBUS_FTP_CLIENT_TRUE); - } - else if(strncmp(feature_label, "SIZE", 4) == 0) - { - globus_i_ftp_client_feature_set( - target->features, - GLOBUS_FTP_CLIENT_FEATURE_SIZE, - GLOBUS_FTP_CLIENT_TRUE); - } + for(i = 0; i < GLOBUS_FTP_CLIENT_FEATURE_SBUF; i++) + { + if(globus_i_ftp_client_feature_get( + target->features, i) == GLOBUS_FTP_CLIENT_MAYBE) + { + globus_i_ftp_client_feature_set( + target->features, i, GLOBUS_FTP_CLIENT_FALSE); + } + } + } + else if(strncmp(feature_label, "ABUF", 4) == 0) + { + globus_i_ftp_client_feature_set( + target->features, + GLOBUS_FTP_CLIENT_FEATURE_ABUF, + GLOBUS_FTP_CLIENT_TRUE); + } + else if(strncmp(feature_label, "SIZE", 4) == 0) + { + globus_i_ftp_client_feature_set( + target->features, + GLOBUS_FTP_CLIENT_FEATURE_SIZE, + GLOBUS_FTP_CLIENT_TRUE); + } else if(strncmp(feature_label, "GETPUT", 6) == 0) { - globus_i_ftp_client_feature_set( - target->features, - GLOBUS_FTP_CLIENT_FEATURE_GETPUT, - GLOBUS_FTP_CLIENT_TRUE); - } - else if(strncmp(feature_label, "MLST", 4) == 0) - { - globus_i_ftp_client_feature_set( - target->features, - GLOBUS_FTP_CLIENT_FEATURE_MLST, - GLOBUS_FTP_CLIENT_TRUE); - } + globus_i_ftp_client_feature_set( + target->features, + GLOBUS_FTP_CLIENT_FEATURE_GETPUT, + GLOBUS_FTP_CLIENT_TRUE); + } + else if(strncmp(feature_label, "MLST", 4) == 0) + { + globus_i_ftp_client_feature_set( + target->features, + GLOBUS_FTP_CLIENT_FEATURE_MLST, + GLOBUS_FTP_CLIENT_TRUE); + } else if(strncmp(feature_label, "PASV", 4) == 0) - { - if(strstr(feature_parms, "AllowDelayed")) - { - globus_i_ftp_client_feature_set( - target->features, - GLOBUS_FTP_CLIENT_FEATURE_DELAYED_PASV, - GLOBUS_FTP_CLIENT_TRUE); - } - } - p = eol + 2; - - } + { + if(strstr(feature_parms, "AllowDelayed")) + { + globus_i_ftp_client_feature_set( + target->features, + GLOBUS_FTP_CLIENT_FEATURE_DELAYED_PASV, + GLOBUS_FTP_CLIENT_TRUE); + } + } + p = eol + 2; + + } } } /* globus_l_ftp_client_parse_feat() */ @@ -5719,18 +5719,18 @@ static void globus_l_ftp_client_parse_pasv( globus_ftp_control_handle_t * handle, - globus_ftp_control_response_t * response, - globus_ftp_control_host_port_t ** host_port, - int * num_pasv_addresses) + globus_ftp_control_response_t * response, + globus_ftp_control_host_port_t ** host_port, + int * num_pasv_addresses) { - char * p; - int port[2] = {0,0}; - int rc; - int i; - int consumed; + char * p; + int port[2] = {0,0}; + int rc; + int i; + int consumed; char delim; char buf[100]; - + p = strchr((char *) response->response_buffer, '('); if(response->code == 229) { @@ -5738,14 +5738,14 @@ globus_l_ftp_client_parse_pasv( { /* spas */ (*num_pasv_addresses) = -2; - + p = (char *) response->response_buffer; while(GLOBUS_NULL != (p = strchr(p, '\n'))) { (*num_pasv_addresses)++; p++; } - + /* skip the first line of the 229 response */ p = strchr((char *) response->response_buffer, '\n') + 1; while(isspace(*p)) p++; @@ -5759,27 +5759,27 @@ globus_l_ftp_client_parse_pasv( } else { - (*num_pasv_addresses) = 1; - - /* skip the initial 227 in the response */ - if(!p) - { - p = (char *) response->response_buffer + 3; - while(isspace(*p)) p++; - } - else - { - p++; - } + (*num_pasv_addresses) = 1; + + /* skip the initial 227 in the response */ + if(!p) + { + p = (char *) response->response_buffer + 3; + while(isspace(*p)) p++; + } + else + { + p++; + } } (*host_port) = globus_libc_calloc((*num_pasv_addresses), - sizeof(globus_ftp_control_host_port_t)); + sizeof(globus_ftp_control_host_port_t)); if(isdigit(delim = *p)) { delim = 0; } - + for(i = 0; i < (*num_pasv_addresses) && *p; i++) { if(delim) @@ -5796,23 +5796,23 @@ globus_l_ftp_client_parse_pasv( int j = 0; char * s; char * c; - + p++; c = strchr(p, ':'); s = strchr(p, delim); - + if(*p != delim) { if(c && c < s) { buf[j++] = '['; } - + while(j < sizeof(buf) - 1 && p < s) { buf[j++] = *(p++); } - + if(*p == delim && j + 7 < sizeof(buf)) { p++; @@ -5820,7 +5820,7 @@ globus_l_ftp_client_parse_pasv( { buf[j++] = ']'; } - + buf[j++] = ':'; while(j < sizeof(buf) - 2 && *p && *p != delim) { @@ -5831,9 +5831,9 @@ globus_l_ftp_client_parse_pasv( p++; } } - + buf[j] = 0; - + globus_libc_contact_string_to_ints(buf, (*host_port)[i].host, &(*host_port)[i].hostlen, @@ -5852,7 +5852,7 @@ globus_l_ftp_client_parse_pasv( else { while(*p && !isdigit(*p)) p++; - + rc = sscanf(p, "%d,%d,%d,%d,%d,%d%n", &(*host_port)[i].host[0], @@ -5890,40 +5890,40 @@ globus_l_ftp_client_parse_pasv( static char * globus_l_ftp_client_layout_string( - globus_i_ftp_client_target_t * target) + globus_i_ftp_client_target_t * target) { - char * ptr = GLOBUS_NULL; - globus_size_t length; + char * ptr = GLOBUS_NULL; + globus_size_t length; - length = 16; /* " StripeLayout=;\0" */ + length = 16; /* " StripeLayout=;\0" */ switch(target->attr->layout.mode) { case GLOBUS_FTP_CONTROL_STRIPING_PARTITIONED: - if(target->layout.mode != GLOBUS_FTP_CONTROL_STRIPING_PARTITIONED) - { - length += 11; /* "Partitioned" */ - ptr = globus_libc_malloc(length); - sprintf(ptr, "StripeLayout=Partitioned;"); - } - break; + if(target->layout.mode != GLOBUS_FTP_CONTROL_STRIPING_PARTITIONED) + { + length += 11; /* "Partitioned" */ + ptr = globus_libc_malloc(length); + sprintf(ptr, "StripeLayout=Partitioned;"); + } + break; case GLOBUS_FTP_CONTROL_STRIPING_BLOCKED_ROUND_ROBIN: - if((target->layout.mode != - GLOBUS_FTP_CONTROL_STRIPING_BLOCKED_ROUND_ROBIN) || - (target->attr->layout.round_robin.block_size != - target->layout.round_robin.block_size)) - { - length += 18; /* "Blocked;BlockSize=" */ - length += - globus_i_ftp_client_count_digits( - target->attr->layout.round_robin.block_size); - ptr = globus_libc_malloc(length); - sprintf(ptr, "StripeLayout=Blocked;BlockSize=%d;", - (int) target->attr->layout.round_robin.block_size); - } - break; + if((target->layout.mode != + GLOBUS_FTP_CONTROL_STRIPING_BLOCKED_ROUND_ROBIN) || + (target->attr->layout.round_robin.block_size != + target->layout.round_robin.block_size)) + { + length += 18; /* "Blocked;BlockSize=" */ + length += + globus_i_ftp_client_count_digits( + target->attr->layout.round_robin.block_size); + ptr = globus_libc_malloc(length); + sprintf(ptr, "StripeLayout=Blocked;BlockSize=%d;", + (int) target->attr->layout.round_robin.block_size); + } + break; case GLOBUS_FTP_CONTROL_STRIPING_NONE: - break; + break; } return ptr; } @@ -5942,39 +5942,39 @@ globus_l_ftp_client_layout_string( static char * globus_l_ftp_client_parallelism_string( - globus_i_ftp_client_target_t * target) + globus_i_ftp_client_target_t * target) { - char * ptr = GLOBUS_NULL; - globus_size_t length; + char * ptr = GLOBUS_NULL; + globus_size_t length; - length = 17; /* " Parallelism=,,;\0" */ + length = 17; /* " Parallelism=,,;\0" */ switch(target->attr->parallelism.mode) { case GLOBUS_FTP_CONTROL_PARALLELISM_FIXED: - if((target->parallelism.mode != - GLOBUS_FTP_CONTROL_PARALLELISM_FIXED) || - (target->attr->parallelism.fixed.size != - target->parallelism.fixed.size)) - { - length += 3 * - globus_i_ftp_client_count_digits( - target->attr->parallelism.fixed.size); - ptr = globus_libc_malloc(length); - sprintf(ptr, "Parallelism=%d,%d,%d;", - (int) target->attr->parallelism.fixed.size, - (int) target->attr->parallelism.fixed.size, - (int) target->attr->parallelism.fixed.size); - } - break; + if((target->parallelism.mode != + GLOBUS_FTP_CONTROL_PARALLELISM_FIXED) || + (target->attr->parallelism.fixed.size != + target->parallelism.fixed.size)) + { + length += 3 * + globus_i_ftp_client_count_digits( + target->attr->parallelism.fixed.size); + ptr = globus_libc_malloc(length); + sprintf(ptr, "Parallelism=%d,%d,%d;", + (int) target->attr->parallelism.fixed.size, + (int) target->attr->parallelism.fixed.size, + (int) target->attr->parallelism.fixed.size); + } + break; case GLOBUS_FTP_CONTROL_PARALLELISM_NONE: if((target->parallelism.mode != - GLOBUS_FTP_CONTROL_PARALLELISM_NONE) && - (target->parallelism.fixed.size != 1)) - { - ptr = globus_libc_strdup("Parallelism=1,1,1;"); - } - break; + GLOBUS_FTP_CONTROL_PARALLELISM_NONE) && + (target->parallelism.fixed.size != 1)) + { + ptr = globus_libc_strdup("Parallelism=1,1,1;"); + } + break; } return ptr; } @@ -5988,9 +5988,9 @@ globus_i_ftp_client_faked_force_close_callback( void * user_args) { globus_i_ftp_client_target_t * target; - + target = (globus_i_ftp_client_target_t *) user_args; - + globus_i_ftp_client_force_close_callback( target, target->control_handle, @@ -6020,34 +6020,34 @@ globus_i_ftp_client_faked_force_close_callback( static void globus_l_ftp_client_connection_error( - globus_i_ftp_client_handle_t * client_handle, - globus_i_ftp_client_target_t * target, - globus_object_t * error, - globus_ftp_control_response_t * response) + globus_i_ftp_client_handle_t * client_handle, + globus_i_ftp_client_target_t * target, + globus_object_t * error, + globus_ftp_control_response_t * response) { - globus_result_t result; + globus_result_t result; GlobusFuncName(globus_l_ftp_client_connection_error); - - globus_i_ftp_client_debug_printf(1, + + globus_i_ftp_client_debug_printf(1, (stderr, "globus_l_ftp_client_connection_error() entering\n")); globus_i_ftp_client_debug_states(2, client_handle); if(client_handle->err == GLOBUS_NULL) { - if(error) - { - client_handle->err = globus_object_copy(error); - } - else if(response && response->response_buffer) - { - client_handle->err = GLOBUS_I_FTP_CLIENT_ERROR_RESPONSE(response); - } - else - { - client_handle->err = GLOBUS_I_FTP_CLIENT_ERROR_PROTOCOL_ERROR(); - } + if(error) + { + client_handle->err = globus_object_copy(error); + } + else if(response && response->response_buffer) + { + client_handle->err = GLOBUS_I_FTP_CLIENT_ERROR_RESPONSE(response); + } + else + { + client_handle->err = GLOBUS_I_FTP_CLIENT_ERROR_PROTOCOL_ERROR(); + } } - + /* * Now, let's figure out to cope with this fault. Get/Put are * similar, but 3rd party transfer is rather different @@ -6064,77 +6064,77 @@ globus_l_ftp_client_connection_error( /* Mark the target for destruction, since we faulted on it. */ target->state = GLOBUS_FTP_CLIENT_TARGET_FAULT; } - - /* If we haven't been restarted yet, then we will deal with - * the fault here. - */ - if(client_handle->state != GLOBUS_FTP_CLIENT_HANDLE_RESTART) - { - client_handle->state = GLOBUS_FTP_CLIENT_HANDLE_FAILURE; - - /* - * If we're in this function, then whatever buffers the - * user has registered will not yet be passed to the - * control library. That means we've got to call back for all - * of the data buffers which have been registered. - * - * Because we are in the FAILURE state, the plugins may - * *not* do a restart now. - */ - globus_i_ftp_client_data_flush(client_handle); - - /* - * If there are no more blocks registered with the control - * library, we're done, otherwise, the callbacks for those - * blocks will pick this up and call complete. - */ - - if(client_handle->num_active_blocks == 0) - { - globus_i_ftp_client_transfer_complete(client_handle); - globus_i_ftp_client_debug_printf(1, + + /* If we haven't been restarted yet, then we will deal with + * the fault here. + */ + if(client_handle->state != GLOBUS_FTP_CLIENT_HANDLE_RESTART) + { + client_handle->state = GLOBUS_FTP_CLIENT_HANDLE_FAILURE; + + /* + * If we're in this function, then whatever buffers the + * user has registered will not yet be passed to the + * control library. That means we've got to call back for all + * of the data buffers which have been registered. + * + * Because we are in the FAILURE state, the plugins may + * *not* do a restart now. + */ + globus_i_ftp_client_data_flush(client_handle); + + /* + * If there are no more blocks registered with the control + * library, we're done, otherwise, the callbacks for those + * blocks will pick this up and call complete. + */ + + if(client_handle->num_active_blocks == 0) + { + globus_i_ftp_client_transfer_complete(client_handle); + globus_i_ftp_client_debug_printf(1, (stderr, "globus_l_ftp_client_connection_error() exiting\n")); globus_i_ftp_client_debug_states(2, client_handle); - - return; - } - } + + return; + } + } } else if(client_handle->op == GLOBUS_FTP_CLIENT_TRANSFER) { - if(client_handle->state != GLOBUS_FTP_CLIENT_HANDLE_RESTART) - { - globus_i_ftp_client_target_t * other_target = 0; - - client_handle->state = GLOBUS_FTP_CLIENT_HANDLE_FAILURE; - /* In a third party transfer, this fault can happen on - * either the source or destination target's control - * handle. - */ - if(client_handle->source == target) - { - other_target = client_handle->dest; - } - else if(client_handle->dest == target) - { - other_target = client_handle->source; - } - globus_assert(other_target != GLOBUS_NULL); - - /* - * if the other target is in the start or setup_connection - * state, then we can release complete w/failure - * immediately. Otherwise, we need to either abort the - * active command on it, or force it to close. - */ - if(other_target->state == GLOBUS_FTP_CLIENT_TARGET_START || - other_target->state == GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION) - { - if(target->state != GLOBUS_FTP_CLIENT_TARGET_FAULT && - target->state != GLOBUS_FTP_CLIENT_TARGET_CLOSED) - { - target->state = GLOBUS_FTP_CLIENT_TARGET_FAULT; - + if(client_handle->state != GLOBUS_FTP_CLIENT_HANDLE_RESTART) + { + globus_i_ftp_client_target_t * other_target = 0; + + client_handle->state = GLOBUS_FTP_CLIENT_HANDLE_FAILURE; + /* In a third party transfer, this fault can happen on + * either the source or destination target's control + * handle. + */ + if(client_handle->source == target) + { + other_target = client_handle->dest; + } + else if(client_handle->dest == target) + { + other_target = client_handle->source; + } + globus_assert(other_target != GLOBUS_NULL); + + /* + * if the other target is in the start or setup_connection + * state, then we can release complete w/failure + * immediately. Otherwise, we need to either abort the + * active command on it, or force it to close. + */ + if(other_target->state == GLOBUS_FTP_CLIENT_TARGET_START || + other_target->state == GLOBUS_FTP_CLIENT_TARGET_SETUP_CONNECTION) + { + if(target->state != GLOBUS_FTP_CLIENT_TARGET_FAULT && + target->state != GLOBUS_FTP_CLIENT_TARGET_CLOSED) + { + target->state = GLOBUS_FTP_CLIENT_TARGET_FAULT; + /* * Kill the current target---the other one is idle */ @@ -6142,7 +6142,7 @@ globus_l_ftp_client_connection_error( target->control_handle, globus_i_ftp_client_force_close_callback, target); - + if(result != GLOBUS_SUCCESS) { /* Shoot, that didn't work. Fake it. */ @@ -6153,18 +6153,18 @@ globus_l_ftp_client_connection_error( target); } } - } - else - { - if(other_target->state != GLOBUS_FTP_CLIENT_TARGET_FAULT && - other_target->state != GLOBUS_FTP_CLIENT_TARGET_CLOSED) - { + } + else + { + if(other_target->state != GLOBUS_FTP_CLIENT_TARGET_FAULT && + other_target->state != GLOBUS_FTP_CLIENT_TARGET_CLOSED) + { /* * If the target is doing something else, then we will * just kill it. */ other_target->state = GLOBUS_FTP_CLIENT_TARGET_FAULT; - + result = globus_ftp_control_force_close( other_target->control_handle, globus_i_ftp_client_force_close_callback, @@ -6179,20 +6179,20 @@ globus_l_ftp_client_connection_error( other_target); } } - + if(target->state != GLOBUS_FTP_CLIENT_TARGET_FAULT && - target->state != GLOBUS_FTP_CLIENT_TARGET_CLOSED) - { - /* + target->state != GLOBUS_FTP_CLIENT_TARGET_CLOSED) + { + /* * Kill the current target---the other one is idle now. */ target->state = GLOBUS_FTP_CLIENT_TARGET_FAULT; - + result = globus_ftp_control_force_close( target->control_handle, globus_i_ftp_client_force_close_callback, target); - + if(result != GLOBUS_SUCCESS) { /* Shoot, that didn't work. Fake it. */ @@ -6203,9 +6203,9 @@ globus_l_ftp_client_connection_error( target); } } - } - } - else if(error) + } + } + else if(error) { /* Mark the target for destruction, since we faulted on it. */ target->state = GLOBUS_FTP_CLIENT_TARGET_FAULT; @@ -6218,28 +6218,28 @@ globus_l_ftp_client_connection_error( /* Mark the target for destruction, since we faulted on it. */ target->state = GLOBUS_FTP_CLIENT_TARGET_FAULT; } - - /* If we haven't been restarted yet, then we will deal with - * the fault here. - */ - if(client_handle->state != GLOBUS_FTP_CLIENT_HANDLE_RESTART) - { - client_handle->state = GLOBUS_FTP_CLIENT_HANDLE_FAILURE; - globus_i_ftp_client_transfer_complete(client_handle); - - globus_i_ftp_client_debug_printf(1, + + /* If we haven't been restarted yet, then we will deal with + * the fault here. + */ + if(client_handle->state != GLOBUS_FTP_CLIENT_HANDLE_RESTART) + { + client_handle->state = GLOBUS_FTP_CLIENT_HANDLE_FAILURE; + globus_i_ftp_client_transfer_complete(client_handle); + + globus_i_ftp_client_debug_printf(1, (stderr, "globus_l_ftp_client_connection_error() exiting\n")); - return; - } + return; + } } globus_i_ftp_client_handle_unlock(client_handle); - - globus_i_ftp_client_debug_printf(1, + + globus_i_ftp_client_debug_printf(1, (stderr, "globus_l_ftp_client_connection_error() exiting\n")); globus_i_ftp_client_debug_states(2, client_handle); - + return; } /* globus_l_ftp_client_connection_error() */ @@ -6247,12 +6247,12 @@ globus_l_ftp_client_connection_error( static const char * globus_l_ftp_client_guess_buffer_command( - globus_i_ftp_client_handle_t * handle, - globus_i_ftp_client_target_t * target) + globus_i_ftp_client_handle_t * handle, + globus_i_ftp_client_target_t * target) { - int i; - globus_bool_t stor_desired = GLOBUS_FALSE; - globus_bool_t retr_desired = GLOBUS_FALSE; + int i; + globus_bool_t stor_desired = GLOBUS_FALSE; + globus_bool_t retr_desired = GLOBUS_FALSE; int first_maybe; if(handle->op == GLOBUS_FTP_CLIENT_GET || @@ -6262,41 +6262,41 @@ globus_l_ftp_client_guess_buffer_command( handle->op == GLOBUS_FTP_CLIENT_MLSR || (handle->op == GLOBUS_FTP_CLIENT_TRANSFER && handle->source == target)) { - retr_desired = GLOBUS_TRUE; + retr_desired = GLOBUS_TRUE; } if(handle->op == GLOBUS_FTP_CLIENT_PUT || (handle->op == GLOBUS_FTP_CLIENT_TRANSFER && handle->dest == target)) { - stor_desired = GLOBUS_TRUE; + stor_desired = GLOBUS_TRUE; } - + first_maybe = -1; for(i = 0; i < GLOBUS_FTP_CLIENT_LAST_BUFFER_COMMAND; i++) { globus_ftp_client_tristate_t is_supported; - + is_supported = globus_i_ftp_client_feature_get(target->features, i); - - if(is_supported && - ((globus_l_ftp_client_buffer_cmd_info[i].stor_ok && stor_desired) || - (globus_l_ftp_client_buffer_cmd_info[i].retr_ok && retr_desired))) - { - if(is_supported == GLOBUS_FTP_CLIENT_TRUE) - { - return globus_l_ftp_client_buffer_cmd_info[i].string; - } - else if(first_maybe < 0) - { - first_maybe = i; - } - } + + if(is_supported && + ((globus_l_ftp_client_buffer_cmd_info[i].stor_ok && stor_desired) || + (globus_l_ftp_client_buffer_cmd_info[i].retr_ok && retr_desired))) + { + if(is_supported == GLOBUS_FTP_CLIENT_TRUE) + { + return globus_l_ftp_client_buffer_cmd_info[i].string; + } + else if(first_maybe < 0) + { + first_maybe = i; + } + } } - + if(first_maybe >= 0) { return globus_l_ftp_client_buffer_cmd_info[first_maybe].string; } - + return NULL; } /* globus_l_ftp_client_guess_buffer_command() */ @@ -6316,18 +6316,18 @@ globus_l_ftp_client_guess_buffer_command( * The actual ftp target that we sent the command to. * @param ok * If set to GLOBUS_TRUE, then the last ftp buffer command - * worked. Otherwise, it failed. + * worked. Otherwise, it failed. */ static void globus_l_ftp_client_update_buffer_feature( - globus_i_ftp_client_handle_t * handle, - globus_i_ftp_client_target_t * target, - globus_ftp_client_tristate_t ok) + globus_i_ftp_client_handle_t * handle, + globus_i_ftp_client_target_t * target, + globus_ftp_client_tristate_t ok) { - int i; - globus_bool_t stor_desired = GLOBUS_FALSE; - globus_bool_t retr_desired = GLOBUS_FALSE; + int i; + globus_bool_t stor_desired = GLOBUS_FALSE; + globus_bool_t retr_desired = GLOBUS_FALSE; if(handle->op == GLOBUS_FTP_CLIENT_GET || handle->op == GLOBUS_FTP_CLIENT_LIST || @@ -6336,26 +6336,26 @@ globus_l_ftp_client_update_buffer_feature( handle->op == GLOBUS_FTP_CLIENT_MLSR || (handle->op == GLOBUS_FTP_CLIENT_TRANSFER && handle->source == target)) { - retr_desired = GLOBUS_TRUE; + retr_desired = GLOBUS_TRUE; } if(handle->op == GLOBUS_FTP_CLIENT_PUT || (handle->op == GLOBUS_FTP_CLIENT_TRANSFER && handle->dest == target)) { - stor_desired = GLOBUS_TRUE; + stor_desired = GLOBUS_TRUE; } for(i = 0; i < GLOBUS_FTP_CLIENT_LAST_BUFFER_COMMAND; i++) { - if(globus_i_ftp_client_feature_get( target->features, i) && - ((globus_l_ftp_client_buffer_cmd_info[i].stor_ok && stor_desired) || - (globus_l_ftp_client_buffer_cmd_info[i].retr_ok && retr_desired))) - { - if(globus_i_ftp_client_feature_get(target->features, i) != ok) - { - globus_i_ftp_client_feature_set(target->features, i, ok); - break; - } - } + if(globus_i_ftp_client_feature_get( target->features, i) && + ((globus_l_ftp_client_buffer_cmd_info[i].stor_ok && stor_desired) || + (globus_l_ftp_client_buffer_cmd_info[i].retr_ok && retr_desired))) + { + if(globus_i_ftp_client_feature_get(target->features, i) != ok) + { + globus_i_ftp_client_feature_set(target->features, i, ok); + break; + } + } } } /* globus_l_ftp_client_update_buffer_feature() */ @@ -6375,17 +6375,17 @@ globus_l_ftp_client_update_buffer_feature( static void globus_l_ftp_client_parse_restart_marker( - globus_i_ftp_client_handle_t * handle, - globus_ftp_control_response_t * response) + globus_i_ftp_client_handle_t * handle, + globus_ftp_control_response_t * response) { - globus_off_t offset, end; - char * p; - globus_result_t res; - int consumed; + globus_off_t offset, end; + char * p; + globus_result_t res; + int consumed; if(response->code != 111) { - return; + return; } p = (char *) response->response_buffer; @@ -6394,28 +6394,28 @@ globus_l_ftp_client_parse_restart_marker( while(!isdigit(*p)) p++; while( sscanf(p, "%"GLOBUS_OFF_T_FORMAT"-%"GLOBUS_OFF_T_FORMAT"%n", - &offset, &end, &consumed) >= 2) + &offset, &end, &consumed) >= 2) { - res = globus_ftp_client_restart_marker_insert_range( - &handle->restart_marker, - offset, - end); - - if(res) - { - break; - } - - p += consumed; - - if(*p == ',') - { - p++; - } - else - { - break; - } + res = globus_ftp_client_restart_marker_insert_range( + &handle->restart_marker, + offset, + end); + + if(res) + { + break; + } + + p += consumed; + + if(*p == ',') + { + p++; + } + else + { + break; + } } } /* globus_l_ftp_client_parse_restart_marker() */ @@ -6427,7 +6427,6 @@ globus_l_ftp_client_parse_cksm( globus_ftp_control_response_t * response) { char * p; - int rc; GlobusFuncName(globus_l_ftp_client_parse_cksm); if(response->code != 213) @@ -6440,7 +6439,7 @@ globus_l_ftp_client_parse_cksm( /* skip 213 */ p += 4; - rc=sscanf(p, "%s", client_handle->checksum); + sscanf(p, "%s", client_handle->checksum); } @@ -6448,10 +6447,10 @@ globus_l_ftp_client_parse_cksm( static void globus_l_ftp_client_parse_mdtm( - globus_i_ftp_client_handle_t * client_handle, - globus_ftp_control_response_t * response) + globus_i_ftp_client_handle_t * client_handle, + globus_ftp_control_response_t * response) { - char * p; + char * p; struct tm tm; struct tm gmt_now_tm; struct tm * gmt_now_tm_p; @@ -6459,15 +6458,15 @@ globus_l_ftp_client_parse_mdtm( time_t gmt_now; time_t now; time_t file_time; - float fraction; - unsigned long nsec = 0UL; - int rc; - int i; + float fraction; + unsigned long nsec = 0UL; + int rc; + int i; GlobusFuncName(globus_l_ftp_client_parse_mdtm); if(response->code != 213) { - return; + return; } p = (char *) response->response_buffer; @@ -6476,12 +6475,12 @@ globus_l_ftp_client_parse_mdtm( while(!isdigit(*p)) p++; if(strlen(p) < 14) - goto error_exit; + goto error_exit; for(i = 0; i < 14; i++) { - if(!isdigit(*(p+i))) - goto error_exit; + if(!isdigit(*(p+i))) + goto error_exit; } memset(&tm, '\0', sizeof(struct tm)); @@ -6489,7 +6488,7 @@ globus_l_ftp_client_parse_mdtm( rc = sscanf(p, "%04d", &tm.tm_year); if(rc != 1) { - goto error_exit; + goto error_exit; } tm.tm_year -= 1900; p += 4; @@ -6498,7 +6497,7 @@ globus_l_ftp_client_parse_mdtm( rc = sscanf(p, "%02d", &tm.tm_mon); if(rc != 1) { - goto error_exit; + goto error_exit; } tm.tm_mon--; p += 2; @@ -6507,7 +6506,7 @@ globus_l_ftp_client_parse_mdtm( rc = sscanf(p, "%02d", &tm.tm_mday); if(rc != 1) { - goto error_exit; + goto error_exit; } p += 2; @@ -6515,7 +6514,7 @@ globus_l_ftp_client_parse_mdtm( rc = sscanf(p, "%02d", &tm.tm_hour); if(rc != 1) { - goto error_exit; + goto error_exit; } p += 2; @@ -6523,7 +6522,7 @@ globus_l_ftp_client_parse_mdtm( rc = sscanf(p, "%02d", &tm.tm_min); if(rc != 1) { - goto error_exit; + goto error_exit; } p += 2; @@ -6531,41 +6530,41 @@ globus_l_ftp_client_parse_mdtm( rc = sscanf(p, "%02d", &tm.tm_sec); if(rc != 1) { - goto error_exit; + goto error_exit; } p += 2; if(*p == '.') { - sscanf(p, "%f", &fraction); - nsec = fraction * 1000000000; + sscanf(p, "%f", &fraction); + nsec = fraction * 1000000000; } - + file_time = mktime(&tm); if(file_time == (time_t) -1) { - goto error_exit; + goto error_exit; } - + now = time(&now); if(now == (time_t) -1) { - goto error_exit; + goto error_exit; } - + memset(&gmt_now_tm, '\0', sizeof(struct tm)); gmt_now_tm_p = globus_libc_gmtime_r(&now, &gmt_now_tm); if(gmt_now_tm_p == NULL) { - goto error_exit; + goto error_exit; } - + gmt_now = mktime(&gmt_now_tm); if(gmt_now == (time_t) -1) { - goto error_exit; + goto error_exit; } - + offset = now - gmt_now; client_handle->modification_time_pointer->tv_sec = file_time + offset; @@ -6576,12 +6575,12 @@ globus_l_ftp_client_parse_mdtm( error_exit: if(client_handle->err == GLOBUS_SUCCESS) { - client_handle->err = GLOBUS_I_FTP_CLIENT_ERROR_PROTOCOL_ERROR(); + client_handle->err = GLOBUS_I_FTP_CLIENT_ERROR_PROTOCOL_ERROR(); } } /* -We expect the response buffer for MLST to look like this: +We expect the response buffer for MLST to look like this: 250-Begin type=dir;modify=20020101224853;UNIX.mode=0755/pub/kernel/software @@ -6589,7 +6588,7 @@ We expect the response buffer for MLST to look like this: There may be multiple fact string lines, but the filenames must be the same. If there are multiple fact string lines, we verify that the filenames are the same -and concatenate the fact lists into a single fact list. The user will always +and concatenate the fact lists into a single fact list. The user will always get a single line consisting of "factlistfilename". If the response buffer doesn't look like that we exit with a protocol error. @@ -6597,10 +6596,10 @@ If the response buffer doesn't look like that we exit with a protocol error. static void globus_l_ftp_client_parse_mlst( - globus_i_ftp_client_handle_t * client_handle, - globus_ftp_control_response_t * response) + globus_i_ftp_client_handle_t * client_handle, + globus_ftp_control_response_t * response) { - char * p; + char * p; globus_byte_t * buffer; char * fact_list; char * this_filename; @@ -6614,19 +6613,19 @@ globus_l_ftp_client_parse_mlst( if(response->code != 250) { - return; + return; } - + buffer = (globus_byte_t *) globus_malloc( response->response_length * sizeof(globus_byte_t)); if(buffer == GLOBUS_NULL) { goto nomem_exit; } - + p = (char *) response->response_buffer; - /* advancing past the starting control response */ + /* advancing past the starting control response */ while(*p && *p != '\r' && *p != '\n') { p++; @@ -6635,24 +6634,24 @@ globus_l_ftp_client_parse_mlst( { p++; } - + /* every fact line starts with a space */ while(*p == ' ' && *(++p)) - { + { fact_list = p; - + /* filename starts after the first space no spaces are allowed in the fact list */ this_filename = strchr(p, ' '); if(this_filename == GLOBUS_NULL) { goto error_exit; - } + } fact_list_length = this_filename - p; - - /* copy current fact list to buffer */ + + /* copy current fact list to buffer */ memcpy(buffer + total_fact_list_length, fact_list, fact_list_length); - + total_fact_list_length += fact_list_length; /* advancing past the end of the filename */ @@ -6660,7 +6659,7 @@ globus_l_ftp_client_parse_mlst( while(*p && *p != '\r' && *p != '\n') { p++; - } + } /* if we have multiple fact strings for this file, check that the filenames are the same. exit with protocol error if not */ @@ -6671,42 +6670,42 @@ globus_l_ftp_client_parse_mlst( { goto error_exit; } - } + } else - { + { filename_length = p - this_filename; filename = this_filename; } - + /* advancing past the CRLF to the start of the next line */ while(*p && (*p == '\r' || *p == '\n')) { p++; - } - } - + } + } + if(*p == '\0' || filename_length == 0) { goto error_exit; } - + memcpy(buffer + total_fact_list_length, filename, filename_length); - + data_length = total_fact_list_length + filename_length; - - /* null terminate the buffer since the user + + /* null terminate the buffer since the user will likely treat it as a string */ buffer[data_length] = '\0'; - + *client_handle->mlst_buffer_pointer = buffer; - *client_handle->mlst_buffer_length_pointer = data_length; - + *client_handle->mlst_buffer_length_pointer = data_length; + return; error_exit: if(client_handle->err == GLOBUS_SUCCESS) { - client_handle->err = GLOBUS_I_FTP_CLIENT_ERROR_PROTOCOL_ERROR(); + client_handle->err = GLOBUS_I_FTP_CLIENT_ERROR_PROTOCOL_ERROR(); } globus_free(buffer); return; @@ -6714,7 +6713,7 @@ globus_l_ftp_client_parse_mlst( nomem_exit: if(client_handle->err == GLOBUS_SUCCESS) { - client_handle->err = GLOBUS_I_FTP_CLIENT_ERROR_OUT_OF_MEMORY(); + client_handle->err = GLOBUS_I_FTP_CLIENT_ERROR_OUT_OF_MEMORY(); } return; } /* globus_l_ftp_client_parse_mlst() */ @@ -6723,8 +6722,8 @@ globus_l_ftp_client_parse_mlst( static void globus_l_ftp_client_parse_cwd( - globus_i_ftp_client_handle_t * client_handle, - globus_ftp_control_response_t * response) + globus_i_ftp_client_handle_t * client_handle, + globus_ftp_control_response_t * response) { globus_byte_t * buffer; @@ -6732,12 +6731,12 @@ globus_l_ftp_client_parse_cwd( if(response->code != 250) { - return; + return; } - + if ( client_handle->mlst_buffer_pointer == NULL || - client_handle->mlst_buffer_length_pointer == NULL ) { - return; + client_handle->mlst_buffer_length_pointer == NULL ) { + return; } buffer = globus_malloc( @@ -6750,14 +6749,14 @@ globus_l_ftp_client_parse_cwd( memcpy( buffer, response->response_buffer, response->response_length ); *client_handle->mlst_buffer_pointer = buffer; - *client_handle->mlst_buffer_length_pointer = response->response_length; + *client_handle->mlst_buffer_length_pointer = response->response_length; return; nomem_exit: if(client_handle->err == GLOBUS_SUCCESS) { - client_handle->err = GLOBUS_I_FTP_CLIENT_ERROR_OUT_OF_MEMORY(); + client_handle->err = GLOBUS_I_FTP_CLIENT_ERROR_OUT_OF_MEMORY(); } return; } /* globus_l_ftp_client_parse_cwd() */ @@ -6765,11 +6764,11 @@ globus_l_ftp_client_parse_cwd( static void globus_l_ftp_client_parse_stat( - globus_i_ftp_client_handle_t * client_handle, - globus_ftp_control_response_t * response) + globus_i_ftp_client_handle_t * client_handle, + globus_ftp_control_response_t * response) { - char * p; - char * listing_start; + char * p; + char * listing_start; globus_byte_t * buffer = NULL; int listing_length = 0; char res_code[5]; @@ -6780,21 +6779,21 @@ globus_l_ftp_client_parse_stat( response->code != 212 && response->code != 213) { - goto error_exit; + goto error_exit; } - + snprintf(res_code, 5, "%d ", response->code); - + buffer = (globus_byte_t *) globus_malloc( response->response_length * sizeof(globus_byte_t)); if(buffer == GLOBUS_NULL) { goto nomem_exit; } - + p = (char *) response->response_buffer; - /* advancing past the starting control response */ + /* advancing past the starting control response */ while(*p && *p != '\r' && *p != '\n') { p++; @@ -6803,45 +6802,45 @@ globus_l_ftp_client_parse_stat( { p++; } - + listing_start = p; /* check for the end control response */ while(*p && strncmp(p, res_code, 4) != 0) - { + { /* advancing to the end of the listing */ while(*p && *p != '\r' && *p != '\n') { p++; - } + } /* advancing past the CRLF to the start of the next line */ while(*p && (*p == '\r' || *p == '\n')) { p++; - } - } + } + } listing_length = p - listing_start; - + if(*p == '\0' || listing_length == 0) { goto error_exit; } - + memcpy(buffer, listing_start, listing_length); - - /* null terminate the buffer since the user + + /* null terminate the buffer since the user will likely treat it as a string */ buffer[listing_length] = '\0'; - + *client_handle->mlst_buffer_pointer = buffer; - *client_handle->mlst_buffer_length_pointer = listing_length; - + *client_handle->mlst_buffer_length_pointer = listing_length; + return; error_exit: if(client_handle->err == GLOBUS_SUCCESS) { - client_handle->err = GLOBUS_I_FTP_CLIENT_ERROR_PROTOCOL_ERROR(); + client_handle->err = GLOBUS_I_FTP_CLIENT_ERROR_PROTOCOL_ERROR(); } if(buffer) { @@ -6852,7 +6851,7 @@ globus_l_ftp_client_parse_stat( nomem_exit: if(client_handle->err == GLOBUS_SUCCESS) { - client_handle->err = GLOBUS_I_FTP_CLIENT_ERROR_OUT_OF_MEMORY(); + client_handle->err = GLOBUS_I_FTP_CLIENT_ERROR_OUT_OF_MEMORY(); } return; } /* globus_l_ftp_client_parse_stat() */ @@ -6861,7 +6860,7 @@ globus_l_ftp_client_parse_stat( static globus_bool_t globus_l_ftp_client_can_cache_data_connection( - globus_i_ftp_client_target_t * target) + globus_i_ftp_client_target_t * target) { return GLOBUS_TRUE; } @@ -6869,9 +6868,9 @@ globus_l_ftp_client_can_cache_data_connection( static void globus_l_ftp_client_data_force_close_callback( - void * callback_arg, - globus_ftp_control_handle_t * control_handle, - globus_object_t * error) + void * callback_arg, + globus_ftp_control_handle_t * control_handle, + globus_object_t * error) { } @@ -6894,7 +6893,7 @@ globus_l_ftp_client_pp_src_add( &pl_source_url, &pl_dest_url, client_handle->attr.pipeline_arg); - + if(pl_source_url == NULL) { return GLOBUS_SUCCESS; @@ -6983,7 +6982,7 @@ globus_l_ftp_client_pp_dst_add( &pl_source_url, &pl_dest_url, client_handle->attr.pipeline_arg); - + if(pl_dest_url == NULL) { return GLOBUS_SUCCESS; @@ -7000,7 +6999,7 @@ globus_l_ftp_client_pp_dst_add( client_handle->no_callback_count++; globus_fifo_enqueue(&client_handle->dst_response_pending_queue, url_ent); - + if(target->attr->module_alg_str != GLOBUS_NULL) { globus_i_ftp_client_plugin_notify_command( @@ -7125,7 +7124,7 @@ globus_l_ftp_client_pp_get_next( memcpy(src_url_ent, url_ent, sizeof(globus_i_ftp_client_url_ent_t)); globus_fifo_enqueue(&client_handle->src_op_queue, src_url_ent); } - + return GLOBUS_SUCCESS; } @@ -7153,7 +7152,7 @@ globus_l_ftp_client_pp_xfer_dst_add( } url_ent = (globus_i_ftp_client_url_ent_t *) globus_fifo_dequeue(&client_handle->dst_op_queue); - + client_handle->no_callback_count++; globus_fifo_enqueue(&client_handle->dst_response_pending_queue, url_ent); @@ -7283,19 +7282,19 @@ globus_l_ftp_client_pp_xfer_src_add( static globus_result_t globus_l_ftp_client_use_gridftp2_getput( - globus_i_ftp_client_target_t * target, + globus_i_ftp_client_target_t * target, globus_bool_t * getput) { - globus_i_ftp_client_handle_t * client_handle; + globus_i_ftp_client_handle_t * client_handle; globus_ftp_client_handleattr_t handle_attr; - globus_result_t result; + globus_result_t result; client_handle = target->owner; handle_attr = &client_handle->attr; - /* Does target support GFD.47? + /* Does target support GFD.47? */ - result = + result = globus_ftp_client_handleattr_get_gridftp2(&handle_attr, getput); if(result != GLOBUS_SUCCESS || *getput == GLOBUS_FALSE) { @@ -7314,7 +7313,7 @@ globus_l_ftp_client_use_gridftp2_getput( /* Are GFD.47 extensions enabled? */ - if (globus_i_ftp_client_feature_get( + if (globus_i_ftp_client_feature_get( target->features, GLOBUS_FTP_CLIENT_FEATURE_GETPUT) != GLOBUS_FTP_CLIENT_TRUE) { @@ -7358,14 +7357,14 @@ globus_l_ftp_client_use_gridftp2_getput( static globus_result_t globus_l_ftp_client_send_get( - globus_i_ftp_client_target_t * target, + globus_i_ftp_client_target_t * target, char * pathname, globus_bool_t pasv) { - char * tmpstr = GLOBUS_NULL; - globus_i_ftp_client_handle_t * client_handle; - int rc, oldrc; - globus_result_t result; + char * tmpstr = GLOBUS_NULL; + globus_i_ftp_client_handle_t * client_handle; + int rc, oldrc; + globus_result_t result; client_handle = target->owner; @@ -7402,7 +7401,7 @@ globus_l_ftp_client_send_get( client_handle->pasv_address[0].port & 0xff); if(rc == oldrc) { - globus_libc_free(tmpstr); + globus_libc_free(tmpstr); return globus_error_put(GLOBUS_ERROR_NO_INFO); } } @@ -7414,7 +7413,7 @@ globus_l_ftp_client_send_get( "GET path=%s;%s" CRLF, pathname, tmpstr); - + if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) @@ -7422,7 +7421,7 @@ globus_l_ftp_client_send_get( globus_libc_free(tmpstr); return GLOBUS_SUCCESS; } - + result = globus_ftp_control_send_command( target->control_handle, @@ -7431,7 +7430,7 @@ globus_l_ftp_client_send_get( target, pathname, tmpstr); - + globus_libc_free(tmpstr); return result; @@ -7443,14 +7442,14 @@ globus_l_ftp_client_send_get( static globus_result_t globus_l_ftp_client_send_put( - globus_i_ftp_client_target_t * target, + globus_i_ftp_client_target_t * target, char * pathname, globus_bool_t pasv) { - char * tmpstr = GLOBUS_NULL; - globus_i_ftp_client_handle_t * client_handle; - int rc, oldrc; - globus_result_t result; + char * tmpstr = GLOBUS_NULL; + globus_i_ftp_client_handle_t * client_handle; + int rc, oldrc; + globus_result_t result; client_handle = target->owner; @@ -7487,7 +7486,7 @@ globus_l_ftp_client_send_put( client_handle->pasv_address[0].port & 0xff); if(rc == oldrc) { - globus_libc_free(tmpstr); + globus_libc_free(tmpstr); return globus_error_put(GLOBUS_ERROR_NO_INFO); } } @@ -7499,7 +7498,7 @@ globus_l_ftp_client_send_put( "PUT path=%s;%s" CRLF, pathname, tmpstr); - + if(client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_ABORT || client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_RESTART || client_handle->state == GLOBUS_FTP_CLIENT_HANDLE_FAILURE) @@ -7507,7 +7506,7 @@ globus_l_ftp_client_send_put( globus_libc_free(tmpstr); return GLOBUS_SUCCESS; } - + result = globus_ftp_control_send_command( target->control_handle, @@ -7516,7 +7515,7 @@ globus_l_ftp_client_send_put( target, pathname, tmpstr); - + globus_libc_free(tmpstr); return result; diff --git a/gridftp/client/source/test/lingering-get-test.c b/gridftp/client/source/test/lingering-get-test.c index 501f4331ca..84ea211217 100644 --- a/gridftp/client/source/test/lingering-get-test.c +++ b/gridftp/client/source/test/lingering-get-test.c @@ -18,7 +18,7 @@ * simple authenticated get which is not completed before * deactivation. * - * makes sure that the ftp client and control libraries will + * makes sure that the ftp client and control libraries will * correctly deal with a handle in a unfinished state before * deactivation. */ @@ -33,9 +33,9 @@ static int done = 0; static void done_cb( - void * user_arg, - globus_ftp_client_handle_t * handle, - globus_object_t * err) + void * user_arg, + globus_ftp_client_handle_t * handle, + globus_object_t * err) { char * tmpstr; @@ -47,18 +47,17 @@ done_cb( done = GLOBUS_TRUE; globus_cond_signal(&cond); globus_mutex_unlock(&lock); - + } int main(int argc, - char *argv[]) + char *argv[]) { - globus_ftp_client_handle_t handle; - globus_ftp_client_operationattr_t attr; - globus_result_t result; - char * src; - char * dst; - globus_ftp_client_handleattr_t handle_attr; + globus_ftp_client_handle_t handle; + globus_ftp_client_operationattr_t attr; + char * src; + char * dst; + globus_ftp_client_handleattr_t handle_attr; LTDL_SET_PRELOADED_SYMBOLS(); globus_module_activate(GLOBUS_FTP_CLIENT_MODULE); @@ -66,12 +65,12 @@ int main(int argc, globus_ftp_client_handleattr_init(&handle_attr); globus_ftp_client_operationattr_init(&attr); - test_parse_args(argc, - argv, - &handle_attr, - &attr, - &src, - &dst); + test_parse_args(argc, + argv, + &handle_attr, + &attr, + &src, + &dst); globus_mutex_init(&lock, GLOBUS_NULL); globus_cond_init(&cond, GLOBUS_NULL); @@ -79,12 +78,12 @@ int main(int argc, 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_ftp_client_get(&handle, + src, + &attr, + GLOBUS_NULL, + done_cb, + 0); globus_module_deactivate_all(); return done; diff --git a/gridftp/client/source/test/multiple-block-get-test.c b/gridftp/client/source/test/multiple-block-get-test.c index 87172baea3..34761a4c3a 100644 --- a/gridftp/client/source/test/multiple-block-get-test.c +++ b/gridftp/client/source/test/multiple-block-get-test.c @@ -33,45 +33,44 @@ static globus_bool_t error = GLOBUS_FALSE; static void done_cb( - void * user_arg, - globus_ftp_client_handle_t * handle, - globus_object_t * err) + void * user_arg, + globus_ftp_client_handle_t * handle, + globus_object_t * err) { char * tmpstr; if(err) tmpstr = " an"; else tmpstr = "out"; - if(err) { printf("done with%s error\n", tmpstr); + if(err) { printf("done with%s error\n", tmpstr); error = GLOBUS_TRUE; } globus_mutex_lock(&lock); done = GLOBUS_TRUE; globus_cond_signal(&cond); globus_mutex_unlock(&lock); - + } static void data_cb( - void * user_arg, - globus_ftp_client_handle_t * handle, - globus_object_t * err, - globus_byte_t * buffer, - globus_size_t length, - globus_off_t offset, - globus_bool_t eof) + void * user_arg, + globus_ftp_client_handle_t * handle, + globus_object_t * err, + globus_byte_t * buffer, + globus_size_t length, + globus_off_t offset, + globus_bool_t eof) { - globus_result_t result; fwrite(buffer, 1, length, stdout); if(!eof) { - result = globus_ftp_client_register_read(handle, - buffer, - BUFSIZE, - data_cb, - 0); + globus_ftp_client_register_read(handle, + buffer, + BUFSIZE, + data_cb, + 0); } else { @@ -81,14 +80,14 @@ data_cb( 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; - int i; - globus_ftp_client_handleattr_t handle_attr; - char * src; - char * dst; + globus_ftp_client_handle_t handle; + globus_ftp_client_operationattr_t attr; + globus_byte_t * buffer; + 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); @@ -99,43 +98,43 @@ int main(int argc, char **argv) globus_cond_init(&cond, GLOBUS_NULL); test_parse_args(argc, - argv, - &handle_attr, - &attr, - &src, - &dst); + argv, + &handle_attr, + &attr, + &src, + &dst); globus_ftp_client_handle_init(&handle, &handle_attr); done = GLOBUS_FALSE; result = globus_ftp_client_get(&handle, - src, - &attr, - GLOBUS_NULL, - done_cb, - 0); + src, + &attr, + GLOBUS_NULL, + done_cb, + 0); if(result != GLOBUS_SUCCESS) { - error = GLOBUS_TRUE; - done = GLOBUS_TRUE; + error = GLOBUS_TRUE; + done = GLOBUS_TRUE; } else { - for(i = 0; i < 5; i++) - { - buffer = globus_libc_malloc(BUFSIZE); - globus_ftp_client_register_read( - &handle, - buffer, - BUFSIZE, - data_cb, - 0); - } + for(i = 0; i < 5; i++) + { + buffer = globus_libc_malloc(BUFSIZE); + globus_ftp_client_register_read( + &handle, + buffer, + BUFSIZE, + data_cb, + 0); + } } globus_mutex_lock(&lock); while(!done) { - globus_cond_wait(&cond, &lock); + globus_cond_wait(&cond, &lock); } globus_mutex_unlock(&lock); @@ -144,7 +143,7 @@ int main(int argc, char **argv) if(test_abort_count && error) { - return 0; + return 0; } return error; } diff --git a/gridftp/control/source/configure.ac b/gridftp/control/source/configure.ac index 4ffe02c199..c57b493fb1 100644 --- a/gridftp/control/source/configure.ac +++ b/gridftp/control/source/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ([2.60]) -AC_INIT([globus_ftp_control], [9.10], [https://github.com/gridcf/gct/issues]) +AC_INIT([globus_ftp_control], [9.11], [https://github.com/gridcf/gct/issues]) AC_CONFIG_MACRO_DIR([m4]) AC_SUBST([MAJOR_VERSION], [${PACKAGE_VERSION%%.*}]) AC_SUBST([MINOR_VERSION], [${PACKAGE_VERSION##*.}]) diff --git a/gridftp/control/source/globus_ftp_control_data.c b/gridftp/control/source/globus_ftp_control_data.c index 68ddee325f..533e0fbd79 100644 --- a/gridftp/control/source/globus_ftp_control_data.c +++ b/gridftp/control/source/globus_ftp_control_data.c @@ -192,7 +192,7 @@ typedef struct globus_i_ftp_dc_transfer_handle_s globus_mutex_t * mutex; globus_i_ftp_dc_handle_t * whos_my_daddy; struct globus_ftp_control_handle_s * control_handle; - + globus_mutex_t order_mutex; globus_bool_t order_data; int order_ctr; @@ -301,7 +301,7 @@ globus_l_ftp_control_data_stream_connect_direction( globus_result_t globus_l_ftp_data_stream_stripe_poll( - globus_ftp_data_stripe_t * stripe); + globus_ftp_data_stripe_t * stripe); globus_result_t globus_l_ftp_data_stripe_poll( @@ -672,7 +672,7 @@ globus_i_ftp_control_data_set_netlogger( * else if priority_1 comes before priority_2, return < 0 * else return 0 */ - + static int globus_l_ftp_control_q_compare( @@ -682,10 +682,10 @@ globus_l_ftp_control_q_compare( int rc; globus_l_ftp_handle_table_entry_t * entry1; globus_l_ftp_handle_table_entry_t * entry2; - + entry1 = (globus_l_ftp_handle_table_entry_t *) priority_1; entry2 = (globus_l_ftp_handle_table_entry_t *) priority_2; - + if(entry1->offset > entry2->offset || entry1->eof) { rc = 1; @@ -766,7 +766,7 @@ globus_i_ftp_control_create_stack( !globus_list_empty(list); list = globus_list_rest(list)) { - driver_ent = + driver_ent = (globus_i_ftp_control_stack_entry_t *) globus_list_first(list); result = GLOBUS_SUCCESS; @@ -788,13 +788,13 @@ globus_i_ftp_control_create_stack( driver_ent->opts); } } - + return GLOBUS_SUCCESS; error: globus_xio_stack_destroy(*stack); return result; - + } void @@ -807,11 +807,11 @@ globus_i_ftp_control_unload_xio_drivers( { driver_ent = (globus_i_ftp_control_stack_entry_t *) globus_list_first(driver_list); - - + + if(driver_ent->driver_name) { - if(strcmp(driver_ent->driver_name, "tcp") != 0 && + if(strcmp(driver_ent->driver_name, "tcp") != 0 && strcmp(driver_ent->driver_name, "gsi") != 0) { /* globus_xio_driver_unload(driver_ent->driver); */ @@ -824,11 +824,11 @@ globus_i_ftp_control_unload_xio_drivers( globus_free(driver_ent->opts); } globus_free(driver_ent); - + globus_list_remove(&driver_list, driver_list); } } - + globus_result_t globus_i_ftp_control_load_xio_drivers( char * driver_string, @@ -856,7 +856,7 @@ globus_i_ftp_control_load_xio_drivers( if(ptr != NULL) { *ptr = '\0'; - tmp_str = ptr+1; + tmp_str = ptr+1; } else { @@ -893,7 +893,7 @@ globus_i_ftp_control_load_xio_drivers( globus_list_insert(&list, stack_ent); } - + globus_free(driver_str); } else @@ -919,7 +919,7 @@ globus_i_ftp_control_load_xio_drivers( globus_list_insert(driver_list, globus_list_first(list)); globus_list_remove(&list, list); } - + return GLOBUS_SUCCESS; error_load: @@ -1049,7 +1049,7 @@ globus_list_remove_element( */ globus_result_t globus_ftp_control_data_connect_read( - globus_ftp_control_handle_t * handle, + globus_ftp_control_handle_t * handle, globus_ftp_control_data_connect_callback_t callback, void * user_arg) { @@ -1101,7 +1101,7 @@ globus_ftp_control_data_connect_read( globus_object_free(dc_handle->connect_error); dc_handle->connect_error = GLOBUS_NULL; } - + if(dc_handle->mode == GLOBUS_FTP_CONTROL_MODE_STREAM) { if(dc_handle->state != GLOBUS_FTP_DATA_STATE_PORT && @@ -1244,7 +1244,7 @@ globus_ftp_control_data_set_interface( */ globus_result_t globus_ftp_control_data_connect_write( - globus_ftp_control_handle_t * handle, + globus_ftp_control_handle_t * handle, globus_ftp_control_data_connect_callback_t callback, void * user_arg) { @@ -1285,7 +1285,7 @@ globus_ftp_control_data_connect_write( globus_object_free(dc_handle->connect_error); dc_handle->connect_error = GLOBUS_NULL; } - + if(dc_handle->mode == GLOBUS_FTP_CONTROL_MODE_STREAM) { if(dc_handle->state != GLOBUS_FTP_DATA_STATE_PORT && @@ -1910,7 +1910,7 @@ globus_ftp_control_data_add_channels( * Sends an EOF message to each stripe along an open data connection. * * @param handle - * A pointer to a FTP control handle. This handle contains + * A pointer to a FTP control handle. This handle contains * the state for a connection. * @param count[] * This array of integers should contain an integer that @@ -2031,7 +2031,7 @@ globus_ftp_control_data_send_eof( : globus_error_construct_string( GLOBUS_FTP_CONTROL_MODULE, GLOBUS_NULL, - _FCSL("globus_ftp_control_data_send_eof() handle not in proper state %s"), + _FCSL("globus_ftp_control_data_send_eof() handle not in proper state %s"), globus_l_ftp_control_state_to_string(dc_handle->state)); } else if(!transfer_handle->eof_registered) @@ -2043,13 +2043,13 @@ globus_ftp_control_data_send_eof( } else if(dc_handle->send_eof) { - + err = globus_error_construct_string( GLOBUS_FTP_CONTROL_MODULE, GLOBUS_NULL, _FCSL("globus_ftp_control_data_send_eof() : The current handle is set to automatically send eof. Pass GLOBUS_FALSE to globus_ftp_control_local_send_eof().")); } - + if(err) { globus_mutex_unlock(&dc_handle->mutex); @@ -2307,8 +2307,8 @@ globus_ftp_control_data_remove_channels( */ globus_result_t globus_ftp_control_data_query_channels( - globus_ftp_control_handle_t * handle, - unsigned int * num_channels, + globus_ftp_control_handle_t * handle, + unsigned int * num_channels, unsigned int stripe_ndx) { globus_i_ftp_dc_handle_t * dc_handle; @@ -2397,8 +2397,8 @@ globus_ftp_control_data_query_channels( */ globus_result_t globus_ftp_control_data_get_total_data_channels( - globus_ftp_control_handle_t * handle, - unsigned int * num_channels, + globus_ftp_control_handle_t * handle, + unsigned int * num_channels, unsigned int stripe_ndx) { globus_i_ftp_dc_handle_t * dc_handle; @@ -2478,7 +2478,7 @@ globus_ftp_control_data_get_total_data_channels( globus_result_t globus_ftp_control_data_get_remote_hosts( - globus_ftp_control_handle_t * handle, + globus_ftp_control_handle_t * handle, globus_ftp_control_host_port_t * address, int * addr_count) { @@ -2491,7 +2491,6 @@ globus_ftp_control_data_get_remote_hosts( globus_ftp_data_connection_t * data_conn; int ctr; int ndx; - int count; static char * myname= "globus_ftp_control_data_get_remote_hosts"; @@ -2565,13 +2564,6 @@ globus_ftp_control_data_get_remote_hosts( return res; } - /* count the total # of connections */ - count = 0; - for(ctr = 0; ctr < transfer_handle->stripe_count; ctr++) - { - count += globus_list_size(transfer_handle->stripes[ctr].all_conn_list); - } - ndx = 0; for(ctr = 0; ctr < transfer_handle->stripe_count && ndx < *addr_count; ctr++) @@ -2620,7 +2612,7 @@ globus_ftp_control_data_get_remote_hosts( */ globus_result_t globus_ftp_control_local_send_eof( - globus_ftp_control_handle_t * handle, + globus_ftp_control_handle_t * handle, globus_bool_t send_eof) { globus_i_ftp_dc_handle_t * dc_handle; @@ -2666,8 +2658,8 @@ globus_ftp_control_local_send_eof( globus_result_t globus_ftp_control_get_parallelism( - globus_ftp_control_handle_t * handle, - globus_ftp_control_parallelism_t * parallelism) + globus_ftp_control_handle_t * handle, + globus_ftp_control_parallelism_t * parallelism) { globus_i_ftp_dc_handle_t * dc_handle; globus_object_t * err; @@ -2736,8 +2728,8 @@ globus_ftp_control_get_parallelism( */ globus_result_t globus_ftp_control_local_parallelism( - globus_ftp_control_handle_t * handle, - globus_ftp_control_parallelism_t * parallelism) + globus_ftp_control_handle_t * handle, + globus_ftp_control_parallelism_t * parallelism) { int ctr; globus_ftp_data_stripe_t * stripe; @@ -2824,7 +2816,7 @@ globus_ftp_control_local_parallelism( */ globus_result_t globus_ftp_control_local_pasv( - globus_ftp_control_handle_t * handle, + globus_ftp_control_handle_t * handle, globus_ftp_control_host_port_t * address) { globus_result_t result = GLOBUS_SUCCESS; @@ -2886,7 +2878,7 @@ globus_ftp_control_local_pasv( return globus_error_put(globus_error_construct_string( GLOBUS_FTP_CONTROL_MODULE, GLOBUS_NULL, - _FCSL("globus_ftp_control_local_pasv(): Handle not in the proper state %s."), + _FCSL("globus_ftp_control_local_pasv(): Handle not in the proper state %s."), globus_l_ftp_control_state_to_string(dc_handle->state))); } @@ -2900,13 +2892,13 @@ globus_ftp_control_local_pasv( address, 1); stripe = &dc_handle->transfer_handle->stripes[0]; - + result = globus_io_tcp_create_listener( &address->port, -1, &dc_handle->io_attr, &stripe->listener_handle); - + if(result == GLOBUS_SUCCESS) { dc_handle->transfer_handle->ref++; @@ -2920,7 +2912,7 @@ globus_ftp_control_local_pasv( { unsigned short p; char * dataip; - + if((dataip = getenv("GLOBUS_FTP_CLIENT_DATA_IP")) != NULL) { result = globus_libc_contact_string_to_ints( @@ -2931,7 +2923,7 @@ globus_ftp_control_local_pasv( } } else - { + { res = globus_io_tcp_get_local_address_ex( &handle->cc_handle.io_handle, address->host, @@ -2941,12 +2933,12 @@ globus_ftp_control_local_pasv( { char * cs; globus_sockaddr_t addr; - + GlobusLibcSockaddrSetFamily(addr, AF_INET); GlobusLibcSockaddrSetPort(addr, address->port); result = globus_libc_addr_to_contact_string( &addr, - GLOBUS_LIBC_ADDR_LOCAL | + GLOBUS_LIBC_ADDR_LOCAL | GLOBUS_LIBC_ADDR_NUMERIC | GLOBUS_LIBC_ADDR_IPV4, &cs); @@ -2964,7 +2956,7 @@ globus_ftp_control_local_pasv( } } } - + dc_handle->state = GLOBUS_FTP_DATA_STATE_PASV; } } @@ -3021,7 +3013,7 @@ globus_ftp_control_local_spas( */ globus_result_t globus_ftp_control_local_port( - globus_ftp_control_handle_t * handle, + globus_ftp_control_handle_t * handle, globus_ftp_control_host_port_t * address) { globus_result_t result = GLOBUS_SUCCESS; @@ -3079,7 +3071,7 @@ globus_ftp_control_local_port( return globus_error_put(globus_error_construct_string( GLOBUS_FTP_CONTROL_MODULE, GLOBUS_NULL, - _FCSL("globus_ftp_control_local_port(): Handle not in the proper state %s."), + _FCSL("globus_ftp_control_local_port(): Handle not in the proper state %s."), globus_l_ftp_control_state_to_string(dc_handle->state))); } @@ -3103,7 +3095,7 @@ globus_ftp_control_local_port( globus_result_t globus_ftp_control_get_spor( - globus_ftp_control_handle_t * handle, + globus_ftp_control_handle_t * handle, globus_ftp_control_host_port_t addresses[], unsigned int * num_addresses) { @@ -3201,9 +3193,9 @@ globus_ftp_control_get_spor( */ globus_result_t globus_ftp_control_local_spor( - globus_ftp_control_handle_t * handle, - globus_ftp_control_host_port_t addresses[], - unsigned int num_addresses) + globus_ftp_control_handle_t * handle, + globus_ftp_control_host_port_t addresses[], + unsigned int num_addresses) { globus_i_ftp_dc_handle_t * dc_handle; globus_object_t * err; @@ -3399,7 +3391,7 @@ globus_ftp_control_get_type( globus_result_t globus_ftp_control_get_mode( - globus_ftp_control_handle_t * handle, + globus_ftp_control_handle_t * handle, globus_ftp_control_mode_t * mode) { globus_i_ftp_dc_handle_t * dc_handle; @@ -3462,7 +3454,7 @@ globus_ftp_control_get_mode( */ globus_result_t globus_ftp_control_local_mode( - globus_ftp_control_handle_t * handle, + globus_ftp_control_handle_t * handle, globus_ftp_control_mode_t mode) { globus_i_ftp_dc_handle_t * dc_handle; @@ -3532,7 +3524,7 @@ globus_ftp_control_local_mode( * @param starting_offset * The starting offset to expect. May not be 0 for restarted transfers. * - * Note that this may result in slower transfers, or, if + * Note that this may result in slower transfers, or, if * the data arrives far out of order, failed transfers. */ globus_result_t @@ -3584,8 +3576,8 @@ globus_ftp_control_set_force_order( globus_mutex_lock(&dc_handle->mutex); { dc_handle->transfer_handle->order_data = order_data; - dc_handle->transfer_handle->order_next_offset = starting_offset; - dc_handle->transfer_handle->order_next_offset_passed = starting_offset; + dc_handle->transfer_handle->order_next_offset = starting_offset; + dc_handle->transfer_handle->order_next_offset_passed = starting_offset; } globus_mutex_unlock(&dc_handle->mutex); @@ -3609,13 +3601,13 @@ globus_ftp_control_set_force_order( */ globus_result_t globus_ftp_control_local_tcp_buffer( - globus_ftp_control_handle_t * handle, + globus_ftp_control_handle_t * handle, globus_ftp_control_tcpbuffer_t * tcp_buffer) { globus_i_ftp_dc_handle_t * dc_handle; globus_object_t * err; static char * myname= - "globus_ftp_control_local_tcp_buffer"; + "globus_ftp_control_local_tcp_buffer"; /* * error checking @@ -3645,21 +3637,21 @@ globus_ftp_control_local_tcp_buffer( if(tcp_buffer->mode != GLOBUS_FTP_CONTROL_TCPBUFFER_FIXED) { - err = globus_error_construct_string( - GLOBUS_FTP_CONTROL_MODULE, - GLOBUS_NULL, - _FCSL("globus_ftp_control_local_tcp_buffer(): buffer setting mode not supported")); - return globus_error_put(err); + err = globus_error_construct_string( + GLOBUS_FTP_CONTROL_MODULE, + GLOBUS_NULL, + _FCSL("globus_ftp_control_local_tcp_buffer(): buffer setting mode not supported")); + return globus_error_put(err); } if( 0 > tcp_buffer->fixed.size ) { - err = globus_error_construct_string( - GLOBUS_FTP_CONTROL_MODULE, - GLOBUS_NULL, - _FCSL("globus_ftp_control_local_tcp_buffer(): buffer size must be greater than 0")); - return globus_error_put(err); + err = globus_error_construct_string( + GLOBUS_FTP_CONTROL_MODULE, + GLOBUS_NULL, + _FCSL("globus_ftp_control_local_tcp_buffer(): buffer size must be greater than 0")); + return globus_error_put(err); } dc_handle = &handle->dc_handle; @@ -3667,15 +3659,15 @@ globus_ftp_control_local_tcp_buffer( globus_mutex_lock(&dc_handle->mutex); { dc_handle->tcp_buffer_size = tcp_buffer->fixed.size; - if(dc_handle->tcp_buffer_size > 0) - { - globus_io_attr_set_socket_sndbuf( - &dc_handle->io_attr, - dc_handle->tcp_buffer_size); - globus_io_attr_set_socket_rcvbuf( - &dc_handle->io_attr, - dc_handle->tcp_buffer_size); - } + if(dc_handle->tcp_buffer_size > 0) + { + globus_io_attr_set_socket_sndbuf( + &dc_handle->io_attr, + dc_handle->tcp_buffer_size); + globus_io_attr_set_socket_rcvbuf( + &dc_handle->io_attr, + dc_handle->tcp_buffer_size); + } } globus_mutex_unlock(&dc_handle->mutex); @@ -3694,7 +3686,7 @@ globus_ftp_control_data_get_socket_buf( globus_ftp_data_stripe_t * stripes; globus_i_ftp_dc_handle_t * dc_handle; static char * my_name = - "globus_ftp_control_data_get_socket_buf"; + "globus_ftp_control_data_get_socket_buf"; if(handle == NULL) { @@ -3768,7 +3760,7 @@ globus_ftp_control_data_get_socket_buf( my_name); return globus_error_put(err); } - res = globus_io_handle_get_socket_buf( + res = globus_io_handle_get_socket_buf( &data_conn->io_handle, rcvbuf, sndbuf); @@ -3856,7 +3848,7 @@ globus_ftp_control_data_get_retransmit_count( } tcp_driver = globus_io_compat_get_tcp_driver(); - + for(ctr = 0; ctr < transfer_handle->stripe_count; ctr++) { stripe = &transfer_handle->stripes[ctr]; @@ -3895,7 +3887,7 @@ globus_ftp_control_data_get_retransmit_count( { struct tcp_info tcpinfo; socklen_t len; - + len = sizeof(tcpinfo); res = globus_xio_system_socket_getsockopt( socket, IPPROTO_TCP, TCP_INFO, (void *) &tcpinfo, &len); @@ -3904,7 +3896,7 @@ globus_ftp_control_data_get_retransmit_count( globus_mutex_unlock(&dc_handle->mutex); return res; } - + count = tcpinfo.tcpi_total_retrans; } #endif @@ -3948,13 +3940,13 @@ globus_ftp_control_data_get_retransmit_count( * @param delegated_credential_handle */ globus_result_t globus_ftp_control_local_dcau( - globus_ftp_control_handle_t * handle, + globus_ftp_control_handle_t * handle, const globus_ftp_control_dcau_t * dcau, gss_cred_id_t delegated_credential_handle) { globus_i_ftp_dc_handle_t * dc_handle; static char * myname= - "globus_ftp_control_local_dcau"; + "globus_ftp_control_local_dcau"; globus_object_t * err; /* @@ -3975,9 +3967,9 @@ globus_ftp_control_local_dcau( dcau->mode != GLOBUS_FTP_CONTROL_DCAU_SUBJECT) { err = globus_error_construct_string( - GLOBUS_FTP_CONTROL_MODULE, - GLOBUS_NULL, - _FCSL("globus_ftp_control_local_dcau: invalid dcau mode")); + GLOBUS_FTP_CONTROL_MODULE, + GLOBUS_NULL, + _FCSL("globus_ftp_control_local_dcau: invalid dcau mode")); return globus_error_put(err); } @@ -3996,75 +3988,75 @@ globus_ftp_control_local_dcau( globus_mutex_lock(&dc_handle->mutex); { - if(dc_handle->dcau.mode == GLOBUS_FTP_CONTROL_DCAU_SUBJECT && - dc_handle->dcau.subject.subject != GLOBUS_NULL) - { - globus_libc_free(dc_handle->dcau.subject.subject); - dc_handle->dcau.subject.subject = GLOBUS_NULL; - } - dc_handle->dcau.mode = dcau->mode; - if(dcau->mode == GLOBUS_FTP_CONTROL_DCAU_SUBJECT) - { - dc_handle->dcau.subject.subject = - globus_libc_strdup(dcau->subject.subject); - } - - if(dc_handle->dcau.mode != GLOBUS_FTP_CONTROL_DCAU_NONE) - { - globus_io_secure_authorization_data_t auth_data; - globus_io_secure_authorization_data_initialize(&auth_data); - - globus_io_attr_set_secure_authentication_mode( - &dc_handle->io_attr, - GLOBUS_IO_SECURE_AUTHENTICATION_MODE_MUTUAL, - delegated_credential_handle); + if(dc_handle->dcau.mode == GLOBUS_FTP_CONTROL_DCAU_SUBJECT && + dc_handle->dcau.subject.subject != GLOBUS_NULL) + { + globus_libc_free(dc_handle->dcau.subject.subject); + dc_handle->dcau.subject.subject = GLOBUS_NULL; + } + dc_handle->dcau.mode = dcau->mode; + if(dcau->mode == GLOBUS_FTP_CONTROL_DCAU_SUBJECT) + { + dc_handle->dcau.subject.subject = + globus_libc_strdup(dcau->subject.subject); + } + + if(dc_handle->dcau.mode != GLOBUS_FTP_CONTROL_DCAU_NONE) + { + globus_io_secure_authorization_data_t auth_data; + globus_io_secure_authorization_data_initialize(&auth_data); + + globus_io_attr_set_secure_authentication_mode( + &dc_handle->io_attr, + GLOBUS_IO_SECURE_AUTHENTICATION_MODE_MUTUAL, + delegated_credential_handle); globus_io_attr_set_secure_proxy_mode( &dc_handle->io_attr, - GLOBUS_IO_SECURE_PROXY_MODE_MANY); - - switch(dc_handle->dcau.mode) - { - case GLOBUS_FTP_CONTROL_DCAU_SELF: - globus_io_attr_set_secure_authorization_mode( - &dc_handle->io_attr, - GLOBUS_IO_SECURE_AUTHORIZATION_MODE_SELF, - &auth_data); - break; - - case GLOBUS_FTP_CONTROL_DCAU_SUBJECT: - globus_io_secure_authorization_data_set_identity( - &auth_data, - dc_handle->dcau.subject.subject); - globus_io_attr_set_secure_authorization_mode( - &dc_handle->io_attr, - GLOBUS_IO_SECURE_AUTHORIZATION_MODE_IDENTITY, - &auth_data); - break; - default: - break; - } - - globus_io_secure_authorization_data_destroy(&auth_data); - } - else - { - dc_handle->protection = GLOBUS_FTP_CONTROL_PROTECTION_CLEAR; - - globus_io_attr_set_secure_channel_mode( - &dc_handle->io_attr, - GLOBUS_IO_SECURE_CHANNEL_MODE_CLEAR); - - globus_io_attr_set_secure_authorization_mode( - &dc_handle->io_attr, - GLOBUS_IO_SECURE_AUTHORIZATION_MODE_NONE, - GLOBUS_NULL); - - globus_io_attr_set_secure_authentication_mode( - &dc_handle->io_attr, - GLOBUS_IO_SECURE_AUTHENTICATION_MODE_NONE, - GLOBUS_NULL); - } + GLOBUS_IO_SECURE_PROXY_MODE_MANY); + + switch(dc_handle->dcau.mode) + { + case GLOBUS_FTP_CONTROL_DCAU_SELF: + globus_io_attr_set_secure_authorization_mode( + &dc_handle->io_attr, + GLOBUS_IO_SECURE_AUTHORIZATION_MODE_SELF, + &auth_data); + break; + + case GLOBUS_FTP_CONTROL_DCAU_SUBJECT: + globus_io_secure_authorization_data_set_identity( + &auth_data, + dc_handle->dcau.subject.subject); + globus_io_attr_set_secure_authorization_mode( + &dc_handle->io_attr, + GLOBUS_IO_SECURE_AUTHORIZATION_MODE_IDENTITY, + &auth_data); + break; + default: + break; + } + + globus_io_secure_authorization_data_destroy(&auth_data); + } + else + { + dc_handle->protection = GLOBUS_FTP_CONTROL_PROTECTION_CLEAR; + + globus_io_attr_set_secure_channel_mode( + &dc_handle->io_attr, + GLOBUS_IO_SECURE_CHANNEL_MODE_CLEAR); + + globus_io_attr_set_secure_authorization_mode( + &dc_handle->io_attr, + GLOBUS_IO_SECURE_AUTHORIZATION_MODE_NONE, + GLOBUS_NULL); + + globus_io_attr_set_secure_authentication_mode( + &dc_handle->io_attr, + GLOBUS_IO_SECURE_AUTHENTICATION_MODE_NONE, + GLOBUS_NULL); + } } globus_mutex_unlock(&dc_handle->mutex); @@ -4073,8 +4065,8 @@ globus_ftp_control_local_dcau( globus_result_t globus_ftp_control_get_dcau( - globus_ftp_control_handle_t * handle, - globus_ftp_control_dcau_t * dcau) + globus_ftp_control_handle_t * handle, + globus_ftp_control_dcau_t * dcau) { globus_i_ftp_dc_handle_t * dc_handle; globus_object_t * err = GLOBUS_SUCCESS; @@ -4109,19 +4101,19 @@ globus_ftp_control_get_dcau( globus_mutex_lock(&dc_handle->mutex); { - dcau->mode = dc_handle->dcau.mode; - if(dc_handle->dcau.mode == GLOBUS_FTP_CONTROL_DCAU_SUBJECT) - { - dcau->subject.subject = - globus_libc_strdup(dc_handle->dcau.subject.subject); - if(!dcau->subject.subject) - { - err = globus_error_construct_string( - GLOBUS_FTP_CONTROL_MODULE, - GLOBUS_NULL, - _FCSL("globus_ftp_control_get_dcau: malloc failed")); - } - } + dcau->mode = dc_handle->dcau.mode; + if(dc_handle->dcau.mode == GLOBUS_FTP_CONTROL_DCAU_SUBJECT) + { + dcau->subject.subject = + globus_libc_strdup(dc_handle->dcau.subject.subject); + if(!dcau->subject.subject) + { + err = globus_error_construct_string( + GLOBUS_FTP_CONTROL_MODULE, + GLOBUS_NULL, + _FCSL("globus_ftp_control_get_dcau: malloc failed")); + } + } } globus_mutex_unlock(&dc_handle->mutex); @@ -4131,12 +4123,12 @@ globus_ftp_control_get_dcau( globus_result_t globus_ftp_control_local_prot( - globus_ftp_control_handle_t * handle, - globus_ftp_control_protection_t protection) + globus_ftp_control_handle_t * handle, + globus_ftp_control_protection_t protection) { globus_i_ftp_dc_handle_t * dc_handle; static char * myname= - "globus_ftp_control_local_prot"; + "globus_ftp_control_local_prot"; globus_object_t * err; /* @@ -4169,64 +4161,64 @@ globus_ftp_control_local_prot( GlobusFTPControlDataTestMagic(dc_handle); if(dc_handle->dcau.mode == GLOBUS_FTP_CONTROL_DCAU_NONE) { - err = globus_error_construct_string( - GLOBUS_FTP_CONTROL_MODULE, - GLOBUS_NULL, - _FCSL("Cannot set protection without using dcau")); - return globus_error_put(err); + err = globus_error_construct_string( + GLOBUS_FTP_CONTROL_MODULE, + GLOBUS_NULL, + _FCSL("Cannot set protection without using dcau")); + return globus_error_put(err); } if(dc_handle->protection == GLOBUS_FTP_CONTROL_PROTECTION_CONFIDENTIAL) { - err = globus_error_construct_string( - GLOBUS_FTP_CONTROL_MODULE, - GLOBUS_NULL, - _FCSL("\"Confidential\" protection level not supported with GSSAPI")); - return globus_error_put(err); + err = globus_error_construct_string( + GLOBUS_FTP_CONTROL_MODULE, + GLOBUS_NULL, + _FCSL("\"Confidential\" protection level not supported with GSSAPI")); + return globus_error_put(err); } globus_mutex_lock(&dc_handle->mutex); { - dc_handle->protection = protection; - - switch(dc_handle->protection) - { - case GLOBUS_FTP_CONTROL_PROTECTION_CLEAR: - globus_io_attr_set_secure_channel_mode( - &dc_handle->io_attr, - GLOBUS_IO_SECURE_CHANNEL_MODE_CLEAR); - globus_io_attr_set_secure_protection_mode( - &dc_handle->io_attr, - GLOBUS_IO_SECURE_PROTECTION_MODE_NONE); - break; - - case GLOBUS_FTP_CONTROL_PROTECTION_SAFE: - globus_io_attr_set_secure_channel_mode( - &dc_handle->io_attr, - GLOBUS_IO_SECURE_CHANNEL_MODE_SSL_WRAP); - globus_io_attr_set_secure_protection_mode( - &dc_handle->io_attr, - GLOBUS_IO_SECURE_PROTECTION_MODE_SAFE); - break; - - case GLOBUS_FTP_CONTROL_PROTECTION_PRIVATE: - globus_io_attr_set_secure_channel_mode( - &dc_handle->io_attr, - GLOBUS_IO_SECURE_CHANNEL_MODE_SSL_WRAP); - globus_io_attr_set_secure_protection_mode( - &dc_handle->io_attr, - GLOBUS_IO_SECURE_PROTECTION_MODE_PRIVATE); - break; - - default: - globus_assert( - dc_handle->protection - == GLOBUS_FTP_CONTROL_PROTECTION_CLEAR || - dc_handle->protection - == GLOBUS_FTP_CONTROL_PROTECTION_SAFE || - dc_handle->protection - == GLOBUS_FTP_CONTROL_PROTECTION_PRIVATE); - break; - } + dc_handle->protection = protection; + + switch(dc_handle->protection) + { + case GLOBUS_FTP_CONTROL_PROTECTION_CLEAR: + globus_io_attr_set_secure_channel_mode( + &dc_handle->io_attr, + GLOBUS_IO_SECURE_CHANNEL_MODE_CLEAR); + globus_io_attr_set_secure_protection_mode( + &dc_handle->io_attr, + GLOBUS_IO_SECURE_PROTECTION_MODE_NONE); + break; + + case GLOBUS_FTP_CONTROL_PROTECTION_SAFE: + globus_io_attr_set_secure_channel_mode( + &dc_handle->io_attr, + GLOBUS_IO_SECURE_CHANNEL_MODE_SSL_WRAP); + globus_io_attr_set_secure_protection_mode( + &dc_handle->io_attr, + GLOBUS_IO_SECURE_PROTECTION_MODE_SAFE); + break; + + case GLOBUS_FTP_CONTROL_PROTECTION_PRIVATE: + globus_io_attr_set_secure_channel_mode( + &dc_handle->io_attr, + GLOBUS_IO_SECURE_CHANNEL_MODE_SSL_WRAP); + globus_io_attr_set_secure_protection_mode( + &dc_handle->io_attr, + GLOBUS_IO_SECURE_PROTECTION_MODE_PRIVATE); + break; + + default: + globus_assert( + dc_handle->protection + == GLOBUS_FTP_CONTROL_PROTECTION_CLEAR || + dc_handle->protection + == GLOBUS_FTP_CONTROL_PROTECTION_SAFE || + dc_handle->protection + == GLOBUS_FTP_CONTROL_PROTECTION_PRIVATE); + break; + } } globus_mutex_unlock(&dc_handle->mutex); @@ -4236,8 +4228,8 @@ globus_ftp_control_local_prot( globus_result_t globus_ftp_control_get_prot( - globus_ftp_control_handle_t * handle, - globus_ftp_control_protection_t * protection) + globus_ftp_control_handle_t * handle, + globus_ftp_control_protection_t * protection) { globus_i_ftp_dc_handle_t * dc_handle; globus_object_t * err = GLOBUS_SUCCESS; @@ -4271,7 +4263,7 @@ globus_ftp_control_get_prot( globus_mutex_lock(&dc_handle->mutex); { - *protection = dc_handle->protection; + *protection = dc_handle->protection; } globus_mutex_unlock(&dc_handle->mutex); @@ -4297,42 +4289,42 @@ globus_ftp_control_get_prot( */ globus_result_t globus_ftp_control_local_pbsz( - globus_ftp_control_handle_t * handle, - unsigned long bufsize) + globus_ftp_control_handle_t * handle, + unsigned long bufsize) { - globus_object_t * error = GLOBUS_NULL; + globus_object_t * error = GLOBUS_NULL; if(handle == GLOBUS_NULL) { - error = globus_error_construct_string( - GLOBUS_FTP_CONTROL_MODULE, - GLOBUS_NULL, - _FCSL("globus_ftp_control_local_pbsz: Handle argument is NULL")); - goto error_exit; + error = globus_error_construct_string( + GLOBUS_FTP_CONTROL_MODULE, + GLOBUS_NULL, + _FCSL("globus_ftp_control_local_pbsz: Handle argument is NULL")); + goto error_exit; } /* pbsz must be <= 32 bits */ if(bufsize != (bufsize & 0xffffffff)) { - error = globus_error_construct_string( - GLOBUS_FTP_CONTROL_MODULE, - GLOBUS_NULL, - _FCSL("globus_ftp_control_local_pbsz: Invalid buffer size")); - goto error_exit; + error = globus_error_construct_string( + GLOBUS_FTP_CONTROL_MODULE, + GLOBUS_NULL, + _FCSL("globus_ftp_control_local_pbsz: Invalid buffer size")); + goto error_exit; } globus_mutex_lock(&(handle->dc_handle.mutex)); { - if(handle->dc_handle.pbsz != 0UL && - handle->dc_handle.pbsz < bufsize) - { - error = globus_error_construct_string( - GLOBUS_FTP_CONTROL_MODULE, - GLOBUS_NULL, - _FCSL("globus_ftp_control_local_pbsz: Invalid buffer size")); + if(handle->dc_handle.pbsz != 0UL && + handle->dc_handle.pbsz < bufsize) + { + error = globus_error_construct_string( + GLOBUS_FTP_CONTROL_MODULE, + GLOBUS_NULL, + _FCSL("globus_ftp_control_local_pbsz: Invalid buffer size")); - goto unlock_exit; - } - handle->dc_handle.pbsz = bufsize; + goto unlock_exit; + } + handle->dc_handle.pbsz = bufsize; } unlock_exit: globus_mutex_unlock(&handle->dc_handle.mutex); @@ -4360,28 +4352,28 @@ globus_ftp_control_local_pbsz( */ globus_result_t globus_ftp_control_get_pbsz( - globus_ftp_control_handle_t * handle, - unsigned long * bufsize) + globus_ftp_control_handle_t * handle, + unsigned long * bufsize) { if(handle == GLOBUS_NULL) { - return globus_error_put( - globus_error_construct_string( - GLOBUS_FTP_CONTROL_MODULE, - GLOBUS_NULL, - _FCSL("globus_ftp_control_local_pbsz: Handle argument is NULL"))); + return globus_error_put( + globus_error_construct_string( + GLOBUS_FTP_CONTROL_MODULE, + GLOBUS_NULL, + _FCSL("globus_ftp_control_local_pbsz: Handle argument is NULL"))); } if(bufsize == GLOBUS_NULL) { - return globus_error_put( - globus_error_construct_string( - GLOBUS_FTP_CONTROL_MODULE, - GLOBUS_NULL, - _FCSL("globus_ftp_control_local_pbsz: bufsize argument is NULL"))); + return globus_error_put( + globus_error_construct_string( + GLOBUS_FTP_CONTROL_MODULE, + GLOBUS_NULL, + _FCSL("globus_ftp_control_local_pbsz: bufsize argument is NULL"))); } globus_mutex_lock(&(handle->dc_handle.mutex)); { - *bufsize = handle->dc_handle.pbsz; + *bufsize = handle->dc_handle.pbsz; } globus_mutex_unlock(&(handle->dc_handle.mutex)); @@ -4412,8 +4404,8 @@ globus_ftp_control_get_pbsz( */ globus_result_t globus_ftp_control_local_stru( - globus_ftp_control_handle_t * handle, - globus_ftp_control_structure_t structure) + globus_ftp_control_handle_t * handle, + globus_ftp_control_structure_t structure) { globus_i_ftp_dc_handle_t * dc_handle; globus_object_t * err; @@ -4499,13 +4491,13 @@ globus_ftp_control_local_stru( */ globus_result_t globus_ftp_control_data_write( - globus_ftp_control_handle_t * handle, - globus_byte_t * buffer, - globus_size_t length, - globus_off_t offset, - globus_bool_t eof, - globus_ftp_control_data_callback_t callback, - void * callback_arg) + globus_ftp_control_handle_t * handle, + globus_byte_t * buffer, + globus_size_t length, + globus_off_t offset, + globus_bool_t eof, + globus_ftp_control_data_callback_t callback, + void * callback_arg) { globus_i_ftp_dc_handle_t * dc_handle; globus_result_t result = GLOBUS_SUCCESS; @@ -4579,7 +4571,7 @@ globus_ftp_control_data_write( : globus_error_construct_string( GLOBUS_FTP_CONTROL_MODULE, GLOBUS_NULL, - _FCSL("globus_ftp_control_data_write(): Handle not in proper state. %s"), + _FCSL("globus_ftp_control_data_write(): Handle not in proper state. %s"), globus_l_ftp_control_state_to_string(dc_handle->state)); } else if(dc_handle->mode == GLOBUS_FTP_CONTROL_MODE_STREAM) @@ -4613,7 +4605,7 @@ globus_ftp_control_data_write( GLOBUS_NULL, _FCSL("globus_ftp_control_data_write(): Handle not in proper state.")); } - + if(err) { globus_mutex_unlock(&dc_handle->mutex); @@ -4629,7 +4621,7 @@ globus_ftp_control_data_write( globus_result_t globus_ftp_control_get_stripe_count( - globus_ftp_control_handle_t * handle, + globus_ftp_control_handle_t * handle, int * stripe_count) { globus_i_ftp_dc_handle_t * dc_handle; @@ -4700,11 +4692,11 @@ globus_ftp_control_get_stripe_count( */ globus_result_t globus_ftp_control_data_read( - globus_ftp_control_handle_t * handle, - globus_byte_t * buffer, - globus_size_t max_length, - globus_ftp_control_data_callback_t callback, - void * callback_arg) + globus_ftp_control_handle_t * handle, + globus_byte_t * buffer, + globus_size_t max_length, + globus_ftp_control_data_callback_t callback, + void * callback_arg) { globus_i_ftp_dc_handle_t * dc_handle; globus_result_t result = GLOBUS_SUCCESS; @@ -4761,7 +4753,7 @@ globus_ftp_control_data_read( globus_mutex_lock(&dc_handle->mutex); { err = GLOBUS_NULL; - + if(dc_handle->transfer_handle == GLOBUS_NULL) { err = dc_handle->connect_error @@ -4771,7 +4763,7 @@ globus_ftp_control_data_read( GLOBUS_NULL, _FCSL("Handle not in the proper state:transfer handle == NULL")); } - else if(dc_handle->state != GLOBUS_FTP_DATA_STATE_CONNECT_READ && + else if(dc_handle->state != GLOBUS_FTP_DATA_STATE_CONNECT_READ && (dc_handle->state != GLOBUS_FTP_DATA_STATE_EOF || dc_handle->transfer_handle->direction != GLOBUS_FTP_DATA_STATE_CONNECT_READ)) { @@ -4815,7 +4807,7 @@ globus_ftp_control_data_read( GLOBUS_NULL, _FCSL("globus_ftp_control_data_read(): Handle not using correct mode. Possible memory corruption.")); } - + if(err) { globus_mutex_unlock(&dc_handle->mutex); @@ -4834,11 +4826,11 @@ globus_ftp_control_data_read( */ globus_result_t globus_ftp_control_data_read_all( - globus_ftp_control_handle_t * handle, - globus_byte_t * buffer, - globus_size_t length, + globus_ftp_control_handle_t * handle, + globus_byte_t * buffer, + globus_size_t length, globus_ftp_control_data_callback_t callback, - void * callback_arg) + void * callback_arg) { globus_i_ftp_dc_handle_t * dc_handle; globus_ftp_data_stripe_t * stripe; @@ -4901,7 +4893,7 @@ globus_ftp_control_data_read_all( globus_mutex_lock(&dc_handle->mutex); { err = GLOBUS_NULL; - + if(dc_handle->transfer_handle == GLOBUS_NULL) { err = dc_handle->connect_error @@ -4928,13 +4920,13 @@ globus_ftp_control_data_read_all( GLOBUS_NULL, _FCSL("globus_ftp_control_data_read_all(): Only one read_all can be registered at a time. You must wait for a callback with eof set to GLOBUS_TRUE before calling read all again.")); } - + if(err) { globus_mutex_unlock(&dc_handle->mutex); return globus_error_put(err); } - + transfer_handle->big_buffer = buffer; transfer_handle->big_buffer_length = length; transfer_handle->big_buffer_cb = callback; @@ -5121,7 +5113,7 @@ globus_l_ftp_control_data_stream_read_write( globus_ftp_data_stripe_t * stripe; globus_object_t * err; globus_i_ftp_dc_transfer_handle_t * transfer_handle; - static char * my_name = + static char * my_name = "globus_l_ftp_control_data_stream_read_write"; if(dc_handle->state == GLOBUS_FTP_DATA_STATE_CLOSING) @@ -5304,9 +5296,9 @@ globus_l_ftp_control_data_eb_write( GLOBUS_NULL, GLOBUS_NULL, dc_handle); - tmp_ent->callback_table_handle = + tmp_ent->callback_table_handle = data_info.callback_table_handle; - + globus_fifo_enqueue(&stripe->command_q, (void *)tmp_ent); @@ -5667,9 +5659,9 @@ globus_X_ftp_control_local_layout( name); } globus_mutex_unlock(&globus_l_ftp_control_data_mutex); - + globus_free(name); - + if(layout_info == GLOBUS_NULL) { return globus_error_put(globus_error_construct_string( @@ -5745,7 +5737,7 @@ globus_X_ftp_control_local_layout( */ globus_result_t globus_ftp_control_create_data_info( - globus_ftp_control_handle_t * handle, + globus_ftp_control_handle_t * handle, globus_ftp_control_data_write_info_t * data_info, globus_byte_t * buffer, globus_size_t length, @@ -5844,7 +5836,7 @@ globus_ftp_control_create_data_info( */ globus_result_t globus_ftp_control_release_data_info( - globus_ftp_control_handle_t * handle, + globus_ftp_control_handle_t * handle, globus_ftp_control_data_write_info_t * data_info) { globus_i_ftp_dc_handle_t * dc_handle; @@ -5942,7 +5934,7 @@ globus_ftp_control_release_data_info( */ globus_result_t globus_ftp_control_data_write_stripe( - globus_ftp_control_handle_t * handle, + globus_ftp_control_handle_t * handle, globus_byte_t * buffer, globus_size_t length, globus_off_t offset, @@ -5997,7 +5989,7 @@ globus_ftp_control_data_write_stripe( _FCSL("Handle not in the proper state")); return globus_error_put(err); } - + res = globus_i_ftp_control_create_data_info( dc_handle, &data_info, @@ -6073,7 +6065,7 @@ globus_ftp_control_data_write_stripe( */ globus_result_t globus_X_ftp_control_data_write_stripe( - globus_ftp_control_handle_t * handle, + globus_ftp_control_handle_t * handle, globus_byte_t * buffer, globus_size_t length, globus_off_t offset, @@ -6145,10 +6137,10 @@ globus_X_ftp_control_data_write_stripe( globus_result_t globus_i_ftp_control_data_write_stripe( globus_i_ftp_dc_handle_t * dc_handle, - globus_byte_t * buffer, - globus_size_t length, - globus_off_t offset, - globus_bool_t eof, + globus_byte_t * buffer, + globus_size_t length, + globus_off_t offset, + globus_bool_t eof, int stripe_ndx, globus_ftp_control_data_write_info_t * data_info) { @@ -6366,7 +6358,7 @@ globus_l_ftp_data_stripe_poll( */ globus_result_t globus_l_ftp_data_stream_stripe_poll( - globus_ftp_data_stripe_t * stripe) + globus_ftp_data_stripe_t * stripe) { globus_l_ftp_handle_table_entry_t * entry; globus_ftp_data_connection_t * data_conn; @@ -6401,7 +6393,7 @@ globus_l_ftp_data_stream_stripe_poll( entry->buffer, entry->length, &tmp_len); - + if(entry->ascii_buffer) { tmp_buf = entry->ascii_buffer; @@ -6688,8 +6680,8 @@ globus_l_ftp_data_eb_poll( }/* end while */ } else if(dc_handle->state == GLOBUS_FTP_DATA_STATE_CONNECT_READ - || (dc_handle->state == GLOBUS_FTP_DATA_STATE_EOF && - transfer_handle->direction == GLOBUS_FTP_DATA_STATE_CONNECT_READ)) + || (dc_handle->state == GLOBUS_FTP_DATA_STATE_EOF && + transfer_handle->direction == GLOBUS_FTP_DATA_STATE_CONNECT_READ)) { /* * if we are reading a big buffer @@ -6768,13 +6760,13 @@ globus_l_ftp_data_eb_poll( globus_fifo_dequeue(&stripe->free_conn_q); if(transfer_handle->order_data) - { + { /* forcing ordered data */ checked_order = GLOBUS_TRUE; - + /* find offset we are looking for */ - while(data_conn->offset != - transfer_handle->order_next_offset && + while(data_conn->offset != + transfer_handle->order_next_offset && !globus_fifo_empty(&stripe->free_conn_q)) { globus_fifo_enqueue(&remaining_conn_q, data_conn); @@ -6783,14 +6775,14 @@ globus_l_ftp_data_eb_poll( } globus_i_ftp_control_debug_printf(9, - (stderr, "w: %"GLOBUS_OFF_T_FORMAT", h: %"GLOBUS_OFF_T_FORMAT", %p\n", - transfer_handle->order_next_offset, + (stderr, "w: %"GLOBUS_OFF_T_FORMAT", h: %"GLOBUS_OFF_T_FORMAT", %p\n", + transfer_handle->order_next_offset, data_conn->offset, (void *) data_conn)); - - /* if this stream has the offset we want, + + /* if this stream has the offset we want, * register the read, otherwise queue up the read */ - if(data_conn->offset == transfer_handle->order_next_offset) + if(data_conn->offset == transfer_handle->order_next_offset) { do_read = GLOBUS_TRUE; transfer_handle->order_ctr = 0; @@ -6800,7 +6792,7 @@ globus_l_ftp_data_eb_poll( do_read = GLOBUS_FALSE; done = GLOBUS_TRUE; globus_fifo_enqueue(&remaining_conn_q, data_conn); - + /* offset not available, restore queues */ globus_fifo_enqueue(&remaining_command_q, entry); while(!globus_fifo_empty(&stripe->command_q)) @@ -6852,7 +6844,7 @@ globus_l_ftp_data_eb_poll( globus_l_ftp_eb_read_callback, (void *)entry); globus_assert(res == GLOBUS_SUCCESS); - + transfer_handle->order_next_offset += entry->length; } } @@ -6865,12 +6857,12 @@ globus_l_ftp_data_eb_poll( done = GLOBUS_TRUE; } }/* end while */ - if(dc_handle->state == GLOBUS_FTP_DATA_STATE_CONNECT_READ && + if(dc_handle->state == GLOBUS_FTP_DATA_STATE_CONNECT_READ && transfer_handle->order_data) { int pending_connections; - - pending_connections = + + pending_connections = stripe->total_connection_count + stripe->outstanding_connections - globus_fifo_size(&stripe->free_conn_q); @@ -6881,7 +6873,7 @@ globus_l_ftp_data_eb_poll( globus_fifo_size(&stripe->free_conn_q), pending_connections)); if(pending_connections == 0 && checked_order) - { + { /* give time for pending incoming connections */ if(transfer_handle->order_ctr > stripe->total_connection_count * 2 + 10) { @@ -7324,7 +7316,7 @@ globus_l_ftp_control_stripes_destroy( &data_conn->io_handle, globus_l_ftp_io_close_callback, (void *)callback_info); - + if(res != GLOBUS_SUCCESS) { res = globus_callback_register_oneshot( @@ -7458,7 +7450,7 @@ globus_l_ftp_control_data_adjust_connection( { data_conn = (globus_ftp_data_connection_t *) globus_fifo_dequeue(&stripe->free_conn_q); - globus_list_remove(&stripe->all_conn_list, + globus_list_remove(&stripe->all_conn_list, globus_list_search(stripe->all_conn_list, data_conn)); data_conn->eod = GLOBUS_TRUE; @@ -7549,7 +7541,7 @@ globus_l_ftp_control_command_flush_callback( } } globus_mutex_unlock(&dc_handle->mutex); - + if(entry->error) { globus_object_free(entry->error); @@ -7606,7 +7598,7 @@ globus_l_ftp_control_command_kickout( dc_handle = entry->dc_handle; GlobusFTPControlDataTestMagic(dc_handle); transfer_handle = entry->transfer_handle; - + if(entry->callback) { entry->callback( @@ -7637,7 +7629,7 @@ globus_l_ftp_control_command_kickout( } globus_free(entry); - + } static @@ -7736,7 +7728,7 @@ globus_i_ftp_control_data_cc_init( dc_handle->connect_error = GLOBUS_NULL; globus_io_tcpattr_init(&dc_handle->io_attr); globus_io_attr_set_tcp_nodelay(&dc_handle->io_attr, - GLOBUS_TRUE); + GLOBUS_TRUE); dc_handle->layout_func = GLOBUS_NULL; dc_handle->layout_user_arg = GLOBUS_NULL; @@ -7804,7 +7796,7 @@ globus_l_ftp_control_dc_dec_ref( if(dc_handle->close_callback != GLOBUS_NULL && globus_list_empty(dc_handle->transfer_list)) { - globus_result_t res; + globus_result_t res; GlobusTimeReltimeSet(reltime, 0, 0); res = globus_callback_register_oneshot( GLOBUS_NULL, @@ -7832,10 +7824,10 @@ globus_l_ftp_control_dc_dec_ref( globus_priority_q_destroy(&transfer_handle->ordered_buffer_q); globus_handle_table_destroy(&transfer_handle->handle_table); globus_free(transfer_handle->stripes); - - globus_assert(dc_handle->transfer_handle != transfer_handle && + + globus_assert(dc_handle->transfer_handle != transfer_handle && "Destroying a transfer_handle we still have a pointer to"); - + globus_free(transfer_handle); globus_cond_signal(&globus_l_ftp_control_data_cond); } @@ -7902,7 +7894,7 @@ globus_i_ftp_control_data_cc_destroy( { dc_handle->initialized = GLOBUS_FALSE; res = GLOBUS_SUCCESS; - globus_io_tcpattr_destroy(&dc_handle->io_attr); + globus_io_tcpattr_destroy(&dc_handle->io_attr); if(dc_handle->nl_io_handle_set) { globus_netlogger_handle_destroy(&dc_handle->nl_io_handle); @@ -7920,7 +7912,7 @@ globus_i_ftp_control_data_cc_destroy( { globus_libc_free(dc_handle->dcau.subject.subject); } - + if(dc_handle->connect_error) { globus_object_free(dc_handle->connect_error); @@ -8219,7 +8211,6 @@ globus_l_ftp_io_close_callback( globus_l_ftp_data_callback_info_t * callback_info; globus_ftp_control_data_callback_t eof_callback = GLOBUS_NULL; globus_l_ftp_handle_table_entry_t * eof_cb_ent; - globus_bool_t poll; callback_info = (globus_l_ftp_data_callback_info_t *)arg; @@ -8266,13 +8257,13 @@ globus_l_ftp_io_close_callback( globus_mutex_lock(&dc_handle->mutex); { - poll = !globus_l_ftp_control_dc_dec_ref(transfer_handle); + globus_l_ftp_control_dc_dec_ref(transfer_handle); /* * decrement the reference the callbacks had */ if(eof_callback != GLOBUS_NULL) { - poll = !globus_l_ftp_control_dc_dec_ref(transfer_handle); + globus_l_ftp_control_dc_dec_ref(transfer_handle); } } globus_mutex_unlock(&dc_handle->mutex); @@ -8293,14 +8284,6 @@ globus_l_ftp_io_close_callback( data_conn->free_me = GLOBUS_TRUE; } } - - /* - This is not needed and introduces a race - if(poll) - { - globus_l_ftp_data_stripe_poll(dc_handle); - } - */ } @@ -8321,9 +8304,9 @@ globus_l_ftp_stream_write_eof_callback( globus_ftp_control_handle_t * control_handle; globus_ftp_data_connection_t * data_conn; globus_byte_t * buffer = GLOBUS_NULL; - void * big_buffer_cb_arg; - globus_ftp_control_data_callback_t big_buffer_cb = GLOBUS_NULL; - globus_byte_t * big_buffer = GLOBUS_NULL; + void * big_buffer_cb_arg; + globus_ftp_control_data_callback_t big_buffer_cb = GLOBUS_NULL; + globus_byte_t * big_buffer = GLOBUS_NULL; globus_bool_t poll; entry = (globus_l_ftp_handle_table_entry_t *) arg; @@ -8531,7 +8514,7 @@ globus_l_ftp_stream_listen_callback( user_arg = data_conn->user_arg; stripe_ndx = stripe->stripe_ndx; globus_free(callback_info); - } + } /* * remove reference for listener callback @@ -8540,7 +8523,7 @@ globus_l_ftp_stream_listen_callback( { dc_handle->connect_error = globus_object_copy(error); } - + poll = !globus_l_ftp_control_dc_dec_ref(transfer_handle); if(poll) { @@ -8553,7 +8536,7 @@ globus_l_ftp_stream_listen_callback( if(callback != GLOBUS_NULL) { callback(user_arg, control_handle, stripe_ndx, GLOBUS_FALSE, error); - + /* * if the user wanted a callback we must dec the reference * it had after we call it. @@ -8658,9 +8641,9 @@ globus_l_ftp_stream_accept_connect_callback( type, GLOBUS_IO_ERROR_TYPE_IO_CANCELLED)) { - globus_list_remove_element( - &stripe->all_conn_list, - data_conn); + globus_list_remove_element( + &stripe->all_conn_list, + data_conn); globus_l_ftp_control_stripes_destroy(dc_handle, error); } @@ -8698,7 +8681,7 @@ globus_l_ftp_stream_accept_connect_callback( globus_fifo_enqueue(&stripe->free_conn_q, data_conn); stripe->connection_count++; } - + if(error && !dc_handle->connect_error) { dc_handle->connect_error = globus_object_copy(error); @@ -8711,12 +8694,12 @@ globus_l_ftp_stream_accept_connect_callback( { callback(user_arg, control_handle, stripe_ndx, GLOBUS_FALSE, error); } - + if(error) { globus_object_free(error); } - + globus_mutex_lock(&dc_handle->mutex); { if(callback != GLOBUS_NULL) @@ -9236,11 +9219,11 @@ globus_l_ftp_eb_listen_callback( callback = data_conn->callback; user_arg = data_conn->user_arg; stripe_ndx = stripe->stripe_ndx; - } + } /* * remove reference for listener callback */ - + if(error && !dc_handle->connect_error) { dc_handle->connect_error = globus_object_copy(error); @@ -9444,7 +9427,7 @@ globus_l_ftp_eb_accept_callback( } globus_mutex_unlock(&dc_handle->mutex); } - + if(error) { globus_object_free(error); @@ -9506,7 +9489,7 @@ globus_l_ftp_eb_read_header_callback( else { if(eb_header->descriptor & GLOBUS_FTP_CONTROL_DATA_DESCRIPTOR_EOD) - { + { /* set connection state eod and local state eod */ data_conn->eod = GLOBUS_TRUE; eod = GLOBUS_TRUE; @@ -9552,13 +9535,13 @@ globus_l_ftp_eb_read_header_callback( /* * next assertion happens if the writer breaks * the protocol and sends a CLOSE prior to - * an EOD. + * an EOD. * - * TODO: stop transfer and return error to user + * TODO: stop transfer and return error to user */ globus_assert(data_conn->reusing || data_conn->eod); - /* + /* * if local eod state is true it means we have not * already preformed the following needed steps so * do them now. @@ -9568,7 +9551,7 @@ globus_l_ftp_eb_read_header_callback( stripe->eods_received++; stripe->connection_count--; } - /* + /* * if not local eod but conn state eod, it means that * that we have added the connection to the free_cache * list and must remove it @@ -9581,7 +9564,7 @@ globus_l_ftp_eb_read_header_callback( stripe->free_cache_list, data_conn)); } - /* + /* * remove from all list before closing */ globus_list_remove_element( @@ -9660,10 +9643,10 @@ globus_l_ftp_eb_read_header_callback( else { globus_off_t end_offset; - globus_off_t end_buffer; + globus_off_t end_buffer; - end_offset = ((globus_off_t) data_conn->bytes_ready) + - data_conn->offset; + end_offset = ((globus_off_t) data_conn->bytes_ready) + + data_conn->offset; end_buffer = ((globus_off_t) transfer_handle->big_buffer_length); @@ -9676,7 +9659,7 @@ globus_l_ftp_eb_read_header_callback( error = globus_error_construct_string( GLOBUS_FTP_CONTROL_MODULE, GLOBUS_NULL, - _FCSL("too much data has been sent.")); + _FCSL("too much data has been sent.")); globus_l_ftp_control_stripes_destroy(dc_handle, error); } else @@ -9719,7 +9702,7 @@ globus_l_ftp_eb_read_header_callback( globus_free(eb_header); - + if(error != GLOBUS_NULL) { globus_object_free(error); @@ -9735,7 +9718,7 @@ globus_l_ftp_data_order_read_cb( globus_i_ftp_dc_transfer_handle_t * transfer_handle; globus_bool_t done = GLOBUS_FALSE; int rc; - + entry = (globus_l_ftp_handle_table_entry_t *) ent; transfer_handle = entry->transfer_handle; dc_handle = entry->dc_handle; @@ -9746,18 +9729,18 @@ globus_l_ftp_data_order_read_cb( (void *)entry, (void *)entry); globus_assert(rc == GLOBUS_SUCCESS); - - while(!done && + + while(!done && !globus_priority_q_empty(&transfer_handle->ordered_buffer_q)) { - entry = (globus_l_ftp_handle_table_entry_t *) + entry = (globus_l_ftp_handle_table_entry_t *) globus_priority_q_first( &transfer_handle->ordered_buffer_q); globus_i_ftp_control_debug_printf(9, - (stderr, "bw: %"GLOBUS_OFF_T_FORMAT", bh: %"GLOBUS_OFF_T_FORMAT"\n", + (stderr, "bw: %"GLOBUS_OFF_T_FORMAT", bh: %"GLOBUS_OFF_T_FORMAT"\n", transfer_handle->order_next_offset_passed, entry->offset)); - + if(transfer_handle->order_next_offset_passed == entry->offset) { entry = (globus_l_ftp_handle_table_entry_t *) @@ -9831,7 +9814,7 @@ globus_l_ftp_eb_read_callback( transfer_handle = stripe->whos_my_daddy; control_handle = dc_handle->whos_my_daddy; globus_i_ftp_control_debug_printf(9, - (stderr, "readcb: %"GLOBUS_OFF_T_FORMAT", %p\n", + (stderr, "readcb: %"GLOBUS_OFF_T_FORMAT", %p\n", data_conn->offset, (void *) data_conn)); @@ -9972,7 +9955,7 @@ globus_l_ftp_eb_read_callback( { globus_free(entry->ascii_buffer); } - + if(transfer_handle->order_data) { free_entry = GLOBUS_FALSE; @@ -9991,7 +9974,7 @@ globus_l_ftp_eb_read_callback( } } globus_mutex_unlock(&dc_handle->mutex); - + if(free_entry) { if(entry->callback != GLOBUS_NULL) @@ -10023,7 +10006,7 @@ globus_l_ftp_eb_read_callback( } } globus_mutex_unlock(&dc_handle->mutex); - + if(error != GLOBUS_NULL) { globus_object_free(error); @@ -10184,7 +10167,7 @@ globus_l_ftp_eb_connect_callback( globus_fifo_enqueue(&stripe->free_conn_q, data_conn); } } - + if(error && !dc_handle->connect_error) { dc_handle->connect_error = globus_object_copy(error); @@ -10210,12 +10193,12 @@ globus_l_ftp_eb_connect_callback( GLOBUS_TRUE); globus_free(eof_cb_ent); } - + if(error) { globus_object_free(error); } - + globus_mutex_lock(&dc_handle->mutex); { /* @@ -10616,11 +10599,11 @@ globus_l_ftp_eb_send_eof_callback( globus_mutex_lock(&dc_handle->mutex); { - /* in case of error we ended up never calling the user cb, since - * we destroy right after this -- save original error now so + /* in case of error we ended up never calling the user cb, since + * we destroy right after this -- save original error now so * we can check later if we should fire_cb */ initial_state = dc_handle->state; - + globus_assert(eof_ent->dc_handle->transfer_handle != NULL); if(result != GLOBUS_SUCCESS) { @@ -10674,7 +10657,7 @@ globus_l_ftp_eb_send_eof_callback( fire_cb = GLOBUS_TRUE; globus_free(tmp_ent->count); globus_free(tmp_ent); - } + } else { transfer_handle->send_eof_ent = tmp_ent; @@ -10899,7 +10882,7 @@ globus_l_ftp_control_data_encode( globus_off_t in_size) { globus_off_t x; - int ind; + int ind; x = (globus_off_t) in_size; @@ -10907,74 +10890,74 @@ globus_l_ftp_control_data_encode( if(sizeof(globus_off_t) < 8) { - buf[ind++] = 0; + buf[ind++] = 0; } else { - buf[ind++] = (x >> 56) & 0xff; + buf[ind++] = (x >> 56) & 0xff; } if(sizeof(globus_off_t) < 7) { - buf[ind++] = 0; + buf[ind++] = 0; } else { - buf[ind++] = (x >> 48) & 0xff; + buf[ind++] = (x >> 48) & 0xff; } if(sizeof(globus_off_t) < 6) { - buf[ind++] = 0; + buf[ind++] = 0; } else { - buf[ind++] = (x >> 40) & 0xff; + buf[ind++] = (x >> 40) & 0xff; } if(sizeof(globus_off_t) < 5) { - buf[ind++] = 0; + buf[ind++] = 0; } else { - buf[ind++] = (x >> 32) & 0xff; + buf[ind++] = (x >> 32) & 0xff; } if(sizeof(globus_off_t) < 4) { - buf[ind++] = 0; + buf[ind++] = 0; } else { - buf[ind++] = (x >> 24) & 0xff; + buf[ind++] = (x >> 24) & 0xff; } if(sizeof(globus_off_t) < 3) { - buf[ind++] = 0; + buf[ind++] = 0; } else { - buf[ind++] = (x >> 16) & 0xff; + buf[ind++] = (x >> 16) & 0xff; } if(sizeof(globus_off_t) < 2) { - buf[ind++] = 0; + buf[ind++] = 0; } else { - buf[ind++] = (x >> 8) & 0xff; + buf[ind++] = (x >> 8) & 0xff; } if(sizeof(globus_off_t) < 1) { - buf[ind++] = 0; + buf[ind++] = 0; } else { - buf[ind++] = (x) & 0xff; + buf[ind++] = (x) & 0xff; } } /* globus_l_ftp_control_data_encode() */ @@ -10985,106 +10968,106 @@ globus_l_ftp_control_data_decode( globus_byte_t * buf, globus_off_t * out_size) { - globus_off_t x; - globus_bool_t overflow; + globus_off_t x; + globus_bool_t overflow; x = 0; overflow = GLOBUS_FALSE; if(sizeof(globus_off_t) >= 8) { - x += ((globus_off_t) buf[0]) << 56; + x += ((globus_off_t) buf[0]) << 56; } else { - if(buf[0] != 0) - { - overflow = GLOBUS_TRUE; - } + if(buf[0] != 0) + { + overflow = GLOBUS_TRUE; + } } if(sizeof(globus_off_t) >= 7) { - x += ((globus_off_t) buf[1]) << 48; + x += ((globus_off_t) buf[1]) << 48; } else { - if(buf[1] != 0) - { - overflow = GLOBUS_TRUE; - } + if(buf[1] != 0) + { + overflow = GLOBUS_TRUE; + } } if(sizeof(globus_off_t) >= 6) { - x += ((globus_off_t) buf[2]) << 40; + x += ((globus_off_t) buf[2]) << 40; } else { - if(buf[2] != 0) - { - overflow = GLOBUS_TRUE; - } + if(buf[2] != 0) + { + overflow = GLOBUS_TRUE; + } } if(sizeof(globus_off_t) >= 5) { - x += ((globus_off_t) buf[3]) << 32; + x += ((globus_off_t) buf[3]) << 32; } else { - if(buf[3] != 0) - { - overflow = GLOBUS_TRUE; - } + if(buf[3] != 0) + { + overflow = GLOBUS_TRUE; + } } if(sizeof(globus_off_t) >= 4) { - x += ((globus_off_t) buf[4]) << 24; + x += ((globus_off_t) buf[4]) << 24; } else { - if(buf[4] != 0) - { - overflow = GLOBUS_TRUE; - } + if(buf[4] != 0) + { + overflow = GLOBUS_TRUE; + } } if(sizeof(globus_off_t) >= 3) { - x += ((globus_off_t) buf[5]) << 16; + x += ((globus_off_t) buf[5]) << 16; } else { - if(buf[5] != 0) - { - overflow = GLOBUS_TRUE; - } + if(buf[5] != 0) + { + overflow = GLOBUS_TRUE; + } } if(sizeof(globus_off_t) >= 2) { - x += ((globus_off_t) buf[6]) << 8; + x += ((globus_off_t) buf[6]) << 8; } else { - if(buf[6] != 0) - { - overflow = GLOBUS_TRUE; - } + if(buf[6] != 0) + { + overflow = GLOBUS_TRUE; + } } if(sizeof(globus_off_t) >= 1) { - x += ((globus_off_t) buf[7]); + x += ((globus_off_t) buf[7]); } else { - if(buf[7] != 0) - { - overflow = GLOBUS_TRUE; - } + if(buf[7] != 0) + { + overflow = GLOBUS_TRUE; + } } /* should do something with overflow? */ @@ -11107,7 +11090,7 @@ globus_l_ftp_control_state_to_string( static const char * eof = "EOF"; static const char * send_eof = "SEND_EOF"; static const char * unknown = "UNKNOWN"; - + switch(state) { case GLOBUS_FTP_DATA_STATE_NONE: diff --git a/gridftp/control/source/globus_ftp_control_server.c b/gridftp/control/source/globus_ftp_control_server.c index 932726005a..3060531c9c 100644 --- a/gridftp/control/source/globus_ftp_control_server.c +++ b/gridftp/control/source/globus_ftp_control_server.c @@ -45,55 +45,55 @@ typedef struct globus_ftp_l_command_hash_entry_s } globus_ftp_l_command_hash_entry_t; -static void +static void globus_l_ftp_control_listen_cb( - void * arg, + void * arg, globus_io_handle_t * handle, globus_result_t result); -static void +static void globus_l_ftp_control_accept_cb( - void * arg, + void * arg, globus_io_handle_t * handle, globus_result_t result); -static void +static void globus_l_ftp_control_stop_server_cb( - void * arg, + void * arg, globus_io_handle_t * handle, globus_result_t result); static void globus_l_ftp_control_read_command_cb( - void * arg, + void * arg, globus_io_handle_t * handle, globus_result_t result, - globus_byte_t * buf, + globus_byte_t * buf, globus_size_t nbytes); -static void +static void globus_l_ftp_control_send_response_cb( - void * arg, + void * arg, globus_io_handle_t * handle, globus_result_t result, - globus_byte_t * buf, + globus_byte_t * buf, globus_size_t nbytes); -static void +static void globus_l_ftp_control_auth_write_cb( - void * arg, + void * arg, globus_io_handle_t * handle, globus_result_t result, - globus_byte_t * buf, + globus_byte_t * buf, globus_size_t nbytes); -static void +static void globus_l_ftp_control_auth_read_cb( - void * arg, + void * arg, globus_io_handle_t * handle, globus_result_t result, - globus_byte_t * buf, + globus_byte_t * buf, globus_size_t nbytes); globus_result_t globus_l_ftp_control_parse_sbuf_cmd( @@ -121,7 +121,7 @@ globus_result_t globus_l_ftp_control_parse_mode_cmd( globus_ftp_control_command_t * command); globus_result_t globus_l_ftp_control_parse_opts_cmd( - globus_ftp_control_command_t * command); + globus_ftp_control_command_t * command); globus_result_t globus_l_ftp_control_parse_string_arg( globus_ftp_control_command_t * command); @@ -131,8 +131,8 @@ globus_result_t globus_l_ftp_control_parse_no_arg( #endif -/* - * Hardcoded replies used int the accept/authentication process +/* + * Hardcoded replies used int the accept/authentication process */ const char * globus_i_ftp_server_220_reply= @@ -152,7 +152,7 @@ const char * globus_i_ftp_server_334_reply= * @details * This function will set up (i.e. initialize all mutexes and * variables) a globus ftp server handle. It will also enter the - * handle in a list used by the module activation/deactivation functions. + * handle in a list used by the module activation/deactivation functions. * * @param handle * The handle to initialize. @@ -160,7 +160,7 @@ const char * globus_i_ftp_server_334_reply= * - GLOBUS_SUCCESS * - invalid handle */ -globus_result_t +globus_result_t globus_ftp_control_server_handle_init( globus_ftp_control_server_t * handle) { @@ -210,7 +210,7 @@ globus_ftp_control_server_handle_init( */ -globus_result_t +globus_result_t globus_ftp_control_server_handle_destroy( globus_ftp_control_server_t * handle) { @@ -224,10 +224,10 @@ globus_ftp_control_server_handle_destroy( ); } - if(handle->state == + if(handle->state == GLOBUS_FTP_CONTROL_SERVER_LISTENING) { - + return globus_error_put( globus_error_construct_string( GLOBUS_FTP_CONTROL_MODULE, @@ -235,7 +235,7 @@ globus_ftp_control_server_handle_destroy( _FCSL("globus_ftp_control_server_handle_destroy: handle is still listening")) ); } - + globus_mutex_lock(&globus_l_ftp_server_handle_list_mutex); { globus_mutex_destroy(&(handle->mutex)); @@ -268,7 +268,7 @@ globus_ftp_control_server_handle_destroy( * The callback function called when connection requests * are made. * @param callback_arg - * The user argument passed to the callback function when + * The user argument passed to the callback function when * connection requests are made. * * @note I'm not providing any mechanism for making sure that this @@ -322,7 +322,7 @@ globus_ftp_control_server_listen( * The callback function called when connection requests * are made. * @param callback_arg - * The user argument passed to the callback function when + * The user argument passed to the callback function when * connection requests are made. * * @note I'm not providing any mechanism for making sure that this @@ -402,7 +402,7 @@ globus_ftp_control_server_listen_ex( globus_mutex_unlock(&(server_handle->mutex)); backlog=-1; - + globus_io_attr_set_socket_oobinline(attr, GLOBUS_TRUE); globus_io_attr_set_tcp_nodelay(attr, GLOBUS_TRUE); @@ -410,36 +410,36 @@ globus_ftp_control_server_listen_ex( backlog, attr, &server_handle->io_handle); - + if(rc != GLOBUS_SUCCESS) { return rc; } - + globus_mutex_lock(&(server_handle->mutex)); { server_handle->state=GLOBUS_FTP_CONTROL_SERVER_LISTENING; } globus_mutex_unlock(&(server_handle->mutex)); - + rc=globus_io_tcp_register_listen(&server_handle->io_handle, globus_l_ftp_control_listen_cb, (void *) server_handle); - + if(rc != GLOBUS_SUCCESS) { return rc; } - + return GLOBUS_SUCCESS; } #ifdef GLOBUS_INTERNAL_DOC /** - * Internal callback for the globus_io_tcp_register_listen function. - * + * Internal callback for the globus_io_tcp_register_listen function. + * * This is a internal callback used with the * globus_io_tcp_register_listen function, which in this library is * used for detecting connections to a listening "server" socket. @@ -459,15 +459,15 @@ globus_ftp_control_server_listen_ex( * * @note If a error is detected in this function the user callback is * called with an appropriate error object and the function - * returns. + * returns. */ #endif -static void +static void globus_l_ftp_control_listen_cb( - void * arg, + void * arg, globus_io_handle_t * handle, globus_result_t result) { @@ -490,11 +490,11 @@ globus_l_ftp_control_listen_cb( (server_handle->callback)(server_handle->callback_arg, server_handle, GLOBUS_NULL); - + rc=globus_io_tcp_register_listen(&server_handle->io_handle, globus_l_ftp_control_listen_cb, arg); - + if(rc != GLOBUS_SUCCESS) { error=globus_error_get(rc); @@ -516,11 +516,11 @@ globus_l_ftp_control_listen_cb( * @details * This function initializes a command structure based on a null * terminated string representing one line of input from the - * client. The command structure is used as a convenience to determine + * client. The command structure is used as a convenience to determine * what command the client issued. This function parses a command * string sent by a client and populates the command argument * appropriately. In the GSSAPI case it will also decode and unwrap - * the command before parsing it. + * the command before parsing it. * * @param command * A pointer to the command structure to be initialized @@ -543,7 +543,7 @@ globus_ftp_control_command_init( char * decoded_cmd = GLOBUS_NULL; globus_result_t rc; globus_ftp_l_command_hash_entry_t * command_hash_entry; - + length=strlen(raw_command); command->noop.raw_command= @@ -569,7 +569,7 @@ globus_ftp_control_command_init( } else { - command->noop.raw_command[j]=raw_command[i]; + command->noop.raw_command[j]=raw_command[i]; j++; } } @@ -586,7 +586,7 @@ globus_ftp_control_command_init( return rc; } } - + if(decoded_cmd != GLOBUS_NULL) { globus_libc_free(command->noop.raw_command); @@ -600,7 +600,7 @@ globus_ftp_control_command_init( sscanf(command->noop.raw_command,"%4s",cmd); i=0; - + while(cmd[i] != '\0') { cmd[i]=toupper(cmd[i]); @@ -621,7 +621,7 @@ globus_ftp_control_command_init( command->code = GLOBUS_FTP_CONTROL_COMMAND_UNKNOWN; rc = GLOBUS_SUCCESS; } - + return rc; } @@ -631,7 +631,7 @@ globus_ftp_control_command_init( * @details * This function frees up the memory allocated to the command * argument. - * + * * @param command * The command structure whose associated memory is to be freed */ @@ -648,13 +648,13 @@ globus_ftp_control_command_destroy( _FCSL("globus_ftp_control_command_destroy: command argument is NULL")) ); } - + globus_libc_free(command->noop.raw_command); - + switch(command->code) { case GLOBUS_FTP_CONTROL_COMMAND_SITE: - case GLOBUS_FTP_CONTROL_COMMAND_DELE: + case GLOBUS_FTP_CONTROL_COMMAND_DELE: case GLOBUS_FTP_CONTROL_COMMAND_RMD: case GLOBUS_FTP_CONTROL_COMMAND_MKD: case GLOBUS_FTP_CONTROL_COMMAND_NLST: @@ -684,7 +684,7 @@ globus_ftp_control_command_destroy( case GLOBUS_FTP_CONTROL_COMMAND_SPOR: { globus_libc_free(command->spor.host_port); - break; + break; } default: break; @@ -697,7 +697,7 @@ globus_ftp_control_command_destroy( * @brief Copy of GridFTP command * @ingroup globus_ftp_control_server * @details - * This function should be called when the user needs to make a + * This function should be called when the user needs to make a * copy of a command structure. * * @param dest @@ -717,7 +717,7 @@ globus_ftp_control_command_copy( GLOBUS_FTP_CONTROL_MODULE, GLOBUS_NULL, _FCSL("globus_ftp_control_command_copy: dest argument is NULL")) - ); + ); } if(src == GLOBUS_NULL) @@ -727,13 +727,13 @@ globus_ftp_control_command_copy( GLOBUS_FTP_CONTROL_MODULE, GLOBUS_NULL, _FCSL("globus_ftp_control_command_copy: src argument is NULL")) - ); + ); } dest->code=src->code; dest->noop.raw_command=globus_libc_strdup(src->noop.raw_command); - + if(dest->noop.raw_command == GLOBUS_NULL) { return globus_error_put( @@ -741,14 +741,14 @@ globus_ftp_control_command_copy( GLOBUS_FTP_CONTROL_MODULE, GLOBUS_NULL, _FCSL("globus_ftp_control_command_copy: strdup failed")) - ); + ); } - + switch(dest->code) { case GLOBUS_FTP_CONTROL_COMMAND_UNKNOWN: case GLOBUS_FTP_CONTROL_COMMAND_SITE: - case GLOBUS_FTP_CONTROL_COMMAND_DELE: + case GLOBUS_FTP_CONTROL_COMMAND_DELE: case GLOBUS_FTP_CONTROL_COMMAND_RMD: case GLOBUS_FTP_CONTROL_COMMAND_MKD: case GLOBUS_FTP_CONTROL_COMMAND_NLST: @@ -772,12 +772,12 @@ globus_ftp_control_command_copy( case GLOBUS_FTP_CONTROL_COMMAND_QUIT: dest->noop.string_arg = GLOBUS_NULL; - + if(src->noop.string_arg != GLOBUS_NULL) { dest->noop.string_arg= globus_libc_strdup(src->noop.string_arg); - + if(dest->noop.string_arg == GLOBUS_NULL) { globus_libc_free(dest->noop.raw_command); @@ -786,7 +786,7 @@ globus_ftp_control_command_copy( GLOBUS_FTP_CONTROL_MODULE, GLOBUS_NULL, _FCSL("globus_ftp_control_command_copy: strdup failed")) - ); + ); } } break; @@ -801,7 +801,7 @@ globus_ftp_control_command_copy( case GLOBUS_FTP_CONTROL_COMMAND_SPOR: dest->spor.num_args=src->spor.num_args; dest->spor.host_port = (globus_ftp_control_host_port_t *) - globus_libc_malloc(src->spor.num_args * + globus_libc_malloc(src->spor.num_args * sizeof(globus_ftp_control_host_port_t)); if(dest->spor.host_port == GLOBUS_NULL) { @@ -811,12 +811,12 @@ globus_ftp_control_command_copy( GLOBUS_FTP_CONTROL_MODULE, GLOBUS_NULL, _FCSL("globus_ftp_control_command_copy: malloc failed")) - ); + ); } - + memcpy(dest->spor.host_port, src->spor.host_port, - src->spor.num_args * + src->spor.num_args * sizeof(globus_ftp_control_host_port_t)); break; case GLOBUS_FTP_CONTROL_COMMAND_TYPE: @@ -840,9 +840,9 @@ globus_ftp_control_command_copy( GLOBUS_FTP_CONTROL_MODULE, GLOBUS_NULL, _FCSL("globus_ftp_control_command_copy: Unknown command")) - ); + ); } - + return GLOBUS_SUCCESS; } @@ -851,10 +851,10 @@ globus_ftp_control_command_copy( * @ingroup globus_ftp_control_server * @details * This function stops listening on the given listener object - * for client connections. All existing client connections are + * for client connections. All existing client connections are * left open. * - * @param listener + * @param listener * the globus_ftp_control_server_t object that should * no longer listen for connections. * @param callback @@ -871,10 +871,10 @@ globus_ftp_control_server_stop( { globus_result_t rc; globus_i_ftp_server_passthru_cb_arg_t * cb_arg; - + if(listener == GLOBUS_NULL) - { + { return globus_error_put( globus_error_construct_string( GLOBUS_FTP_CONTROL_MODULE, @@ -892,10 +892,10 @@ globus_ftp_control_server_stop( _FCSL("globus_ftp_control_server_stop: callback argument is NULL")) ); } - + globus_mutex_lock(&(listener->mutex)); { - if(listener->state != + if(listener->state != GLOBUS_FTP_CONTROL_SERVER_LISTENING) { globus_mutex_unlock(&(listener->mutex)); @@ -908,7 +908,7 @@ globus_ftp_control_server_stop( cb_arg = (globus_i_ftp_server_passthru_cb_arg_t *) globus_libc_malloc( sizeof(globus_i_ftp_server_passthru_cb_arg_t)); - + if(cb_arg == GLOBUS_NULL) { return globus_error_put( @@ -931,7 +931,7 @@ globus_ftp_control_server_stop( globus_libc_free(cb_arg); return rc; } - + return GLOBUS_SUCCESS; } @@ -939,8 +939,8 @@ globus_ftp_control_server_stop( #ifdef GLOBUS_INTERNAL_DOC /** - * Internal callback for the globus_io_register_close function. - * + * Internal callback for the globus_io_register_close function. + * * This is an internal callback used as part of the * globus_ftp_control_server_stop function. It checks the result of * the close and calls the user callback. @@ -952,20 +952,20 @@ globus_ftp_control_server_stop( * The globus_io handle for the connection. In practice this * represents the socket fd for the connection. * @param result - * The result of the close operation + * The result of the close operation * * @return void * * @note If a error is detected in this function the user callback is * called with an appropriate error object or ftp response and - * the function returns. + * the function returns. */ #endif -static void +static void globus_l_ftp_control_stop_server_cb( - void * arg, + void * arg, globus_io_handle_t * handle, globus_result_t result) { @@ -973,7 +973,7 @@ globus_l_ftp_control_stop_server_cb( globus_object_t * error; cb_arg = (globus_i_ftp_server_passthru_cb_arg_t *) arg; - + if(result != GLOBUS_SUCCESS){ error=globus_error_get(result); (cb_arg->callback)(cb_arg->callback_arg, @@ -1004,9 +1004,9 @@ globus_l_ftp_control_stop_server_cb( * connection. This function must be called to accept that user * connection request. Once the connection is established or if * a error occurs, the callback function is called. - * + * * @param listener - * The server object that received the connection request. + * The server object that received the connection request. * @param handle * The control connection object. This structure will be populated * and passed to the callback when the client is authorized. This @@ -1050,12 +1050,12 @@ globus_ftp_control_server_accept( GLOBUS_FTP_CONTROL_MODULE, GLOBUS_NULL, _FCSL("globus_ftp_control_server_accept: listener argument is NULL")) - ); + ); } globus_mutex_lock(&(listener->mutex)); { - if(listener->state != + if(listener->state != GLOBUS_FTP_CONTROL_SERVER_LISTENING) { globus_mutex_unlock(&(listener->mutex)); @@ -1101,7 +1101,7 @@ globus_ftp_control_server_accept( globus_l_ftp_control_accept_cb, (void *) handle); globus_io_tcpattr_destroy(&listener_attr); - + if(rc != GLOBUS_SUCCESS) { globus_mutex_lock(&(handle->cc_handle.mutex)); @@ -1130,8 +1130,8 @@ globus_ftp_control_server_accept( #ifdef GLOBUS_INTERNAL_DOC /** - * Internal callback for the globus_io_register_accept function. - * + * Internal callback for the globus_io_register_accept function. + * * This is an internal callback used as part of the * globus_ftp_control_accept function. It checks the result of * the accept, and sends a initial response to the user. @@ -1143,20 +1143,20 @@ globus_ftp_control_server_accept( * The globus_io handle for the connection. In practice this * represents the socket fd for the connection. * @param result - * The result of the accept operation + * The result of the accept operation * * @return void * * @note If a error is detected in this function the user callback is * called with an appropriate error object or ftp response and - * the function returns. + * the function returns. */ #endif -static void +static void globus_l_ftp_control_accept_cb( - void * arg, + void * arg, globus_io_handle_t * handle, globus_result_t result) { @@ -1165,7 +1165,7 @@ globus_l_ftp_control_accept_cb( globus_ftp_control_handle_t * c_handle; globus_bool_t call_close_cb = GLOBUS_FALSE; - + c_handle=(globus_ftp_control_handle_t *) arg; cc_handle=&(c_handle->cc_handle); @@ -1198,7 +1198,7 @@ globus_l_ftp_control_accept_cb( globus_mutex_lock(&(cc_handle->mutex)); { cc_handle->cb_count--; - + if(!cc_handle->cb_count && cc_handle->cc_state == GLOBUS_FTP_CONTROL_CLOSING) { @@ -1224,7 +1224,7 @@ globus_l_ftp_control_accept_cb( * globus_ftp_control_server_accept call), this function should be called * to authenticate the client. The caller of this function may specify * certain authentication requirements using the auth_requirements parameter. - * + * * @param handle * The control connection object. This structure will be populated * and passed to the callback when the client is authorized. This @@ -1247,13 +1247,12 @@ globus_l_ftp_control_accept_cb( * have been initialized prior to calling this function. */ globus_result_t -globus_ftp_control_server_authenticate( +globus_ftp_control_server_authenticate( globus_ftp_control_handle_t * handle, globus_ftp_control_auth_requirements_t auth_requirements, globus_ftp_control_auth_callback_t callback, void * callback_arg) { - globus_object_t * error = GLOBUS_NULL; globus_ftp_cc_handle_t * cc_handle; globus_result_t rc; globus_result_t rc2; @@ -1298,7 +1297,6 @@ globus_ftp_control_server_authenticate( &(cc_handle->auth_info),GLOBUS_NULL); if(rc != GLOBUS_SUCCESS) { - error=globus_error_get(rc); goto error_std; } @@ -1316,7 +1314,6 @@ globus_ftp_control_server_authenticate( if (rc != GLOBUS_SUCCESS) { - error = globus_error_get(rc); goto error_std; } @@ -1330,11 +1327,12 @@ globus_ftp_control_server_authenticate( || cc_handle->auth_info.auth_gssapi_context == GSS_C_NO_CONTEXT) { - error = globus_error_construct_string( - GLOBUS_FTP_CONTROL_MODULE, - (rc != GLOBUS_SUCCESS) ? globus_error_get(rc) : NULL, - _FCSL("TLS control channel not established")); - + rc = globus_error_put( + globus_error_construct_string( + GLOBUS_FTP_CONTROL_MODULE, + (rc != GLOBUS_SUCCESS) ? globus_error_get(rc) : NULL, + _FCSL("TLS control channel not established")) + ); goto error_std; } @@ -1358,10 +1356,12 @@ globus_ftp_control_server_authenticate( if (maj_stat != GSS_S_COMPLETE) { - error = globus_error_construct_string( - GLOBUS_FTP_CONTROL_MODULE, - globus_error_get(min_stat), - _FCSL("gss_inquire_context failed")); + rc = globus_error_put( + globus_error_construct_string( + GLOBUS_FTP_CONTROL_MODULE, + globus_error_get(min_stat), + _FCSL("gss_inquire_context failed")) + ); goto error_std; } @@ -1378,23 +1378,27 @@ globus_ftp_control_server_authenticate( if (maj_stat != GSS_S_COMPLETE) { - error = globus_error_construct_string( - GLOBUS_FTP_CONTROL_MODULE, - NULL, - _FCSL("gss_display_name failed")); + rc = globus_error_put( + globus_error_construct_string( + GLOBUS_FTP_CONTROL_MODULE, + NULL, + _FCSL("gss_display_name failed")) + ); goto error_std; } cc_handle->auth_info.auth_gssapi_subject = malloc(subject_buf.length + 1); - + if (cc_handle->auth_info.auth_gssapi_subject == NULL) { gss_release_buffer(&min_stat, &subject_buf); - - error = globus_error_construct_string( + + rc = globus_error_put( + globus_error_construct_string( GLOBUS_FTP_CONTROL_MODULE, GLOBUS_NULL, - _FCSL("globus_l_ftp_control_auth_read_cb: malloc failed")); + _FCSL("globus_l_ftp_control_auth_read_cb: malloc failed")) + ); goto error_std; } @@ -1410,19 +1414,18 @@ globus_ftp_control_server_authenticate( rc=globus_io_register_read(&cc_handle->io_handle, cc_handle->read_buffer, GLOBUS_FTP_CONTROL_READ_BUFFER_SIZE, - 1, + 1, globus_l_ftp_control_auth_read_cb, handle); if(rc != GLOBUS_SUCCESS) { - error=globus_error_get(rc); goto error_std; } - + return GLOBUS_SUCCESS; - + error_std: - + rc2 = globus_i_ftp_control_auth_info_destroy( &(cc_handle->auth_info)); globus_assert(rc2 == GLOBUS_SUCCESS); @@ -1430,7 +1433,7 @@ globus_ftp_control_server_authenticate( globus_mutex_lock(&(cc_handle->mutex)); { cc_handle->cb_count--; - + if(!cc_handle->cb_count && cc_handle->cc_state == GLOBUS_FTP_CONTROL_CLOSING) { @@ -1443,15 +1446,15 @@ globus_ftp_control_server_authenticate( { globus_i_ftp_control_call_close_cb(handle); } - + return rc; } #ifdef GLOBUS_INTERNAL_DOC /** - * Internal callback for the globus_io_register_write function. - * + * Internal callback for the globus_io_register_write function. + * * This is an internal callback used as part of the * globus_ftp_control_authenticate function. It checks the result of * the write (which was used to send a response to the client), and @@ -1466,23 +1469,23 @@ globus_ftp_control_server_authenticate( * The globus_io handle for the connection. In practice this * represents the socket fd for the connection. * @param result - * The result of the write operation + * The result of the write operation * * @return void * * @note If a error is detected in this function the user callback is * called with an appropriate error object or ftp response and - * the function returns. + * the function returns. */ #endif -static void +static void globus_l_ftp_control_auth_write_cb( - void * arg, + void * arg, globus_io_handle_t * handle, globus_result_t result, - globus_byte_t * buf, + globus_byte_t * buf, globus_size_t nbytes) { globus_ftp_cc_handle_t * cc_handle; @@ -1504,7 +1507,7 @@ globus_l_ftp_control_auth_write_cb( goto error_auth_destroy; } - if(cc_handle->auth_requirements & + if(cc_handle->auth_requirements & GLOBUS_FTP_CONTROL_AUTH_REQ_NONE) { callback=cc_handle->auth_cb; @@ -1527,17 +1530,17 @@ globus_l_ftp_control_auth_write_cb( cc_handle->cb_count--; if(!cc_handle->cb_count && - cc_handle->cc_state == GLOBUS_FTP_CONTROL_CLOSING) - { - call_close_cb = GLOBUS_TRUE; - } + cc_handle->cc_state == GLOBUS_FTP_CONTROL_CLOSING) + { + call_close_cb = GLOBUS_TRUE; + } } globus_mutex_unlock(&(cc_handle->mutex)); - if(call_close_cb == GLOBUS_TRUE) - { - globus_i_ftp_control_call_close_cb(c_handle); - } + if(call_close_cb == GLOBUS_TRUE) + { + globus_i_ftp_control_call_close_cb(c_handle); + } return; } @@ -1558,7 +1561,7 @@ globus_l_ftp_control_auth_write_cb( error=globus_error_get(rc); goto error_auth_destroy; } - + return; error_auth_destroy: @@ -1578,17 +1581,17 @@ globus_l_ftp_control_auth_write_cb( cc_handle->cb_count--; if(!cc_handle->cb_count && - cc_handle->cc_state == GLOBUS_FTP_CONTROL_CLOSING) - { - call_close_cb = GLOBUS_TRUE; - } + cc_handle->cc_state == GLOBUS_FTP_CONTROL_CLOSING) + { + call_close_cb = GLOBUS_TRUE; + } } globus_mutex_unlock(&(cc_handle->mutex)); - - if(call_close_cb == GLOBUS_TRUE) - { - globus_i_ftp_control_call_close_cb(c_handle); - } + + if(call_close_cb == GLOBUS_TRUE) + { + globus_i_ftp_control_call_close_cb(c_handle); + } return; } @@ -1596,8 +1599,8 @@ globus_l_ftp_control_auth_write_cb( #ifdef GLOBUS_INTERNAL_DOC /** - * Internal callback for the globus_io_register_read function. - * + * Internal callback for the globus_io_register_read function. + * * This is an internal callback used as part of the * globus_ftp_control_authenticate function. It checks the result of * the read (which was used to read commands from the client), and @@ -1607,7 +1610,7 @@ globus_l_ftp_control_auth_write_cb( * is not complete a reply to the received command is sent to then * client using the auth_write callbacks which will continue to read * commands. If no full command was received a new register_read is - * called. + * called. * * @param arg * The callback argument, which in this case is the control @@ -1616,23 +1619,23 @@ globus_l_ftp_control_auth_write_cb( * The globus_io handle for the connection. In practice this * represents the socket fd for the connection. * @param result - * The result of the accept operation + * The result of the accept operation * * @return void * * @note If a error is detected in this function the user callback is * called with an appropriate error object or ftp response and - * the function returns. + * the function returns. */ #endif -static void +static void globus_l_ftp_control_auth_read_cb( - void * arg, + void * arg, globus_io_handle_t * handle, globus_result_t result, - globus_byte_t * buf, + globus_byte_t * buf, globus_size_t nbytes) { globus_ftp_cc_handle_t * cc_handle; @@ -1667,7 +1670,7 @@ globus_l_ftp_control_auth_read_cb( error=globus_error_get(result); goto error_auth_destroy; } - + cc_handle->bytes_read += nbytes; for(i = 1;ibytes_read;i++) @@ -1687,19 +1690,19 @@ globus_l_ftp_control_auth_read_cb( error=globus_error_get(rc); goto error_auth_destroy; } - + for(j=i+1;jbytes_read;j++) { cc_handle->read_buffer[j-(i+1)]= cc_handle->read_buffer[j]; } - + cc_handle->bytes_read -= (i+1); - + switch(command.code) { case GLOBUS_FTP_CONTROL_COMMAND_AUTH: - if(command.auth.type != + if(command.auth.type != GLOBUS_FTP_CONTROL_AUTH_GSSAPI) { error=globus_error_construct_string( @@ -1708,8 +1711,8 @@ globus_l_ftp_control_auth_read_cb( _FCSL("globus_l_ftp_control_auth_read_cb: Authentication mechanism not supported")); goto error_cmd_destroy; } - - if( !(cc_handle->auth_requirements & + + if( !(cc_handle->auth_requirements & GLOBUS_FTP_CONTROL_AUTH_REQ_GSSAPI)) { error=globus_error_construct_string( @@ -1718,8 +1721,8 @@ globus_l_ftp_control_auth_read_cb( _FCSL("globus_l_ftp_control_auth_read_cb: GSSAPI authentication not allowed")); goto error_cmd_destroy; } - - if(cc_handle->auth_info.prev_cmd != + + if(cc_handle->auth_info.prev_cmd != GLOBUS_FTP_CONTROL_COMMAND_UNKNOWN) { error=globus_error_construct_string( @@ -1728,11 +1731,11 @@ globus_l_ftp_control_auth_read_cb( _FCSL("globus_l_ftp_control_auth_read_cb: AUTH must be the first command in the authentication sequence")); goto error_cmd_destroy; } - + maj_stat=globus_gss_assist_acquire_cred( &min_stat, GSS_C_ACCEPT, - &(cc_handle->auth_info.credential_handle)); + &(cc_handle->auth_info.credential_handle)); if(maj_stat != GSS_S_COMPLETE) { @@ -1740,7 +1743,7 @@ globus_l_ftp_control_auth_read_cb( GLOBUS_FTP_CONTROL_MODULE, GLOBUS_NULL, _FCSL("globus_l_ftp_control_auth_read_cb: globus_gss_assist_acquire_cred failed")); - goto error_cmd_destroy; + goto error_cmd_destroy; } else { @@ -1748,17 +1751,17 @@ globus_l_ftp_control_auth_read_cb( } cc_handle->auth_info.prev_cmd=command.code; - + reply=globus_libc_strdup( globus_i_ftp_server_334_reply); - + if(reply == GLOBUS_NULL) { error=globus_error_construct_string( GLOBUS_FTP_CONTROL_MODULE, GLOBUS_NULL, _FCSL("globus_l_ftp_control_auth_read_cb: strdup failed")); - goto error_cmd_destroy; + goto error_cmd_destroy; } rc=globus_io_register_write( @@ -1767,20 +1770,20 @@ globus_l_ftp_control_auth_read_cb( (globus_size_t) strlen(reply), globus_l_ftp_control_auth_write_cb, arg); - + if(rc != GLOBUS_SUCCESS) { globus_libc_free(reply); error=globus_error_get(rc); goto error_cmd_destroy; } - + break; - + case GLOBUS_FTP_CONTROL_COMMAND_ADAT: - if((cc_handle->auth_info.prev_cmd != + if((cc_handle->auth_info.prev_cmd != GLOBUS_FTP_CONTROL_COMMAND_AUTH) && - (cc_handle->auth_info.prev_cmd != + (cc_handle->auth_info.prev_cmd != GLOBUS_FTP_CONTROL_COMMAND_ADAT)) { error=globus_error_construct_string( @@ -1791,8 +1794,8 @@ globus_l_ftp_control_auth_read_cb( } cc_handle->auth_info.prev_cmd=command.code; - - recv_tok.value= + + recv_tok.value= globus_libc_malloc( (strlen(command.adat.string_arg) + 3) * 6 / 8); @@ -1804,10 +1807,10 @@ globus_l_ftp_control_auth_read_cb( _FCSL("globus_l_ftp_control_auth_read_cb: malloc failed")); goto error_cmd_destroy; } - + rc=globus_i_ftp_control_radix_decode( - (globus_byte_t *) command.adat.string_arg, - recv_tok.value, + (globus_byte_t *) command.adat.string_arg, + recv_tok.value, &length); if(rc != GLOBUS_SUCCESS) { @@ -1815,7 +1818,7 @@ globus_l_ftp_control_auth_read_cb( error=globus_error_get(rc); goto error_cmd_destroy; } - + recv_tok.length = length; if(cc_handle->auth_info.encrypt) @@ -1827,9 +1830,9 @@ globus_l_ftp_control_auth_read_cb( /* context_handle */ &(cc_handle->auth_info.auth_gssapi_context), /* verifier_cred_handle */ - cc_handle->auth_info.credential_handle, + cc_handle->auth_info.credential_handle, /* input_token */ - &recv_tok, + &recv_tok, /* channel bindings */ GSS_C_NO_CHANNEL_BINDINGS, /* src_name */ @@ -1840,17 +1843,17 @@ globus_l_ftp_control_auth_read_cb( &send_tok, &ret_flags, /* ignore time_rec */ - GLOBUS_NULL, + GLOBUS_NULL, &(cc_handle->auth_info.delegated_credential_handle) ); - + globus_libc_free(recv_tok.value); switch(maj_stat) { case GSS_S_COMPLETE: - + cc_handle->use_auth = GLOBUS_TRUE; cc_handle->auth_info.authenticated = GLOBUS_TRUE; @@ -1858,7 +1861,7 @@ globus_l_ftp_control_auth_read_cb( { cc_handle->auth_info.encrypt = GLOBUS_TRUE; } - + maj_stat = gss_display_name( &min_stat, cc_handle->auth_info.target_name, @@ -1868,11 +1871,11 @@ globus_l_ftp_control_auth_read_cb( cc_handle->auth_info.auth_gssapi_subject = malloc(sizeof(char)* (subject_buf.length + 1)); - + if(cc_handle->auth_info.auth_gssapi_subject == GLOBUS_NULL) { gss_release_buffer(&min_stat, &subject_buf); - + error=globus_error_construct_string( GLOBUS_FTP_CONTROL_MODULE, GLOBUS_NULL, @@ -1886,31 +1889,31 @@ globus_l_ftp_control_auth_read_cb( cc_handle->auth_info.auth_gssapi_subject[ subject_buf.length] = '\0'; - + gss_release_buffer(&min_stat, &subject_buf); - if(cc_handle->auth_requirements & + if(cc_handle->auth_requirements & GLOBUS_FTP_CONTROL_AUTH_REQ_USER) { if(send_tok.length == 0) - { + { reply=globus_libc_strdup( globus_i_ftp_server_235_reply); - + if(reply == GLOBUS_NULL) { error=globus_error_construct_string( GLOBUS_FTP_CONTROL_MODULE, GLOBUS_NULL, _FCSL("globus_l_ftp_control_auth_read_cb: strdup failed")); - goto error_cmd_destroy; + goto error_cmd_destroy; } } else { reply= (char *) globus_libc_malloc( send_tok.length * 8 / 6 + 16); - + if(reply == GLOBUS_NULL) { gss_release_buffer(&min_stat, &send_tok); @@ -1920,16 +1923,16 @@ globus_l_ftp_control_auth_read_cb( _FCSL("globus_l_ftp_control_auth_read_cb: malloc failed")); goto error_cmd_destroy; } - + strcpy(reply,"235 ADAT="); - + length=send_tok.length; - - rc = globus_i_ftp_control_radix_encode(send_tok.value, - (globus_byte_t *) &(reply[9]), + + rc = globus_i_ftp_control_radix_encode(send_tok.value, + (globus_byte_t *) &(reply[9]), &length); gss_release_buffer(&min_stat, &send_tok); - + if(rc != GLOBUS_SUCCESS) { globus_libc_free(reply); @@ -1940,14 +1943,14 @@ globus_l_ftp_control_auth_read_cb( reply[length+9]='\r'; reply[length+10]='\n'; } - + rc=globus_io_register_write( handle, (globus_byte_t *) reply, (globus_size_t) strlen(reply), globus_l_ftp_control_auth_write_cb, arg); - + if(rc != GLOBUS_SUCCESS) { globus_libc_free(reply); @@ -1963,7 +1966,7 @@ globus_l_ftp_control_auth_read_cb( cc_handle->auth_cb_arg=GLOBUS_NULL; } globus_mutex_unlock(&(cc_handle->mutex)); - + (callback)(callback_arg, c_handle, GLOBUS_NULL, @@ -1972,26 +1975,26 @@ globus_l_ftp_control_auth_read_cb( globus_mutex_lock(&(cc_handle->mutex)); { cc_handle->cb_count--; - + if(!cc_handle->cb_count && - cc_handle->cc_state == - GLOBUS_FTP_CONTROL_CLOSING) - { - call_close_cb = GLOBUS_TRUE; - } + cc_handle->cc_state == + GLOBUS_FTP_CONTROL_CLOSING) + { + call_close_cb = GLOBUS_TRUE; + } } globus_mutex_unlock(&(cc_handle->mutex)); - - if(call_close_cb == GLOBUS_TRUE) - { - globus_i_ftp_control_call_close_cb(c_handle); - } + + if(call_close_cb == GLOBUS_TRUE) + { + globus_i_ftp_control_call_close_cb(c_handle); + } } break; case GSS_S_CONTINUE_NEEDED: reply= (char *) globus_libc_malloc( send_tok.length * 8 / 6 + 16); - + if(reply == GLOBUS_NULL) { gss_release_buffer(&min_stat, &send_tok); @@ -2001,13 +2004,13 @@ globus_l_ftp_control_auth_read_cb( _FCSL("globus_l_ftp_control_auth_read_cb: malloc failed")); goto error_cmd_destroy; } - + strcpy(reply,"335 ADAT="); - + length=send_tok.length; - - rc = globus_i_ftp_control_radix_encode(send_tok.value, - (globus_byte_t *) &(reply[9]), + + rc = globus_i_ftp_control_radix_encode(send_tok.value, + (globus_byte_t *) &(reply[9]), &length); gss_release_buffer(&min_stat, &send_tok); @@ -2020,7 +2023,7 @@ globus_l_ftp_control_auth_read_cb( reply[length+9]='\r'; reply[length+10]='\n'; - + rc=globus_io_register_write( handle, (globus_byte_t *) reply, @@ -2044,9 +2047,9 @@ globus_l_ftp_control_auth_read_cb( } break; case GLOBUS_FTP_CONTROL_COMMAND_USER: - if((cc_handle->auth_info.prev_cmd != + if((cc_handle->auth_info.prev_cmd != GLOBUS_FTP_CONTROL_COMMAND_ADAT) && - (cc_handle->auth_info.prev_cmd != + (cc_handle->auth_info.prev_cmd != GLOBUS_FTP_CONTROL_COMMAND_UNKNOWN)) { error=globus_error_construct_string( @@ -2055,10 +2058,10 @@ globus_l_ftp_control_auth_read_cb( _FCSL("globus_l_ftp_control_auth_read_cb: USER must either be preceded by ADAT or be the first command")); goto error_cmd_destroy; } - + cc_handle->auth_info.prev_cmd=command.code; - if((cc_handle->auth_requirements & + if((cc_handle->auth_requirements & GLOBUS_FTP_CONTROL_AUTH_REQ_GSSAPI) && (cc_handle->use_auth == GLOBUS_FALSE)) { @@ -2066,9 +2069,9 @@ globus_l_ftp_control_auth_read_cb( GLOBUS_FTP_CONTROL_MODULE, GLOBUS_NULL, _FCSL("globus_l_ftp_control_auth_read_cb: GSSAPI authentication required")); - goto error_cmd_destroy; + goto error_cmd_destroy; } - + cc_handle->auth_info.user=globus_libc_strdup( command.user.string_arg); @@ -2080,8 +2083,8 @@ globus_l_ftp_control_auth_read_cb( _FCSL("globus_l_ftp_control_auth_read_cb: strdup failed")); goto error_cmd_destroy; } - - if(cc_handle->auth_requirements & + + if(cc_handle->auth_requirements & GLOBUS_FTP_CONTROL_AUTH_REQ_USER) { @@ -2095,7 +2098,7 @@ globus_l_ftp_control_auth_read_cb( cc_handle->auth_cb_arg=GLOBUS_NULL; } globus_mutex_unlock(&(cc_handle->mutex)); - + (callback)(callback_arg, c_handle, GLOBUS_NULL, @@ -2106,19 +2109,19 @@ globus_l_ftp_control_auth_read_cb( cc_handle->cb_count--; if(!cc_handle->cb_count && - cc_handle->cc_state == - GLOBUS_FTP_CONTROL_CLOSING) - { - call_close_cb = GLOBUS_TRUE; - } + cc_handle->cc_state == + GLOBUS_FTP_CONTROL_CLOSING) + { + call_close_cb = GLOBUS_TRUE; + } } globus_mutex_unlock(&(cc_handle->mutex)); - if(call_close_cb == GLOBUS_TRUE) - { - globus_i_ftp_control_call_close_cb(c_handle); - } - + if(call_close_cb == GLOBUS_TRUE) + { + globus_i_ftp_control_call_close_cb(c_handle); + } + break; } @@ -2135,8 +2138,8 @@ globus_l_ftp_control_auth_read_cb( reply= globus_libc_strdup( globus_i_ftp_server_332_reply); } - - + + if(reply == GLOBUS_NULL) { error=globus_error_construct_string( @@ -2145,14 +2148,14 @@ globus_l_ftp_control_auth_read_cb( _FCSL("globus_l_ftp_control_auth_read_cb: strdup failed")); goto error_cmd_destroy; } - + if(cc_handle->auth_info.authenticated == GLOBUS_TRUE) { rc=globus_i_ftp_control_encode_reply( reply, &encoded_reply, &(cc_handle->auth_info)); - + globus_libc_free(reply); if(rc != GLOBUS_SUCCESS) @@ -2160,10 +2163,10 @@ globus_l_ftp_control_auth_read_cb( error=globus_error_get(rc); goto error_cmd_destroy; } - + reply=encoded_reply; } - + rc=globus_io_register_write( handle, @@ -2171,14 +2174,14 @@ globus_l_ftp_control_auth_read_cb( (globus_size_t) strlen(reply), globus_l_ftp_control_auth_write_cb, arg); - + if(rc != GLOBUS_SUCCESS) { globus_libc_free(reply); error=globus_error_get(rc); goto error_cmd_destroy; } - + } else { @@ -2191,7 +2194,7 @@ globus_l_ftp_control_auth_read_cb( break; case GLOBUS_FTP_CONTROL_COMMAND_PASS: - if(cc_handle->auth_info.prev_cmd != + if(cc_handle->auth_info.prev_cmd != GLOBUS_FTP_CONTROL_COMMAND_USER) { error=globus_error_construct_string( @@ -2214,8 +2217,8 @@ globus_l_ftp_control_auth_read_cb( _FCSL("globus_l_ftp_control_auth_read_cb: No password given")); goto error_cmd_destroy; } - - if(!(cc_handle->auth_requirements & + + if(!(cc_handle->auth_requirements & GLOBUS_FTP_CONTROL_AUTH_REQ_ACCT)) { globus_mutex_lock(&(cc_handle->mutex)); @@ -2224,7 +2227,7 @@ globus_l_ftp_control_auth_read_cb( cc_handle->auth_cb_arg=GLOBUS_NULL; } globus_mutex_unlock(&(cc_handle->mutex)); - + (callback)(callback_arg, c_handle, GLOBUS_NULL, @@ -2233,23 +2236,23 @@ globus_l_ftp_control_auth_read_cb( { cc_handle->cb_count--; if(!cc_handle->cb_count && - cc_handle->cc_state == GLOBUS_FTP_CONTROL_CLOSING) - { - call_close_cb = GLOBUS_TRUE; - } + cc_handle->cc_state == GLOBUS_FTP_CONTROL_CLOSING) + { + call_close_cb = GLOBUS_TRUE; + } } globus_mutex_unlock(&(cc_handle->mutex)); - - if(call_close_cb == GLOBUS_TRUE) - { - globus_i_ftp_control_call_close_cb(c_handle); - } + + if(call_close_cb == GLOBUS_TRUE) + { + globus_i_ftp_control_call_close_cb(c_handle); + } } else { reply=globus_libc_strdup( globus_i_ftp_server_332_reply); - + if(reply == GLOBUS_NULL) { error=globus_error_construct_string( @@ -2258,25 +2261,25 @@ globus_l_ftp_control_auth_read_cb( _FCSL("globus_l_ftp_control_auth_read_cb: strdup failed")); goto error_cmd_destroy; } - + if(cc_handle->auth_info.authenticated == GLOBUS_TRUE) { rc=globus_i_ftp_control_encode_reply( reply, &encoded_reply, &(cc_handle->auth_info)); - + globus_libc_free(reply); - + if(rc != GLOBUS_SUCCESS) { error=globus_error_get(rc); goto error_cmd_destroy; } - + reply=encoded_reply; } - + rc=globus_io_register_write( handle, (globus_byte_t *) reply, @@ -2293,11 +2296,11 @@ globus_l_ftp_control_auth_read_cb( } break; case GLOBUS_FTP_CONTROL_COMMAND_ACCT: - if(((cc_handle->auth_requirements & + if(((cc_handle->auth_requirements & GLOBUS_FTP_CONTROL_AUTH_REQ_PASS) && - (cc_handle->auth_info.prev_cmd != + (cc_handle->auth_info.prev_cmd != GLOBUS_FTP_CONTROL_COMMAND_PASS)) || - (cc_handle->auth_info.prev_cmd != + (cc_handle->auth_info.prev_cmd != GLOBUS_FTP_CONTROL_COMMAND_USER)) { error=globus_error_construct_string( @@ -2318,8 +2321,8 @@ globus_l_ftp_control_auth_read_cb( _FCSL("globus_l_ftp_control_auth_read_cb: no account given")); goto error_cmd_destroy; } - - if(cc_handle->auth_requirements & + + if(cc_handle->auth_requirements & GLOBUS_FTP_CONTROL_AUTH_REQ_ACCT) { globus_mutex_lock(&(cc_handle->mutex)); @@ -2328,7 +2331,7 @@ globus_l_ftp_control_auth_read_cb( cc_handle->auth_cb_arg=GLOBUS_NULL; } globus_mutex_unlock(&(cc_handle->mutex)); - + (callback)(callback_arg, c_handle, GLOBUS_NULL, @@ -2338,18 +2341,18 @@ globus_l_ftp_control_auth_read_cb( cc_handle->cb_count--; if(!cc_handle->cb_count && - cc_handle->cc_state == GLOBUS_FTP_CONTROL_CLOSING) - { - call_close_cb = GLOBUS_TRUE; - } + cc_handle->cc_state == GLOBUS_FTP_CONTROL_CLOSING) + { + call_close_cb = GLOBUS_TRUE; + } } globus_mutex_unlock(&(cc_handle->mutex)); - if(call_close_cb == GLOBUS_TRUE) - { - globus_i_ftp_control_call_close_cb(c_handle); - } + if(call_close_cb == GLOBUS_TRUE) + { + globus_i_ftp_control_call_close_cb(c_handle); + } } else { @@ -2367,18 +2370,18 @@ globus_l_ftp_control_auth_read_cb( _FCSL("globus_l_ftp_control_auth_read_cb: Command not part of authentication process")); goto error_cmd_destroy; } - + globus_ftp_control_command_destroy(&command); return; } } - + if(cc_handle->bytes_read == cc_handle->read_buffer_size) { new_buf= (globus_byte_t *) globus_libc_malloc( cc_handle->read_buffer_size + GLOBUS_I_FTP_CONTROL_BUF_INCR); - + if(new_buf == GLOBUS_NULL) { error=globus_error_construct_string( @@ -2387,31 +2390,31 @@ globus_l_ftp_control_auth_read_cb( _FCSL("globus_l_ftp_control_auth_read_cb: malloc failed")); goto error_auth_destroy; } - + memcpy(new_buf, cc_handle->read_buffer, cc_handle->bytes_read); - + cc_handle->read_buffer_size += GLOBUS_I_FTP_CONTROL_BUF_INCR; globus_libc_free(cc_handle->read_buffer); cc_handle->read_buffer=new_buf; } - + rc=globus_io_register_read(&(cc_handle->io_handle), &(cc_handle->read_buffer[ cc_handle->bytes_read]), - cc_handle->read_buffer_size - + cc_handle->read_buffer_size - cc_handle->bytes_read, 1, globus_l_ftp_control_auth_read_cb, arg); - + if(rc != GLOBUS_SUCCESS) { error=globus_error_get(rc); goto error_auth_destroy; } - + return; error_cmd_destroy: @@ -2420,7 +2423,7 @@ globus_l_ftp_control_auth_read_cb( rc = globus_i_ftp_control_auth_info_destroy( &(cc_handle->auth_info)); globus_assert(rc == GLOBUS_SUCCESS); - + (cc_handle->auth_cb)(cc_handle->auth_cb_arg, c_handle, error, @@ -2431,18 +2434,18 @@ globus_l_ftp_control_auth_read_cb( { cc_handle->cb_count--; if(!cc_handle->cb_count && - cc_handle->cc_state == GLOBUS_FTP_CONTROL_CLOSING) - { - call_close_cb = GLOBUS_TRUE; - } + cc_handle->cc_state == GLOBUS_FTP_CONTROL_CLOSING) + { + call_close_cb = GLOBUS_TRUE; + } } globus_mutex_unlock(&(cc_handle->mutex)); - if(call_close_cb == GLOBUS_TRUE) - { - globus_i_ftp_control_call_close_cb(c_handle); - } - + if(call_close_cb == GLOBUS_TRUE) + { + globus_i_ftp_control_call_close_cb(c_handle); + } + return; } @@ -2450,13 +2453,13 @@ globus_l_ftp_control_auth_read_cb( * @brief Read GridFTP commands * @ingroup globus_ftp_control_server * @details - * This function begins reading control commands on a + * This function begins reading control commands on a * globus_ftp_control_handle_t. When a command is read * the callback function is called. * * @param handle * The control connection handle that commands will be read - * from. Prior to calling this the function + * from. Prior to calling this the function * globus_ftp_control_handle_t must be populated via a * call to globus_ftp_control_accept(). * @param callback @@ -2507,11 +2510,11 @@ globus_ftp_control_read_commands( } globus_mutex_unlock(&(handle->cc_handle.mutex)); - + rc=globus_io_register_read(&(handle->cc_handle.io_handle), &(handle->cc_handle.read_buffer[ handle->cc_handle.bytes_read]), - handle->cc_handle.read_buffer_size - + handle->cc_handle.read_buffer_size - handle->cc_handle.bytes_read, 0, globus_l_ftp_control_read_command_cb, @@ -2521,40 +2524,40 @@ globus_ftp_control_read_commands( { globus_i_ftp_control_auth_info_destroy( &(handle->cc_handle.auth_info)); - + globus_mutex_lock(&(handle->cc_handle.mutex)); { handle->cc_handle.cb_count--; if(!handle->cc_handle.cb_count && - handle->cc_handle.cc_state == GLOBUS_FTP_CONTROL_CLOSING) - { - call_close_cb = GLOBUS_TRUE; - } + handle->cc_handle.cc_state == GLOBUS_FTP_CONTROL_CLOSING) + { + call_close_cb = GLOBUS_TRUE; + } } globus_mutex_unlock(&(handle->cc_handle.mutex)); - if(call_close_cb == GLOBUS_TRUE) - { - globus_i_ftp_control_call_close_cb(handle); - } + if(call_close_cb == GLOBUS_TRUE) + { + globus_i_ftp_control_call_close_cb(handle); + } return rc; } - + return GLOBUS_SUCCESS; } #ifdef GLOBUS_INTERNAL_DOC /** - * Internal callback for the globus_io_register_read function. - * + * Internal callback for the globus_io_register_read function. + * * This is an internal callback used as part of the - * globus_ftp_control_read_commands function. It checks the result of + * globus_ftp_control_read_commands function. It checks the result of * the read (which was used to read commands from the client), and * if a full command was received, parses it and returns the resulting * command structure to the user through the user callback. If no full - * command was received a new register_read is called. + * command was received a new register_read is called. * * @param arg * The callback argument, which in this case is the control @@ -2563,23 +2566,23 @@ globus_ftp_control_read_commands( * The globus_io handle for the connection. In practice this * represents the socket fd for the connection. * @param result - * The result of the accept operation + * The result of the accept operation * * @return void * * @note If a error is detected in this function the user callback is * called with an appropriate error object or ftp response and - * the function returns. + * the function returns. */ #endif static void globus_l_ftp_control_read_command_cb( - void * arg, + void * arg, globus_io_handle_t * handle, globus_result_t result, - globus_byte_t * buf, + globus_byte_t * buf, globus_size_t nbytes) { globus_ftp_cc_handle_t * cc_handle; @@ -2602,11 +2605,11 @@ globus_l_ftp_control_read_command_cb( error=globus_error_get(result); goto error_auth_destroy; } - + cc_handle->bytes_read += nbytes; last=0; - + for(i = 1;i < cc_handle->bytes_read; i++) { if(cc_handle->read_buffer[i-1] == '\r' && @@ -2624,7 +2627,7 @@ globus_l_ftp_control_read_command_cb( error=globus_error_get(rc); goto error_auth_destroy; } - + (cc_handle->command_cb)(cc_handle->command_cb_arg, c_handle, GLOBUS_NULL, @@ -2634,7 +2637,7 @@ globus_l_ftp_control_read_command_cb( last=i+1; } } - + if(last != 0) { for(i=last;ibytes_read;i++) @@ -2642,7 +2645,7 @@ globus_l_ftp_control_read_command_cb( cc_handle->read_buffer[i-last]= cc_handle->read_buffer[i]; } - + cc_handle->bytes_read -= last; } else @@ -2661,7 +2664,7 @@ globus_l_ftp_control_read_command_cb( _FCSL("globus_l_ftp_control_read_command_cb: malloc failed")); goto error_auth_destroy; } - + memcpy(new_buf, cc_handle->read_buffer, cc_handle->bytes_read); @@ -2676,71 +2679,71 @@ globus_l_ftp_control_read_command_cb( globus_mutex_lock(&(cc_handle->mutex)); { if(cc_handle->cb_count == 1 && - cc_handle->cc_state == GLOBUS_FTP_CONTROL_CLOSING) + cc_handle->cc_state == GLOBUS_FTP_CONTROL_CLOSING) { cc_handle->cb_count--; - call_close_cb = GLOBUS_TRUE; + call_close_cb = GLOBUS_TRUE; } - else if(code == GLOBUS_FTP_CONTROL_COMMAND_QUIT) - { + else if(code == GLOBUS_FTP_CONTROL_COMMAND_QUIT) + { cc_handle->cb_count--; - } + } } globus_mutex_unlock(&(cc_handle->mutex)); - - if(call_close_cb == GLOBUS_TRUE) - { + + if(call_close_cb == GLOBUS_TRUE) + { globus_i_ftp_control_call_close_cb(c_handle); return; - } - + } + if(code != GLOBUS_FTP_CONTROL_COMMAND_QUIT) { rc=globus_io_register_read(&(cc_handle->io_handle), &(cc_handle->read_buffer[ cc_handle->bytes_read]), - cc_handle->read_buffer_size - + cc_handle->read_buffer_size - cc_handle->bytes_read, 1, globus_l_ftp_control_read_command_cb, arg); - + if(rc != GLOBUS_SUCCESS) { error=globus_error_get(rc); goto error_auth_destroy; } } - + return; error_auth_destroy: rc = globus_i_ftp_control_auth_info_destroy( &(cc_handle->auth_info)); globus_assert(rc == GLOBUS_SUCCESS); - + (cc_handle->command_cb)(cc_handle->command_cb_arg, c_handle, error, GLOBUS_NULL); globus_object_free(error); - + globus_mutex_lock(&(cc_handle->mutex)); { cc_handle->cb_count--; if(!cc_handle->cb_count && - cc_handle->cc_state == GLOBUS_FTP_CONTROL_CLOSING) - { - call_close_cb = GLOBUS_TRUE; - } + cc_handle->cc_state == GLOBUS_FTP_CONTROL_CLOSING) + { + call_close_cb = GLOBUS_TRUE; + } } globus_mutex_unlock(&(cc_handle->mutex)); - - if(call_close_cb == GLOBUS_TRUE) - { - globus_i_ftp_control_call_close_cb(c_handle); - } + + if(call_close_cb == GLOBUS_TRUE) + { + globus_i_ftp_control_call_close_cb(c_handle); + } return; } @@ -2750,8 +2753,8 @@ globus_l_ftp_control_read_command_cb( * @brief Send a GridFTP response * @ingroup globus_ftp_control_server * @details - * This function sends a GridFTP formatted response to the client. - * When a command callback is received the user calls this function + * This function sends a GridFTP formatted response to the client. + * When a command callback is received the user calls this function * to respond to the clients request. * * @param handle @@ -2794,15 +2797,15 @@ globus_ftp_control_send_response( ); } - + va_start(ap, callback_arg); - + arglength=globus_libc_vfprintf(globus_i_ftp_control_devnull, respspec, ap); va_end(ap); - + if(arglength < 1) { result=globus_error_put( @@ -2857,13 +2860,13 @@ globus_ftp_control_send_response( result=rc; goto return_error; } - + buf=encoded_buf; } element = (globus_ftp_control_rw_queue_element_t *) globus_libc_malloc(sizeof(globus_ftp_control_rw_queue_element_t)); - + if(element == GLOBUS_NULL) { result=globus_error_put( @@ -2917,7 +2920,7 @@ globus_ftp_control_send_response( (globus_size_t) strlen((char *) buf), globus_l_ftp_control_send_response_cb, (void *) handle); - + if(rc != GLOBUS_SUCCESS) { globus_mutex_lock(&(handle->cc_handle.mutex)); @@ -2927,26 +2930,26 @@ globus_ftp_control_send_response( queue_empty=globus_fifo_empty(&handle->cc_handle.writers); if(!handle->cc_handle.cb_count && - handle->cc_handle.cc_state == GLOBUS_FTP_CONTROL_CLOSING) - { - call_close_cb = GLOBUS_TRUE; - } + handle->cc_handle.cc_state == GLOBUS_FTP_CONTROL_CLOSING) + { + call_close_cb = GLOBUS_TRUE; + } } globus_mutex_unlock(&(handle->cc_handle.mutex)); - if(call_close_cb == GLOBUS_TRUE) - { - globus_i_ftp_control_call_close_cb(handle); + if(call_close_cb == GLOBUS_TRUE) + { + globus_i_ftp_control_call_close_cb(handle); } globus_libc_free(buf); - globus_libc_free(element); + globus_libc_free(element); if(queue_empty == GLOBUS_FALSE) { globus_i_ftp_control_write_next(handle); } - + result=rc; goto return_error; } @@ -2961,8 +2964,8 @@ globus_ftp_control_send_response( #ifdef GLOBUS_INTERNAL_DOC /** - * Internal callback for the globus_io_register_write function. - * + * Internal callback for the globus_io_register_write function. + * * This is an internal callback used as part of the * globus_ftp_control_send_response function. It checks the result of * the write (which was used to send a response to the client), and @@ -2975,23 +2978,23 @@ globus_ftp_control_send_response( * The globus_io handle for the connection. In practice this * represents the socket fd for the connection. * @param result - * The result of the write operation + * The result of the write operation * * @return void * * @note If a error is detected in this function the user callback is * called with an appropriate error object or ftp response and - * the function returns. + * the function returns. */ #endif -static void +static void globus_l_ftp_control_send_response_cb( - void * arg, + void * arg, globus_io_handle_t * handle, globus_result_t result, - globus_byte_t * buf, + globus_byte_t * buf, globus_size_t nbytes) { globus_ftp_cc_handle_t * cc_handle; @@ -3014,12 +3017,12 @@ globus_l_ftp_control_send_response_cb( queue_empty=globus_fifo_empty(&cc_handle->writers); } globus_mutex_unlock(&(cc_handle->mutex)); - + if(queue_empty == GLOBUS_FALSE) { globus_i_ftp_control_write_next(c_handle); } - + if(result != GLOBUS_SUCCESS) { error=globus_error_get(result); @@ -3031,26 +3034,26 @@ globus_l_ftp_control_send_response_cb( GLOBUS_NULL); globus_libc_free(element); - + globus_mutex_lock(&(cc_handle->mutex)); { cc_handle->cb_count--; if(!cc_handle->cb_count && - cc_handle->cc_state == GLOBUS_FTP_CONTROL_CLOSING) - { - call_close_cb = GLOBUS_TRUE; + cc_handle->cc_state == GLOBUS_FTP_CONTROL_CLOSING) + { + call_close_cb = GLOBUS_TRUE; } } globus_mutex_unlock(&(cc_handle->mutex)); - - if(call_close_cb == GLOBUS_TRUE) - { - globus_i_ftp_control_call_close_cb(c_handle); - } + + if(call_close_cb == GLOBUS_TRUE) + { + globus_i_ftp_control_call_close_cb(c_handle); + } return; - + return_error: (element->send_response_cb)((element->arg), @@ -3063,17 +3066,17 @@ globus_l_ftp_control_send_response_cb( { cc_handle->cb_count--; if(!cc_handle->cb_count && - cc_handle->cc_state == GLOBUS_FTP_CONTROL_CLOSING) - { - call_close_cb = GLOBUS_TRUE; + cc_handle->cc_state == GLOBUS_FTP_CONTROL_CLOSING) + { + call_close_cb = GLOBUS_TRUE; } } globus_mutex_unlock(&(cc_handle->mutex)); - if(call_close_cb == GLOBUS_TRUE) - { - globus_i_ftp_control_call_close_cb(c_handle); - } + if(call_close_cb == GLOBUS_TRUE) + { + globus_i_ftp_control_call_close_cb(c_handle); + } return; } @@ -3083,7 +3086,7 @@ globus_l_ftp_control_send_response_cb( /** * Internal helper function which base 64 decodes and gss unwraps a * MIC command - * + * * Internal helper function which base 64 decodes and gss unwraps a * MIC command * @@ -3095,7 +3098,7 @@ globus_l_ftp_control_send_response_cb( * @param auth_info * The auth_info structure to use for gss unwrapping the command * - * @return + * @return * - error object * - GLOBUS_SUCCESS * @@ -3119,7 +3122,7 @@ globus_i_ftp_control_decode_command( OM_uint32 min_stat; int conf_state; gss_qop_t qop_state; - + if(cmd == GLOBUS_NULL) { return globus_error_put( @@ -3129,11 +3132,11 @@ globus_i_ftp_control_decode_command( _FCSL("globus_i_ftp_control_decode_command: cmd argument is NULL")) ); } - + length=strlen(cmd); - + tmp=(char *) globus_libc_malloc(length+1); - + if(tmp == GLOBUS_NULL) { return globus_error_put( @@ -3143,7 +3146,7 @@ globus_i_ftp_control_decode_command( _FCSL("globus_ftp_control_decode_command: malloc failed")) ); } - + if(sscanf(cmd,"%4s",tmp) < 1) { rc = globus_error_put( @@ -3154,16 +3157,16 @@ globus_i_ftp_control_decode_command( ); goto decode_error; } - + i=0; - + while(tmp[i] != '\0') { tmp[i]=toupper(tmp[i]); i++; } - - + + if(strcmp(tmp,"MIC") && strcmp(tmp,"ENC")) { @@ -3180,7 +3183,7 @@ globus_i_ftp_control_decode_command( { /* if command is ENC and encryption isn't turned on in sec context */ - + rc = globus_error_put( globus_error_construct_string( GLOBUS_FTP_CONTROL_MODULE, @@ -3189,7 +3192,7 @@ globus_i_ftp_control_decode_command( ); goto decode_error; } - + if(sscanf(cmd,"%*s %s",tmp) < 1) { rc = globus_error_put( @@ -3200,9 +3203,9 @@ globus_i_ftp_control_decode_command( ); goto decode_error; } - + *decoded_cmd = (char *) globus_libc_malloc((length+3) * 6/8); - + if(*decoded_cmd == GLOBUS_NULL) { rc = globus_error_put( @@ -3213,27 +3216,27 @@ globus_i_ftp_control_decode_command( ); goto decode_error; } - + rc=globus_i_ftp_control_radix_decode( (globus_byte_t *) tmp, (globus_byte_t *) *decoded_cmd,&length); - + if(rc != GLOBUS_SUCCESS) { globus_libc_free(*decoded_cmd); goto decode_error; } - + wrapped_token.value = *decoded_cmd; wrapped_token.length = length; - maj_stat = gss_unwrap(&min_stat, + maj_stat = gss_unwrap(&min_stat, auth_info->auth_gssapi_context, - &wrapped_token, + &wrapped_token, &unwrapped_token, - &conf_state, + &conf_state, &qop_state); - + if(maj_stat != GSS_S_COMPLETE) { rc = globus_error_put( @@ -3242,23 +3245,23 @@ globus_i_ftp_control_decode_command( GLOBUS_NULL, _FCSL("globus_ftp_control_decode_command: failed to unwrap command")) ); - + globus_libc_free(*decoded_cmd); goto decode_error; } - + globus_assert(strlen(cmd) > unwrapped_token.length); - + memcpy(tmp, unwrapped_token.value, unwrapped_token.length); tmp[unwrapped_token.length] = '\0'; - + gss_release_buffer(&min_stat, &unwrapped_token); - + globus_libc_free(*decoded_cmd); - + *decoded_cmd=tmp; return GLOBUS_SUCCESS; @@ -3266,9 +3269,9 @@ globus_i_ftp_control_decode_command( decode_error: *decoded_cmd=GLOBUS_NULL; - + globus_libc_free(tmp); - + return rc; } @@ -3277,7 +3280,7 @@ globus_i_ftp_control_decode_command( /** * Internal helper function which gss wraps, base 64 encodes and puts * a 635 in front of the supplied response - * + * * Internal helper function which gss wraps, base 64 encodes and puts * a 635 in front of the supplied response * @@ -3289,7 +3292,7 @@ globus_i_ftp_control_decode_command( * @param auth_info * The auth_info structure to use for gss wrapping the reply. * - * @return + * @return * - error object * - GLOBUS_SUCCESS * @@ -3310,7 +3313,7 @@ globus_i_ftp_control_encode_reply( OM_uint32 min_stat; int conf_state; int length; - + if(auth_info == GLOBUS_NULL || reply == GLOBUS_NULL || encoded_reply == GLOBUS_NULL) @@ -3322,7 +3325,7 @@ globus_i_ftp_control_encode_reply( _FCSL("globus_i_ftp_control_encode_reply: NULL argument detected")) ); } - + in_buf.value = reply; in_buf.length = strlen(reply)+1; @@ -3330,11 +3333,11 @@ globus_i_ftp_control_encode_reply( auth_info->auth_gssapi_context, 0, GSS_C_QOP_DEFAULT, - &in_buf, + &in_buf, &conf_state, &out_buf); - - if(maj_stat != GSS_S_COMPLETE) + + if(maj_stat != GSS_S_COMPLETE) { return globus_error_put( globus_error_construct_string( @@ -3368,11 +3371,11 @@ globus_i_ftp_control_encode_reply( { strcat(*encoded_reply,"631 "); } - + length = out_buf.length; globus_i_ftp_control_radix_encode( out_buf.value, - (globus_byte_t *) &((*encoded_reply)[4]), + (globus_byte_t *) &((*encoded_reply)[4]), &length); (*encoded_reply)[length+4]='\r'; @@ -3380,7 +3383,7 @@ globus_i_ftp_control_encode_reply( (*encoded_reply)[length+6]='\0'; gss_release_buffer(&min_stat, &out_buf); - + return GLOBUS_SUCCESS; } @@ -3392,12 +3395,12 @@ globus_i_ftp_control_encode_reply( /** * Internal helper function which sets up a list for keeping track of * server handles. - * + * * Internal helper function which sets up a list for keeping track of * server handles. * * - * @return + * @return * - GLOBUS_SUCCESS * */ @@ -3409,7 +3412,7 @@ globus_result_t globus_i_ftp_control_server_activate(void) { globus_ftp_l_command_hash_entry_t * entries; - + globus_mutex_init( &(globus_l_ftp_server_handle_list_mutex), GLOBUS_NULL); @@ -3419,7 +3422,7 @@ globus_i_ftp_control_server_activate(void) globus_hashtable_string_keyeq); /* the size of this array needs to be adjusted */ - + entries = (globus_ftp_l_command_hash_entry_t *) globus_libc_malloc(44 * sizeof(globus_ftp_l_command_hash_entry_t)); @@ -3530,7 +3533,7 @@ globus_i_ftp_control_server_activate(void) globus_hashtable_insert(&globus_l_ftp_control_parse_table, "SMNT", &entries[17]); - + entries[18].code = GLOBUS_FTP_CONTROL_COMMAND_OPTS; entries[18].parse_func = globus_l_ftp_control_parse_opts_cmd; globus_hashtable_insert(&globus_l_ftp_control_parse_table, @@ -3584,7 +3587,7 @@ globus_i_ftp_control_server_activate(void) globus_hashtable_insert(&globus_l_ftp_control_parse_table, "PASS", &entries[26]); - + entries[27].code = GLOBUS_FTP_CONTROL_COMMAND_RMD; entries[27].parse_func = globus_l_ftp_control_parse_string_arg; globus_hashtable_insert(&globus_l_ftp_control_parse_table, @@ -3697,9 +3700,9 @@ globus_i_ftp_control_server_activate(void) * * Internal helper function which goes through a list of server * handles and closes any open connections associated with the - * handles. - * - * @return + * handles. + * + * @return * - GLOBUS_SUCCESS * */ @@ -3720,7 +3723,7 @@ globus_i_ftp_control_server_deactivate(void) globus_list_first(globus_l_ftp_server_handle_list); globus_mutex_lock(&(server_handle->mutex)); { - if(server_handle->state == + if(server_handle->state == GLOBUS_FTP_CONTROL_SERVER_LISTENING) { rc=globus_io_close(&(server_handle->io_handle)); @@ -3729,7 +3732,7 @@ globus_i_ftp_control_server_deactivate(void) } } globus_mutex_unlock(&(server_handle->mutex)); - + globus_mutex_destroy(&(server_handle->mutex)); globus_list_remove(&globus_l_ftp_server_handle_list, globus_l_ftp_server_handle_list); @@ -3741,18 +3744,18 @@ globus_i_ftp_control_server_deactivate(void) /* free all command hash memory */ - + globus_libc_free(globus_hashtable_lookup( &globus_l_ftp_control_parse_table, "SBUF")); globus_hashtable_destroy(&globus_l_ftp_control_parse_table); - + return GLOBUS_SUCCESS; } globus_result_t globus_l_ftp_control_parse_sbuf_cmd( - globus_ftp_control_command_t * command) + globus_ftp_control_command_t * command) { if(sscanf(command->noop.raw_command, "%*s %d", &command->sbuf.buffer_size) < 1) @@ -3767,12 +3770,12 @@ globus_result_t globus_l_ftp_control_parse_string_arg( { int length; int arg_start; - + length = strlen(command->noop.raw_command); - + command->size.string_arg = (char *) globus_libc_malloc(length); - + if(command->size.string_arg == GLOBUS_NULL) { return globus_error_put( @@ -3781,10 +3784,10 @@ globus_result_t globus_l_ftp_control_parse_string_arg( GLOBUS_NULL, _FCSL("globus_ftp_control_command_init: malloc failed"))); } - + sscanf(command->noop.raw_command,"%*s%n", &arg_start); - + while(isspace(command->noop.raw_command[arg_start])) { arg_start++; @@ -3795,11 +3798,11 @@ globus_result_t globus_l_ftp_control_parse_string_arg( length--; } - command->noop.raw_command[length]='\0'; + command->noop.raw_command[length]='\0'; strcpy(command->eret.string_arg, &command->noop.raw_command[arg_start]); - + return GLOBUS_SUCCESS; } @@ -3807,13 +3810,13 @@ globus_result_t globus_l_ftp_control_parse_string_arg( globus_result_t globus_l_ftp_control_parse_no_arg( globus_ftp_control_command_t * command) { - command->cdup.string_arg=GLOBUS_NULL; + command->cdup.string_arg=GLOBUS_NULL; return GLOBUS_SUCCESS; } globus_result_t globus_l_ftp_control_parse_allo_cmd( - globus_ftp_control_command_t * command) + globus_ftp_control_command_t * command) { command->allo.record_size = 0; if(sscanf(command->noop.raw_command,"%*s %d R %d", @@ -3823,12 +3826,12 @@ globus_result_t globus_l_ftp_control_parse_allo_cmd( command->allo.size = 0; command->allo.record_size = 0; } - + return GLOBUS_SUCCESS; } globus_result_t globus_l_ftp_control_parse_opts_cmd( - globus_ftp_control_command_t * command) + globus_ftp_control_command_t * command) { int length; @@ -3836,7 +3839,7 @@ globus_result_t globus_l_ftp_control_parse_opts_cmd( command->opts.cmd_name = (char *) globus_libc_malloc(length); - + if(command->opts.cmd_name == GLOBUS_NULL) { return globus_error_put( @@ -3846,7 +3849,7 @@ globus_result_t globus_l_ftp_control_parse_opts_cmd( _FCSL("globus_ftp_control_command_init: malloc failed"))); } - command->opts.cmd_opts = + command->opts.cmd_opts = (char *) globus_libc_malloc(length); if(command->opts.cmd_opts == GLOBUS_NULL) @@ -3858,7 +3861,7 @@ globus_result_t globus_l_ftp_control_parse_opts_cmd( GLOBUS_NULL, _FCSL("globus_ftp_control_command_init: malloc failed"))); } - + if(sscanf(command->noop.raw_command,"%*s %s %s", command->opts.cmd_name, command->opts.cmd_opts) < 2) { @@ -3872,10 +3875,10 @@ globus_result_t globus_l_ftp_control_parse_opts_cmd( globus_result_t globus_l_ftp_control_parse_port_cmd( - globus_ftp_control_command_t * command) + globus_ftp_control_command_t * command) { int port[2]; - + if(sscanf(command->noop.raw_command, "%*s %u,%u,%u,%u,%u,%u", &(command->port.host_port.host[0]), @@ -3888,7 +3891,7 @@ globus_result_t globus_l_ftp_control_parse_port_cmd( command->code=GLOBUS_FTP_CONTROL_COMMAND_UNKNOWN; return GLOBUS_SUCCESS; } - + if((command->port.host_port.host)[0] > 255 || (command->port.host_port.host)[1] > 255 || (command->port.host_port.host)[2] > 255 || @@ -3899,38 +3902,38 @@ globus_result_t globus_l_ftp_control_parse_port_cmd( command->code=GLOBUS_FTP_CONTROL_COMMAND_UNKNOWN; return GLOBUS_SUCCESS; } - + command->port.host_port.port= (short) 256*port[0]+port[1]; command->port.host_port.hostlen = 4; return GLOBUS_SUCCESS; } globus_result_t globus_l_ftp_control_parse_spor_cmd( - globus_ftp_control_command_t * command) + globus_ftp_control_command_t * command) { char * start; int i; int j; int arg_start; int port[2]; - + start=strstr(command->noop.raw_command,"SPOR"); - + i=0; - + while(start != &(command->noop.raw_command[i])) { i++; } arg_start = i+4; - + i = arg_start; - + j = 0; - + /* figure out how many host/port arguments there are */ - + while(command->noop.raw_command[i]) { if(isspace(command->noop.raw_command[i])) @@ -3941,7 +3944,7 @@ globus_result_t globus_l_ftp_control_parse_spor_cmd( { i++; } - + if(command->noop.raw_command[i]) { j++; @@ -3952,12 +3955,12 @@ globus_result_t globus_l_ftp_control_parse_spor_cmd( i++; } } - + /* allocate memory for them */ - + command->spor.host_port = (globus_ftp_control_host_port_t*) globus_libc_malloc(j*sizeof(globus_ftp_control_host_port_t)); - + if(command->spor.host_port == GLOBUS_NULL) { return globus_error_put( @@ -3966,12 +3969,12 @@ globus_result_t globus_l_ftp_control_parse_spor_cmd( GLOBUS_NULL, _FCSL("globus_ftp_control_command_init: malloc failed"))); } - + command->spor.num_args = j; - + i = arg_start; j = 0; - + while(command->noop.raw_command[i]) { if(!isspace(command->noop.raw_command[i])) @@ -3989,7 +3992,7 @@ globus_result_t globus_l_ftp_control_parse_spor_cmd( command->code=GLOBUS_FTP_CONTROL_COMMAND_UNKNOWN; return GLOBUS_SUCCESS; } - + if((command->spor.host_port[j].host)[0] > 255 || (command->spor.host_port[j].host)[1] > 255 || (command->spor.host_port[j].host)[2] > 255 || @@ -4001,18 +4004,18 @@ globus_result_t globus_l_ftp_control_parse_spor_cmd( command->code=GLOBUS_FTP_CONTROL_COMMAND_UNKNOWN; return GLOBUS_SUCCESS; } - - command->spor.host_port[j].port= + + command->spor.host_port[j].port= (short) 256*port[0]+port[1]; command->spor.host_port[j].hostlen = 4; - + i++; while(command->noop.raw_command[i] && !isspace(command->noop.raw_command[i])) { i++; } - + if(command->noop.raw_command[i]) { j++; @@ -4023,16 +4026,16 @@ globus_result_t globus_l_ftp_control_parse_spor_cmd( i++; } } - + return GLOBUS_SUCCESS; } globus_result_t globus_l_ftp_control_parse_type_cmd( - globus_ftp_control_command_t * command) + globus_ftp_control_command_t * command) { char tmp; - + command->type.option=GLOBUS_FTP_CONTROL_TYPE_NO_OPTION; command->type.bytesize=0; @@ -4040,13 +4043,13 @@ globus_result_t globus_l_ftp_control_parse_type_cmd( { command->type.type=GLOBUS_FTP_CONTROL_TYPE_NONE; } - + switch(tmp) { case 'A': case 'a': command->type.type=GLOBUS_FTP_CONTROL_TYPE_ASCII; - + if(sscanf(command->noop.raw_command, "%*s %*c %c",&tmp) > 0) { @@ -4068,11 +4071,11 @@ globus_result_t globus_l_ftp_control_parse_type_cmd( } } return GLOBUS_SUCCESS; - + case 'E': case 'e': command->type.type=GLOBUS_FTP_CONTROL_TYPE_EBCDIC; - + if(sscanf(command->noop.raw_command, "%*s %*c %c",&tmp) > 0) { @@ -4118,17 +4121,17 @@ globus_result_t globus_l_ftp_control_parse_type_cmd( globus_result_t globus_l_ftp_control_parse_stru_cmd( - globus_ftp_control_command_t * command) + globus_ftp_control_command_t * command) { char tmp; - + command->stru.structure= GLOBUS_FTP_CONTROL_STRUCTURE_NONE; if(sscanf(command->noop.raw_command,"%*s %c",&tmp) < 1) { return GLOBUS_SUCCESS; } - + switch(tmp) { case 'F': @@ -4153,48 +4156,48 @@ globus_result_t globus_l_ftp_control_parse_stru_cmd( globus_result_t globus_l_ftp_control_parse_auth_cmd( - globus_ftp_control_command_t * command) + globus_ftp_control_command_t * command) { char tmp[10]; int i; - + command->auth.type=GLOBUS_FTP_CONTROL_AUTH_UNKNOWN; - + if(sscanf(command->noop.raw_command,"%*s %7s",tmp) < 1) { return GLOBUS_SUCCESS; } - + i = 0; - + while(tmp[i] != '\0') { tmp[i] = toupper(tmp[i]); i++; } - + if(strcmp("GSSAPI",tmp) == 0) { command->auth.type=GLOBUS_FTP_CONTROL_AUTH_GSSAPI; } - + return GLOBUS_SUCCESS; - + } globus_result_t globus_l_ftp_control_parse_mode_cmd( - globus_ftp_control_command_t * command) + globus_ftp_control_command_t * command) { char tmp; - + command->code=GLOBUS_FTP_CONTROL_COMMAND_MODE; - + if(sscanf(command->noop.raw_command,"%*s %c",&tmp) < 1) { command->mode.mode=GLOBUS_FTP_CONTROL_MODE_NONE; return GLOBUS_SUCCESS; } - + switch(tmp) { case 'S': diff --git a/gridftp/control/source/test/connect_disconnect_test.c b/gridftp/control/source/test/connect_disconnect_test.c index 92673a84a2..bf47a474a6 100644 --- a/gridftp/control/source/test/connect_disconnect_test.c +++ b/gridftp/control/source/test/connect_disconnect_test.c @@ -73,10 +73,10 @@ connect_response_callback( { memset(&auth, '\0', sizeof(auth)); { - OM_uint32 maj, min; + OM_uint32 min; gss_buffer_desc buffer; - maj = gss_acquire_cred( + gss_acquire_cred( &min, GSS_C_NO_NAME, 0, diff --git a/gridftp/control/source/test/connect_test.c b/gridftp/control/source/test/connect_test.c index 2a9ed57394..9f9ab9ee90 100644 --- a/gridftp/control/source/test/connect_test.c +++ b/gridftp/control/source/test/connect_test.c @@ -59,7 +59,7 @@ typedef struct globus_ftp_control_auth_info_t auth_info; bool use_auth; enum - { + { CMD_CONNECT, CMD_AUTHENTICATE, CMD_QUIT, @@ -80,7 +80,7 @@ void globus_l_server_close_callback( void * callback_arg, globus_ftp_control_handle_t *handle, - globus_object_t *error, + globus_object_t *error, globus_ftp_control_response_t *ftp_response); static void @@ -94,7 +94,7 @@ void globus_l_client_callback( void * callback_arg, globus_ftp_control_handle_t *handle, - globus_object_t *error, + globus_object_t *error, globus_ftp_control_response_t *ftp_response) { globus_result_t result = GLOBUS_SUCCESS; @@ -138,7 +138,7 @@ globus_l_client_callback( globus_l_client_callback, client); client->command = CMD_QUIT; - if (result == GLOBUS_SUCCESS + if (result == GLOBUS_SUCCESS && ftp_response->code > 399) { client->error = globus_error_construct_string( @@ -877,7 +877,7 @@ void globus_l_server_close_callback( void * callback_arg, globus_ftp_control_handle_t *handle, - globus_object_t *error, + globus_object_t *error, globus_ftp_control_response_t *ftp_response) { globus_l_server_response_callback(callback_arg, handle, error); @@ -892,7 +892,7 @@ globus_l_server_response_callback( { auth_test_server_session_t *session = callback_arg; globus_result_t res = GLOBUS_SUCCESS; - globus_ftp_control_auth_requirements_t + globus_ftp_control_auth_requirements_t auth_req; if (error) @@ -954,19 +954,18 @@ globus_l_server_accept_callback( globus_ftp_control_handle_t * handle, globus_object_t * error) { - globus_result_t res; auth_test_server_session_t *session = callback_arg; if (error != NULL) { session->server_state = SERVER_DONE; - res = globus_ftp_control_force_close( + globus_ftp_control_force_close( handle, globus_l_server_close_callback, callback_arg); } - res = globus_ftp_control_send_response( + globus_ftp_control_send_response( handle, "220 Globus GridFTP Test Server\r\n", globus_l_server_response_callback, @@ -974,7 +973,7 @@ globus_l_server_accept_callback( } static -void +void globus_l_server_listen_callback( void * callback_arg, globus_ftp_control_server_t * server_handle, @@ -1048,7 +1047,7 @@ initialize_servers(void) cleartext_server.auth_requirements = GLOBUS_FTP_CONTROL_AUTH_REQ_USER | GLOBUS_FTP_CONTROL_AUTH_REQ_PASS; - + result = globus_ftp_control_server_handle_init( &tls_server.server); if (result != GLOBUS_SUCCESS) diff --git a/gridftp/control/source/test/data_test.c b/gridftp/control/source/test/data_test.c index 8e58816f44..ba5d9e6102 100644 --- a/gridftp/control/source/test/data_test.c +++ b/gridftp/control/source/test/data_test.c @@ -146,12 +146,12 @@ connect_read_big_buffer_callback( globus_bool_t resuse, globus_object_t * error); -void +void binary_eb_mode( globus_ftp_control_handle_t * handle, int plevel); -void +void binary_stream_mode( globus_ftp_control_handle_t * handle, int plevel); @@ -170,7 +170,7 @@ diff( const char * dest); void -force_close_cb( +force_close_cb( void * user_arg, globus_ftp_control_handle_t * handle, globus_object_t * error) @@ -187,15 +187,15 @@ force_close_cb( globus_mutex_unlock(&monitor->mutex); } -int +int main( int argc, char * argv[]) -{ +{ globus_result_t res; int ctr; - int rc; - int i; + int rc; + int i; int plevel; LTDL_SET_PRELOADED_SYMBOLS(); @@ -328,7 +328,7 @@ main( for(plevel = 1; plevel <= MAX_PLEVEL; plevel++) { verbose_printf(2, "parallel level %d\n", plevel); - big_buffer_test(binary_eb_mode, plevel); + big_buffer_test(binary_eb_mode, plevel); } verbose_printf(1, "big buffer in eb mode passed\n"); printf("ok - big_buffer_test(binary_eb_mode, plevel)\n"); @@ -414,13 +414,13 @@ test_send_eof( (void *)&done_monitor); if(res != GLOBUS_SUCCESS) - { + { return res; } globus_mutex_lock(&done_monitor.mutex); { while(!done_monitor.done) - { + { globus_cond_wait(&done_monitor.cond, &done_monitor.mutex); } } @@ -490,7 +490,7 @@ big_buffer_test( verbose_printf(3, "waiting for transfer.\n"); globus_mutex_lock(&done_monitor.mutex); { - while(done_monitor.count < 2 && + while(done_monitor.count < 2 && !done_monitor.done) { globus_cond_wait(&done_monitor.cond, &done_monitor.mutex); @@ -619,12 +619,12 @@ reuse_handles_test( &port_connections, 0); - verbose_printf(3, + verbose_printf(3, "pasv_connection count = %d, port connection count = %d\n", pasv_connections, port_connections); globus_mutex_lock(&done_monitor.mutex); { - while(done_monitor.count < 2 && + while(done_monitor.count < 2 && !done_monitor.done) { globus_cond_wait(&done_monitor.cond, &done_monitor.mutex); @@ -684,7 +684,7 @@ reuse_handles_test( return GLOBUS_SUCCESS; } -void +void binary_eb_mode( globus_ftp_control_handle_t * handle, int plevel) @@ -696,23 +696,23 @@ binary_eb_mode( parallelism.fixed.size = plevel; res = globus_ftp_control_local_type( - handle, - GLOBUS_FTP_CONTROL_TYPE_IMAGE, + handle, + GLOBUS_FTP_CONTROL_TYPE_IMAGE, 0); test_result(res, "local_type", __LINE__); res = globus_ftp_control_local_mode( - handle, + handle, GLOBUS_FTP_CONTROL_MODE_EXTENDED_BLOCK); test_result(res, "local_mode", __LINE__); res = globus_ftp_control_local_parallelism( - handle, + handle, ¶llelism); test_result(res, "local_mode", __LINE__); } -void +void binary_stream_mode( globus_ftp_control_handle_t * handle, int plevel) @@ -720,13 +720,13 @@ binary_stream_mode( globus_result_t res; res = globus_ftp_control_local_type( - handle, - GLOBUS_FTP_CONTROL_TYPE_IMAGE, + handle, + GLOBUS_FTP_CONTROL_TYPE_IMAGE, 0); test_result(res, "local_type", __LINE__); res = globus_ftp_control_local_mode( - handle, + handle, GLOBUS_FTP_CONTROL_MODE_STREAM); test_result(res, "local_mode", __LINE__); } @@ -735,7 +735,6 @@ globus_result_t cache_multiparallel_test( set_handle_mode_cb_t mode_cb) { - int ctr; int ctr2; globus_result_t res; globus_ftp_control_host_port_t host_port; @@ -743,7 +742,7 @@ cache_multiparallel_test( globus_ftp_control_handle_t pasv_handle; ftp_test_monitor_t done_monitor; data_test_info_t * test_info; - int nsock_a[] = + int nsock_a[] = {4, 16, 8, 32, 2, 4, 0}; ftp_test_monitor_init(&done_monitor); @@ -769,7 +768,6 @@ cache_multiparallel_test( for(ctr2 = 0; nsock_a[ctr2] != 0; ctr2++) { verbose_printf(2, "parallel level %d\n", nsock_a[ctr2]); -// for(ctr = 0; ctr < TEST_ITERATIONS; ctr++) { mode_cb(&pasv_handle, nsock_a[ctr2]); mode_cb(&port_handle, nsock_a[ctr2]); @@ -794,7 +792,7 @@ cache_multiparallel_test( verbose_printf(3, "waiting for transfer.\n"); globus_mutex_lock(&done_monitor.mutex); { - while(done_monitor.count < 2 && + while(done_monitor.count < 2 && !done_monitor.done) { globus_cond_wait(&done_monitor.cond, &done_monitor.mutex); @@ -914,7 +912,7 @@ cache_test( verbose_printf(3, "waiting for transfer.\n"); globus_mutex_lock(&done_monitor.mutex); { - while(done_monitor.count < 2 && + while(done_monitor.count < 2 && !done_monitor.done) { globus_cond_wait(&done_monitor.cond, &done_monitor.mutex); @@ -974,13 +972,13 @@ cache_test( * It then sends data to all of them and compares the data on both ends * if the trasfers. In order to ease the testing of some of the clean up * this test does leak some memory. - * + * * It tests the control library data code for: * 1) read and write functionality for data integrity * 2) functionality when multiple handles are simaltaneously being used. * 3) reads of sizes greater than and smaller than the size of the extended * block. - * 4) clean up. At the end of half the transfers close() and destroy() + * 4) clean up. At the end of half the transfers close() and destroy() * are called. The other half leave the clean up up to deactivate. */ globus_result_t @@ -1018,7 +1016,7 @@ transfer_test( res = globus_i_ftp_control_data_cc_init(pasv_handle); test_result(res, "pasv handle init", __LINE__); - + res = globus_i_ftp_control_data_cc_init(port_handle); test_result(res, "port handle init", __LINE__); @@ -1033,7 +1031,7 @@ transfer_test( mode_cb(pasv_handle, plevel); mode_cb(port_handle, plevel); - + if(!g_send_eof) { res = globus_ftp_control_local_send_eof( @@ -1082,7 +1080,7 @@ transfer_test( if(res == GLOBUS_SUCCESS) { globus_mutex_lock(&done_monitor.mutex); - { + { while(!done_monitor.done) { globus_cond_wait(&done_monitor.cond, &done_monitor.mutex); @@ -1136,12 +1134,12 @@ connect_read_big_buffer_callback( globus_result_t res; test_info = (data_test_info_t *)callback_arg; - - verbose_printf(3, - "connect_read_big_buffer_callback() : start\n"); + + verbose_printf(3, + "connect_read_big_buffer_callback() : start\n"); if(error != GLOBUS_NULL) { - test_result(globus_error_put(error), + test_result(globus_error_put(error), "connect_read_big_buffer_callback error", __LINE__); } @@ -1194,8 +1192,8 @@ connect_read_callback( globus_result_t res; test_info = (data_test_info_t *)callback_arg; - - verbose_printf(3, "connect_read_callback() : start\n"); + + verbose_printf(3, "connect_read_callback() : start\n"); if(error != GLOBUS_NULL) { test_result(globus_error_put(error), "connect_read_callback error" @@ -1213,7 +1211,7 @@ connect_read_callback( { failure_end("stat failed\n"); } - write_blk_size = stat_info.st_size / WRITE_CHUNK_COUNT + 1; + write_blk_size = stat_info.st_size / WRITE_CHUNK_COUNT + 1; blk_size = write_blk_size / 2 + 1; buf = (globus_byte_t *)malloc(blk_size); @@ -1239,10 +1237,10 @@ data_read_big_buffer_callback( globus_off_t offset_read, globus_bool_t eof) { - data_test_info_t * test_info; + data_test_info_t * test_info; - verbose_printf(4, - "data_read_big_buffer_callback():start %d %d %d\n", + verbose_printf(4, + "data_read_big_buffer_callback():start %d %d %d\n", length_read, offset_read, eof); if(error != GLOBUS_NULL) @@ -1262,8 +1260,8 @@ data_read_big_buffer_callback( { verbose_printf(3, "eof big buffer callback\n"); /* write out the entire buffer */ - - if(fwrite(buffer, 1, test_info->bb_len, test_info->fout) + + if(fwrite(buffer, 1, test_info->bb_len, test_info->fout) != test_info->bb_len) { failure_end("fwrite failed\n"); @@ -1276,7 +1274,7 @@ data_read_big_buffer_callback( { verbose_printf(1, "files are not the same: %d\n", __LINE__); test_info->monitor->done = GLOBUS_TRUE; - test_info->monitor->result = + test_info->monitor->result = globus_error_put(GLOBUS_ERROR_NO_INFO); globus_cond_signal(&test_info->monitor->cond); } @@ -1331,10 +1329,10 @@ connect_write_big_buffer_callback( { failure_end("stat failed\n"); } - + offset = 0; fseek(test_info->fin, offset, SEEK_SET); - blk_size = stat_info.st_size / WRITE_CHUNK_COUNT + 1; + blk_size = stat_info.st_size / WRITE_CHUNK_COUNT + 1; for(ctr = 0; ctr < WRITE_CHUNK_COUNT; ctr++) { buf = globus_malloc(blk_size); @@ -1342,7 +1340,7 @@ connect_write_big_buffer_callback( /* * read a chunk */ - nbyte = fread(buf, 1, blk_size, test_info->fin); + nbyte = fread(buf, 1, blk_size, test_info->fin); if(nbyte < blk_size) { if(feof(test_info->fin)) @@ -1368,7 +1366,7 @@ connect_write_big_buffer_callback( nbyte, offset, eof, - data_write_callback, + data_write_callback, (void *)test_info); test_result(res, "data_write", __LINE__); offset += nbyte; @@ -1377,7 +1375,7 @@ connect_write_big_buffer_callback( globus_mutex_unlock(&test_info->monitor->mutex); } -void +void data_read_callback( void * callback_arg, globus_ftp_control_handle_t * handle, @@ -1387,12 +1385,12 @@ data_read_callback( globus_off_t offset, globus_bool_t eof) { - data_test_info_t * test_info; + data_test_info_t * test_info; globus_result_t res; int blk_size; globus_byte_t * buf; - verbose_printf(4, "data_read_callback() : start\n"); + verbose_printf(4, "data_read_callback() : start\n"); if(error != GLOBUS_NULL) { failure_end("data_read_callback error\n"); @@ -1420,7 +1418,7 @@ data_read_callback( { verbose_printf(1, "files are not the same: %d\n", __LINE__); test_info->monitor->done = GLOBUS_TRUE; - test_info->monitor->result = + test_info->monitor->result = globus_error_put(GLOBUS_ERROR_NO_INFO); globus_cond_signal(&test_info->monitor->cond); } @@ -1492,8 +1490,8 @@ connect_write_callback( { failure_end("stat failed\n"); } - - blk_size = stat_info.st_size / WRITE_CHUNK_COUNT + 1; + + blk_size = stat_info.st_size / WRITE_CHUNK_COUNT + 1; for(ctr = 0; ctr < WRITE_CHUNK_COUNT; ctr++) { buf = globus_malloc(blk_size); @@ -1501,7 +1499,7 @@ connect_write_callback( /* * read a chunk */ - nbyte = fread(buf, 1, blk_size, test_info->fin); + nbyte = fread(buf, 1, blk_size, test_info->fin); if(nbyte < blk_size) { if(feof(test_info->fin)) @@ -1518,7 +1516,7 @@ connect_write_callback( /* * write a chunk */ - verbose_printf(4, + verbose_printf(4, "registering a write 0x%x offset=%d length=%d eof=%d\n", buf, offset, nbyte, eof); res = globus_ftp_control_data_write( @@ -1527,7 +1525,7 @@ connect_write_callback( nbyte, offset, eof, - data_write_callback, + data_write_callback, (void *)test_info); test_result(res, "data_write", __LINE__); offset += nbyte; @@ -1592,7 +1590,7 @@ connect_write_zero_eof_callback( /* * write a chunk */ - verbose_printf(4, + verbose_printf(4, "registering a write 0x%x offset=%d length=%d eof=%d\n", buf, offset, nbyte, eof); res = globus_ftp_control_data_write( @@ -1605,7 +1603,7 @@ connect_write_zero_eof_callback( (void *)test_info); test_result(res, "data_write", __LINE__); offset += nbyte; - + res = globus_ftp_control_data_write( handle, buf, @@ -1658,7 +1656,7 @@ data_write_callback( globus_cond_signal(&test_info->monitor->cond); } globus_mutex_unlock(&test_info->monitor->mutex); - } + } if(length > 0 &&!eof) { globus_free(buffer); @@ -1776,7 +1774,7 @@ diff( do { b += fread(dbuf + b, 1, a-b, dfp); - } + } while (b > 0 && b < a && (!feof(dfp)) && (!ferror(dfp))); if (a == b) diff --git a/gridftp/control/source/test/get_lingering_close.c b/gridftp/control/source/test/get_lingering_close.c index fa10030d8a..3fa6925dd7 100644 --- a/gridftp/control/source/test/get_lingering_close.c +++ b/gridftp/control/source/test/get_lingering_close.c @@ -59,13 +59,13 @@ response_cb( { if(response->code == 220) { - OM_uint32 maj, min; + OM_uint32 min; gss_buffer_desc buffer; gss_cred_id_t g_cred; gss_name_t g_name; char * g_subject; - maj = gss_acquire_cred( + gss_acquire_cred( &min, GSS_C_NO_NAME, 0, diff --git a/gridftp/control/source/test/globus_ftp_control_test.c b/gridftp/control/source/test/globus_ftp_control_test.c index 4d68e44f2c..01575ab51a 100644 --- a/gridftp/control/source/test/globus_ftp_control_test.c +++ b/gridftp/control/source/test/globus_ftp_control_test.c @@ -57,8 +57,8 @@ abort_test_wrapper( * a string describing it to the "test_array" table, and * increase the TEST_COUNT by one. ****************************************************************/ -typedef -globus_bool_t +typedef +globus_bool_t (*globus_ftp_control_test_func_t)( globus_ftp_control_handle_t * control_handle); @@ -74,7 +74,7 @@ test_entry_t test_array[] = {disconnect_wrapper, "disconnect handle test"}, {simple_dir_test_wrapper, "simple directory test"}, {simple_data_test_wrapper, "simple data test"}, - {abort_test_wrapper, "abort test"}, + {abort_test_wrapper, "abort test"}, {outstanding_io_test_wrapper, "outstanding io data test"}, {simple_control_test_wrapper, "simple control test"}, {async_control_test, "asynchronous control test"}, @@ -99,11 +99,11 @@ login_t login_info = { 0 }; extern int verbose_print_level; -int +int main( int argc, char * argv[]) -{ +{ int ctr; globus_ftp_control_handle_t control_handle; globus_result_t result; @@ -167,24 +167,24 @@ main( /* * first test */ - rc = globus_module_activate(GLOBUS_FTP_CONTROL_MODULE); + globus_module_activate(GLOBUS_FTP_CONTROL_MODULE); tests_run++; result = globus_ftp_control_handle_init(&handles[0]); connect_control_handle( - &handles[0], + &handles[0], login_info.login, login_info.password, login_info.dir, login_info.hostname, login_info.port); - rc = globus_module_deactivate(GLOBUS_FTP_CONTROL_MODULE); + globus_module_deactivate(GLOBUS_FTP_CONTROL_MODULE); tests_passed++; verbose_printf(1, "test #%d) activate/connect/deactivate passed\n", tests_run); /* * second test */ - rc = globus_module_activate(GLOBUS_FTP_CONTROL_MODULE); + globus_module_activate(GLOBUS_FTP_CONTROL_MODULE); tests_run++; for(ctr = 0; ctr < TEST_COUNT; ctr++) { @@ -192,8 +192,8 @@ main( if(result != GLOBUS_SUCCESS) { tests_failed++; - verbose_printf(1, - "activate/deactivate test # %d failed\n", + verbose_printf(1, + "activate/deactivate test # %d failed\n", tests_run); exit(1); } @@ -203,31 +203,31 @@ main( if(result != GLOBUS_SUCCESS) { tests_failed++; - verbose_printf(1, - "activate/deactivate test # %d failed\n", + verbose_printf(1, + "activate/deactivate test # %d failed\n", tests_run); exit(1); } } } rc = globus_module_deactivate(GLOBUS_FTP_CONTROL_MODULE); - if(result != GLOBUS_SUCCESS) + if(rc != GLOBUS_SUCCESS) { tests_failed++; - verbose_printf(1, - "activate/deactivate test # %d failed\n", + verbose_printf(1, + "activate/deactivate test # %d failed\n", tests_run); exit(1); } tests_passed++; verbose_printf(1, "test #%d) activate/deactivate passed\n", tests_run); - + /* * initailize variables for the test */ rc = globus_module_activate(GLOBUS_COMMON_MODULE); - if(result != GLOBUS_SUCCESS) + if(rc != GLOBUS_SUCCESS) { globus_libc_printf("unable to activate common module\n"); exit(1); @@ -236,7 +236,7 @@ main( * run stream mode tests */ rc = globus_module_activate(GLOBUS_FTP_CONTROL_MODULE); - if(result != GLOBUS_SUCCESS) + if(rc != GLOBUS_SUCCESS) { globus_libc_printf("unable to activate gsiftp module\n"); exit(1); @@ -249,14 +249,14 @@ main( if(eb_test_array[ctr].test_func(&control_handle)) { tests_passed++; - verbose_printf(1, "test #%d) \"%s\" passed.\n", + verbose_printf(1, "test #%d) \"%s\" passed.\n", tests_run, eb_test_array[ctr].name); } else { tests_failed++; printf("Failed\n"); - verbose_printf(1, "test #%d) \"%s\" failed.\n", + verbose_printf(1, "test #%d) \"%s\" failed.\n", tests_run, eb_test_array[ctr].name); exit(1); } @@ -270,14 +270,14 @@ main( if(test_array[ctr].test_func(&control_handle)) { tests_passed++; - verbose_printf(1, "test #%d) \"%s\" passed.\n", + verbose_printf(1, "test #%d) \"%s\" passed.\n", tests_run, test_array[ctr].name); } else { tests_failed++; printf("Failed\n"); - verbose_printf(1, "test #%d) \"%s\" failed.\n", + verbose_printf(1, "test #%d) \"%s\" failed.\n", tests_run, test_array[ctr].name); exit(1); } @@ -285,7 +285,7 @@ main( globus_ftp_control_handle_destroy(&control_handle); rc = globus_module_deactivate(GLOBUS_FTP_CONTROL_MODULE); - if(result != GLOBUS_SUCCESS) + if(rc != GLOBUS_SUCCESS) { globus_libc_printf("unable to activate gsiftp module\n"); exit(1); @@ -310,12 +310,12 @@ simple_control_test_wrapper( login_info.dir, login_info.hostname, login_info.port); - if(rc) + if(rc) { rc = simple_control_test(control_handle); } if(rc) - { + { rc = disconnect_control_handle(control_handle); } @@ -362,14 +362,14 @@ simple_data_test_wrapper( { rc = simple_data_test(control_handle); } - if(rc) + if(rc) { rc = disconnect_control_handle(control_handle); } return rc; } - + globus_bool_t eb_simple_data_test_wrapper( globus_ftp_control_handle_t * control_handle) @@ -386,14 +386,14 @@ eb_simple_data_test_wrapper( { rc = eb_data_test(control_handle); } - if(rc) + if(rc) { rc = disconnect_control_handle(control_handle); } return rc; } - + globus_bool_t outstanding_io_test_wrapper( globus_ftp_control_handle_t * control_handle) @@ -406,11 +406,11 @@ outstanding_io_test_wrapper( login_info.dir, login_info.hostname, login_info.port); - if(rc) + if(rc) { rc = outstanding_io_test(control_handle); } - if(rc) + if(rc) { rc = disconnect_control_handle(control_handle); } @@ -464,4 +464,4 @@ abort_test_wrapper( } return rc; -} +} diff --git a/gridftp/control/source/test/test_server.c b/gridftp/control/source/test/test_server.c index d0274624af..56b94c5305 100644 --- a/gridftp/control/source/test/test_server.c +++ b/gridftp/control/source/test/test_server.c @@ -119,9 +119,8 @@ gpftpd_ac_response_callback( void * callback_arg, globus_ftp_control_handle_t * handle, globus_object_t * error) -{ - globus_result_t result; - result = globus_ftp_control_read_commands( +{ + globus_ftp_control_read_commands( handle, gpftpd_command_callback, callback_arg); @@ -213,21 +212,19 @@ gpftpd_accept_callback( globus_ftp_control_handle_t * handle, globus_object_t * error) { - globus_result_t res; - if(error) { error_msg(globus_error_put(error), __LINE__); } - res = globus_ftp_control_send_response( + globus_ftp_control_send_response( handle, "220 Globus GridFTP Test Server\r\n", gpftpd_response_callback, callback_arg); } -void +void gpftpd_listen_callback( void * callback_arg, globus_ftp_control_server_t * server_handle, diff --git a/gridftp/gfork/source/configure.ac b/gridftp/gfork/source/configure.ac index ae14337357..5e9ce8b07a 100644 --- a/gridftp/gfork/source/configure.ac +++ b/gridftp/gfork/source/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ([2.60]) -AC_INIT([globus_gfork], [5.0], [https://github.com/gridcf/gct/issues]) +AC_INIT([globus_gfork], [5.1], [https://github.com/gridcf/gct/issues]) AC_CONFIG_MACRO_DIR([m4]) AC_SUBST([MAJOR_VERSION], [${PACKAGE_VERSION%%.*}]) AC_SUBST([MINOR_VERSION], [${PACKAGE_VERSION##*.}]) diff --git a/gridftp/gfork/source/globus_gfork_server.c b/gridftp/gfork/source/globus_gfork_server.c index abb63b012f..64db5b2620 100644 --- a/gridftp/gfork/source/globus_gfork_server.c +++ b/gridftp/gfork/source/globus_gfork_server.c @@ -53,7 +53,7 @@ gfork_accept_allowed() { return GLOBUS_TRUE; } - + return (gfork_l_connection_count < gfork_l_options.instances); } @@ -104,7 +104,7 @@ gfork_kid_set_keeper_envs( globus_list_insert(&new_list, globus_libc_strdup(val_s)); } - + for(i = 0; gfork_l_keep_envs[i] != NULL; i++) { @@ -120,16 +120,16 @@ gfork_kid_set_keeper_envs( } /* set extra envs */ - kv_pair = globus_common_create_string("%s=%d", + kv_pair = globus_common_create_string("%s=%d", GFORK_CHILD_READ_ENV, read_fd); globus_list_insert(&new_list, kv_pair); - kv_pair = globus_common_create_string("%s=%d", + kv_pair = globus_common_create_string("%s=%d", GFORK_CHILD_WRITE_ENV, write_fd); globus_list_insert(&new_list, kv_pair); - kv_pair = globus_common_create_string("%s=%s", + kv_pair = globus_common_create_string("%s=%s", GFORK_CHILD_CS_ENV, g_contact_string); globus_list_insert(&new_list, kv_pair); - kv_pair = globus_common_create_string("%s=%d", + kv_pair = globus_common_create_string("%s=%d", GFORK_CHILD_INSTANCE_ENV, gfork_l_options.instances); globus_list_insert(&new_list, kv_pair); @@ -224,7 +224,7 @@ gfork_l_kid_read_close_cb( globus_xio_handle_t handle, globus_result_t result, void * user_arg) -{ +{ globus_list_t * list; gfork_i_child_handle_t * kid_handle; gfork_i_state_t tmp_state; @@ -253,7 +253,7 @@ gfork_l_kid_read_close_cb( } globus_fifo_destroy(&kid_handle->write_q); globus_free(kid_handle); - + globus_cond_signal(&gfork_l_cond); } globus_mutex_unlock(&gfork_l_mutex); @@ -267,7 +267,7 @@ gfork_l_kid_write_close_cb( globus_xio_handle_t handle, globus_result_t result, void * user_arg) -{ +{ gfork_i_child_handle_t * kid_handle; kid_handle = (gfork_i_child_handle_t *) user_arg; @@ -332,7 +332,7 @@ gfork_l_write_open_cb( sizeof(gfork_i_msg_header_t), NULL, gfork_l_read_header_cb, - msg); + msg); if(result != GLOBUS_SUCCESS) { goto error_post; @@ -388,12 +388,10 @@ gfork_l_write_close_cb( globus_xio_data_descriptor_t data_desc, void * user_arg) { - gfork_i_child_handle_t * kid_handle; gfork_i_child_handle_t * ms_handle; gfork_i_msg_t * msg; msg = (gfork_i_msg_t *) user_arg; - kid_handle = msg->from_kid; ms_handle = msg->to_kid; globus_mutex_lock(&gfork_l_mutex); @@ -426,7 +424,7 @@ gfork_i_write_close( gfork_i_child_handle_t * kid_handle) { globus_result_t result; - globus_list_t * list; + globus_list_t * list; gfork_i_msg_t * msg; globus_hashtable_to_list(&gfork_l_master_pid_table, &list); @@ -434,7 +432,7 @@ gfork_i_write_close( { gfork_i_child_handle_t * ms_kid; ms_kid = (gfork_i_child_handle_t *) globus_list_remove(&list, list); - + msg = (gfork_i_msg_t *) globus_calloc(1, sizeof(gfork_i_msg_t)); msg->header.type = GLOBUS_GFORK_MSG_CLOSE; msg->header.from_pid = kid_handle->pid; @@ -495,17 +493,13 @@ gfork_l_spawn_master( pid_t pid; int infds[2]; int outfds[2]; - int read_fd; - int write_fd; int rc; - gfork_i_options_t * gfork_h; globus_result_t result; gfork_i_msg_t * msg; globus_list_t * child_env_list; gfork_i_child_handle_t * master_child_handle = NULL; GForkFuncName(gfork_l_spawn_master); - gfork_h = &gfork_l_options; if(ms_ent->master == NULL) { gfork_log(1, "There is no master program.\n"); @@ -543,9 +537,6 @@ gfork_l_spawn_master( close(outfds[1]); close(infds[0]); - read_fd = outfds[0]; - write_fd = infds[1]; - environ = child_env; nice(ms_ent->master_nice); @@ -610,7 +601,7 @@ gfork_l_spawn_master( sizeof(gfork_i_msg_header_t), NULL, gfork_l_read_header_cb, - msg); + msg); if(result != GLOBUS_SUCCESS) { goto error_read_post; @@ -690,7 +681,7 @@ gfork_l_dead_kid( globus_assert(list != NULL); globus_list_remove(&gfork_l_pid_list, list); - gfork_log(2, "Cleaned up child %d, list is at %d\n", + gfork_log(2, "Cleaned up child %d, list is at %d\n", child_pid, globus_list_size(gfork_l_pid_list)); globus_cond_signal(&gfork_l_cond); @@ -703,7 +694,6 @@ gfork_l_sigchld( { int child_pid; int child_status; - int child_rc; globus_bool_t dead; gfork_log(2, "Sigint child\n"); @@ -715,7 +705,6 @@ gfork_l_sigchld( if(WIFEXITED(child_status)) { /* normal exit */ - child_rc = WEXITSTATUS(child_status); dead = GLOBUS_TRUE; } else if(WIFSIGNALED(child_status)) @@ -1107,7 +1096,7 @@ gfork_init_server() } /* - * post for in child. Never returns from here + * post for in child. Never returns from here */ static void @@ -1118,7 +1107,6 @@ gfork_new_child( int write_fd, globus_list_t * list) { - globus_result_t res; int rc = 1; GlobusGForkFuncName(gfork_new_child); @@ -1132,13 +1120,11 @@ gfork_new_child( rc = dup2(socket_handle, STDIN_FILENO); if(rc < 0) { - res = GForkErrorErrno(strerror, errno); goto error_dupin; } rc = dup2(socket_handle, STDOUT_FILENO); if(rc < 0) { - res = GForkErrorErrno(strerror, errno); goto error_dupout; } close(socket_handle); @@ -1174,7 +1160,7 @@ gfork_i_opts_unknown( /******************** IO functions ****************************/ static -void +void gfork_l_read_body_cb( globus_xio_handle_t handle, globus_result_t result, @@ -1283,7 +1269,7 @@ gfork_l_read_body_cb( gfork_l_write(ms_kid); } } - + gfork_log(1, "posting header read on %d for %d bytes\n", msg->from_kid->pid, sizeof(gfork_i_msg_header_t)); result = globus_xio_register_read( @@ -1496,9 +1482,9 @@ gfork_l_write( error_register: - return; + return; } - + @@ -1590,11 +1576,11 @@ main( } #ifndef BUILD_LITE -/* when threaded add a periodic callback to simulate the SIGCHLD signal, since +/* when threaded add a periodic callback to simulate the SIGCHLD signal, since * many versions of LinuxThreads don't seem to pass that to right thread */ { globus_reltime_t delay; - + GlobusTimeReltimeSet(delay, 10, 0); result = globus_callback_register_periodic( NULL, diff --git a/gridftp/gridftp_driver/source/configure.ac b/gridftp/gridftp_driver/source/configure.ac index c3dcd0bd70..9642848d61 100644 --- a/gridftp/gridftp_driver/source/configure.ac +++ b/gridftp/gridftp_driver/source/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ([2.60]) -AC_INIT([globus_xio_gridftp_driver],[3.6],[https://github.com/gridcf/gct/issues]) +AC_INIT([globus_xio_gridftp_driver],[3.7],[https://github.com/gridcf/gct/issues]) AC_CONFIG_MACRO_DIR([m4]) AC_SUBST([MAJOR_VERSION], [${PACKAGE_VERSION%%.*}]) AC_SUBST([MINOR_VERSION], [${PACKAGE_VERSION##*.}]) diff --git a/gridftp/gridftp_driver/source/globus_xio_gridftp_driver.h b/gridftp/gridftp_driver/source/globus_xio_gridftp_driver.h index 344a14b4d5..f04fc44cdd 100644 --- a/gridftp/gridftp_driver/source/globus_xio_gridftp_driver.h +++ b/gridftp/gridftp_driver/source/globus_xio_gridftp_driver.h @@ -28,7 +28,7 @@ #ifndef GLOBUS_GLOBAL_DOCUMENT_SET /** * @mainpage Globus XIO GridFTP Driver - * @copydoc globus_xio_gridftp_driver + * @copydoc globus_xio_gridftp_driver */ #endif @@ -41,12 +41,12 @@ * @addtogroup globus_xio_gridftp_driver * @section globus_xio_gridftp_driver_handles Handles * - * An XIO handle with the gridftp client driver can be created with - * globus_xio_handle_create() + * An XIO handle with the gridftp client driver can be created with + * globus_xio_handle_create() * - * The GridFTP client driver makes use of globus ftp client library. - * globus_xio_register_open() call creates a new ftp client handle (unless - * one is set on the attr passed), establishes connection with the + * The GridFTP client driver makes use of globus ftp client library. + * globus_xio_register_open() call creates a new ftp client handle (unless + * one is set on the attr passed), establishes connection with the * GridFTP server. The contact string must contain the scheme, host name, * and the resource, optionally it might contain port and subject also. * @@ -60,12 +60,12 @@ * * The globus_xio_register_read() enforce that the waitforbytes parameter * should be one. When multiple TCP streams are used between the client and the - * server, data might not be delivered in order. + * server, data might not be delivered in order. * globus_xio_data_descriptor_cntl() can be used to get the offset of the - * data. + * data. * - * globus_xio_register_write() does not enforce any restriction on the - * waitforbytes parameter. + * globus_xio_register_write() does not enforce any restriction on the + * waitforbytes parameter. * * In any case, when an error or EOF occurs before the waitforbytes request * has been met, the outgoing nbytes is set to the amount of data actually @@ -74,11 +74,11 @@ /** * @addtogroup globus_xio_gridftp_driver - * + * * @section globus_xio_gridftp_driver_env Environment Variables * - * - GLOBUS_XIO_GRIDFTP_DEBUG Available if using a debug build. See - * globus_debug.h for format. + * - GLOBUS_XIO_GRIDFTP_DEBUG Available if using a debug build. See + * globus_debug.h for format. */ /** @@ -100,11 +100,11 @@ * @addtogroup globus_xio_gridftp_driver * @section globus_xio_gridftp_driver_types Types * - * The errors reported by the GRIDFTP driver include GLOBUS_XIO_ERROR_EOF, - * GLOBUS_XIO_ERROR_CANCELED, @ref GLOBUS_XIO_GRIDFTP_ERROR_OUTSTANDING_READ, - * @ref GLOBUS_XIO_GRIDFTP_ERROR_SEEK, + * The errors reported by the GRIDFTP driver include GLOBUS_XIO_ERROR_EOF, + * GLOBUS_XIO_ERROR_CANCELED, @ref GLOBUS_XIO_GRIDFTP_ERROR_OUTSTANDING_READ, + * @ref GLOBUS_XIO_GRIDFTP_ERROR_SEEK, * @ref GLOBUS_XIO_GRIDFTP_ERROR_OUTSTANDING_WRITE, - * @ref GLOBUS_XIO_GRIDFTP_ERROR_PENDING_READ, + * @ref GLOBUS_XIO_GRIDFTP_ERROR_PENDING_READ, * @ref GLOBUS_XIO_GRIDFTP_ERROR_PENDING_WRITE, * @ref GLOBUS_XIO_GRIDFTP_ERROR_OUTSTANDING_PARTIAL_XFER * @@ -127,21 +127,21 @@ typedef enum */ GLOBUS_XIO_GRIDFTP_ERROR_SEEK, /** - * Indicates that a write has been called while there is an outstanding + * Indicates that a write has been called while there is an outstanding * read */ GLOBUS_XIO_GRIDFTP_ERROR_OUTSTANDING_READ, /** - * Indicates that a read has been called while there is an outstanding + * Indicates that a read has been called while there is an outstanding * write */ GLOBUS_XIO_GRIDFTP_ERROR_OUTSTANDING_WRITE, /** - * Indicates that a write has been called while there is a read pending + * Indicates that a write has been called while there is a read pending */ GLOBUS_XIO_GRIDFTP_ERROR_PENDING_READ, /** - * Indicates that a read has been called while there is a write pending + * Indicates that a read has been called while there is a write pending */ GLOBUS_XIO_GRIDFTP_ERROR_PENDING_WRITE, /** @@ -171,16 +171,16 @@ typedef enum { /* * handle cntls - */ + */ /** GlobusVarArgEnum(handle) * Reposition the offset of the file being read/written. - * @ingroup gridftp_driver_cntls + * @ingroup globus_xio_gridftp_driver * * @param seek_offset * Specifies the desired offset. */ - /* globus_off_t seek_offset */ + /* globus_off_t seek_offset */ GLOBUS_XIO_GRIDFTP_SEEK, /* @@ -188,213 +188,213 @@ typedef enum */ /** GlobusVarArgEnum(attr) * Set the ftp client handle to use. - * @ingroup gridftp_driver_cntls + * @ingroup globus_xio_gridftp_driver * Do not create a new ftp client handle, use this handle instead. * * @param ftp_handle * Specifies the pointer to globus ftp client handle. * Note: this handle will not be destroyed. */ - /* globus_ftp_client_handle_t * ftp_handle */ + /* globus_ftp_client_handle_t * ftp_handle */ GLOBUS_XIO_GRIDFTP_SET_HANDLE, /** GlobusVarArgEnum(attr) * Get the ftp client handle on the attr. - * @ingroup gridftp_driver_cntls + * @ingroup globus_xio_gridftp_driver * * @param ftp_handle_out * The ftp client handle pointer will be stored here. If none is set, * NULL will be set. */ - /* globus_ftp_client_handle_t ** ftp_handle_out */ + /* globus_ftp_client_handle_t ** ftp_handle_out */ GLOBUS_XIO_GRIDFTP_GET_HANDLE, /** GlobusVarArgEnum(attr) * Enable or disable opening the file in append mode. - * @ingroup gridftp_driver_cntls + * @ingroup globus_xio_gridftp_driver * * @param append * GLOBUS_TRUE to enable, GLOBUS_FALSE to disable (default). */ - /* globus_bool_t append */ + /* globus_bool_t append */ GLOBUS_XIO_GRIDFTP_SET_APPEND, /** GlobusVarArgEnum(attr) * Get the append flag on the attr. - * @ingroup gridftp_driver_cntls + * @ingroup globus_xio_gridftp_driver * * @param append_out - * The append flag will be stored here. + * The append flag will be stored here. */ - /* globus_bool_t * append_out */ + /* globus_bool_t * append_out */ GLOBUS_XIO_GRIDFTP_GET_APPEND, /** GlobusVarArgEnum(attr) * Set the ERET algorithm string. This string contains information needed - * to invoke a server-specific data reduction algorithm on the file being + * to invoke a server-specific data reduction algorithm on the file being * retrieved. - * @ingroup gridftp_driver_cntls + * @ingroup globus_xio_gridftp_driver * * @param eret_alg_str * Specifies the ERET algorithm string. */ - /* const char * eret_alg_str */ + /* const char * eret_alg_str */ GLOBUS_XIO_GRIDFTP_SET_ERET, /** GlobusVarArgEnum(attr) - * Get the ERET algorithm string. - * @ingroup gridftp_driver_cntls + * Get the ERET algorithm string. + * @ingroup globus_xio_gridftp_driver * * @param eret_alg_str_out - * The ERET algorithm string will be stored here. It is the + * The ERET algorithm string will be stored here. It is the * responsibility of the user to free the memory allocated for this string. */ - /* char ** eret_alg_str_out */ + /* char ** eret_alg_str_out */ GLOBUS_XIO_GRIDFTP_GET_ERET, /** GlobusVarArgEnum(attr) * Set the ESTO algorithm string. This string contains information needed - * to invoke a server-specific data reduction algorithm on the file being + * to invoke a server-specific data reduction algorithm on the file being * stored. - * @ingroup gridftp_driver_cntls + * @ingroup globus_xio_gridftp_driver * * @param esto_alg_str * Specifies the ESTO algorithm string. */ - /* const char * esto_alg_str */ + /* const char * esto_alg_str */ GLOBUS_XIO_GRIDFTP_SET_ESTO, /** GlobusVarArgEnum(attr) - * Get the ESTO algorithm string. - * @ingroup gridftp_driver_cntls + * Get the ESTO algorithm string. + * @ingroup globus_xio_gridftp_driver * * @param esto_alg_str_out - * The ESTO algorithm string will be stored here. It is the + * The ESTO algorithm string will be stored here. It is the * responsibility of the user to free the memory allocated for this string. */ - /* char ** esto_alg_str_out */ + /* char ** esto_alg_str_out */ GLOBUS_XIO_GRIDFTP_GET_ESTO, /** GlobusVarArgEnum(attr) - * Enable or disable partial transfer (associate a transfer with each + * Enable or disable partial transfer (associate a transfer with each * read/write) on the GridFTP handle. - * @ingroup gridftp_driver_cntls + * @ingroup globus_xio_gridftp_driver * * @param partial_xfer * GLOBUS_TRUE to enable, GLOBUS_FALSE to disable (default). */ - /* globus_bool_t partial_xfer */ + /* globus_bool_t partial_xfer */ GLOBUS_XIO_GRIDFTP_SET_PARTIAL_TRANSFER, /** GlobusVarArgEnum(attr) - * Get the partial transfer flag on the attr. - * @ingroup gridftp_driver_cntls + * Get the partial transfer flag on the attr. + * @ingroup globus_xio_gridftp_driver * * @param partial_xfer_out * The partial xfer flag will be stored here. */ - /* globus_bool_t * partial_xfer_out */ + /* globus_bool_t * partial_xfer_out */ GLOBUS_XIO_GRIDFTP_GET_PARTIAL_TRANSFER, /** GlobusVarArgEnum(attr) - * Set the number of TCP streams to be used between the client and the + * Set the number of TCP streams to be used between the client and the * server. - * @ingroup gridftp_driver_cntls + * @ingroup globus_xio_gridftp_driver * * @param num_streams * Specifies the number of streams to use. */ - /* int num_streams */ + /* int num_streams */ GLOBUS_XIO_GRIDFTP_SET_NUM_STREAMS, /** GlobusVarArgEnum(attr) * Get the number of TCP streams on the attr. - * @ingroup gridftp_driver_cntls + * @ingroup globus_xio_gridftp_driver * * @param num_streams_out * The stream count will be stored here. */ - /* int * num_streams_out */ + /* int * num_streams_out */ GLOBUS_XIO_GRIDFTP_GET_NUM_STREAMS, /** GlobusVarArgEnum(attr) * Set the TCP socket send/recv buffer size. - * @ingroup gridftp_driver_cntls + * @ingroup globus_xio_gridftp_driver * * @param buf_size - * The send/recv buffer size in bytes to use. (default is system + * The send/recv buffer size in bytes to use. (default is system * specific) */ - /* int buf_size */ + /* int buf_size */ GLOBUS_XIO_GRIDFTP_SET_TCP_BUFFER, /** GlobusVarArgEnum(attr) * Get the TCP socket send/recv buffer size on the attr. - * @ingroup gridftp_driver_cntls + * @ingroup globus_xio_gridftp_driver * * @param buf_size_out * The send/recv buffer size will be stored here. */ - /* int * buf_size_out */ + /* int * buf_size_out */ GLOBUS_XIO_GRIDFTP_GET_TCP_BUFFER, /** GlobusVarArgEnum(attr) * Set the transmission mode used for data transfer - * @ingroup gridftp_driver_cntls + * @ingroup globus_xio_gridftp_driver * * @param mode * Specifies the data transmission mode. (default is stream mode) - * + * * @see globus_l_xio_gridftp_mode_t */ - /* int mode */ + /* int mode */ GLOBUS_XIO_GRIDFTP_SET_MODE, /** GlobusVarArgEnum(attr) * Get the data transmission mode on the attr. - * @ingroup gridftp_driver_cntls + * @ingroup globus_xio_gridftp_driver * * @param mode_out * The data transmission mode will be stored here. * * @see globus_l_xio_gridftp_mode_t - */ - /* int * mode_out */ + */ + /* int * mode_out */ GLOBUS_XIO_GRIDFTP_GET_MODE, /** GlobusVarArgEnum(attr) * Set the authentication information used to authenticate with the GridFTP * server - * @ingroup gridftp_driver_cntls + * @ingroup globus_xio_gridftp_driver * * @param credential * The credential to use for authenticating with a GridFTP server. * This may be GSS_C_NO_CREDENTIAL to use the default credential. * @param user - * The user name to send to the GridFTP server. When doing a GSI - * transfer, this may be set to NULL, and the default gridmap entry + * The user name to send to the GridFTP server. When doing a GSI + * transfer, this may be set to NULL, and the default gridmap entry * for the user's GSI identity will be used * @param password - * The password to send to the GridFTP server. When doing a GSI - * transfer, this may be set to NULL. + * The password to send to the GridFTP server. When doing a GSI + * transfer, this may be set to NULL. * @param account * The account to use for the data transfer. * @param subject - * The subject name of the GridFTP server. This is only used when - * doing a GSI transfer, and then only when the security subject + * The subject name of the GridFTP server. This is only used when + * doing a GSI transfer, and then only when the security subject * name does not match the hostname of the server (ie, when the server - * is being run by a user). + * is being run by a user). */ - /* gss_cred_id_t credential, - * const char * user, - * const char * password, - * const char * account, - * const char * subject */ + /* gss_cred_id_t credential, + * const char * user, + * const char * password, + * const char * account, + * const char * subject */ GLOBUS_XIO_GRIDFTP_SET_AUTH, /** GlobusVarArgEnum(attr) * Get the authentication information on the attr. - * @ingroup gridftp_driver_cntls + * @ingroup globus_xio_gridftp_driver * * @param credential_out * The credential will be stored here. @@ -407,7 +407,7 @@ typedef enum * @param subject_out * The subject name will be stored here. */ - /* gss_cred_id_t * credential_out, + /* gss_cred_id_t * credential_out, * const char ** user_out, * const char ** password_out, * const char ** account_out, @@ -416,83 +416,83 @@ typedef enum /** GlobusVarArgEnum(attr) * Set the mode of authentication to be performed on GridFTP data channels. - * @ingroup gridftp_driver_cntls + * @ingroup globus_xio_gridftp_driver * * @param dcau_mode * Specifies the authentication mode. * * @see globus_l_xio_gridftp_dcau_mode_t */ - /* int dcau_mode */ + /* int dcau_mode */ GLOBUS_XIO_GRIDFTP_SET_DCAU, /** GlobusVarArgEnum(attr) * Get the data channel authentication mode on the attr. - * @ingroup gridftp_driver_cntls + * @ingroup globus_xio_gridftp_driver * * @param dcau_mode_out * The data channel authentication mode will be stored here. * * @see globus_l_xio_gridftp_dcau_mode_t */ - /* int * dcau_mode_out */ + /* int * dcau_mode_out */ GLOBUS_XIO_GRIDFTP_GET_DCAU, /** GlobusVarArgEnum(attr) * Set protection level on the data channel. - * @ingroup gridftp_driver_cntls + * @ingroup globus_xio_gridftp_driver * * @param protection * Specifies the protection level. * * @see globus_l_xio_gridftp_protection_t */ - /* int protection */ + /* int protection */ GLOBUS_XIO_GRIDFTP_SET_DATA_PROTECTION, /** GlobusVarArgEnum(attr) * Get the data channel protection level on the attr. - * @ingroup gridftp_driver_cntls + * @ingroup globus_xio_gridftp_driver * * @param protection_out * The data channel protection level will be stored here. * * @see globus_l_xio_gridftp_dcau_mode_t */ - /* int * protection_out */ + /* int * protection_out */ GLOBUS_XIO_GRIDFTP_GET_DATA_PROTECTION, /** GlobusVarArgEnum(attr) * Set protection level on the control channel. - * @ingroup gridftp_driver_cntls + * @ingroup globus_xio_gridftp_driver * * @param protection * Specifies the protection level. * * @see globus_l_xio_gridftp_protection_t */ - /* int protection */ + /* int protection */ GLOBUS_XIO_GRIDFTP_SET_CONTROL_PROTECTION, /** GlobusVarArgEnum(attr) * Get the control channel protection level on the attr. - * @ingroup gridftp_driver_cntls + * @ingroup globus_xio_gridftp_driver * * @param protection_out * The control channel protection level will be stored here. * * @see globus_l_xio_gridftp_protection_t */ - /* int * protection_out */ + /* int * protection_out */ GLOBUS_XIO_GRIDFTP_GET_CONTROL_PROTECTION -} globus_xio_gridftp_cmd_t; +} globus_xio_gridftp_cmd_t; -/** +/** * GRIDFTP driver specific types * @ingroup globus_xio_gridftp_driver * @hideinitializer - */ + */ typedef enum globus_l_xio_gridftp_mode_e { diff --git a/gridftp/gridftp_driver/source/test/globus_gridftp_driver_test.c b/gridftp/gridftp_driver/source/test/globus_gridftp_driver_test.c index f1da8da2f9..63f26a64d3 100644 --- a/gridftp/gridftp_driver/source/test/globus_gridftp_driver_test.c +++ b/gridftp/gridftp_driver/source/test/globus_gridftp_driver_test.c @@ -45,7 +45,7 @@ _test_res( void help() { - fprintf(stdout, + fprintf(stdout, "globus-xio-gridftp [options]\n" "-----------------\n" "specify -c to communicate with the server" @@ -98,7 +98,7 @@ main( { cs = argv[++ctr]; } - else + else { help(); exit(1); @@ -110,7 +110,7 @@ main( { filename = argv[++ctr]; } - else + else { help(); exit(1); @@ -119,7 +119,7 @@ main( else if(strcmp(argv[ctr], "-r") == 0) { read = GLOBUS_TRUE; - } + } else if(strcmp(argv[ctr], "-w") == 0) { read = GLOBUS_FALSE; @@ -172,8 +172,8 @@ main( test_res(res); res = globus_xio_stack_push_driver(stack, gridftp_driver); test_res(res); - - + + res = globus_xio_handle_create(&xio_handle, stack); test_res(res); res = globus_xio_stack_destroy(stack); @@ -188,13 +188,13 @@ main( } if (partial_xfer) { - res = globus_xio_attr_cntl(attr, gridftp_driver, + res = globus_xio_attr_cntl(attr, gridftp_driver, GLOBUS_XIO_GRIDFTP_SET_PARTIAL_TRANSFER, GLOBUS_TRUE); test_res(res); } if (append) { - res = globus_xio_attr_cntl(attr, gridftp_driver, + res = globus_xio_attr_cntl(attr, gridftp_driver, GLOBUS_XIO_GRIDFTP_SET_APPEND, GLOBUS_TRUE); test_res(res); } @@ -202,12 +202,12 @@ main( { if (read) { - res = globus_xio_attr_cntl(attr, gridftp_driver, + res = globus_xio_attr_cntl(attr, gridftp_driver, GLOBUS_XIO_GRIDFTP_SET_ERET, eret_esto_alg_str); } else { - res = globus_xio_attr_cntl(attr, gridftp_driver, + res = globus_xio_attr_cntl(attr, gridftp_driver, GLOBUS_XIO_GRIDFTP_SET_ESTO, eret_esto_alg_str); } test_res(res); @@ -231,7 +231,7 @@ main( { globus_byte_t buffer[CHUNK_SIZE + 1]; size_t nbytes; - int i, x, j = 0; + int i, j = 0; fp = fopen(filename, "r"); if (fp == NULL) { @@ -242,7 +242,7 @@ main( { for (i = 0; i< CHUNK_SIZE + 1; i++) buffer[i] = '\0'; - x = fread(buffer, CHUNK_SIZE, 1, fp); + fread(buffer, CHUNK_SIZE, 1, fp); nbytes = strlen((char *) buffer); res = globus_xio_write( xio_handle, @@ -251,17 +251,17 @@ main( nbytes, &nbytes, NULL); - test_res(res); + test_res(res); if (seek) { j += 2*nbytes; res = globus_xio_handle_cntl(xio_handle, gridftp_driver, GLOBUS_XIO_GRIDFTP_SEEK, j); - test_res(res); + test_res(res); } - } - fclose(fp); - + } + fclose(fp); + } else { @@ -293,7 +293,7 @@ main( j += 2*nbytes; res = globus_xio_handle_cntl(xio_handle, gridftp_driver, GLOBUS_XIO_GRIDFTP_SEEK, j); - test_res(res); + test_res(res); } } else @@ -309,11 +309,11 @@ main( if (user_handle) { - globus_ftp_client_handle_destroy(&ftp_handle); + globus_ftp_client_handle_destroy(&ftp_handle); } res = globus_xio_driver_unload(gridftp_driver); test_res(res); - + rc = globus_module_deactivate(GLOBUS_XIO_MODULE); globus_assert(rc == GLOBUS_SUCCESS); return 0; diff --git a/gridftp/server-lib/src/configure.ac b/gridftp/server-lib/src/configure.ac index 561f1206d7..5d3d7c5c2e 100644 --- a/gridftp/server-lib/src/configure.ac +++ b/gridftp/server-lib/src/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ([2.60]) -AC_INIT([globus_gridftp_server_control],[9.5],[https://github.com/gridcf/gct/issues]) +AC_INIT([globus_gridftp_server_control],[9.6],[https://github.com/gridcf/gct/issues]) AC_CONFIG_MACRO_DIR([m4]) AC_SUBST([MAJOR_VERSION], [${PACKAGE_VERSION%%.*}]) AC_SUBST([MINOR_VERSION], [${PACKAGE_VERSION##*.}]) diff --git a/gridftp/server-lib/src/globus_gridftp_server_control.c b/gridftp/server-lib/src/globus_gridftp_server_control.c index ccc69e03ac..8e14baa3e4 100644 --- a/gridftp/server-lib/src/globus_gridftp_server_control.c +++ b/gridftp/server-lib/src/globus_gridftp_server_control.c @@ -147,7 +147,7 @@ do \ } \ } while(0) -static char * globus_l_gfs_handle_state_name_table[] = +static char * globus_l_gfs_handle_state_name_table[] = { "GLOBUS_L_GSC_STATE_NONE", "GLOBUS_L_GSC_STATE_OPENING", @@ -259,7 +259,7 @@ static void globus_l_gsc_command_callout( void * user_arg); -static void +static void globus_l_gsc_free_command_array( char ** cmd_a); @@ -289,7 +289,7 @@ static globus_xio_driver_t globus_l_gsc_gssapi_ftp_driver; static globus_xio_driver_t globus_l_gsc_telnet_driver; static globus_hashtable_t globus_l_gsc_pwent_cache; static globus_hashtable_t globus_l_gsc_grent_cache; -static int globus_l_gsc_max_read_q = +static int globus_l_gsc_max_read_q = DEFAULT_MAX_Q_LEN; GlobusDebugDefine(GLOBUS_GRIDFTP_SERVER_CONTROL); @@ -301,7 +301,7 @@ globus_l_gsc_activate() int rc = 0; char * e; globus_result_t res; - + rc = globus_module_activate(GLOBUS_XIO_MODULE); if(rc != 0) { @@ -340,7 +340,7 @@ globus_l_gsc_activate() { return GLOBUS_FAILURE; } - + if((e = getenv("GFS_MAX_READ_QUEUE")) != NULL) { globus_l_gsc_max_read_q = atoi(e); @@ -349,14 +349,14 @@ globus_l_gsc_activate() globus_l_gsc_max_read_q = DEFAULT_MAX_Q_LEN; } } - + GlobusLTestSuiteMsg(); GlobusDebugInit(GLOBUS_GRIDFTP_SERVER_CONTROL, ERROR WARNING TRACE INTERNAL_TRACE COMMANDS VERBOSE STATE); /* add all the default command handlers */ globus_gridftp_server_control_attr_init(&globus_l_gsc_default_attr); - + globus_hashtable_init( &globus_l_gsc_pwent_cache, 128, @@ -454,7 +454,7 @@ globus_l_gsc_timeout_cb( } else { - globus_l_gsc_final_reply(server_handle, + globus_l_gsc_final_reply(server_handle, _FSMSL("421 Idle Timeout: closing control connection.\r\n")); rc = GLOBUS_TRUE; } @@ -555,12 +555,12 @@ globus_i_gsc_op_destroy( if(op->stat_info[ctr].name != NULL) { globus_free(op->stat_info[ctr].name); - } + } if(op->stat_info[ctr].symlink_target != NULL) { globus_free(op->stat_info[ctr].symlink_target); } - } + } globus_free(op->stat_info); } if(op->cs != NULL) @@ -649,26 +649,26 @@ globus_l_gsc_trans_table_copy( /* * Read Callback * ------------- - * Every time a command comes in this function is called. + * Every time a command comes in this function is called. * * Reads are continually posted and queued. The reason for this is * the ABOR case. Since an ABOR is read as oobinline we must have * a read posted while a command is being process. This leads to - * the possibility of commands other than ABOR being read while a + * the possibility of commands other than ABOR being read while a * preceding command is being processed, the solution to this is to * constantly read and queue all commands. * * states * on error simply call terminate * - * OPEN : + * OPEN : * read and queue the command. If the command is ABOR reply * imediatly and post another read, else start processing * the next command in the queue * - * PROCESSING : + * PROCESSING : * simply queue the command and post another read. if the command - * is ABOR, change to ABORTING STATE and call the users abort + * is ABOR, change to ABORTING STATE and call the users abort * callback. * * STOPPING/ABORTING_STOPPING: @@ -745,8 +745,8 @@ globus_l_gsc_read_cb( case GLOBUS_L_GSC_STATE_PROCESSING: /* parse out the command name */ command_name = (char *) globus_malloc(len + 1); - for(ctr = 0, tmp_ptr = buffer; - *tmp_ptr != ' ' && *tmp_ptr != '\r' + for(ctr = 0, tmp_ptr = buffer; + *tmp_ptr != ' ' && *tmp_ptr != '\r' && *tmp_ptr != '\n' && ctr < len; tmp_ptr++, ctr++) { @@ -773,10 +773,10 @@ globus_l_gsc_read_cb( { globus_l_gsc_process_next_cmd(server_handle); } - /* allow outstanding commands, just queue them up, but + /* allow outstanding commands, just queue them up, but only to a certain number */ - if(globus_fifo_size(&server_handle->read_q) < - server_handle->max_q_len || + if(globus_fifo_size(&server_handle->read_q) < + server_handle->max_q_len || server_handle->max_q_len <= 0) { res = globus_xio_register_read( @@ -845,7 +845,7 @@ globus_l_gsc_read_cb( GLOBUS_GRIDFTP_SERVER_CONTROL_EVENT_ABORT && /* this last codition make deal with a race of an abort and a finished transfer */ - server_handle->data_object->state == + server_handle->data_object->state == GLOBUS_L_GSC_DATA_OBJ_INUSE) { assert(server_handle->data_object->state == GLOBUS_L_GSC_DATA_OBJ_INUSE); @@ -853,7 +853,7 @@ assert(server_handle->data_object->state == GLOBUS_L_GSC_DATA_OBJ_INUSE); server_handle->outstanding_op, GLOBUS_GRIDFTP_SERVER_CONTROL_EVENT_ABORT, server_handle->outstanding_op->event.user_arg); - server_handle->outstanding_op->aborted = + server_handle->outstanding_op->aborted = GLOBUS_FALSE; } } @@ -902,11 +902,11 @@ assert(server_handle->data_object->state == GLOBUS_L_GSC_DATA_OBJ_INUSE); * * This is called in a few places. It is called when a user decideds * to terminate the conection via _stop(), when the command modules - * panic (typically due to being out of memory) or when an error + * panic (typically due to being out of memory) or when an error * occurs on the client connection (typically due to it closing). * * states: - * + * * OPENING: * Noting has really been done yet, there is possibly an outstanding * open or an outstaning write. cancel any open and write callbacks. @@ -914,13 +914,13 @@ assert(server_handle->data_object->state == GLOBUS_L_GSC_DATA_OBJ_INUSE); * * OPEN: * There are no outstanidng commands so move to the stoping state, - * cancel the command read that is posted. When the canceled read - * returns the termination process will continue. + * cancel the command read that is posted. When the canceled read + * returns the termination process will continue. * * PROCESSING: * A command is outstanding so move to the ABORTING_STOPPING state, * call the users abort callback. When the finished op command returns - * the termination process will continue. + * the termination process will continue. * Flush any commands that have been read with an error. * * ABORTING: @@ -966,18 +966,18 @@ globus_l_gsc_terminate( globus_i_guc_data_object_destroy(server_handle, data_obj); server_handle->data_object = NULL; break; - + case GLOBUS_L_GSC_DATA_OBJ_DESTROY_WAIT: case GLOBUS_L_GSC_DATA_OBJ_DESTROYING: /* do nuttin */ break; - + case GLOBUS_L_GSC_DATA_OBJ_INUSE: /* start an abort event */ dh_to_abort = GLOBUS_TRUE; data_obj->state = GLOBUS_L_GSC_DATA_OBJ_DESTROY_WAIT; break; - + default: globus_assert(0 && "possible memory corruption"); break; @@ -1076,7 +1076,7 @@ i /* is ok to call this twice stopped twice: ex: client quits, read callback returns with error, then user - quits before getting the done callback. + quits before getting the done callback. In these cases there is nothing to be done. */ case GLOBUS_L_GSC_STATE_ABORTING_STOPPING: case GLOBUS_L_GSC_STATE_STOPPING: @@ -1146,18 +1146,18 @@ globus_gsc_959_terminate( * this is ulmiately called when a command module finishes a command * * states: - * + * * PROCESSING: * if the command is finished (reply_msg != NULL), then send the final * reply else call the next in the chain. The state will be changed * when the final reply returns. - * + * * ABORTING: - * flush the commands read q and send out the final abort message, if + * flush the commands read q and send out the final abort message, if * final reply is successful another read will be posted. * * ABORTING_STOPPING: - * move to the STOPPING state. If reference is zero kickout done + * move to the STOPPING state. If reference is zero kickout done * callback * * STOPPING: @@ -1295,7 +1295,7 @@ globus_l_gsc_finished_op( * is called once the 220 is written and if succesful moves things * to the OPEN state. */ -static void +static void globus_l_gsc_220_write_cb( globus_xio_handle_t xio_handle, globus_result_t result, @@ -1417,7 +1417,7 @@ globus_l_gsc_open_cb( /* * callback for replies */ -static void +static void globus_l_gsc_final_reply_cb( globus_xio_handle_t xio_handle, globus_result_t result, @@ -1474,7 +1474,7 @@ globus_l_gsc_final_reply_cb( (void *) server_handle); if(res != GLOBUS_SUCCESS) { - goto err; + goto err; } GlobusLServerRefInc(server_handle); GlobusGSCHandleStateChange( @@ -1539,7 +1539,7 @@ globus_l_gsc_final_reply_cb( return; } -static void +static void globus_l_gsc_intermediate_reply_cb( globus_xio_handle_t xio_handle, globus_result_t result, @@ -1690,11 +1690,11 @@ globus_l_gsc_user_close_kickout( } globus_mutex_unlock(&server_handle->mutex); - /* call destroy on all the data connections, if not in the list + /* call destroy on all the data connections, if not in the list then a call is already pending on it */ while(!globus_list_empty(data_conn_list)) { - data_object = (globus_i_gsc_data_t *) + data_object = (globus_i_gsc_data_t *) globus_list_remove(&data_conn_list, data_conn_list); if(server_handle->funcs.data_destroy_cb != NULL) { @@ -1720,7 +1720,7 @@ globus_l_gsc_user_close_kickout( /* * close callback - * + * * handle is not closed until user requests a close. */ static void @@ -1762,9 +1762,9 @@ globus_i_guc_data_object_destroy( if(data_object) { globus_hashtable_remove( - &server_handle->data_object_table, + &server_handle->data_object_table, data_object->user_handle); - + if(server_handle->funcs.data_destroy_cb != NULL) { GlobusLServerRefInc(server_handle); @@ -1953,7 +1953,7 @@ globus_l_gsc_parse_command( return -1; } -static void +static void globus_l_gsc_free_command_array( char ** cmd_a) { @@ -2014,14 +2014,14 @@ globus_i_gsc_concat_path( globus_mutex_lock(&i_server->mutex); { - + if(in_path[0] == '/') { tmp_path = globus_libc_strdup(in_path); } else if(in_path[0] == '~') { - if((tmp_ptr = strchr(in_path, '/')) != NULL) + if((tmp_ptr = (char *) strchr(in_path, '/')) != NULL) { tmp_path = globus_common_create_string("%s%s", i_server->default_cwd, @@ -2043,7 +2043,7 @@ globus_i_gsc_concat_path( { goto error; } - + /* remove all double slashes */ tmp_ptr = strstr(tmp_path, "//"); while(tmp_ptr != NULL) @@ -2140,19 +2140,19 @@ globus_i_gridftp_server_control_cs_verify( else if(net_prt == GLOBUS_GRIDFTP_SERVER_CONTROL_PROTOCOL_IPV6) { globus_xio_contact_t contact_info; - + if(globus_xio_contact_parse(&contact_info, cs) != GLOBUS_SUCCESS) { return GLOBUS_FALSE; } - - if(!(contact_info.host && contact_info.port) || + + if(!(contact_info.host && contact_info.port) || (unsigned) atoi(contact_info.port) > 65535) { globus_xio_contact_destroy(&contact_info); return GLOBUS_FALSE; } - + /* verify that the string contains nothing but * hex digits, ':'. and '.' */ @@ -2166,9 +2166,9 @@ globus_i_gridftp_server_control_cs_verify( } cs++; } - + globus_xio_contact_destroy(&contact_info); - + return GLOBUS_TRUE; } @@ -2195,11 +2195,11 @@ globus_l_gsc_cmd_site( { char * tmp_ptr; GlobusGridFTPServerName(globus_l_gsc_cmd_site); - + GlobusGridFTPServerDebugInternalEnter(); /* to upper in the actual initial buffer */ - for(tmp_ptr = strstr(full_command, cmd_a[1]); tmp_ptr && *tmp_ptr && *tmp_ptr != ' '; tmp_ptr++) + for(tmp_ptr = (char *) strstr(full_command, cmd_a[1]); tmp_ptr && *tmp_ptr && *tmp_ptr != ' '; tmp_ptr++) { *tmp_ptr = toupper(*tmp_ptr); } @@ -2208,7 +2208,7 @@ globus_l_gsc_cmd_site( *tmp_ptr = toupper(*tmp_ptr); } *tmp_ptr = '\0'; - + globus_assert(op->cmd_list == NULL); # if defined(GLOBUS_L_SITE_TEST_SUITE_MSG) @@ -2245,7 +2245,6 @@ globus_l_gsc_command_callout( globus_bool_t auth = GLOBUS_FALSE; char ** cmd_array; char * msg; - globus_result_t res; globus_l_gsc_cmd_ent_t * cmd_ent; globus_bool_t done = GLOBUS_FALSE; globus_i_gsc_op_t * op; @@ -2281,11 +2280,11 @@ globus_l_gsc_command_callout( if(op->cmd_list == NULL) { /* log unknown */ - globus_i_gsc_log(server_handle, op->command, + globus_i_gsc_log(server_handle, op->command, GLOBUS_GRIDFTP_SERVER_CONTROL_LOG_ERROR); globus_i_gsc_op_destroy(op); - res = globus_l_gsc_final_reply(server_handle, msg); + globus_l_gsc_final_reply(server_handle, msg); done = GLOBUS_TRUE; } else @@ -2297,7 +2296,7 @@ globus_l_gsc_command_callout( { msg = _FSMSL("530 Please login with USER and PASS.\r\n"); } - else if(auth && + else if(auth && !(cmd_ent->desc & GLOBUS_GSC_COMMAND_POST_AUTH)) { msg = _FSMSL("503 You are already logged in.\r\n"); @@ -2324,10 +2323,10 @@ globus_l_gsc_command_callout( char ** restrict_args = NULL; int i; char * restrict_cmd; - + restrict_cmd = globus_list_first(list); list = globus_list_rest(list); - + globus_l_gsc_parse_command( restrict_cmd, &restrict_args, cmd_ent->max_argc); @@ -2336,7 +2335,7 @@ globus_l_gsc_command_callout( { i++; } - + do { if(!cmd_array[i] || !restrict_args || !restrict_args[i]) @@ -2356,13 +2355,13 @@ globus_l_gsc_command_callout( } i++; } while(fail_restrict && !done); - + if(restrict_args) { globus_l_gsc_free_command_array(restrict_args); } - } - + } + if(argc < cmd_ent->min_argc) { globus_gsc_959_finished_command(op, @@ -2462,7 +2461,7 @@ globus_l_gsc_final_reply( goto error_alloc; } len = strlen(tmp_ptr); - + globus_i_gsc_log( server_handle, message, GLOBUS_GRIDFTP_SERVER_CONTROL_LOG_REPLY); res = globus_xio_register_write( @@ -2621,7 +2620,7 @@ globus_gridftp_server_control_init( server_handle->max_q_len = globus_l_gsc_max_read_q; server_handle->state = GLOBUS_L_GSC_STATE_NONE; server_handle->reply_outstanding = GLOBUS_FALSE; - server_handle->pre_auth_banner = + server_handle->pre_auth_banner = globus_libc_strdup(GLOBUS_L_GSC_DEFAULT_220); globus_fifo_init(&server_handle->read_q); globus_fifo_init(&server_handle->reply_q); @@ -2631,7 +2630,7 @@ globus_gridftp_server_control_init( 128, globus_hashtable_string_hash, globus_hashtable_string_keyeq); - + globus_hashtable_init( &server_handle->site_cmd_table, 128, @@ -2643,7 +2642,7 @@ globus_gridftp_server_control_init( 256, globus_hashtable_voidp_hash, globus_hashtable_voidp_keyeq); - + globus_i_gsc_add_commands(server_handle); *server = server_handle; @@ -2719,14 +2718,14 @@ globus_gridftp_server_control_destroy( } if(server_handle->del_cred != GSS_C_NO_CREDENTIAL) { - OM_uint32 min, maj; - maj = gss_release_cred(&min, &server_handle->del_cred); + OM_uint32 min; + gss_release_cred(&min, &server_handle->del_cred); } while(!globus_list_empty(server_handle->all_cmd_list)) { cmd_ent = (globus_l_gsc_cmd_ent_t *) globus_list_remove( &server_handle->all_cmd_list, server_handle->all_cmd_list); - + if(cmd_ent->cmd_name != NULL) { globus_free(cmd_ent->cmd_name); @@ -2819,7 +2818,7 @@ globus_gridftp_server_control_start( goto err; #endif } - + if(S_ISFIFO(statbuf.st_mode)) { transport = globus_l_gsc_pipe_driver; @@ -2902,7 +2901,7 @@ globus_gridftp_server_control_start( } res = globus_xio_attr_cntl( xio_attr, globus_l_gsc_gsi_driver, - GLOBUS_XIO_GSI_SET_PROTECTION_LEVEL, + GLOBUS_XIO_GSI_SET_PROTECTION_LEVEL, GLOBUS_XIO_GSI_PROTECTION_LEVEL_PRIVACY); if(res != GLOBUS_SUCCESS) { @@ -2958,7 +2957,7 @@ globus_gridftp_server_control_start( else if(transport == globus_l_gsc_pipe_driver) { int outfd; - + res = globus_xio_attr_cntl(xio_attr, globus_l_gsc_pipe_driver, GLOBUS_XIO_PIPE_SET_IN_HANDLE, system_handle); if(res != GLOBUS_SUCCESS) @@ -3010,10 +3009,10 @@ globus_gridftp_server_control_start( server_handle->funcs.done_cb = done_cb; globus_hashtable_copy( - &server_handle->funcs.send_cb_table, + &server_handle->funcs.send_cb_table, &i_attr->funcs.send_cb_table, globus_l_gsc_trans_table_copy); globus_hashtable_copy( - &server_handle->funcs.recv_cb_table, + &server_handle->funcs.recv_cb_table, &i_attr->funcs.recv_cb_table, globus_l_gsc_trans_table_copy); if(server_handle->modes != NULL) @@ -3026,7 +3025,7 @@ globus_gridftp_server_control_start( } /* default options */ strcpy(server_handle->opts.mlsx_fact_str, "TMSPUOIGDQLAN"); - server_handle->opts.send_buf = 0; + server_handle->opts.send_buf = 0; server_handle->opts.perf_frequency = 5; server_handle->opts.retr_perf_frequency = 0; server_handle->opts.restart_frequency = 5; @@ -3068,16 +3067,16 @@ globus_gridftp_server_control_start( } server_handle->cwd = globus_libc_strdup(i_attr->base_dir); server_handle->default_cwd = NULL; - + if(i_attr->pre_auth_banner != NULL) { globus_free(server_handle->pre_auth_banner); - server_handle->pre_auth_banner = + server_handle->pre_auth_banner = globus_libc_strdup(i_attr->pre_auth_banner); } if(i_attr->post_auth_banner != NULL) { - server_handle->post_auth_banner = + server_handle->post_auth_banner = globus_libc_strdup(i_attr->post_auth_banner); } @@ -3098,8 +3097,8 @@ globus_gridftp_server_control_start( GlobusGSCHandleStateChange( server_handle, GLOBUS_L_GSC_STATE_OPENING); res = globus_xio_register_open( - server_handle->xio_handle, - NULL, + server_handle->xio_handle, + NULL, xio_attr, globus_l_gsc_open_cb, server_handle); @@ -3189,7 +3188,7 @@ globus_i_gsc_command_panic( GlobusGSCHandleStateChange( op->server_handle, GLOBUS_L_GSC_STATE_STOPPING); - /* not much can be done about an error here, we are terminating + /* not much can be done about an error here, we are terminating anyway */ res = globus_l_gsc_final_reply( op->server_handle, @@ -3434,11 +3433,11 @@ globus_gsc_959_command_remove( { *tmp_ptr = toupper(*tmp_ptr); } - + if(strncmp("SITE ", cmd_name, 5) == 0 && strlen(cmd_name) > 5) { char * save_ptr; - + tmp_ptr = (char *)&cmd_name[5]; while(*tmp_ptr == ' ') tmp_ptr++; save_ptr = tmp_ptr; @@ -3447,7 +3446,7 @@ globus_gsc_959_command_remove( *tmp_ptr = toupper(*tmp_ptr); } tmp_ptr = save_ptr; - + restrict_args = strchr(tmp_ptr, ' '); if(restrict_args) { @@ -3498,11 +3497,11 @@ globus_gsc_959_command_remove( } if(restrict_args && *restrict_args) - { + { while(!globus_list_empty(list)) { cmd_ent = (globus_l_gsc_cmd_ent_t *) globus_list_first(list); - + globus_list_insert( &cmd_ent->restrict_list, globus_common_create_string("%s %s\r\n",spacer, restrict_args)); @@ -3516,7 +3515,7 @@ globus_gsc_959_command_remove( { cmd_ent = (globus_l_gsc_cmd_ent_t *) globus_list_remove(&list, list); - + if(cmd_ent->help) { globus_free(cmd_ent->help); @@ -3533,7 +3532,7 @@ globus_gsc_959_command_remove( globus_free(cmd_name); } globus_mutex_unlock(&server_handle->mutex); - + return GLOBUS_SUCCESS; error_notexist: @@ -3610,12 +3609,12 @@ globus_i_gsc_get_help( _FSMSL("214-Help for %s:\r\n"), command_name); while(!globus_list_empty(site_list)) { - list = (globus_list_t *) + list = (globus_list_t *) globus_list_remove(&site_list, site_list); while(!globus_list_empty(list)) { - cmd_ent = (globus_l_gsc_cmd_ent_t *) + cmd_ent = (globus_l_gsc_cmd_ent_t *) globus_list_first(list); if(cmd_ent->help != NULL) { @@ -3667,10 +3666,10 @@ globus_i_gsc_get_help( } /* preline only affects multiline strings. - a null preline will prepend a "code-" to the front of each line by default, + a null preline will prepend a "code-" to the front of each line by default, otherwise the preline is prepended. used to follow spec for mlst where the lines MUST be prepended with exactly - one space, but general multiline responses are allowed to have any + one space, but general multiline responses are allowed to have any (or none at all, i.e. "") padding text */ char * globus_gsc_string_to_959( @@ -3727,8 +3726,8 @@ globus_gsc_string_to_959( tmp_ptr = msg; msg = globus_common_create_string( - "%s%s%s\r\n", - tmp_ptr, + "%s%s%s\r\n", + tmp_ptr, (ctr > 0) ? prepad : "", start_ptr); globus_free(tmp_ptr); @@ -3792,10 +3791,10 @@ globus_l_gsc_mlsx_urlencode( if(NEEDS_ENCODING(*in_ptr)) { enc_count++; - } + } in_ptr++; } - + if(enc_count) { enc_count = 0; @@ -3808,7 +3807,7 @@ globus_l_gsc_mlsx_urlencode( *out_ptr++ = hex_chars[(*in_ptr >> 4) & 0xF]; *out_ptr++ = hex_chars[*in_ptr & 0xF]; enc_count++; - } + } else { *out_ptr++ = *in_ptr; @@ -3822,7 +3821,7 @@ globus_l_gsc_mlsx_urlencode( { *out_string = (char *) in_string; } - + return enc_count; GlobusGridFTPServerDebugInternalExit(); } @@ -3836,15 +3835,15 @@ globus_libc_cached_getpwuid( struct passwd * result_pw = NULL; globus_l_libc_cached_pwent_t * pwent; int rc; - + /* XXX TODO make proper function in globus_libc */ pwent = (globus_l_libc_cached_pwent_t *) globus_hashtable_lookup( &globus_l_gsc_pwent_cache, (void *) (intptr_t) uid); if(pwent == NULL) { - pwent = (globus_l_libc_cached_pwent_t *) - globus_calloc(1, sizeof(globus_l_libc_cached_pwent_t)); rc = globus_libc_getpwuid_r( + pwent = (globus_l_libc_cached_pwent_t *) + globus_calloc(1, sizeof(globus_l_libc_cached_pwent_t)); rc = globus_libc_getpwuid_r( uid, &pwent->pw, pwent->buffer, GSU_MAX_PW_LENGTH, &result_pw); if(rc != 0 || result_pw == NULL) { @@ -3861,12 +3860,12 @@ globus_libc_cached_getpwuid( } return &pwent->pw; - + error_pwent: globus_free(pwent); #endif return NULL; -} +} static struct group * @@ -3896,9 +3895,9 @@ globus_libc_cached_getgrgid( grent->gr_gid = gr->gr_gid; /* we don't use other members */ globus_libc_unlock(); - + grent->gr_name = globus_libc_strdup(name); - + globus_hashtable_insert( &globus_l_gsc_grent_cache, (void *) (intptr_t) grent->gr_gid, @@ -3906,12 +3905,12 @@ globus_libc_cached_getgrgid( } return grent; - + error_group: globus_libc_unlock(); globus_free(grent); return NULL; -} +} char * globus_i_gsc_nlst_line( @@ -3939,7 +3938,7 @@ globus_i_gsc_nlst_line( if(buf_left < (tmp_i + 3)) { int ndx; - + ndx = tmp_ptr - buf; buf_left += buf_len + tmp_i + 3; buf_len += buf_len + tmp_i + 3; @@ -3987,8 +3986,8 @@ globus_i_gsc_mlsx_line_single( GlobusGridFTPServerDebugInternalEnter(); - buf_len = MAXPATHLEN * 4 + 256; /* rough guess... could be a maxpathlen - for the path, and 3*maxpathlen for + buf_len = MAXPATHLEN * 4 + 256; /* rough guess... could be a maxpathlen + for the path, and 3*maxpathlen for the urlencoded link target */ out_buf = globus_malloc(buf_len); @@ -4004,7 +4003,7 @@ globus_i_gsc_mlsx_line_single( case GLOBUS_GSC_MLSX_FACT_TYPE: if(S_ISREG(stat_info->mode)) { - sprintf(tmp_ptr, "Type=file;"); + sprintf(tmp_ptr, "Type=file;"); } else if(S_ISDIR(stat_info->mode)) { @@ -4028,25 +4027,25 @@ globus_i_gsc_mlsx_line_single( sprintf(tmp_ptr, "Type=dir;"); } } - else if(S_ISLNK(stat_info->mode)) + else if(S_ISLNK(stat_info->mode)) { sprintf(tmp_ptr, "Type=slink;"); } else if(S_ISCHR(stat_info->mode)) { - sprintf(tmp_ptr, "Type=OS.unix=chr;"); + sprintf(tmp_ptr, "Type=OS.unix=chr;"); } else if(S_ISBLK(stat_info->mode)) { - sprintf(tmp_ptr, "Type=OS.unix=blk;"); + sprintf(tmp_ptr, "Type=OS.unix=blk;"); } else if(S_ISFIFO(stat_info->mode)) { - sprintf(tmp_ptr, "Type=OS.unix=pipe;"); + sprintf(tmp_ptr, "Type=OS.unix=pipe;"); } else { - sprintf(tmp_ptr, "Type=OS.unix=other;"); + sprintf(tmp_ptr, "Type=OS.unix=other;"); } break; @@ -4062,7 +4061,7 @@ globus_i_gsc_mlsx_line_single( break; case GLOBUS_GSC_MLSX_FACT_SIZE: - sprintf(tmp_ptr, + sprintf(tmp_ptr, "Size=%"GLOBUS_OFF_T_FORMAT";", stat_info->size); break; @@ -4118,7 +4117,7 @@ globus_i_gsc_mlsx_line_single( *(tmp_ptr++) = 'w'; } - if(is_writable && is_executable && + if(is_writable && is_executable && S_ISDIR(stat_info->mode)) { *(tmp_ptr++) = 'c'; @@ -4130,7 +4129,7 @@ globus_i_gsc_mlsx_line_single( { *(tmp_ptr++) = 'e'; } - if(is_readable && is_executable && + if(is_readable && is_executable && S_ISDIR(stat_info->mode)) { *(tmp_ptr++) = 'l'; @@ -4145,26 +4144,26 @@ globus_i_gsc_mlsx_line_single( break; case GLOBUS_GSC_MLSX_FACT_UNIXMODE: - sprintf(tmp_ptr, "UNIX.mode=%04o;", + sprintf(tmp_ptr, "UNIX.mode=%04o;", (unsigned) (stat_info->mode & 07777)); break; case GLOBUS_GSX_MLSX_FACT_UNIXUID: sprintf(tmp_ptr, "UNIX.uid=%d;", stat_info->uid); break; - + case GLOBUS_GSX_MLSX_FACT_UNIXGID: sprintf(tmp_ptr, "UNIX.gid=%d;", stat_info->gid); break; - + case GLOBUS_GSC_MLSX_FACT_UNIXOWNER: pw = globus_libc_cached_getpwuid(stat_info->uid); enc_str = NULL; if(pw) - { + { cnt = globus_l_gsc_mlsx_urlencode(pw->pw_name, &enc_str); } - + if(enc_str) { sprintf(tmp_ptr, "UNIX.owner=%s;", enc_str); @@ -4179,10 +4178,10 @@ globus_i_gsc_mlsx_line_single( gr = globus_libc_cached_getgrgid(stat_info->gid); enc_str = NULL; if(gr) - { + { cnt = globus_l_gsc_mlsx_urlencode(gr->gr_name, &enc_str); } - + if(enc_str) { sprintf(tmp_ptr, "UNIX.group=%s;", enc_str); @@ -4194,13 +4193,13 @@ globus_i_gsc_mlsx_line_single( break; case GLOBUS_GSC_MLSX_FACT_UNIQUE: - sprintf(tmp_ptr, "Unique=%lx-%lx;", + sprintf(tmp_ptr, "Unique=%lx-%lx;", (unsigned long) stat_info->dev, (unsigned long) stat_info->ino); break; case GLOBUS_GSC_MLSX_FACT_UNIXSLINK: - if(stat_info->symlink_target != NULL && + if(stat_info->symlink_target != NULL && *stat_info->symlink_target != '\0') { encoded_symlink_target = NULL; @@ -4208,7 +4207,7 @@ globus_i_gsc_mlsx_line_single( stat_info->symlink_target, &encoded_symlink_target); if(encoded_symlink_target != NULL) { - sprintf(tmp_ptr, + sprintf(tmp_ptr, "UNIX.slink=%s;", encoded_symlink_target); if(cnt) { @@ -4222,7 +4221,7 @@ globus_i_gsc_mlsx_line_single( if(is_cdir && absolute_path) { const char * slash = "/"; - + enc_str = NULL; if(absolute_path[strlen(absolute_path) - 1] == '/') { @@ -4250,8 +4249,8 @@ globus_i_gsc_mlsx_line_single( } tmp_ptr += strlen(tmp_ptr); } - - switch (stat_info->error) + + switch (stat_info->error) { case GLOBUS_GRIDFTP_SERVER_CONTROL_STAT_SUCCESS: break; @@ -4264,19 +4263,19 @@ globus_i_gsc_mlsx_line_single( tmp_ptr += strlen(tmp_ptr); break; } - - if(base_path) + + if(base_path) { if(stat_info->name[0] == '\0') { /** Don't print trailing slash if no name */ sprintf(tmp_ptr, " %s", base_path); - } - else + } + else { sprintf(tmp_ptr, " %s/%s", base_path, stat_info->name); } - } + } else { sprintf(tmp_ptr, " %s", stat_info->name); @@ -4293,7 +4292,7 @@ globus_i_gsc_mlsx_line( const char * mlsx_fact_str, uid_t uid, const char * base_path, - const char * absolute_path, + const char * absolute_path, globus_bool_t indent) { char * line; @@ -4327,7 +4326,7 @@ globus_i_gsc_mlsx_line( if(buf_left < (tmp_i + 4)) { int ndx; - + ndx = tmp_ptr - buf; buf_left += buf_len + tmp_i + 4; buf_len += buf_len + tmp_i + 4; @@ -4353,7 +4352,7 @@ globus_i_gsc_mlsx_line( GlobusGridFTPServerDebugInternalExit(); return buf; } - + /* * turn a stat struct into a string */ @@ -4398,7 +4397,7 @@ globus_i_gsc_list_single_line( { snprintf(grpname, sizeof(grpname), "%s", gr->gr_name); } - + if(S_ISDIR(stat_info->mode)) { perms[0] = 'd'; @@ -4419,7 +4418,7 @@ globus_i_gsc_list_single_line( { perms[0] = 'b'; } - + if(S_IRUSR & stat_info->mode) { perms[1] = 'r'; @@ -4505,11 +4504,11 @@ globus_i_gsc_list_line( { no_match = fnmatch(glob_match_str, stat_info[ctr].name, 0); } -#endif +#endif if(no_match) { continue; - } + } line = globus_i_gsc_list_single_line(&stat_info[ctr]); if(line != NULL) { @@ -4517,14 +4516,14 @@ globus_i_gsc_list_line( if(buf_left < (tmp_i + 3)) { int ndx; - + ndx = tmp_ptr - buf; buf_left += buf_len + tmp_i + 3; buf_len += buf_len + tmp_i + 3; buf = globus_libc_realloc(buf, buf_len); tmp_ptr = buf + ndx; } - + memcpy(tmp_ptr, line, tmp_i); tmp_ptr[tmp_i++] = '\r'; tmp_ptr[tmp_i++] = '\n'; @@ -4747,7 +4746,7 @@ globus_i_gsc_port( switch(op->server_handle->data_object->state) { case GLOBUS_L_GSC_DATA_OBJ_READY: - op->server_handle->data_object->state = + op->server_handle->data_object->state = GLOBUS_L_GSC_DATA_OBJ_DESTROYING; globus_i_guc_data_object_destroy( op->server_handle, op->server_handle->data_object); @@ -4826,13 +4825,13 @@ globus_i_gsc_passive( switch(op->server_handle->data_object->state) { case GLOBUS_L_GSC_DATA_OBJ_READY: - op->server_handle->data_object->state = + op->server_handle->data_object->state = GLOBUS_L_GSC_DATA_OBJ_DESTROYING; globus_i_guc_data_object_destroy( op->server_handle, op->server_handle->data_object); op->server_handle->data_object = NULL; break; - + case GLOBUS_L_GSC_DATA_OBJ_DESTROYING: /* do nuttin */ break; @@ -4897,7 +4896,7 @@ globus_i_gsc_list( globus_mutex_lock(&op->server_handle->mutex); { if(op->server_handle->data_object == NULL || - !(op->server_handle->data_object->dir & + !(op->server_handle->data_object->dir & GLOBUS_GRIDFTP_SERVER_CONTROL_DATA_DIR_SEND)) { globus_mutex_unlock(&op->server_handle->mutex); @@ -4908,7 +4907,7 @@ globus_i_gsc_list( { /* the state we want */ case GLOBUS_L_GSC_DATA_OBJ_READY: - op->server_handle->data_object->state = + op->server_handle->data_object->state = GLOBUS_L_GSC_DATA_OBJ_INUSE; break; @@ -4949,7 +4948,7 @@ globus_i_gsc_list( case GLOBUS_L_GSC_OP_TYPE_MLSR: depth = -1; - + case GLOBUS_L_GSC_OP_TYPE_MLSD: default: fact_str = op->server_handle->opts.mlsx_fact_str; @@ -4963,7 +4962,7 @@ globus_i_gsc_list( if(user_cb != NULL) { user_cb( - op, + op, op->server_handle->data_object->user_handle, op->path, fact_str, @@ -5012,7 +5011,7 @@ globus_i_gsc_send( globus_mutex_lock(&op->server_handle->mutex); { if(op->server_handle->data_object == NULL || - !(op->server_handle->data_object->dir & + !(op->server_handle->data_object->dir & GLOBUS_GRIDFTP_SERVER_CONTROL_DATA_DIR_SEND)) { globus_mutex_unlock(&op->server_handle->mutex); @@ -5022,7 +5021,7 @@ globus_i_gsc_send( { /* the state we want */ case GLOBUS_L_GSC_DATA_OBJ_READY: - op->server_handle->data_object->state = + op->server_handle->data_object->state = GLOBUS_L_GSC_DATA_OBJ_INUSE; break; @@ -5122,7 +5121,7 @@ globus_i_gsc_recv( globus_mutex_lock(&op->server_handle->mutex); { if(op->server_handle->data_object == NULL || - !(op->server_handle->data_object->dir & + !(op->server_handle->data_object->dir & GLOBUS_GRIDFTP_SERVER_CONTROL_DATA_DIR_RECV)) { globus_mutex_unlock(&op->server_handle->mutex); @@ -5132,7 +5131,7 @@ globus_i_gsc_recv( { /* the state we want */ case GLOBUS_L_GSC_DATA_OBJ_READY: - op->server_handle->data_object->state = + op->server_handle->data_object->state = GLOBUS_L_GSC_DATA_OBJ_INUSE; break; @@ -5191,7 +5190,7 @@ globus_i_gsc_recv( if(user_cb != NULL) { user_cb( - op, + op, op->server_handle->data_object->user_handle, op->path, op->mod_name, @@ -5321,9 +5320,9 @@ globus_gridftp_server_control_finished_auth( { globus_free(op->server_handle->default_cwd); } - op->server_handle->default_cwd = + op->server_handle->default_cwd = globus_libc_strdup(op->server_handle->cwd); - + op->response_type = response_code; if(op->response_type == GLOBUS_GRIDFTP_SERVER_CONTROL_RESPONSE_SUCCESS) { @@ -5371,14 +5370,14 @@ globus_gridftp_server_control_finished_resource( { globus_mutex_lock(&op->stat_lock); } - + op->response_type = response_code; op->response_msg = NULL; if(msg != NULL) { op->response_msg = strdup(msg); } - + if(res == GLOBUS_SUCCESS && op->stat_cb != NULL) { if(op->stat_info != NULL) @@ -5388,12 +5387,12 @@ globus_gridftp_server_control_finished_resource( if(op->stat_info[ctr].name != NULL) { globus_free(op->stat_info[ctr].name); - } + } if(op->stat_info[ctr].symlink_target != NULL) { globus_free(op->stat_info[ctr].symlink_target); } - } + } globus_free(op->stat_info); } op->stat_info = (globus_gridftp_server_control_stat_t *) @@ -5406,7 +5405,7 @@ globus_gridftp_server_control_finished_resource( &op->stat_info[ctr], &stat_info_array[ctr]); } op->uid = uid; - + /* added gid stuff here, doesn't get pushed all the way through to the cwd or mlsd funcs yet, but that is all internal api so easy to change. */ @@ -5417,11 +5416,11 @@ globus_gridftp_server_control_finished_resource( op->gid_count = gid_count; if(gid_count != 0 && gid_array != NULL) { - op->gid_array = (int *) + op->gid_array = (int *) globus_malloc(gid_count * sizeof(int)); memcpy( - op->gid_array, - gid_array, + op->gid_array, + gid_array, gid_count * sizeof(int)); } } @@ -5515,7 +5514,7 @@ globus_gridftp_server_control_finished_active_connect( return GLOBUS_SUCCESS; } - + globus_result_t globus_gridftp_server_control_finished_passive_connect( globus_gridftp_server_control_op_t op, @@ -5666,7 +5665,7 @@ globus_gridftp_server_control_disconnected( return result; } - + globus_result_t globus_gridftp_server_control_begin_transfer( globus_gridftp_server_control_op_t op) @@ -5685,7 +5684,7 @@ globus_gridftp_server_control_begin_transfer( op->type != GLOBUS_L_GSC_OP_TYPE_LIST && op->type != GLOBUS_L_GSC_OP_TYPE_NLST && op->type != GLOBUS_L_GSC_OP_TYPE_MLSD && - op->type != GLOBUS_L_GSC_OP_TYPE_MLSR) + op->type != GLOBUS_L_GSC_OP_TYPE_MLSR) { return GlobusGridFTPServerErrorParameter("op"); } @@ -5736,7 +5735,7 @@ globus_gridftp_server_control_finished_transfer( op->type != GLOBUS_L_GSC_OP_TYPE_LIST && op->type != GLOBUS_L_GSC_OP_TYPE_NLST && op->type != GLOBUS_L_GSC_OP_TYPE_MLSD && - op->type != GLOBUS_L_GSC_OP_TYPE_MLSR) + op->type != GLOBUS_L_GSC_OP_TYPE_MLSR) { return GlobusGridFTPServerErrorParameter("op"); } @@ -5756,7 +5755,7 @@ globus_gridftp_server_control_finished_transfer( switch(op->server_handle->data_object->state) { case GLOBUS_L_GSC_DATA_OBJ_INUSE: - op->server_handle->data_object->state = + op->server_handle->data_object->state = GLOBUS_L_GSC_DATA_OBJ_READY; break; @@ -5806,7 +5805,7 @@ globus_gridftp_server_control_set_paths( op->absolute_path = strdup(absolute_path); } /* resolved_path ignored */ - + GlobusGridFTPServerDebugExit(); return GLOBUS_SUCCESS; } @@ -5846,7 +5845,7 @@ globus_gridftp_server_control_list_buffer_alloc( return GlobusGridFTPServerErrorParameter("out_size"); } - if(strncmp("LIST:", fact_str, 5) == 0) + if(strncmp("LIST:", fact_str, 5) == 0) { const char * glob_match_str; if(fact_str[5] == '\0') @@ -5906,7 +5905,7 @@ globus_gridftp_server_control_events_enable( op->type != GLOBUS_L_GSC_OP_TYPE_LIST && op->type != GLOBUS_L_GSC_OP_TYPE_NLST && op->type != GLOBUS_L_GSC_OP_TYPE_MLSD && - op->type != GLOBUS_L_GSC_OP_TYPE_MLSR) + op->type != GLOBUS_L_GSC_OP_TYPE_MLSR) { res = GlobusGridFTPServerErrorParameter("op"); goto error_param; diff --git a/gridftp/server-lib/src/globus_gridftp_server_control_commands.c b/gridftp/server-lib/src/globus_gridftp_server_control_commands.c index b3afb2b3cf..4cbbc5919a 100644 --- a/gridftp/server-lib/src/globus_gridftp_server_control_commands.c +++ b/gridftp/server-lib/src/globus_gridftp_server_control_commands.c @@ -62,7 +62,7 @@ globus_l_gsc_cmd_stru( globus_i_gsc_log(op->server_handle, full_command, GLOBUS_GRIDFTP_SERVER_CONTROL_LOG_OTHER); tmp_ptr = cmd_a[1]; - if((tmp_ptr[0] == 'f' || tmp_ptr[0] == 'F') + if((tmp_ptr[0] == 'f' || tmp_ptr[0] == 'F') && tmp_ptr[1] == '\0') { globus_gsc_959_finished_command(op, _FSMSL("200 STRU F ok.\r\n")); @@ -130,7 +130,7 @@ globus_l_gsc_cmd_pbsz( globus_i_gsc_log(op->server_handle, full_command, GLOBUS_GRIDFTP_SERVER_CONTROL_LOG_SECURITY); - if(strlen(cmd_a[1]) > 10 || + if(strlen(cmd_a[1]) > 10 || (strlen(cmd_a[1]) == 10 && strcmp(cmd_a[1], "4294967296") >= 0)) { msg = globus_common_create_string(_FSMSL("501 Bad value for PBSZ: %s\r\n"), @@ -364,7 +364,7 @@ globus_l_gsc_cmd_mdtm_cb( code = 213; msg = globus_common_create_string( "%04d%02d%02d%02d%02d%02d", - tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday, + tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); } @@ -425,7 +425,7 @@ globus_l_gsc_cmd_mode( ch = (char)toupper((int)cmd_a[1][0]); if(strchr(op->server_handle->modes, ch) == NULL) { - tmp_ptr = strstr(full_command, "\r\n"); + tmp_ptr = (char *) strstr(full_command, "\r\n"); if(tmp_ptr != NULL) { *tmp_ptr = '\0'; @@ -501,16 +501,16 @@ globus_l_gsc_cmd_lang( { char * lang = NULL; - + char * msg; globus_i_gsc_log(op->server_handle, full_command, GLOBUS_GRIDFTP_SERVER_CONTROL_LOG_TRANSFER_STATE); if (cmd_a[1]==NULL) { - /*nothing specified after LANG, keep default*/ + /*nothing specified after LANG, keep default*/ msg = globus_common_create_string(_FSMSL("200 lang set to %s.\r\n"), lang); - op->server_handle->lang = lang; + op->server_handle->lang = lang; } else { @@ -523,21 +523,21 @@ globus_l_gsc_cmd_lang( } else { - /*Check if it is a supported language*/ - /*As internationalization continues, this will be discovered - * from configuration--hardcoded for now - */ - if (strcmp(lang, "EN")==0) - { + /*Check if it is a supported language*/ + /*As internationalization continues, this will be discovered + * from configuration--hardcoded for now + */ + if (strcmp(lang, "EN")==0) + { msg = globus_common_create_string(_FSMSL("200 lang set to %s.\r\n"), lang); op->server_handle->lang = lang; - } - else - { + } + else + { msg = globus_common_create_string( _FSMSL("501 '%s' unrecognized language.\r\n"), full_command); free(lang); - } + } } if(msg == NULL) { @@ -807,7 +807,7 @@ globus_l_gsc_cmd_stat_cb( } else if((intptr_t) user_arg == GLOBUS_L_GSC_OP_TYPE_MLSD) { - if(response_type == + if(response_type == GLOBUS_GRIDFTP_SERVER_CONTROL_RESPONSE_PARTIAL_SUCCESS) { partial = GLOBUS_TRUE; @@ -818,19 +818,19 @@ globus_l_gsc_cmd_stat_cb( code = 250; } tmp_ptr = globus_i_gsc_mlsx_line( - stat_info, - stat_count, - op->server_handle->opts.mlsx_fact_str, + stat_info, + stat_count, + op->server_handle->opts.mlsx_fact_str, uid, NULL, abs_path, GLOBUS_TRUE); msg = globus_common_create_string( - _FSMSL("%d-Contents of %s\r\n%s%d End.\r\n"), - code, - op->path, + _FSMSL("%d-Contents of %s\r\n%s%d End.\r\n"), + code, + op->path, tmp_ptr, - code); + code); globus_free(tmp_ptr); } else @@ -1024,9 +1024,9 @@ globus_l_gsc_cmd_size_cb( globus_gsc_959_finished_command(op, tmp_ptr); globus_free(tmp_ptr); globus_free(msg); - + return; - + err: if(msg != NULL) { @@ -1257,7 +1257,7 @@ globus_l_gsc_cmd_syst( globus_i_gsc_log(op->server_handle, full_command, GLOBUS_GRIDFTP_SERVER_CONTROL_LOG_OTHER); - + globus_gsc_959_finished_command(op, "215 UNIX Type: L8\r\n"); return; @@ -1378,7 +1378,7 @@ globus_l_gsc_cmd_opts( { *tmp_ptr = toupper(*tmp_ptr); } - + if(argc != 3) { msg = _FSMSL("500 OPTS failed.\r\n"); @@ -1389,7 +1389,7 @@ globus_l_gsc_cmd_opts( { *tmp_ptr = tolower(*tmp_ptr); } - + tmp_ptr = cmd_a[2]; msg = _FSMSL("500 OPTS failed.\r\n"); @@ -1477,7 +1477,7 @@ globus_l_gsc_cmd_opts( if(sscanf(tmp_ptr, "markers=%d;", &tmp_i) == 1) { char * freq_str = globus_common_create_string("%d", tmp_i); - op->server_handle->opts.retr_perf_frequency = tmp_i; + op->server_handle->opts.retr_perf_frequency = tmp_i; globus_libc_setenv("GFS_RETR_MARKERS", freq_str, 1); } else @@ -1517,7 +1517,7 @@ globus_l_gsc_cmd_opts( msg = _FSMSL("500 OPTS failed.\r\n"); } } - else if(strcmp("PASV", cmd_a[1]) == 0 || + else if(strcmp("PASV", cmd_a[1]) == 0 || strcmp("SPAS", cmd_a[1]) == 0 || strcmp("EPSV", cmd_a[1]) == 0) { @@ -1535,12 +1535,12 @@ globus_l_gsc_cmd_opts( msg = _FSMSL("500 OPTS failed.\r\n"); } } - else if(strcmp("MLST", cmd_a[1]) == 0 || + else if(strcmp("MLST", cmd_a[1]) == 0 || strcmp("MLSD", cmd_a[1]) == 0 || strcmp("MLSR", cmd_a[1]) == 0) { globus_bool_t mlsr_options = GLOBUS_FALSE; - + for(tmp_ptr = cmd_a[2]; *tmp_ptr != '\0'; tmp_ptr++) { *tmp_ptr = tolower(*tmp_ptr); @@ -1552,22 +1552,22 @@ globus_l_gsc_cmd_opts( { opts->mlsr_traversal_options |= GLOBUS_GFS_TRAVERSAL_CONTINUE; mlsr_options = GLOBUS_TRUE; - } + } else if(strstr(cmd_a[2], "onerror=fail")) { opts->mlsr_traversal_options &= ~GLOBUS_GFS_TRAVERSAL_CONTINUE; mlsr_options = GLOBUS_TRUE; - } + } if(strstr(cmd_a[2], "traversesymboliclinks=true")) { opts->mlsr_traversal_options |= GLOBUS_GFS_TRAVERSAL_FOLLOW_SYMLINKS; mlsr_options = GLOBUS_TRUE; - } + } else if(strstr(cmd_a[2], "traversesymboliclinks=false")) { opts->mlsr_traversal_options &= ~GLOBUS_GFS_TRAVERSAL_FOLLOW_SYMLINKS; mlsr_options = GLOBUS_TRUE; - } + } } /** Parse out common options */ tmp_ptr = opts->mlsx_fact_str; @@ -1625,7 +1625,7 @@ globus_l_gsc_cmd_opts( { *tmp_ptr = GLOBUS_GSX_MLSX_FACT_UNIXUID; tmp_ptr++; - } + } if(strstr(cmd_a[2], "unix.gid")) { *tmp_ptr = GLOBUS_GSX_MLSX_FACT_UNIXGID; @@ -1786,7 +1786,7 @@ globus_l_gsc_cmd_site_fault( { int len; int ctr; - + globus_i_gsc_log(op->server_handle, full_command, GLOBUS_GRIDFTP_SERVER_CONTROL_LOG_SITE); @@ -1799,10 +1799,10 @@ globus_l_gsc_cmd_site_fault( len = strlen(op->server_handle->fault_cmd); for(ctr = 0; ctr < len; ctr++) { - op->server_handle->fault_cmd[ctr] = + op->server_handle->fault_cmd[ctr] = toupper(op->server_handle->fault_cmd[ctr]); } - + globus_gsc_959_finished_command( op, "200 Site Command Successful.\r\n"); @@ -1845,8 +1845,8 @@ globus_l_gsc_cmd_rest( tmp_ptr = cmd_a[1]; while(tmp_ptr != NULL) { - sc = sscanf(tmp_ptr, - "%"GLOBUS_OFF_T_FORMAT"-%"GLOBUS_OFF_T_FORMAT, + sc = sscanf(tmp_ptr, + "%"GLOBUS_OFF_T_FORMAT"-%"GLOBUS_OFF_T_FORMAT, &start_offset, &end_offset); if(sc != 2) { @@ -1870,7 +1870,7 @@ globus_l_gsc_cmd_rest( globus_range_list_destroy(op->server_handle->range_list); } op->server_handle->range_list = range_list; - globus_gsc_959_finished_command(op, + globus_gsc_959_finished_command(op, _FSMSL("350 Restart Marker OK. Send STORE or RETR to initiate transfer.\r\n")); } @@ -1911,7 +1911,7 @@ globus_l_gsc_cmd_pasv_cb( err_code = 534; err_msg = "Data connection auth error"; break; - + default: if (globus_l_gsc_is_ftp_code(response_type)) { @@ -1942,7 +1942,7 @@ globus_l_gsc_cmd_pasv_cb( if(globus_libc_contact_string_to_ints( cs[0], host_ip, &ip_count, &port) != GLOBUS_SUCCESS) { - err_code = 500; + err_code = 500; err_msg = "Resource error.\r\n"; goto err; } @@ -1952,7 +1952,7 @@ globus_l_gsc_cmd_pasv_cb( err_msg = "Network protocol not supported.\r\n"; goto err; } - + msg = globus_common_create_string( "%d Entering Passive Mode (%d,%d,%d,%d,%d,%d)\r\n", wrapper->reply_code, @@ -1971,7 +1971,7 @@ globus_l_gsc_cmd_pasv_cb( addr_count = 1; } msg = globus_common_create_string( - "%d-Entering Striped Passive Mode.\r\n", + "%d-Entering Striped Passive Mode.\r\n", wrapper->reply_code); for(ctr = 0; ctr < addr_count; ctr++) { @@ -1988,7 +1988,7 @@ globus_l_gsc_cmd_pasv_cb( err_msg = "Network protocol not supported.\r\n"; goto err; } - + tmp_ptr = globus_common_create_string( "%s %d,%d,%d,%d,%d,%d\r\n", msg, @@ -2007,7 +2007,7 @@ globus_l_gsc_cmd_pasv_cb( globus_free(msg); msg = tmp_ptr; } - tmp_ptr = globus_common_create_string("%s%d End\r\n", + tmp_ptr = globus_common_create_string("%s%d End\r\n", msg, wrapper->reply_code); if(tmp_ptr == NULL) { @@ -2026,7 +2026,7 @@ globus_l_gsc_cmd_pasv_cb( { char * p; char * h; - + host = globus_libc_strdup(cs[0]); if(!host) { @@ -2034,7 +2034,7 @@ globus_l_gsc_cmd_pasv_cb( err_msg = "Resource error.\r\n"; goto err; } - + p = strrchr(host, ':'); if(!p || p == host) { @@ -2043,7 +2043,7 @@ globus_l_gsc_cmd_pasv_cb( err_msg = "Internal Parse error.\r\n"; goto err; } - + h = host; if(*host == '[') { @@ -2060,7 +2060,7 @@ globus_l_gsc_cmd_pasv_cb( *p = 0; } p++; - + sc = sscanf(p, "%hu", &port); if(sc != 1) { @@ -2069,7 +2069,7 @@ globus_l_gsc_cmd_pasv_cb( err_msg = "Internal Parse error.\r\n"; goto err; } - + if(op->server_handle->epsv_ip) { msg = globus_common_create_string( @@ -2083,7 +2083,7 @@ globus_l_gsc_cmd_pasv_cb( { msg = globus_common_create_string( "%d Entering Extended Passive Mode (|||%d|)\r\n", - wrapper->reply_code, + wrapper->reply_code, (int) port); } globus_free(host); @@ -2101,7 +2101,7 @@ globus_l_gsc_cmd_pasv_cb( { char * p; char * h; - + host = globus_libc_strdup(cs[ctr]); if(!host) { @@ -2109,7 +2109,7 @@ globus_l_gsc_cmd_pasv_cb( err_msg = "Resource error.\r\n"; goto err; } - + p = strrchr(host, ':'); if(!p || p == host) { @@ -2118,7 +2118,7 @@ globus_l_gsc_cmd_pasv_cb( err_msg = "Internal Parse error.\r\n"; goto err; } - + h = host; if(*cs[0] == '[') { @@ -2130,7 +2130,7 @@ globus_l_gsc_cmd_pasv_cb( *p = 0; } p++; - + sc = sscanf(p, "%hu", &port); if(sc != 1) { @@ -2139,7 +2139,7 @@ globus_l_gsc_cmd_pasv_cb( err_msg = "Internal Parse error.\r\n"; goto err; } - + tmp_ptr = globus_common_create_string( "%s |%d|%s|%d|\r\n", msg, @@ -2156,7 +2156,7 @@ globus_l_gsc_cmd_pasv_cb( globus_free(msg); msg = tmp_ptr; } - tmp_ptr = globus_common_create_string("%s%d End\r\n", + tmp_ptr = globus_common_create_string("%s%d End\r\n", msg, wrapper->reply_code); if(tmp_ptr == NULL) { @@ -2283,7 +2283,7 @@ globus_l_gsc_cmd_pasv( } } } - + wrapper->reply_code = 229; wrapper->cmd_ndx = 2; } @@ -2293,7 +2293,7 @@ globus_l_gsc_cmd_pasv( wrapper->cmd_ndx = 3; wrapper->reply_code = 229; wrapper->prt = GLOBUS_GRIDFTP_SERVER_CONTROL_PROTOCOL_IPV4; - + /* optional 2nd argument similar to epsv */ if(argc == 2) { @@ -2368,7 +2368,7 @@ globus_l_gsc_cmd_port_cb( code = 534; msg = strdup("Data connection auth error"); break; - + default: if (globus_l_gsc_is_ftp_code(response_type)) { @@ -2451,7 +2451,7 @@ globus_l_gsc_cmd_port( else if(strcmp(cmd_a[0], "SPOR") == 0) { wrapper->max = -1; - + stripe_count = 1; /* for the first */ p = cmd_a[1]; while((p = strchr(p, ' '))) @@ -2469,13 +2469,13 @@ globus_l_gsc_cmd_port( { globus_assert(GLOBUS_FALSE); } - + contact_strings = globus_libc_calloc(stripe_count, sizeof(char *)); if(contact_strings == NULL) { goto err; } - + /* move to the first command argument */ p = cmd_a[1]; while(isspace(*p)) p++; @@ -2483,7 +2483,7 @@ globus_l_gsc_cmd_port( { delim = 0; } - + for(i = 0; i < stripe_count && *p; i++) { if(delim) @@ -2498,11 +2498,11 @@ globus_l_gsc_cmd_port( /* get prt portion */ if(sscanf(p, "%d", &sc) < 1 || (sc != 1 && sc != 2)) { - msg = + msg = "522 Network protocol not supported, use (1,2).\r\n"; break; } - + /* may need to handle mixed prt in striped mode */ if(sc == 1) { @@ -2514,7 +2514,7 @@ globus_l_gsc_cmd_port( wrapper->prt = GLOBUS_GRIDFTP_SERVER_CONTROL_PROTOCOL_IPV6; } - + while(*p && *p != delim) p++; } else @@ -2523,18 +2523,18 @@ globus_l_gsc_cmd_port( break; } } - + if(*p) { int j = 0; char * s; char * c; char buf[100]; - + p++; c = strchr(p, ':'); s = strchr(p, delim); - + if(*p != delim) { /* get ip portion */ @@ -2542,12 +2542,12 @@ globus_l_gsc_cmd_port( { buf[j++] = '['; } - + while(j < sizeof(buf) - 1 && p < s) { buf[j++] = *(p++); } - + /* need room for ], :, 5 digits, and nul */ if(*p == delim && j + 7 < sizeof(buf)) { @@ -2557,7 +2557,7 @@ globus_l_gsc_cmd_port( { buf[j++] = ']'; } - + buf[j++] = ':'; while(j < sizeof(buf) - 1 && isdigit(*p) && *p != delim) @@ -2573,9 +2573,9 @@ globus_l_gsc_cmd_port( msg = "501 Malformed argument.\r\n"; break; } - + buf[j] = 0; - + contact_strings[i] = globus_libc_strdup(buf); } else @@ -2594,11 +2594,11 @@ globus_l_gsc_cmd_port( else { int consumed; - + wrapper->prt = GLOBUS_GRIDFTP_SERVER_CONTROL_PROTOCOL_IPV4; - + while(*p && !isdigit(*p)) p++; - + sc = sscanf(p, "%u,%u,%u,%u,%u,%u%n", &host_ip[0], @@ -2635,7 +2635,7 @@ globus_l_gsc_cmd_port( p += consumed; } } - + if(!contact_strings[i]) { msg = _FSMSL("501 Resource error.\r\n"); @@ -2689,7 +2689,7 @@ globus_l_gsc_cmd_port( * ------------------ ************************************************************************/ -static void +static void globus_l_gsc_data_cb( globus_i_gsc_op_t * op, globus_gridftp_server_control_response_t response_type, @@ -2788,7 +2788,7 @@ globus_l_gsc_cmd_transfer( globus_l_gsc_data_cb, wrapper); break; - + default: globus_assert(GLOBUS_FALSE); break; @@ -2837,7 +2837,7 @@ globus_l_gsc_cmd_stor_retr_cb( wrapper = (globus_i_gsc_cmd_wrapper_t *) user_arg; wrapper->op = op; - wrapper->path = globus_libc_strdup(path); + wrapper->path = globus_libc_strdup(path); if(response_type == GLOBUS_GRIDFTP_SERVER_CONTROL_RESPONSE_SUCCESS && stat_count > 1) @@ -2846,13 +2846,13 @@ globus_l_gsc_cmd_stor_retr_cb( msg = globus_common_create_string( _FSMSL("Path is a directory.")); } - + if(response_type != GLOBUS_GRIDFTP_SERVER_CONTROL_RESPONSE_SUCCESS || stat_count < 1) { /* we'll mimic a STOR here since the file doesn't exist */ wrapper->mod_name = NULL; - wrapper->mod_parms = NULL; + wrapper->mod_parms = NULL; } else { @@ -2861,7 +2861,7 @@ globus_l_gsc_cmd_stor_retr_cb( wrapper->mod_parms = globus_common_create_string( "%"GLOBUS_OFF_T_FORMAT, stat_info->size); } - + if(msg != NULL) { tmp_ptr = globus_gsc_string_to_959(code, msg, NULL); @@ -2899,7 +2899,7 @@ globus_l_gsc_cmd_stor_retr_cb( globus_l_gsc_cmd_transfer(wrapper); } return; - + } /* @@ -2981,7 +2981,7 @@ globus_l_gsc_cmd_stor_retr( } else if(strcmp(cmd_a[0], "APPE") == 0) { - int mask = + int mask = GLOBUS_GRIDFTP_SERVER_CONTROL_RESOURCE_FILE_ONLY; res = globus_i_gsc_resource_query( @@ -3007,8 +3007,8 @@ globus_l_gsc_cmd_stor_retr( arg2 = cmd_a[1] + 2; while(isspace(*arg2) && *arg2 != '\0') arg2++; - sc = sscanf(arg2, - "%"GLOBUS_OFF_T_FORMAT" %"GLOBUS_OFF_T_FORMAT, + sc = sscanf(arg2, + "%"GLOBUS_OFF_T_FORMAT" %"GLOBUS_OFF_T_FORMAT, &tmp_o, &tmp_o); if(sc != 2) { @@ -3097,7 +3097,7 @@ globus_l_gsc_cmd_stor_retr( globus_free(wrapper); globus_gsc_959_finished_command(op, _FSMSL("500 command failed: space.\r\n")); return; - } + } *tmp_ptr = '\0'; if(tmp_ptr[1] == '\0' || tmp_ptr[2] == '\0') { @@ -3137,8 +3137,8 @@ globus_l_gsc_cmd_stor_retr( tmp_ptr++; } } - - if((*tmp_ptr == '*' && *(tmp_ptr + 1) == '\0') || + + if((*tmp_ptr == '*' && *(tmp_ptr + 1) == '\0') || *tmp_ptr == '\0') { path = globus_libc_strdup(op->server_handle->cwd); @@ -3147,14 +3147,14 @@ globus_l_gsc_cmd_stor_retr( { int len; char * fn_ptr; - + len = strlen(tmp_ptr); if(strcspn(tmp_ptr, "[]*?") == len) { path = globus_libc_strdup(tmp_ptr); } else - { + { if((fn_ptr = strrchr(tmp_ptr, '/')) != NULL) { fn_ptr++; @@ -3232,7 +3232,7 @@ globus_i_gsc_add_commands( globus_gsc_959_command_add( server_handle, - "ALLO", + "ALLO", globus_l_gsc_cmd_allo, GLOBUS_GSC_COMMAND_POST_AUTH, 2, @@ -3242,7 +3242,7 @@ globus_i_gsc_add_commands( globus_gsc_959_command_add( server_handle, - "APPE", + "APPE", globus_l_gsc_cmd_stor_retr, GLOBUS_GSC_COMMAND_POST_AUTH, 2, @@ -3252,7 +3252,7 @@ globus_i_gsc_add_commands( globus_gsc_959_command_add( server_handle, - "CWD", + "CWD", globus_l_gsc_cmd_cwd, GLOBUS_GSC_COMMAND_POST_AUTH, 2, @@ -3262,7 +3262,7 @@ globus_i_gsc_add_commands( globus_gsc_959_command_add( server_handle, - "CDUP", + "CDUP", globus_l_gsc_cmd_cwd, GLOBUS_GSC_COMMAND_POST_AUTH, 1, @@ -3272,7 +3272,7 @@ globus_i_gsc_add_commands( globus_gsc_959_command_add( server_handle, - "DCAU", + "DCAU", globus_l_gsc_cmd_dcau, GLOBUS_GSC_COMMAND_POST_AUTH, 2, @@ -3282,7 +3282,7 @@ globus_i_gsc_add_commands( globus_gsc_959_command_add( server_handle, - "EPSV", + "EPSV", globus_l_gsc_cmd_pasv, GLOBUS_GSC_COMMAND_POST_AUTH, 1, @@ -3292,7 +3292,7 @@ globus_i_gsc_add_commands( globus_gsc_959_command_add( server_handle, - "ERET", + "ERET", globus_l_gsc_cmd_stor_retr, GLOBUS_GSC_COMMAND_POST_AUTH, 2, @@ -3302,7 +3302,7 @@ globus_i_gsc_add_commands( globus_gsc_959_command_add( server_handle, - "ESTO", + "ESTO", globus_l_gsc_cmd_stor_retr, GLOBUS_GSC_COMMAND_POST_AUTH, 2, @@ -3312,9 +3312,9 @@ globus_i_gsc_add_commands( globus_gsc_959_command_add( server_handle, - "FEAT", + "FEAT", globus_l_gsc_cmd_feat, - GLOBUS_GSC_COMMAND_PRE_AUTH | + GLOBUS_GSC_COMMAND_PRE_AUTH | GLOBUS_GSC_COMMAND_POST_AUTH, 1, 1, @@ -3323,9 +3323,9 @@ globus_i_gsc_add_commands( globus_gsc_959_command_add( server_handle, - "HELP", + "HELP", globus_l_gsc_cmd_help, - GLOBUS_GSC_COMMAND_PRE_AUTH | + GLOBUS_GSC_COMMAND_PRE_AUTH | GLOBUS_GSC_COMMAND_POST_AUTH, 1, 2, @@ -3334,7 +3334,7 @@ globus_i_gsc_add_commands( globus_gsc_959_command_add( server_handle, - "LIST", + "LIST", globus_l_gsc_cmd_stor_retr, GLOBUS_GSC_COMMAND_POST_AUTH, 1, @@ -3344,7 +3344,7 @@ globus_i_gsc_add_commands( globus_gsc_959_command_add( server_handle, - "MDTM", + "MDTM", globus_l_gsc_cmd_mdtm, GLOBUS_GSC_COMMAND_POST_AUTH, 2, @@ -3354,7 +3354,7 @@ globus_i_gsc_add_commands( globus_gsc_959_command_add( server_handle, - "MODE", + "MODE", globus_l_gsc_cmd_mode, GLOBUS_GSC_COMMAND_POST_AUTH, 2, @@ -3364,7 +3364,7 @@ globus_i_gsc_add_commands( globus_gsc_959_command_add( server_handle, - "NLST", + "NLST", globus_l_gsc_cmd_stor_retr, GLOBUS_GSC_COMMAND_POST_AUTH, 1, @@ -3414,9 +3414,9 @@ globus_i_gsc_add_commands( globus_gsc_959_command_add( server_handle, - "NOOP", + "NOOP", globus_l_gsc_cmd_noop, - GLOBUS_GSC_COMMAND_PRE_AUTH | + GLOBUS_GSC_COMMAND_PRE_AUTH | GLOBUS_GSC_COMMAND_POST_AUTH, 1, 1, @@ -3425,7 +3425,7 @@ globus_i_gsc_add_commands( globus_gsc_959_command_add( server_handle, - "OPTS", + "OPTS", globus_l_gsc_cmd_opts, GLOBUS_GSC_COMMAND_POST_AUTH, 2, @@ -3435,7 +3435,7 @@ globus_i_gsc_add_commands( globus_gsc_959_command_add( server_handle, - "PASS", + "PASS", globus_l_gsc_cmd_pass, GLOBUS_GSC_COMMAND_PRE_AUTH, 1, @@ -3445,7 +3445,7 @@ globus_i_gsc_add_commands( globus_gsc_959_command_add( server_handle, - "PASV", + "PASV", globus_l_gsc_cmd_pasv, GLOBUS_GSC_COMMAND_POST_AUTH, 1, @@ -3455,7 +3455,7 @@ globus_i_gsc_add_commands( globus_gsc_959_command_add( server_handle, - "PBSZ", + "PBSZ", globus_l_gsc_cmd_pbsz, GLOBUS_GSC_COMMAND_POST_AUTH, 2, @@ -3465,7 +3465,7 @@ globus_i_gsc_add_commands( globus_gsc_959_command_add( server_handle, - "PORT", + "PORT", globus_l_gsc_cmd_port, GLOBUS_GSC_COMMAND_POST_AUTH, 2, @@ -3475,7 +3475,7 @@ globus_i_gsc_add_commands( globus_gsc_959_command_add( server_handle, - "PROT", + "PROT", globus_l_gsc_cmd_prot, GLOBUS_GSC_COMMAND_POST_AUTH, 2, @@ -3485,7 +3485,7 @@ globus_i_gsc_add_commands( globus_gsc_959_command_add( server_handle, - "EPRT", + "EPRT", globus_l_gsc_cmd_port, GLOBUS_GSC_COMMAND_POST_AUTH, 2, @@ -3495,7 +3495,7 @@ globus_i_gsc_add_commands( globus_gsc_959_command_add( server_handle, - "SPOR", + "SPOR", globus_l_gsc_cmd_port, GLOBUS_GSC_COMMAND_POST_AUTH, 2, @@ -3505,7 +3505,7 @@ globus_i_gsc_add_commands( globus_gsc_959_command_add( server_handle, - "TREV", + "TREV", globus_l_gsc_cmd_trev, GLOBUS_GSC_COMMAND_POST_AUTH, 3, @@ -3515,7 +3515,7 @@ globus_i_gsc_add_commands( globus_gsc_959_command_add( server_handle, - "PWD", + "PWD", globus_l_gsc_cmd_pwd, GLOBUS_GSC_COMMAND_POST_AUTH, 1, @@ -3525,9 +3525,9 @@ globus_i_gsc_add_commands( globus_gsc_959_command_add( server_handle, - "QUIT", + "QUIT", globus_l_gsc_cmd_quit, - GLOBUS_GSC_COMMAND_PRE_AUTH | + GLOBUS_GSC_COMMAND_PRE_AUTH | GLOBUS_GSC_COMMAND_POST_AUTH, 1, 1, @@ -3536,7 +3536,7 @@ globus_i_gsc_add_commands( globus_gsc_959_command_add( server_handle, - "REST", + "REST", globus_l_gsc_cmd_rest, GLOBUS_GSC_COMMAND_POST_AUTH, 2, @@ -3546,7 +3546,7 @@ globus_i_gsc_add_commands( globus_gsc_959_command_add( server_handle, - "RETR", + "RETR", globus_l_gsc_cmd_stor_retr, GLOBUS_GSC_COMMAND_POST_AUTH, 2, @@ -3556,7 +3556,7 @@ globus_i_gsc_add_commands( globus_gsc_959_command_add( server_handle, - "SBUF", + "SBUF", globus_l_gsc_cmd_sbuf, GLOBUS_GSC_COMMAND_POST_AUTH, 2, @@ -3566,7 +3566,7 @@ globus_i_gsc_add_commands( globus_gsc_959_command_add( server_handle, - "SIZE", + "SIZE", globus_l_gsc_cmd_size, GLOBUS_GSC_COMMAND_POST_AUTH, 2, @@ -3576,7 +3576,7 @@ globus_i_gsc_add_commands( globus_gsc_959_command_add( server_handle, - "SPAS", + "SPAS", globus_l_gsc_cmd_pasv, GLOBUS_GSC_COMMAND_POST_AUTH, 1, @@ -3586,7 +3586,7 @@ globus_i_gsc_add_commands( globus_gsc_959_command_add( server_handle, - "STAT", + "STAT", globus_l_gsc_cmd_stat, GLOBUS_GSC_COMMAND_POST_AUTH, 1, @@ -3596,7 +3596,7 @@ globus_i_gsc_add_commands( globus_gsc_959_command_add( server_handle, - "STOR", + "STOR", globus_l_gsc_cmd_stor_retr, GLOBUS_GSC_COMMAND_POST_AUTH, 2, @@ -3606,7 +3606,7 @@ globus_i_gsc_add_commands( globus_gsc_959_command_add( server_handle, - "STRU", + "STRU", globus_l_gsc_cmd_stru, GLOBUS_GSC_COMMAND_POST_AUTH, 2, @@ -3616,7 +3616,7 @@ globus_i_gsc_add_commands( globus_gsc_959_command_add( server_handle, - "SYST", + "SYST", globus_l_gsc_cmd_syst, GLOBUS_GSC_COMMAND_POST_AUTH, 1, @@ -3626,7 +3626,7 @@ globus_i_gsc_add_commands( globus_gsc_959_command_add( server_handle, - "TYPE", + "TYPE", globus_l_gsc_cmd_type, GLOBUS_GSC_COMMAND_POST_AUTH, 2, @@ -3636,7 +3636,7 @@ globus_i_gsc_add_commands( globus_gsc_959_command_add( server_handle, - "USER", + "USER", globus_l_gsc_cmd_user, GLOBUS_GSC_COMMAND_PRE_AUTH, 2, @@ -3646,7 +3646,7 @@ globus_i_gsc_add_commands( globus_gsc_959_command_add( server_handle, - "SITE SBUF", + "SITE SBUF", globus_l_gsc_cmd_site_sbuf, GLOBUS_GSC_COMMAND_POST_AUTH, 3, @@ -3656,7 +3656,7 @@ globus_i_gsc_add_commands( globus_gsc_959_command_add( server_handle, - "SITE RETRBUFSIZE", + "SITE RETRBUFSIZE", globus_l_gsc_cmd_site_receive_buf, GLOBUS_GSC_COMMAND_POST_AUTH, 3, @@ -3666,7 +3666,7 @@ globus_i_gsc_add_commands( globus_gsc_959_command_add( server_handle, - "SITE RBUFSZ", + "SITE RBUFSZ", globus_l_gsc_cmd_site_receive_buf, GLOBUS_GSC_COMMAND_POST_AUTH, 3, @@ -3676,7 +3676,7 @@ globus_i_gsc_add_commands( globus_gsc_959_command_add( server_handle, - "SITE RBUFSIZ", + "SITE RBUFSIZ", globus_l_gsc_cmd_site_receive_buf, GLOBUS_GSC_COMMAND_POST_AUTH, 3, @@ -3686,7 +3686,7 @@ globus_i_gsc_add_commands( globus_gsc_959_command_add( server_handle, - "SITE STORBUFSIZE", + "SITE STORBUFSIZE", globus_l_gsc_cmd_site_send_buf, GLOBUS_GSC_COMMAND_POST_AUTH, 3, @@ -3696,7 +3696,7 @@ globus_i_gsc_add_commands( globus_gsc_959_command_add( server_handle, - "SITE SBUFSZ", + "SITE SBUFSZ", globus_l_gsc_cmd_site_send_buf, GLOBUS_GSC_COMMAND_POST_AUTH, 3, @@ -3706,7 +3706,7 @@ globus_i_gsc_add_commands( globus_gsc_959_command_add( server_handle, - "SITE SBUFSIZ", + "SITE SBUFSIZ", globus_l_gsc_cmd_site_send_buf, GLOBUS_GSC_COMMAND_POST_AUTH, 3, @@ -3716,9 +3716,9 @@ globus_i_gsc_add_commands( globus_gsc_959_command_add( server_handle, - "SITE HELP", + "SITE HELP", globus_l_gsc_cmd_help, - GLOBUS_GSC_COMMAND_PRE_AUTH | + GLOBUS_GSC_COMMAND_PRE_AUTH | GLOBUS_GSC_COMMAND_POST_AUTH, 2, 3, @@ -3727,7 +3727,7 @@ globus_i_gsc_add_commands( globus_gsc_959_command_add( server_handle, - "SITE FAULT", + "SITE FAULT", globus_l_gsc_cmd_site_fault, GLOBUS_GSC_COMMAND_POST_AUTH, 3, @@ -3737,14 +3737,14 @@ globus_i_gsc_add_commands( globus_gsc_959_command_add( server_handle, - "LANG", + "LANG", globus_l_gsc_cmd_lang, GLOBUS_GSC_COMMAND_POST_AUTH, 1, 2, "LANG: set language for messages", NULL); - + /* add features */ globus_gridftp_server_control_add_feature(server_handle, "PASV AllowDelayed;"); globus_gridftp_server_control_add_feature(server_handle, "MDTM"); @@ -3753,11 +3753,11 @@ globus_i_gsc_add_commands( globus_gridftp_server_control_add_feature(server_handle, "SPAS"); globus_gridftp_server_control_add_feature(server_handle, "ESTO"); globus_gridftp_server_control_add_feature(server_handle, "ERET"); - globus_gridftp_server_control_add_feature(server_handle, "MLST Type*;Size*;Modify*;Perm*;Charset;UNIX.mode*;UNIX.owner*;UNIX.uid*;UNIX.group*;UNIX.gid*;Unique*;UNIX.slink*;X.count;"); - globus_gridftp_server_control_add_feature(server_handle, "SIZE"); - globus_gridftp_server_control_add_feature(server_handle, "PARALLEL"); - globus_gridftp_server_control_add_feature(server_handle, "DCAU"); - globus_gridftp_server_control_add_feature(server_handle, "LANG EN"); + globus_gridftp_server_control_add_feature(server_handle, "MLST Type*;Size*;Modify*;Perm*;Charset;UNIX.mode*;UNIX.owner*;UNIX.uid*;UNIX.group*;UNIX.gid*;Unique*;UNIX.slink*;X.count;"); + globus_gridftp_server_control_add_feature(server_handle, "SIZE"); + globus_gridftp_server_control_add_feature(server_handle, "PARALLEL"); + globus_gridftp_server_control_add_feature(server_handle, "DCAU"); + globus_gridftp_server_control_add_feature(server_handle, "LANG EN"); globus_gridftp_server_control_add_feature(server_handle, "UTF8"); globus_gridftp_server_control_add_feature(server_handle, "MLSC"); globus_gridftp_server_control_add_feature(server_handle, "MLSR"); diff --git a/gridftp/server-lib/src/globus_xio_gssapi_ftp.c b/gridftp/server-lib/src/globus_xio_gssapi_ftp.c index c41674ba25..c9717254e3 100644 --- a/gridftp/server-lib/src/globus_xio_gssapi_ftp.c +++ b/gridftp/server-lib/src/globus_xio_gssapi_ftp.c @@ -35,7 +35,7 @@ _xio_name, \ __LINE__, \ "Bad Parameter")) - + #define GlobusXIOGssapiFTPOutstandingOp() \ globus_error_put( \ globus_error_construct_error( \ @@ -46,7 +46,7 @@ _xio_name, \ __LINE__, \ "Operation is outstanding")) - + #define GlobusXIOGssapiFTPEncodingError() \ globus_error_put( \ globus_error_construct_error( \ @@ -57,7 +57,7 @@ _xio_name, \ __LINE__, \ "Error encoding.")) - + #define GlobusXIOGssapiFTPAllocError() \ globus_error_put( \ globus_error_construct_error( \ @@ -92,7 +92,7 @@ _xio_name, \ __LINE__, \ failure)) - + #define GlobusXIOGssapiFTPAuthenticationFailure(str) \ globus_error_put( \ globus_error_construct_error( \ @@ -104,7 +104,7 @@ __LINE__, \ "Authentication Error: %s", \ str)) - + #define GlobusXIOGssapiFTPQuit() \ globus_error_put( \ globus_error_construct_error( \ @@ -221,16 +221,16 @@ static globus_xio_driver_t globus_l_gssapi_telnet_driver = NULL; static char globus_l_xio_gssapi_ftp_pad = '='; static char * globus_l_xio_gssapi_ftp_radix_n = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - + /************************************************************************** - * data type definitions + * data type definitions * --------------------- *************************************************************************/ /** * opening * ------- - * When a user opens a handle the authentication process begins. The + * When a user opens a handle the authentication process begins. The * default case will do the entire authentication processes as described * in the state machine. However the user can override various bits * of the authentication process by setting the start state on the handle @@ -239,11 +239,11 @@ static char * globus_l_xio_gssapi_ftp_radix_n = /* * writting * -------- - * Once an open handle is esstablished the user may post writes. If + * Once an open handle is esstablished the user may post writes. If * a write is posted that does not contain a complete command (no \r\n) * then it is copied to an internal buffer and the user is told that the * write operation is complete. As soon as a complete comman is received - * it is wrapped and encoded then passed down the stack. Additional + * it is wrapped and encoded then passed down the stack. Additional * data beyound a complete command is cached in the same way. */ @@ -418,7 +418,7 @@ globus_l_xio_gssapi_ftp_handle_create() /* * create a new handle and initialize it */ - handle = (globus_l_xio_gssapi_ftp_handle_t *) + handle = (globus_l_xio_gssapi_ftp_handle_t *) globus_libc_calloc(sizeof(globus_l_xio_gssapi_ftp_handle_t), 1); if(handle == NULL) { @@ -521,7 +521,7 @@ globus_l_xio_gssapi_ftp_radix_decode( { if ((p = strchr(globus_l_xio_gssapi_ftp_radix_n, inbuf[i])) == NULL) { - goto err; + goto err; } D = p - globus_l_xio_gssapi_ftp_radix_n; switch (i&3) @@ -548,27 +548,27 @@ globus_l_xio_gssapi_ftp_radix_decode( switch (i&3) { case 1: - goto err; - + goto err; + case 2: if (D&15) { - goto err; + goto err; } if (strcmp((char *)&inbuf[i], "==")) { - goto err; + goto err; } break; case 3: if (D&3) { - goto err; + goto err; } if (strcmp((char *)&inbuf[i], "=")) { - goto err; + goto err; } break; @@ -759,7 +759,7 @@ globus_l_xio_gssapi_ftp_decode_adat( /* if we have finished the security exchange */ case GSS_S_COMPLETE: /* get the subject and copy into handle */ - + maj_stat = gss_display_name( &min_stat, handle->target_name, @@ -954,7 +954,7 @@ globus_l_xio_gssapi_ftp_parse_command( sub_len -= 4; } /* feat is returning continuation commands that look strabge - this allows it to work, but TODO: verifiy server is + this allows it to work, but TODO: verifiy server is correct */ else { @@ -1002,8 +1002,8 @@ globus_l_xio_gssapi_ftp_parse_command( } /* - * take a wrapped buffer and decode and unwrap it. The caller is - * responsible for freeing the out buffer if the function returns + * take a wrapped buffer and decode and unwrap it. The caller is + * responsible for freeing the out buffer if the function returns * successfully. */ static globus_result_t @@ -1062,9 +1062,9 @@ globus_l_xio_gssapi_ftp_unwrap( globus_free(buf); goto err; } - + globus_free(buf); - + /* copy the unwrapped token in */ len = unwrapped_token.length; buf = globus_malloc(len+3); @@ -1106,7 +1106,7 @@ globus_l_xio_gssapi_ftp_unwrap( static globus_result_t globus_l_xio_gssapi_ftp_wrap( globus_l_xio_gssapi_ftp_handle_t * handle, - globus_byte_t * in_buf, + globus_byte_t * in_buf, globus_size_t length, void ** out_buffer, globus_size_t * out_len, @@ -1125,7 +1125,7 @@ globus_l_xio_gssapi_ftp_wrap( gss_in_buf.value = in_buf; gss_in_buf.length = length; - + maj_stat = gss_wrap(&min_stat, handle->gssapi_context, 0, @@ -1139,7 +1139,7 @@ globus_l_xio_gssapi_ftp_wrap( goto err; } - encoded_buf = (char *) + encoded_buf = (char *) globus_libc_malloc((gss_out_buf.length + 3) * 8 / 6 + 9); if(encoded_buf == NULL) { @@ -1195,10 +1195,10 @@ globus_l_xio_gssapi_ftp_wrap( } /* preline only affects multiline strings. - a null preline will prepend a "code-" to the front of each line by default, + a null preline will prepend a "code-" to the front of each line by default, otherwise the preline is prepended. */ -static +static char * globus_l_xio_gssapi_ftp_string_to_959( int code, @@ -1251,8 +1251,8 @@ globus_l_xio_gssapi_ftp_string_to_959( tmp_ptr = msg; msg = globus_common_create_string( - "%s%s%s\r\n", - tmp_ptr, + "%s%s%s\r\n", + tmp_ptr, (ctr > 0) ? prepad : "", start_ptr); globus_free(tmp_ptr); @@ -1283,7 +1283,7 @@ globus_l_xio_gssapi_ftp_string_to_959( * server open * ----------- * - * This section contains the functions used by a server in openning + * This section contains the functions used by a server in openning * a handle. ***********************************************************************/ /* @@ -1370,7 +1370,7 @@ globus_l_xio_gssapi_ftp_server_read_cb( msg = globus_libc_strdup(REPLY_530_EXPECTING_ADAT); } } - else if(cmd_a[1] == NULL || + else if(cmd_a[1] == NULL || strcasecmp(cmd_a[1], "GSSAPI") != 0) { msg = globus_libc_strdup(REPLY_504_BAD_AUTH_TYPE); @@ -1492,9 +1492,9 @@ globus_l_xio_gssapi_ftp_server_read_cb( handle->auth_write_iov.iov_len = globus_libc_strlen(msg); GlobusXIOGssapiftpDebugPassWrite(); res = globus_xio_driver_pass_write( - op, + op, &handle->auth_write_iov, - 1, + 1, handle->auth_write_iov.iov_len, globus_l_xio_gssapi_ftp_auth_server_write_cb, handle); @@ -1529,8 +1529,8 @@ globus_l_xio_gssapi_ftp_server_read_cb( /* * while in the open authentication process, this callback is used for - * all of the writes. - */ + * all of the writes. + */ static void globus_l_xio_gssapi_ftp_auth_server_write_cb( globus_xio_operation_t op, @@ -1580,7 +1580,7 @@ globus_l_xio_gssapi_ftp_auth_server_write_cb( break; case GSSAPI_FTP_STATE_SERVER_ADAT_REPLY: - GlobusXIOGssapiftpDebugChangeState(handle, + GlobusXIOGssapiftpDebugChangeState(handle, GSSAPI_FTP_STATE_OPEN); break; @@ -1620,8 +1620,8 @@ globus_l_xio_gssapi_ftp_auth_server_write_cb( } /* * while in the open authentication process, this callback is used for - * all of the writes. - */ + * all of the writes. + */ static void globus_l_xio_gssapi_ftp_client_preauth_client_write_cb( globus_xio_operation_t op, @@ -1709,8 +1709,8 @@ globus_l_xio_gssapi_ftp_accept_cb( } /* - * callback for the pass open. If the state is not completely open - * post a read to move to the next point in the authentication + * callback for the pass open. If the state is not completely open + * post a read to move to the next point in the authentication * process. In the normal case this will be AUTH, however the user * may circumvent these steps. */ @@ -1794,7 +1794,7 @@ globus_l_xio_gssapi_ftp_server_open_cb( /************************************************************************ * client open functions * --------------------- - * + * * This section has functions that open a handle for a client ***********************************************************************/ @@ -1829,7 +1829,7 @@ globus_l_xio_gssapi_ftp_client_adat( if(handle->subject == NULL) { - xio_driver_handle = + xio_driver_handle = globus_xio_operation_get_driver_handle(handle->op); result = globus_xio_driver_handle_cntl( @@ -1892,15 +1892,15 @@ globus_l_xio_gssapi_ftp_client_adat( case GSSAPI_FTP_STATE_CLIENT_SENDING_ADAT: /* base64 decode the reply */ length = globus_libc_strlen(buffer); - + radix_buf = globus_libc_malloc((length + 1) * 6 / 8 + 1); - + if(radix_buf == GLOBUS_NULL) { res = GlobusXIOGssapiFTPAllocError(); goto err; } - + res = globus_l_xio_gssapi_ftp_radix_decode( (const globus_byte_t *) buffer, radix_buf, @@ -1962,8 +1962,8 @@ globus_l_xio_gssapi_ftp_client_adat( memcpy(radix_buf, "ADAT ", 5); length = send_tok.length; res = globus_l_xio_gssapi_ftp_radix_encode( - send_tok.value, - send_tok.length, + send_tok.value, + send_tok.length, &radix_buf[5], &length); if(res != GLOBUS_SUCCESS) @@ -1978,7 +1978,7 @@ globus_l_xio_gssapi_ftp_client_adat( *out_buffer = (char *) radix_buf; } - break; + break; default: res = GlobusXIOGssapiFTPGSIAuthFailure(maj_stat, min_stat); @@ -2054,7 +2054,7 @@ globus_l_xio_gssapi_ftp_preauth_client_read_cb( { GlobusXIOGssapiftpDebugChangeState(handle, GSSAPI_FTP_STATE_CLIENT_SENDING_AUTH); - send_buffer = + send_buffer = globus_libc_strdup(CLIENT_AUTH_GSSAPI_COMMAND); handle->banner = handle->auth_read_iov.iov_base; handle->banner_length = handle->auth_read_iov.iov_len; @@ -2222,7 +2222,7 @@ globus_l_xio_gssapi_ftp_accept( GlobusXIOGssapiftpDebugEnter(); - res = globus_xio_driver_pass_accept(accept_op, + res = globus_xio_driver_pass_accept(accept_op, globus_l_xio_gssapi_ftp_accept_cb, NULL); GlobusXIOGssapiftpDebugExit(); @@ -2242,11 +2242,11 @@ globus_l_xio_gssapi_ftp_attr_init( GlobusXIOGssapiftpDebugEnter(); - attr = (globus_l_xio_gssapi_attr_t *) + attr = (globus_l_xio_gssapi_attr_t *) globus_calloc(1, sizeof(globus_l_xio_gssapi_attr_t)); if(attr == NULL) { - goto err; + goto err; } attr->subject = NULL; attr->start_state = GSSAPI_FTP_STATE_NONE; @@ -2330,7 +2330,7 @@ globus_l_xio_gssapi_ftp_attr_copy( res = globus_l_xio_gssapi_ftp_attr_init((void **) &dst_attr); if(res != GLOBUS_SUCCESS) { - goto err; + goto err; } memcpy(dst_attr, src_attr, sizeof(globus_l_xio_gssapi_attr_t)); if(src_attr->subject != NULL) @@ -2390,11 +2390,11 @@ globus_l_xio_gssapi_ftp_open( attr = (globus_l_xio_gssapi_attr_t *) driver_attr; globus_xio_driver_attr_cntl( - op, globus_l_gssapi_telnet_driver, + op, globus_l_gssapi_telnet_driver, GLOBUS_XIO_TELNET_BUFFER, GLOBUS_TRUE); /* - * create a new handle and initialize it + * create a new handle and initialize it */ handle = globus_l_xio_gssapi_ftp_handle_create(); if(handle == NULL) @@ -2407,7 +2407,7 @@ globus_l_xio_gssapi_ftp_open( { handle->client = GLOBUS_FALSE; globus_xio_driver_attr_cntl( - op, globus_l_gssapi_telnet_driver, + op, globus_l_gssapi_telnet_driver, GLOBUS_XIO_TELNET_FORCE_SERVER, GLOBUS_TRUE); } else @@ -2482,7 +2482,7 @@ globus_l_xio_gssapi_ftp_close( /************************************************************************ * write functions * --------------- - * + * * This section has function that handle writes ***********************************************************************/ @@ -2557,7 +2557,6 @@ globus_l_xio_gssapi_ftp_write( globus_byte_t * out_buf; globus_byte_t * next_ptr; globus_byte_t * tmp_ptr; - int tmp_i; int tmp_i2; globus_xio_iovec_t * l_iov; int l_iov_ndx = 1; @@ -2601,7 +2600,7 @@ globus_l_xio_gssapi_ftp_write( if(handle->client) { res = globus_l_xio_gssapi_ftp_wrap( - handle, handle->write_buffer, length, + handle, handle->write_buffer, length, &l_iov[0].iov_base, &l_iov[0].iov_len, handle->client); @@ -2635,14 +2634,12 @@ globus_l_xio_gssapi_ftp_write( l_iov_ndx = 0; out_buf = NULL; - tmp_i = 3; tmp_ptr = handle->write_buffer; while(tmp_ptr - handle->write_buffer < length) { if(!first) { out_buf[3] = '-'; - tmp_i += tmp_i2; } next_ptr = (globus_byte_t *) strstr((const char *) tmp_ptr, "\r\n"); @@ -2676,7 +2673,7 @@ globus_l_xio_gssapi_ftp_write( handle->write_iov = l_iov; handle->write_iov_count = l_iov_ndx; res = globus_xio_driver_pass_write( - op, + op, l_iov, l_iov_ndx, length, @@ -2706,7 +2703,7 @@ globus_l_xio_gssapi_ftp_write( /************************************************************************ * read functions * -------------- - * + * * This section has function that handle writes ***********************************************************************/ @@ -2836,7 +2833,7 @@ globus_l_xio_gssapi_ftp_read( /* should serialize */ /* completely de const'ipating here */ - handle->read_iov = (globus_xio_iovec_t *) iovec; + handle->read_iov = (globus_xio_iovec_t *) iovec; if(handle->client) { if(handle->banner != NULL) @@ -2872,7 +2869,7 @@ globus_l_xio_gssapi_ftp_read( &handle->auth_read_iov, 1, 1, - globus_l_xio_gssapi_ftp_server_read_cb, + globus_l_xio_gssapi_ftp_server_read_cb, handle); if(res != GLOBUS_SUCCESS) { @@ -2880,7 +2877,7 @@ globus_l_xio_gssapi_ftp_read( } handle->read_posted = GLOBUS_TRUE; } - } + } globus_mutex_unlock(&handle->mutex); if(finished) @@ -2967,7 +2964,7 @@ globus_l_xio_gssapi_ftp_handle_cntl( /************************************************************************ * load and activate * ----------------- - * + * * This section has function that handle writes ***********************************************************************/ static globus_result_t @@ -3050,13 +3047,13 @@ globus_l_xio_gssapi_ftp_activate(void) rc = globus_module_activate(GLOBUS_XIO_MODULE); rc = globus_module_activate(GLOBUS_GSI_GSS_ASSIST_MODULE); globus_module_activate(GLOBUS_GSI_OPENSSL_ERROR_MODULE); - + res = globus_xio_driver_load("telnet", &globus_l_gssapi_telnet_driver); if(res != GLOBUS_SUCCESS) { return GLOBUS_FAILURE; } - + GlobusXIORegisterDriver(gssapi_ftp); GlobusXIOGssapiftpDebugExit(); return rc; diff --git a/gridftp/server/multi/source/configure.ac b/gridftp/server/multi/source/configure.ac index 8c7f0de348..5dcb1c5fdc 100644 --- a/gridftp/server/multi/source/configure.ac +++ b/gridftp/server/multi/source/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ([2.60]) -AC_INIT([globus_xio_gridftp_multicast],[2.2],[https://github.com/gridcf/gct/issues]) +AC_INIT([globus_xio_gridftp_multicast],[2.3],[https://github.com/gridcf/gct/issues]) AC_CONFIG_MACRO_DIR([m4]) AC_SUBST([MAJOR_VERSION], [${PACKAGE_VERSION%%.*}]) AC_SUBST([MINOR_VERSION], [${PACKAGE_VERSION##*.}]) diff --git a/gridftp/server/multi/source/globus_xio_gridftp_multicast_driver.c b/gridftp/server/multi/source/globus_xio_gridftp_multicast_driver.c index dddb698868..558d30071e 100644 --- a/gridftp/server/multi/source/globus_xio_gridftp_multicast_driver.c +++ b/gridftp/server/multi/source/globus_xio_gridftp_multicast_driver.c @@ -21,12 +21,12 @@ * use is for multicast broad casts in the gridftp server. * * If an error occurs on any one gridftp handle it is not imediately - * reported to the user. It is reecorded and no futher buffers will be - * passed down that connection. Upon closing the handle all errors + * reported to the user. It is reecorded and no futher buffers will be + * passed down that connection. Upon closing the handle all errors * are reported. * * However, if a pass error occurs it is reported immediately and all - * active ftp connections are terminated. + * active ftp connections are terminated. * * The user is not required to actually pass data down the stack. In * some cases they will want buffers to hop around servers in a network @@ -37,7 +37,7 @@ */ #include "globus_xio_driver.h" #include "globus_xio_gridftp_multicast_driver.h" -#include "globus_ftp_client.h" +#include "globus_ftp_client.h" #include "version.h" GlobusDebugDefine(GLOBUS_XIO_GRIDFTP_MULTICAST); @@ -73,7 +73,7 @@ GlobusXIODeclareDriver(gridftp_multicast); __FILE__, \ _xio_name, \ __LINE__, \ - _XIOSL(_reason)) + _XIOSL(_reason)) #define GMC_ERROR_TOKEN "GMC_ERROR=\n" #define GMC_URL_ENC_CHAR "#;:=+ ," @@ -236,7 +236,7 @@ xio_l_gmc_handle_destroy( globus_ftp_client_handleattr_destroy(&ftp_handle->handle_attr); globus_ftp_client_operationattr_destroy(&ftp_handle->op_attr); - /* free up the client lib stuff + /* free up the client lib stuff globus_ftp_client_handle_t client_h; */ } @@ -451,20 +451,20 @@ xio_l_gridftp_multicast_activate() static int xio_l_gridftp_multicast_deactivate() -{ +{ int rc; GlobusXIOName(xio_l_gridftp_multicast_deactivate); - + GlobusXIOGridftpMulticastDebugEnter(); GlobusXIOUnRegisterDriver(gridftp_multicast); rc = globus_module_deactivate(GLOBUS_FTP_CLIENT_MODULE); if (rc != GLOBUS_SUCCESS) - { + { goto error_deactivate; } rc = globus_module_deactivate(GLOBUS_XIO_MODULE); if (rc != GLOBUS_SUCCESS) - { + { goto error_deactivate; } GlobusXIOGridftpMulticastDebugExit(); @@ -756,7 +756,7 @@ xio_l_gridftp_multicast_open( 1, sizeof(xio_l_gridftp_multicast_handle_t)); globus_mutex_init(&handle->mutex, NULL); handle->local_url = strdup(contact_info->unparsed); - handle->P = attr->P; + handle->P = attr->P; handle->tcp_bs = attr->tcp_bs; handle->pass_write = attr->pass_write; @@ -922,7 +922,7 @@ xio_l_gmc_destroy_forwarder( ftp_handle->closing = GLOBUS_TRUE; result = globus_ftp_client_abort(&ftp_handle->client_h); - + /* not the ost interesting error, but we will hang onto it if there wasnt a better one around */ if(result != GLOBUS_SUCCESS && ftp_handle->result == GLOBUS_SUCCESS) @@ -944,7 +944,6 @@ xio_l_gmc_setup_forwarder( int max_str_len, int each_cast_count) { - int cast_count; char * driver_del; char * stack_str; int stack_str_ndx; @@ -959,7 +958,6 @@ xio_l_gmc_setup_forwarder( handle = ftp_handle->whos_my_daddy; - cast_count = 0; stack_str = malloc(max_str_len*3); /* 3x for url encoding */ stack_str_ndx = 0; for(i = 0; i < each_cast_count; i++) @@ -977,7 +975,6 @@ xio_l_gmc_setup_forwarder( stack_str_ndx += strlen(str); free(str); - cast_count++; } stack_str[stack_str_ndx] = '\0'; } @@ -1239,7 +1236,7 @@ xio_l_gridftp_multicast_write( globus_off_t offset; globus_bool_t finish_write = GLOBUS_FALSE; GlobusXIOName(xio_l_gridftp_multicast_write); - + handle = (xio_l_gridftp_multicast_handle_t *) driver_specific_handle; globus_mutex_lock(&handle->mutex); @@ -1253,8 +1250,8 @@ xio_l_gridftp_multicast_write( { ftp_handle = &handle->ftp_handles[i]; offset = handle->offset; - for(j = 0; - j < iovec_count && + for(j = 0; + j < iovec_count && ftp_handle->result == GLOBUS_SUCCESS; j++) { @@ -1403,7 +1400,7 @@ xio_l_gmc_close_cb( globus_bool_t finish_close = GLOBUS_FALSE; xio_l_gridftp_multicast_handle_t * handle; GlobusXIOName(xio_l_gmc_close_cb); - + handle = (xio_l_gridftp_multicast_handle_t *) user_arg; globus_mutex_lock(&handle->mutex); { @@ -1441,7 +1438,7 @@ xio_l_gridftp_multicast_close( xio_l_gmc_ftp_handle_t * ftp_handle; xio_l_gridftp_multicast_handle_t * handle; GlobusXIOName(xio_l_gridftp_multicast_close); - + handle = (xio_l_gridftp_multicast_handle_t *) driver_specific_handle; globus_mutex_lock(&handle->mutex); @@ -1503,7 +1500,7 @@ xio_l_gridftp_multicast_close( handle->op_count++; } break; - + case XIO_GMC_STATE_OPENING_ERROR: case XIO_GMC_STATE_OPENING: case XIO_GMC_STATE_CLOSING: @@ -1582,7 +1579,7 @@ xio_l_gridftp_multicast_attr_init( { xio_l_gridftp_multicast_attr_t * attr; - attr = (xio_l_gridftp_multicast_attr_t *) + attr = (xio_l_gridftp_multicast_attr_t *) globus_calloc(1, sizeof(xio_l_gridftp_multicast_attr_t)); globus_fifo_init(&attr->url_q); @@ -1591,14 +1588,14 @@ xio_l_gridftp_multicast_attr_init( attr->tcp_bs = xio_l_gmc_default_attr.tcp_bs; attr->cast_count = xio_l_gmc_default_attr.cast_count; attr->pass_write = xio_l_gmc_default_attr.pass_write; - + *out_attr = attr; return GLOBUS_SUCCESS; } -static globus_xio_string_cntl_table_t +static globus_xio_string_cntl_table_t xio_l_gridftp_multicast_string_opts_table[] = { {"P", GLOBUS_XIO_GRIDFTP_MULTICAST_ATTR_PARALLEL, @@ -1680,7 +1677,7 @@ xio_l_gridftp_multicast_attr_copy( { int i; char * str; - xio_l_gridftp_multicast_attr_t * dst_attr; + xio_l_gridftp_multicast_attr_t * dst_attr; xio_l_gridftp_multicast_attr_t * src_attr; src_attr = (xio_l_gridftp_multicast_attr_t *) src; diff --git a/gridftp/server/src/configure.ac b/gridftp/server/src/configure.ac index dd54e47989..826aeaa341 100644 --- a/gridftp/server/src/configure.ac +++ b/gridftp/server/src/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ([2.60]) -AC_INIT([globus_gridftp_server],[13.28],[https://github.com/gridcf/gct/issues]) +AC_INIT([globus_gridftp_server],[13.29],[https://github.com/gridcf/gct/issues]) AC_CONFIG_MACRO_DIR([m4]) AC_SUBST([MAJOR_VERSION], [${PACKAGE_VERSION%%.*}]) AC_SUBST([MINOR_VERSION], [${PACKAGE_VERSION##*.}]) diff --git a/gridftp/server/src/gfs_dynbe_client.c b/gridftp/server/src/gfs_dynbe_client.c index 62134e0a6c..09bee672ac 100644 --- a/gridftp/server/src/gfs_dynbe_client.c +++ b/gridftp/server/src/gfs_dynbe_client.c @@ -40,7 +40,7 @@ "%s", \ (error_msg))) -enum +enum { GLOBUS_DYNCLIENT_ERROR_PARM = 1 }; @@ -219,7 +219,7 @@ main( goto error_open; } result = globus_xio_write( - g_xio_handle, buffer, + g_xio_handle, buffer, GF_DYN_PACKET_LEN, GF_DYN_PACKET_LEN, &nbytes, NULL); if(result != GLOBUS_SUCCESS) { @@ -392,6 +392,7 @@ gfs_l_dynclient_opts_gsi( return GLOBUS_SUCCESS; } +static globus_options_entry_t gfork_l_opts_table[] = { {"quiet", "q", NULL, NULL, diff --git a/gridftp/server/src/gfs_gfork_master.c b/gridftp/server/src/gfs_gfork_master.c index ac49e7d247..b22ae6f948 100644 --- a/gridftp/server/src/gfs_gfork_master.c +++ b/gridftp/server/src/gfs_gfork_master.c @@ -17,7 +17,7 @@ /* This is ment to be a fairly simple program. If it starts creeping too much we need to reconsider it */ -/* TODO: +/* TODO: 1) memory limitation, perhaps just implemented in brain based on connection count? @@ -50,7 +50,7 @@ #define GFSGForkFuncName(func) static const char * _gfs_gfork_func_name = #func #endif -#define GFSGforkTopNiceShare(_val) ((_val * 9) / 10) +#define GFSGforkTopNiceShare(_val) ((_val * 9) / 10) #define GFSGforkSizeOfIdleServer (2*1024*1024) @@ -138,7 +138,7 @@ typedef struct gfs_l_gfork_master_entry_s static -void +void gfs_l_gfork_write_close_cb( globus_xio_handle_t handle, globus_result_t result, @@ -178,7 +178,7 @@ gfs_l_gfork_log( fflush(g_log_fptr); } -static +static void gfs_l_gfork_timeout( void * user_arg) @@ -404,7 +404,7 @@ gfs_l_gfork_read_dynbe_bc_cb( int i; for(i = 0; i < count; i++) - { + { globus_free(iovec[i].iov_base); } } @@ -483,7 +483,7 @@ gfs_l_gfork_read_dynbe( &g_gfork_be_table, table_key); if(ent_buf == NULL) { - ent_buf = (gfs_l_gfork_master_entry_t *) + ent_buf = (gfs_l_gfork_master_entry_t *) globus_calloc(1, sizeof(gfs_l_gfork_master_entry_t)); memcpy(ent_buf->buffer, buffer, GF_DYN_PACKET_LEN); @@ -527,7 +527,7 @@ gfs_l_gfork_read_dynbe( gfs_l_gfork_write_close_cb, buffer); globus_free(buffer); - goto error_cs; + goto error_cs; } iov[0].iov_base = malloc(GF_DYN_PACKET_LEN); memcpy(iov[0].iov_base, buffer, GF_DYN_PACKET_LEN); @@ -882,7 +882,7 @@ gfs_l_gfork_dyn_be_open( { /* a good buffer */ - /* temparily assign ent_buf here, we ultimatale + /* temparily assign ent_buf here, we ultimatale want ent_buf-> buffer */ iov[i].iov_base = ent_buf; iov[i].iov_len = GF_DYN_PACKET_LEN; @@ -1033,6 +1033,7 @@ gfs_l_gfork_mem_limit_send( } } +/* static void gfs_l_gfork_kill_send( @@ -1069,6 +1070,7 @@ gfs_l_gfork_kill_send( result, 3, "failed to send kill to %d\n", to_pid); } } +*/ static void @@ -1112,7 +1114,7 @@ gfs_l_gfork_ready_send( handle, to_pid, &iov, - 1, + 1, gfs_l_gfork_free_write_cb, NULL); if(result != GLOBUS_SUCCESS) @@ -1121,7 +1123,7 @@ gfs_l_gfork_ready_send( result, 3, "failed to send to %d\n", to_pid); } } - + static void gfs_l_gfork_mem_try( @@ -1166,7 +1168,7 @@ gfs_l_gfork_mem_try( entry->mem_size += mem_given; entry->tcp_buffer_mem = mem_given / 3; - + globus_hashtable_insert( &gfs_l_memlimit_table, (void *) (intptr_t) entry->pid, entry); @@ -1176,6 +1178,7 @@ gfs_l_gfork_mem_try( } } +/* static void gfs_l_gfork_mem_try_cb( @@ -1194,6 +1197,7 @@ gfs_l_gfork_mem_try_cb( } globus_mutex_unlock(&g_mutex); } +*/ static void @@ -1348,7 +1352,7 @@ gfs_l_gfork_incoming_cb( { if(buffer[GF_VERSION_NDX] != GF_VERSION) { - gfs_l_gfork_log(GLOBUS_SUCCESS, 0, + gfs_l_gfork_log(GLOBUS_SUCCESS, 0, "Incoming message with bad version, ignoring."); goto error; } @@ -1357,7 +1361,7 @@ gfs_l_gfork_incoming_cb( &gfs_l_memlimit_table, (void *) (intptr_t) from_pid); if(entry == NULL) { - gfs_l_gfork_log(GLOBUS_SUCCESS, 0, + gfs_l_gfork_log(GLOBUS_SUCCESS, 0, "Incoming message from unknown pid %d", from_pid); goto error; } @@ -1366,11 +1370,11 @@ gfs_l_gfork_incoming_cb( { case GFS_GFORK_MSG_TYPE_RELEASE: - memcpy(&tmp32, + memcpy(&tmp32, &buffer[GF_RELEASE_COUNT_NDX], GF_RELEASE_COUNT_LEN); if(tmp32 > 0) { - gfs_l_gfork_log(GLOBUS_SUCCESS, 0, + gfs_l_gfork_log(GLOBUS_SUCCESS, 0, "Pid %d returning %d bytes.\n", from_pid, (int)tmp32); diff = entry->tcp_buffer_mem - tmp32; @@ -1726,7 +1730,7 @@ main( g_done = GLOBUS_FALSE; globus_hashtable_init( - &g_gfork_be_table, + &g_gfork_be_table, 256, globus_hashtable_string_hash, globus_hashtable_string_keyeq); @@ -2008,7 +2012,7 @@ gfs_l_gfork_opts_updatetime( char ** opt, void * arg, int * out_parms_used) -{ +{ globus_result_t result; int sc; int tm; @@ -2107,7 +2111,7 @@ gfs_l_gfork_opts_nice_share( char ** opt, void * arg, int * out_parms_used) -{ +{ globus_result_t result; int sc; int n; @@ -2120,18 +2124,19 @@ gfs_l_gfork_opts_nice_share( GFS_GFORK_ERROR_PARAMETER); goto error_format; } - + gfs_l_gfork_nice_share_count = n; *out_parms_used = 1; - + return GLOBUS_SUCCESS; error_format: return result; - + } +static globus_options_entry_t gfork_l_opts_table[] = { {"help", "h", NULL, NULL, @@ -2204,7 +2209,7 @@ gfs_gfork_master_options( globus_result_t result; int sc; char * env_s; - + GFSGForkFuncName(gfs_gfork_master_options); globus_options_init( diff --git a/gridftp/server/src/globus_i_gfs_config.c b/gridftp/server/src/globus_i_gfs_config.c index d5ee9a9a70..0f1a5356b2 100644 --- a/gridftp/server/src/globus_i_gfs_config.c +++ b/gridftp/server/src/globus_i_gfs_config.c @@ -103,8 +103,8 @@ typedef struct static globus_mutex_t globus_i_gfs_config_mutex; -static const globus_l_gfs_config_option_t option_list[] = -{ +static const globus_l_gfs_config_option_t option_list[] = +{ {NULL, "Informational Options", NULL, NULL, NULL, 0, 0, NULL, NULL, NULL, NULL, GLOBUS_FALSE, NULL}, {"help", "help", NULL, "help", "h", GLOBUS_L_GFS_CONFIG_BOOL, GLOBUS_FALSE, NULL, "Show usage information and exit.", NULL, NULL,GLOBUS_FALSE, NULL}, @@ -133,7 +133,7 @@ static const globus_l_gfs_config_option_t option_list[] = "Directory to chdir to after starting. Will use / if not set. Note that this is the " "directory of the process, not the client's home directory.", NULL, NULL,GLOBUS_FALSE, NULL}, {"threads", "threads", NULL, "threads", NULL, GLOBUS_L_GFS_CONFIG_INT, 0, NULL, - "Enable threaded operation and set the number of threads. The default is 0, which " + "Enable threaded operation and set the number of threads. The default is 0, which " "is non-threaded. When threading is required, a thread count of 1 or 2 should " "be sufficient.", NULL, NULL, GLOBUS_TRUE, NULL}, {"fork", "fork", NULL, "fork", "f", GLOBUS_L_GFS_CONFIG_BOOL, GLOBUS_TRUE, NULL, @@ -142,9 +142,9 @@ static const globus_l_gfs_config_option_t option_list[] = "accept a single connection, and then exit.", NULL, NULL,GLOBUS_FALSE, NULL}, {"fork_fallback", "fork_fallback", NULL, "fork-fallback", NULL, GLOBUS_L_GFS_CONFIG_BOOL, GLOBUS_FALSE, NULL, NULL /* attempt to run non-forked if fork fails */, NULL, NULL, GLOBUS_FALSE, NULL}, - {"single", "single", NULL, "single", "1", GLOBUS_L_GFS_CONFIG_BOOL, GLOBUS_FALSE, NULL, + {"single", "single", NULL, "single", "1", GLOBUS_L_GFS_CONFIG_BOOL, GLOBUS_FALSE, NULL, "Exit after a single connection.", NULL, NULL,GLOBUS_FALSE, NULL}, - {"chroot_path", "chroot_path", NULL, "chroot-path", NULL, GLOBUS_L_GFS_CONFIG_STRING, 0, NULL, + {"chroot_path", "chroot_path", NULL, "chroot-path", NULL, GLOBUS_L_GFS_CONFIG_STRING, 0, NULL, "Path to become the new root after authentication. This path must contain a valid " "certificate structure, /etc/passwd, and /etc/group. The command " "globus-gridftp-server-setup-chroot can help create a suitable directory structure.", NULL, NULL,GLOBUS_FALSE, NULL}, @@ -282,7 +282,7 @@ static const globus_l_gfs_config_option_t option_list[] = "replaced by the authenticated user's home directory, or the '-home-dir' option, if used. " "Note that if the home directory is not accessible, '~' will be set to '/'. " "By default all paths are allowed, and access control is handled by the OS. " - "In a striped or split process configuration, this should be set on both the frontend and data nodes.", + "In a striped or split process configuration, this should be set on both the frontend and data nodes.", NULL, NULL,GLOBUS_FALSE, NULL}, {"rp_follow_symlinks", "rp_follow_symlinks", NULL, "rp-follow-symlinks", NULL, GLOBUS_L_GFS_CONFIG_BOOL, GLOBUS_FALSE, NULL, "Do not verify that a symlink points to an allowed path before following. By default, symlinks are " @@ -290,7 +290,7 @@ static const globus_l_gfs_config_option_t option_list[] = "will be followed even if they point to a path that is otherwise restricted.", NULL, NULL,GLOBUS_FALSE, NULL}, {"acl", "acl", NULL, "acl", "em", GLOBUS_L_GFS_CONFIG_STRING, 0, NULL, "A comma separated list of ACL or event modules to load.", - NULL, NULL,GLOBUS_FALSE, NULL}, + NULL, NULL,GLOBUS_FALSE, NULL}, {NULL, "Logging Options", NULL, NULL, NULL, 0, 0, NULL, NULL, NULL, NULL,GLOBUS_FALSE, NULL}, {"log_level", "log_level", NULL, "log-level", "d", GLOBUS_L_GFS_CONFIG_STRING, 0, "ERROR", "Log level. A comma separated list of levels from: 'ERROR, WARN, INFO, TRANSFER, DUMP, ALL'. " @@ -426,7 +426,7 @@ static const globus_l_gfs_config_option_t option_list[] = "to unauthenticated clients.", NULL, NULL,GLOBUS_FALSE, NULL}, {"banner_append", "banner_append", NULL, "banner-append", NULL, GLOBUS_L_GFS_CONFIG_BOOL, GLOBUS_FALSE, NULL, "When this is set, the message set in the 'banner' or 'banner_file' option " - "will be appended to the default banner message rather than replacing it.", + "will be appended to the default banner message rather than replacing it.", NULL, NULL,GLOBUS_FALSE, NULL}, {"version_tag", "version_tag", NULL, "version-tag", NULL, GLOBUS_L_GFS_CONFIG_STRING, 0, NULL, "Add an identifying string to the existing toolkit version. This is displayed in the default " @@ -439,12 +439,12 @@ static const globus_l_gfs_config_option_t option_list[] = {"load_dsi_module", "load_dsi_module", NULL, "dsi", NULL, GLOBUS_L_GFS_CONFIG_STRING, 0, NULL, "Data Storage Interface module to load. File and remote modules are defined by the server. " "If not set, the file module is loaded, unless the 'remote' option is specified, in which case the remote " - "module is loaded. An additional configuration string can be passed to the DSI using the format " + "module is loaded. An additional configuration string can be passed to the DSI using the format " "[module name]:[configuration string] to this option. The format of the configuration " "string is defined by the DSI being loaded.", NULL, NULL,GLOBUS_FALSE, NULL}, {"allowed_modules", "allowed_modules", NULL, "allowed-modules", NULL, GLOBUS_L_GFS_CONFIG_STRING, 0, NULL, "Comma separated list of ERET/ESTO modules to allow, and optionally specify an alias for. " - "Example: module1,alias2:module2,module3 (module2 will be loaded when a client asks for alias2).", NULL, NULL,GLOBUS_FALSE, NULL}, + "Example: module1,alias2:module2,module3 (module2 will be loaded when a client asks for alias2).", NULL, NULL,GLOBUS_FALSE, NULL}, {"dc_whitelist", "dc_whitelist", NULL, "dc-whitelist", NULL, GLOBUS_L_GFS_CONFIG_STRING, 0, NULL, "A comma separated list of drivers allowed on the network stack.", NULL, NULL,GLOBUS_FALSE, NULL}, {"fs_whitelist", "fs_whitelist", NULL, "fs-whitelist", NULL, GLOBUS_L_GFS_CONFIG_STRING, 0, NULL, @@ -484,7 +484,7 @@ static const globus_l_gfs_config_option_t option_list[] = "Sets options that make server easier to debug. Forces no-fork, no-chdir, " "and allows core dumps on bad signals instead of exiting cleanly. " "Not recommended for production servers. Note that non-forked servers running " - "as 'root' will only accept a single connection, and then exit.", NULL, NULL,GLOBUS_FALSE, NULL}, + "as 'root' will only accept a single connection, and then exit.", NULL, NULL,GLOBUS_FALSE, NULL}, {"pidfile", "pidfile", NULL, "pidfile", NULL, GLOBUS_L_GFS_CONFIG_STRING, 0, NULL, "Write PID of the GridFTP server to this path. May contain variable references to ${localstatedir}", NULL, NULL, GLOBUS_FALSE, NULL}, @@ -498,7 +498,7 @@ static const globus_l_gfs_config_option_t option_list[] = {"slow_dirlist", "slow_dirlist", NULL, NULL, NULL, GLOBUS_L_GFS_CONFIG_INT, 0, NULL, NULL, NULL, NULL,GLOBUS_FALSE, NULL}, /* fake stat responses on dirs with more than this many entries */ {"checksum_throttle", "checksum_throttle", NULL, NULL, NULL, GLOBUS_L_GFS_CONFIG_INT, 0, NULL, - NULL, NULL, NULL,GLOBUS_FALSE, NULL}, /* delay checksum reads by this many microseconds per blocksize'd read, + NULL, NULL, NULL,GLOBUS_FALSE, NULL}, /* delay checksum reads by this many microseconds per blocksize'd read, * effectively setting a floor on the checksum rate to size/blocksize*delay per size */ {"test_acl", NULL, NULL, NULL, "testacl", GLOBUS_L_GFS_CONFIG_STRING, 0, NULL, NULL /* load and pass arguments to the test acl module. the string @@ -554,13 +554,13 @@ static const globus_l_gfs_config_option_t option_list[] = NULL /* Data node connection count. */, NULL, NULL, GLOBUS_TRUE, NULL}, {"tcp_mem_limit", NULL, NULL, NULL, NULL, GLOBUS_L_GFS_CONFIG_INT, 0, NULL, NULL /* TCP memory limit */, NULL, NULL, GLOBUS_TRUE, NULL}, - {"max_bw", NULL, NULL, NULL, NULL, GLOBUS_L_GFS_CONFIG_INT, 0, NULL, + {"max_bw", NULL, NULL, NULL, NULL, GLOBUS_L_GFS_CONFIG_INT, 0, NULL, NULL, NULL, NULL, GLOBUS_TRUE, NULL}, - {"current_bw", NULL, NULL, NULL, NULL, GLOBUS_L_GFS_CONFIG_INT, 0, NULL, + {"current_bw", NULL, NULL, NULL, NULL, GLOBUS_L_GFS_CONFIG_INT, 0, NULL, NULL, NULL, NULL, GLOBUS_TRUE, NULL}, {"file_transfer_count", NULL, NULL, NULL, NULL, GLOBUS_L_GFS_CONFIG_INT, 0, NULL, NULL, NULL, NULL, GLOBUS_TRUE, NULL}, - {"byte_transfer_count", NULL, NULL, NULL, NULL, GLOBUS_L_GFS_CONFIG_STRING, 0, NULL, + {"byte_transfer_count", NULL, NULL, NULL, NULL, GLOBUS_L_GFS_CONFIG_STRING, 0, NULL, NULL, NULL, NULL, GLOBUS_TRUE, NULL}, {NULL, /* END */ NULL, NULL, NULL, NULL, 0, 0, NULL, NULL, NULL, NULL,GLOBUS_FALSE, NULL} }; @@ -573,7 +573,7 @@ static char * globus_l_gfs_port_range = NULL; static globus_bool_t globus_l_gfs_common_loaded = GLOBUS_FALSE; static globus_bool_t globus_l_gfs_is_worker = GLOBUS_FALSE; -/* for string options, setting with an int_val of 1 will free the old one */ +/* for string options, setting with an int_val of 1 will free the old one */ static int globus_l_gfs_config_set( @@ -583,24 +583,24 @@ globus_l_gfs_config_set( { globus_l_gfs_config_option_t * option; int i; - int rc; + int rc; GlobusGFSName(globus_l_gfs_config_set); GlobusGFSDebugEnter(); option = (globus_l_gfs_config_option_t *) globus_hashtable_remove( - &option_table, option_name); + &option_table, option_name); if(!option) { option = (globus_l_gfs_config_option_t *) globus_calloc(1, sizeof(globus_l_gfs_config_option_t)); - for(i = 0; + for(i = 0; i < option_count && option_list[i].option_name && - strcmp(option_name, option_list[i].option_name); + strcmp(option_name, option_list[i].option_name); i++); if(i == option_count) { goto error; - } + } memcpy(option, &option_list[i], sizeof(globus_l_gfs_config_option_t)); } switch(option->type) @@ -636,7 +636,7 @@ globus_l_gfs_config_set( error: globus_free(option); GlobusGFSDebugExitWithError(); - return 1; + return 1; } #define GLOBUS_L_GFS_LINEBUFLEN 1024 @@ -668,7 +668,7 @@ globus_l_gfs_config_load_config_file( GlobusGFSDebugExitWithError(); return -2; /* XXX construct real error */ } - globus_l_gfs_config_set("loaded_config", 0, globus_libc_strdup(filename)); + globus_l_gfs_config_set("loaded_config", 0, globus_libc_strdup(filename)); line_num = 0; linebuf = globus_malloc(linebuflen); @@ -686,7 +686,7 @@ globus_l_gfs_config_load_config_file( { goto error_mem; } - + while(fgets(linebuf, linebuflen, fptr) != NULL) { p = linebuf; @@ -704,7 +704,7 @@ globus_l_gfs_config_load_config_file( goto error_mem; } strncat(linebuf, part_line, linebuflen); - + optionbuf = globus_realloc(optionbuf, linebuflen); if(!optionbuf) { @@ -719,7 +719,7 @@ globus_l_gfs_config_load_config_file( } line_num++; p = linebuf; - optlen = 0; + optlen = 0; while(*p && isspace(*p)) { p++; @@ -731,11 +731,11 @@ globus_l_gfs_config_load_config_file( if(*p == '#') { continue; - } + } if(*p == '$') { continue; - } + } if(*p == '"') { @@ -745,14 +745,14 @@ globus_l_gfs_config_load_config_file( else { rc = sscanf(p, "%s", optionbuf); - } + } if(rc != 1) - { + { goto error_parse; } optlen += strlen(optionbuf); p = p + optlen; - + optlen = 0; while(*p && isspace(*p)) { @@ -766,13 +766,13 @@ globus_l_gfs_config_load_config_file( else { rc = sscanf(p, "%s", valuebuf); - } + } if(rc != 1) - { + { goto error_parse; - } + } optlen += strlen(valuebuf); - p = p + optlen; + p = p + optlen; while(*p && isspace(*p)) { p++; @@ -781,7 +781,7 @@ globus_l_gfs_config_load_config_file( { goto error_parse; } - + found = GLOBUS_FALSE; for(i = 0; !found && i < option_count; i++) { @@ -789,16 +789,16 @@ globus_l_gfs_config_load_config_file( { continue; } - if(!option_list[i].configfile_option || + if(!option_list[i].configfile_option || strcmp(optionbuf, option_list[i].configfile_option)) { continue; } - + found = GLOBUS_TRUE; - + option = (globus_l_gfs_config_option_t *) globus_hashtable_remove( - &option_table, option_list[i].option_name); + &option_table, option_list[i].option_name); if(!option) { option = (globus_l_gfs_config_option_t *) @@ -818,19 +818,19 @@ globus_l_gfs_config_load_config_file( } else { - globus_gfs_log_exit_message("Value for %s must be 0 or 1.\n", + globus_gfs_log_exit_message("Value for %s must be 0 or 1.\n", option_list[i].option_name); goto error_parse; - } + } break; case GLOBUS_L_GFS_CONFIG_INT: rc = globus_args_bytestr_to_num(valuebuf, &tmp_off); if(rc != 0) { - globus_gfs_log_exit_message("Invalid value for %s\n", + globus_gfs_log_exit_message("Invalid value for %s\n", option_list[i].option_name); goto error_parse; - } + } option->int_value = (int) tmp_off; break; case GLOBUS_L_GFS_CONFIG_STRING: @@ -842,7 +842,7 @@ globus_l_gfs_config_load_config_file( rc = globus_hashtable_insert(&option_table, option->option_name, (void *) option); - + if(rc) { /* XXX error, log something */ @@ -851,24 +851,24 @@ globus_l_gfs_config_load_config_file( if(!found) { globus_gfs_log_exit_message("Problem parsing config file %s: line %d. " - "Unknown option '%s'.\n", + "Unknown option '%s'.\n", filename, line_num, optionbuf); goto error_param; } } fclose(fptr); - + globus_free(linebuf); globus_free(valuebuf); globus_free(optionbuf); - + GlobusGFSDebugExit(); return GLOBUS_SUCCESS; error_parse: fclose(fptr); - globus_gfs_log_exit_message("Problem parsing config file %s: line %d.\n", + globus_gfs_log_exit_message("Problem parsing config file %s: line %d.\n", filename, line_num); error_param: error_mem: @@ -878,9 +878,9 @@ globus_l_gfs_config_load_config_file( } -/* handle options needed before module inits. +/* handle options needed before module inits. no return - errors get caught on next pass */ -static +static void globus_l_gfs_config_parse_preinit_opt( char * line, @@ -889,15 +889,15 @@ globus_l_gfs_config_parse_preinit_opt( { int rc; char * p = line; - + if((rc = sscanf(p, "%s", optionbuf)) == 1) { - if(!globus_l_gfs_is_worker && + if(!globus_l_gfs_is_worker && (!strcmp(optionbuf, "inetd") || !strcmp(optionbuf, "debug") || !strcmp(optionbuf, "ssh") || !strcmp(optionbuf, "fork"))) { p = p + strlen(optionbuf); - + while(*p && isspace(*p)) { p++; @@ -909,7 +909,7 @@ globus_l_gfs_config_parse_preinit_opt( else { rc = sscanf(p, "%s", valuebuf); - } + } if(rc == 1) { globus_l_gfs_is_worker = atoi(valuebuf); @@ -922,7 +922,7 @@ globus_l_gfs_config_parse_preinit_opt( if(globus_l_gfs_num_threads == -1 && !strcmp(optionbuf, "threads")) { p = p + strlen(optionbuf); - + while(*p && isspace(*p)) { p++; @@ -934,7 +934,7 @@ globus_l_gfs_config_parse_preinit_opt( else { rc = sscanf(p, "%s", valuebuf); - } + } if(rc == 1) { globus_l_gfs_num_threads = atoi(valuebuf); @@ -943,7 +943,7 @@ globus_l_gfs_config_parse_preinit_opt( if(!globus_l_gfs_port_range && !strcmp(optionbuf, "port_range")) { p = p + strlen(optionbuf); - + while(*p && isspace(*p)) { p++; @@ -955,7 +955,7 @@ globus_l_gfs_config_parse_preinit_opt( else { rc = sscanf(p, "%s", valuebuf); - } + } if(rc == 1) { setenv("GLOBUS_TCP_PORT_RANGE", valuebuf, 1); @@ -1022,7 +1022,7 @@ globus_l_gfs_config_load_envs_from_file( goto error_mem; } strncat(linebuf, part_line, linebuflen); - + optionbuf = realloc(optionbuf, linebuflen); if(!optionbuf) { @@ -1037,12 +1037,12 @@ globus_l_gfs_config_load_envs_from_file( } line_num++; p = linebuf; - optlen = 0; + optlen = 0; while(*p && isspace(*p)) { p++; } - + /* parse some non-env options */ if(*p != '$') { @@ -1050,15 +1050,15 @@ globus_l_gfs_config_load_envs_from_file( continue; } p++; - + rc = sscanf(p, "%s", optionbuf); if(rc != 1) - { + { goto error_parse; } optlen += strlen(optionbuf); p = p + optlen; - + optlen = 0; while(*p && isspace(*p)) { @@ -1072,13 +1072,13 @@ globus_l_gfs_config_load_envs_from_file( else { rc = sscanf(p, "%s", valuebuf); - } + } if(rc != 1) - { + { goto error_parse; - } + } optlen += strlen(valuebuf); - p = p + optlen; + p = p + optlen; while(*p && isspace(*p)) { p++; @@ -1087,14 +1087,14 @@ globus_l_gfs_config_load_envs_from_file( { goto error_parse; } - + rc = globus_libc_setenv(optionbuf, valuebuf, 1); if(rc < 0) { char errstr[PATH_MAX]; snprintf( errstr, PATH_MAX, - "Problem loading environment from config file %s: line %d.\n", + "Problem loading environment from config file %s: line %d.\n", filename, line_num); perror(errstr); } @@ -1105,20 +1105,20 @@ globus_l_gfs_config_load_envs_from_file( free(linebuf); free(valuebuf); free(optionbuf); - + return 0; error_parse: if(globus_l_gfs_common_loaded) { - globus_gfs_log_exit_message("Problem parsing environment from config file %s: line %d.\n", + globus_gfs_log_exit_message("Problem parsing environment from config file %s: line %d.\n", filename, line_num); } else { fprintf( stderr, - "Problem parsing environment from config file %s: line %d. \n", + "Problem parsing environment from config file %s: line %d. \n", filename, line_num); } @@ -1205,7 +1205,7 @@ globus_l_gfs_config_load_config_dir( } } result = globus_l_gfs_config_load_envs_from_file(full_path); - + free(entries[i]); free(full_path); } @@ -1233,7 +1233,7 @@ globus_l_gfs_config_load_config_env() globus_off_t tmp_off; GlobusGFSName(globus_l_gfs_config_load_config_env); GlobusGFSDebugEnter(); - + for(i = 0; i < option_count; i++) { @@ -1247,14 +1247,14 @@ globus_l_gfs_config_load_config_env() } value = getenv(option_list[i].env_var_option); - + if (!value) { continue; } - + option = (globus_l_gfs_config_option_t *) globus_hashtable_remove( - &option_table, option_list[i].option_name); + &option_table, option_list[i].option_name); if(!option) { option = (globus_l_gfs_config_option_t *) @@ -1275,10 +1275,10 @@ globus_l_gfs_config_load_config_env() } else { - globus_gfs_log_exit_message("Value for %s must be 0 or 1.\n", + globus_gfs_log_exit_message("Value for %s must be 0 or 1.\n", option_list[i].option_name); return -1; - } + } break; case GLOBUS_L_GFS_CONFIG_INT: rc = globus_args_bytestr_to_num(value, &tmp_off); @@ -1288,10 +1288,10 @@ globus_l_gfs_config_load_config_env() { free(option); } - globus_gfs_log_exit_message("Invalid value for %s\n", + globus_gfs_log_exit_message("Invalid value for %s\n", option_list[i].option_name); return -1; - } + } option->int_value = (int) tmp_off; break; case GLOBUS_L_GFS_CONFIG_STRING: @@ -1303,12 +1303,12 @@ globus_l_gfs_config_load_config_env() rc = globus_hashtable_insert(&option_table, option->option_name, (void *) option); - + if(rc) { /* XXX error, log something */ } - } + } GlobusGFSDebugExit(); return GLOBUS_SUCCESS; @@ -1333,7 +1333,7 @@ globus_l_gfs_config_load_commandline( globus_off_t tmp_off; GlobusGFSName(globus_l_gfs_config_load_commandline); GlobusGFSDebugEnter(); - + for(arg_num = 1; arg_num < argc; ++arg_num) { found = GLOBUS_FALSE; @@ -1341,7 +1341,7 @@ globus_l_gfs_config_load_commandline( argp = argv[arg_num]; len = strlen(argp); - + if(len && *argp == '-') { argp++; @@ -1364,25 +1364,25 @@ globus_l_gfs_config_load_commandline( len--; negate = GLOBUS_TRUE; } - + for(i = 0; i < option_count && !found && len; i++) { if(option_list[i].option_name == NULL) { continue; } - if((!option_list[i].short_cmdline_option || - strcmp(argp, option_list[i].short_cmdline_option)) && - (!option_list[i].long_cmdline_option || + if((!option_list[i].short_cmdline_option || + strcmp(argp, option_list[i].short_cmdline_option)) && + (!option_list[i].long_cmdline_option || strcmp(argp, option_list[i].long_cmdline_option)) ) { continue; } - + found = GLOBUS_TRUE; - + option = (globus_l_gfs_config_option_t *) globus_hashtable_remove( - &option_table, option_list[i].option_name); + &option_table, option_list[i].option_name); if(!option) { opt_is_new = GLOBUS_TRUE; @@ -1419,10 +1419,10 @@ globus_l_gfs_config_load_commandline( } globus_gfs_log_exit_message("Invalid value for %s\n", argp); return -1; - } + } option->int_value = (int) tmp_off; break; - + case GLOBUS_L_GFS_CONFIG_STRING: if(++arg_num >= argc) { @@ -1443,14 +1443,14 @@ globus_l_gfs_config_load_commandline( rc = globus_hashtable_insert(&option_table, option->option_name, (void *) option); - + if(rc) { /* XXX error, log something */ } - + } - + if(!found) { if(opt_is_new) @@ -1462,7 +1462,7 @@ globus_l_gfs_config_load_commandline( return -1; } } - + GlobusGFSDebugExit(); return GLOBUS_SUCCESS; @@ -1478,9 +1478,9 @@ globus_l_gfs_config_load_defaults() globus_l_gfs_config_option_t * option; GlobusGFSName(globus_l_gfs_config_load_defaults); GlobusGFSDebugEnter(); - + for(i = 0; i < option_count; i++) - { + { if(option_list[i].option_name == NULL) { continue; @@ -1488,11 +1488,11 @@ globus_l_gfs_config_load_defaults() option = (globus_l_gfs_config_option_t *) globus_malloc(sizeof(globus_l_gfs_config_option_t)); memcpy(option, &option_list[i], sizeof(globus_l_gfs_config_option_t)); - - rc = globus_hashtable_insert(&option_table, - option->option_name, + + rc = globus_hashtable_insert(&option_table, + option->option_name, (void *) option); - + if(rc) { /* XXX error, log something */ @@ -1500,7 +1500,7 @@ globus_l_gfs_config_load_defaults() } GlobusGFSDebugExit(); - return GLOBUS_SUCCESS; + return GLOBUS_SUCCESS; } static @@ -1514,18 +1514,18 @@ globus_l_config_loadfile( char * out_buf; GlobusGFSName(globus_l_config_loadfile); GlobusGFSDebugEnter(); - + file = fopen(filename, "r"); if(!file) { goto error; } - + fseek(file, 0L, SEEK_END); file_len = ftell(file); - fseek(file, 0L, SEEK_SET); + fseek(file, 0L, SEEK_SET); - out_buf = (char *) malloc((file_len + 1) * sizeof(char)); + out_buf = (char *) malloc((file_len + 1) * sizeof(char)); if(!out_buf) { fclose(file); @@ -1537,7 +1537,7 @@ globus_l_config_loadfile( out_buf[file_len] = '\0'; *data_out = out_buf; - + GlobusGFSDebugExit(); return 0; @@ -1554,18 +1554,18 @@ globus_l_gfs_config_display_html_usage() globus_l_gfs_config_option_t * o; GlobusGFSName(globus_l_gfs_config_display_html_usage); GlobusGFSDebugEnter(); - + printf("\n"); printf("

\n" - "The table below lists config file options, associated command line " + "The table below lists config file options, associated command line " "options (if available) and descriptions. Note that any boolean " - "option can be negated on the command line by preceding the specified " + "option can be negated on the command line by preceding the specified " "option with '-no-' or '-n'. Example: -no-cas or -nf.\n" "

\n"); printf("
    \n"); for(i = 0; i < option_count; i++) - { + { o = (globus_l_gfs_config_option_t *) &option_list[i]; if(o->option_name == NULL && o->configfile_option != NULL) { @@ -1579,12 +1579,12 @@ globus_l_gfs_config_display_html_usage() printf("\n"); for(i = 0; i < option_count; i++) - { + { char * shortflag; char * longflag; char * value; char * defval; - + o = (globus_l_gfs_config_option_t *) &option_list[i]; if(o->option_name == NULL && o->configfile_option != NULL) { @@ -1606,26 +1606,26 @@ globus_l_gfs_config_display_html_usage() case GLOBUS_L_GFS_CONFIG_BOOL: shortflag = "-"; longflag = "-"; - value = " <0|1>"; + value = " <0|1>"; defval = o->int_value ? "TRUE" : "FALSE"; break; case GLOBUS_L_GFS_CONFIG_INT: shortflag = "-"; longflag = "-"; - value = " <number>"; - defval = o->int_value > 0 ? + value = " <number>"; + defval = o->int_value > 0 ? globus_common_create_string("%d", o->int_value) : "not set"; break; case GLOBUS_L_GFS_CONFIG_STRING: shortflag = "-"; longflag = "-"; - value = " <string>"; + value = " <string>"; defval = o->value ? o->value : "not set"; break; default: shortflag = ""; longflag = ""; - value = ""; + value = ""; defval = o->value ? o->value : "not set"; break; } @@ -1638,17 +1638,17 @@ globus_l_gfs_config_display_html_usage() "
    \n" " \n" "

    %s

    Default value: %s

    \n" - " \n", - o->configfile_option, + " \n", + o->configfile_option, value, - o->short_cmdline_option ? shortflag : "", + o->short_cmdline_option ? shortflag : "", o->short_cmdline_option ? o->short_cmdline_option : "", - o->type != GLOBUS_L_GFS_CONFIG_BOOL && + o->type != GLOBUS_L_GFS_CONFIG_BOOL && o->short_cmdline_option ? value : "", - o->short_cmdline_option ? "\n" : "", + o->short_cmdline_option ? "\n" : "", o->long_cmdline_option ? longflag : "", o->long_cmdline_option ? o->long_cmdline_option : "", - o->type != GLOBUS_L_GFS_CONFIG_BOOL && + o->type != GLOBUS_L_GFS_CONFIG_BOOL && o->long_cmdline_option ? value : "", o->usage, defval); @@ -1680,7 +1680,7 @@ globus_l_gfs_config_display_wsdl() out = stdout; } for(i = 0; i < option_count; i++) - { + { o = (globus_l_gfs_config_option_t *) &option_list[i]; if(o->option_name != NULL && o->public) { @@ -1709,7 +1709,7 @@ globus_l_gfs_config_display_wsdl() fprintf(out, " \n"); for(i = 0; i < option_count; i++) - { + { o = (globus_l_gfs_config_option_t *) &option_list[i]; if(o->option_name != NULL && o->public) { @@ -1750,7 +1750,7 @@ globus_l_gfs_config_display_c_service() globus_bool_t close = GLOBUS_TRUE; char * c_file; GlobusGFSDebugEnter(); - + c_file = globus_common_create_string("%s.c", globus_i_gfs_config_string("wsdl")); out = fopen(c_file, "w"); @@ -1760,7 +1760,7 @@ globus_l_gfs_config_display_c_service() out = stdout; } for(i = 0; i < option_count; i++) - { + { o = (globus_l_gfs_config_option_t *) &option_list[i]; if(o->option_name != NULL && o->public) { @@ -1787,7 +1787,7 @@ globus_l_gfs_config_display_c_service() fprintf(out, " globus_result_t result;\n"); fprintf(out, " globus_i_gfs_config_option_cb_ent_t * cb_handle;\n"); for(i = 0; i < option_count; i++) - { + { o = (globus_l_gfs_config_option_t *) &option_list[i]; if(o->option_name != NULL && o->public) { @@ -1867,7 +1867,7 @@ globus_l_gfs_config_display_docbook_usage() globus_l_gfs_config_option_t * o; GlobusGFSName(globus_l_gfs_config_display_docbook_usage); GlobusGFSDebugEnter(); - + printf("\n"); printf("\n" "The list below contains the command-line options for the server, " @@ -1879,10 +1879,10 @@ globus_l_gfs_config_display_docbook_usage() "\n"); for(i = 0; i < option_count; i++) - { + { char * value; char * defval; - + o = (globus_l_gfs_config_option_t *) &option_list[i]; if(o->option_name == NULL && o->configfile_option != NULL) { @@ -1911,8 +1911,8 @@ globus_l_gfs_config_display_docbook_usage() defval = o->int_value ? "TRUE" : "FALSE"; break; case GLOBUS_L_GFS_CONFIG_INT: - value = "number"; - defval = o->int_value > 0 ? + value = "number"; + defval = o->int_value > 0 ? globus_common_create_string("%d", o->int_value) : NULL; break; case GLOBUS_L_GFS_CONFIG_STRING: @@ -1920,11 +1920,11 @@ globus_l_gfs_config_display_docbook_usage() defval = o->value ? o->value : NULL; break; default: - value = ""; + value = ""; defval = o->value ? o->value : NULL; break; } - + printf(" \n"); if (o->short_cmdline_option) { @@ -1979,7 +1979,7 @@ globus_l_gfs_config_display_asciidoc_usage() globus_l_gfs_config_option_t * o; GlobusGFSName(globus_l_gfs_config_display_docbook_usage); GlobusGFSDebugEnter(); - + printf("////\ngenerated by globus-gridftp-server -help -asciidoc\n////\n"); printf("The list below contains the command-line options for the server, " "and also the name of the configuration file entry that implements " @@ -1989,10 +1989,10 @@ globus_l_gfs_config_display_asciidoc_usage() "\n"); for(i = 0; i < option_count; i++) - { + { char * value; char * defval; - + o = (globus_l_gfs_config_option_t *) &option_list[i]; if(o->option_name == NULL && o->configfile_option != NULL) { @@ -2026,8 +2026,8 @@ globus_l_gfs_config_display_asciidoc_usage() defval = o->int_value ? "TRUE" : "FALSE"; break; case GLOBUS_L_GFS_CONFIG_INT: - value = "number"; - defval = o->int_value > 0 ? + value = "number"; + defval = o->int_value > 0 ? globus_common_create_string("%d", o->int_value) : NULL; break; case GLOBUS_L_GFS_CONFIG_STRING: @@ -2035,11 +2035,11 @@ globus_l_gfs_config_display_asciidoc_usage() defval = o->value ? o->value : NULL; break; default: - value = ""; + value = ""; defval = o->value ? o->value : NULL; break; } - + printf("*"); if (o->short_cmdline_option) { @@ -2123,16 +2123,16 @@ globus_i_gfs_config_display_long_usage() globus_l_gfs_config_display_c_service(); } else - { + { for(i = 0; i < option_count; i++) - { + { o = (globus_l_gfs_config_option_t *) &option_list[i]; if(o->usage == NULL) { continue; } - - printf("%-14s %s\n%-14s %sCommand line or ENV args:", + + printf("%-14s %s\n%-14s %sCommand line or ENV args:", o->option_name, o->usage, "", o->type == GLOBUS_L_GFS_CONFIG_BOOL ? "(FLAG) " : ""); if(o->short_cmdline_option) @@ -2172,15 +2172,15 @@ globus_l_gfs_config_format_line( int count; int last; int blanks; - + len = strlen(in_str); count = 0; last = 0; memset(out_buffer, 0, rows * columns); - + for(i = 0; i < rows && count < len; i++) { - for(j = 0; j < columns - 1 && count < len; j++, count++) + for(j = 0; j < columns - 1 && count < len; j++, count++) { if(in_str[count] == ' ') { @@ -2205,12 +2205,12 @@ globus_l_gfs_config_format_line( while(count < len && in_str[count] == ' ') { count++; - } + } } return 0; } - + void globus_i_gfs_config_display_usage() { @@ -2218,7 +2218,7 @@ globus_i_gfs_config_display_usage() globus_l_gfs_config_option_t * o; GlobusGFSName(globus_i_gfs_config_display_short_usage); GlobusGFSDebugEnter(); - + if(globus_i_gfs_config_bool("html")) { globus_l_gfs_config_display_html_usage(); @@ -2237,7 +2237,7 @@ globus_i_gfs_config_display_usage() globus_l_gfs_config_display_c_service(); } else - { + { for(i = 0; i < option_count; i++) { char linebuffer[GLOBUS_GFS_HELP_ROWS * GLOBUS_GFS_HELP_COLS]; @@ -2253,7 +2253,7 @@ globus_i_gfs_config_display_usage() { count = 0; printf("\n"); - len = GLOBUS_GFS_HELP_WIDTH - + len = GLOBUS_GFS_HELP_WIDTH - (strlen(o->configfile_option) + 4); if(len > 0) { @@ -2280,16 +2280,16 @@ globus_i_gfs_config_display_usage() { continue; } - + switch(o->type) { case GLOBUS_L_GFS_CONFIG_BOOL: - value = ""; + value = ""; sprintf(defval, "%s", o->int_value ? "TRUE" : "FALSE"); break; case GLOBUS_L_GFS_CONFIG_INT: - value = ""; - if(o->int_value > 0) + value = ""; + if(o->int_value > 0) { sprintf(defval, "%d", o->int_value); } @@ -2299,16 +2299,16 @@ globus_i_gfs_config_display_usage() } break; case GLOBUS_L_GFS_CONFIG_STRING: - value = ""; - sprintf(defval, "%s", + value = ""; + sprintf(defval, "%s", o->value ? (char *) o->value : "not set"); break; default: - value = ""; + value = ""; sprintf(defval, "%s", "not set"); break; } - + if(o->short_cmdline_option) { count += printf(" -%s", o->short_cmdline_option); @@ -2330,16 +2330,16 @@ globus_i_gfs_config_display_usage() usage, GLOBUS_GFS_HELP_ROWS, GLOBUS_GFS_HELP_COLS, linebuffer); len = strlen(linebuffer); - for(row = 0; row < GLOBUS_GFS_HELP_ROWS && - linebuffer[row * GLOBUS_GFS_HELP_COLS]; + for(row = 0; row < GLOBUS_GFS_HELP_ROWS && + linebuffer[row * GLOBUS_GFS_HELP_COLS]; row++) { if(row == 1) { count += printf(" Default: %s ", defval); } - for(col = count; - col < GLOBUS_GFS_HELP_WIDTH - GLOBUS_GFS_HELP_COLS; + for(col = count; + col < GLOBUS_GFS_HELP_WIDTH - GLOBUS_GFS_HELP_COLS; col++) { printf(" "); @@ -2373,14 +2373,14 @@ globus_i_gfs_config_hostname_to_address_string( globus_addrinfo_t hints; globus_addrinfo_t * addrinfo; globus_result_t result; - + memset(&hints, 0, sizeof(globus_addrinfo_t)); hints.ai_family = PF_UNSPEC; hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = 0; result = globus_libc_getaddrinfo(hostname, NULL, &hints, &addrinfo); - if(result != GLOBUS_SUCCESS || addrinfo == NULL || + if(result != GLOBUS_SUCCESS || addrinfo == NULL || addrinfo->ai_addr == NULL) { goto error_exit; @@ -2396,11 +2396,11 @@ globus_i_gfs_config_hostname_to_address_string( { globus_libc_freeaddrinfo(addrinfo); goto error_exit; - } - globus_libc_freeaddrinfo(addrinfo); - + } + globus_libc_freeaddrinfo(addrinfo); + return GLOBUS_SUCCESS; - + error_exit: return result; } @@ -2439,7 +2439,6 @@ globus_l_gfs_config_misc() globus_list_t * popen_list = NULL; char * module; char * ptr; - int rc; char * value; char * data; globus_result_t result; @@ -2462,9 +2461,9 @@ globus_l_gfs_config_misc() #ifdef WIN32 globus_l_gfs_config_set("fork", GLOBUS_FALSE, NULL); -#endif +#endif - if(globus_i_gfs_config_bool("detach") && + if(globus_i_gfs_config_bool("detach") && !globus_i_gfs_config_bool("daemon")) { globus_l_gfs_config_set("daemon", GLOBUS_TRUE, NULL); @@ -2510,8 +2509,8 @@ globus_l_gfs_config_misc() else if(strchr(value, ':') == NULL) { globus_l_gfs_config_set( - "log_module", - 0, + "log_module", + 0, globus_common_create_string("%s:buffer=0", value)); globus_free(value); } @@ -2546,29 +2545,29 @@ globus_l_gfs_config_misc() "control_interface", 0, globus_libc_strdup(iface)); } } - - if((value = + + if((value = globus_i_gfs_config_string("control_interface")) != GLOBUS_NULL) - { + { memset(ipaddr, 0, sizeof(ipaddr)); result = globus_i_gfs_config_hostname_to_address_string( - value, ipaddr, sizeof(ipaddr)); + value, ipaddr, sizeof(ipaddr)); if(result != GLOBUS_SUCCESS) - { + { goto error_exit; } globus_l_gfs_config_set( "control_interface", 1, globus_libc_strdup(ipaddr)); } - if((value = + if((value = globus_i_gfs_config_string("data_interface")) != GLOBUS_NULL) - { + { memset(ipaddr, 0, sizeof(ipaddr)); result = globus_i_gfs_config_hostname_to_address_string( - value, ipaddr, sizeof(ipaddr)); + value, ipaddr, sizeof(ipaddr)); if(result != GLOBUS_SUCCESS) - { + { goto error_exit; } globus_l_gfs_config_set( @@ -2578,15 +2577,15 @@ globus_l_gfs_config_misc() if((value = globus_i_gfs_config_string("hostname")) != GLOBUS_NULL) { globus_l_gfs_config_set("fqdn", 0, globus_libc_strdup(value)); - + memset(ipaddr, 0, sizeof(ipaddr)); result = globus_i_gfs_config_hostname_to_address_string( - value, ipaddr, sizeof(ipaddr)); + value, ipaddr, sizeof(ipaddr)); if(result != GLOBUS_SUCCESS) - { + { goto error_exit; } - + if(globus_i_gfs_config_string("control_interface") == NULL) { globus_l_gfs_config_set( @@ -2605,18 +2604,18 @@ globus_l_gfs_config_misc() globus_libc_gethostname(hostname, 1024); globus_l_gfs_config_set("fqdn", 0, globus_libc_strdup(hostname)); globus_free(hostname); - } + } if((value = globus_i_gfs_config_string("version_tag")) != NULL) { - toolkit_version = + toolkit_version = globus_common_create_string("%s %s", toolkit_id, value); } else { toolkit_version = globus_libc_strdup(toolkit_id); } - + default_banner = globus_common_create_string( "%s GridFTP Server %d.%d (%s, %d-%d) [%s] ready.", globus_i_gfs_config_string("fqdn"), @@ -2626,27 +2625,27 @@ globus_l_gfs_config_misc() local_version.timestamp, local_version.branch_id, toolkit_version); - + data = NULL; if(globus_i_gfs_config_bool("banner_terse")) { - data = globus_libc_strdup(""); + data = globus_libc_strdup(""); } else if((value = globus_i_gfs_config_string("banner_file")) != GLOBUS_NULL) { - rc = globus_l_config_loadfile(value, &data); + globus_l_config_loadfile(value, &data); } else if((value = globus_i_gfs_config_string("banner")) != GLOBUS_NULL) { data = globus_libc_strdup(value); } - + if(data != NULL) { if(globus_i_gfs_config_bool("banner_append")) { char * banner; - banner = + banner = globus_common_create_string("%s %s", default_banner, data); globus_free(data); data = banner; @@ -2657,8 +2656,8 @@ globus_l_gfs_config_misc() { data = default_banner; } - globus_l_gfs_config_set("banner", 1, data); - + globus_l_gfs_config_set("banner", 1, data); + data = globus_common_create_string( "%d.%d (%s, %d-%d) [%s]", local_version.major, @@ -2672,15 +2671,15 @@ globus_l_gfs_config_misc() if((value = globus_i_gfs_config_string("login_msg_file")) != GLOBUS_NULL) { - rc = globus_l_config_loadfile(value, &data); - globus_l_gfs_config_set("login_msg", 0, data); + globus_l_config_loadfile(value, &data); + globus_l_gfs_config_set("login_msg", 0, data); } value = globus_i_gfs_config_string("load_dsi_module"); if(value != NULL) { char * ptr; - + ptr = strchr(value, ':'); if(ptr) { @@ -2700,26 +2699,26 @@ globus_l_gfs_config_misc() if(value) { if(globus_i_gfs_config_string("load_dsi_module") == NULL && - !globus_i_gfs_config_bool("data_node") && + !globus_i_gfs_config_bool("data_node") && !globus_i_gfs_config_bool("hybrid")) { globus_l_gfs_config_set( - "load_dsi_module", 0, globus_libc_strdup("remote")); + "load_dsi_module", 0, globus_libc_strdup("remote")); } - - /* if stripe_count wasn't set, set it to the number of + + /* if stripe_count wasn't set, set it to the number of * nodes configured */ if(globus_i_gfs_config_int("stripe_count") == -1) { int node_count = 1; char * ptr; - + ptr = value; while(ptr && *ptr && (ptr = strchr(ptr, ',')) != NULL) { ptr++; node_count++; - } + } globus_l_gfs_config_set("stripe_count", node_count, NULL); } } @@ -2731,9 +2730,9 @@ globus_l_gfs_config_misc() globus_l_gfs_config_set("stripe_count", 1, NULL); } } - + } - + value = globus_libc_strdup(globus_i_gfs_config_string("popen_whitelist")); if(value != NULL) { @@ -2741,21 +2740,21 @@ globus_l_gfs_config_misc() while((ptr = strchr(module, ',')) != NULL) { *ptr = '\0'; - globus_list_insert(&popen_list, globus_libc_strdup(module)); + globus_list_insert(&popen_list, globus_libc_strdup(module)); module = ptr + 1; } if(ptr == NULL) { - globus_list_insert(&popen_list, globus_libc_strdup(module)); - } - globus_free(value); + globus_list_insert(&popen_list, globus_libc_strdup(module)); + } + globus_free(value); } - globus_l_gfs_config_set("popen_list", 0, popen_list); + globus_l_gfs_config_set("popen_list", 0, popen_list); if(globus_i_gfs_config_string("load_dsi_module") == NULL) { - globus_l_gfs_config_set("load_dsi_module", 0, globus_libc_strdup("file")); - } + globus_l_gfs_config_set("load_dsi_module", 0, globus_libc_strdup("file")); + } value = globus_libc_strdup(globus_i_gfs_config_string("allowed_modules")); if(value != NULL) @@ -2764,17 +2763,17 @@ globus_l_gfs_config_misc() while((ptr = strchr(module, ',')) != NULL) { *ptr = '\0'; - globus_list_insert(&module_list, globus_libc_strdup(module)); + globus_list_insert(&module_list, globus_libc_strdup(module)); module = ptr + 1; } if(ptr == NULL) { - globus_list_insert(&module_list, globus_libc_strdup(module)); - } - globus_free(value); + globus_list_insert(&module_list, globus_libc_strdup(module)); + } + globus_free(value); } - globus_l_gfs_config_set("module_list", 0, module_list); - + globus_l_gfs_config_set("module_list", 0, module_list); + /* if auth_level is -1 it means it has not yet been touched */ switch(globus_i_gfs_config_int("auth_level")) { @@ -2820,7 +2819,7 @@ globus_l_gfs_config_misc() if(globus_i_gfs_config_bool("fork")) { /* should log an error */ - globus_l_gfs_config_set("fork", GLOBUS_FALSE, NULL); + globus_l_gfs_config_set("fork", GLOBUS_FALSE, NULL); } /* set the convenience conf opt */ @@ -2840,9 +2839,9 @@ globus_l_gfs_config_misc() globus_l_gfs_config_set("ipc_deny_from", 0, str); } } - - if(globus_i_gfs_config_string("remote_nodes") && - !globus_i_gfs_config_bool("data_node") && + + if(globus_i_gfs_config_string("remote_nodes") && + !globus_i_gfs_config_bool("data_node") && globus_i_gfs_config_string("ipc_subject")) { char * ipc_dn; @@ -2851,7 +2850,7 @@ globus_l_gfs_config_misc() OM_uint32 maj_stat; gss_name_t cred_name; gss_cred_id_t cred; - + ipc_dn = globus_i_gfs_config_string("ipc_subject"); if(strcasecmp(ipc_dn, "auto") == 0) @@ -2888,11 +2887,11 @@ globus_l_gfs_config_misc() result = min_stat; goto error_exit; } - globus_l_gfs_config_set("ipc_cred", 0, cred); + globus_l_gfs_config_set("ipc_cred", 0, cred); } - - else if(globus_i_gfs_config_string("remote_nodes") && - !globus_i_gfs_config_bool("data_node") && + + else if(globus_i_gfs_config_string("remote_nodes") && + !globus_i_gfs_config_bool("data_node") && globus_i_gfs_config_string("ipc_credential")) { char * cred_file; @@ -2900,13 +2899,13 @@ globus_l_gfs_config_misc() OM_uint32 min_stat; OM_uint32 maj_stat; gss_cred_id_t cred; - + cred_file = globus_i_gfs_config_string("ipc_credential"); buf.value = globus_common_create_string( "X509_USER_PROXY=%s", cred_file); buf.length = strlen(buf.value); - + maj_stat = gss_import_cred( &min_stat, &cred, @@ -2920,20 +2919,20 @@ globus_l_gfs_config_misc() result = min_stat; goto error_exit; } - + globus_free(buf.value); - - globus_l_gfs_config_set("ipc_cred", 0, cred); + + globus_l_gfs_config_set("ipc_cred", 0, cred); } - + GlobusGFSDebugExit(); return GLOBUS_SUCCESS; - + error_exit: GlobusGFSDebugExitWithError(); return result; } - + /* logging is available in this func */ void @@ -2944,7 +2943,7 @@ globus_i_gfs_config_post_init() if(globus_i_gfs_config_bool("allow_udt") && globus_l_gfs_num_threads < 1) { - globus_gfs_log_message(GLOBUS_GFS_LOG_WARN, + globus_gfs_log_message(GLOBUS_GFS_LOG_WARN, "Disabling UDT: threads must be enabled for UDT to function.\n"); globus_l_gfs_config_set("allow_udt", GLOBUS_FALSE, NULL); @@ -2954,13 +2953,13 @@ globus_i_gfs_config_post_init() } /** - * load configuration. read from defaults, file, env, and command line + * load configuration. read from defaults, file, env, and command line * arguments. each overriding the other. * this function will log error messages and exit the server if any * errors occur. * XXX need to allow config errors to log to syslog, stderr, etc */ - + int globus_i_gfs_config_init_envs( int argc, @@ -2988,8 +2987,8 @@ globus_i_gfs_config_init_envs( { tmp_argv = argv; } - - GLOBUS_GSI_SYSCONFIG_GET_CURRENT_WORKING_DIR(&cwd_str); + + GLOBUS_GSI_SYSCONFIG_GET_CURRENT_WORKING_DIR(&cwd_str); global_config_file = "/etc/grid-security/gridftp.conf"; local_config_file = NULL; @@ -3002,14 +3001,14 @@ globus_i_gfs_config_init_envs( { argp++; } - if(argp[0] == 'c' && argp[1] == '\0' + if(argp[0] == 'c' && argp[1] == '\0' && tmp_argv[arg_num + 1]) { local_config_file = strdup(tmp_argv[arg_num + 1]); arg_num++; cmdline_config = 1; } - else if(argp[0] == 'C' && argp[1] == '\0' && + else if(argp[0] == 'C' && argp[1] == '\0' && tmp_argv[arg_num + 1]) { conf_dir = strdup(tmp_argv[arg_num + 1]); @@ -3021,14 +3020,14 @@ globus_i_gfs_config_init_envs( arg_num++; } else if(!strcmp(argp, "threads") && tmp_argv[arg_num + 1]) - { + { globus_l_gfs_num_threads = atoi(tmp_argv[arg_num + 1]); arg_num++; } else if(!strcmp(argp, "inetd") || !strcmp(argp, "debug") || - !strcmp(argp, "i") || !strcmp(argp, "ssh") || + !strcmp(argp, "i") || !strcmp(argp, "ssh") || !strcmp(argp, "no-fork")) - { + { globus_l_gfs_is_worker = GLOBUS_TRUE; } else if(!strcmp(argp, "port-range") && tmp_argv[arg_num + 1]) @@ -3042,7 +3041,7 @@ globus_i_gfs_config_init_envs( if(local_config_file == NULL) { char * tmp_gl; - + tmp_str = malloc(PATH_MAX); tmp_gl = getenv("GLOBUS_LOCATION"); if(tmp_gl) @@ -3051,10 +3050,10 @@ globus_i_gfs_config_init_envs( if(rc > 0) { local_config_file = tmp_str; - } + } } } - + if(base_str) { free(cwd_str); @@ -3110,7 +3109,7 @@ globus_i_gfs_config_init_envs( { rc = globus_l_gfs_config_load_envs_from_file(global_config_file); } - + if(globus_l_gfs_port_range) { setenv("GLOBUS_TCP_PORT_RANGE", globus_l_gfs_port_range, 1); @@ -3120,12 +3119,12 @@ globus_i_gfs_config_init_envs( /* only enable threads for real process, not daemon */ if(globus_l_gfs_num_threads > 0 && globus_l_gfs_is_worker) { - char nthreads[8]; + char nthreads[11]; snprintf(nthreads, sizeof(nthreads), "%d", globus_l_gfs_num_threads); setenv("GLOBUS_CALLBACK_POLLING_THREADS", nthreads, 1); globus_thread_set_model("pthread"); } - + if(local_config_file != NULL) { free(local_config_file); @@ -3138,7 +3137,7 @@ globus_i_gfs_config_init_envs( { free(base_str); } - + return 0; error: @@ -3166,9 +3165,9 @@ globus_i_gfs_config_init( char * base_str = NULL; GlobusGFSName(globus_i_gfs_config_init); GlobusGFSDebugEnter(); - + globus_l_gfs_common_loaded = GLOBUS_TRUE; - + globus_hashtable_init( &option_table, 256, @@ -3185,9 +3184,9 @@ globus_i_gfs_config_init( { tmp_argv = argv; } - - GLOBUS_GSI_SYSCONFIG_GET_CURRENT_WORKING_DIR(&cwd_str); - + + GLOBUS_GSI_SYSCONFIG_GET_CURRENT_WORKING_DIR(&cwd_str); + exec_name = tmp_argv[0]; /* set default exe name */ globus_location(&tmp_str); @@ -3211,7 +3210,7 @@ globus_i_gfs_config_init( global_config_file = "/etc/grid-security/gridftp.conf"; local_config_file = NULL; conf_dir = NULL; - + for(arg_num = 0; arg_num < argc; arg_num++) { argp = tmp_argv[arg_num]; @@ -3223,7 +3222,7 @@ globus_i_gfs_config_init( { argp++; } - + if(argp[0] == 'c' && argp[1] == '\0' && tmp_argv[arg_num + 1]) { local_config_file = globus_libc_strdup(tmp_argv[arg_num + 1]); @@ -3231,7 +3230,7 @@ globus_i_gfs_config_init( arg_num++; continue; } - + if(argp[0] == 'C' && argp[1] == '\0' && tmp_argv[arg_num + 1]) { conf_dir = globus_libc_strdup(tmp_argv[arg_num + 1]); @@ -3245,14 +3244,14 @@ globus_i_gfs_config_init( continue; } } - + if(local_config_file == NULL && !argv_only) { globus_eval_path("${sysconfdir}/gridftp.conf", &local_config_file); } globus_l_gfs_config_load_defaults(); - + if(base_str) { globus_free(cwd_str); @@ -3279,7 +3278,7 @@ globus_i_gfs_config_init( goto error; } } - + if(local_config_file != NULL) { if(*local_config_file != '/') @@ -3303,7 +3302,7 @@ globus_i_gfs_config_init( { rc = globus_l_gfs_config_load_envs_from_file(global_config_file); } - + if(!argv_only) { globus_l_gfs_config_load_config_env(); @@ -3313,15 +3312,15 @@ globus_i_gfs_config_init( { goto error; } - + result = globus_l_gfs_config_misc(); if(result != GLOBUS_SUCCESS) { - globus_gfs_log_exit_message("Error in post config setup:\n %s", + globus_gfs_log_exit_message("Error in post config setup:\n %s", globus_error_print_friendly(globus_error_peek(result))); goto error; } - + globus_l_gfs_config_set("exec_name", 0, exec_name); globus_l_gfs_config_set("argv", 0, tmp_argv); globus_l_gfs_config_set("argc", argc, NULL); @@ -3338,7 +3337,7 @@ globus_i_gfs_config_init( { globus_free(base_str); } - + globus_mutex_init(&globus_i_gfs_config_mutex, NULL); GlobusGFSDebugExit(); @@ -3354,15 +3353,15 @@ globus_i_gfs_config_int( const char * option_name) { globus_l_gfs_config_option_t * option; - int value = 0; + int value = 0; GlobusGFSName(globus_i_gfs_config_int); GlobusGFSDebugEnter(); - - option = (globus_l_gfs_config_option_t *) + + option = (globus_l_gfs_config_option_t *) globus_hashtable_lookup(&option_table, (void *) option_name); - + if(option) - { + { value = option->int_value; } @@ -3376,15 +3375,15 @@ globus_i_gfs_config_get( const char * option_name) { globus_l_gfs_config_option_t * option; - void * value = NULL; + void * value = NULL; GlobusGFSName(globus_i_gfs_config_get); GlobusGFSDebugEnter(); - - option = (globus_l_gfs_config_option_t *) + + option = (globus_l_gfs_config_option_t *) globus_hashtable_lookup(&option_table, (void *) option_name); - + if(option && option->value) - { + { value = option->value; } @@ -3418,7 +3417,7 @@ globus_i_gfs_config_is_anonymous( valid = GLOBUS_TRUE; } } - + GlobusGFSDebugExit(); return valid; } @@ -3444,7 +3443,7 @@ globus_i_gfs_config_allow_addr( globus_i_gfs_config_string("ipc_deny_from")); } else - { + { allow_list = globus_libc_strdup( globus_i_gfs_config_string("allow_from")); deny_list = globus_libc_strdup( @@ -3517,7 +3516,7 @@ globus_i_gfs_config_get_module_name( GlobusGFSName(globus_i_gfs_config_get_module_name); GlobusGFSDebugEnter(); - module_list = (globus_list_t *) globus_i_gfs_config_get("module_list"); + module_list = (globus_list_t *) globus_i_gfs_config_get("module_list"); for(list = module_list; !globus_list_empty(list) && !found; list = globus_list_rest(list)) @@ -3539,7 +3538,7 @@ globus_i_gfs_config_get_module_name( { found = GLOBUS_TRUE; } - } + } if(found) { out_module = module; @@ -3560,7 +3559,7 @@ globus_gfs_config_get_bool( globus_bool_t rc; globus_mutex_lock(&globus_i_gfs_config_mutex); - rc = globus_i_gfs_config_bool(option_name); + rc = globus_i_gfs_config_bool(option_name); globus_mutex_unlock(&globus_i_gfs_config_mutex); return rc; } @@ -3572,7 +3571,7 @@ globus_gfs_config_get_string( char * rc; globus_mutex_lock(&globus_i_gfs_config_mutex); - rc = globus_i_gfs_config_string(option_name); + rc = globus_i_gfs_config_string(option_name); globus_mutex_unlock(&globus_i_gfs_config_mutex); return rc; } @@ -3584,7 +3583,7 @@ globus_gfs_config_get_list( globus_list_t * rc; globus_mutex_lock(&globus_i_gfs_config_mutex); - rc = globus_i_gfs_config_list(option_name); + rc = globus_i_gfs_config_list(option_name); globus_mutex_unlock(&globus_i_gfs_config_mutex); return rc; } @@ -3596,7 +3595,7 @@ globus_gfs_config_get( void * rc; globus_mutex_lock(&globus_i_gfs_config_mutex); - rc = globus_i_gfs_config_get(option_name); + rc = globus_i_gfs_config_get(option_name); globus_mutex_unlock(&globus_i_gfs_config_mutex); return rc; } @@ -3608,7 +3607,7 @@ globus_gfs_config_get_int( int rc; globus_mutex_lock(&globus_i_gfs_config_mutex); - rc = globus_i_gfs_config_int(option_name); + rc = globus_i_gfs_config_int(option_name); globus_mutex_unlock(&globus_i_gfs_config_mutex); return rc; } diff --git a/gridftp/server/src/globus_i_gfs_control.c b/gridftp/server/src/globus_i_gfs_control.c index e18953becc..496ef12df4 100644 --- a/gridftp/server/src/globus_i_gfs_control.c +++ b/gridftp/server/src/globus_i_gfs_control.c @@ -91,7 +91,7 @@ typedef struct char * username; globus_gridftp_server_control_t server_handle; globus_object_t * close_error; - + globus_hashtable_t custom_cmd_table; } globus_l_gfs_server_instance_t; @@ -105,7 +105,7 @@ typedef struct globus_gfs_operation_type_t bounce_type; globus_i_gfs_data_callback_t bounce_cb; - void * bounce_info; + void * bounce_info; } globus_l_gfs_request_info_t; typedef struct globus_l_gfs_auth_info_s @@ -123,7 +123,7 @@ static globus_bool_t globus_l_gfs_control_should_be_gone = GL char * globus_i_gsc_string_to_959( int code, - const char * in_str, + const char * in_str, const char * preline); static @@ -133,7 +133,7 @@ globus_l_gfs_control_log( const char * message, int type, void * user_arg); - + static void globus_l_gfs_request_custom_command( @@ -147,7 +147,7 @@ static int globus_l_gfs_activate() { int rc = 0; - + rc = globus_module_activate(GLOBUS_XIO_MODULE); if(rc != 0) { @@ -168,7 +168,7 @@ globus_l_gfs_activate() { return rc; } - + GlobusDebugInit(GLOBUS_GRIDFTP_SERVER, ERROR WARNING TRACE INTERNAL_TRACE INFO STATE INFO_VERBOSE); @@ -248,7 +248,7 @@ globus_i_gfs_control_init() "connections_max", globus_l_gfs_conn_max_change_cb, NULL); - + GlobusGFSDebugExit(); } @@ -264,12 +264,12 @@ globus_i_gfs_control_stop() { globus_l_gfs_control_active = GLOBUS_FALSE; globus_l_gfs_control_should_be_gone = GLOBUS_TRUE; - + for(list = globus_l_gfs_server_handle_list; !globus_list_empty(list); list = globus_list_rest(list)) { - instance = (globus_l_gfs_server_instance_t *) + instance = (globus_l_gfs_server_instance_t *) globus_list_first(list); globus_gridftp_server_control_stop(instance->server_handle); @@ -300,7 +300,7 @@ globus_l_gfs_request_info_init( result = GlobusGFSErrorMemory("request"); goto error; } - + request->control_op = control_op; request->instance = instance; request->info = info_struct; @@ -411,13 +411,13 @@ globus_l_gfs_kvstr_path( { new_kvstr = globus_libc_strdup(kvstr); } - + globus_free(chk_path); globus_free(real_path); - + *out_kvstr = new_kvstr; return GLOBUS_SUCCESS; - + err: if(chk_path) { @@ -427,8 +427,8 @@ globus_l_gfs_kvstr_path( { globus_free(real_path); } - - return result; + + return result; } @@ -465,7 +465,7 @@ globus_l_gfs_channel_close_cb( { instance->close_func(instance->close_arg, instance->close_error); } - + if(instance->home_dir) { globus_free(instance->home_dir); @@ -505,7 +505,7 @@ globus_l_gfs_done_cb( globus_mutex_lock(&globus_l_gfs_control_mutex); { globus_l_gfs_control_should_be_gone = GLOBUS_TRUE; - + globus_list_remove(&globus_l_gfs_server_handle_list, globus_list_search(globus_l_gfs_server_handle_list, instance)); } @@ -513,7 +513,7 @@ globus_l_gfs_done_cb( globus_gridftp_server_control_destroy(instance->server_handle); - instance->close_error = + instance->close_error = (result == GLOBUS_SUCCESS ? NULL : globus_error_get(result)); result = globus_xio_register_close( instance->xio_handle, @@ -574,54 +574,53 @@ globus_l_gfs_auth_session_cb( "User %s successfully authorized.\n", reply->info.session.username); - if(reply->info.session.home_dir != NULL && + if(reply->info.session.home_dir != NULL && globus_i_gfs_config_bool("use_home_dirs")) { -#ifdef WIN32 - if(isalpha(reply->info.session.home_dir[0]) && +#ifdef WIN32 + if(isalpha(reply->info.session.home_dir[0]) && reply->info.session.home_dir[1] == ':') { reply->info.session.home_dir[1] = reply->info.session.home_dir[0]; reply->info.session.home_dir[0] = '/'; - } -#endif + } +#endif globus_gridftp_server_control_set_cwd( auth_info->instance->server_handle, reply->info.session.home_dir); } - + if(reply->info.session.home_dir) { - auth_info->instance->home_dir = + auth_info->instance->home_dir = globus_libc_strdup(reply->info.session.home_dir); } - /* + /* else { auth_info->instance->home_dir = globus_libc_strdup("/"); } */ - auth_info->instance->username = + auth_info->instance->username = globus_libc_strdup(reply->info.session.username); - - if(reply->op_info && + + if(reply->op_info && !globus_hashtable_empty(&reply->op_info->custom_command_table)) { globus_list_t * list; - int rc; globus_i_gfs_cmd_ent_t * cmd_ent; - - auth_info->instance->custom_cmd_table = + + auth_info->instance->custom_cmd_table = reply->op_info->custom_command_table; - - rc = globus_hashtable_to_list( + + globus_hashtable_to_list( &reply->op_info->custom_command_table, &list); - + while(!globus_list_empty(list)) { - cmd_ent = (globus_i_gfs_cmd_ent_t *) + cmd_ent = (globus_i_gfs_cmd_ent_t *) globus_list_remove(&list, list); - + result = globus_gsc_959_command_add( auth_info->instance->server_handle, cmd_ent->cmd_name, @@ -636,7 +635,7 @@ globus_l_gfs_auth_session_cb( char * tmp_msg; tmp_msg = globus_error_print_friendly( globus_error_peek(result)); - + globus_gfs_log_message( GLOBUS_GFS_LOG_ERR, "Could not register command '%s':\n%s", @@ -729,7 +728,7 @@ globus_l_gfs_request_auth( "session.authn", 0, "user=%s DN=\"%s\"", - user_name, + user_name, subject ? subject : ""); result = globus_gridftp_server_control_get_data_auth( @@ -775,7 +774,7 @@ globus_l_gfs_request_auth( goto user_error; } } - + auth_info = (globus_l_gfs_auth_info_t *) calloc(1, sizeof(globus_l_gfs_auth_info_t)); if(auth_info == NULL) @@ -832,7 +831,7 @@ globus_l_gfs_data_stat_cb( if(reply->result != GLOBUS_SUCCESS) { int ftp_code; - + /* use code and message from reply if set */ if(reply->code && reply->msg) { @@ -881,7 +880,7 @@ globus_l_gfs_data_stat_cb( GLOBUS_GRIDFTP_SERVER_CONTROL_RESPONSE_SUCCESS, GLOBUS_NULL); } - + if(reply->code / 100 != 1) { info = (globus_gfs_stat_info_t *) request->info; @@ -917,7 +916,7 @@ globus_l_gfs_request_stat( instance = (globus_l_gfs_server_instance_t *) user_arg; - stat_info = (globus_gfs_stat_info_t *) + stat_info = (globus_gfs_stat_info_t *) globus_calloc(1, sizeof(globus_gfs_stat_info_t)); result = globus_l_gfs_request_info_init( @@ -947,11 +946,11 @@ globus_l_gfs_request_stat( GlobusGFSDebugExit(); return; - + error_init: { int ftp_code; - + /* pull response code from error */ if((ftp_code = globus_gfs_error_get_ftp_response_code( globus_error_peek(result))) == 0) @@ -1022,7 +1021,7 @@ globus_l_gfs_data_command_cb( globus_gsc_959_finished_command(op, msg); globus_free(msg); break; - + case GLOBUS_GFS_CMD_SITE_CHROOT: if(request->instance->home_dir) { @@ -1085,14 +1084,14 @@ globus_l_gfs_data_command_cb( globus_gsc_959_finished_command(op, msg); globus_free(msg); break; - + case GLOBUS_GFS_CMD_HTTP_PUT: case GLOBUS_GFS_CMD_HTTP_GET: if(reply->code / 100 == 1) { struct timeval now; gettimeofday(&now, NULL); - + switch(reply->code) { case 112: @@ -1109,7 +1108,7 @@ globus_l_gfs_data_command_cb( default: return; } - + globus_i_gsc_cmd_intermediate_reply(op, msg); globus_free(msg); } @@ -1121,7 +1120,7 @@ globus_l_gfs_data_command_cb( _tmp = globus_common_create_string( "OK.\n%s", reply->msg); msg = globus_gsc_string_to_959(200, _tmp, NULL); - } + } else { msg = strdup("200 OK.\r\n"); @@ -1141,7 +1140,7 @@ globus_l_gfs_data_command_cb( } } else - { + { globus_gsc_959_finished_command(op, "250 OK.\r\n"); } break; @@ -1177,10 +1176,10 @@ globus_l_gfs_data_command_cb( globus_free(tmp_msg); globus_free(msg); } - + if(reply->code / 100 == 1) return; - + if(info) { if(info->pathname) @@ -1212,7 +1211,7 @@ globus_l_gfs_data_command_cb( globus_free(info->op_info->argv[ctr]); } globus_free(info->op_info->argv); - } + } globus_free(info->op_info); } globus_free(info); @@ -1254,20 +1253,20 @@ globus_l_gfs_data_internal_stat_cb( { globus_gfs_command_info_t * command_info; globus_gfs_data_reply_t command_reply; - + memset(&command_reply, 0, sizeof(globus_gfs_data_reply_t)); command_info = (globus_gfs_command_info_t *) request->info; command_reply.info.command.command = command_info->command; command_reply.result = reply->result; - + request->bounce_cb(&command_reply, request); } break; - + default: break; } - + GlobusGFSDebugExit(); } @@ -1297,7 +1296,7 @@ globus_l_gfs_request_custom_command( instance = (globus_l_gfs_server_instance_t *) user_arg; - command_info = (globus_gfs_command_info_t *) + command_info = (globus_gfs_command_info_t *) globus_calloc(1, sizeof(globus_gfs_command_info_t)); result = globus_l_gfs_request_info_init( @@ -1310,22 +1309,22 @@ globus_l_gfs_request_custom_command( if(strcmp(cmd_array[0], "SITE") == 0) { char key[1024]; - + snprintf(key, sizeof(key), "%s %s", cmd_array[0], cmd_array[1]); cmd_ent = globus_hashtable_lookup( &instance->custom_cmd_table, key); } else - { + { cmd_ent = globus_hashtable_lookup( &instance->custom_cmd_table, cmd_array[0]); } - + if(cmd_ent) { command_info->command = cmd_ent->cmd_id; if(cmd_ent->has_pathname) - { + { switch(cmd_ent->access_type) { case GFS_ACL_ACTION_READ: @@ -1340,11 +1339,11 @@ globus_l_gfs_request_custom_command( default: acc = GFS_L_WRITE; break; - } + } result = globus_l_gfs_get_full_path( - instance, - cmd_array[argc - 1], - &command_info->pathname, + instance, + cmd_array[argc - 1], + &command_info->pathname, acc); if(command_info->pathname == NULL) { @@ -1356,7 +1355,7 @@ globus_l_gfs_request_custom_command( command_info->pathname = globus_libc_strdup(cmd_array[argc - 1]); } - command_info->op_info = + command_info->op_info = globus_calloc(1, sizeof(globus_i_gfs_op_info_t)); command_info->op_info->cmd_ent = cmd_ent; @@ -1364,7 +1363,7 @@ globus_l_gfs_request_custom_command( command_info->op_info->argv = globus_calloc(argc, sizeof(char *)); for(i = 0; i < argc; i++) { - command_info->op_info->argv[i] = + command_info->op_info->argv[i] = globus_libc_strdup(cmd_array[i]); } @@ -1388,23 +1387,23 @@ globus_l_gfs_request_custom_command( globus_l_gfs_control_log(instance->server_handle, msg_for_log, type, instance); free(msg_for_log); - + GlobusGFSDebugExit(); return; -err: +err: error_init: globus_l_gfs_control_log(instance->server_handle, msg_for_log, GLOBUS_GRIDFTP_SERVER_CONTROL_LOG_ERROR, instance); free(msg_for_log); - + if(result != GLOBUS_SUCCESS) { char * ftp_str; char * tmp_str; int ftp_code; - + /* pull response code from error */ if((ftp_code = globus_gfs_error_get_ftp_response_code( globus_error_peek(result))) == 0) @@ -1450,7 +1449,7 @@ globus_l_gfs_request_command( instance = (globus_l_gfs_server_instance_t *) user_arg; - command_info = (globus_gfs_command_info_t *) + command_info = (globus_gfs_command_info_t *) globus_calloc(1, sizeof(globus_gfs_command_info_t)); result = globus_l_gfs_request_info_init( @@ -1496,7 +1495,7 @@ globus_l_gfs_request_command( else if(strcmp(cmd_array[0], "RNFR") == 0) { globus_gfs_stat_info_t * stat_info; - + command_info->command = GLOBUS_GFS_CMD_RNFR; result = globus_l_gfs_get_full_path( instance, cmd_array[1], &command_info->pathname, GFS_L_WRITE); @@ -1504,8 +1503,8 @@ globus_l_gfs_request_command( { goto err; } - - stat_info = (globus_gfs_stat_info_t *) + + stat_info = (globus_gfs_stat_info_t *) globus_calloc(1, sizeof(globus_gfs_stat_info_t)); stat_info->file_only = GLOBUS_TRUE; @@ -1545,7 +1544,7 @@ globus_l_gfs_request_command( command_info->command = GLOBUS_GFS_CMD_DCSC; command_info->cksm_alg = globus_libc_strdup(cmd_array[1]); command_info->pathname = globus_libc_strdup(cmd_array[2]); - if(command_info->pathname == NULL && + if(command_info->pathname == NULL && strcasecmp(command_info->cksm_alg, "d") != 0) { goto err; @@ -1556,7 +1555,7 @@ globus_l_gfs_request_command( { char * freq; int consumed; - + command_info->command = GLOBUS_GFS_CMD_CKSM; result = globus_l_gfs_get_full_path( instance, cmd_array[4], &command_info->pathname, GFS_L_READ); @@ -1570,7 +1569,7 @@ globus_l_gfs_request_command( cmd_array[2], &command_info->cksm_offset, &consumed); - if(rc < 1 || *(cmd_array[2] + consumed) != '\0' || + if(rc < 1 || *(cmd_array[2] + consumed) != '\0' || command_info->cksm_offset < 0) { result = GlobusGFSErrorGeneric("Invalid offset."); @@ -1581,7 +1580,7 @@ globus_l_gfs_request_command( cmd_array[3], &command_info->cksm_length, &consumed); - if(rc < 1 || *(cmd_array[3] + consumed) != '\0' || + if(rc < 1 || *(cmd_array[3] + consumed) != '\0' || command_info->cksm_length < -1) { result = GlobusGFSErrorGeneric("Invalid length."); @@ -1589,7 +1588,7 @@ globus_l_gfs_request_command( } type = GLOBUS_GRIDFTP_SERVER_CONTROL_LOG_FILE_COMMANDS; - + if((freq = getenv("GFS_CKSM_MARKERS")) != NULL) { command_info->chmod_mode = strtol(freq, NULL, 10); @@ -1626,13 +1625,13 @@ globus_l_gfs_request_command( } if (strlen(cmd_array[1]) < 14) { - goto err; + goto err; } { char* tz; struct tm modtime; memset(&modtime, 0, sizeof(modtime)); - if (sscanf(cmd_array[1], "%4d%2d%2d%2d%2d%2d", + if (sscanf(cmd_array[1], "%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) { @@ -1655,7 +1654,7 @@ globus_l_gfs_request_command( if (command_info->utime_time < 0) { goto err; - } + } } type = GLOBUS_GRIDFTP_SERVER_CONTROL_LOG_SITE; } @@ -1707,7 +1706,7 @@ globus_l_gfs_request_command( else if(strcmp(cmd_array[1], "VERSION") == 0) { char version_string[1024]; - + type = GLOBUS_GRIDFTP_SERVER_CONTROL_LOG_SITE; snprintf(version_string, sizeof(version_string), "200 %s\r\n", globus_i_gfs_config_string("version_string")); @@ -1769,13 +1768,13 @@ globus_l_gfs_request_command( } if (strlen(cmd_array[2]) < 14) { - goto err; + goto err; } { char* tz; struct tm modtime; memset(&modtime, 0, sizeof(modtime)); - if (sscanf(cmd_array[2], "%4d%2d%2d%2d%2d%2d", + if (sscanf(cmd_array[2], "%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) { @@ -1802,14 +1801,14 @@ globus_l_gfs_request_command( if (command_info->utime_time < 0) { goto err; - } + } } type = GLOBUS_GRIDFTP_SERVER_CONTROL_LOG_SITE; } else if(strcmp(cmd_array[1], "SYMLINKFROM") == 0) - { + { globus_gfs_stat_info_t * stat_info; - + command_info->command = GLOBUS_GFS_CMD_SITE_SYMLINKFROM; result = globus_l_gfs_get_full_path( instance, cmd_array[2], &command_info->pathname, GFS_L_READ); @@ -1817,10 +1816,10 @@ globus_l_gfs_request_command( { goto err; } - - stat_info = (globus_gfs_stat_info_t *) + + stat_info = (globus_gfs_stat_info_t *) globus_calloc(1, sizeof(globus_gfs_stat_info_t)); - + stat_info->file_only = GLOBUS_TRUE; stat_info->pathname = globus_libc_strdup(command_info->pathname); request->bounce_info = stat_info; @@ -1890,7 +1889,7 @@ globus_l_gfs_request_command( "%s %s", cmd_array[2], tmp_path); globus_free(tmp_path); } - else if(strcasecmp(cmd_array[2], "CREATE") == 0) + else if(strcasecmp(cmd_array[2], "CREATE") == 0) { char * tmp_argstr; result = globus_l_gfs_kvstr_path( @@ -1903,12 +1902,12 @@ globus_l_gfs_request_command( "%s %s", cmd_array[2], tmp_argstr); globus_free(tmp_argstr); } - else if(strcasecmp(cmd_array[2], "DELETE") == 0) + else if(strcasecmp(cmd_array[2], "DELETE") == 0) { command_info->pathname = globus_common_create_string( "%s %s", cmd_array[2], cmd_array[3]); } - + if(command_info->pathname == NULL) { goto err; @@ -1919,14 +1918,14 @@ globus_l_gfs_request_command( { command_info->command = GLOBUS_GFS_CMD_UPAS; command_info->pathname = globus_libc_strdup(cmd_array[2]); - + type = GLOBUS_GRIDFTP_SERVER_CONTROL_LOG_TRANSFER_STATE; } else if(strcmp(cmd_array[1], "UPRT") == 0) { command_info->command = GLOBUS_GFS_CMD_UPRT; command_info->pathname = globus_libc_strdup(cmd_array[2]); - + type = GLOBUS_GRIDFTP_SERVER_CONTROL_LOG_TRANSFER_STATE; } else if(strcmp(cmd_array[1], "HTTP") == 0) @@ -1940,8 +1939,8 @@ globus_l_gfs_request_command( { goto err; } - } - else if(strcasecmp(cmd_array[2], "DOWNLOAD") == 0) + } + else if(strcasecmp(cmd_array[2], "DOWNLOAD") == 0) { command_info->command = GLOBUS_GFS_CMD_HTTP_GET; result = globus_l_gfs_kvstr_path( @@ -1951,7 +1950,7 @@ globus_l_gfs_request_command( goto err; } } - else if(strcasecmp(cmd_array[2], "CONFIG") == 0) + else if(strcasecmp(cmd_array[2], "CONFIG") == 0) { command_info->command = GLOBUS_GFS_CMD_HTTP_CONFIG; command_info->pathname = globus_libc_strdup(cmd_array[3]); @@ -1972,12 +1971,12 @@ globus_l_gfs_request_command( { goto err; } - + rc = globus_libc_scan_off_t( cmd_array[2], &command_info->cksm_offset, &consumed); - if(rc < 1 || *(cmd_array[2] + consumed) != '\0' || + if(rc < 1 || *(cmd_array[2] + consumed) != '\0' || command_info->cksm_offset < 0) { result = GlobusGFSErrorGeneric("Invalid length."); @@ -2035,7 +2034,7 @@ globus_l_gfs_request_command( globus_l_gfs_control_log(instance->server_handle, msg_for_log, type, instance); free(msg_for_log); - + GlobusGFSDebugExit(); return; @@ -2047,20 +2046,20 @@ globus_l_gfs_request_command( globus_l_gfs_control_log(instance->server_handle, msg_for_log, GLOBUS_GRIDFTP_SERVER_CONTROL_LOG_ERROR, instance); free(msg_for_log); - + if(result != GLOBUS_SUCCESS) { char * ftp_str; char * tmp_str; int ftp_code; - + /* pull response code from error */ if((ftp_code = globus_gfs_error_get_ftp_response_code( globus_error_peek(result))) == 0) { ftp_code = 500; } - tmp_str = globus_error_print_friendly(globus_error_peek(result)); + tmp_str = globus_error_print_friendly(globus_error_peek(result)); ftp_str = globus_gsc_string_to_959(ftp_code, tmp_str, NULL); globus_gsc_959_finished_command(op, ftp_str); globus_free(tmp_str); @@ -2188,7 +2187,7 @@ globus_l_gfs_get_event_mask( } if(in_event_mask & GLOBUS_GFS_EVENT_TRANSFER_COMPLETE) { - out_event_mask |= + out_event_mask |= GLOBUS_GRIDFTP_SERVER_CONTROL_EVENT_TRANSFER_COMPLETE; } @@ -2215,7 +2214,7 @@ globus_l_gfs_data_event_cb( { case GLOBUS_GFS_EVENT_TRANSFER_BEGIN: request->event_arg = reply->event_arg; - + request->transfer_events = GLOBUS_TRUE; event_mask = globus_l_gfs_get_event_mask(reply->event_mask); result = globus_gridftp_server_control_events_enable( @@ -2229,27 +2228,27 @@ globus_l_gfs_data_event_cb( /* TODO: can we ignore this */ } break; - + case GLOBUS_GFS_EVENT_TRANSFER_CONNECTED: globus_gridftp_server_control_begin_transfer(op); break; - + case GLOBUS_GFS_EVENT_DISCONNECTED: globus_gridftp_server_control_disconnected( - request->instance->server_handle, + request->instance->server_handle, reply->data_arg); break; - + case GLOBUS_GFS_EVENT_BYTES_RECVD: globus_gridftp_server_control_event_send_perf( op, reply->node_ndx, reply->recvd_bytes); break; - + case GLOBUS_GFS_EVENT_RANGES_RECVD: globus_gridftp_server_control_event_send_restart( op, reply->recvd_ranges); break; - + default: globus_assert(0 && "Unexpected event type"); break; @@ -2273,7 +2272,7 @@ globus_l_gfs_data_transfer_cb( request = (globus_l_gfs_request_info_t *) user_arg; op = request->control_op; - + destroy_req = !request->transfer_events; if(reply->result != GLOBUS_SUCCESS) @@ -2281,7 +2280,7 @@ globus_l_gfs_data_transfer_cb( char * msg; globus_result_t result; int ftp_code; - + /* use code and message from reply if set */ if(reply->code && reply->msg) { @@ -2435,11 +2434,11 @@ globus_l_gfs_request_send( GlobusGFSDebugExit(); return; - + error_init: { int ftp_code; - + /* pull response code from error */ if((ftp_code = globus_gfs_error_get_ftp_response_code( globus_error_peek(result))) == 0) @@ -2496,7 +2495,7 @@ globus_l_gfs_request_recv( { goto error_init; } - + /* if restart range is anything but 0-MAX then we don't trunc the file */ if(globus_range_list_size(range_list)) { @@ -2514,9 +2513,9 @@ globus_l_gfs_request_recv( "%"GLOBUS_OFF_T_FORMAT, &recv_info->partial_offset); recv_info->partial_length = -1; - + /* ESTO A 0 /file is not the same as STOR /file - ESTO doesn't truncate the file. + ESTO doesn't truncate the file. */ recv_info->truncate = GLOBUS_FALSE; @@ -2526,7 +2525,7 @@ globus_l_gfs_request_recv( { recv_info->partial_offset = 0; recv_info->partial_length = -1; - + if(mod_name != NULL) { recv_info->module_name = globus_libc_strdup(mod_name); @@ -2544,7 +2543,7 @@ globus_l_gfs_request_recv( } } - + result = globus_l_gfs_get_full_path( instance, path, &recv_info->pathname, GFS_L_WRITE); if(result != GLOBUS_SUCCESS) @@ -2555,7 +2554,7 @@ globus_l_gfs_request_recv( recv_info->stripe_count = 1; recv_info->node_count = 1; recv_info->data_arg = data_handle; - + globus_i_gfs_data_request_recv( NULL, instance->session_arg, @@ -2567,11 +2566,11 @@ globus_l_gfs_request_recv( GlobusGFSDebugExit(); return; - + error_init: { int ftp_code; - + /* pull response code from error */ if((ftp_code = globus_gfs_error_get_ftp_response_code( globus_error_peek(result))) == 0) @@ -2643,11 +2642,11 @@ globus_l_gfs_request_list( GlobusGFSDebugExit(); return; - + error_init: { int ftp_code; - + /* pull response code from error */ if((ftp_code = globus_gfs_error_get_ftp_response_code( globus_error_peek(result))) == 0) @@ -2776,25 +2775,25 @@ globus_l_gfs_get_data_info( NULL); globus_assert(result == GLOBUS_SUCCESS); - result = globus_gridftp_server_control_get_layout( + result = globus_gridftp_server_control_get_layout( op, (globus_gsc_layout_t *) &data_info->stripe_layout, &data_info->stripe_blocksize); globus_assert(result == GLOBUS_SUCCESS); - - if(data_info->stripe_blocksize == 0 || + + if(data_info->stripe_blocksize == 0 || globus_i_gfs_config_bool("stripe_blocksize_locked")) { - data_info->stripe_blocksize = + data_info->stripe_blocksize = globus_i_gfs_config_int("stripe_blocksize"); } if(globus_i_gfs_config_int("stripe_layout_locked")) { - data_info->stripe_layout = + data_info->stripe_layout = globus_i_gfs_config_int("stripe_layout"); } else - { + { switch(data_info->stripe_layout) { case GLOBUS_GSC_LAYOUT_TYPE_PARTITIONED: @@ -2805,12 +2804,12 @@ globus_l_gfs_get_data_info( break; case GLOBUS_GSC_LAYOUT_TYPE_NONE: default: - data_info->stripe_layout = + data_info->stripe_layout = globus_i_gfs_config_int("stripe_layout"); break; } } - + data_info->blocksize = globus_i_gfs_config_int("blocksize"); GlobusGFSDebugExit(); @@ -2850,29 +2849,29 @@ globus_l_gfs_request_passive_data( globus_l_gfs_get_data_info(op, data_info, net_prt); - if(globus_i_gfs_config_bool("encrypt_data") && + if(globus_i_gfs_config_bool("encrypt_data") && (data_info->prot != 'P' || data_info->dcau == 'N')) { tmp_str = strdup("Encryption is required."); err_code = GLOBUS_GRIDFTP_SERVER_CONTROL_RESPONSE_DATA_CONN_AUTH; goto error_postinit; } - + if(pathname) { - /* delayed pasv, final perm check will happen on the stor/retr */ + /* delayed pasv, final perm check will happen on the stor/retr */ result = globus_l_gfs_get_full_path( instance, pathname, &data_info->pathname, GFS_L_LIST); if(result != GLOBUS_SUCCESS) { err_code = GLOBUS_GRIDFTP_SERVER_CONTROL_RESPONSE_ACTION_FAILED; goto error_postinit; - } + } } globus_xio_contact_parse(&parsed_contact, instance->local_contact); data_info->max_cs = max; data_info->interface = globus_libc_strdup(parsed_contact.host); - + globus_xio_contact_destroy(&parsed_contact); globus_i_gfs_data_request_passive( @@ -2885,7 +2884,7 @@ globus_l_gfs_request_passive_data( GlobusGFSDebugExit(); return; - + error_postinit: globus_l_gfs_request_info_destroy(request); error_init: @@ -2999,7 +2998,7 @@ globus_l_gfs_request_active_data( } globus_l_gfs_get_data_info(op, data_info, net_prt); - if(globus_i_gfs_config_bool("encrypt_data") && + if(globus_i_gfs_config_bool("encrypt_data") && (data_info->prot != 'P' || data_info->dcau == 'N')) { tmp_str = strdup("Encryption is required."); @@ -3012,9 +3011,9 @@ globus_l_gfs_request_active_data( data_info->contact_strings = cs; data_info->cs_count = cs_count; data_info->interface = globus_libc_strdup(parsed_contact.host); - + globus_xio_contact_destroy(&parsed_contact); - + globus_i_gfs_data_request_active( NULL, instance->session_arg, @@ -3025,7 +3024,7 @@ globus_l_gfs_request_active_data( GlobusGFSDebugExit(); return; - + error_postinit: globus_l_gfs_request_info_destroy(request); error_init: @@ -3085,7 +3084,7 @@ globus_l_gfs_control_log( msg = globus_libc_strdup(message); globus_i_gfs_log_tr(msg, '\"', '\''); globus_i_gfs_log_tr(msg, '\r', ' '); - + switch(type) { case GLOBUS_GRIDFTP_SERVER_CONTROL_LOG_REPLY: @@ -3124,7 +3123,7 @@ globus_l_gfs_control_log( msg); break; } - + globus_free(msg); GlobusGFSDebugExit(); @@ -3538,7 +3537,7 @@ globus_l_gfs_add_commands( { goto error; } - + if(globus_i_gfs_config_bool("allow_udt")) { result = globus_gridftp_server_control_add_feature( @@ -3601,7 +3600,7 @@ globus_l_gfs_add_commands( if(dsi_ver) { feat_str = globus_common_create_string("DSI %s", dsi_ver); - + result = globus_gridftp_server_control_add_feature( control_handle, feat_str); globus_free(feat_str); @@ -3697,11 +3696,11 @@ globus_l_gfs_control_watchdog_check( } } globus_mutex_unlock(&globus_l_gfs_control_mutex); - + if(can_kill) { globus_reltime_t timer; - + GlobusTimeReltimeSet(timer, 60, 0); globus_callback_register_oneshot( NULL, @@ -3798,7 +3797,7 @@ globus_i_gfs_control_start( idle_timeout = globus_i_gfs_config_int("control_idle_timeout"); preauth_timeout = globus_i_gfs_config_int("control_preauth_timeout"); - + result = globus_gridftp_server_control_attr_set_idle_time( attr, idle_timeout, preauth_timeout); if(result != GLOBUS_SUCCESS) @@ -3870,7 +3869,7 @@ globus_i_gfs_control_start( goto error_attr_setup; } - module_list = (globus_list_t *) globus_i_gfs_config_get("module_list"); + module_list = (globus_list_t *) globus_i_gfs_config_get("module_list"); for(list = module_list; !globus_list_empty(list); list = globus_list_rest(list)) @@ -3895,7 +3894,7 @@ globus_i_gfs_control_start( goto error_attr_setup; } globus_free(alias); - } + } result = globus_gridftp_server_control_attr_set_list( attr, globus_l_gfs_request_list, instance); @@ -3939,7 +3938,7 @@ globus_i_gfs_control_start( goto error_add_commands; } - + /* disable commands if the user says to */ if((value = globus_i_gfs_config_string("disable_command_list")) != NULL) @@ -3962,7 +3961,7 @@ globus_i_gfs_control_start( { goto error_start; } - + globus_gfs_log_event( GLOBUS_GFS_LOG_INFO, GLOBUS_GFS_LOG_EVENT_START, diff --git a/gridftp/server/src/globus_i_gfs_data.c b/gridftp/server/src/globus_i_gfs_data.c index 0bf0ea4369..4fccc9dfb5 100644 --- a/gridftp/server/src/globus_i_gfs_data.c +++ b/gridftp/server/src/globus_i_gfs_data.c @@ -218,10 +218,10 @@ typedef struct globus_bool_t final; } globus_l_gfs_data_bounce_t; -typedef struct +typedef struct { char * all; - + char * modify; globus_bool_t modify_seen; char * checksum_md5; @@ -271,21 +271,21 @@ typedef struct char * client_appver; char * client_scheme; gss_cred_id_t dcsc_cred; - + globus_bool_t upas; globus_ftp_control_handle_t udt_data_channel; globus_bool_t udt_data_channel_inuse; - + globus_list_t ** active_rp_list; globus_list_t * rp_list; - + globus_bool_t sharing; char * sharing_state_dir; char * sharing_id; char * sharing_sharee; - + char * taskid; - + char * s3id; char * s3key; gss_cred_id_t http_cred; @@ -297,16 +297,16 @@ typedef struct globus_xio_driver_t http_driver; char * storattr_str; - + globus_bool_t order_data; - + int last_active; globus_off_t watch_updates; globus_bool_t watch; globus_bool_t watch_aborted; char * watch_op; globus_callback_handle_t watch_handle; - + globus_hashtable_t custom_cmd_table; } globus_l_gfs_data_session_t; @@ -357,7 +357,7 @@ typedef struct globus_l_gfs_data_operation_s int list_depth; int traversal_options; globus_result_t delayed_error; - + char * user_msg; int user_code; @@ -367,7 +367,7 @@ typedef struct globus_l_gfs_data_operation_s globus_range_list_t recvd_ranges; int retr_markers; globus_bool_t markers; - + globus_l_gfs_data_path_list_t * path_list; globus_l_gfs_data_path_list_t * current_path; globus_l_gfs_data_path_list_t * root_paths; @@ -403,12 +403,12 @@ typedef struct globus_l_gfs_data_operation_s /**/ globus_l_gfs_storattr_t * storattr; - + char * http_response_str; char * http_ip; int update_interval; - + void * event_arg; int event_mask; @@ -570,7 +570,7 @@ static void globus_l_gfs_data_active_kickout( void * user_arg); - + static void globus_l_gfs_data_passive_kickout( @@ -594,24 +594,24 @@ globus_l_gfs_data_brain_ready_delay_cb( void globus_i_gfs_data_http_read_cb( - globus_xio_handle_t xio_handle, + globus_xio_handle_t xio_handle, globus_result_t result, globus_byte_t * buffer, globus_size_t length, - globus_size_t nbytes, + globus_size_t nbytes, globus_xio_data_descriptor_t data_desc, void * user_arg); void globus_i_gfs_data_http_write_cb( - globus_xio_handle_t xio_handle, + globus_xio_handle_t xio_handle, globus_result_t result, globus_byte_t * buffer, globus_size_t length, - globus_size_t nbytes, + globus_size_t nbytes, globus_xio_data_descriptor_t data_desc, void * user_arg); -globus_result_t +globus_result_t globus_i_gfs_data_http_get( globus_l_gfs_data_operation_t * op, char * path, @@ -656,13 +656,12 @@ globus_i_gfs_data_http_print_response( char * header_str = NULL; char * header_tmp; globus_result_t result; - int rc; globus_xio_http_header_t * header; char * b64_header = NULL; char * b64_body = NULL; int body_len = 0; - - rc = globus_hashtable_to_list(header_table, &header_list); + + globus_hashtable_to_list(header_table, &header_list); header_str = strdup(""); while(!globus_list_empty(header_list)) @@ -681,10 +680,10 @@ globus_i_gfs_data_http_print_response( body, body_len, (globus_byte_t *) b64_body, NULL); globus_assert(result == GLOBUS_SUCCESS); } - + b64_header = malloc(strlen(header_str) * 4 / 3 + 4); result = globus_l_gfs_base64_encode( - (globus_byte_t *) header_str, strlen(header_str), + (globus_byte_t *) header_str, strlen(header_str), (globus_byte_t *) b64_header, NULL); globus_assert(result == GLOBUS_SUCCESS); @@ -712,8 +711,8 @@ globus_i_gfs_data_http_print_response( response_code, b64_header); } - - globus_free(header_str); + + globus_free(header_str); globus_free(b64_header); if(b64_body) { @@ -727,7 +726,7 @@ globus_i_gfs_data_http_print_response( static char globus_l_gfs_base64_pad = '='; static char * globus_l_gfs_base64_n = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; -static +static globus_result_t globus_l_gfs_base64_decode( const unsigned char * inbuf, @@ -745,7 +744,7 @@ globus_l_gfs_base64_decode( { if((p = strchr(globus_l_gfs_base64_n, inbuf[i])) == NULL) { - goto err; + goto err; } D = p - globus_l_gfs_base64_n; switch(i&3) @@ -772,27 +771,27 @@ globus_l_gfs_base64_decode( switch(i&3) { case 1: - goto err; - + goto err; + case 2: if(D&15) { - goto err; + goto err; } if(strcmp((char *) &inbuf[i], "==")) { - goto err; + goto err; } break; case 3: if(D&3) { - goto err; + goto err; } if(strcmp((char *) &inbuf[i], "=")) { - goto err; + goto err; } break; @@ -814,7 +813,7 @@ char * globus_l_gfs_defaulthome() { char * home_dir; -#ifdef WIN32 +#ifdef WIN32 char * ptr; if(getenv("HOMEDRIVE") && getenv("HOMEPATH")) @@ -851,7 +850,7 @@ globus_l_gfs_defaulthome() * for disabled accounts. Returns an error globus_result_t otherwise. * Assumes caller has checked value of pw (i.e. pw is not NULL). */ - + static globus_result_t globus_l_gfs_validate_pwent( @@ -876,7 +875,7 @@ globus_l_gfs_validate_pwent( ("shell is not a regular file: %s", pw->pw_shell)); goto err; } - + /* shell executable? */ if((statbuf.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) == 0) { @@ -887,7 +886,7 @@ globus_l_gfs_validate_pwent( GlobusGFSDebugExit(); return GLOBUS_SUCCESS; - + err: GlobusGFSDebugExitWithError(); return result; @@ -987,9 +986,9 @@ globus_l_gfs_data_watchdog_check( void * arg) { globus_l_gfs_data_session_t * session_handle; - + session_handle = (globus_l_gfs_data_session_t *) arg; - + if(!session_handle) { globus_gfs_log_message(GLOBUS_GFS_LOG_ERR, @@ -998,7 +997,7 @@ globus_l_gfs_data_watchdog_check( } else if(session_handle->watch && session_handle->watch_aborted) { - if(time(NULL) > + if(time(NULL) > session_handle->last_active + globus_l_gfs_watchdog_limit) { char * msg = globus_common_create_string( @@ -1032,7 +1031,7 @@ globus_l_gfs_data_reset_watchdog( session_handle->watch_op = operation; session_handle->watch_updates = 0; session_handle->watch_aborted = GLOBUS_FALSE; - + if(session_handle->watch) { if(session_handle->watch_handle == 0) @@ -1169,7 +1168,7 @@ globus_l_gfs_data_post_transfer_event_cb( } return remote_data_arg; -} +} globus_result_t globus_i_gfs_data_virtualize_path( @@ -1180,28 +1179,28 @@ globus_i_gfs_data_virtualize_path( globus_l_gfs_data_session_t * session_handle; char * tmp_ptr; session_handle = (globus_l_gfs_data_session_t *) session_arg; - + if(!session_handle->chroot_path) { *ret_string = NULL; return GLOBUS_SUCCESS; } - + tmp_ptr = strstr(in_string, session_handle->chroot_path); - + if(!tmp_ptr) { *ret_string = NULL; return GLOBUS_SUCCESS; } - + *ret_string = globus_malloc( strlen(in_string) + strlen(session_handle->chroot_path)); - + strncpy(*ret_string, in_string, tmp_ptr - in_string); - strcpy(*ret_string + (tmp_ptr - in_string), + strcpy(*ret_string + (tmp_ptr - in_string), tmp_ptr + strlen((session_handle->chroot_path))); - + return GLOBUS_SUCCESS; } @@ -1331,7 +1330,7 @@ globus_i_gfs_get_full_path( result = GlobusGFSErrorGeneric("invalid pathname"); goto done; } - + #ifdef WIN32 #define WIN_CHARS_NOT_ALLOWED ":*?\"<>|" tmp_path = in_path; @@ -1348,10 +1347,10 @@ globus_i_gfs_get_full_path( result = GlobusGFSErrorGeneric( "A filename cannot contain any of the following characters: " "\\ / : * ? \" < > |"); - goto done; - } + goto done; + } #endif - + if(*in_path == '/') { strncpy(path, in_path, sizeof(path)); @@ -1362,7 +1361,7 @@ globus_i_gfs_get_full_path( { result = GlobusGFSErrorGeneric( "No home directory, cannot expand ~"); - goto done; + goto done; } in_path++; if(*in_path == '/') @@ -1403,11 +1402,11 @@ globus_i_gfs_get_full_path( /* XXX expand other usernames here */ result = GlobusGFSErrorGeneric( "Cannot expand ~"); - goto done; + goto done; } - + cwd = globus_libc_strdup(res_pwd->pw_dir); - } + } cwd_len = strlen(cwd); if(cwd_len > 1 && cwd[cwd_len - 1] == '/') { @@ -1441,7 +1440,7 @@ globus_i_gfs_get_full_path( } DriveLetterToWin(norm_path); - + result = globus_i_gfs_data_check_path( session_arg, norm_path, ret_path, access_type, 1); if(result != GLOBUS_SUCCESS) @@ -1495,7 +1494,7 @@ globus_i_gfs_data_check_path( globus_list_t * rp_list; GlobusGFSName(globus_i_gfs_data_check_path); GlobusGFSDebugEnter(); - + session_handle = (globus_l_gfs_data_session_t *) session_arg; if(globus_list_empty(*session_handle->active_rp_list) && @@ -1503,7 +1502,7 @@ globus_i_gfs_data_check_path( { allowed = GLOBUS_TRUE; } - + if(is_virtual && session_handle->chroot_path) { if(in_path[0] == '/' && in_path[1] == '\0') @@ -1520,14 +1519,14 @@ globus_i_gfs_data_check_path( { start_path = in_path; } - + if(!allowed) { if(session_handle->dsi->descriptor & GLOBUS_GFS_DSI_DESCRIPTOR_HAS_REALPATH && - !globus_i_gfs_config_bool("rp_follow_symlinks") && - strcmp(start_path, "/") != 0 && + !globus_i_gfs_config_bool("rp_follow_symlinks") && + strcmp(start_path, "/") != 0 && session_handle->dsi->realpath_func != NULL) - { + { result = session_handle->dsi->realpath_func( start_path, &true_path, session_handle->session_arg); if(result != GLOBUS_SUCCESS) @@ -1535,20 +1534,20 @@ globus_i_gfs_data_check_path( char * true_base; char * end_slash = ""; int path_len; - + strncpy(path, start_path, sizeof(path)); path[MAXPATHLEN - 1] = '\0'; - + path_len = strlen(path); if(path[path_len - 1] == '/') { path[--path_len] = '\0'; end_slash = "/"; } - + tmp_ptr = strrchr(path, '/'); *(tmp_ptr++) = '\0'; - + if(*path == '\0') { result = GLOBUS_FAILURE; @@ -1558,7 +1557,7 @@ globus_i_gfs_data_check_path( result = session_handle->dsi->realpath_func( path, &true_base, session_handle->session_arg); } - + if(result != GLOBUS_SUCCESS) { result = GLOBUS_SUCCESS; @@ -1588,7 +1587,7 @@ globus_i_gfs_data_check_path( *ret_path = NULL; } } - + if(true_path) { @@ -1608,26 +1607,26 @@ globus_i_gfs_data_check_path( rp_list = session_handle->rp_list; } - + while(!globus_list_empty(rp_list)) { check_path = true_path; do { in_path_len = strlen(check_path); - + for(list = rp_list; !globus_list_empty(list) && !allowed && !disallowed; list = globus_list_rest(list)) - { + { alias_ent = globus_list_first(list); - + /* disallow if this a dir check and any contents are denied */ if(access_type & GFS_L_DIR && alias_ent->access & GFS_L_NONE) { if(strncmp(check_path, alias_ent->alias, in_path_len) == 0 && (check_path[in_path_len - 1] == '/' || - alias_ent->alias[in_path_len] == '\0' || + alias_ent->alias[in_path_len] == '\0' || alias_ent->alias[in_path_len] == '/')) { disallowed = GLOBUS_TRUE; @@ -1639,7 +1638,7 @@ globus_i_gfs_data_check_path( continue; } } - + /* check if we have an exact match */ if(strcspn(alias_ent->alias, "[*?") != alias_ent->alias_len) { @@ -1658,7 +1657,7 @@ globus_i_gfs_data_check_path( } else if(strncmp(check_path, alias_ent->alias, alias_ent->alias_len) == 0 && (alias_ent->alias[alias_ent->alias_len - 1] == '/' || - check_path[alias_ent->alias_len] == '\0' || + check_path[alias_ent->alias_len] == '\0' || check_path[alias_ent->alias_len] == '/')) { if(alias_ent->access & access_type) @@ -1670,13 +1669,13 @@ globus_i_gfs_data_check_path( disallowed = GLOBUS_TRUE; } } - + /* check if we are a parent of an exact match */ if(!allowed && !disallowed && access_type & GFS_L_LIST) { if(strncmp(check_path, alias_ent->alias, in_path_len) == 0 && (check_path[in_path_len - 1] == '/' || - alias_ent->alias[in_path_len] == '\0' || + alias_ent->alias[in_path_len] == '\0' || alias_ent->alias[in_path_len] == '/')) { if(alias_ent->access & access_type) @@ -1708,17 +1707,17 @@ globus_i_gfs_data_check_path( check_again = GLOBUS_FALSE; } } while(check_again); - + if(!allowed) { result = GlobusGFSErrorGeneric( "Path not allowed."); - + rp_list = NULL; } else { - if(rp_list == *session_handle->active_rp_list && + if(rp_list == *session_handle->active_rp_list && !globus_list_empty(session_handle->rp_list)) { rp_list = session_handle->rp_list; @@ -1728,15 +1727,15 @@ globus_i_gfs_data_check_path( { rp_list = NULL; } - + if(!rp_list && ret_path) { if(alias_ent && alias_ent->realpath) { strncpy(path, alias_ent->realpath, alias_ent->realpath_len); - strcpy(path + alias_ent->realpath_len, + strcpy(path + alias_ent->realpath_len, true_path + alias_ent->alias_len); - + *ret_path = globus_libc_strdup(path); } else if(session_handle->chroot_path) @@ -1750,11 +1749,11 @@ globus_i_gfs_data_check_path( } } } - + globus_free(true_path); } - + if(is_virtual && session_handle->chroot_path) { globus_free(start_path); @@ -1979,7 +1978,7 @@ globus_l_gfs_free_session_handle( } globus_free(session_handle->session_info_copy); } - + if(session_handle->custom_cmd_table) { globus_list_t * list; @@ -2004,7 +2003,7 @@ globus_l_gfs_free_session_handle( } globus_hashtable_destroy(&session_handle->custom_cmd_table); } - + if(session_handle->https_stack) { globus_xio_stack_destroy(session_handle->https_stack); @@ -2198,13 +2197,13 @@ globus_i_gfs_kv_getval( int keylen; char * tmp_val = NULL; globus_bool_t done = GLOBUS_FALSE; - + keylen = strlen(key); keystart = kvstring; keyend = strchr(kvstring, '='); while(keyend && keystart && !done) { - if((keylen == keyend - keystart) && + if((keylen == keyend - keystart) && strncasecmp(key, keystart, keyend - keystart) == 0) { done = GLOBUS_TRUE; @@ -2230,7 +2229,7 @@ globus_i_gfs_kv_getval( { strncpy(tmp_val, valstart, valend - valstart); tmp_val[valend - valstart] = '\0'; - + if(urldecode) { globus_url_string_hex_decode(tmp_val); @@ -2238,7 +2237,7 @@ globus_i_gfs_kv_getval( } } } - + return tmp_val; } @@ -2258,7 +2257,7 @@ globus_i_gfs_kv_replaceval( char save; char * enc_val; globus_bool_t done = GLOBUS_FALSE; - + if(encode) { enc_val = globus_url_string_hex_encode(new_val, ";"); @@ -2271,13 +2270,13 @@ globus_i_gfs_kv_replaceval( } enc_val = new_val; } - + keylen = strlen(key); keystart = kvstring; keyend = strchr(keystart, '='); while(keyend && keystart && !done) { - if((keylen == keyend - keystart) && + if((keylen == keyend - keystart) && strncasecmp(key, keystart, keyend - keystart) == 0) { done = GLOBUS_TRUE; @@ -2305,7 +2304,7 @@ globus_i_gfs_kv_replaceval( *valstart = save; } } - + if(encode) { globus_free(enc_val); @@ -2423,16 +2422,16 @@ globus_l_gfs_authorize_cb( { globus_gfs_finished_info_t finished_info; globus_l_gfs_data_operation_t * op; - + op = (globus_l_gfs_data_operation_t *) user_arg; memset(&finished_info, '\0', sizeof(globus_gfs_finished_info_t)); - + result = GlobusGFSErrorWrapFailed( "authorization", result); finished_info.result = result; finished_info.type = op->type; finished_info.id = op->id; - + if(op->callback == NULL) { globus_gfs_ipc_reply_finished( @@ -2444,7 +2443,7 @@ globus_l_gfs_authorize_cb( &finished_info, op->user_arg); } - + globus_mutex_lock(&op->session_handle->mutex); { if(op->data_handle != NULL) @@ -2455,19 +2454,19 @@ globus_l_gfs_authorize_cb( op->data_handle->state = GLOBUS_L_GFS_DATA_HANDLE_VALID; break; - + case GLOBUS_L_GFS_DATA_HANDLE_CLOSING: break; - + case GLOBUS_L_GFS_DATA_HANDLE_CLOSED: case GLOBUS_L_GFS_DATA_HANDLE_CLOSING_AND_DESTROYED: if(!op->data_handle->is_mine) { - remote_data_arg = + remote_data_arg = op->data_handle->remote_data_arg; } break; - + case GLOBUS_L_GFS_DATA_HANDLE_TE_PRE_CLOSED: case GLOBUS_L_GFS_DATA_HANDLE_TE_PRE_AND_DESTROYED: case GLOBUS_L_GFS_DATA_HANDLE_VALID: @@ -2480,9 +2479,9 @@ globus_l_gfs_authorize_cb( } globus_mutex_unlock(&op->session_handle->mutex); globus_assert(destroy_op); - + globus_l_gfs_data_fire_cb(op, remote_data_arg, destroy_session); - + globus_l_gfs_data_operation_destroy(op); } } @@ -2618,7 +2617,7 @@ globus_i_gfs_data_new_dsi( globus_result_t result = GLOBUS_SUCCESS; GlobusGFSName(globus_i_gfs_data_new_dsi); GlobusGFSDebugEnter(); - + if(check_name) { module_name = globus_i_gfs_config_get_module_name(dsi_name); @@ -2652,7 +2651,7 @@ globus_i_gfs_data_new_dsi( goto err; } } - + /* check again */ new_dsi = (globus_gfs_storage_iface_t *) globus_extension_lookup( dsi_handle, GLOBUS_GFS_DSI_REGISTRY, (void *) module_name); @@ -2665,7 +2664,7 @@ globus_i_gfs_data_new_dsi( *dsi_iface = new_dsi; return GLOBUS_SUCCESS; - + err: *dsi_iface = NULL; GlobusGFSDebugExit(); @@ -2679,7 +2678,6 @@ globus_l_gfs_data_new_dsi( const char * in_module_name) { const char * module_name; - globus_result_t result; GlobusGFSName(globus_l_gfs_data_new_dsi); GlobusGFSDebugEnter(); @@ -2708,7 +2706,7 @@ globus_l_gfs_data_new_dsi( globus_extension_release(session_handle->mod_dsi_handle); session_handle->mod_dsi_name = globus_libc_strdup(module_name); - result = globus_i_gfs_data_new_dsi( + globus_i_gfs_data_new_dsi( &session_handle->mod_dsi_handle, session_handle->mod_dsi_name, &session_handle->mod_dsi, @@ -2722,7 +2720,7 @@ globus_l_gfs_data_new_dsi( else { session_handle->mod_dsi_name = globus_libc_strdup(module_name); - result = globus_i_gfs_data_new_dsi( + globus_i_gfs_data_new_dsi( &session_handle->mod_dsi_handle, session_handle->mod_dsi_name, &session_handle->mod_dsi, @@ -2813,7 +2811,7 @@ globus_l_gfs_data_brain_ready_delay_cb( globus_free(op->session_handle->home_dir); } op->session_handle->home_dir = strdup("/"); - } + } finished_info.info.session.home_dir = op->session_handle->home_dir; @@ -2830,7 +2828,7 @@ globus_l_gfs_data_brain_ready_delay_cb( op->user_arg); } globus_l_gfs_data_reset_watchdog(op->session_handle, NULL); - + globus_mutex_lock(&op->session_handle->mutex); { GFSDataOpDec(op, destroy_op, destroy_session); @@ -2942,9 +2940,9 @@ globus_l_libc_initgroups_cb( { globus_l_libc_initgroups_info_t * info; int rc; - + info = (globus_l_libc_initgroups_info_t *) user_arg; - + globus_mutex_lock(&info->mutex); { rc = initgroups(info->username, info->gid); @@ -2952,7 +2950,7 @@ globus_l_libc_initgroups_cb( { info->rc = rc; } - + info->count--; if(info->count == 0) { @@ -2977,7 +2975,7 @@ globus_libc_initgroups( int threads; char * tmp; - threads = 2; /* XXX include globus_callback_threads.c to get #define? */ + threads = 2; /* XXX include globus_callback_threads.c to get #define? */ if((tmp = globus_module_getenv("GLOBUS_CALLBACK_POLLING_THREADS")) != NULL) { rc = atoi(tmp); @@ -2987,7 +2985,7 @@ globus_libc_initgroups( } } - info = (globus_l_libc_initgroups_info_t *) + info = (globus_l_libc_initgroups_info_t *) globus_malloc(sizeof(globus_l_libc_initgroups_info_t)); globus_mutex_init(&info->mutex, NULL); @@ -3008,14 +3006,14 @@ globus_libc_initgroups( info); info->count++; } - + while(info->count > 0) { globus_cond_wait(&info->cond, &info->mutex); } } globus_mutex_unlock(&info->mutex); - + tmprc = info->rc; globus_mutex_destroy(&info->mutex); globus_cond_destroy(&info->cond); @@ -3028,13 +3026,13 @@ globus_libc_initgroups( { rc = tmprc; } - + return rc; } int globus_list_cmp_alias_ent( - void * a, + void * a, void * b, void * arg) { @@ -3045,7 +3043,7 @@ globus_list_cmp_alias_ent( char b_tmp[b_ent->alias_len+1]; size_t a_i; size_t b_i; - + strcpy(a_tmp, a_ent->alias ? a_ent->alias : ""); strcpy(b_tmp, b_ent->alias ? b_ent->alias : ""); @@ -3060,14 +3058,14 @@ globus_list_cmp_alias_ent( case '*': a_tmp[a_i] = 1; break; - case '?': + case '?': a_tmp[a_i] = 2; break; - case '[': + case '[': a_tmp[a_i] = 3; break; } - } + } b_i = strcspn(b_tmp, "[*?"); if(b_i < b_ent->alias_len) @@ -3077,15 +3075,15 @@ globus_list_cmp_alias_ent( case '*': b_tmp[b_i] = 1; break; - case '?': + case '?': b_tmp[b_i] = 2; break; - case '[': + case '[': b_tmp[b_i] = 3; break; } } - + return strcmp(a_tmp, b_tmp) >= 0; } @@ -3102,7 +3100,7 @@ globus_l_gfs_data_update_var_path( GlobusGFSDebugEnter(); path = globus_libc_strdup(in_path); - + if((var = strstr(path, "$USER")) != NULL) { *var = '\0'; @@ -3123,9 +3121,9 @@ globus_l_gfs_data_update_var_path( } if((var = strstr(path, "~")) != NULL) { - char * tmp_home; - - tmp_home = session_handle->home_dir ? + char * tmp_home; + + tmp_home = session_handle->home_dir ? session_handle->home_dir : session_handle->true_home; *var = '\0'; var += 1; @@ -3134,10 +3132,10 @@ globus_l_gfs_data_update_var_path( globus_free(path); path = new_path; } - + return path; -} - +} + static void globus_l_gfs_data_update_restricted_paths( @@ -3150,27 +3148,27 @@ globus_l_gfs_data_update_restricted_paths( char * var_path; GlobusGFSName(globus_l_gfs_data_update_restricted_paths); GlobusGFSDebugEnter(); - - + + if(!globus_list_empty(*rp_list)) - { + { for(list = *rp_list; !globus_list_empty(list); list = globus_list_rest(list)) - { + { alias_ent = globus_list_first(list); - + if(alias_ent->alias[0] == '~' || strchr(alias_ent->alias, '$')) { var_path = globus_l_gfs_data_update_var_path( session_handle, alias_ent->alias); - + globus_free(alias_ent->alias); - alias_ent->alias = var_path; + alias_ent->alias = var_path; alias_ent->alias_len = strlen(alias_ent->alias); resort = GLOBUS_TRUE; - + #ifdef WIN32 for(var_path = alias_ent->alias; *var_path != '\0'; var_path++) { @@ -3179,15 +3177,15 @@ globus_l_gfs_data_update_restricted_paths( #endif } - if(alias_ent->realpath && + if(alias_ent->realpath && (alias_ent->realpath[0] == '~' || strchr(alias_ent->realpath, '$'))) { var_path = globus_l_gfs_data_update_var_path( session_handle, alias_ent->realpath); - + globus_free(alias_ent->realpath); - alias_ent->realpath = var_path; - alias_ent->realpath_len = strlen(alias_ent->realpath); + alias_ent->realpath = var_path; + alias_ent->realpath_len = strlen(alias_ent->realpath); #ifdef WIN32 for(var_path = alias_ent->realpath; *var_path != '\0'; var_path++) @@ -3197,7 +3195,7 @@ globus_l_gfs_data_update_restricted_paths( #endif } } - + if(resort) { *rp_list = globus_list_sort_destructive( @@ -3218,31 +3216,31 @@ globus_l_gfs_data_update_restricted_paths_symlinks( globus_bool_t resort = GLOBUS_FALSE; GlobusGFSName(globus_l_gfs_data_update_restricted_paths); GlobusGFSDebugEnter(); - + if(!globus_i_gfs_config_bool("rp_follow_symlinks") && session_handle && session_handle->dsi->descriptor & GLOBUS_GFS_DSI_DESCRIPTOR_HAS_REALPATH && session_handle->dsi->realpath_func) { if(!globus_list_empty(*rp_list)) - { + { for(list = *rp_list; !globus_list_empty(list); list = globus_list_rest(list)) - { + { char * real_path = NULL; globus_bool_t result; - + alias_ent = globus_list_first(list); - + result = session_handle->dsi->realpath_func( alias_ent->alias, &real_path, session_handle->session_arg); - + if(result == GLOBUS_SUCCESS && real_path) { if(strcmp(real_path, alias_ent->alias) != 0) { globus_l_gfs_alias_ent_t * new_ent; - + new_ent = (globus_l_gfs_alias_ent_t *) globus_calloc(1, sizeof(globus_l_gfs_alias_ent_t)); new_ent->access = alias_ent->access; @@ -3253,9 +3251,9 @@ globus_l_gfs_data_update_restricted_paths_symlinks( new_ent->realpath = strdup(alias_ent->realpath); new_ent->realpath_len = alias_ent->realpath_len; } - + globus_list_insert(&new_list, new_ent); - + resort = GLOBUS_TRUE; } else @@ -3263,15 +3261,15 @@ globus_l_gfs_data_update_restricted_paths_symlinks( globus_free(real_path); real_path = NULL; } - } + } } - + if(resort) { while(!globus_list_empty(new_list)) { globus_list_insert( - rp_list, + rp_list, globus_list_remove(&new_list, new_list)); } @@ -3298,20 +3296,20 @@ globus_l_gfs_data_parse_restricted_paths( char * chroot_path_esc = NULL; GlobusGFSName(globus_l_gfs_data_parse_restricted_paths); GlobusGFSDebugEnter(); - + list = globus_list_from_string(restrict_paths, ',', NULL); - + /* escape glob chars in chroot */ if(is_virtual && session_handle && session_handle->chroot_path && - strcspn(session_handle->chroot_path, "[*?") != + strcspn(session_handle->chroot_path, "[*?") != strlen(session_handle->chroot_path)) { char * ptr; char * ptr_esc; - - chroot_path_esc = + + chroot_path_esc = (char *) malloc(2 * strlen(session_handle->chroot_path) + 1); - + ptr = session_handle->chroot_path; ptr_esc = chroot_path_esc; while(*ptr) @@ -3324,7 +3322,7 @@ globus_l_gfs_data_parse_restricted_paths( case ']': case '\\': *ptr_esc++ = '\\'; - + default: *ptr_esc++ = *ptr++; break; @@ -3344,13 +3342,13 @@ globus_l_gfs_data_parse_restricted_paths( char * ptr; char * alias; globus_bool_t done; - + ent = (globus_l_gfs_alias_ent_t *) globus_malloc(sizeof(globus_l_gfs_alias_ent_t)); ent->access = 0; - - ent_str = (char *) globus_list_remove(&list, list); - + + ent_str = (char *) globus_list_remove(&list, list); + ptr = ent_str; done = GLOBUS_FALSE; while(*ptr && !done) @@ -3362,7 +3360,7 @@ globus_l_gfs_data_parse_restricted_paths( ent->access |= GFS_L_READ; ptr++; break; - + case 'w': case 'W': ent->access |= GFS_L_WRITE; @@ -3374,7 +3372,7 @@ globus_l_gfs_data_parse_restricted_paths( ent->access |= GFS_L_NONE; ptr++; break; - + case '/': case '~': case '$': @@ -3387,7 +3385,7 @@ globus_l_gfs_data_parse_restricted_paths( } done = GLOBUS_TRUE; break; - + default: done = GLOBUS_TRUE; GlobusGFSErrorGenericStr(result, @@ -3396,24 +3394,24 @@ globus_l_gfs_data_parse_restricted_paths( "The entry '%s' is invalid.\n", ent_str)); return result; break; - } + } } ent->access |= GFS_L_LIST; - + if(ent->access & GFS_L_NONE) { ent->access = GFS_L_NONE; } - + if((alias = strchr(ptr, ':')) != NULL) { *alias = '\0'; alias++; - + ent->alias = globus_libc_strdup(alias); globus_url_string_hex_decode(ent->alias); ent->alias_len = strlen(ent->alias); - + ent->realpath = globus_libc_strdup(ptr); globus_url_string_hex_decode(ent->realpath); ent->realpath_len = strlen(ent->realpath); @@ -3423,7 +3421,7 @@ globus_l_gfs_data_parse_restricted_paths( ent->alias = globus_libc_strdup(ptr); globus_url_string_hex_decode(ent->alias); ent->alias_len = strlen(ent->alias); - + ent->realpath = NULL; ent->realpath_len = 0; } @@ -3431,7 +3429,7 @@ globus_l_gfs_data_parse_restricted_paths( if(strchr(GFS_RP_LEAD_CHARS, *ent->alias) == NULL || (ent->realpath && strchr(GFS_RP_LEAD_CHARS, *ent->alias) == NULL)) - { + { globus_free(ent->alias); if(ent->realpath) { @@ -3442,22 +3440,22 @@ globus_l_gfs_data_parse_restricted_paths( else { if(is_virtual) - { + { char * tmp_path; - + if(ent->realpath) { globus_free(ent->realpath); ent->realpath = NULL; ent->realpath_len = 0; } - + if(ent->alias[0] == '~') { tmp_path = globus_common_create_string( - "%s%s", - chroot_path_esc ? - "/" : session_handle->home_dir, + "%s%s", + chroot_path_esc ? + "/" : session_handle->home_dir, ent->alias + 1); globus_free(ent->alias); ent->alias = tmp_path; @@ -3466,15 +3464,15 @@ globus_l_gfs_data_parse_restricted_paths( else { if(chroot_path_esc) - { - tmp_path = globus_common_create_string("%s%s", + { + tmp_path = globus_common_create_string("%s%s", chroot_path_esc, ent->alias); globus_free(ent->alias); ent->alias = tmp_path; ent->alias_len = strlen(ent->alias); } } - + if(ent->alias_len > 1 && ent->alias[ent->alias_len - 1] == '/') { ent->alias[ent->alias_len - 1] = '\0'; @@ -3485,12 +3483,12 @@ globus_l_gfs_data_parse_restricted_paths( #ifdef WIN32 globus_l_gfs_alias_ent_t * new_ent; char * tmp_ptr; - + for(tmp_ptr = ent->alias; *tmp_ptr != '\0'; tmp_ptr++) { *tmp_ptr = tolower(*tmp_ptr); } - + if(ent->realpath) { for(tmp_ptr = ent->realpath; *tmp_ptr != '\0'; tmp_ptr++) @@ -3500,7 +3498,7 @@ globus_l_gfs_data_parse_restricted_paths( } #endif globus_list_insert(&tmp_list, ent); - + #ifdef WIN32 /* now store driveletter:/path form of the ent */ if(ent->alias[0] == '/' && ent->alias[1] == '\0') @@ -3508,7 +3506,7 @@ globus_l_gfs_data_parse_restricted_paths( /* the root path needs to mean every drive letter */ DWORD drivemask; char drive[] = "a"; - + drivemask = GetLogicalDrives(); while(drivemask && *drive <= 'z') { @@ -3520,7 +3518,7 @@ globus_l_gfs_data_parse_restricted_paths( new_ent->alias_len = strlen("_:/"); new_ent->alias = strdup("_:/"); new_ent->alias[0] = *drive; - + globus_list_insert(&tmp_list, new_ent); } (*drive)++; @@ -3535,7 +3533,7 @@ globus_l_gfs_data_parse_restricted_paths( new_ent->alias = globus_libc_strdup(ent->alias); new_ent->realpath = globus_libc_strdup(ent->realpath); ent = new_ent; - + if(!ent->realpath && ent->alias[0] == '/' && isalpha(ent->alias[1])) { @@ -3549,7 +3547,7 @@ globus_l_gfs_data_parse_restricted_paths( ent->alias_len = 3; } } - + if(ent->realpath && ent->realpath[0] == '/' && isalpha(ent->realpath[1])) { @@ -3566,11 +3564,11 @@ globus_l_gfs_data_parse_restricted_paths( globus_list_insert(&tmp_list, ent); } #endif - } + } } } - + if(!globus_list_empty(tmp_list)) { *out_list = globus_list_sort_destructive( @@ -3580,7 +3578,7 @@ globus_l_gfs_data_parse_restricted_paths( { result = GlobusGFSErrorGeneric("No valid paths added to restricted list."); } - + GlobusGFSDebugExit(); return result; } @@ -3631,7 +3629,7 @@ globus_l_gfs_data_read_share_file( res = GlobusGFSErrorGeneric("Problem allocating memory.\n"); goto error_mem; } - + while(fgets(linebuf, linebuflen, fptr) != NULL) { p = linebuf; @@ -3650,7 +3648,7 @@ globus_l_gfs_data_read_share_file( goto error_mem; } strncat(linebuf, part_line, linebuflen); - + optionbuf = globus_realloc(optionbuf, linebuflen); if(!optionbuf) { @@ -3667,7 +3665,7 @@ globus_l_gfs_data_read_share_file( } line_num++; p = linebuf; - optlen = 0; + optlen = 0; while(*p && isspace(*p)) { p++; @@ -3679,7 +3677,7 @@ globus_l_gfs_data_read_share_file( if(*p == '#') { continue; - } + } if(*p == '"') { @@ -3689,14 +3687,14 @@ globus_l_gfs_data_read_share_file( else { rc = sscanf(p, "%s", optionbuf); - } + } if(rc != 1) - { + { goto error_parse; } optlen += strlen(optionbuf); p = p + optlen; - + optlen = 0; while(*p && isspace(*p)) { @@ -3710,13 +3708,13 @@ globus_l_gfs_data_read_share_file( else { rc = sscanf(p, "%s", valuebuf); - } + } if(rc != 1) - { + { goto error_parse; - } + } optlen += strlen(valuebuf); - p = p + optlen; + p = p + optlen; while(*p && isspace(*p)) { p++; @@ -3725,7 +3723,7 @@ globus_l_gfs_data_read_share_file( { goto error_parse; } - + if(!strcmp(optionbuf, "share_path")) { *share_path = strdup(valuebuf); @@ -3734,11 +3732,11 @@ globus_l_gfs_data_read_share_file( } fclose(fptr); - + globus_free(linebuf); globus_free(valuebuf); globus_free(optionbuf); - + GlobusGFSDebugExit(); return GLOBUS_SUCCESS; @@ -3769,7 +3767,7 @@ globus_l_gfs_data_check_sharing_perms( owned by user; must have no group and world perms */ if(statbuf.st_uid == session_handle->uid) { - if((statbuf.st_mode & + if((statbuf.st_mode & (S_IRGRP | S_IXGRP | S_IWGRP | S_IROTH | S_IWOTH | S_IXOTH)) == 0) { rc = 0; @@ -3783,7 +3781,7 @@ globus_l_gfs_data_check_sharing_perms( dir); } } - + /* case 2: community state directory world or group writable not world or group readable @@ -3791,7 +3789,7 @@ globus_l_gfs_data_check_sharing_perms( #ifndef WIN32 else if((statbuf.st_mode & (S_IWGRP | S_IWOTH)) != 0) { - if(statbuf.st_uid == 0 && ((statbuf.st_mode & S_ISVTX) != 0) && + if(statbuf.st_uid == 0 && ((statbuf.st_mode & S_ISVTX) != 0) && ((statbuf.st_mode & (S_IRGRP | S_IROTH)) == 0)) { rc = 0; @@ -3825,7 +3823,7 @@ globus_l_gfs_data_check_sharing_perms( "accessed.\n", dir); } - + return rc; } @@ -3861,7 +3859,7 @@ globus_l_gfs_data_check_sharing_allowed( * if the deny list includes the user, he is immediately denied. * if the allow list includes the user, he is immediately allowed. * if the allow list is unset, he is allowed pending the group check. - * if the allow list is set and does not include the user, he is denied + * if the allow list is set and does not include the user, he is denied pending the group check. */ if(user_allow == NULL) @@ -3873,7 +3871,7 @@ globus_l_gfs_data_check_sharing_allowed( { allowed = GLOBUS_FALSE; explicitly = GLOBUS_FALSE; - + user = user_allow; while((ptr = strchr(user, ',')) != NULL && !allowed) { @@ -3917,13 +3915,13 @@ globus_l_gfs_data_check_sharing_allowed( } } globus_free(user_deny); - } + } if(explicitly) { goto finish; } - + group_deny = globus_libc_strdup( globus_gfs_config_get_string("sharing_groups_deny")); @@ -3942,7 +3940,7 @@ globus_l_gfs_data_check_sharing_allowed( while((ptr = strchr(group, ',')) != NULL && !allowed) { *ptr = '\0'; - + grent = getgrnam(group); if(grent) { @@ -4021,7 +4019,7 @@ globus_l_gfs_data_check_sharing_allowed( } } } - } + } if(group_deny) { globus_free(group_deny); @@ -4078,18 +4076,18 @@ globus_l_gfs_data_authorize( auth_level = globus_i_gfs_config_int("auth_level"); pw_file = (char *) globus_i_gfs_config_string("pw_file"); process_username = globus_i_gfs_config_string("process_user"); - /* if there is a subject or del cred we are using gsi, + /* if there is a subject or del cred we are using gsi, look it up in the gridmap */ sharing_dn = globus_i_gfs_config_string("sharing_dn"); op->session_handle->sharing = (sharing_dn != NULL); - + if(session_info->subject != NULL || session_info->del_cred != NULL) { if(sharing_dn && !strcmp(sharing_dn, session_info->subject)) { - if(session_info->username && - strncmp(session_info->username, - GLOBUS_SHARING_PREFIX, + if(session_info->username && + strncmp(session_info->username, + GLOBUS_SHARING_PREFIX, strlen(GLOBUS_SHARING_PREFIX)) == 0) { char * usr_tmp; @@ -4099,13 +4097,13 @@ globus_l_gfs_data_authorize( globus_size_t cert_len = 0; char * tmp; globus_gsi_cred_handle_t tmp_cred_handle; - - shared_user_str = + + shared_user_str = session_info->username + strlen(GLOBUS_SHARING_PREFIX); ptr = shared_user_str; - + if((usr_tmp = globus_i_gfs_kv_getval(ptr, "USER", 1)) != NULL) - { + { session_info->map_user = GLOBUS_FALSE; } else @@ -4114,7 +4112,7 @@ globus_l_gfs_data_authorize( session_info->map_user = GLOBUS_TRUE; } - if((op->session_handle->sharing_id = + if((op->session_handle->sharing_id = globus_i_gfs_kv_getval(ptr, "ID", 1)) == NULL) { res = GlobusGFSErrorGeneric( @@ -4135,7 +4133,7 @@ globus_l_gfs_data_authorize( } if((crt_tmp = globus_i_gfs_kv_getval(ptr, "CERT", 0)) != NULL) - { + { desired_user_cert = malloc(strlen(crt_tmp + 1)); res = globus_l_gfs_base64_decode( (globus_byte_t *) crt_tmp, @@ -4158,7 +4156,7 @@ globus_l_gfs_data_authorize( { goto pwent_error; } - + globus_gfs_log_message( GLOBUS_GFS_LOG_INFO, "DN %s has provided sharing credentials for DN %s.\n", @@ -4182,31 +4180,31 @@ globus_l_gfs_data_authorize( "Invalid arguments for " GLOBUS_SHARING_PREFIX ". Missing SHAREE."); goto pwent_error; } - + globus_free(session_info->username); session_info->username = usr_tmp; sharing_attempted = GLOBUS_TRUE; - } + } } - if(!sharing_attempted && session_info->username && - strncmp(session_info->username, - GLOBUS_SHARING_PREFIX, + if(!sharing_attempted && session_info->username && + strncmp(session_info->username, + GLOBUS_SHARING_PREFIX, strlen(GLOBUS_SHARING_PREFIX)) == 0) { GlobusGFSErrorGenericStr(res, ("Sharing not allowed with DN %s", session_info->subject)); goto pwent_error; } - + if(!(auth_level & GLOBUS_L_GFS_AUTH_NOGRIDMAP)) { - if(globus_i_gfs_config_bool("cas") && + if(globus_i_gfs_config_bool("cas") && (context || sharing_attempted)) { globus_bool_t free_usr = GLOBUS_FALSE; - + if(session_info->map_user) { usr = NULL; @@ -4217,7 +4215,7 @@ globus_l_gfs_data_authorize( } *authz_usr = '\0'; - + if(sharing_attempted) { res = globus_gss_assist_map_and_authorize_sharing( @@ -4226,7 +4224,7 @@ globus_l_gfs_data_authorize( usr, authz_usr, USER_NAME_MAX); - + globus_free(desired_user_cert); desired_user_cert = NULL; } @@ -4515,7 +4513,7 @@ globus_l_gfs_data_authorize( res = GlobusGFSErrorGeneric("Access denied by configuration."); goto pwent_error; } - + /* check that account is not disabled */ if(pwent && !globus_i_gfs_config_bool("allow_disabled_login")) { @@ -4526,7 +4524,7 @@ globus_l_gfs_data_authorize( errmsg = globus_error_print_friendly(globus_error_peek(res)); globus_gfs_log_message( GLOBUS_GFS_LOG_ERR, - "Access denied for user '%s': %s\n", + "Access denied for user '%s': %s\n", session_info->username, errmsg); globus_free(errmsg); res = GlobusGFSErrorGeneric( @@ -4566,7 +4564,7 @@ globus_l_gfs_data_authorize( goto uid_error; } } - + if(pwent->pw_uid == 0 && !globus_i_gfs_config_bool("allow_root")) { @@ -4626,23 +4624,23 @@ globus_l_gfs_data_authorize( var_dir = globus_l_gfs_data_update_var_path( op->session_handle, custom_home_dir); - + op->session_handle->home_dir = var_dir; } else { - op->session_handle->home_dir = + op->session_handle->home_dir = globus_libc_strdup(op->session_handle->true_home); } - + if(sharing_dn) { char * sharing_state; - + sharing_state = globus_i_gfs_config_string("sharing_state_dir"); - op->session_handle->sharing_state_dir = + op->session_handle->sharing_state_dir = globus_l_gfs_data_update_var_path( - op->session_handle, + op->session_handle, sharing_state ? sharing_state : "$HOME/.globus/sharing"); if(!op->session_handle->sharing_state_dir) @@ -4650,7 +4648,7 @@ globus_l_gfs_data_authorize( res = GlobusGFSErrorMemory("sharing state dir"); goto pwent_error; } - + if(sharing_attempted) { char * share_path = NULL; @@ -4665,7 +4663,7 @@ globus_l_gfs_data_authorize( session_info->username)); goto pwent_error; } - + share_file = globus_common_create_string( "%s/share-%s", op->session_handle->sharing_state_dir, @@ -4745,16 +4743,16 @@ globus_l_gfs_data_authorize( } globus_free(share_file); share_file = NULL; - + globus_gfs_log_message( GLOBUS_GFS_LOG_INFO, "Access allowed for sharing of user '%s' from share id '%s'. " "Sharee '%s' is restricted to '%s'.\n", - session_info->username, - op->session_handle->sharing_id, - op->session_handle->sharing_sharee, + session_info->username, + op->session_handle->sharing_id, + op->session_handle->sharing_sharee, op->session_handle->chroot_path); - + if(op->session_handle->chroot_path[1] == '\0') { globus_free(op->session_handle->chroot_path); @@ -4772,13 +4770,13 @@ globus_l_gfs_data_authorize( { tmp_restrict = globus_common_create_string( "RW/,N%s,N~/.*", op->session_handle->sharing_state_dir); - } + } #ifdef WIN32 if(strstr(tmp_restrict, ":/")) { char * tp; tp = strstr(tmp_restrict, ":/"); - tp--; + tp--; tp[1] = tp[0]; tp[0] = '/'; } @@ -4788,18 +4786,18 @@ globus_l_gfs_data_authorize( while(!globus_list_empty(tmp_list)) { globus_list_insert( - &globus_l_gfs_path_alias_list_sharing, + &globus_l_gfs_path_alias_list_sharing, globus_list_remove(&tmp_list, tmp_list)); } globus_free(tmp_restrict); - + if(res != GLOBUS_SUCCESS) { goto pwent_error; } } } - + globus_l_gfs_data_update_restricted_paths( op->session_handle, &globus_l_gfs_path_alias_list_base); globus_l_gfs_data_update_restricted_paths( @@ -4821,8 +4819,8 @@ globus_l_gfs_data_authorize( { op->session_handle->active_rp_list = &globus_l_gfs_path_alias_list_base; } - - if(!globus_i_gfs_config_bool("use_home_dirs") || + + if(!globus_i_gfs_config_bool("use_home_dirs") || op->session_handle->home_dir == NULL) { if(op->session_handle->home_dir) @@ -4830,22 +4828,22 @@ globus_l_gfs_data_authorize( globus_free(op->session_handle->home_dir); } op->session_handle->home_dir = strdup("/"); - } + } if(op->session_handle->real_username == NULL) { - if(pwent) + if(pwent) { - op->session_handle->real_username = + op->session_handle->real_username = globus_libc_strdup(pwent->pw_name); } else { - op->session_handle->real_username = + op->session_handle->real_username = globus_libc_strdup(op->session_handle->username); } } - + globus_gfs_log_event( GLOBUS_GFS_LOG_INFO, GLOBUS_GFS_LOG_EVENT_END, @@ -4992,7 +4990,7 @@ globus_l_gfs_load_safe( GLOBUS_GFS_LOG_ERR, "Some network stack drivers failed to load: %s\n", msg = globus_error_print_friendly(globus_error_peek(result))); - + if(msg) { globus_free(msg); @@ -5071,7 +5069,7 @@ globus_i_gfs_data_dsi_checksum_support( } -char * +char * globus_i_gfs_data_dsi_version() { int rc; @@ -5080,15 +5078,15 @@ globus_i_gfs_data_dsi_version() GlobusGFSName(globus_i_gfs_data_init); GlobusGFSDebugEnter(); - + rc = globus_extension_get_module_version( globus_l_gfs_active_dsi_handle, &version); if(rc == GLOBUS_SUCCESS) { str = globus_common_create_string( - "%s-%d.%d", - globus_l_gfs_active_dsi_name, - version.major, + "%s-%d.%d", + globus_l_gfs_active_dsi_name, + version.major, version.minor); } @@ -5107,19 +5105,19 @@ globus_i_gfs_data_init() globus_extension_register_builtins(local_extensions); - globus_l_gfs_active_dsi_name = + globus_l_gfs_active_dsi_name = globus_i_gfs_config_string("load_dsi_module"); result = globus_i_gfs_data_new_dsi( - &globus_l_gfs_active_dsi_handle, + &globus_l_gfs_active_dsi_handle, globus_l_gfs_active_dsi_name, - &globus_l_gfs_dsi, + &globus_l_gfs_dsi, GLOBUS_FALSE); if(result != GLOBUS_SUCCESS) { globus_gfs_log_exit_message( - "Couldn't load '%s'. %s\n", globus_l_gfs_active_dsi_name, + "Couldn't load '%s'. %s\n", globus_l_gfs_active_dsi_name, globus_error_print_friendly(globus_error_peek(result))); exit(1); } @@ -5158,7 +5156,7 @@ globus_i_gfs_data_init() { result = globus_l_gfs_data_parse_restricted_paths( NULL, restrict_path, &globus_l_gfs_path_alias_list_sharing, 0); - + if(result != GLOBUS_SUCCESS) { globus_gfs_log_exit_result("Error parsing sharing restricted paths", result); @@ -5171,7 +5169,7 @@ globus_i_gfs_data_init() { result = globus_l_gfs_data_parse_restricted_paths( NULL, restrict_path, &globus_l_gfs_path_alias_list_sharing, 0); - + if(result != GLOBUS_SUCCESS) { globus_gfs_log_exit_result("Error parsing restricted paths", result); @@ -5184,14 +5182,14 @@ globus_i_gfs_data_init() { result = globus_l_gfs_data_parse_restricted_paths( NULL, restrict_path, &globus_l_gfs_path_alias_list_base, 0); - + if(result != GLOBUS_SUCCESS) { globus_gfs_log_exit_result("Error parsing restricted paths", result); exit(1); } } - + if(globus_i_gfs_config_bool("inetd")) { globus_l_gfs_watchdog_limit = globus_i_gfs_config_int("control_idle_timeout"); @@ -5200,30 +5198,30 @@ globus_i_gfs_data_init() globus_l_gfs_watchdog_limit = 300; } } - + if(globus_i_gfs_config_bool("allow_udt")) { result = globus_xio_driver_load("udt", &globus_l_gfs_udt_driver_preload); if(result != GLOBUS_SUCCESS) { globus_gfs_log_result( - GLOBUS_GFS_LOG_INFO, + GLOBUS_GFS_LOG_INFO, "Unable to load UDT driver", result); globus_gfs_config_set_bool("allow_udt", GLOBUS_FALSE); } } - + if((globus_i_gfs_config_string("netmgr")) != NULL) { result = globus_xio_driver_load("net_manager", &globus_l_gfs_netmgr_driver); if(result != GLOBUS_SUCCESS) { globus_gfs_log_result( - GLOBUS_GFS_LOG_INFO, + GLOBUS_GFS_LOG_INFO, "Unable to load Network Manager driver", result); } - } - + } + GlobusGFSDebugExit(); } @@ -5454,7 +5452,7 @@ globus_l_gfs_data_stat_kickout( { reply.code = 100; } - + reply.type = GLOBUS_GFS_OP_STAT; reply.id = bounce_info->op->id; reply.result = bounce_info->error ? @@ -5466,7 +5464,7 @@ globus_l_gfs_data_stat_kickout( reply.info.stat.gid_array = (int *)bounce_info->op->session_handle->gid_array; /* pull response code from error */ - if(bounce_info->final_stat && reply.result != GLOBUS_SUCCESS && + if(bounce_info->final_stat && reply.result != GLOBUS_SUCCESS && (code = globus_gfs_error_get_ftp_response_code( globus_error_peek(reply.result))) != 0) { @@ -5499,13 +5497,13 @@ globus_l_gfs_data_stat_kickout( bounce_info->op->session_handle, bounce_info->op->data_handle); } globus_mutex_unlock(&bounce_info->op->session_handle->mutex); - + globus_assert(destroy_op); globus_l_gfs_data_fire_cb( bounce_info->op, remote_data_arg, destroy_session); globus_l_gfs_data_operation_destroy(bounce_info->op); } - + if(bounce_info->stat_array) { for(i = 0; i < bounce_info->stat_count; i++) @@ -5563,7 +5561,7 @@ globus_l_gfs_data_approve_popen( result = GlobusGFSErrorGeneric("small malloc failure."); goto error; } - + end = cmd; while(end && (ptr = strstr(end, "popen:"))) { @@ -5574,23 +5572,23 @@ globus_l_gfs_data_approve_popen( result = GlobusGFSErrorGeneric("popen argv not supplied."); goto error; } - + ptr += 5; - + delim = *ptr; - *ptr = '\0'; + *ptr = '\0'; ptr++; - + endchars[0] = delim; end = strpbrk(ptr, endchars); - + if(end != NULL) { end_delim = *end; *end = '\0'; end++; } - + for(found = GLOBUS_FALSE, list = (globus_list_t *) globus_i_gfs_config_get("popen_list"); !globus_list_empty(list) && !found; @@ -5608,14 +5606,14 @@ globus_l_gfs_data_approve_popen( { size = strlen(alias); prog = alias; - + } if((strncmp(alias, ptr, size) == 0 && strlen(ptr) == size) || strcmp(prog, ptr) == 0) { found = GLOBUS_TRUE; } - } + } if(found) { if(access(prog, R_OK | X_OK) < 0) @@ -5639,7 +5637,7 @@ globus_l_gfs_data_approve_popen( } else { - tmp = globus_common_create_string("%s%s%c%s", + tmp = globus_common_create_string("%s%s%c%s", out ? out : "", start, delim, prog); if(out) { @@ -5668,9 +5666,9 @@ globus_l_gfs_data_approve_popen( globus_free(cmd); } - + *out_cmd = out; - + GlobusGFSDebugExit(); return result; @@ -5702,7 +5700,7 @@ globus_l_gfs_data_load_stack( globus_result_t result = GLOBUS_SUCCESS; GlobusGFSName(globus_l_gfs_data_load_stack); GlobusGFSDebugEnter(); - + if(*driver_list_out) { globus_xio_driver_list_destroy(*driver_list_out, GLOBUS_FALSE); @@ -5710,14 +5708,14 @@ globus_l_gfs_data_load_stack( } if(strcasecmp(driver_string_in, "default") == 0) - { + { driver_string = default_stack; } else { driver_string = driver_string_in; } - + if(driver_string) { result = globus_l_gfs_data_approve_popen( @@ -5733,9 +5731,9 @@ globus_l_gfs_data_load_stack( parsed_driver_string, driver_list_out, allowed_drivers); - + globus_free(parsed_driver_string); - + if(subst_io_drivers) { globus_xio_driver_list_ent_t * ent; @@ -5764,7 +5762,7 @@ globus_l_gfs_data_load_stack( } } } - + GlobusGFSDebugExit(); return result; } @@ -5867,14 +5865,14 @@ globus_i_gfs_data_request_command( else if(strcasecmp(cmd_info->cksm_alg, "P") == 0) { globus_size_t dcsc_len; - OM_uint32 major_status; + OM_uint32 major_status; OM_uint32 minor_status; - gss_buffer_desc buf; + gss_buffer_desc buf; gss_cred_id_t cred; - + dcsc_len = strlen(cmd_info->pathname); buf.value = calloc(1, dcsc_len); - + rc = globus_l_gfs_base64_decode( (globus_byte_t *) cmd_info->pathname, buf.value, &dcsc_len); if(rc != GLOBUS_SUCCESS) @@ -5884,7 +5882,7 @@ globus_i_gfs_data_request_command( "Invalid base64 input for credential type P."); } else - { + { buf.length = strlen(buf.value); major_status = gss_import_cred( &minor_status, @@ -5908,7 +5906,7 @@ globus_i_gfs_data_request_command( gss_release_cred( &min_rc, &op->session_handle->dcsc_cred); } - + op->session_handle->dcsc_cred = cred; } } @@ -5926,7 +5924,7 @@ globus_i_gfs_data_request_command( globus_byte_t * tmp_val; globus_byte_t * ca_pem = NULL; globus_size_t ca_pem_len = 0; - + op->session_handle->http_config_called = GLOBUS_TRUE; if((tmp_val = (globus_byte_t *) globus_i_gfs_kv_getval( @@ -5943,8 +5941,8 @@ globus_i_gfs_data_request_command( "Invalid base64 input for CA_CERTS."); } else - { - result = GLOBUS_SUCCESS; + { + result = GLOBUS_SUCCESS; if(op->session_handle->http_ca_certs) { globus_free(op->session_handle->http_ca_certs); @@ -5952,20 +5950,20 @@ globus_i_gfs_data_request_command( op->session_handle->http_ca_certs = (char *) ca_pem; } } - + call = GLOBUS_FALSE; globus_gridftp_server_finished_command(op, result, NULL); break; } - + case GLOBUS_GFS_CMD_HTTP_PUT: - { + { char * request; char * path; globus_off_t offset; - globus_off_t length; - + globus_off_t length; + result = globus_i_gfs_data_http_parse_args( cmd_info->pathname, &path, &request, &offset, &length); if(result == GLOBUS_SUCCESS) @@ -5982,12 +5980,12 @@ globus_i_gfs_data_request_command( break; case GLOBUS_GFS_CMD_HTTP_GET: - { + { char * request; char * path; globus_off_t offset; - globus_off_t length; - + globus_off_t length; + result = globus_i_gfs_data_http_parse_args( cmd_info->pathname, &path, &request, &offset, &length); if(result == GLOBUS_SUCCESS) @@ -6030,7 +6028,7 @@ globus_i_gfs_data_request_command( break; case GLOBUS_GFS_CMD_SITE_SETDISKSTACK: - if(session_handle->dsi->descriptor & + if(session_handle->dsi->descriptor & GLOBUS_GFS_DSI_DESCRIPTOR_SENDER) { result = globus_l_gfs_data_load_stack( @@ -6068,14 +6066,14 @@ globus_i_gfs_data_request_command( result = GlobusGFSErrorGeneric( "Sharing control is not allowed."); } - + else if(!strncasecmp(cmd_info->pathname, "CREATE", 6)) { char * share_args; char * share_path = NULL; char * share_id = NULL; char * share_file = NULL; - + share_args = strchr(cmd_info->pathname, ' '); if(!share_args) { @@ -6083,7 +6081,7 @@ globus_i_gfs_data_request_command( goto share_create_error; } share_args++; - if((share_id = + if((share_id = globus_i_gfs_kv_getval(share_args, "ID", 1)) == NULL) { result = GlobusGFSErrorGeneric( @@ -6102,7 +6100,7 @@ globus_i_gfs_data_request_command( } tmp++; } - if((share_path = + if((share_path = globus_i_gfs_kv_getval(share_args, "PATH", 1)) == NULL) { result = GlobusGFSErrorGeneric( @@ -6117,12 +6115,12 @@ globus_i_gfs_data_request_command( "Sharing is not allowed for the current user."); goto share_create_error; } - + share_file = globus_common_create_string( "%s/share-%s", op->session_handle->sharing_state_dir, share_id); - + /* check if path will be accessible */ if(result == GLOBUS_SUCCESS) { @@ -6162,14 +6160,14 @@ globus_i_gfs_data_request_command( if(access(share_file, F_OK) < 0) { int sharingfd; - + /* create state dir if default and doesn't exist */ - if(strstr(op->session_handle->sharing_state_dir, "/.globus/sharing") && + if(strstr(op->session_handle->sharing_state_dir, "/.globus/sharing") && access(op->session_handle->sharing_state_dir, F_OK) < 0) { char * tmp_dir; char * ptr; - + tmp_dir = strdup(op->session_handle->sharing_state_dir); ptr = strrchr(tmp_dir, '/'); if(ptr) @@ -6181,15 +6179,15 @@ globus_i_gfs_data_request_command( mkdir(tmp_dir, 0700); free(tmp_dir); } - + if(globus_l_gfs_data_check_sharing_perms(op->session_handle) != 0) { result = GlobusGFSErrorGeneric( "Sharing state dir has invalid permissions."); goto share_create_error; - } + } - sharingfd = + sharingfd = open(share_file, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR); if(sharingfd < 0) { @@ -6201,7 +6199,7 @@ globus_i_gfs_data_request_command( char * tmp_content; char * tmp_enc; int save_rc = 0; -#ifdef WIN32 +#ifdef WIN32 if(isalpha(share_path[0]) && share_path[1] == ':') { share_path[1] = share_path[0]; @@ -6213,8 +6211,8 @@ globus_i_gfs_data_request_command( } #endif tmp_enc = globus_url_string_hex_encode(share_path, "\""); - - tmp_content = globus_common_create_string( + + tmp_content = globus_common_create_string( "#\n# This file is required in order to enable GridFTP file sharing.\n" "# If you remove this file, file sharing will no longer work.\n#\n\n" "share_path \"%s\"\n", tmp_enc); @@ -6233,14 +6231,14 @@ globus_i_gfs_data_request_command( "Enabling sharing (close)", errno); save_rc = rc; } - + rc = chmod(share_file, S_IRUSR); if(rc < 0 && !save_rc) { result = GlobusGFSErrorSystemError( "Enabling sharing (chmod)", errno); } - + globus_free(tmp_enc); globus_free(tmp_content); } @@ -6270,7 +6268,7 @@ globus_i_gfs_data_request_command( { char * share_file = NULL; char * share_id = NULL; - + share_id = strchr(cmd_info->pathname, ' '); if(!share_id) { @@ -6290,7 +6288,7 @@ globus_i_gfs_data_request_command( } tmp++; } - + share_file = globus_common_create_string( "%s/share-%s", op->session_handle->sharing_state_dir, @@ -6340,9 +6338,9 @@ globus_i_gfs_data_request_command( result = GlobusGFSErrorGeneric("Missing path argument."); goto share_test_error; } - + share_path++; - + /** check if sharing can be enabled **/ /* creation disabled */ if(!globus_i_gfs_config_bool("sharing_control")) @@ -6350,7 +6348,7 @@ globus_i_gfs_data_request_command( result = GlobusGFSErrorGeneric( "Sharing control is not enabled."); } - + /* check allow/deny config */ else if(!globus_l_gfs_data_check_sharing_allowed(op->session_handle)) { @@ -6362,12 +6360,12 @@ globus_i_gfs_data_request_command( else { /* create state dir if default and doesn't exist */ - if(strstr(op->session_handle->sharing_state_dir, "/.globus/sharing") && + if(strstr(op->session_handle->sharing_state_dir, "/.globus/sharing") && access(op->session_handle->sharing_state_dir, F_OK) < 0) { char * tmp_dir; char * ptr; - + tmp_dir = strdup(op->session_handle->sharing_state_dir); ptr = strrchr(tmp_dir, '/'); if(ptr) @@ -6379,14 +6377,14 @@ globus_i_gfs_data_request_command( mkdir(tmp_dir, 0700); free(tmp_dir); } - + if(globus_l_gfs_data_check_sharing_perms(op->session_handle) != 0) { result = GlobusGFSErrorGeneric( "Sharing state dir has invalid permissions."); goto share_test_error; - } - + } + if(access(op->session_handle->sharing_state_dir, W_OK) == 0) { result = GLOBUS_SUCCESS; @@ -6427,9 +6425,9 @@ globus_i_gfs_data_request_command( } globus_gridftp_server_finished_command(op, result, NULL); call = GLOBUS_FALSE; - + break; - + case GLOBUS_GFS_CMD_SITE_RESTRICT: if(!globus_list_empty(session_handle->rp_list)) { @@ -6441,10 +6439,10 @@ globus_i_gfs_data_request_command( result = globus_l_gfs_data_parse_restricted_paths( session_handle, cmd_info->pathname, &session_handle->rp_list, 1); } - + globus_l_gfs_data_update_restricted_paths_symlinks( session_handle, &session_handle->rp_list); - + globus_gridftp_server_finished_command(op, result, NULL); @@ -6463,11 +6461,11 @@ globus_i_gfs_data_request_command( } else { - session_handle->chroot_path = + session_handle->chroot_path = globus_libc_strdup(cmd_info->pathname); result = GLOBUS_SUCCESS; } - + globus_gridftp_server_finished_command(op, result, NULL); call = GLOBUS_FALSE; @@ -6479,7 +6477,7 @@ globus_i_gfs_data_request_command( { result = GlobusGFSErrorGeneric( "Controller parameter must be 0 or 1."); - + globus_gridftp_server_finished_command(op, result, NULL); } @@ -6489,13 +6487,13 @@ globus_i_gfs_data_request_command( char * stunserver; globus_xio_driver_list_ent_t * ent; globus_xio_attr_t xio_attr; - + if(session_handle->net_stack_list == NULL) { result = globus_l_gfs_data_load_stack( op->session_handle->subject ? "udt,gsi" : "udt", &op->session_handle->net_stack_list, - globus_i_gfs_config_bool("allow_udt") ? + globus_i_gfs_config_bool("allow_udt") ? NULL : &gfs_l_data_net_allowed_drivers, NULL, GLOBUS_TRUE); @@ -6505,10 +6503,10 @@ globus_i_gfs_data_request_command( "Setting data channel driver stack", result); } } - + ent = globus_xio_driver_list_find_driver( session_handle->net_stack_list, "udt"); - + if(ent) { if(session_handle->udt_data_channel_inuse) @@ -6517,7 +6515,7 @@ globus_i_gfs_data_request_command( &session_handle->udt_data_channel); session_handle->udt_data_channel_inuse = GLOBUS_FALSE; } - + result = globus_ftp_control_handle_init( &session_handle->udt_data_channel); if(result != GLOBUS_SUCCESS) @@ -6527,7 +6525,7 @@ globus_i_gfs_data_request_command( goto error_upas; } session_handle->udt_data_channel_inuse = GLOBUS_TRUE; - + result = globus_i_ftp_control_data_get_attr( &session_handle->udt_data_channel, &xio_attr); @@ -6557,7 +6555,7 @@ globus_i_gfs_data_request_command( error_upas: globus_gridftp_server_finished_command(op, result, candidates); } - + call = GLOBUS_FALSE; break; @@ -6565,7 +6563,7 @@ globus_i_gfs_data_request_command( { globus_xio_driver_list_ent_t * ent; globus_xio_attr_t xio_attr; - + ent = globus_xio_driver_list_find_driver( session_handle->net_stack_list, "udt"); if(ent) @@ -6577,25 +6575,25 @@ globus_i_gfs_data_request_command( { goto error_uprt; } - + result = globus_xio_attr_cntl( xio_attr, ent->driver, 18 /* GLOBUS_XIO_UDT_SET_REMOTE_CANDIDATES */, cmd_info->pathname); - + session_handle->upas = GLOBUS_TRUE; } else { result = GlobusGFSErrorWrapFailed( "Setting data channel driver stack", result); - } + } error_uprt: globus_gridftp_server_finished_command(op, result, NULL); } - + call = GLOBUS_FALSE; break; @@ -6682,7 +6680,7 @@ globus_i_gfs_data_request_command( call = GLOBUS_FALSE; globus_gridftp_server_finished_command(op, result, NULL); break; - + case GLOBUS_GFS_CMD_SITE_TASKID: if(op->session_handle->taskid) { @@ -6699,7 +6697,7 @@ globus_i_gfs_data_request_command( { globus_free(op->session_handle->storattr_str); } - op->session_handle->storattr_str = + op->session_handle->storattr_str = globus_libc_strdup(cmd_info->pathname); call = GLOBUS_FALSE; @@ -6749,15 +6747,15 @@ globus_i_gfs_data_request_command( case GLOBUS_GFS_CMD_SITE_CHGRP: action = GFS_ACL_ACTION_WRITE; break; - + case GLOBUS_GFS_CMD_SITE_UTIME: action = GFS_ACL_ACTION_WRITE; break; - + case GLOBUS_GFS_CMD_SITE_SYMLINK: action = GFS_ACL_ACTION_CREATE; break; - + case GLOBUS_GFS_CMD_SITE_AUTHZ_ASSERT: /* * A new action to provide authorization assertions received @@ -6783,7 +6781,7 @@ globus_i_gfs_data_request_command( default: if(cmd_info->command >= GLOBUS_GFS_MIN_CUSTOM_CMD) { - if(cmd_info->op_info && cmd_info->op_info->cmd_ent && + if(cmd_info->op_info && cmd_info->op_info->cmd_ent && cmd_info->op_info->cmd_ent->access_type) { action = cmd_info->op_info->cmd_ent->access_type; @@ -6890,12 +6888,12 @@ globus_l_gfs_data_handle_init( if(session_handle->udt_data_channel_inuse) { - memcpy(&handle->data_channel, &session_handle->udt_data_channel, + memcpy(&handle->data_channel, &session_handle->udt_data_channel, sizeof(globus_ftp_control_handle_t)); session_handle->udt_data_channel_inuse = GLOBUS_FALSE; } else - { + { result = globus_ftp_control_handle_init(&handle->data_channel); if(result != GLOBUS_SUCCESS) { @@ -6964,7 +6962,7 @@ globus_l_gfs_data_handle_init( { handle->info.nstreams = 1; } - + if(handle->info.mode == 'S') { handle->info.nstreams = 1; @@ -7032,7 +7030,7 @@ globus_l_gfs_data_handle_init( dcau.mode = handle->info.dcau; dcau.subject.mode = handle->info.dcau; dcau.subject.subject = handle->info.subject; - + if(session_handle->dcsc_cred != GSS_C_NO_CREDENTIAL) { globus_xio_attr_t xio_attr; @@ -7068,7 +7066,7 @@ globus_l_gfs_data_handle_init( { cred = handle->info.del_cred; } - + result = globus_ftp_control_local_dcau( &handle->data_channel, &dcau, cred); if(result != GLOBUS_SUCCESS) @@ -7099,13 +7097,13 @@ globus_l_gfs_data_handle_init( goto error_control; } } - + /* create a default stack that we can add the netmgr driver to */ if(globus_l_gfs_netmgr_driver && globus_list_empty(net_stack_list)) { globus_xio_driver_list_ent_t * ent; globus_list_t ** tailp = &net_stack_list; - + ent = malloc(sizeof(globus_xio_driver_list_ent_t)); ent->driver = globus_io_compat_get_tcp_driver(); ent->driver_name = strdup("tcp"); @@ -7114,7 +7112,7 @@ globus_l_gfs_data_handle_init( ent->loaded = GLOBUS_TRUE; globus_list_insert(tailp, ent); tailp = globus_list_rest_ref(*tailp); - + ent = malloc(sizeof(globus_xio_driver_list_ent_t)); ent->driver = globus_io_compat_get_gsi_driver(); ent->driver_name = strdup("gsi"); @@ -7124,7 +7122,7 @@ globus_l_gfs_data_handle_init( globus_list_insert(tailp, ent); tailp = globus_list_rest_ref(*tailp); } - + if(!globus_list_empty(net_stack_list)) { globus_xio_stack_t stack; @@ -7144,7 +7142,7 @@ globus_l_gfs_data_handle_init( globus_error_print_friendly(globus_error_peek(result))); goto error_control; } - + for (p = net_stack_list; !globus_list_empty(p); p = globus_list_rest(p)) { @@ -7160,7 +7158,7 @@ globus_l_gfs_data_handle_init( } globus_xio_stack_init(&stack, NULL); - + result = globus_xio_driver_list_to_stack_attr( new_net_stack_list, stack, xio_attr); globus_list_free(new_net_stack_list); @@ -7179,10 +7177,10 @@ globus_l_gfs_data_handle_init( char * opt_str; globus_xio_stack_push_driver(stack, globus_l_gfs_netmgr_driver); - + opt_str = globus_common_create_string( - "service=gridftp-data;task-id=%s;%s", - session_handle->taskid ? session_handle->taskid : "none", + "service=gridftp-data;task-id=%s;%s", + session_handle->taskid ? session_handle->taskid : "none", globus_i_gfs_config_string("netmgr")); result = globus_xio_attr_cntl( @@ -7197,13 +7195,13 @@ globus_l_gfs_data_handle_init( "Setting network manager options \"%s\": %s\n", opt_str, globus_error_print_friendly(globus_error_peek(result))); - globus_free(opt_str); + globus_free(opt_str); goto error_control; } globus_free(opt_str); } - + result = globus_i_ftp_control_data_set_stack( &handle->data_channel, stack); if(result != GLOBUS_SUCCESS) @@ -7720,7 +7718,7 @@ globus_l_gfs_data_hybrid_session_start_cb( { globus_l_gfs_data_operation_t * op; globus_l_gfs_data_operation_t * hybrid_op; - + op = user_arg; if(op && op->hybrid_op) { @@ -7754,7 +7752,7 @@ globus_l_gfs_data_hybrid_session_start_cb( globus_l_gfs_data_passive_kickout, bounce_info); } - + else { globus_i_gfs_data_request_passive( @@ -7790,7 +7788,7 @@ globus_l_gfs_data_hybrid_session_start_cb( globus_l_gfs_data_active_kickout, bounce_info); } - + else { globus_i_gfs_data_request_active( @@ -7836,7 +7834,7 @@ globus_l_gfs_data_passive_kickout( bounce_info->handle->is_mine = GLOBUS_TRUE; bounce_info->handle->state = GLOBUS_L_GFS_DATA_HANDLE_VALID; - reply.info.data.data_arg = (void *) (intptr_t) + reply.info.data.data_arg = (void *) (intptr_t) globus_handle_table_insert( &bounce_info->handle->session_handle->handle_table, bounce_info->handle, @@ -7901,16 +7899,16 @@ globus_i_gfs_data_request_passive( session_handle = (globus_l_gfs_data_session_t *) session_arg; globus_l_gfs_data_reset_watchdog(session_handle, NULL); - if(session_handle->hybrid && data_info->max_cs != 1 && + if(session_handle->hybrid && data_info->max_cs != 1 && session_handle->dsi != globus_l_gfs_dsi_hybrid) { globus_l_gfs_data_operation_t * hybrid_op; result = globus_i_gfs_data_new_dsi( - &globus_l_gfs_active_dsi_handle, - "remote", - &globus_l_gfs_dsi_hybrid, + &globus_l_gfs_active_dsi_handle, + "remote", + &globus_l_gfs_dsi_hybrid, GLOBUS_FALSE); - + if(!globus_l_gfs_dsi_hybrid) { goto error_op; @@ -7925,7 +7923,7 @@ globus_i_gfs_data_request_passive( } session_handle->dsi = globus_l_gfs_dsi_hybrid; - + result = globus_l_gfs_data_operation_init(&op, session_handle); if(result != GLOBUS_SUCCESS) { @@ -7933,7 +7931,7 @@ globus_i_gfs_data_request_passive( "globus_l_gfs_data_operation_init", result); goto error_op; } - + result = globus_l_gfs_data_operation_init( (globus_l_gfs_data_operation_t **) &op->hybrid_op, session_handle); if(result != GLOBUS_SUCCESS) @@ -7952,8 +7950,8 @@ globus_i_gfs_data_request_passive( hybrid_op->session_handle = session_handle; hybrid_op->info_struct = data_info; - - + + op->callback = globus_l_gfs_data_hybrid_session_start_cb; op->user_arg = op; op->session_handle = session_handle; @@ -7962,10 +7960,10 @@ globus_i_gfs_data_request_passive( op->type = GLOBUS_L_GFS_DATA_INFO_TYPE_PASSIVE; globus_l_gfs_data_auth_init_cb( NULL, GFS_ACL_ACTION_INIT, op, GLOBUS_SUCCESS); - + return; } - + if(session_handle->dsi->passive_func != NULL) { result = globus_l_gfs_data_operation_init(&op, session_handle); @@ -8009,7 +8007,7 @@ globus_i_gfs_data_request_passive( data_info->del_cred = session_handle->del_cred; } else - { + { session_handle->dcsc_cred = data_info->del_cred; data_info->del_cred = NULL; } @@ -8035,7 +8033,7 @@ globus_i_gfs_data_request_passive( "globus_ftp_control_local_pasv", result); goto error_control; } - + /* XXX This needs to be smarter. The address should be the same one * the user is connected to on the control channel (at least when @@ -8232,17 +8230,17 @@ globus_i_gfs_data_request_active( session_handle = (globus_l_gfs_data_session_t *) session_arg; globus_l_gfs_data_reset_watchdog(session_handle, NULL); - if(session_handle->hybrid && data_info->cs_count != 1 && + if(session_handle->hybrid && data_info->cs_count != 1 && session_handle->dsi != globus_l_gfs_dsi_hybrid) { globus_l_gfs_data_operation_t * hybrid_op; - + result = globus_i_gfs_data_new_dsi( &globus_l_gfs_active_dsi_handle, "remote", &globus_l_gfs_dsi_hybrid, GLOBUS_FALSE); - + if(!globus_l_gfs_dsi_hybrid) { goto error_op; @@ -8257,7 +8255,7 @@ globus_i_gfs_data_request_active( } session_handle->dsi = globus_l_gfs_dsi_hybrid; - + result = globus_l_gfs_data_operation_init(&op, session_handle); if(result != GLOBUS_SUCCESS) { @@ -8265,7 +8263,7 @@ globus_i_gfs_data_request_active( "globus_l_gfs_data_operation_init", result); goto error_op; } - + result = globus_l_gfs_data_operation_init( (globus_l_gfs_data_operation_t **) &op->hybrid_op, session_handle); if(result != GLOBUS_SUCCESS) @@ -8284,8 +8282,8 @@ globus_i_gfs_data_request_active( hybrid_op->session_handle = session_handle; hybrid_op->info_struct = data_info; - - + + op->callback = globus_l_gfs_data_hybrid_session_start_cb; op->user_arg = op; op->session_handle = session_handle; @@ -8294,10 +8292,10 @@ globus_i_gfs_data_request_active( op->type = GLOBUS_L_GFS_DATA_INFO_TYPE_ACTIVE; globus_l_gfs_data_auth_init_cb( NULL, GFS_ACL_ACTION_INIT, op, GLOBUS_SUCCESS); - + return; } - + if(session_handle->dsi->active_func != NULL) { result = globus_l_gfs_data_operation_init(&op, session_handle); @@ -8489,7 +8487,7 @@ globus_i_gfs_data_request_recv( session_handle = (globus_l_gfs_data_session_t *) session_arg; globus_l_gfs_data_reset_watchdog(session_handle, "RECV"); - + /* YOU ARE ENTERING THE UGLY HACK ZONE */ globus_mutex_lock(&session_handle->mutex); { @@ -8517,7 +8515,7 @@ globus_i_gfs_data_request_recv( "globus_l_gfs_data_operation_init", result); goto error_op; } - + op->ipc_handle = ipc_handle; op->session_handle = session_handle; op->type = GLOBUS_L_GFS_DATA_INFO_TYPE_RECV; @@ -8539,14 +8537,14 @@ globus_i_gfs_data_request_recv( op->markers = globus_i_gfs_config_bool("always_send_markers"); if(session_handle->storattr_str) { - op->storattr = (globus_l_gfs_storattr_t *) + op->storattr = (globus_l_gfs_storattr_t *) globus_calloc(1, sizeof(globus_l_gfs_storattr_t)); op->storattr->all = session_handle->storattr_str; session_handle->storattr_str = NULL; op->storattr->modify = globus_i_gfs_kv_getval( op->storattr->all, "modify", 0); - + op->storattr->checksum_md5 = globus_i_gfs_kv_getval( op->storattr->all, "x.checksum.md5", 0); if(!op->storattr->checksum_md5) @@ -8554,11 +8552,11 @@ globus_i_gfs_data_request_recv( op->storattr->checksum_md5 = globus_i_gfs_kv_getval( op->storattr->all, "checksum.md5", 0); } - + if(op->storattr->checksum_md5 && !recv_info->expected_checksum) { recv_info->expected_checksum_alg = globus_libc_strdup("md5"); - recv_info->expected_checksum = + recv_info->expected_checksum = globus_libc_strdup(op->storattr->checksum_md5); } } @@ -8568,7 +8566,7 @@ globus_i_gfs_data_request_recv( { /* globus_assert(data_handle->outstanding_op == NULL); */ data_handle->outstanding_op = op; - globus_assert(data_handle->state == GLOBUS_L_GFS_DATA_HANDLE_VALID || + globus_assert(data_handle->state == GLOBUS_L_GFS_DATA_HANDLE_VALID || data_handle->state == GLOBUS_L_GFS_DATA_HANDLE_TE_VALID); data_handle->state = GLOBUS_L_GFS_DATA_HANDLE_INUSE; } @@ -8577,7 +8575,7 @@ globus_i_gfs_data_request_recv( { op->http_ip = data_handle->http_ip; data_handle->http_ip = NULL; - + op->op_info_id = globus_l_gfs_op_info_ctr++; if(!recv_info->op_info) { @@ -8748,7 +8746,7 @@ globus_i_gfs_data_request_send( { /*globus_assert(data_handle->outstanding_op == NULL); */ data_handle->outstanding_op = op; - globus_assert(data_handle->state == GLOBUS_L_GFS_DATA_HANDLE_VALID || + globus_assert(data_handle->state == GLOBUS_L_GFS_DATA_HANDLE_VALID || data_handle->state == GLOBUS_L_GFS_DATA_HANDLE_TE_VALID); data_handle->state = GLOBUS_L_GFS_DATA_HANDLE_INUSE; } @@ -8757,7 +8755,7 @@ globus_i_gfs_data_request_send( { op->http_ip = data_handle->http_ip; data_handle->http_ip = NULL; - + op->op_info_id = globus_l_gfs_op_info_ctr++; if(!send_info->op_info) { @@ -8774,7 +8772,7 @@ globus_i_gfs_data_request_send( char * full_pathname = NULL; chdir_to = globus_i_gfs_config_string("chdir_to"); - + result = globus_i_gfs_get_full_path( session_handle->home_dir, chdir_to ? chdir_to : "/", // XXX @@ -8853,7 +8851,7 @@ globus_i_gfs_data_request_send( static void globus_l_gfs_data_list_done( - globus_l_gfs_data_operation_t* op, + globus_l_gfs_data_operation_t* op, globus_result_t result) { while(op->path_list) @@ -8871,7 +8869,7 @@ globus_l_gfs_data_list_done( globus_free(tofree->pathname); globus_free(tofree); } - + op->current_path = NULL; globus_free(op->stat_wrapper); globus_gridftp_server_finished_transfer(op, result); @@ -8899,18 +8897,18 @@ globus_l_gfs_data_request_next_path( orig_op->current_path = NULL; free(stat_info->pathname); } - + nextpath = orig_op->path_list; if(nextpath) { orig_op->path_list = nextpath->next; - + result = globus_l_gfs_data_operation_init(&op, orig_op->session_handle); if(result != GLOBUS_SUCCESS) { goto error_op; - } - + } + op->uid = getuid(); op->state = GLOBUS_L_GFS_DATA_REQUESTING; op->callback = globus_l_gfs_data_list_stat_cb; @@ -8918,15 +8916,15 @@ globus_l_gfs_data_request_next_path( op->session_handle = orig_op->session_handle; op->info_struct = orig_op->stat_wrapper; op->type = GLOBUS_L_GFS_DATA_INFO_TYPE_STAT; - + stat_info->pathname = nextpath->pathname; - + globus_callback_register_oneshot( NULL, NULL, globus_l_gfs_blocking_dispatch_kickout, op); - + orig_op->current_path = nextpath; } @@ -8965,21 +8963,21 @@ globus_l_gfs_data_list_write_cb( { globus_free(bounce_info->list_response); } - + globus_mutex_lock(&op->stat_lock); if(bounce_info->final_stat && !globus_l_gfs_data_request_next_path(op)) { finish = GLOBUS_TRUE; } globus_mutex_unlock(&op->stat_lock); - + globus_free(bounce_info); if(op->delayed_error != GLOBUS_SUCCESS) { result = op->delayed_error; } - + if(finish) { globus_l_gfs_data_list_done(op, result); @@ -9007,7 +9005,7 @@ globus_l_gfs_data_list_stat_cb( int i; int dirlen; int baselen; - + GlobusGFSName(globus_l_gfs_data_list_stat_cb); GlobusGFSDebugEnter(); @@ -9025,7 +9023,7 @@ globus_l_gfs_data_list_stat_cb( result = reply->result; goto error; } - if (!(op->traversal_options & GLOBUS_GFS_TRAVERSAL_CONTINUE)) + if (!(op->traversal_options & GLOBUS_GFS_TRAVERSAL_CONTINUE)) { /** MLSR failure. We want to write out the information for * this directory and then fail. */ @@ -9036,13 +9034,13 @@ globus_l_gfs_data_list_stat_cb( stat_array = reply->info.stat.stat_array; stat_count = reply->info.stat.stat_count; file_count = stat_count; - + if(op->list_depth != 0) { /** Skip the first entry if we are including the directory itself in the listing */ int base_entry = 0; - - /** Correct for path which pointed to a single file */ + + /** Correct for path which pointed to a single file */ if(stat_count == 1 && op->current_path && op->current_path->subpath) { int plen = strlen(op->current_path->subpath); @@ -9050,12 +9048,12 @@ globus_l_gfs_data_list_stat_cb( if(plen > nlen && strcmp(&op->current_path->subpath[plen-nlen], stat_array[0].name) == 0) { op->current_path->subpath[plen-nlen-1] = '\0'; - } + } } if (stat_info->include_path_stat && stat_count > 0 && S_ISDIR(stat_array[0].mode)) { - if (op->current_path) + if (op->current_path) { stat_array[0].name[0] = '\0'; } @@ -9066,11 +9064,11 @@ globus_l_gfs_data_list_stat_cb( } ++base_entry; } - + /** Move unwanted directory entries to the end and add them to the path */ for (i = base_entry; i < file_count;) { - if (S_ISDIR(stat_array[i].mode) && + if (S_ISDIR(stat_array[i].mode) && (stat_info->include_path_stat || (stat_array[i].name[0] == '.' && (stat_array[i].name[1] == '\0' || (stat_array[i].name[1] == '.' && stat_array[i].name[2] == '\0'))))) @@ -9081,29 +9079,29 @@ globus_l_gfs_data_list_stat_cb( memcpy(&stat_array[i], &stat_array[file_count-1], sizeof(globus_gfs_stat_t)); memcpy(&stat_array[file_count-1], &stat_temp, sizeof(globus_gfs_stat_t)); /** Decrement effective count */ - --file_count; + --file_count; } else { ++i; - } + } } - + dirlen = strlen(stat_info->pathname); - baselen = op->current_path ? - (strlen(op->current_path->pathname) - strlen(op->current_path->subpath)) : + baselen = op->current_path ? + (strlen(op->current_path->pathname) - strlen(op->current_path->subpath)) : (dirlen + 1); - + /** Add directories, minus the current (.) and parent (..), to the list * of paths to be explored. Paths should be added at the end of the list. */ for (i = base_entry; i < stat_count; ++i) { globus_l_gfs_data_path_list_t* newpath = NULL; - + /** If we are to follow symbolic links, create a new traversal path for each */ - if ((op->traversal_options & GLOBUS_GFS_TRAVERSAL_FOLLOW_SYMLINKS) && + if ((op->traversal_options & GLOBUS_GFS_TRAVERSAL_FOLLOW_SYMLINKS) && stat_array[i].symlink_target && - stat_array[i].error != GLOBUS_GRIDFTP_SERVER_CONTROL_STAT_INVALIDLINK) + stat_array[i].error != GLOBUS_GRIDFTP_SERVER_CONTROL_STAT_INVALIDLINK) { newpath = (globus_l_gfs_data_path_list_t*)globus_malloc(sizeof(globus_l_gfs_data_path_list_t)); if (newpath) @@ -9114,19 +9112,19 @@ globus_l_gfs_data_list_stat_cb( else { goto error; - } - } + } + } /** Create new traversal paths for subdirectories (ignore . and ..) */ else if (S_ISDIR(stat_array[i].mode) && - (stat_array[i].name[0] != '.' || + (stat_array[i].name[0] != '.' || (stat_array[i].name[1] != '\0' && (stat_array[i].name[1] != '.' || stat_array[i].name[2] != '\0')))) { newpath = (globus_l_gfs_data_path_list_t*)globus_malloc(sizeof(globus_l_gfs_data_path_list_t)); if (newpath) { - newpath->pathname = (char *)globus_malloc(dirlen + strlen(stat_array[i].name) + 2); + newpath->pathname = (char *)globus_malloc(dirlen + strlen(stat_array[i].name) + 2); sprintf(newpath->pathname, "%s/%s", stat_info->pathname, stat_array[i].name); - newpath->subpath = &newpath->pathname[baselen]; + newpath->subpath = &newpath->pathname[baselen]; } else { @@ -9134,20 +9132,20 @@ globus_l_gfs_data_list_stat_cb( } } - if (newpath) + if (newpath) { /* * This section does cycle and duplicate path detection. We only need to do * this when symbolic link traversal is on (shouldn't happen otherwise, unless * someone's done something nasty with hard links). - * + * * We check symbolic link targets against a set of "root paths", which are either - * the base root the MLSR was started with, or other link targets. If a root is + * the base root the MLSR was started with, or other link targets. If a root is * entirely contained in a target, we'll already catch it, so no need to add it. - * - * If the target is entirely contained in a root, then we have a cycle, and we - * mark the path as such. - * + * + * If the target is entirely contained in a root, then we have a cycle, and we + * mark the path as such. + * * When expanding directories, if the parent is marked as having a cycle, we * check the subdirectory. If the subdirectory still has a cycle, it is marked * as such--however, if it doesn't then we can avoid the cycle check for future @@ -9158,11 +9156,11 @@ globus_l_gfs_data_list_stat_cb( */ if (op->traversal_options & GLOBUS_GFS_TRAVERSAL_FOLLOW_SYMLINKS) { - globus_l_gfs_data_path_list_t* iter; - int newpathlen = strlen(newpath->pathname); - + globus_l_gfs_data_path_list_t* iter; + int newpathlen = strlen(newpath->pathname); + newpath->has_cycle = GLOBUS_FALSE; - + /** For symbolic links, validate the path--we don't want any duplicated paths */ if (stat_array[i].symlink_target) { @@ -9181,7 +9179,7 @@ globus_l_gfs_data_list_stat_cb( (iter->pathname[newpathlen] == '/' || iter->pathname[newpathlen] == '\0')) { /** This target has a cycle */ - newpath->has_cycle = GLOBUS_TRUE; + newpath->has_cycle = GLOBUS_TRUE; } } } @@ -9196,7 +9194,7 @@ globus_l_gfs_data_list_stat_cb( globus_free(newpath->pathname); globus_free(newpath); newpath = NULL; - } + } else if(strncmp(iter->pathname, newpath->pathname, newpathlen) == 0 && (iter->pathname[newpathlen] == '/' || iter->pathname[newpathlen] == '\0')) { @@ -9205,19 +9203,19 @@ globus_l_gfs_data_list_stat_cb( } } } - + /** Add the path to the traversal list */ - if (newpath) + if (newpath) { if (stat_array[i].symlink_target) { globus_l_gfs_data_path_list_t** ppiter; - + /** Append symlink targets to the end of the traversal queue */ - newpath->next = NULL; + newpath->next = NULL; for (ppiter = &op->path_list; *ppiter; ppiter = &((*ppiter)->next)) ; - *ppiter = newpath; - + *ppiter = newpath; + /** Symbolic links to directories should be added to the root list. */ if (S_ISDIR(stat_array[i].link_mode)) { @@ -9228,37 +9226,37 @@ globus_l_gfs_data_list_stat_cb( newroot->pathname = globus_libc_strdup(newpath->pathname); newroot->subpath = NULL; newroot->next = op->root_paths; - op->root_paths = newroot; - } + op->root_paths = newroot; + } else { goto error; } } - } - else + } + else { /** Prepend directory expansion targets to the head of the queue */ newpath->next = op->path_list; op->path_list = newpath; } - } + } } } } - + globus_mutex_lock(&op->stat_lock); if(!op->begin_called) { op->begin_called = GLOBUS_TRUE; globus_gridftp_server_begin_transfer(op, 0, NULL); } - + list_buffer = NULL; buffer_len = 0; - - if(file_count > 0) - { + + if(file_count > 0) + { result = globus_gridftp_server_control_list_buffer_alloc( op->list_type, op->uid, @@ -9273,7 +9271,7 @@ globus_l_gfs_data_list_stat_cb( "globus_gridftp_server_control_list_buffer_alloc", result); goto error; } - } + } else if(op->delayed_error != GLOBUS_SUCCESS || !globus_l_gfs_data_request_next_path(op)) { list_buffer = (globus_byte_t *) globus_libc_strdup("\r"); @@ -9289,12 +9287,12 @@ globus_l_gfs_data_list_stat_cb( result = GlobusGFSErrorMemory("bounce_info"); goto error; } - + if(reply->code != 100) { bounce_info->final_stat = GLOBUS_TRUE; } - + result = globus_gridftp_server_register_write( op, list_buffer, @@ -9312,8 +9310,8 @@ globus_l_gfs_data_list_stat_cb( goto error; } op->list_buffer_offset += buffer_len; - } - + } + globus_mutex_unlock(&op->stat_lock); GlobusGFSDebugExit(); @@ -9355,7 +9353,7 @@ globus_gridftp_server_finished_stat_custom_list( result = GlobusGFSErrorMemory("bounce_info"); goto error; } - + bounce_info->custom_list = GLOBUS_TRUE; bounce_info->free_buffer = free_buffer; if(free_buffer) @@ -9519,7 +9517,7 @@ globus_i_gfs_data_request_list( stat_info->pathname = list_info->pathname; stat_info->file_only = GLOBUS_FALSE; stat_info->use_symlink_info = data_op->list_depth != 0; - stat_info->include_path_stat = data_op->list_depth != 0; + stat_info->include_path_stat = data_op->list_depth != 0; data_op->info_struct = list_info; data_op->stat_wrapper = stat_info; @@ -9536,7 +9534,7 @@ globus_i_gfs_data_request_list( /** *** Trim any trailing '/' - **/ + **/ len = strlen(stat_info->pathname); if(len > 0 && stat_info->pathname[len - 1] == '/') { @@ -9801,7 +9799,7 @@ globus_l_gfs_data_begin_cb( op->data_handle->info.tcp_bufsize = sndbuf; } } - + globus_gfs_log_message( GLOBUS_GFS_LOG_INFO, "Starting to transfer \"%s\".\n", @@ -9835,7 +9833,7 @@ globus_l_gfs_data_begin_cb( event_reply.type = GLOBUS_GFS_EVENT_TRANSFER_CONNECTED; event_reply.id = op->id; event_reply.event_arg = op; - + if(op->event_callback != NULL) { op->event_callback(&event_reply, op->user_arg); @@ -9846,14 +9844,14 @@ globus_l_gfs_data_begin_cb( event_reply.op_info->remote_ip = globus_libc_strdup(op->remote_ip); globus_gfs_ipc_reply_event(op->ipc_handle, &event_reply); - + if(event_reply.op_info->remote_ip) { globus_free(event_reply.op_info->remote_ip); } globus_free(event_reply.op_info); } - + if((!op->writing || op->retr_markers) && (op->data_handle->info.mode == 'E' || op->markers)) { @@ -10041,7 +10039,7 @@ globus_l_gfs_data_end_transfer_kickout( memset(&reply, '\0', sizeof(globus_gfs_finished_info_t)); - if(op->cached_res == GLOBUS_SUCCESS && + if(op->cached_res == GLOBUS_SUCCESS && op->writing && op->data_handle->http_handle) { globus_xio_data_descriptor_t descriptor; @@ -10054,12 +10052,12 @@ globus_l_gfs_data_end_transfer_kickout( globus_hashtable_t header_table = NULL; globus_bool_t eof = 0; - + globus_xio_handle_cntl( handle, op->session_handle->http_driver, GLOBUS_XIO_HTTP_HANDLE_SET_END_OF_ENTITY); - + result = globus_xio_data_descriptor_init(&descriptor, handle); globus_assert(result == GLOBUS_SUCCESS); @@ -10104,7 +10102,7 @@ globus_l_gfs_data_end_transfer_kickout( body_buffer = malloc(buflen+1); do - { + { body_nbytes = 0; result = globus_xio_read( handle, @@ -10131,13 +10129,13 @@ globus_l_gfs_data_end_transfer_kickout( else { waitfor = GLOBUS_MIN(1024, buflen-total_nbytes); - } + } } while(!eof); - + body_buffer[total_nbytes] = '\0'; globus_i_gfs_data_http_print_response( status_code, &header_table, body_buffer, &header_str); - + err_str = globus_common_create_string( "HTTP PUT failed with \"%03d %s\"\n%s", status_code, @@ -10145,7 +10143,7 @@ globus_l_gfs_data_end_transfer_kickout( header_str); result = GlobusGFSErrorGeneric(err_str); - + globus_free(err_str); globus_free(header_str); globus_free(body_buffer); @@ -10181,7 +10179,7 @@ globus_l_gfs_data_end_transfer_kickout( eof = GLOBUS_TRUE; } total_nbytes += body_nbytes; - + if(body_nbytes == 0 || total_nbytes == buflen) { eof = GLOBUS_TRUE; @@ -10189,14 +10187,14 @@ globus_l_gfs_data_end_transfer_kickout( else { waitfor = GLOBUS_MIN(1024, buflen-total_nbytes); - } + } } result = GLOBUS_SUCCESS; globus_free(body_buffer); globus_i_gfs_data_http_print_response( status_code, &header_table, NULL, &op->data_handle->http_response_str); } - + } response_exit: if(op->cached_res == GLOBUS_SUCCESS) @@ -10450,7 +10448,7 @@ globus_l_gfs_data_end_transfer_kickout( { globus_free(retransmit_str); } - + /* XXX sc process bytes transferred count */ { char * names[5] = @@ -10495,7 +10493,7 @@ globus_l_gfs_data_end_transfer_kickout( reply.result = op->cached_res; /* pull response code from error */ - if(reply.result != GLOBUS_SUCCESS && + if(reply.result != GLOBUS_SUCCESS && (reply.code = globus_gfs_error_get_ftp_response_code( globus_error_peek(reply.result))) != 0) { @@ -10506,9 +10504,9 @@ globus_l_gfs_data_end_transfer_kickout( { reply.code = op->user_code; - /* DO NETLOGGER STUFF + /* DO NETLOGGER STUFF * XXX unless user has a message -- will only be a problem if a DSI - * is sending messages to the control channel, in which case they + * is sending messages to the control channel, in which case they * just aren't compatible with the netlogger bottleneck reporting */ if(op->user_msg == NULL) @@ -10533,7 +10531,7 @@ globus_l_gfs_data_end_transfer_kickout( &reply); } globus_l_gfs_data_reset_watchdog(op->session_handle, NULL); - + /* remove the reference for this callback. It is possible that before acquiring this lock the completing state occurred and we are ready to finish */ @@ -10688,7 +10686,7 @@ globus_l_gfs_data_end_read_kickout( } globus_mutex_lock(&op->session_handle->mutex); - { + { switch(op->data_handle->state) { case GLOBUS_L_GFS_DATA_HANDLE_INUSE: @@ -10715,7 +10713,7 @@ globus_l_gfs_data_end_read_kickout( default: break; } - + recv_info = op->info_struct; object.name = recv_info->pathname; object.size = op->bytes_transferred; @@ -10788,7 +10786,7 @@ void globus_l_gfs_data_send_eof_cb( void * callback_arg, struct globus_ftp_control_handle_s * handle, - globus_object_t * error) + globus_object_t * error) { globus_l_gfs_data_operation_t * op; GlobusGFSName(globus_l_gfs_data_send_eof_cb); @@ -11102,7 +11100,7 @@ globus_l_gfs_data_trev_kickout( bounce_info->op->recvd_bytes = 0; event_reply->type = GLOBUS_GFS_EVENT_BYTES_RECVD; break; - + case GLOBUS_GFS_EVENT_RANGES_RECVD: event_reply->type = GLOBUS_GFS_EVENT_RANGES_RECVD; globus_range_list_copy( @@ -11111,7 +11109,7 @@ globus_l_gfs_data_trev_kickout( globus_range_list_remove( bounce_info->op->recvd_ranges, 0, GLOBUS_RANGE_LIST_MAX); break; - + default: globus_assert(0 && "invalid state, not possible"); break; @@ -11378,7 +11376,7 @@ globus_i_gfs_data_request_transfer_event( GlobusGFSDebugEnter(); session_handle = (globus_l_gfs_data_session_t *) session_arg; - op = (globus_l_gfs_data_operation_t *) + op = (globus_l_gfs_data_operation_t *) globus_handle_table_lookup( &session_handle->handle_table, (intptr_t) event_info->event_arg); if(op == NULL) @@ -11561,7 +11559,7 @@ globus_i_gfs_data_request_transfer_event( globus_mutex_unlock(&op->session_handle->mutex); /* - if(event_info->type == GLOBUS_GFS_EVENT_TRANSFER_COMPLETE && + if(event_info->type == GLOBUS_GFS_EVENT_TRANSFER_COMPLETE && op->data_handle->state == GLOBUS_L_GFS_DATA_HANDLE_TE_VALID) { op->data_handle->state = GLOBUS_L_GFS_DATA_HANDLE_VALID; @@ -11603,7 +11601,7 @@ globus_i_gfs_data_session_start( session_handle->del_cred = session_info->del_cred; session_handle->context = context; session_handle->dcsc_cred = GSS_C_NO_CREDENTIAL; - session_handle->order_data = session_handle->dsi->descriptor & + session_handle->order_data = session_handle->dsi->descriptor & GLOBUS_GFS_DSI_DESCRIPTOR_REQUIRES_ORDERED_DATA; result = globus_l_gfs_data_operation_init(&op, session_handle); if(result != GLOBUS_SUCCESS) @@ -11619,7 +11617,7 @@ globus_i_gfs_data_session_start( op->callback = cb; op->user_arg = user_arg; op->info_struct = session_info; - + result = globus_l_gfs_data_load_stack( "default", &op->session_handle->net_stack_list, @@ -11657,11 +11655,11 @@ globus_i_gfs_data_session_start( if(globus_i_gfs_config_int("auth_level") & GLOBUS_L_GFS_AUTH_IDENTIFY) { globus_l_gfs_data_authorize(op, context, session_info); - + if(globus_i_gfs_config_bool("hybrid")) { globus_gfs_session_info_t * session_info_copy; - + session_info_copy = (globus_gfs_session_info_t *) globus_malloc(sizeof(globus_gfs_session_info_t)); session_info_copy->del_cred = session_info->del_cred; @@ -11672,7 +11670,7 @@ globus_i_gfs_data_session_start( session_info_copy->subject = globus_libc_strdup(session_info->subject); session_info_copy->cookie = globus_libc_strdup(session_info->cookie); session_info_copy->host_id = globus_libc_strdup(session_info->host_id); - + session_handle->session_info_copy = session_info_copy; session_handle->hybrid = GLOBUS_TRUE; } @@ -11694,7 +11692,7 @@ globus_i_gfs_data_session_start( op->session_handle->gid_array); } - op->session_handle->username = + op->session_handle->username = globus_libc_strdup(session_info->username); pwent = getpwuid(op->session_handle->uid); @@ -11706,30 +11704,30 @@ globus_i_gfs_data_session_start( { op->session_handle->true_home = globus_l_gfs_defaulthome(); } - + custom_home_dir = globus_i_gfs_config_string("home_dir"); if(custom_home_dir) { char * var_dir; - + var_dir = globus_l_gfs_data_update_var_path( op->session_handle, custom_home_dir); - + op->session_handle->home_dir = var_dir; } else { - op->session_handle->home_dir = + op->session_handle->home_dir = globus_libc_strdup(op->session_handle->true_home); } - + globus_l_gfs_data_update_restricted_paths( op->session_handle, &globus_l_gfs_path_alias_list_base); globus_l_gfs_data_update_restricted_paths( op->session_handle, &globus_l_gfs_path_alias_list_sharing); op->session_handle->active_rp_list = &globus_l_gfs_path_alias_list_base; - - if(!globus_i_gfs_config_bool("use_home_dirs") || + + if(!globus_i_gfs_config_bool("use_home_dirs") || op->session_handle->home_dir == NULL) { if(op->session_handle->home_dir) @@ -11737,12 +11735,12 @@ globus_i_gfs_data_session_start( globus_free(op->session_handle->home_dir); } op->session_handle->home_dir = strdup("/"); - } + } if(globus_i_gfs_config_bool("hybrid")) { globus_gfs_session_info_t * session_info_copy; - + session_info_copy = (globus_gfs_session_info_t *) globus_malloc(sizeof(globus_gfs_session_info_t)); session_info_copy->del_cred = session_info->del_cred; @@ -11753,18 +11751,18 @@ globus_i_gfs_data_session_start( session_info_copy->subject = globus_libc_strdup(session_info->subject); session_info_copy->cookie = globus_libc_strdup(session_info->cookie); session_info_copy->host_id = globus_libc_strdup(session_info->host_id); - + session_handle->session_info_copy = session_info_copy; session_handle->hybrid = GLOBUS_TRUE; } - + globus_l_gfs_data_auth_init_cb( NULL, GFS_ACL_ACTION_INIT, op, GLOBUS_SUCCESS); } GlobusGFSDebugExit(); } - + void globus_i_gfs_data_session_stop( globus_gfs_ipc_handle_t ipc_handle, @@ -11830,7 +11828,7 @@ globus_i_gfs_data_session_stop( globus_gfs_log_message( GLOBUS_GFS_LOG_INFO, "Called main session_stop after %d ticks.\n", waitcnt - 1); - } + } } if(globus_l_gfs_watchdog_limit) @@ -11860,7 +11858,7 @@ globus_l_gfs_finished_command_kickout( bounce = (globus_l_gfs_data_cmd_bounce_t *) user_arg; op = bounce->op; - + if(op->callback != NULL) { op->callback( @@ -11873,7 +11871,7 @@ globus_l_gfs_finished_command_kickout( op->ipc_handle, &bounce->reply); } - + if(bounce->reply.info.command.checksum) { globus_free(bounce->reply.info.command.checksum); @@ -11906,7 +11904,7 @@ globus_l_gfs_finished_command_kickout( globus_assert(destroy_op); globus_l_gfs_data_fire_cb(op, remote_data_arg, destroy_session); globus_l_gfs_data_operation_destroy(op); - + globus_free(bounce); } @@ -11969,7 +11967,7 @@ globus_gridftp_server_finished_command( } op->cached_res = result; - bounce = (globus_l_gfs_data_cmd_bounce_t *) + bounce = (globus_l_gfs_data_cmd_bounce_t *) globus_calloc(1, sizeof(globus_l_gfs_data_cmd_bounce_t)); bounce->op = op; @@ -11980,7 +11978,7 @@ globus_gridftp_server_finished_command( bounce->reply.info.command.checksum = globus_libc_strdup(op->cksm_response); /* pull response code from error */ - if(result != GLOBUS_SUCCESS && + if(result != GLOBUS_SUCCESS && (code = globus_gfs_error_get_ftp_response_code( globus_error_peek(result))) != 0) { @@ -12003,7 +12001,7 @@ globus_gridftp_server_finished_command( bounce->reply.info.command.created_dir = globus_libc_strdup(op->pathname); } } - + result = globus_callback_register_oneshot( NULL, NULL, @@ -12038,9 +12036,9 @@ globus_gridftp_server_finished_stat_partial( globus_mutex_lock(&op->stat_lock); if(result == GLOBUS_SUCCESS) - { + { stat_info = (globus_gfs_stat_info_t *) op->info_struct; - + stat_copy = (globus_gfs_stat_t *) globus_malloc(sizeof(globus_gfs_stat_t) * stat_count); if(stat_copy == NULL) @@ -12048,9 +12046,9 @@ globus_gridftp_server_finished_stat_partial( result = GlobusGFSErrorMemory("stat_copy"); } } - + if(result == GLOBUS_SUCCESS) - { + { base_path = stat_info->pathname; /* if we have explicit access on the base path, no need to prune */ if(stat_info->file_only || globus_i_gfs_data_check_path(op->session_handle, @@ -12082,7 +12080,7 @@ globus_gridftp_server_finished_stat_partial( char * nam; char * full_path; char * slash; - + if(base_path[strlen(base_path) - 1] != '/') { slash = "/"; @@ -12096,21 +12094,21 @@ globus_gridftp_server_finished_stat_partial( nam = stat_array[i].name; full_path = globus_common_create_string( "%s%s%s", base_path, slash, nam); - if(nam && ((nam[0] == '.' && + if(nam && ((nam[0] == '.' && (nam[1] == '\0' || (nam[1] == '.' && nam[2] == '\0'))) || (globus_i_gfs_data_check_path(op->session_handle, full_path, NULL, GFS_L_LIST, 0) == GLOBUS_SUCCESS))) { memcpy( - &stat_copy[pruned_stat_count], + &stat_copy[pruned_stat_count], &stat_array[i], sizeof(globus_gfs_stat_t)); - - stat_copy[pruned_stat_count].name = + + stat_copy[pruned_stat_count].name = globus_libc_strdup(stat_array[i].name); stat_copy[pruned_stat_count].symlink_target = globus_libc_strdup(stat_array[i].symlink_target); - + pruned_stat_count++; } globus_free(full_path); @@ -12121,7 +12119,7 @@ globus_gridftp_server_finished_stat_partial( stat_copy[0].nlink = pruned_stat_count; } } - + } else { @@ -12143,7 +12141,7 @@ globus_gridftp_server_finished_stat_partial( bounce_info->stat_count = stat_count; bounce_info->stat_array = stat_copy; bounce_info->final_stat = GLOBUS_FALSE; - + result = globus_callback_register_oneshot( GLOBUS_NULL, GLOBUS_NULL, @@ -12158,7 +12156,7 @@ globus_gridftp_server_finished_stat_partial( globus_mutex_unlock(&op->stat_lock); globus_poll(); - + GlobusGFSDebugExit(); return; @@ -12185,7 +12183,7 @@ globus_gridftp_server_intermediate_command( globus_l_gfs_data_alive(op->session_handle); - bounce = (globus_l_gfs_data_cmd_bounce_t *) + bounce = (globus_l_gfs_data_cmd_bounce_t *) globus_calloc(1, sizeof(globus_l_gfs_data_cmd_bounce_t)); switch(op->command) @@ -12194,7 +12192,7 @@ globus_gridftp_server_intermediate_command( bounce->reply.info.command.checksum = globus_libc_strdup(command_data); bounce->reply.code = 113; break; - + case GLOBUS_GFS_CMD_HTTP_PUT: case GLOBUS_GFS_CMD_HTTP_GET: bounce->reply.info.command.checksum = globus_libc_strdup(command_data); @@ -12248,7 +12246,7 @@ globus_gridftp_server_finished_stat( GlobusGFSDebugEnter(); globus_l_gfs_data_alive(op->session_handle); - + globus_mutex_lock(&op->stat_lock); if(stat_array != NULL && stat_count > 0) { @@ -12261,7 +12259,7 @@ globus_gridftp_server_finished_stat( result = GlobusGFSErrorMemory("stat_copy"); goto error_alloc; } - + base_path = stat_info->pathname; /* if we have explicit access on the base path, no need to prune */ if(stat_info->file_only || globus_i_gfs_data_check_path(op->session_handle, @@ -12293,7 +12291,7 @@ globus_gridftp_server_finished_stat( char * nam; char * full_path; char * slash; - + if(base_path[strlen(base_path) - 1] != '/') { slash = "/"; @@ -12307,21 +12305,21 @@ globus_gridftp_server_finished_stat( nam = stat_array[i].name; full_path = globus_common_create_string( "%s%s%s", base_path, slash, nam); - if(nam && ((nam[0] == '.' && + if(nam && ((nam[0] == '.' && (nam[1] == '\0' || (nam[1] == '.' && nam[2] == '\0'))) || (globus_i_gfs_data_check_path(op->session_handle, full_path, NULL, GFS_L_LIST, 0) == GLOBUS_SUCCESS))) { memcpy( - &stat_copy[pruned_stat_count], + &stat_copy[pruned_stat_count], &stat_array[i], sizeof(globus_gfs_stat_t)); - - stat_copy[pruned_stat_count].name = + + stat_copy[pruned_stat_count].name = globus_libc_strdup(stat_array[i].name); stat_copy[pruned_stat_count].symlink_target = globus_libc_strdup(stat_array[i].symlink_target); - + pruned_stat_count++; } globus_free(full_path); @@ -12332,7 +12330,7 @@ globus_gridftp_server_finished_stat( stat_copy[0].nlink = pruned_stat_count; } } - + } else { @@ -12354,7 +12352,7 @@ globus_gridftp_server_finished_stat( bounce_info->stat_count = stat_count; bounce_info->stat_array = stat_copy; bounce_info->final_stat = GLOBUS_TRUE; - + result = globus_callback_register_oneshot( GLOBUS_NULL, GLOBUS_NULL, @@ -12477,7 +12475,7 @@ globus_gridftp_server_begin_transfer( { GlobusGFSDebugInfo( "globus_ftp_control_data_connect_read"); - + if(op->order_data && op->data_handle->info.mode == 'E') { result = globus_ftp_control_set_force_order( @@ -12748,7 +12746,7 @@ globus_l_gfs_operation_finished_kickout( if(bounce->finished_info->type == GLOBUS_GFS_OP_SESSION_START) { /* update home dir based on restricted paths */ - + /* reset home dir to / if chroot. */ if(op->session_handle->chroot_path) { @@ -12775,7 +12773,7 @@ globus_l_gfs_operation_finished_kickout( globus_free(op->session_handle->home_dir); } op->session_handle->home_dir = strdup("/"); - + bounce->finished_info->info.session.home_dir = op->session_handle->home_dir; } @@ -12861,9 +12859,9 @@ globus_gridftp_server_operation_finished( break; case GLOBUS_GFS_OP_STAT: globus_gridftp_server_finished_stat_partial( - op, - result, - finished_info->info.stat.stat_array, + op, + result, + finished_info->info.stat.stat_array, finished_info->info.stat.stat_count); return; default: @@ -12881,13 +12879,13 @@ globus_gridftp_server_operation_finished( finished_info->id = op->id; finished_info->result = result; - + if(finished_info->msg != NULL) { op->user_msg = globus_libc_strdup(finished_info->msg); } op->user_code = finished_info->code; - + switch(finished_info->type) { case GLOBUS_GFS_OP_RECV: @@ -12925,23 +12923,23 @@ globus_gridftp_server_operation_finished( { globus_free(op->session_handle->home_dir); } - op->session_handle->home_dir = + op->session_handle->home_dir = strdup(finished_info->info.session.home_dir); } - + if(globus_hashtable_empty(&op->session_handle->custom_cmd_table)) { finished_info->op_info = NULL; } - if(op->callback != NULL && + if(op->callback != NULL && !globus_hashtable_empty( &op->session_handle->custom_cmd_table)) { finished_info->op_info = globus_calloc(1, sizeof(globus_i_gfs_op_info_t)); - finished_info->op_info->custom_command_table = + finished_info->op_info->custom_command_table = op->session_handle->custom_cmd_table; } - + break; case GLOBUS_GFS_OP_PASSIVE: @@ -13071,7 +13069,7 @@ globus_gridftp_server_update_bytes_recvd( globus_mutex_lock(&op->session_handle->mutex); { op->recvd_bytes += length; - + if(op->data_handle->http_handle) { op->data_handle->http_transferred += length; @@ -13119,7 +13117,7 @@ globus_gridftp_server_update_bytes_written( op->recvd_bytes += length; globus_range_list_insert( op->recvd_ranges, offset + op->transfer_delta, length); - + if(op->data_handle->http_handle) { op->data_handle->http_transferred += length; @@ -13144,9 +13142,9 @@ globus_gridftp_server_get_optimal_concurrency( return; } if(!op->writing) - { + { globus_mutex_lock(&op->session_handle->mutex); - if(op->data_handle->state == GLOBUS_L_GFS_DATA_HANDLE_INUSE && + if(op->data_handle->state == GLOBUS_L_GFS_DATA_HANDLE_INUSE && op->data_handle->is_mine) { unsigned int num_streams; @@ -13353,7 +13351,7 @@ globus_gridftp_server_query_op_info( { globus_result_t res = GLOBUS_SUCCESS; va_list ap; - + char *** argv; int * argc; GlobusGFSName(globus_gridftp_server_query_op_info); @@ -13374,16 +13372,16 @@ globus_gridftp_server_query_op_info( case GLOBUS_GFS_OP_INFO_CMD_ARGS: argv = va_arg(ap, char ***); argc = va_arg(ap, int *); - + *argv = op_info->argv; *argc = op_info->argc; break; - + default: res = GlobusGFSErrorGeneric("Invalid query parameter."); break; } - + va_end(ap); if(res != GLOBUS_SUCCESS) @@ -13397,7 +13395,7 @@ globus_gridftp_server_query_op_info( err: GlobusGFSDebugExitWithError(); return res; -} +} globus_result_t globus_gridftp_server_set_checksum_support( @@ -13441,7 +13439,7 @@ globus_gridftp_server_add_command( result = GlobusGFSErrorGeneric("Invalid cmd_id.");; goto err; } - + if(op->session_handle->custom_cmd_table == NULL) { globus_hashtable_init( @@ -13450,10 +13448,10 @@ globus_gridftp_server_add_command( globus_hashtable_string_hash, globus_hashtable_string_keyeq); } - + cmd_ent = (globus_i_gfs_cmd_ent_t *) globus_calloc(1, sizeof(globus_i_gfs_cmd_ent_t)); - + cmd_ent->cmd_name = globus_libc_strdup(command_name); ptr = cmd_ent->cmd_name; while(ptr && *ptr) @@ -13467,7 +13465,7 @@ globus_gridftp_server_add_command( cmd_ent->help_str = globus_libc_strdup(help_string); cmd_ent->has_pathname = has_pathname; cmd_ent->access_type = access_type; - + rc = globus_hashtable_insert( &op->session_handle->custom_cmd_table, cmd_ent->cmd_name, cmd_ent); @@ -13476,15 +13474,15 @@ globus_gridftp_server_add_command( result = GlobusGFSErrorGeneric("Could not store command entry."); goto err; } - - GlobusGFSDebugExit(); + + GlobusGFSDebugExit(); return GLOBUS_SUCCESS; - + err: - GlobusGFSDebugExitWithError(); + GlobusGFSDebugExitWithError(); return result; } - + /* this is used to translate the restart and partial offset/lengths into a sets of ranges to transfer... storage interface shouldn't know about @@ -13503,7 +13501,6 @@ globus_gridftp_server_get_write_range( globus_off_t tmp_len = -1; globus_off_t tmp_write = 0; globus_off_t tmp_transfer = 0; - int rc; GlobusGFSName(globus_gridftp_server_get_write_range); GlobusGFSDebugEnter(); @@ -13511,7 +13508,7 @@ globus_gridftp_server_get_write_range( if(globus_range_list_size(op->range_list)) { - rc = globus_range_list_remove_at( + globus_range_list_remove_at( op->range_list, 0, &tmp_off, @@ -13551,7 +13548,6 @@ globus_gridftp_server_get_read_range( globus_off_t tmp_off = 0; globus_off_t tmp_len = -1; globus_off_t tmp_write = 0; - int rc; globus_off_t start_offset; globus_off_t end_offset; globus_off_t stripe_block_size; @@ -13561,9 +13557,9 @@ globus_gridftp_server_get_read_range( globus_off_t part_size; GlobusGFSName(globus_gridftp_server_get_read_range); GlobusGFSDebugEnter(); - + globus_l_gfs_data_alive(op->session_handle); - + /* this whole function is crazy ugly and inneffiecient... needs rethinking */ globus_mutex_lock(&op->session_handle->mutex); @@ -13604,7 +13600,7 @@ globus_gridftp_server_get_read_range( if(globus_range_list_size(op->stripe_range_list)) { - rc = globus_range_list_remove_at( + globus_range_list_remove_at( op->stripe_range_list, 0, &tmp_off, @@ -13616,7 +13612,7 @@ globus_gridftp_server_get_read_range( { for(i = 0; i < size; i++) { - rc = globus_range_list_at( + globus_range_list_at( op->range_list, i, &tmp_off, @@ -13656,7 +13652,7 @@ globus_gridftp_server_get_read_range( if(globus_range_list_size(op->stripe_range_list)) { - rc = globus_range_list_remove_at( + globus_range_list_remove_at( op->stripe_range_list, 0, &tmp_off, @@ -13678,7 +13674,7 @@ globus_gridftp_server_get_read_range( } else if(globus_range_list_size(op->range_list)) { - rc = globus_range_list_remove_at( + globus_range_list_remove_at( op->range_list, 0, &tmp_off, @@ -13733,7 +13729,7 @@ globus_result_t globus_gridftp_server_get_recv_modification_time( globus_gfs_operation_t op, time_t * out_time) -{ +{ globus_result_t result; time_t tmp_time = -1; GlobusGFSName(globus_gridftp_server_get_recv_modification_time); @@ -13744,13 +13740,13 @@ globus_gridftp_server_get_recv_modification_time( result = GlobusGFSErrorGeneric("Invalid parameters."); goto error; } - + if(op->storattr && op->storattr->modify) { char* tz; struct tm modtime; memset(&modtime, 0, sizeof(modtime)); - if (sscanf(op->storattr->modify, "%4d%2d%2d%2d%2d%2d", + if (sscanf(op->storattr->modify, "%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) { @@ -13771,11 +13767,11 @@ globus_gridftp_server_get_recv_modification_time( else globus_libc_unsetenv("TZ"); tzset(); - + op->storattr->modify_seen = GLOBUS_TRUE; } *out_time = tmp_time; - + GlobusGFSDebugExit(); return GLOBUS_SUCCESS; @@ -13784,8 +13780,8 @@ globus_gridftp_server_get_recv_modification_time( *out_time = -1; return result; } - - + + globus_result_t globus_gridftp_server_get_recv_attr_string( @@ -13804,7 +13800,7 @@ globus_gridftp_server_get_recv_attr_string( result = GlobusGFSErrorGeneric("Invalid parameters."); goto error; } - + if(op->storattr) { if(requested_attr) @@ -13838,7 +13834,7 @@ globus_gridftp_server_get_recv_attr_string( } } *out_value = tmp_val; - + GlobusGFSDebugExit(); return GLOBUS_SUCCESS; @@ -13846,7 +13842,7 @@ globus_gridftp_server_get_recv_attr_string( GlobusGFSDebugExitWithError(); return result; } - + globus_result_t globus_gridftp_server_register_read( @@ -14046,7 +14042,7 @@ globus_gridftp_server_finished_session_start( finished_info.info.session.home_dir = home_dir; /* pull response code from error */ - if(result != GLOBUS_SUCCESS && + if(result != GLOBUS_SUCCESS && (code = globus_gfs_error_get_ftp_response_code( globus_error_peek(result))) != 0) { @@ -14084,7 +14080,7 @@ globus_gridftp_server_finished_active_data( finished_info.info.data.bi_directional = bi_directional; /* pull response code from error */ - if(result != GLOBUS_SUCCESS && + if(result != GLOBUS_SUCCESS && (code = globus_gfs_error_get_ftp_response_code( globus_error_peek(result))) != 0) { @@ -14126,7 +14122,7 @@ globus_gridftp_server_finished_passive_data( finished_info.info.data.cs_count = cs_count; /* pull response code from error */ - if(result != GLOBUS_SUCCESS && + if(result != GLOBUS_SUCCESS && (code = globus_gfs_error_get_ftp_response_code( globus_error_peek(result))) != 0) { @@ -14155,7 +14151,7 @@ globus_i_gfs_data_request_set_cred( session_handle = (globus_l_gfs_data_session_t *) session_arg; globus_l_gfs_data_reset_watchdog(session_handle, NULL); - + if(del_cred != NULL) { session_handle->del_cred = del_cred; @@ -14186,7 +14182,7 @@ globus_i_gfs_data_request_buffer_send( session_handle = (globus_l_gfs_data_session_t *) session_arg; globus_l_gfs_data_reset_watchdog(session_handle, NULL); - + if(buffer_type & GLOBUS_GFS_BUFFER_SERVER_DEFINED) { switch(buffer_type) @@ -14215,11 +14211,11 @@ globus_i_gfs_data_request_buffer_send( void globus_i_gfs_data_http_read_cb( - globus_xio_handle_t xio_handle, + globus_xio_handle_t xio_handle, globus_result_t result, globus_byte_t * buffer, globus_size_t length, - globus_size_t nbytes, + globus_size_t nbytes, globus_xio_data_descriptor_t data_desc, void * user_arg) { @@ -14232,11 +14228,11 @@ globus_i_gfs_data_http_read_cb( offset = bounce_info->op->bytes_transferred; bounce_info->op->bytes_transferred += nbytes; - + eof = globus_xio_error_is_eof(result); if(eof) - { - if(bounce_info->op->bytes_transferred < + { + if(bounce_info->op->bytes_transferred < bounce_info->op->data_handle->http_length) { result = GlobusGFSErrorGeneric( @@ -14247,7 +14243,7 @@ globus_i_gfs_data_http_read_cb( result = GLOBUS_SUCCESS; } } - if(bounce_info->op->bytes_transferred > + if(bounce_info->op->bytes_transferred > bounce_info->op->data_handle->http_length) { result = GlobusGFSErrorGeneric( @@ -14271,11 +14267,11 @@ globus_i_gfs_data_http_read_cb( void globus_i_gfs_data_http_write_cb( - globus_xio_handle_t xio_handle, + globus_xio_handle_t xio_handle, globus_result_t result, globus_byte_t * buffer, globus_size_t length, - globus_size_t nbytes, + globus_size_t nbytes, globus_xio_data_descriptor_t data_desc, void * user_arg) { @@ -14316,9 +14312,9 @@ globus_l_gfs_data_http_perf( void * arg) { globus_l_gfs_data_operation_t * op; - + op = (globus_l_gfs_data_operation_t *) arg; - + if(op->data_handle) { globus_gfs_event_info_t event_reply; @@ -14350,14 +14346,14 @@ globus_l_gfs_data_http_transfer_cb( globus_mutex_unlock(&op->session_handle->mutex); globus_assert(!destroy_op); } - + if(op->data_handle->perf_handle != GLOBUS_NULL_HANDLE) { globus_callback_unregister( op->data_handle->perf_handle, NULL, NULL, NULL); op->data_handle->perf_handle = GLOBUS_NULL_HANDLE; } - + globus_xio_close(op->data_handle->http_handle, NULL); globus_libc_unsetenv("GLOBUS_GFS_EXTRA_CA_CERTS"); @@ -14369,7 +14365,7 @@ globus_l_gfs_data_http_transfer_cb( { char * count; globus_mutex_lock(&op->session_handle->mutex); - { + { count = globus_common_create_string("%"GLOBUS_OFF_T_FORMAT, op->data_handle->http_transferred); op->data_handle->http_transferred = 0; @@ -14393,7 +14389,7 @@ globus_l_gfs_data_http_event_cb( globus_result_t result = GLOBUS_SUCCESS; char * count; globus_l_gfs_data_operation_t * op; - + GlobusGFSName(globus_l_gfs_data_http_event_cb); GlobusGFSDebugEnter(); @@ -14403,7 +14399,7 @@ globus_l_gfs_data_http_event_cb( { case GLOBUS_GFS_EVENT_TRANSFER_BEGIN: globus_gridftp_server_intermediate_command(op, result, "0"); - + if(op->data_handle->perf_handle == GLOBUS_NULL_HANDLE) { globus_reltime_t timer; @@ -14416,16 +14412,16 @@ globus_l_gfs_data_http_event_cb( (void *) op); } break; - + case GLOBUS_GFS_EVENT_TRANSFER_CONNECTED: break; - + case GLOBUS_GFS_EVENT_DISCONNECTED: break; - + case GLOBUS_GFS_EVENT_BYTES_RECVD: globus_mutex_lock(&op->session_handle->mutex); - { + { count = globus_common_create_string("%"GLOBUS_OFF_T_FORMAT, op->data_handle->http_transferred); } @@ -14435,10 +14431,10 @@ globus_l_gfs_data_http_event_cb( globus_free(count); break; - + case GLOBUS_GFS_EVENT_RANGES_RECVD: break; - + default: globus_assert(0 && "Unexpected event type"); break; @@ -14466,7 +14462,7 @@ globus_i_gfs_data_http_parse_args( int tmp_consume; GlobusGFSName(globus_i_gfs_data_http_parse_args); GlobusGFSDebugEnter(); - + if((tmp_val = globus_i_gfs_kv_getval(argstring, "OFFSET", 0)) == NULL) { result = GlobusGFSErrorGeneric( @@ -14480,7 +14476,7 @@ globus_i_gfs_data_http_parse_args( "Invalid arguments: Invalid OFFSET."); goto err; } - + if((tmp_val = globus_i_gfs_kv_getval(argstring, "LENGTH", 0)) == NULL) { result = GlobusGFSErrorGeneric( @@ -14515,7 +14511,7 @@ globus_i_gfs_data_http_parse_args( *length = tmp_len; *request = tmp_req; *path = tmp_path; - + GlobusGFSDebugExit(); return GLOBUS_SUCCESS; @@ -14553,7 +14549,7 @@ globus_i_gfs_data_http_init( globus_l_gfs_data_session_t * session_handle, globus_bool_t https, globus_xio_handle_t * handle, - globus_xio_attr_t * attr, + globus_xio_attr_t * attr, globus_xio_data_descriptor_t * descriptor) { globus_result_t result; @@ -14583,7 +14579,7 @@ globus_i_gfs_data_http_init( if(!session_handle->http_stack) { globus_xio_stack_init(&session_handle->http_stack, NULL); - + result = globus_xio_stack_push_driver( session_handle->http_stack, gfs_l_tcp_driver); @@ -14600,7 +14596,7 @@ globus_i_gfs_data_http_init( if(!session_handle->https_stack) { globus_xio_stack_init(&session_handle->https_stack, NULL); - + result = globus_xio_stack_push_driver( session_handle->https_stack, gfs_l_tcp_driver); @@ -14630,7 +14626,7 @@ globus_i_gfs_data_http_init( result = globus_xio_handle_create( handle, session_handle->http_stack); } - + globus_assert(result == GLOBUS_SUCCESS); } if(attr) @@ -14646,25 +14642,25 @@ globus_i_gfs_data_http_init( if(https) { result = globus_xio_attr_cntl( - *attr, - gfs_l_gsi_driver, + *attr, + gfs_l_gsi_driver, GLOBUS_XIO_GSI_SET_SSL_COMPATIBLE, GLOBUS_TRUE); globus_assert(result == GLOBUS_SUCCESS); result = globus_xio_attr_cntl( - *attr, - gfs_l_gsi_driver, + *attr, + gfs_l_gsi_driver, GLOBUS_XIO_GSI_SET_PROTECTION_LEVEL, GLOBUS_XIO_GSI_PROTECTION_LEVEL_PRIVACY); globus_assert(result == GLOBUS_SUCCESS); result = globus_xio_attr_cntl( - *attr, - gfs_l_gsi_driver, + *attr, + gfs_l_gsi_driver, GLOBUS_XIO_GSI_SET_ANON); globus_assert(result == GLOBUS_SUCCESS); result = globus_xio_attr_cntl( - *attr, - gfs_l_gsi_driver, + *attr, + gfs_l_gsi_driver, GLOBUS_XIO_GSI_SET_ALLOW_MISSING_SIGNING_POLICY, GLOBUS_TRUE); globus_assert(result == GLOBUS_SUCCESS); @@ -14674,7 +14670,7 @@ globus_i_gfs_data_http_init( } else if(session_handle->http_ca_certs) { - globus_libc_setenv("GLOBUS_GFS_EXTRA_CA_CERTS", + globus_libc_setenv("GLOBUS_GFS_EXTRA_CA_CERTS", session_handle->http_ca_certs, 1); } } @@ -14682,7 +14678,7 @@ globus_i_gfs_data_http_init( result = globus_xio_data_descriptor_init(descriptor, *handle); globus_assert(result == GLOBUS_SUCCESS); - + GlobusGFSDebugExit(); return GLOBUS_SUCCESS; } @@ -14695,7 +14691,7 @@ globus_i_gfs_http_data_parse_request( globus_bool_t * https, int * http_ver, char ** method, - globus_xio_http_header_t ** headers, + globus_xio_http_header_t ** headers, int * count) { globus_result_t res; @@ -14725,11 +14721,11 @@ globus_i_gfs_http_data_parse_request( res = GlobusGFSErrorGeneric("Could not decode."); goto err; } - + res = -1; - - /* - parse from + + /* + parse from VERB {http|https}://hostname[:port]/url-encoded-path[?qs] HTTP/1.1\r\n */ line = d_req; @@ -14746,7 +14742,7 @@ globus_i_gfs_http_data_parse_request( goto err; } *ptr++ = 0; - tmp_method = strdup(line); + tmp_method = strdup(line); tmp_url = strdup(ptr); ptr = strchr(tmp_url, ' '); if(!ptr) @@ -14759,7 +14755,7 @@ globus_i_gfs_http_data_parse_request( { tmp_ver = GLOBUS_XIO_HTTP_VERSION_1_1; } - + tmp_headers = globus_malloc(cnt * sizeof(globus_xio_http_header_t)); /* parse headers Header-1: foo \r\n @@ -14781,7 +14777,7 @@ globus_i_gfs_http_data_parse_request( *ptr = 0; next_line = ptr + 2; } - + ptr = strchr(line, ':'); if(!ptr) { @@ -14793,19 +14789,19 @@ globus_i_gfs_http_data_parse_request( ptr++; tmp_hname = strdup(line); tmp_hval = strdup(ptr); - + if(i >= cnt) { cnt += 20; tmp_headers = globus_realloc( tmp_headers, cnt * sizeof(globus_xio_http_header_t)); } - + tmp_headers[i].name = tmp_hname; tmp_headers[i].value = tmp_hval; i++; - - + + line = next_line; } @@ -14817,7 +14813,7 @@ globus_i_gfs_http_data_parse_request( { *https = GLOBUS_FALSE; } - + /* find third / in scheme://host/ to get path */ ptr = strchr(tmp_url, '/'); if(!ptr) @@ -14839,7 +14835,7 @@ globus_i_gfs_http_data_parse_request( res = GlobusGFSErrorGeneric("Invalid URI."); goto err; } - + /* urlencode path in because xio will decode it */ enc_path = globus_url_string_hex_encode(ptr, "<>:@"); *ptr = 0; @@ -14850,20 +14846,20 @@ globus_i_gfs_http_data_parse_request( *count = i; *method = tmp_method; *http_ver = tmp_ver; - + globus_free(tmp_url); globus_free(d_req); GlobusGFSDebugExit(); - + return GLOBUS_SUCCESS; err: GlobusGFSDebugExitWithError(); - return res; + return res; } -globus_result_t +globus_result_t globus_i_gfs_data_http_get( globus_l_gfs_data_operation_t * op, char * path, @@ -14896,7 +14892,7 @@ globus_i_gfs_data_http_get( char * ptr; GlobusGFSName(globus_l_gfs_data_http_get); GlobusGFSDebugEnter(); - + /* parse url, headers */ result = globus_i_gfs_http_data_parse_request( request, &url, &https, &http_ver, &method, &headers, &count); @@ -14905,7 +14901,7 @@ globus_i_gfs_data_http_get( result = GlobusGFSErrorWrapFailed("Invalid request. Parsing", result); goto response_exit; } - + handle = op->session_handle->http_handle; result = globus_i_gfs_data_http_init(op->session_handle, https, &handle, &attr, &descriptor); @@ -14913,7 +14909,7 @@ globus_i_gfs_data_http_get( { goto response_exit; } - + result = globus_xio_attr_cntl( attr, op->session_handle->http_driver, @@ -14933,8 +14929,8 @@ globus_i_gfs_data_http_get( { goto response_exit; } - - /* set individual headers */ + + /* set individual headers */ for (i = 0; i < count; i++) { result = globus_xio_attr_cntl( @@ -14954,9 +14950,9 @@ globus_i_gfs_data_http_get( { retry = do_retry && (globus_error_get_type(globus_error_peek(result)) == GLOBUS_XIO_HTTP_ERROR_PERSISTENT_CONNECTION_DROPPED); - + if(!retry) - { + { result = GlobusGFSErrorWrapFailed("HTTP connection", result); goto response_exit; } @@ -14990,7 +14986,7 @@ globus_i_gfs_data_http_get( { *ptr = '\0'; } - + /* read response, no data */ result = globus_xio_read( handle, @@ -15009,7 +15005,7 @@ globus_i_gfs_data_http_get( result = GLOBUS_SUCCESS; } } - + if(retry) { globus_xio_close(op->session_handle->http_handle, NULL); @@ -15030,7 +15026,7 @@ globus_i_gfs_data_http_get( return globus_i_gfs_data_http_get( op, path, request, offset, length, GLOBUS_FALSE); } - + if(result != GLOBUS_SUCCESS) { result = GlobusGFSErrorWrapFailed("Before getting response, HTTP connection", result); @@ -15090,9 +15086,9 @@ globus_i_gfs_data_http_get( else { waitfor = GLOBUS_MIN(1024, buflen-total_nbytes); - } + } } while(!eof); - + body_buffer[total_nbytes] = '\0'; globus_i_gfs_data_http_print_response( status_code, &header_table, body_buffer, &header_str); @@ -15104,7 +15100,7 @@ globus_i_gfs_data_http_get( header_str); result = GlobusGFSErrorGeneric(err_str); - + globus_free(err_str); globus_free(header_str); globus_free(body_buffer); @@ -15115,10 +15111,10 @@ globus_i_gfs_data_http_get( { globus_i_gfs_data_http_print_response( status_code, &header_table, NULL, &op->user_msg); - } - - - /* set up internal file recv request */ + } + + + /* set up internal file recv request */ recv_info = (globus_gfs_transfer_info_t *) globus_calloc(1, sizeof(globus_gfs_transfer_info_t)); recv_info->alloc_size = length; @@ -15148,7 +15144,7 @@ globus_i_gfs_data_http_get( &data_handle->session_handle->handle_table, data_handle, 1); - + data_handle->http_handle = handle; data_handle->http_length = length; data_handle->http_ip = globus_libc_strdup(op->http_ip); @@ -15163,8 +15159,8 @@ globus_i_gfs_data_http_get( globus_l_gfs_data_http_transfer_cb, globus_l_gfs_data_http_event_cb, op); - - + + return GLOBUS_SUCCESS; open_exit: @@ -15173,10 +15169,10 @@ globus_i_gfs_data_http_get( GlobusGFSDebugExit(); return result; - + } -globus_result_t +globus_result_t globus_i_gfs_data_http_put( globus_l_gfs_data_operation_t * op, char * path, @@ -15209,7 +15205,7 @@ globus_i_gfs_data_http_put( char * ptr; GlobusGFSName(globus_l_gfs_data_http_put); GlobusGFSDebugEnter(); - + /* parse url, headers */ result = globus_i_gfs_http_data_parse_request( request, &url, &https, &http_ver, &method, &headers, &count); @@ -15226,7 +15222,7 @@ globus_i_gfs_data_http_put( { goto response_exit; } - + result = globus_xio_attr_cntl( attr, op->session_handle->http_driver, @@ -15246,8 +15242,8 @@ globus_i_gfs_data_http_put( { goto response_exit; } - - /* set individual headers */ + + /* set individual headers */ for (i = 0; i < count; i++) { result = globus_xio_attr_cntl( @@ -15289,7 +15285,7 @@ globus_i_gfs_data_http_put( goto response_exit; } } - + result = globus_xio_open(handle, url, attr); if(result != GLOBUS_SUCCESS) { @@ -15327,7 +15323,7 @@ globus_i_gfs_data_http_put( result = GLOBUS_SUCCESS; } } - + if(retry) { globus_xio_close(op->session_handle->http_handle, NULL); @@ -15347,7 +15343,7 @@ globus_i_gfs_data_http_put( return globus_i_gfs_data_http_put( op, path, request, offset, length, GLOBUS_FALSE); } - + if(result != GLOBUS_SUCCESS) { result = GlobusGFSErrorWrapFailed("Before getting response, HTTP connection", result); @@ -15376,7 +15372,7 @@ globus_i_gfs_data_http_put( globus_size_t total_nbytes = 0; globus_bool_t eof; globus_size_t waitfor = 0; - + body_buffer = malloc(buflen+1); do { @@ -15399,7 +15395,7 @@ globus_i_gfs_data_http_put( eof = GLOBUS_TRUE; } total_nbytes += body_nbytes; - + if(body_nbytes == 0 || total_nbytes == buflen) { eof = GLOBUS_TRUE; @@ -15407,25 +15403,25 @@ globus_i_gfs_data_http_put( else { waitfor = GLOBUS_MIN(1024, buflen-total_nbytes); - } + } } while(!eof); - + body_buffer[total_nbytes] = '\0'; globus_i_gfs_data_http_print_response( status_code, &header_table, body_buffer, &header_str); - + err_str = globus_common_create_string( "HTTP PUT failed with \"%03d %s\"\n%s", status_code, reason_phrase, header_str); - + result = GlobusGFSErrorGeneric(err_str); - + globus_free(err_str); globus_free(header_str); globus_free(body_buffer); - + goto open_exit; } } @@ -15460,12 +15456,12 @@ globus_i_gfs_data_http_put( &data_handle->session_handle->handle_table, data_handle, 1); - + data_handle->http_handle = handle; data_handle->http_length = length; data_handle->http_ip = globus_libc_strdup(op->http_ip); op->data_handle = data_handle; - + op->ref++; globus_i_gfs_data_request_send( NULL, @@ -15475,11 +15471,11 @@ globus_i_gfs_data_http_put( globus_l_gfs_data_http_transfer_cb, globus_l_gfs_data_http_event_cb, op); - - + + return GLOBUS_SUCCESS; -open_exit: +open_exit: response_exit: GlobusGFSDebugExit(); return result; diff --git a/gridftp/server/src/globus_i_gfs_default_brain.c b/gridftp/server/src/globus_i_gfs_default_brain.c index d476d224d6..ae456da66e 100644 --- a/gridftp/server/src/globus_i_gfs_default_brain.c +++ b/gridftp/server/src/globus_i_gfs_default_brain.c @@ -84,7 +84,7 @@ gfs_l_db_node_cmp( } /* if the total number of connections is capped and we have exceded the cap send it to the back */ - if(n1->total_max_connections > 0 + if(n1->total_max_connections > 0 && n1->total_connections >= n1->total_max_connections) { return 1; @@ -121,7 +121,7 @@ gfs_l_db_parse_string_list( { return NULL; } - + tmp_str = globus_libc_strdup(str_list); last_str = tmp_str; while((p = strchr(last_str, ',')) != NULL) @@ -131,7 +131,7 @@ gfs_l_db_parse_string_list( last_str = p + 1; } globus_list_insert(&list, strdup(last_str)); - + globus_free(tmp_str); return list; @@ -156,7 +156,7 @@ globus_l_brain_log_socket( { peer_contact = strdup("could get peer addr"); } - + globus_gfs_log_message( GLOBUS_GFS_LOG_WARN, "[%s] %s", peer_contact, msg); @@ -242,7 +242,7 @@ globus_l_gfs_gfork_dyn_reg( repo = (gfs_l_db_repo_t *) calloc(1, sizeof(gfs_l_db_repo_t)); globus_priority_q_init(&repo->node_q, gfs_l_db_node_cmp); globus_hashtable_init( - &repo->node_table, + &repo->node_table, 32, globus_hashtable_string_hash, globus_hashtable_string_keyeq); @@ -257,7 +257,7 @@ globus_l_gfs_gfork_dyn_reg( } if(node == NULL) - { + { node = (gfs_l_db_node_t*)globus_calloc(1, sizeof(gfs_l_db_node_t)); node->host_id = strdup(cs); node->cookie_id = cookie_id; @@ -326,7 +326,6 @@ globus_l_gfs_mem_limit_release_cb( void * user_arg) { globus_xio_iovec_t iov[1]; - globus_result_t result; globus_byte_t * buffer; uint32_t tmp32; @@ -343,7 +342,7 @@ globus_l_gfs_mem_limit_release_cb( iov[0].iov_base = buffer; iov[0].iov_len = GF_RELEASE_MSG_LEN; - result = globus_gfork_send( + globus_gfork_send( globus_l_gfs_gfork_handle, -1, /* to the master */ iov, @@ -407,14 +406,14 @@ globus_l_gfs_gfork_incoming_cb( { globus_gfs_log_message( GLOBUS_GFS_LOG_ERR, - "[%s] error in dyn reg size\n", + "[%s] error in dyn reg size\n", "globus_l_gfs_gfork_incoming_cb()"); } else { globus_gfs_log_message( GLOBUS_GFS_LOG_INFO, - "[%s] registering a new backend %d\n", + "[%s] registering a new backend %d\n", "globus_l_gfs_gfork_incoming_cb()", n32); globus_l_gfs_gfork_dyn_reg( @@ -476,9 +475,9 @@ globus_l_gfs_gfork_incoming_cb( default: globus_gfs_log_message( - GLOBUS_GFS_LOG_WARN, + GLOBUS_GFS_LOG_WARN, "Unknown GFork message type received.\n"); - break; + break; } } globus_mutex_unlock(&globus_l_brain_mutex); @@ -520,7 +519,7 @@ globus_l_gfs_default_brain_init( GFS_DB_REPO_SIZE, globus_hashtable_string_hash, globus_hashtable_string_keyeq); - + remote_list = globus_i_gfs_config_string("remote_nodes"); list = gfs_l_db_parse_string_list(remote_list); @@ -531,7 +530,7 @@ globus_l_gfs_default_brain_init( globus_priority_q_init(&default_repo->node_q, gfs_l_db_node_cmp); globus_hashtable_init( - &gfs_l_db_default_repo->node_table, + &gfs_l_db_default_repo->node_table, 32, globus_hashtable_string_hash, globus_hashtable_string_keyeq); @@ -574,7 +573,7 @@ globus_l_gfs_default_brain_init( if(result != GLOBUS_SUCCESS) { globus_gfs_log_result( - GLOBUS_GFS_LOG_DUMP, + GLOBUS_GFS_LOG_DUMP, "GFork functionality not enabled.", result); @@ -615,7 +614,7 @@ globus_l_gfs_default_brain_available( int * count) { int size; - + size = globus_priority_q_size(&gfs_l_db_default_repo->node_q); *count = size; @@ -690,7 +689,7 @@ globus_l_gfs_default_brain_select_nodes( } count = 0; e_count = count; - + do { loop_count = 0; @@ -709,7 +708,7 @@ globus_l_gfs_default_brain_select_nodes( else if( (node->current_connection >= node->max_connection && node->max_connection < 0) || - (node->total_max_connections > 0 && + (node->total_max_connections > 0 && node->total_connections >= node->total_max_connections)) { /* need to up everything for sake of nice clean up*/ @@ -733,8 +732,8 @@ globus_l_gfs_default_brain_select_nodes( GlobusGFSErrorObjParameter("No nodes available.")); goto error_short; } - - /* if we are here we were successful and must re-enqueue the nodes + + /* if we are here we were successful and must re-enqueue the nodes * we just took out with new order */ for(i = count - loop_count; i < count; i++) { diff --git a/gridftp/server/src/modules/file/globus_gridftp_server_file.c b/gridftp/server/src/modules/file/globus_gridftp_server_file.c index 2ce4c7fae5..3605836441 100644 --- a/gridftp/server/src/modules/file/globus_gridftp_server_file.c +++ b/gridftp/server/src/modules/file/globus_gridftp_server_file.c @@ -58,7 +58,7 @@ GlobusDebugDeclare(GLOBUS_GRIDFTP_SERVER_FILE); GlobusGFSFileDebugPrintf( \ GLOBUS_GFS_DEBUG_TRACE, \ ("[%s] Entering\n", _gfs_name)) - + #define GlobusGFSFileDebugExit() \ GlobusGFSFileDebugPrintf( \ GLOBUS_GFS_DEBUG_TRACE, \ @@ -98,7 +98,7 @@ typedef struct globus_l_gfs_file_cksm_monitor_s globus_size_t block_size; globus_l_gfs_file_cksm_cb_t internal_cb; void * internal_cb_arg; - + globus_callback_handle_t marker_handle; int marker_freq; globus_bool_t send_marker; @@ -116,7 +116,7 @@ typedef struct globus_l_gfs_file_cksm_monitor_s globus_byte_t buffer[]; } globus_l_gfs_file_cksm_monitor_t; -typedef struct +typedef struct { gss_cred_id_t cred; char * sbj; @@ -190,7 +190,7 @@ globus_l_gfs_file_cksm( globus_off_t length, globus_l_gfs_file_cksm_cb_t internal_cb, void * internal_cb_arg); - + static globus_result_t globus_l_gfs_file_make_stack( @@ -279,7 +279,7 @@ globus_l_gfs_file_make_stack( * else if priority_1 comes before priority_2, return < 0 * else return 0 */ - + static int globus_l_gfs_file_queue_compare( @@ -294,7 +294,7 @@ globus_l_gfs_file_queue_compare( buf_info1 = (globus_l_buffer_info_t *) priority_1; buf_info2 = (globus_l_buffer_info_t *) priority_2; - + /* the void * are really just offsets */ if(buf_info1->offset > buf_info2->offset) { @@ -304,7 +304,7 @@ globus_l_gfs_file_queue_compare( { rc = -1; } - + GlobusGFSFileDebugExit(); return rc; } @@ -321,7 +321,7 @@ globus_l_gfs_file_monitor_init( int rc; GlobusGFSName(globus_l_gfs_file_monitor_init); GlobusGFSFileDebugEnter(); - + monitor = (globus_l_file_monitor_t *) globus_malloc( sizeof(globus_l_file_monitor_t)); if(!monitor) @@ -329,15 +329,15 @@ globus_l_gfs_file_monitor_init( result = GlobusGFSErrorMemory("monitor"); goto error_alloc; } - + rc = globus_memory_init(&monitor->mem, block_size, optimal_count); if(!rc) { globus_free(monitor); result = GlobusGFSErrorMemory("buffer"); goto error_alloc; - } - + } + globus_mutex_init(&monitor->lock, NULL); globus_priority_q_init( &monitor->queue, globus_l_gfs_file_queue_compare); @@ -360,7 +360,7 @@ globus_l_gfs_file_monitor_init( monitor->pathname = NULL; *u_monitor = monitor; - + GlobusGFSFileDebugExit(); return GLOBUS_SUCCESS; @@ -379,7 +379,7 @@ globus_l_gfs_file_monitor_destroy( globus_byte_t * buffer; GlobusGFSName(globus_l_gfs_file_monitor_destroy); GlobusGFSFileDebugEnter(); - + while(!globus_priority_q_empty(&monitor->queue)) { buf_info = (globus_l_buffer_info_t *) @@ -393,7 +393,7 @@ globus_l_gfs_file_monitor_destroy( globus_free(buf_info); } } - + for(list = monitor->buffer_list; !globus_list_empty(list); list = globus_list_rest(list)) @@ -401,12 +401,12 @@ globus_l_gfs_file_monitor_destroy( buffer = (globus_byte_t *) globus_list_first(list); globus_memory_push_node(&monitor->mem, buffer); } - + if(monitor->pathname) { globus_free(monitor->pathname); } - + if(monitor->expected_cksm) { globus_free(monitor->expected_cksm); @@ -415,7 +415,7 @@ globus_l_gfs_file_monitor_destroy( { globus_free(monitor->expected_cksm_alg); } - + globus_priority_q_destroy(&monitor->queue); globus_list_free(monitor->buffer_list); globus_memory_destroy(&monitor->mem); @@ -436,12 +436,12 @@ globus_l_gfs_file_cksm_verify( globus_l_file_monitor_t * monitor; GlobusGFSName(globus_l_gfs_file_cksm_verify); GlobusGFSFileDebugEnter(); - + monitor = (globus_l_file_monitor_t *) user_arg; - + if(result != GLOBUS_SUCCESS) { - monitor->finish_result = + monitor->finish_result = GlobusGFSErrorWrapFailed("checksum verification", result); } else if(strcmp(monitor->expected_cksm, cksm) != 0) @@ -452,13 +452,13 @@ globus_l_gfs_file_cksm_verify( globus_gridftp_server_finished_transfer( monitor->op, monitor->finish_result); - + globus_l_gfs_file_monitor_destroy(monitor); GlobusGFSFileDebugExit(); } -static +static globus_bool_t globus_l_gfs_file_timeout_cb( globus_xio_handle_t handle, @@ -472,7 +472,7 @@ globus_l_gfs_file_timeout_cb( globus_gfs_log_message( GLOBUS_GFS_LOG_WARN, "A file access timeout has occurred.\n"); - + GlobusGFSFileDebugExit(); return GLOBUS_TRUE; @@ -491,10 +491,10 @@ globus_l_gfs_file_close_cb( monitor = (globus_l_file_monitor_t *) user_arg; GlobusGFSFileDebugEnter(); - + if(monitor != NULL) { - /* must lock/unlock or we can get to the destroy before the + /* must lock/unlock or we can get to the destroy before the registeration locak has actually released... crazy threads */ globus_mutex_lock(&monitor->lock); { @@ -505,20 +505,20 @@ globus_l_gfs_file_close_cb( } globus_mutex_unlock(&monitor->lock); - if(monitor->finish_result == GLOBUS_SUCCESS && + if(monitor->finish_result == GLOBUS_SUCCESS && monitor->utime >= 0) { monitor->finish_result = globus_l_gfs_file_utime( NULL, monitor->pathname, monitor->utime); } - - if(monitor->finish_result == GLOBUS_SUCCESS && + + if(monitor->finish_result == GLOBUS_SUCCESS && monitor->expected_cksm != NULL) { /* verify file before finishing */ result = globus_l_gfs_file_cksm( - NULL, - monitor->pathname, + NULL, + monitor->pathname, monitor->expected_cksm_alg, 0, -1, @@ -529,7 +529,7 @@ globus_l_gfs_file_close_cb( { globus_gridftp_server_finished_transfer( monitor->op, monitor->finish_result); - + globus_l_gfs_file_monitor_destroy(monitor); } } @@ -597,8 +597,8 @@ globus_l_gfs_file_close( /** * stat calls */ - -/* basepath and filename must be MAXPATHLEN long + +/* basepath and filename must be MAXPATHLEN long * the pathname may be absolute or relative, basepath will be the same */ static void @@ -611,12 +611,12 @@ globus_l_gfs_file_partition_path( char * filepart; GlobusGFSName(globus_l_gfs_file_partition_path); GlobusGFSFileDebugEnter(); - + strncpy(buf, pathname, MAXPATHLEN); buf[MAXPATHLEN - 1] = '\0'; - + filepart = strrchr(buf, '/'); - + #ifdef WIN32 @@ -652,15 +652,15 @@ globus_l_gfs_file_partition_path( } } else - { + { *filepart++ = '\0'; strcpy(basepath, buf); strcpy(filename, filepart); } - } + } if(filename[0] == 0) - { + { filename[0] = '/'; filename[1] = 0; } @@ -678,7 +678,7 @@ globus_l_gfs_file_realpath( char resolved[MAXPATHLEN]; GlobusGFSName(globus_l_gfs_file_stat); GlobusGFSFileDebugEnter(); - + if(realpath(in_path, resolved) == NULL) { result = GlobusGFSErrorSystemError("realpath", errno); @@ -719,7 +719,7 @@ globus_l_gfs_file_copy_stat( stat_object->ino = stat_buf->st_ino; stat_object->link_mode = link_mode; stat_object->error = error; - + if(filename && *filename) { stat_object->name = globus_libc_strdup(filename); @@ -748,23 +748,23 @@ globus_l_gfs_file_destroy_stat( int i; GlobusGFSName(globus_l_gfs_file_destroy_stat); GlobusGFSFileDebugEnter(); - + for(i = 0; i < stat_count; i++) { if(stat_array[i].name != NULL) { globus_free(stat_array[i].name); - } + } if(stat_array[i].symlink_target != NULL) { globus_free(stat_array[i].symlink_target); } } - globus_free(stat_array); + globus_free(stat_array); GlobusGFSFileDebugExit(); } - + #define GFS_STAT_COUNT_CHECK 100 #define GFS_STAT_COUNT_MAX 1000 @@ -787,39 +787,39 @@ globus_l_gfs_file_stat( char filename[MAXPATHLEN]; char symlink_target[MAXPATHLEN]; globus_gridftp_server_control_stat_error_t base_error = GLOBUS_GRIDFTP_SERVER_CONTROL_STAT_SUCCESS; - + GlobusGFSName(globus_l_gfs_file_stat); GlobusGFSFileDebugEnter(); - + /* lstat is the same as stat when not operating on a link */ if(lstat(stat_info->pathname, &stat_buf) != 0) { result = GlobusGFSErrorSystemError("stat", errno); goto error_stat1; } - /* if this is a link we still need to stat to get the info we are - interested in and then use realpath() to get the full path of + /* if this is a link we still need to stat to get the info we are + interested in and then use realpath() to get the full path of the symlink target */ *symlink_target = '\0'; if(S_ISLNK(stat_buf.st_mode)) { int stat_result = 0; - + if(stat_info->use_symlink_info) { memset(&link_stat_buf, 0, sizeof(struct stat)); stat_result = stat(stat_info->pathname, &link_stat_buf); - } + } else if(stat(stat_info->pathname, &stat_buf) != 0) { result = GlobusGFSErrorSystemError("stat", errno); goto error_stat1; } - + if(stat_result < 0 || realpath(stat_info->pathname, symlink_target) == NULL) { int nchars = readlink(stat_info->pathname, symlink_target, MAXPATHLEN); - if (nchars < 0) + if (nchars < 0) { result = GlobusGFSErrorSystemError("realpath", errno); goto error_stat1; @@ -827,9 +827,9 @@ globus_l_gfs_file_stat( symlink_target[nchars] = '\0'; base_error = GLOBUS_GRIDFTP_SERVER_CONTROL_STAT_INVALIDLINK; } - } + } globus_l_gfs_file_partition_path(stat_info->pathname, basepath, filename); - + if(!S_ISDIR(stat_buf.st_mode) || stat_info->file_only) { stat_array = (globus_gfs_stat_t *) @@ -839,7 +839,7 @@ globus_l_gfs_file_stat( result = GlobusGFSErrorMemory("stat_array"); goto error_alloc1; } - + globus_l_gfs_file_copy_stat( stat_array, &stat_buf, filename, symlink_target, link_stat_buf.st_mode, base_error); stat_count = 1; @@ -859,17 +859,17 @@ globus_l_gfs_file_stat( globus_bool_t check_cdir = GLOBUS_TRUE; stat_limit_time = time(NULL) + GFS_STAT_TIME; - + stat_count = stat_info->include_path_stat ? 1 : 0; - + { - if(stat_info->pathname && + if(stat_info->pathname && stat_info->pathname[0] == '/' && stat_info->pathname[1] == 0) { DWORD drivemask; char drive[] = "A"; - + stat_array = (globus_gfs_stat_t *) globus_malloc(sizeof(globus_gfs_stat_t) * 30); if(!stat_array) @@ -892,7 +892,7 @@ globus_l_gfs_file_stat( } goto done_fake; - + } } @@ -904,7 +904,7 @@ globus_l_gfs_file_stat( if (!stat_info->include_path_stat) goto error_open; } - + total_stat_count = 0; while(globus_libc_readdir_r(dir, &dir_entry) == 0 && dir_entry) @@ -912,46 +912,46 @@ globus_l_gfs_file_stat( total_stat_count++; globus_free(dir_entry); } - + globus_libc_rewinddir(dir); stat_array = (globus_gfs_stat_t *) globus_malloc( - sizeof(globus_gfs_stat_t) * + sizeof(globus_gfs_stat_t) * (GLOBUS_MIN(stat_limit_max, total_stat_count) + 1)); if(!stat_array) { result = GlobusGFSErrorMemory("stat_array"); goto error_alloc2; } - + snprintf( - dir_path, - sizeof(dir_path), - "%s/%s", - (basepath[0] != '/' || basepath[1] != '\0') ? basepath : "", + dir_path, + sizeof(dir_path), + "%s/%s", + (basepath[0] != '/' || basepath[1] != '\0') ? basepath : "", filename); - + dir_path[maxpathlen - 1] = '\0'; if(!basepath[0] && filename[0] == '/') { dir_path[0] = 0; } - + i = 0; - if(stat_info->include_path_stat) + if(stat_info->include_path_stat) { globus_l_gfs_file_copy_stat(&stat_array[i++], &stat_buf, filename, NULL, 0, dir ? GLOBUS_GRIDFTP_SERVER_CONTROL_STAT_SUCCESS : GLOBUS_GRIDFTP_SERVER_CONTROL_STAT_OPENFAILED); } - + while(globus_libc_readdir_r(dir, &dir_entry) == 0 && dir_entry) { char path[maxpathlen]; - + base_error = GLOBUS_GRIDFTP_SERVER_CONTROL_STAT_SUCCESS; snprintf(path, sizeof(path), "%s/%s", dir_path, dir_entry->d_name); path[maxpathlen - 1] = '\0'; - + if(stat(path, &stat_buf) != 0) { /* stat() doesn't return a useful error */ @@ -980,7 +980,7 @@ globus_l_gfs_file_stat( &stat_array[i], &stat_buf, dir_entry->d_name, symlink_target, link_stat_buf.st_mode, base_error); /* set nlink to total files in dir for . entry */ - if(check_cdir && dir_entry->d_name && + if(check_cdir && dir_entry->d_name && dir_entry->d_name[0] == '.' && dir_entry->d_name[1] == '\0') { check_cdir = GLOBUS_FALSE; @@ -990,7 +990,7 @@ globus_l_gfs_file_stat( { unsigned long h = 0; char * key; - + key = path; while(*key) { @@ -1001,13 +1001,13 @@ globus_l_gfs_file_stat( i++; globus_free(dir_entry); - + /* send updates every GFS_STAT_TIME, checked every GFS_STAT_CHECK */ if(i >= stat_limit_check) { time_t tmp_time; globus_bool_t send_stats = GLOBUS_FALSE; - + tmp_time = time(NULL); if(i >= stat_limit_max || tmp_time > stat_limit_time) { @@ -1017,7 +1017,7 @@ globus_l_gfs_file_stat( { stat_limit_check += GFS_STAT_COUNT_CHECK; } - + if(send_stats) { stat_count = i; @@ -1025,12 +1025,12 @@ globus_l_gfs_file_stat( stat_limit_time = tmp_time + GFS_STAT_TIME; i = 0; - + globus_gridftp_server_finished_stat_partial( op, GLOBUS_SUCCESS, stat_array, stat_count); - + globus_l_gfs_file_destroy_stat(stat_array, stat_count); - + stat_array = (globus_gfs_stat_t *) globus_malloc( sizeof(globus_gfs_stat_t) * (stat_limit_max + 1)); if(!stat_array) @@ -1038,13 +1038,13 @@ globus_l_gfs_file_stat( result = GlobusGFSErrorMemory("stat_array"); goto error_alloc2; } - + stat_count = 0; } - } + } } stat_count = i; - + closedir(dir); goto done_fake; @@ -1071,11 +1071,11 @@ globus_l_gfs_file_stat( int slow_listing_thresh; stat_limit_time = time(NULL) + GFS_STAT_TIME; - + total_stat_count = scandir( - stat_info->pathname, - &entries, - NULL, + stat_info->pathname, + &entries, + NULL, (getenv("FTPNOSORT") ? NULL : alphasort)); if(total_stat_count < 0) { @@ -1090,33 +1090,33 @@ globus_l_gfs_file_stat( } stat_array = (globus_gfs_stat_t *) globus_malloc( - sizeof(globus_gfs_stat_t) * + sizeof(globus_gfs_stat_t) * (GLOBUS_MIN(stat_limit_max, total_stat_count) + 1)); if(!stat_array) { result = GlobusGFSErrorMemory("stat_array"); goto error_open; } - + snprintf( - dir_path, - sizeof(dir_path), - "%s/%s", - (basepath[0] != '/' || basepath[1] != '\0') ? basepath : "", + dir_path, + sizeof(dir_path), + "%s/%s", + (basepath[0] != '/' || basepath[1] != '\0') ? basepath : "", filename); - + dir_path[MAXPATHLEN - 1] = '\0'; - + i = 0; j = 0; while(j < total_stat_count) - { + { char path[MAXPATHLEN]; - + dir_entry = entries[j++]; snprintf(path, sizeof(path), "%s/%s", dir_path, dir_entry->d_name); path[MAXPATHLEN - 1] = '\0'; - + /* fake a stat response if stats are slow, d_type is valid, * and indicates a file or dir */ #ifndef _DIRENT_HAVE_D_TYPE @@ -1186,7 +1186,7 @@ globus_l_gfs_file_stat( } globus_l_gfs_file_copy_stat( &stat_array[i], &stat_buf, dir_entry->d_name, symlink_target, link_stat_buf.st_mode, base_error); - + /* set nlink to total files in dir for . entry */ if(check_cdir && dir_entry->d_name[0] == '.' && dir_entry->d_name[1] == '\0') @@ -1204,7 +1204,7 @@ globus_l_gfs_file_stat( { time_t tmp_time; globus_bool_t send_stats = GLOBUS_FALSE; - + tmp_time = time(NULL); if(i >= stat_limit_max || tmp_time >= stat_limit_time) { @@ -1214,7 +1214,7 @@ globus_l_gfs_file_stat( { stat_limit_check += GFS_STAT_COUNT_CHECK; } - + if(send_stats) { stat_count = i; @@ -1227,7 +1227,7 @@ globus_l_gfs_file_stat( op, GLOBUS_SUCCESS, stat_array, stat_count); globus_l_gfs_file_destroy_stat(stat_array, stat_count); - + stat_array = (globus_gfs_stat_t *) globus_malloc( sizeof(globus_gfs_stat_t) * (stat_limit_max + 1)); if(!stat_array) @@ -1235,13 +1235,13 @@ globus_l_gfs_file_stat( result = GlobusGFSErrorMemory("stat_array"); goto error_open; } - + stat_count = 0; } - } + } } stat_count = i; - + if(entries) { globus_free(entries); @@ -1252,7 +1252,7 @@ globus_l_gfs_file_stat( globus_gridftp_server_finished_stat( op, result, stat_array, stat_count); globus_l_gfs_file_destroy_stat(stat_array, stat_count); - + GlobusGFSFileDebugExit(); return; @@ -1276,12 +1276,12 @@ globus_l_gfs_file_truncate( globus_result_t result; globus_xio_system_file_t fd; struct stat sbuf; - + GlobusGFSName(globus_l_gfs_file_truncate); GlobusGFSFileDebugEnter(); result = globus_xio_system_file_open( - &fd, pathname, + &fd, pathname, GLOBUS_XIO_FILE_RDWR | GLOBUS_XIO_FILE_BINARY, 0); if(result != GLOBUS_SUCCESS) { @@ -1289,16 +1289,16 @@ globus_l_gfs_file_truncate( } #ifdef WIN32 - rc = stat(pathname, &sbuf); + rc = stat(pathname, &sbuf); #else rc = fstat(fd, &sbuf); -#endif +#endif if(rc != 0) { result = GlobusGFSErrorSystemError("stat", errno); goto error_close; } - + if(offset > sbuf.st_size) { result = GlobusGFSErrorGeneric( @@ -1311,15 +1311,15 @@ globus_l_gfs_file_truncate( { goto error_close; } - + result = globus_xio_system_file_close(fd); if(result != GLOBUS_SUCCESS) { goto error; } - + globus_gridftp_server_finished_command(op, GLOBUS_SUCCESS, NULL); - + GlobusGFSFileDebugExit(); return GLOBUS_SUCCESS; @@ -1347,12 +1347,12 @@ globus_l_gfs_file_mkdir( result = GlobusGFSErrorSystemError("mkdir", errno); goto error; } - + globus_gridftp_server_finished_command(op, GLOBUS_SUCCESS, NULL); - + GlobusGFSFileDebugExit(); return GLOBUS_SUCCESS; - + error: GlobusGFSFileDebugExitWithError(); return result; @@ -1375,12 +1375,12 @@ globus_l_gfs_file_rmdir( result = GlobusGFSErrorSystemError("rmdir", errno); goto error; } - + globus_gridftp_server_finished_command(op, GLOBUS_SUCCESS, NULL); - + GlobusGFSFileDebugExit(); return GLOBUS_SUCCESS; - + error: GlobusGFSFileDebugExitWithError(); return result; @@ -1397,22 +1397,21 @@ globus_l_gfs_file_delete_dir( DIR * dir; struct stat stat_buf; struct dirent * dir_entry; - int i; char path[MAXPATHLEN]; GlobusGFSName(globus_l_gfs_file_delete_dir); GlobusGFSFileDebugEnter(); - + /* lstat is the same as stat when not operating on a link */ if(lstat(pathname, &stat_buf) != 0) { result = GlobusGFSErrorSystemError("stat", errno); goto error_stat; } - + if(!S_ISDIR(stat_buf.st_mode)) { /* remove anything that isn't a dir -- don't follow links */ - rc = unlink(pathname); + rc = unlink(pathname); if(rc != 0) { result = GlobusGFSErrorSystemError("unlink", errno); @@ -1427,13 +1426,11 @@ globus_l_gfs_file_delete_dir( result = GlobusGFSErrorSystemError("opendir", errno); goto error_open; } - - for(i = 0; - globus_libc_readdir_r(dir, &dir_entry) == 0 && dir_entry; - i++) - { - if(dir_entry->d_name[0] == '.' && - (dir_entry->d_name[1] == '\0' || + + while(globus_libc_readdir_r(dir, &dir_entry) == 0 && dir_entry) + { + if(dir_entry->d_name[0] == '.' && + (dir_entry->d_name[1] == '\0' || (dir_entry->d_name[1] == '.' && dir_entry->d_name[2] == '\0'))) { globus_free(dir_entry); @@ -1441,7 +1438,7 @@ globus_l_gfs_file_delete_dir( } snprintf(path, sizeof(path), "%s/%s", pathname, dir_entry->d_name); path[MAXPATHLEN - 1] = '\0'; - + /* lstat is the same as stat when not operating on a link */ if(lstat(path, &stat_buf) != 0) { @@ -1450,11 +1447,11 @@ globus_l_gfs_file_delete_dir( /* just skip invalid entries */ continue; } - + if(!S_ISDIR(stat_buf.st_mode)) { /* remove anything that isn't a dir -- don't follow links */ - rc = unlink(path); + rc = unlink(path); if(rc != 0) { result = GlobusGFSErrorSystemError("unlink", errno); @@ -1480,23 +1477,23 @@ globus_l_gfs_file_delete_dir( result = GlobusGFSErrorSystemError("rmdir", errno); goto error_rmdir; } - } - + } + GlobusGFSFileDebugExit(); return GLOBUS_SUCCESS; error_recurse: error_unlink2: - closedir(dir); - globus_free(dir_entry); -error_open: + closedir(dir); + globus_free(dir_entry); +error_open: error_stat: error_unlink1: -error_rmdir: +error_rmdir: GlobusGFSFileDebugExitWithError(); - return result; + return result; } - + static globus_result_t globus_l_gfs_file_delete( @@ -1527,12 +1524,12 @@ globus_l_gfs_file_delete( goto error; } } - + globus_gridftp_server_finished_command(op, GLOBUS_SUCCESS, NULL); - + GlobusGFSFileDebugExit(); return GLOBUS_SUCCESS; - + error: GlobusGFSFileDebugExitWithError(); return result; @@ -1556,12 +1553,12 @@ globus_l_gfs_file_rename( result = GlobusGFSErrorSystemError("rename", errno); goto error; } - + globus_gridftp_server_finished_command(op, GLOBUS_SUCCESS, NULL); - + GlobusGFSFileDebugExit(); return GLOBUS_SUCCESS; - + error: GlobusGFSFileDebugExitWithError(); return result; @@ -1579,7 +1576,7 @@ globus_l_gfs_file_chgrp( struct group * grp_info; int grp_id; char* endpt; - + GlobusGFSName(globus_l_gfs_file_chgrp); GlobusGFSFileDebugEnter(); @@ -1587,7 +1584,7 @@ globus_l_gfs_file_chgrp( if(grp_info != NULL) { grp_id = grp_info->gr_gid; - } + } else { grp_id = strtol(group, &endpt, 10); @@ -1597,25 +1594,25 @@ globus_l_gfs_file_chgrp( goto error; } } - + if(grp_id < 0) { result = GlobusGFSErrorSystemError("chgrp", EPERM); goto error; } - + rc = chown(pathname, -1, grp_id); if(rc != 0) { result = GlobusGFSErrorSystemError("chgrp", errno); goto error; } - + globus_gridftp_server_finished_command(op, GLOBUS_SUCCESS, NULL); - + GlobusGFSFileDebugExit(); return GLOBUS_SUCCESS; - + error: GlobusGFSFileDebugExitWithError(); return result; @@ -1624,17 +1621,17 @@ globus_l_gfs_file_chgrp( #ifdef WIN32 /* utime on win32 does not work with directories. - we can work around that by opening a HANDLE with the - FILE_FLAG_BACKUP_SEMANTICS flag, getting the fd from that, and calling + we can work around that by opening a HANDLE with the + FILE_FLAG_BACKUP_SEMANTICS flag, getting the fd from that, and calling _futime on that fd. - we could call SetFileTime() with the HANDLE, but there are quirks with + we could call SetFileTime() with the HANDLE, but there are quirks with DST that result in the time returned by stat() being different than the set time depending on the date and current DST state. the perl module Win32-UTCFileTime documents that bit of fun. */ - -static BOOL + +static BOOL utime_win( const char * path, struct utimbuf * ubuf) @@ -1643,7 +1640,7 @@ utime_win( int rc; int fd; hFile = CreateFile( - path, FILE_WRITE_ATTRIBUTES, FILE_SHARE_WRITE, 0, + path, FILE_WRITE_ATTRIBUTES, FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0); if (hFile == INVALID_HANDLE_VALUE) { @@ -1676,7 +1673,7 @@ globus_l_gfs_file_utime( #ifdef WIN32 rc = utime_win(pathname, &ubuf); -#else +#else rc = utime(pathname, &ubuf); #endif if(rc != 0) @@ -1684,15 +1681,15 @@ globus_l_gfs_file_utime( result = GlobusGFSErrorSystemError("utime", errno); goto error; } - + if(op) { globus_gridftp_server_finished_command(op, GLOBUS_SUCCESS, NULL); } - + GlobusGFSFileDebugExit(); return GLOBUS_SUCCESS; - + error: GlobusGFSFileDebugExitWithError(); return result; @@ -1716,12 +1713,12 @@ globus_l_gfs_file_symlink( result = GlobusGFSErrorSystemError("symlink", errno); goto error; } - + globus_gridftp_server_finished_command(op, GLOBUS_SUCCESS, NULL); - + GlobusGFSFileDebugExit(); return GLOBUS_SUCCESS; - + error: GlobusGFSFileDebugExitWithError(); return result; @@ -1745,12 +1742,12 @@ globus_l_gfs_file_chmod( result = GlobusGFSErrorSystemError("chmod", errno); goto error; } - + globus_gridftp_server_finished_command(op, GLOBUS_SUCCESS, NULL); - + GlobusGFSFileDebugExit(); return GLOBUS_SUCCESS; - + error: GlobusGFSFileDebugExitWithError(); return result; @@ -1759,11 +1756,11 @@ globus_l_gfs_file_chmod( static void globus_l_gfs_file_cksm_read_cb( - globus_xio_handle_t handle, + globus_xio_handle_t handle, globus_result_t result, globus_byte_t * buffer, globus_size_t len, - globus_size_t nbytes, + globus_size_t nbytes, globus_xio_data_descriptor_t data_desc, void * user_arg) { @@ -1777,11 +1774,11 @@ globus_l_gfs_file_cksm_read_cb( unsigned char sha[SHA512_DIGEST_LENGTH]; char shasum[SHA512_DIGEST_LENGTH * 2 + 1] = {0}; char adler32_human[2*sizeof(uint32_t)+1]; - int i; + int i; GlobusGFSName(globus_l_gfs_file_cksm_read_cb); GlobusGFSFileDebugEnter(); - + monitor = (globus_l_gfs_file_cksm_monitor_t *) user_arg; if(result != GLOBUS_SUCCESS) @@ -1796,11 +1793,11 @@ globus_l_gfs_file_cksm_read_cb( "checksum read callback", result); goto error_read; } - } + } if(monitor->length >= 0) { monitor->read_left -= nbytes; - monitor->count = (monitor->read_left > monitor->block_size) ? + monitor->count = (monitor->read_left > monitor->block_size) ? monitor->block_size : monitor->read_left; if(monitor->read_left == 0) { @@ -1835,10 +1832,10 @@ globus_l_gfs_file_cksm_read_cb( if(monitor->send_marker) { monitor->send_marker = GLOBUS_FALSE; - + char count[128]; sprintf(count, "%"GLOBUS_OFF_T_FORMAT, monitor->total_bytes); - + globus_gridftp_server_intermediate_command( monitor->op, GLOBUS_SUCCESS, count); } @@ -1874,7 +1871,7 @@ globus_l_gfs_file_cksm_read_cb( NULL); monitor->marker_handle = GLOBUS_NULL_HANDLE; } - + globus_xio_register_close( handle, NULL, @@ -1937,22 +1934,22 @@ globus_l_gfs_file_cksm_read_cb( { globus_gridftp_server_finished_command( monitor->op, GLOBUS_SUCCESS, cksmptr); - } - + } + globus_free(monitor); - - } + + } GlobusGFSFileDebugExit(); return; - + error_register: error_read: globus_xio_register_close(handle, NULL, NULL, NULL); handle = NULL; - globus_gridftp_server_finished_command(monitor->op, result, NULL); + globus_gridftp_server_finished_command(monitor->op, result, NULL); globus_free(monitor); - + GlobusGFSFileDebugExitWithError(); } @@ -1962,7 +1959,7 @@ globus_l_gfs_file_marker_cb( void * user_arg) { globus_l_gfs_file_cksm_monitor_t * monitor; - + monitor = (globus_l_gfs_file_cksm_monitor_t *) user_arg; monitor->send_marker = GLOBUS_TRUE; } @@ -1973,20 +1970,20 @@ globus_l_gfs_file_open_cksm_cb( globus_xio_handle_t handle, globus_result_t result, void * user_arg) -{ +{ globus_l_gfs_file_cksm_monitor_t * monitor; GlobusGFSName(globus_l_gfs_file_open_cksm_cb); GlobusGFSFileDebugEnter(); - + monitor = (globus_l_gfs_file_cksm_monitor_t *) user_arg; if(result != GLOBUS_SUCCESS) { result = GlobusGFSErrorWrapFailed( "open", result); - goto error_open; - } - + goto error_open; + } + if(monitor->op) { globus_gridftp_server_get_update_interval( @@ -1997,7 +1994,7 @@ globus_l_gfs_file_open_cksm_cb( { globus_result_t res; globus_reltime_t delay; - + GlobusTimeReltimeSet(delay, monitor->marker_freq, 0); res = globus_callback_register_periodic( &monitor->marker_handle, @@ -2007,21 +2004,21 @@ globus_l_gfs_file_open_cksm_cb( monitor); if(res != GLOBUS_SUCCESS) { - + } } - + if(monitor->length >= 0) { monitor->read_left = monitor->length; - monitor->count = (monitor->read_left > monitor->block_size) ? + monitor->count = (monitor->read_left > monitor->block_size) ? monitor->block_size : monitor->read_left; } else { monitor->count = monitor->block_size; } - + if(monitor->offset > 0) { result = globus_xio_handle_cntl( @@ -2058,8 +2055,8 @@ globus_l_gfs_file_open_cksm_cb( { monitor->adler32ctx = adler32(0, NULL, 0); } - - + + result = globus_xio_register_read( handle, monitor->buffer, @@ -2077,7 +2074,7 @@ globus_l_gfs_file_open_cksm_cb( GlobusGFSFileDebugExit(); return; - + error_register: error_seek: error_open: @@ -2090,9 +2087,9 @@ globus_l_gfs_file_open_cksm_cb( else { globus_gridftp_server_finished_command(monitor->op, result, NULL); - } + } globus_free(monitor); - + GlobusGFSFileDebugExitWithError(); } @@ -2118,7 +2115,7 @@ globus_l_gfs_file_cksm( int cksm_type = 0; GlobusGFSName(globus_l_gfs_file_cksm); GlobusGFSFileDebugEnter(); - + if(offset < 0) { result = GlobusGFSErrorGeneric("Invalid offset."); @@ -2186,18 +2183,18 @@ globus_l_gfs_file_cksm( { globus_gfs_log_message( GLOBUS_GFS_LOG_WARN, - "Unable to set file access timeout of %d seconds\n", + "Unable to set file access timeout of %d seconds\n", timeout); } } - + result = globus_xio_stack_init(&stack, NULL); if(result != GLOBUS_SUCCESS) { result = GlobusGFSErrorWrapFailed("globus_xio_stack_init", result); goto error_stack; } - + result = globus_xio_stack_push_driver(stack, globus_l_gfs_file_driver); if(result != GLOBUS_SUCCESS) { @@ -2222,7 +2219,7 @@ globus_l_gfs_file_cksm( result = GlobusGFSErrorMemory("checksum buffer"); goto error_mem; } - + monitor->op = op; monitor->offset = offset; monitor->length = length; @@ -2246,7 +2243,7 @@ globus_l_gfs_file_cksm( globus_xio_attr_destroy(attr); globus_xio_stack_destroy(stack); - + GlobusGFSFileDebugExit(); return GLOBUS_SUCCESS; @@ -2254,22 +2251,22 @@ globus_l_gfs_file_cksm( globus_xio_register_close(file_handle, NULL, NULL, NULL); file_handle = NULL; globus_free(monitor); - + error_mem: error_create: error_push: globus_xio_stack_destroy(stack); - + error_stack: -error_cntl: +error_cntl: globus_xio_attr_destroy(attr); - + error_attr: alg_error: param_error: GlobusGFSFileDebugExitWithError(); return result; -} +} static void @@ -2324,15 +2321,15 @@ globus_l_gfs_file_command( break; case GLOBUS_GFS_CMD_CKSM: result = globus_l_gfs_file_cksm( - op, - cmd_info->pathname, + op, + cmd_info->pathname, cmd_info->cksm_alg, cmd_info->cksm_offset, cmd_info->cksm_length, NULL, NULL); break; - + default: result = GLOBUS_FAILURE; break; @@ -2342,12 +2339,12 @@ globus_l_gfs_file_command( { goto error; } - + GlobusGFSFileDebugExit(); return; error: - globus_gridftp_server_finished_command(op, result, NULL); + globus_gridftp_server_finished_command(op, result, NULL); GlobusGFSFileDebugExitWithError(); } @@ -2371,29 +2368,29 @@ static globus_result_t globus_l_gfs_file_dispatch_write( globus_l_file_monitor_t * monitor); - + static void globus_l_gfs_file_write_cb( - globus_xio_handle_t xio_handle, + globus_xio_handle_t xio_handle, globus_result_t result, globus_byte_t * buffer, globus_size_t len, - globus_size_t nbytes, + globus_size_t nbytes, globus_xio_data_descriptor_t data_desc, void * user_arg) { globus_l_file_monitor_t * monitor; GlobusGFSName(globus_l_gfs_file_write_cb); GlobusGFSFileDebugEnter(); - + monitor = (globus_l_file_monitor_t *) user_arg; - + globus_mutex_lock(&monitor->lock); - { + { monitor->pending_writes--; globus_gridftp_server_update_bytes_written( - monitor->op, + monitor->op, monitor->file_offset, nbytes); monitor->file_offset += nbytes; @@ -2406,7 +2403,7 @@ globus_l_gfs_file_write_cb( { goto error; } - + if(!monitor->eof) { result = globus_gridftp_server_register_read( @@ -2421,14 +2418,14 @@ globus_l_gfs_file_write_cb( "globus_gridftp_server_register_read", result); goto error; } - + monitor->pending_reads++; } else { globus_memory_push_node(&monitor->mem, buffer); } - + result = globus_l_gfs_file_dispatch_write(monitor); if(result != GLOBUS_SUCCESS) { @@ -2436,7 +2433,7 @@ globus_l_gfs_file_write_cb( "globus_l_gfs_file_dispatch_write", result); goto error_dispatch; } - + if(monitor->pending_reads == 0 && monitor->pending_writes == 0) { globus_assert(monitor->eof || monitor->aborted); @@ -2450,7 +2447,7 @@ globus_l_gfs_file_write_cb( } } /* already unlocked */ - + GlobusGFSFileDebugExit(); return; @@ -2461,7 +2458,7 @@ globus_l_gfs_file_write_cb( { /* there are still outstanding callbacks, wait for them */ globus_mutex_unlock(&monitor->lock); - + GlobusGFSFileDebugExitWithError(); return; } @@ -2482,7 +2479,7 @@ globus_l_gfs_file_dispatch_write( globus_result_t result; GlobusGFSName(globus_l_gfs_file_dispatch_write); GlobusGFSFileDebugEnter(); - + if(monitor->pending_writes == 0 && !monitor->aborted) { buf_info = (globus_l_buffer_info_t *) @@ -2490,7 +2487,7 @@ globus_l_gfs_file_dispatch_write( if(buf_info) { if(buf_info->offset != monitor->file_offset) - { + { globus_off_t seek_tmp; monitor->file_offset = buf_info->offset; @@ -2509,7 +2506,7 @@ globus_l_gfs_file_dispatch_write( goto error_seek; } } - + result = globus_xio_register_write( monitor->file_handle, buf_info->buffer, @@ -2524,13 +2521,13 @@ globus_l_gfs_file_dispatch_write( "globus_xio_register_write", result); goto error_register; } - + monitor->pending_writes++; - + globus_free(buf_info); } } - + GlobusGFSFileDebugExit(); return GLOBUS_SUCCESS; @@ -2557,7 +2554,7 @@ globus_l_gfs_file_update_concurrency( int extra; GlobusGFSName(globus_l_gfs_file_update_concurrency); GlobusGFSFileDebugEnter(); - + if(!monitor->eof) { monitor->concurrency_check = monitor->concurrency_check_interval; @@ -2566,16 +2563,16 @@ globus_l_gfs_file_update_concurrency( { monitor->concurrency_check_interval = 1024; } - + globus_gridftp_server_get_optimal_concurrency( monitor->op, &optimal_count); extra = optimal_count - monitor->optimal_count; - + monitor->optimal_count = optimal_count; while(extra-- > 0) { globus_byte_t * buffer; - + buffer = globus_memory_pop_node(&monitor->mem); result = globus_gridftp_server_register_read( monitor->op, @@ -2590,11 +2587,11 @@ globus_l_gfs_file_update_concurrency( "globus_gridftp_server_register_read", result); goto error_register; } - + monitor->pending_reads++; } } - + GlobusGFSFileDebugExit(); return; @@ -2618,9 +2615,9 @@ globus_l_gfs_file_server_read_cb( int rc; GlobusGFSName(globus_l_gfs_file_server_read_cb); GlobusGFSFileDebugEnter(); - + monitor = (globus_l_file_monitor_t *) user_arg; - + globus_mutex_lock(&monitor->lock); { monitor->pending_reads--; @@ -2632,20 +2629,20 @@ globus_l_gfs_file_server_read_cb( { goto error; } - + if(eof) { monitor->eof = GLOBUS_TRUE; } - - buf_info = (globus_l_buffer_info_t *) + + buf_info = (globus_l_buffer_info_t *) globus_malloc(sizeof(globus_l_buffer_info_t)); if(!buf_info) { monitor->error = GlobusGFSErrorObjMemory("buf_info"); goto error_alloc; } - + /* XXX offset may need some interpretation here depending on type of * transfer (may need to remember original start offset) */ @@ -2656,8 +2653,8 @@ globus_l_gfs_file_server_read_cb( if(monitor->concurrency_check == 0 && !eof) { globus_l_gfs_file_update_concurrency(monitor); - } - + } + rc = globus_priority_q_enqueue( &monitor->queue, buf_info, buf_info); if(rc != GLOBUS_SUCCESS) @@ -2677,15 +2674,15 @@ globus_l_gfs_file_server_read_cb( } globus_mutex_unlock(&monitor->lock); - + GlobusGFSFileDebugExit(); return; - + error_enqueue: error_dispatch: /* can't free buf_info, its in queue */ globus_free(buf_info); - + error_alloc: error: globus_memory_push_node(&monitor->mem, buffer); @@ -2713,7 +2710,7 @@ globus_l_gfs_file_open_write_cb( globus_l_file_monitor_t * monitor; GlobusGFSName(globus_l_gfs_file_open_write_cb); GlobusGFSFileDebugEnter(); - + monitor = (globus_l_file_monitor_t *) user_arg; if(result != GLOBUS_SUCCESS) { @@ -2725,18 +2722,18 @@ globus_l_gfs_file_open_write_cb( globus_gridftp_server_begin_transfer( monitor->op, GLOBUS_GFS_EVENT_TRANSFER_ABORT, monitor); - + globus_mutex_lock(&monitor->lock); { int optimal_count; globus_size_t block_size; - + optimal_count = monitor->optimal_count; block_size = monitor->block_size; while(optimal_count--) { globus_byte_t * buffer; - + buffer = globus_memory_pop_node(&monitor->mem); result = globus_gridftp_server_register_read( monitor->op, @@ -2751,12 +2748,12 @@ globus_l_gfs_file_open_write_cb( "globus_gridftp_server_register_read", result); goto error_register; } - + monitor->pending_reads++; } } globus_mutex_unlock(&monitor->lock); - + GlobusGFSFileDebugExit(); return; @@ -2785,7 +2782,7 @@ globus_l_gfs_file_open_read_cb( globus_xio_handle_t handle, globus_result_t result, void * user_arg); - + static globus_result_t globus_l_gfs_file_open( @@ -2804,7 +2801,7 @@ globus_l_gfs_file_open( GlobusGFSFileDebugEnter(); monitor = (globus_l_file_monitor_t *) arg; - + result = globus_xio_attr_init(&attr); if(result != GLOBUS_SUCCESS) { @@ -2816,7 +2813,7 @@ globus_l_gfs_file_open( if(globus_gfs_config_get_bool("direct_io")) { open_flags |= O_DIRECT; - } + } #endif result = globus_xio_attr_cntl( @@ -2836,9 +2833,9 @@ globus_l_gfs_file_open( if(perms != NULL) { int p = 0; - + p = strtoul(perms, NULL, 8); - if(p > 0 || + if(p > 0 || (perms[0] == '0' && perms[1] == '\0')) { result = globus_xio_attr_cntl( @@ -2879,12 +2876,12 @@ globus_l_gfs_file_open( { globus_gfs_log_message( GLOBUS_GFS_LOG_WARN, - "Unable to set file access timeout of %d seconds\n", + "Unable to set file access timeout of %d seconds\n", timeout); } } - - + + result = globus_xio_stack_init(&stack, NULL); if(result != GLOBUS_SUCCESS) { @@ -2904,13 +2901,13 @@ globus_l_gfs_file_open( result = GlobusGFSErrorWrapFailed("globus_xio_handle_create", result); goto error_create; } - + result = globus_xio_register_open( *file_handle, pathname, attr, - (open_flags & GLOBUS_XIO_FILE_CREAT) ? - globus_l_gfs_file_open_write_cb : + (open_flags & GLOBUS_XIO_FILE_CREAT) ? + globus_l_gfs_file_open_write_cb : globus_l_gfs_file_open_read_cb, arg); if(result != GLOBUS_SUCCESS) @@ -2918,11 +2915,11 @@ globus_l_gfs_file_open( result = GlobusGFSErrorWrapFailed("globus_xio_register_open", result); goto error_register; } - - + + globus_xio_attr_destroy(attr); globus_xio_stack_destroy(stack); - + GlobusGFSFileDebugExit(); return GLOBUS_SUCCESS; @@ -2932,11 +2929,11 @@ globus_l_gfs_file_open( error_create: error_push: globus_xio_stack_destroy(stack); - + error_stack: -error_cntl: +error_cntl: globus_xio_attr_destroy(attr); - + error_attr: GlobusGFSFileDebugExitWithError(); return result; @@ -2972,7 +2969,7 @@ globus_l_gfs_file_recv( goto error_alloc; } monitor->session = (gfs_l_file_session_t *) user_arg; - + globus_gridftp_server_get_write_range( op, &offset, @@ -2987,29 +2984,29 @@ globus_l_gfs_file_recv( "globus_gridftp_server_get_recv_modification_time", result); goto error_alloc; } - + monitor->op = op; monitor->pathname = globus_libc_strdup(transfer_info->pathname); - - open_flags = GLOBUS_XIO_FILE_BINARY | - GLOBUS_XIO_FILE_CREAT | + + open_flags = GLOBUS_XIO_FILE_BINARY | + GLOBUS_XIO_FILE_CREAT | GLOBUS_XIO_FILE_WRONLY; if(transfer_info->truncate) { open_flags |= GLOBUS_XIO_FILE_TRUNC; } - + if(transfer_info->expected_checksum) { - monitor->expected_cksm = + monitor->expected_cksm = globus_libc_strdup(transfer_info->expected_checksum); } if(transfer_info->expected_checksum_alg) { - monitor->expected_cksm_alg = + monitor->expected_cksm_alg = globus_libc_strdup(transfer_info->expected_checksum_alg); } - + result = globus_l_gfs_file_open( &monitor->file_handle, transfer_info->pathname, open_flags, monitor); if(result != GLOBUS_SUCCESS) @@ -3017,13 +3014,13 @@ globus_l_gfs_file_recv( result = GlobusGFSErrorWrapFailed("globus_l_gfs_file_open", result); goto error_open; } - + GlobusGFSFileDebugExit(); return; error_open: globus_l_gfs_file_monitor_destroy(monitor); - + error_alloc: globus_gridftp_server_finished_transfer(op, result); @@ -3037,14 +3034,14 @@ globus_l_gfs_file_recv( static void globus_l_gfs_file_read_cb( - globus_xio_handle_t xio_handle, + globus_xio_handle_t xio_handle, globus_result_t result, globus_byte_t * buffer, globus_size_t len, - globus_size_t nbytes, + globus_size_t nbytes, globus_xio_data_descriptor_t data_desc, void * user_arg); - + /* called LOCKED */ static globus_result_t @@ -3056,8 +3053,8 @@ globus_l_gfs_file_dispatch_read( globus_size_t read_length; GlobusGFSName(globus_l_gfs_file_dispatch_read); GlobusGFSFileDebugEnter(); - - if(monitor->first_read && monitor->pending_reads == 0 && + + if(monitor->first_read && monitor->pending_reads == 0 && !monitor->eof && !globus_list_empty(monitor->buffer_list) && !monitor->aborted) { @@ -3070,19 +3067,19 @@ globus_l_gfs_file_dispatch_read( monitor->eof = GLOBUS_TRUE; } else - { + { if (monitor->file_offset != monitor->read_offset) { globus_off_t seek_tmp; seek_tmp = monitor->read_offset; - + result = globus_xio_handle_cntl( monitor->file_handle, GLOBUS_XIO_QUERY, GLOBUS_XIO_SEEK, seek_tmp, GLOBUS_XIO_FILE_SEEK_SET); - + if(result != GLOBUS_SUCCESS) { result = GlobusGFSErrorWrapFailed( @@ -3091,19 +3088,19 @@ globus_l_gfs_file_dispatch_read( } monitor->file_offset = monitor->read_offset; } - + } monitor->first_read = GLOBUS_FALSE; - } + } - if(monitor->pending_reads == 0 && !monitor->eof && + if(monitor->pending_reads == 0 && !monitor->eof && !globus_list_empty(monitor->buffer_list) && !monitor->aborted) { buffer = globus_list_remove( &monitor->buffer_list, monitor->buffer_list); globus_assert(buffer); - - if(monitor->read_length != -1 && + + if(monitor->read_length != -1 && monitor->block_size > monitor->read_length) { read_length = monitor->read_length; @@ -3112,7 +3109,7 @@ globus_l_gfs_file_dispatch_read( { read_length = monitor->block_size; } - + result = globus_xio_register_read( monitor->file_handle, buffer, @@ -3128,10 +3125,10 @@ globus_l_gfs_file_dispatch_read( "globus_xio_register_read", result); goto error_register; } - + monitor->pending_reads++; } - + GlobusGFSFileDebugExit(); return GLOBUS_SUCCESS; @@ -3153,11 +3150,11 @@ globus_l_gfs_file_server_write_cb( globus_l_file_monitor_t * monitor; GlobusGFSName(globus_l_gfs_file_server_write_cb); GlobusGFSFileDebugEnter(); - + monitor = (globus_l_file_monitor_t *) user_arg; - + globus_mutex_lock(&monitor->lock); - { + { monitor->pending_writes--; globus_list_insert(&monitor->buffer_list, buffer); @@ -3169,7 +3166,7 @@ globus_l_gfs_file_server_write_cb( { goto error; } - + result = globus_l_gfs_file_dispatch_read(monitor); if(result != GLOBUS_SUCCESS) { @@ -3177,7 +3174,7 @@ globus_l_gfs_file_server_write_cb( "globus_l_gfs_file_dispatch_read", result); goto error; } - + if(monitor->pending_reads == 0 && monitor->pending_writes == 0) { globus_assert(monitor->eof || monitor->aborted); @@ -3190,7 +3187,7 @@ globus_l_gfs_file_server_write_cb( } } /* already unlocked */ - + GlobusGFSFileDebugExit(); return; @@ -3199,7 +3196,7 @@ globus_l_gfs_file_server_write_cb( { /* there are still outstanding callbacks, wait for them */ globus_mutex_unlock(&monitor->lock); - + GlobusGFSFileDebugExitWithError(); return; } @@ -3212,20 +3209,20 @@ globus_l_gfs_file_server_write_cb( static void globus_l_gfs_file_read_cb( - globus_xio_handle_t xio_handle, + globus_xio_handle_t xio_handle, globus_result_t result, globus_byte_t * buffer, globus_size_t len, - globus_size_t nbytes, + globus_size_t nbytes, globus_xio_data_descriptor_t data_desc, void * user_arg) { globus_l_file_monitor_t * monitor; GlobusGFSName(globus_l_gfs_file_read_cb); GlobusGFSFileDebugEnter(); - + monitor = (globus_l_file_monitor_t *) user_arg; - + globus_mutex_lock(&monitor->lock); { monitor->pending_reads--; @@ -3246,7 +3243,7 @@ globus_l_gfs_file_read_cb( globus_list_insert(&monitor->buffer_list, buffer); goto error; } - + if(nbytes > 0) { result = globus_gridftp_server_register_write( @@ -3264,7 +3261,7 @@ globus_l_gfs_file_read_cb( "globus_gridftp_server_register_write", result); goto error; } - + monitor->pending_writes++; monitor->file_offset += nbytes; if(monitor->read_length != -1) @@ -3276,12 +3273,12 @@ globus_l_gfs_file_read_cb( { globus_list_insert(&monitor->buffer_list, buffer); } - + if(monitor->read_length == 0) { monitor->first_read = GLOBUS_TRUE; } - + result = globus_l_gfs_file_dispatch_read(monitor); if(result != GLOBUS_SUCCESS) { @@ -3289,7 +3286,7 @@ globus_l_gfs_file_read_cb( "globus_l_gfs_file_dispatch_read", result); goto error; } - + if(monitor->pending_reads == 0 && monitor->pending_writes == 0) { globus_assert(monitor->eof || monitor->aborted); @@ -3312,7 +3309,7 @@ globus_l_gfs_file_read_cb( { /* there are still outstanding callbacks, wait for them */ globus_mutex_unlock(&monitor->lock); - + GlobusGFSFileDebugExitWithError(); return; } @@ -3332,7 +3329,7 @@ globus_l_gfs_file_open_read_cb( globus_l_file_monitor_t * monitor; GlobusGFSName(globus_l_gfs_file_open_read_cb); GlobusGFSFileDebugEnter(); - + monitor = (globus_l_file_monitor_t *) user_arg; if(result != GLOBUS_SUCCESS) { @@ -3341,10 +3338,10 @@ globus_l_gfs_file_open_read_cb( monitor->file_handle = NULL; goto error_open; } - + globus_gridftp_server_begin_transfer( monitor->op, GLOBUS_GFS_EVENT_TRANSFER_ABORT, monitor); - + globus_mutex_lock(&monitor->lock); monitor->first_read = GLOBUS_TRUE; result = globus_l_gfs_file_dispatch_read(monitor); @@ -3354,7 +3351,7 @@ globus_l_gfs_file_open_read_cb( "globus_l_gfs_file_dispatch_read", result); goto error_dispatch; } - + if(monitor->pending_reads == 0 && monitor->pending_writes == 0) { globus_assert(monitor->eof || monitor->aborted); @@ -3366,7 +3363,7 @@ globus_l_gfs_file_open_read_cb( { globus_mutex_unlock(&monitor->lock); } - + GlobusGFSFileDebugExit(); return; @@ -3394,11 +3391,11 @@ globus_l_gfs_file_send( globus_xio_file_flag_t open_flags; GlobusGFSName(globus_l_gfs_file_send); GlobusGFSFileDebugEnter(); - + globus_gridftp_server_get_optimal_concurrency(op, &optimal_count); globus_gridftp_server_get_block_size(op, &block_size); globus_assert(optimal_count > 0 && block_size > 0); - + result = globus_l_gfs_file_monitor_init( &monitor, block_size, optimal_count); if(result != GLOBUS_SUCCESS) @@ -3407,7 +3404,7 @@ globus_l_gfs_file_send( "globus_l_gfs_file_monitor_init", result); goto error_alloc; } - + while(optimal_count--) { globus_byte_t * buffer; @@ -3428,14 +3425,14 @@ globus_l_gfs_file_send( result = GlobusGFSErrorWrapFailed("globus_l_gfs_file_open", result); goto error_open; } - + GlobusGFSFileDebugExit(); return; error_open: globus_l_gfs_file_monitor_destroy(monitor); - -error_alloc: + +error_alloc: globus_gridftp_server_finished_transfer(op, result); GlobusGFSFileDebugExitWithError(); @@ -3450,7 +3447,7 @@ globus_l_gfs_file_event( globus_l_file_monitor_t * monitor; GlobusGFSName(globus_l_gfs_file_event); GlobusGFSFileDebugEnter(); - + monitor = (globus_l_file_monitor_t *) event_info->event_arg; switch(event_info->type) @@ -3461,18 +3458,18 @@ globus_l_gfs_file_event( monitor->aborted = GLOBUS_TRUE; } globus_mutex_unlock(&monitor->lock); - + globus_xio_handle_cancel_operations( monitor->file_handle, - GLOBUS_XIO_CANCEL_OPEN | + GLOBUS_XIO_CANCEL_OPEN | GLOBUS_XIO_CANCEL_READ | GLOBUS_XIO_CANCEL_WRITE); break; - + default: break; } - + GlobusGFSFileDebugExit(); } @@ -3540,7 +3537,7 @@ static int globus_l_gfs_file_deactivate(void); -static globus_gfs_storage_iface_t globus_l_gfs_file_dsi_iface = +static globus_gfs_storage_iface_t globus_l_gfs_file_dsi_iface = { GLOBUS_GFS_DSI_DESCRIPTOR_SENDER | GLOBUS_GFS_DSI_DESCRIPTOR_HAS_REALPATH, globus_l_gfs_file_init, @@ -3552,7 +3549,7 @@ static globus_gfs_storage_iface_t globus_l_gfs_file_dsi_iface = NULL, /* active */ NULL, /* passive */ NULL, /* data destroy */ - globus_l_gfs_file_command, + globus_l_gfs_file_command, globus_l_gfs_file_stat, NULL, NULL, @@ -3577,13 +3574,13 @@ globus_l_gfs_file_activate(void) { goto error_activate; } - + if(globus_xio_driver_load( "file", &globus_l_gfs_file_driver) != GLOBUS_SUCCESS) { goto error_load_file; } - + globus_extension_registry_add( GLOBUS_GFS_DSI_REGISTRY, "file", @@ -3592,12 +3589,12 @@ globus_l_gfs_file_activate(void) GlobusDebugInit(GLOBUS_GRIDFTP_SERVER_FILE, ERROR WARNING TRACE INTERNAL_TRACE INFO STATE INFO_VERBOSE); - + return GLOBUS_SUCCESS; - + error_load_file: globus_module_deactivate(GLOBUS_XIO_MODULE); - + error_activate: return GLOBUS_FAILURE; } @@ -3608,8 +3605,8 @@ globus_l_gfs_file_deactivate(void) { globus_extension_registry_remove( GLOBUS_GFS_DSI_REGISTRY, "file"); - + globus_xio_driver_unload(globus_l_gfs_file_driver); - + return globus_module_deactivate(GLOBUS_XIO_MODULE); } diff --git a/gridftp/server/src/modules/remote/globus_gridftp_server_remote.c b/gridftp/server/src/modules/remote/globus_gridftp_server_remote.c index 99721dda25..85d0969fac 100644 --- a/gridftp/server/src/modules/remote/globus_gridftp_server_remote.c +++ b/gridftp/server/src/modules/remote/globus_gridftp_server_remote.c @@ -22,18 +22,18 @@ GlobusDebugDeclare(GLOBUS_GRIDFTP_SERVER_REMOTE); #define BRAIN_RETRY 256 #define GlobusGFSRemoteDebugPrintf(level, message) \ - GlobusDebugPrintf(GLOBUS_GRIDFTP_SERVER_REMOTE, level, message) - + GlobusDebugPrintf(GLOBUS_GRIDFTP_SERVER_REMOTE, level, message) + #define GlobusGFSRemoteDebugEnter() \ GlobusGFSRemoteDebugPrintf( \ GLOBUS_GFS_DEBUG_TRACE, \ - ("[%s] Entering\n", _gfs_name)) - + ("[%s] Entering\n", _gfs_name)) + #define GlobusGFSRemoteDebugExit() \ GlobusGFSRemoteDebugPrintf( \ GLOBUS_GFS_DEBUG_TRACE, \ - ("[%s] Exiting\n", _gfs_name)) - + ("[%s] Exiting\n", _gfs_name)) + #define GlobusGFSRemoteDebugExitWithError() \ GlobusGFSRemoteDebugPrintf( \ GLOBUS_GFS_DEBUG_TRACE, \ @@ -71,7 +71,7 @@ typedef struct globus_l_gfs_remote_ipc_bounce_s int begin_event_pending; int event_pending; int * eof_count; - globus_l_gfs_remote_node_handle_t * node_handle; + globus_l_gfs_remote_node_handle_t * node_handle; int partial_eof_counts; globus_bool_t recv_pending; int nodes_requesting; @@ -93,7 +93,7 @@ typedef void typedef struct globus_l_gfs_remote_node_info_s { globus_gfs_ipc_handle_t ipc_handle; - globus_l_gfs_remote_node_handle_t * node_handle; + globus_l_gfs_remote_node_handle_t * node_handle; struct globus_l_gfs_remote_ipc_bounce_s * bounce; char * cs; void * data_arg; @@ -127,7 +127,7 @@ typedef enum GLOBUS_L_GFS_REMOTE_STRIPED_ONE_TO_ONE = 1, GLOBUS_L_GFS_REMOTE_STRIPED_ALL_TO_ALL } globus_l_gfs_remote_striped_mode_t; - + typedef struct globus_l_gfs_remote_control_node_bounce_s { globus_l_gfs_remote_handle_t * my_handle; @@ -156,7 +156,7 @@ do \ _op, \ _result, \ &_finished_info); \ -} while(0) +} while(0) static void @@ -176,7 +176,7 @@ globus_l_gfs_remote_node_release( { GlobusGFSName(globus_l_gfs_remote_node_release); GlobusGFSRemoteDebugEnter(); - + if(node_info->my_handle->control_node != node_info) { globus_gfs_brain_release_node( @@ -200,7 +200,7 @@ globus_l_gfs_remote_node_release( GlobusGFSRemoteDebugExit(); return GLOBUS_SUCCESS; -} +} static void @@ -233,7 +233,7 @@ globus_l_gfs_remote_node_request_kickout( globus_l_gfs_remote_node_info_t * node_info; GlobusGFSName(globus_l_gfs_remote_node_request_kickout); GlobusGFSRemoteDebugEnter(); - + node_info = (globus_l_gfs_remote_node_info_t *) user_arg; /* LOCKS! */ @@ -269,7 +269,7 @@ globus_l_gfs_remote_node_request_kickout( int cs_len = 1; globus_i_gfs_brain_node_t ** brain_node_array; globus_gfs_log_result( - GLOBUS_GFS_LOG_WARN, + GLOBUS_GFS_LOG_WARN, "could not get initially requested node, trying another", result); /* select a new set of nodes */ @@ -302,13 +302,13 @@ globus_l_gfs_remote_node_request_kickout( { callback = GLOBUS_TRUE; } - globus_free(brain_node_array); + globus_free(brain_node_array); } } } if(callback) - { + { node_info->callback( node_info, result, @@ -347,16 +347,16 @@ globus_l_gfs_remote_node_request_fake_kickout( globus_l_gfs_remote_control_node_bounce_t * bounce; GlobusGFSName(globus_l_gfs_remote_node_request_fake_kickout); GlobusGFSRemoteDebugEnter(); - + bounce = (globus_l_gfs_remote_control_node_bounce_t *) user_arg; - + bounce->callback( bounce->my_handle->control_node, GLOBUS_SUCCESS, bounce->user_arg); globus_free(bounce); - + GlobusGFSRemoteDebugExit(); } @@ -465,7 +465,7 @@ globus_l_gfs_remote_select_nodes( node_info->user_arg = user_arg; node_info->my_handle = my_handle; bounce->ndx_offset++; - + my_handle->session_info.host_id = node_info->brain_node->host_id; result = globus_gfs_ipc_handle_obtain( &my_handle->session_info, @@ -497,7 +497,7 @@ globus_l_gfs_remote_select_nodes( static -globus_result_t +globus_result_t globus_l_gfs_remote_node_request( globus_l_gfs_remote_handle_t * my_handle, int num_nodes, @@ -527,7 +527,7 @@ globus_l_gfs_remote_node_request( nodes_created = 1; ndx_offset = 1; - + result = globus_callback_register_oneshot( NULL, NULL, @@ -540,9 +540,9 @@ globus_l_gfs_remote_node_request( } } num_nodes -= nodes_created; - + if(num_nodes > 0 || nodes_created == 0) - { + { bounce = (globus_l_gfs_remote_control_node_bounce_t *) globus_calloc( 1, sizeof(globus_l_gfs_remote_control_node_bounce_t)); bounce->my_handle = my_handle; @@ -562,7 +562,7 @@ globus_l_gfs_remote_node_request( error: GlobusGFSRemoteDebugExitWithError(); return result; -} +} static void @@ -575,7 +575,7 @@ globus_l_gfs_ipc_finished_cb( globus_l_gfs_remote_ipc_bounce_t * bounce_info; GlobusGFSName(globus_l_gfs_ipc_finished_cb); GlobusGFSRemoteDebugEnter(); - + bounce_info = (globus_l_gfs_remote_ipc_bounce_t *) user_arg; globus_gridftp_server_operation_finished( @@ -609,7 +609,7 @@ globus_l_gfs_ipc_passive_cb( GlobusGFSName(globus_l_gfs_ipc_passive_cb); GlobusGFSRemoteDebugEnter(); - node_info = (globus_l_gfs_remote_node_info_t *) user_arg; + node_info = (globus_l_gfs_remote_node_info_t *) user_arg; bounce_info = node_info->bounce; my_handle = bounce_info->my_handle; @@ -618,7 +618,7 @@ globus_l_gfs_ipc_passive_cb( bounce_info->cached_result = reply->result; } else - { + { /* XXX this is suspect if we chain DSIs another step */ node_info->cs = globus_libc_strdup( reply->info.data.contact_strings[0]); @@ -633,7 +633,7 @@ globus_l_gfs_ipc_passive_cb( bounce_info->nodes_obtained++; } - /* if we got 'em all */ + /* if we got 'em all */ if(!bounce_info->nodes_pending && !bounce_info->nodes_requesting) { globus_l_gfs_remote_node_info_t ** node_array; @@ -644,10 +644,10 @@ globus_l_gfs_ipc_passive_cb( { goto error; } - + memcpy(&finished_info, reply, sizeof(globus_gfs_finished_info_t)); - finished_info.info.data.data_arg = bounce_info->node_handle; + finished_info.info.data.data_arg = bounce_info->node_handle; finished_info.info.data.cs_count = bounce_info->nodes_obtained; /* gotta do some smushin' */ @@ -659,27 +659,27 @@ globus_l_gfs_ipc_passive_cb( finished_info.info.data.cs_count); for(i = 0; i < bounce_info->node_handle->count; i++) { - node_info = (globus_l_gfs_remote_node_info_t *) + node_info = (globus_l_gfs_remote_node_info_t *) bounce_info->node_handle->nodes[i]; if(node_info != NULL) { - if(bounce_info->my_handle->striped_mode == + if(bounce_info->my_handle->striped_mode == GLOBUS_L_GFS_REMOTE_STRIPED_ONE_TO_ONE) { node_info->stripe_count = 1; } else { - node_info->stripe_count = + node_info->stripe_count = finished_info.info.data.cs_count; } /* XXX handle case where cs_count from a single node > 1 */ node_array[ndx] = node_info; - finished_info.info.data.contact_strings[ndx] = + finished_info.info.data.contact_strings[ndx] = node_info->cs; node_info->cs = NULL; - + if(node_info->info && node_info->info_needs_free) { globus_free(node_info->info); @@ -696,7 +696,7 @@ globus_l_gfs_ipc_passive_cb( } } globus_mutex_unlock(&my_handle->mutex); - + if(finished) { @@ -709,12 +709,12 @@ globus_l_gfs_ipc_passive_cb( for(ndx = 0; ndx < finished_info.info.data.cs_count; ndx++) { globus_free((void *) finished_info.info.data.contact_strings[ndx]); - } + } globus_free(finished_info.info.data.contact_strings); - + globus_free(bounce_info); } - + GlobusGFSRemoteDebugExit(); return; error: @@ -743,19 +743,19 @@ globus_l_gfs_ipc_active_cb( GlobusGFSRemoteDebugEnter(); - node_info = (globus_l_gfs_remote_node_info_t *) user_arg; + node_info = (globus_l_gfs_remote_node_info_t *) user_arg; bounce_info = node_info->bounce; node_info->data_arg = reply->info.data.data_arg; my_handle = bounce_info->my_handle; - if(bounce_info->my_handle->striped_mode == + if(bounce_info->my_handle->striped_mode == GLOBUS_L_GFS_REMOTE_STRIPED_ONE_TO_ONE) { node_info->stripe_count = 1; } else { - node_info->stripe_count = + node_info->stripe_count = ((globus_gfs_data_info_t *) bounce_info->state)->cs_count; } @@ -766,7 +766,7 @@ globus_l_gfs_ipc_active_cb( { bounce_info->nodes_obtained++; } - /* in the failure case it is just an unobtained node, if we + /* in the failure case it is just an unobtained node, if we got 0 it will be an error */ /* if this is the last one */ @@ -774,7 +774,7 @@ globus_l_gfs_ipc_active_cb( && bounce_info->nodes_requesting == 0) { finished = GLOBUS_TRUE; - + /* if we failed to get any succesfully */ if(bounce_info->nodes_obtained == 0) { @@ -801,7 +801,7 @@ globus_l_gfs_ipc_active_cb( globus_free(node_info->info); node_info->info = NULL; node_info->info_needs_free = GLOBUS_FALSE; - } + } } } } @@ -813,7 +813,7 @@ globus_l_gfs_ipc_active_cb( globus_gridftp_server_operation_finished( bounce_info->op, finished_info.result, - &finished_info); + &finished_info); globus_free(bounce_info); } @@ -849,7 +849,7 @@ globus_l_gfs_ipc_transfer_cb( node_info = (globus_l_gfs_remote_node_info_t *) user_arg; bounce_info = node_info->bounce; my_handle = bounce_info->my_handle; - + globus_mutex_lock(&my_handle->mutex); { bounce_info->nodes_pending--; @@ -857,13 +857,13 @@ globus_l_gfs_ipc_transfer_cb( { bounce_info->cached_result = reply->result; } - + /* wait for all the nodes to return, or if recving and we get an error - before the first begin_cb we quit right now */ - if((!bounce_info->nodes_pending && !bounce_info->nodes_requesting) || + before the first begin_cb we quit right now */ + if((!bounce_info->nodes_pending && !bounce_info->nodes_requesting) || (bounce_info->cached_result != GLOBUS_SUCCESS && bounce_info->recv_pending)) - { + { memset(&finished_info, '\0', sizeof(globus_gfs_finished_info_t)); finished_info.type = reply->type; finished_info.id = reply->id; @@ -872,15 +872,15 @@ globus_l_gfs_ipc_transfer_cb( finished_info.result = bounce_info->cached_result; finish = GLOBUS_TRUE; op = bounce_info->op; - + if(!bounce_info->events_enabled) { globus_l_gfs_remote_node_info_t * node_info; - + for(i = 0; i < bounce_info->node_handle->count; i++) { node_info = bounce_info->node_handle->nodes[i]; - + if(node_info->info && node_info->info_needs_free) { globus_free(node_info->info); @@ -893,17 +893,17 @@ globus_l_gfs_ipc_transfer_cb( globus_free(bounce_info->eof_count); } globus_free(bounce_info); - } + } } } globus_mutex_unlock(&my_handle->mutex); - + if(finish) { globus_gridftp_server_operation_finished( op, finished_info.result, - &finished_info); + &finished_info); } GlobusGFSRemoteDebugExit(); @@ -926,12 +926,11 @@ globus_l_gfs_ipc_event_cb( globus_l_gfs_remote_node_info_t * node_info; globus_gfs_transfer_info_t * info; globus_gfs_event_info_t event_info; - globus_result_t result; int ctr; GlobusGFSName(globus_l_gfs_ipc_event_cb); GlobusGFSRemoteDebugEnter(); - - node_info = (globus_l_gfs_remote_node_info_t *) user_arg; + + node_info = (globus_l_gfs_remote_node_info_t *) user_arg; bounce_info = node_info->bounce; my_handle = bounce_info->my_handle; @@ -954,12 +953,12 @@ globus_l_gfs_ipc_event_cb( { bounce_info->events_enabled = GLOBUS_TRUE; reply->event_arg = bounce_info; - reply->event_mask = - GLOBUS_GFS_EVENT_TRANSFER_ABORT | + reply->event_mask = + GLOBUS_GFS_EVENT_TRANSFER_ABORT | GLOBUS_GFS_EVENT_TRANSFER_COMPLETE | GLOBUS_GFS_EVENT_BYTES_RECVD | GLOBUS_GFS_EVENT_RANGES_RECVD; - + globus_gridftp_server_operation_event( bounce_info->op, GLOBUS_SUCCESS, @@ -969,7 +968,7 @@ globus_l_gfs_ipc_event_cb( break; case GLOBUS_GFS_EVENT_TRANSFER_CONNECTED: bounce_info->event_pending--; - if(!bounce_info->event_pending && + if(!bounce_info->event_pending && !bounce_info->recv_pending && !bounce_info->nodes_requesting) { @@ -982,7 +981,7 @@ globus_l_gfs_ipc_event_cb( { node_info = bounce_info->node_handle->nodes[i]; info = (globus_gfs_transfer_info_t *) node_info->info; - + if(node_info->ipc_handle == ipc_handle) { globus_assert( @@ -996,11 +995,11 @@ globus_l_gfs_ipc_event_cb( } } for(ctr = 0; ctr < reply->node_count; ctr++) - { + { bounce_info->eof_count[ctr] += reply->eof_count[ctr]; } bounce_info->partial_eof_counts++; - if(bounce_info->partial_eof_counts + 1 == + if(bounce_info->partial_eof_counts + 1 == bounce_info->node_count && !bounce_info->finished) { memset(&event_info, '\0', sizeof(globus_gfs_event_info_t)); @@ -1008,14 +1007,14 @@ globus_l_gfs_ipc_event_cb( event_info.event_arg = master_node->event_arg; event_info.eof_count = bounce_info->eof_count; event_info.node_count = bounce_info->partial_eof_counts + 1; - result = globus_gfs_ipc_request_transfer_event( + globus_gfs_ipc_request_transfer_event( master_node->ipc_handle, &event_info); bounce_info->final_eof++; - } + } break; default: - if(!bounce_info->event_pending || + if(!bounce_info->event_pending || reply->type == GLOBUS_GFS_EVENT_BYTES_RECVD || reply->type == GLOBUS_GFS_EVENT_RANGES_RECVD) { @@ -1027,14 +1026,14 @@ globus_l_gfs_ipc_event_cb( globus_mutex_unlock(&my_handle->mutex); if(finish) - { + { reply->event_arg = bounce_info; globus_gridftp_server_operation_event( bounce_info->op, GLOBUS_SUCCESS, reply); } - + GlobusGFSRemoteDebugExit(); } @@ -1050,7 +1049,7 @@ globus_l_gfs_remote_init_bounce_info( globus_result_t result; GlobusGFSName(globus_l_gfs_remote_init_bounce_info); GlobusGFSRemoteDebugEnter(); - + bounce_info = (globus_l_gfs_remote_ipc_bounce_t *) globus_calloc(1, sizeof(globus_l_gfs_remote_ipc_bounce_t)); if(!bounce_info) @@ -1058,12 +1057,12 @@ globus_l_gfs_remote_init_bounce_info( result = GlobusGFSErrorMemory("bounce_info"); goto error_alloc; } - + bounce_info->op = op; bounce_info->state = state; bounce_info->my_handle = my_handle; *bounce = bounce_info; - + GlobusGFSRemoteDebugExit(); return GLOBUS_SUCCESS; @@ -1084,9 +1083,9 @@ globus_l_gfs_remote_stat( globus_l_gfs_remote_handle_t * my_handle; GlobusGFSName(globus_l_gfs_remote_stat); GlobusGFSRemoteDebugEnter(); - + my_handle = (globus_l_gfs_remote_handle_t *) user_arg; - + result = globus_l_gfs_remote_init_bounce_info( &bounce_info, op, stat_info, my_handle); @@ -1119,7 +1118,7 @@ globus_l_gfs_remote_command( GlobusGFSRemoteDebugEnter(); my_handle = (globus_l_gfs_remote_handle_t *) user_arg; - + result = globus_l_gfs_remote_init_bounce_info( &bounce_info, op, command_info, my_handle); @@ -1151,20 +1150,20 @@ globus_l_gfs_remote_list( globus_l_gfs_remote_node_info_t * node_info; GlobusGFSName(globus_l_gfs_remote_list); GlobusGFSRemoteDebugEnter(); - + my_handle = (globus_l_gfs_remote_handle_t *) user_arg; - /* XXX it appears no lock is needed here */ + /* XXX it appears no lock is needed here */ result = globus_l_gfs_remote_init_bounce_info( &bounce_info, op, transfer_info, my_handle); - globus_free(bounce_info->node_handle); - - bounce_info->node_handle = (globus_l_gfs_remote_node_handle_t *) + globus_free(bounce_info->node_handle); + + bounce_info->node_handle = (globus_l_gfs_remote_node_handle_t *) transfer_info->data_arg; bounce_info->node_handle->destroy++; - + node_info = bounce_info->node_handle->nodes[0]; - + transfer_info->data_arg = node_info->data_arg; transfer_info->stripe_count = 1; transfer_info->node_ndx = 0; @@ -1176,13 +1175,13 @@ globus_l_gfs_remote_list( node_info->info = NULL; node_info->info_needs_free = GLOBUS_FALSE; node_info->bounce = bounce_info; - + result = globus_gfs_ipc_request_list( node_info->ipc_handle, transfer_info, globus_l_gfs_ipc_transfer_cb, globus_l_gfs_ipc_event_cb, - node_info); + node_info); if(result != GLOBUS_SUCCESS) { GlobusGFSErrorOpFinished( @@ -1207,21 +1206,21 @@ globus_l_gfs_remote_recv_next( int ndx = 1; GlobusGFSName(globus_l_gfs_remote_recv_next); GlobusGFSRemoteDebugEnter(); - + /* already sent recv to node 0, now send the rest */ transfer_info = (globus_gfs_transfer_info_t *) bounce_info->state; - + node_count = bounce_info->node_handle->count; - + for(i = 1; i < bounce_info->node_handle->count; i++) { node_info = bounce_info->node_handle->nodes[i]; - + new_transfer_info = (globus_gfs_transfer_info_t *) globus_calloc(1, sizeof(globus_gfs_transfer_info_t)); - memcpy(new_transfer_info, transfer_info, + memcpy(new_transfer_info, transfer_info, sizeof(globus_gfs_transfer_info_t)); - + new_transfer_info->truncate = GLOBUS_FALSE; new_transfer_info->data_arg = node_info->data_arg; new_transfer_info->node_count = node_count; @@ -1238,7 +1237,7 @@ globus_l_gfs_remote_recv_next( new_transfer_info, globus_l_gfs_ipc_transfer_cb, globus_l_gfs_ipc_event_cb, - node_info); + node_info); if(result != GLOBUS_SUCCESS) { if(bounce_info->nodes_pending > 0) @@ -1256,7 +1255,7 @@ globus_l_gfs_remote_recv_next( bounce_info->event_pending++; bounce_info->begin_event_pending++; } - + bounce_info->recv_pending = GLOBUS_FALSE; GlobusGFSRemoteDebugExit(); @@ -1280,23 +1279,23 @@ globus_l_gfs_remote_recv( int node_count; GlobusGFSName(globus_l_gfs_remote_recv); GlobusGFSRemoteDebugEnter(); - + my_handle = (globus_l_gfs_remote_handle_t *) user_arg; globus_mutex_lock(&my_handle->mutex); { result = globus_l_gfs_remote_init_bounce_info( &bounce_info, op, transfer_info, my_handle); - - bounce_info->node_handle = (globus_l_gfs_remote_node_handle_t *) + + bounce_info->node_handle = (globus_l_gfs_remote_node_handle_t *) transfer_info->data_arg; /* only going to do the first recv request here, the others - will be sent after this one responds with the begin event - - we need to do this primarily to make sure the file is opened + will be sent after this one responds with the begin event + + we need to do this primarily to make sure the file is opened in TRUNC mode only the first time */ - + bounce_info->node_handle->destroy++; node_count = bounce_info->node_handle->count; if(node_count > 1) @@ -1305,9 +1304,9 @@ globus_l_gfs_remote_recv( } bounce_info->nodes_requesting = node_count; bounce_info->node_count = node_count; - + node_info = bounce_info->node_handle->nodes[0]; - + new_transfer_info = (globus_gfs_transfer_info_t *) globus_calloc(1, sizeof(globus_gfs_transfer_info_t)); memcpy(new_transfer_info,transfer_info, @@ -1326,14 +1325,14 @@ globus_l_gfs_remote_recv( new_transfer_info, globus_l_gfs_ipc_transfer_cb, globus_l_gfs_ipc_event_cb, - node_info); + node_info); if(result != GLOBUS_SUCCESS) { goto error; } /* could maybe get away with no lock if we moved the next few lines - above the request. we would have to then assume that the - values were meaningless under error. This way is more + above the request. we would have to then assume that the + values were meaningless under error. This way is more consistant and the lock is not very costly */ bounce_info->nodes_pending++; bounce_info->event_pending++; @@ -1368,21 +1367,21 @@ globus_l_gfs_remote_send( int i; GlobusGFSName(globus_l_gfs_remote_send); GlobusGFSRemoteDebugEnter(); - + my_handle = (globus_l_gfs_remote_handle_t *) user_arg; globus_mutex_lock(&my_handle->mutex); { result = globus_l_gfs_remote_init_bounce_info( &bounce_info, op, transfer_info, my_handle); - + bounce_info->node_handle = (globus_l_gfs_remote_node_handle_t *) transfer_info->data_arg; bounce_info->node_handle->destroy++; node_count = bounce_info->node_handle->count; - bounce_info->eof_count = (int *) + bounce_info->eof_count = (int *) globus_calloc(1, node_count * sizeof(int) + 1); bounce_info->nodes_requesting = node_count; @@ -1391,12 +1390,12 @@ globus_l_gfs_remote_send( for(i = 0; i < bounce_info->node_handle->count; i++) { node_info = bounce_info->node_handle->nodes[i]; - + new_transfer_info = (globus_gfs_transfer_info_t *) globus_calloc(1, sizeof(globus_gfs_transfer_info_t)); memcpy(new_transfer_info, transfer_info, sizeof(globus_gfs_transfer_info_t)); - + new_transfer_info->data_arg = node_info->data_arg; new_transfer_info->node_count = node_count; new_transfer_info->stripe_count = node_info->stripe_count; @@ -1404,17 +1403,17 @@ globus_l_gfs_remote_send( node_info->info = new_transfer_info; node_info->info_needs_free = GLOBUS_TRUE; node_info->bounce = bounce_info; - + bounce_info->nodes_pending++; bounce_info->event_pending++; bounce_info->begin_event_pending++; - + result = globus_gfs_ipc_request_send( node_info->ipc_handle, new_transfer_info, globus_l_gfs_ipc_transfer_cb, globus_l_gfs_ipc_event_cb, - node_info); + node_info); if(result != GLOBUS_SUCCESS) { /* if some callbacks are pending we need to wait for the @@ -1473,17 +1472,17 @@ globus_l_gfs_remote_active_kickout( new_data_info = (globus_gfs_data_info_t *) globus_calloc(1, sizeof(globus_gfs_data_info_t)); - + memcpy( new_data_info, bounce_info->state, sizeof(globus_gfs_data_info_t)); - if(bounce_info->my_handle->striped_mode == + if(bounce_info->my_handle->striped_mode == GLOBUS_L_GFS_REMOTE_STRIPED_ONE_TO_ONE) { new_data_info->cs_count = 1; - new_data_info->contact_strings = + new_data_info->contact_strings = (const char **) calloc(1, sizeof(char *)); - new_data_info->contact_strings[0] = + new_data_info->contact_strings[0] = globus_libc_strdup( data_info->contact_strings[bounce_info->node_ndx]); } @@ -1494,7 +1493,7 @@ globus_l_gfs_remote_active_kickout( node_info->ipc_handle, new_data_info, globus_l_gfs_ipc_active_cb, - node_info); + node_info); if(result != GLOBUS_SUCCESS) { goto error; @@ -1540,14 +1539,14 @@ globus_l_gfs_remote_active( int num_nodes; GlobusGFSName(globus_l_gfs_remote_active); GlobusGFSRemoteDebugEnter(); - + my_handle = (globus_l_gfs_remote_handle_t *) user_arg; globus_mutex_lock(&my_handle->mutex); - { + { result = globus_l_gfs_remote_init_bounce_info( &bounce_info, op, data_info, my_handle); - + num_nodes = data_info->cs_count; bounce_info->node_handle = (globus_l_gfs_remote_node_handle_t *) @@ -1563,7 +1562,7 @@ globus_l_gfs_remote_active( num_nodes, NULL, globus_l_gfs_remote_active_kickout, - bounce_info); + bounce_info); if(result != GLOBUS_SUCCESS) { goto error; @@ -1592,12 +1591,12 @@ globus_l_gfs_remote_passive_kickout( globus_l_gfs_remote_ipc_bounce_t * bounce_info; GlobusGFSName(globus_l_gfs_remote_passive_kickout); GlobusGFSRemoteDebugEnter(); - + bounce_info = (globus_l_gfs_remote_ipc_bounce_t *) user_arg; my_handle = (globus_l_gfs_remote_handle_t *) bounce_info->my_handle; globus_mutex_lock(&my_handle->mutex); - { + { bounce_info->nodes_requesting--; if(result != GLOBUS_SUCCESS) { @@ -1651,9 +1650,9 @@ globus_l_gfs_remote_passive( int num_nodes; GlobusGFSName(globus_l_gfs_remote_passive); GlobusGFSRemoteDebugEnter(); - + my_handle = (globus_l_gfs_remote_handle_t *) user_arg; - + result = globus_l_gfs_remote_init_bounce_info( &bounce_info, op, data_info, my_handle); @@ -1677,7 +1676,7 @@ globus_l_gfs_remote_passive( bounce_info->nodes_requesting, NULL, globus_l_gfs_remote_passive_kickout, - bounce_info); + bounce_info); if(result != GLOBUS_SUCCESS) { goto error; @@ -1713,24 +1712,24 @@ globus_l_gfs_remote_data_destroy( globus_l_gfs_remote_node_handle_t * node_handle; GlobusGFSName(globus_l_gfs_remote_data_destroy); GlobusGFSRemoteDebugEnter(); - + my_handle = (globus_l_gfs_remote_handle_t *) user_arg; node_handle = (globus_l_gfs_remote_node_handle_t *) data_arg; globus_mutex_lock(&my_handle->mutex); - { + { for(i = 0; i < node_handle->count; i++) { node_info = (globus_l_gfs_remote_node_info_t *) node_handle->nodes[i]; - + result = globus_gfs_ipc_request_data_destroy( node_info->ipc_handle, - node_info->data_arg); + node_info->data_arg); if(result != GLOBUS_SUCCESS) { globus_gfs_log_result( - GLOBUS_GFS_LOG_ERR, + GLOBUS_GFS_LOG_ERR, "IPC ERROR: remote_data_destroy: ipc call", result); } if(node_info->cs != NULL) @@ -1761,7 +1760,7 @@ globus_l_gfs_remote_data_destroy( { globus_free(node_handle->nodes); globus_free(node_handle); - } + } GlobusGFSRemoteDebugExit(); } @@ -1774,7 +1773,6 @@ globus_l_gfs_remote_trev( { globus_bool_t free_node = GLOBUS_FALSE; int i; - globus_result_t result; globus_l_gfs_remote_handle_t * my_handle; globus_l_gfs_remote_node_info_t * node_info; globus_gfs_event_info_t new_event_info; @@ -1782,11 +1780,11 @@ globus_l_gfs_remote_trev( globus_l_gfs_remote_node_handle_t * free_nh = NULL; GlobusGFSName(globus_l_gfs_remote_trev); GlobusGFSRemoteDebugEnter(); - + bounce_info = (globus_l_gfs_remote_ipc_bounce_t *) event_info->event_arg; - + my_handle = (globus_l_gfs_remote_handle_t *) user_arg; - + memset(&new_event_info, '\0', sizeof(globus_gfs_event_info_t)); new_event_info.type = event_info->type; @@ -1795,13 +1793,13 @@ globus_l_gfs_remote_trev( node_info = bounce_info->node_handle->nodes[i]; new_event_info.event_arg = node_info->event_arg; - result = globus_gfs_ipc_request_transfer_event( + globus_gfs_ipc_request_transfer_event( node_info->ipc_handle, &new_event_info); } - + globus_mutex_lock(&my_handle->mutex); - { + { if(event_info->type == GLOBUS_GFS_EVENT_TRANSFER_COMPLETE) { for(i = 0; i < bounce_info->node_handle->count; i++) @@ -1848,7 +1846,7 @@ globus_l_gfs_remote_session_start_kickout( void * user_arg) { globus_l_gfs_remote_handle_t * my_handle; - globus_gfs_finished_info_t finished_info; + globus_gfs_finished_info_t finished_info; GlobusGFSName(globus_l_gfs_remote_session_start_kickout); GlobusGFSRemoteDebugEnter(); @@ -1856,40 +1854,40 @@ globus_l_gfs_remote_session_start_kickout( with this handle until we signal it has started */ my_handle = (globus_l_gfs_remote_handle_t *) user_arg; - + if(result != GLOBUS_SUCCESS) { goto error; } memset(&finished_info, '\0', sizeof(globus_gfs_finished_info_t)); - finished_info.type = GLOBUS_GFS_OP_SESSION_START; - finished_info.result = result; + finished_info.type = GLOBUS_GFS_OP_SESSION_START; + finished_info.result = result; finished_info.info.session.session_arg = my_handle; - finished_info.info.session.username = node_info->username; - finished_info.info.session.home_dir = node_info->home_dir; + finished_info.info.session.username = node_info->username; + finished_info.info.session.home_dir = node_info->home_dir; my_handle->control_node = node_info; - globus_gridftp_server_operation_finished( - my_handle->op, - result, + globus_gridftp_server_operation_finished( + my_handle->op, + result, &finished_info); GlobusGFSRemoteDebugExit(); return; - -error: + +error: memset(&finished_info, '\0', sizeof(globus_gfs_finished_info_t)); finished_info.type = GLOBUS_GFS_OP_SESSION_START; finished_info.result = result; - globus_gridftp_server_operation_finished( - my_handle->op, - finished_info.result, + globus_gridftp_server_operation_finished( + my_handle->op, + finished_info.result, &finished_info); - + GlobusGFSRemoteDebugExitWithError(); -} +} static void @@ -1902,8 +1900,8 @@ globus_l_gfs_remote_session_start( int nodes_requesting = 1; GlobusGFSName(globus_l_gfs_remote_session_start); GlobusGFSRemoteDebugEnter(); - - my_handle = (globus_l_gfs_remote_handle_t *) + + my_handle = (globus_l_gfs_remote_handle_t *) globus_calloc(1, sizeof(globus_l_gfs_remote_handle_t)); globus_mutex_init(&my_handle->mutex, NULL); my_handle->ipc_release_reason = GLOBUS_GFS_BRAIN_REASON_COMPLETE; @@ -1935,7 +1933,7 @@ globus_l_gfs_remote_session_start( { GlobusGFSErrorOpFinished(op, GLOBUS_GFS_OP_SESSION_START, result); } - + GlobusGFSRemoteDebugExit(); } @@ -1952,7 +1950,7 @@ globus_l_gfs_remote_session_end( GlobusGFSRemoteDebugEnter(); my_handle = (globus_l_gfs_remote_handle_t *) user_arg; - + if(my_handle == NULL) { goto error; @@ -1965,10 +1963,10 @@ globus_l_gfs_remote_session_end( if(result != GLOBUS_SUCCESS) { globus_gfs_log_result( - GLOBUS_GFS_LOG_ERR, + GLOBUS_GFS_LOG_ERR, "ERROR: remote_data_destroy: handle_release", result); } - + if(my_handle->session_info.username != NULL) { globus_free(my_handle->session_info.username); @@ -1983,10 +1981,10 @@ globus_l_gfs_remote_session_end( } globus_mutex_destroy(&my_handle->mutex); globus_free(my_handle); - + GlobusGFSRemoteDebugExit(); return; - + error: GlobusGFSRemoteDebugExitWithError(); } @@ -1999,7 +1997,7 @@ static int globus_l_gfs_remote_deactivate(void); -static globus_gfs_storage_iface_t globus_l_gfs_remote_dsi_iface = +static globus_gfs_storage_iface_t globus_l_gfs_remote_dsi_iface = { 0, globus_l_gfs_remote_session_start, @@ -2011,7 +2009,7 @@ static globus_gfs_storage_iface_t globus_l_gfs_remote_dsi_iface = globus_l_gfs_remote_active, globus_l_gfs_remote_passive, globus_l_gfs_remote_data_destroy, - globus_l_gfs_remote_command, + globus_l_gfs_remote_command, globus_l_gfs_remote_stat, NULL, NULL @@ -2033,13 +2031,13 @@ globus_l_gfs_remote_activate(void) { int rc; GlobusGFSName(globus_l_gfs_remote_activate); - + rc = globus_module_activate(GLOBUS_COMMON_MODULE); if(rc != GLOBUS_SUCCESS) { goto error; } - + globus_extension_registry_add( GLOBUS_GFS_DSI_REGISTRY, "remote", @@ -2048,7 +2046,7 @@ globus_l_gfs_remote_activate(void) GlobusDebugInit(GLOBUS_GRIDFTP_SERVER_REMOTE, ERROR WARNING TRACE INTERNAL_TRACE INFO STATE INFO_VERBOSE); - + return GLOBUS_SUCCESS; error: @@ -2060,11 +2058,11 @@ int globus_l_gfs_remote_deactivate(void) { GlobusGFSName(globus_l_gfs_remote_deactivate); - + globus_extension_registry_remove( GLOBUS_GFS_DSI_REGISTRY, "remote"); - + globus_module_deactivate(GLOBUS_COMMON_MODULE); - + return GLOBUS_SUCCESS; } diff --git a/gsi/callback/source/configure.ac b/gsi/callback/source/configure.ac index e802c673e1..90ce6bfa14 100644 --- a/gsi/callback/source/configure.ac +++ b/gsi/callback/source/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ([2.60]) -AC_INIT([globus_gsi_callback], [6.2],[https://github.com/gridcf/gct/issues]) +AC_INIT([globus_gsi_callback], [6.3],[https://github.com/gridcf/gct/issues]) AC_CONFIG_MACRO_DIR([m4]) AC_SUBST([MAJOR_VERSION], [${PACKAGE_VERSION%%.*}]) AC_SUBST([MINOR_VERSION], [${PACKAGE_VERSION##*.}]) diff --git a/gsi/callback/source/library/globus_gsi_callback.c b/gsi/callback/source/library/globus_gsi_callback.c index ef03f93400..3178d5ce49 100644 --- a/gsi/callback/source/library/globus_gsi_callback.c +++ b/gsi/callback/source/library/globus_gsi_callback.c @@ -89,11 +89,11 @@ static int globus_i_gsi_callback_X509_STORE_callback_data_index = -1; static int globus_l_gsi_callback_openssl_new( - void * parent, - void * ptr, + void * parent, + void * ptr, CRYPTO_EX_DATA * ad, - int idx, - long argl, + int idx, + long argl, void * argp) { int result = 1; @@ -105,18 +105,18 @@ globus_l_gsi_callback_openssl_new( * since we can't allocate the ptr here * this function isn't particularly useful */ - + GLOBUS_I_GSI_CALLBACK_DEBUG_EXIT; return result; } static int globus_l_gsi_callback_openssl_free( - void * parent, - void * ptr, + void * parent, + void * ptr, CRYPTO_EX_DATA * ad, - int idx, - long argl, + int idx, + long argl, void * argp) { int result = 1; @@ -133,17 +133,17 @@ globus_l_gsi_callback_openssl_free( static int globus_l_gsi_callback_openssl_dup( - CRYPTO_EX_DATA * to, - CRYPTO_EX_DATA * from, - void * from_d, - int idx, - long argl, + CRYPTO_EX_DATA * to, + CRYPTO_EX_DATA * from, + void * from_d, + int idx, + long argl, void * argp) { int result = 1; static char * _function_name_ = "globus_gsi_callback_openssl_dup"; - + GLOBUS_I_GSI_CALLBACK_DEBUG_ENTER; /* copy the callback data - currenlty not used by OpenSSL */ @@ -168,7 +168,7 @@ globus_l_gsi_callback_activate(void) if(tmp_string != GLOBUS_NULL) { globus_i_gsi_callback_debug_level = atoi(tmp_string); - + if(globus_i_gsi_callback_debug_level < 0) { globus_i_gsi_callback_debug_level = 0; @@ -198,7 +198,7 @@ globus_l_gsi_callback_activate(void) { goto exit; } - + result = globus_module_activate(GLOBUS_GSI_SYSCONFIG_MODULE); if(result != GLOBUS_SUCCESS) @@ -215,14 +215,14 @@ globus_l_gsi_callback_activate(void) globus_mutex_init(&globus_l_gsi_callback_oldgaa_mutex, NULL); globus_mutex_init(&globus_l_gsi_callback_verify_mutex, NULL); - + OpenSSL_add_all_algorithms(); if(globus_i_gsi_callback_X509_STORE_callback_data_index < 0) { - globus_i_gsi_callback_X509_STORE_callback_data_index = + globus_i_gsi_callback_X509_STORE_callback_data_index = X509_STORE_CTX_get_ex_new_index( - 0, NULL, + 0, NULL, (CRYPTO_EX_new *) &globus_l_gsi_callback_openssl_new, (CRYPTO_EX_dup *) &globus_l_gsi_callback_openssl_dup, (CRYPTO_EX_free *) &globus_l_gsi_callback_openssl_free); @@ -239,7 +239,7 @@ globus_l_gsi_callback_activate(void) if(globus_i_gsi_callback_SSL_callback_data_index < 0) { globus_i_gsi_callback_SSL_callback_data_index = SSL_get_ex_new_index( - 0, NULL, + 0, NULL, (CRYPTO_EX_new *) &globus_l_gsi_callback_openssl_new, (CRYPTO_EX_dup *) &globus_l_gsi_callback_openssl_dup, (CRYPTO_EX_free *) &globus_l_gsi_callback_openssl_free); @@ -304,7 +304,7 @@ globus_l_gsi_callback_deactivate(void) * Will contain the index upon return * * @return - * GLOBUS_SUCCESS unless an error occurred, in which case, + * GLOBUS_SUCCESS unless an error occurred, in which case, * a globus error object ID is returned */ globus_result_t @@ -314,7 +314,7 @@ globus_gsi_callback_get_X509_STORE_callback_data_index( globus_result_t result = GLOBUS_SUCCESS; static char * _function_name_ = "globus_gsi_callback_get_X509_STORE_callback_data_index"; - + GLOBUS_I_GSI_CALLBACK_DEBUG_ENTER; *index = globus_i_gsi_callback_X509_STORE_callback_data_index; @@ -334,7 +334,7 @@ globus_gsi_callback_get_X509_STORE_callback_data_index( * Will contain the index upon return * * @return - * GLOBUS_SUCCESS unless an error occurred, in which case, + * GLOBUS_SUCCESS unless an error occurred, in which case, * a globus error object ID is returned */ globus_result_t @@ -344,9 +344,9 @@ globus_gsi_callback_get_SSL_callback_data_index( globus_result_t result = GLOBUS_SUCCESS; static char * _function_name_ = "globus_gsi_callback_get_SSL_callback_data_index"; - + GLOBUS_I_GSI_CALLBACK_DEBUG_ENTER; - + *index = globus_i_gsi_callback_SSL_callback_data_index; @@ -370,7 +370,7 @@ globus_gsi_callback_get_SSL_callback_data_index( * 1 on success * 0 on failure */ -int +int globus_gsi_callback_X509_verify_cert( X509_STORE_CTX * context, void * arg) @@ -391,15 +391,15 @@ globus_gsi_callback_X509_verify_cert( X509_STORE_set_check_issued(X509_STORE_CTX_get0_store(context), globus_gsi_callback_check_issued); #endif /* - * If this is not set, OpenSSL-0.9.8 assumes the proxy cert + * If this is not set, OpenSSL-0.9.8 assumes the proxy cert * as an EEC and the next level cert in the chain as a CA cert * and throws an invalid CA error. If we set this, the callback - * (globus_gsi_callback_handshake_callback) gets called with - * preverify_ok = 0 with an error "unhandled critical extension" + * (globus_gsi_callback_handshake_callback) gets called with + * preverify_ok = 0 with an error "unhandled critical extension" * and "path length exceeded". - * globus_i_gsi_callback_cred_verify() called by - * globus_gsi_callback_handshake_callback() checks for these - * errors and returns success. globus_i_gsi_callback_cred_verify() + * globus_i_gsi_callback_cred_verify() called by + * globus_gsi_callback_handshake_callback() checks for these + * errors and returns success. globus_i_gsi_callback_cred_verify() * will check the critical extension later. */ #if defined(X509_V_FLAG_ALLOW_PROXY_CERTS) @@ -423,12 +423,12 @@ globus_gsi_callback_X509_verify_cert( * * @param preverify_ok * Communicates the result of default validation steps performed by - * OpenSSL + * OpenSSL * @param x509_context * The validation state object * @return * 1 on success - * 0 on failure + * 0 on failure */ int globus_gsi_callback_create_proxy_callback( int preverify_ok, @@ -438,7 +438,7 @@ int globus_gsi_callback_create_proxy_callback( int verify_result; globus_result_t result; globus_gsi_callback_data_t callback_data; - static char * _function_name_ = + static char * _function_name_ = "globus_i_gsi_callback_create_proxy_callback"; GLOBUS_I_GSI_CALLBACK_DEBUG_ENTER; @@ -449,10 +449,10 @@ int globus_gsi_callback_create_proxy_callback( verify_result = 0; goto exit; } - + callback_data = (globus_gsi_callback_data_t) X509_STORE_CTX_get_ex_data( - x509_context, + x509_context, cb_index); if(!callback_data) @@ -498,12 +498,12 @@ int globus_gsi_callback_create_proxy_callback( * * @param preverify_ok * Communicates the result of default validation steps performed by - * OpenSSL + * OpenSSL * @param x509_context * The validation state object. * @return * 1 on success - * 0 on failure + * 0 on failure */ int globus_gsi_callback_handshake_callback( int preverify_ok, @@ -514,7 +514,7 @@ int globus_gsi_callback_handshake_callback( globus_result_t result; globus_gsi_callback_data_t callback_data; SSL * ssl = NULL; - static char * _function_name_ = + static char * _function_name_ = "globus_gsi_callback_handshake_callback"; GLOBUS_I_GSI_CALLBACK_DEBUG_ENTER; @@ -567,7 +567,7 @@ int globus_gsi_callback_handshake_callback( callback_data->error = result; - exit: + exit: GLOBUS_I_GSI_CALLBACK_DEBUG_EXIT; return verify_result; } @@ -585,15 +585,22 @@ int globus_gsi_callback_handshake_callback( * @param cert * The certificate to check * @param issuer - * The issuer certificate to check + * The issuer certificate to check * @return * 1 on success - * 0 on failure + * 0 on failure */ +#if OPENSSL_VERSION_NUMBER < 0x40000000L int globus_gsi_callback_check_issued( X509_STORE_CTX * context, X509 * cert, X509 * issuer) +#else +int globus_gsi_callback_check_issued( + X509_STORE_CTX * context, + const X509 * cert, + const X509 * issuer) +#endif { globus_result_t result; int return_value; @@ -601,21 +608,21 @@ int globus_gsi_callback_check_issued( globus_gsi_cert_utils_cert_type_t cert_type; static char * _function_name_ = "globus_gsi_callback_check_issued"; - + GLOBUS_I_GSI_CALLBACK_DEBUG_ENTER; - + return_value = X509_check_issued(issuer, cert); if(return_value != X509_V_OK) { return_code = 0; switch(return_value) { - + case X509_V_ERR_KEYUSAGE_NO_CERTSIGN: /* If this is a proxy certificate then the issuer * does not need to have the key_usage set. * So check if its a proxy, and ignore - * the error if so. + * the error if so. */ result = globus_gsi_cert_utils_get_cert_type(cert, &cert_type); if(result != GLOBUS_SUCCESS) @@ -623,19 +630,19 @@ int globus_gsi_callback_check_issued( return_code = 0; break; } - + if(GLOBUS_GSI_CERT_UTILS_IS_PROXY(cert_type)) { /* its a proxy! */ return_code = 1; } break; - + default: break; } } - + GLOBUS_I_GSI_CALLBACK_DEBUG_EXIT; return return_code; } @@ -652,13 +659,13 @@ globus_i_gsi_callback_cred_verify( globus_gsi_cert_utils_cert_type_t cert_type; X509 * tmp_cert = NULL; X509 * prev_cert = NULL; - static char * _function_name_ = + static char * _function_name_ = "globus_i_gsi_callback_cred_verify"; GLOBUS_I_GSI_CALLBACK_DEBUG_ENTER; - + /* Now check for some error conditions which - * can be disregarded. + * can be disregarded. */ if (!preverify_ok) { @@ -666,11 +673,11 @@ globus_i_gsi_callback_cred_verify( { case X509_V_ERR_PATH_LENGTH_EXCEEDED: - /* - * OpenSSL-0.9.8 has this error (0.9.7d did not have this) - * So we will ignore the errors now and do our checks later - * on (as explained below). - */ + /* + * OpenSSL-0.9.8 has this error (0.9.7d did not have this) + * So we will ignore the errors now and do our checks later + * on (as explained below). + */ case X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED: GLOBUS_I_GSI_CALLBACK_DEBUG_PRINT( @@ -684,22 +691,22 @@ globus_i_gsi_callback_cred_verify( */ result = GLOBUS_SUCCESS; break; - /* - * In the later version (097g+) OpenSSL does know about - * proxies, but not non-rfc compliant proxies, it will - * count them as unhandled critical extensions. - * So we will ignore the errors and do our - * own checks later on, when we check the last - * certificate in the chain we will check the chain. - * As OpenSSL does not recognize legacy proxies - */ + /* + * In the later version (097g+) OpenSSL does know about + * proxies, but not non-rfc compliant proxies, it will + * count them as unhandled critical extensions. + * So we will ignore the errors and do our + * own checks later on, when we check the last + * certificate in the chain we will check the chain. + * As OpenSSL does not recognize legacy proxies + */ case X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION: GLOBUS_I_GSI_CALLBACK_DEBUG_PRINT( 2, "X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION\n"); - /* - * Setting this for 098 or later versions avoid the invalid - * CA error but would result in proxy path len exceeded which - * is handled above. + /* + * Setting this for 098 or later versions avoid the invalid + * CA error but would result in proxy path len exceeded which + * is handled above. */ X509_set_proxy_flag(X509_STORE_CTX_get_current_cert(x509_context)); result = GLOBUS_SUCCESS; @@ -713,44 +720,44 @@ globus_i_gsi_callback_cred_verify( result = GLOBUS_SUCCESS; break; - case X509_V_ERR_INVALID_CA: - /* - * If the previous cert in the chain is a proxy cert then - * we get this error just because openssl does not recognize - * our proxy and treats it as an EEC. And thus, it would - * treat higher level proxies (if any) or EEC as CA cert - * (which are not actually CA certs) and would throw this - * error. As long as the previous cert in the chain is a - * proxy cert, we ignore this error. - */ - prev_cert = sk_X509_value( - X509_STORE_CTX_get0_chain(x509_context), X509_STORE_CTX_get_error_depth(x509_context)-1); - result = globus_gsi_cert_utils_get_cert_type(prev_cert, &cert_type); - if(result != GLOBUS_SUCCESS) - { - result = (globus_result_t)GLOBUS_FAILURE; - } - else - { - if(GLOBUS_GSI_CERT_UTILS_IS_PROXY(cert_type)) - { - result = GLOBUS_SUCCESS; - } - else - { - result = (globus_result_t)GLOBUS_FAILURE; - } + case X509_V_ERR_INVALID_CA: + /* + * If the previous cert in the chain is a proxy cert then + * we get this error just because openssl does not recognize + * our proxy and treats it as an EEC. And thus, it would + * treat higher level proxies (if any) or EEC as CA cert + * (which are not actually CA certs) and would throw this + * error. As long as the previous cert in the chain is a + * proxy cert, we ignore this error. + */ + prev_cert = sk_X509_value( + X509_STORE_CTX_get0_chain(x509_context), X509_STORE_CTX_get_error_depth(x509_context)-1); + result = globus_gsi_cert_utils_get_cert_type(prev_cert, &cert_type); + if(result != GLOBUS_SUCCESS) + { + result = (globus_result_t)GLOBUS_FAILURE; + } + else + { + if(GLOBUS_GSI_CERT_UTILS_IS_PROXY(cert_type)) + { + result = GLOBUS_SUCCESS; + } + else + { + result = (globus_result_t)GLOBUS_FAILURE; + } } - break; + break; default: result = (globus_result_t)GLOBUS_FAILURE; break; - } + } if (result != GLOBUS_SUCCESS) { - char * subject_name = - X509_NAME_oneline(X509_get_subject_name(X509_STORE_CTX_get_current_cert(x509_context)), 0, 0); + char * subject_name = + X509_NAME_oneline(X509_get_subject_name(X509_STORE_CTX_get_current_cert(x509_context)), 0, 0); unsigned long issuer_hash = X509_issuer_name_hash(X509_STORE_CTX_get_current_cert(x509_context)); char * cert_dir; @@ -761,9 +768,9 @@ globus_i_gsi_callback_cred_verify( result, GLOBUS_GSI_CALLBACK_ERROR_CERT_NOT_YET_VALID, (_CLS("Cert with subject: %s is not yet valid" - "- check clock skew between hosts."), subject_name)); + "- check clock skew between hosts."), subject_name)); } - else if (X509_STORE_CTX_get_error(x509_context) == + else if (X509_STORE_CTX_get_error(x509_context) == X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY) { cert_dir = NULL; @@ -773,7 +780,7 @@ globus_i_gsi_callback_cred_verify( result, GLOBUS_GSI_CALLBACK_ERROR_CANT_GET_LOCAL_CA_CERT, (_CLS("Cannot find trusted CA certificate " - "with hash %lx%s%s"), + "with hash %lx%s%s"), issuer_hash, cert_dir ? " in " : "", cert_dir ? cert_dir : "")); if (cert_dir) @@ -790,7 +797,7 @@ globus_i_gsi_callback_cred_verify( result, GLOBUS_GSI_CALLBACK_ERROR_CANT_GET_LOCAL_CA_CERT, (_CLS("Untrusted self-signed certificate in chain " - "with hash %lx"), + "with hash %lx"), issuer_hash)); if (cert_dir) { @@ -811,8 +818,8 @@ globus_i_gsi_callback_cred_verify( GLOBUS_GSI_CALLBACK_ERROR_VERIFY_CRED, (X509_verify_cert_error_string(X509_STORE_CTX_get_error(x509_context)))); } - - OPENSSL_free(subject_name); + + OPENSSL_free(subject_name); goto exit; } @@ -847,7 +854,7 @@ globus_i_gsi_callback_cred_verify( goto exit; } #endif - + /* only want to check singing_policy file if its not a proxy */ result = globus_i_gsi_callback_check_signing_policy( x509_context, @@ -858,13 +865,13 @@ globus_i_gsi_callback_cred_verify( result, GLOBUS_GSI_CALLBACK_ERROR_VERIFY_CRED); goto exit; - } + } } tmp_cert = X509_dup(X509_STORE_CTX_get_current_cert(x509_context)); /* add the current cert to the callback data's cert chain */ - sk_X509_insert(callback_data->cert_chain, + sk_X509_insert(callback_data->cert_chain, tmp_cert, 0); callback_data->cert_depth++; @@ -889,7 +896,7 @@ globus_i_gsi_callback_cred_verify( GLOBUS_GSI_CALLBACK_ERROR_VERIFY_CRED); goto exit; } - + exit: GLOBUS_I_GSI_CALLBACK_DEBUG_EXIT; @@ -908,8 +915,8 @@ globus_i_gsi_callback_check_proxy( GLOBUS_I_GSI_CALLBACK_DEBUG_ENTER; - /* All of the OpenSSL tests have passed and we now get to - * look at the certificate to verify the proxy rules, + /* All of the OpenSSL tests have passed and we now get to + * look at the certificate to verify the proxy rules, * and ca-signing-policy rules. We will also do a CRL check */ result = globus_gsi_cert_utils_get_cert_type(X509_STORE_CTX_get_current_cert(x509_context), @@ -923,7 +930,7 @@ globus_i_gsi_callback_check_proxy( } if(GLOBUS_GSI_CERT_UTILS_IS_PROXY(cert_type)) - { + { /* it is a proxy */ /* a legacy globus proxy may only be followed by another legacy globus @@ -935,7 +942,7 @@ globus_i_gsi_callback_check_proxy( * a draft compliant limited proxy may only be followed by another draft * compliant limited proxy or a draft compliant independent proxy */ - + if((GLOBUS_GSI_CERT_UTILS_IS_GSI_2_PROXY(callback_data->cert_type) && !GLOBUS_GSI_CERT_UTILS_IS_GSI_2_PROXY(cert_type)) || (GLOBUS_GSI_CERT_UTILS_IS_GSI_3_PROXY(callback_data->cert_type) && @@ -961,7 +968,7 @@ globus_i_gsi_callback_check_proxy( X509_STORE_CTX_set_error(x509_context, X509_V_ERR_CERT_SIGNATURE_FAILURE); goto exit; } - + GLOBUS_I_GSI_CALLBACK_DEBUG_PRINT(2, "Passed proxy test\n"); callback_data->proxy_depth++; @@ -977,7 +984,7 @@ globus_i_gsi_callback_check_proxy( } callback_data->cert_type = cert_type; - + exit: GLOBUS_I_GSI_CALLBACK_DEBUG_EXIT; @@ -1003,34 +1010,34 @@ globus_i_gsi_callback_check_revoked( globus_bool_t recheck_crl_done = GLOBUS_FALSE; static char * _function_name_ = "globus_i_gsi_callback_check_revoked"; - + GLOBUS_I_GSI_CALLBACK_DEBUG_ENTER; - + do { x509_object = X509_OBJECT_new(); - /* - * SSLeay 0.9.0 handles CRLs but does not check them. + /* + * SSLeay 0.9.0 handles CRLs but does not check them. * We will check the crl for this cert, if there - * is a CRL in the store. - * If we find the crl is not valid, we will fail, - * as once the sysadmin indicates that CRLs are to - * be checked, he best keep it upto date. - * + * is a CRL in the store. + * If we find the crl is not valid, we will fail, + * as once the sysadmin indicates that CRLs are to + * be checked, he best keep it upto date. + * * When future versions of SSLeay support this better, - * we can remove these tests. - * + * we can remove these tests. + * * we come through this code for each certificate, * starting with the CA's We will check for a CRL * each time, but only check the signature if the * subject name matches, and check for revoked * if the issuer name matches. - * this allows the CA to revoke its own cert as well. + * this allows the CA to revoke its own cert as well. */ if (X509_STORE_get_by_subject( x509_context, - X509_LU_CRL, + X509_LU_CRL, X509_get_issuer_name(X509_STORE_CTX_get_current_cert(x509_context)), x509_object)) { @@ -1047,7 +1054,7 @@ globus_i_gsi_callback_check_revoked( next_update = X509_CRL_get0_nextUpdate(crl); last_update = X509_CRL_get0_lastUpdate(crl); has_next_time = (next_update != NULL); - + globus_gsi_cert_utils_make_time(last_update, &last_time); if (has_next_time) { @@ -1067,8 +1074,8 @@ globus_i_gsi_callback_check_revoked( get_issuer = X509_STORE_CTX_get_get_issuer(x509_context); /* verify the signature on this CRL */ - if(get_issuer(&issuer, - x509_context, + if(get_issuer(&issuer, + x509_context, X509_STORE_CTX_get_current_cert(x509_context)) <= 0) { char * subject_string; @@ -1076,7 +1083,7 @@ globus_i_gsi_callback_check_revoked( subject_string = X509_NAME_oneline( X509_get_issuer_name(X509_STORE_CTX_get_current_cert(x509_context)), NULL, 0); - + GLOBUS_GSI_CALLBACK_OPENSSL_ERROR_RESULT( result, GLOBUS_GSI_CALLBACK_ERROR_INVALID_CRL, @@ -1088,7 +1095,7 @@ globus_i_gsi_callback_check_revoked( } issuer_key = X509_get_pubkey(issuer); - + if(issuer_key == NULL) { GLOBUS_GSI_CALLBACK_OPENSSL_ERROR_RESULT( @@ -1114,7 +1121,7 @@ globus_i_gsi_callback_check_revoked( } EVP_PKEY_free(issuer_key); - + /* Check date */ i = X509_cmp_current_time(last_update); @@ -1137,7 +1144,7 @@ globus_i_gsi_callback_check_revoked( X509_STORE_CTX_set_error(x509_context, X509_V_ERR_CRL_NOT_YET_VALID); goto free_X509_object; } - + i = (has_next_time) ? X509_cmp_current_time(next_update) : 1; if (i == 0) { @@ -1148,7 +1155,7 @@ globus_i_gsi_callback_check_revoked( X509_STORE_CTX_set_error(x509_context, X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD); goto free_X509_object; } - + /* If we get an expired CRL, we'll delete it from the store * associated with this ssl context and then try this operation one * more time to see if a new one is in place. @@ -1276,19 +1283,19 @@ globus_i_gsi_callback_check_revoked( revoked = sk_X509_REVOKED_value(revoked_stack, i); revoked_serial_number = X509_REVOKED_get0_serialNumber(revoked); - + if(!ASN1_INTEGER_cmp( revoked_serial_number, X509_get_serialNumber(X509_STORE_CTX_get_current_cert(x509_context)))) { char * subject_string; long serial; - + serial = ASN1_INTEGER_get(revoked_serial_number); subject_string = X509_NAME_oneline(X509_get_subject_name( X509_STORE_CTX_get_current_cert(x509_context)), NULL, 0); - + GLOBUS_GSI_CALLBACK_ERROR_RESULT( result, GLOBUS_GSI_CALLBACK_ERROR_REVOKED_CERT, @@ -1300,7 +1307,7 @@ globus_i_gsi_callback_check_revoked( GLOBUS_I_GSI_CALLBACK_DEBUG_FPRINTF( 2, (globus_i_gsi_callback_debug_fstream, - "revoked %lX\n", + "revoked %lX\n", ASN1_INTEGER_get(revoked_serial_number))); OPENSSL_free(subject_string); @@ -1325,10 +1332,10 @@ globus_i_gsi_callback_check_revoked( while (crl_was_expired && !recheck_crl_done); free_X509_object: - + if (x509_object != NULL) { - X509_OBJECT_free(x509_object); + X509_OBJECT_free(x509_object); } GLOBUS_I_GSI_CALLBACK_DEBUG_EXIT; @@ -1345,7 +1352,7 @@ globus_i_gsi_callback_check_signing_policy( "globus_i_gsi_callback_check_signing_policy"; GLOBUS_I_GSI_CALLBACK_DEBUG_ENTER; - + /* Do not need to check self signed certs against ca_policy_file */ if (X509_NAME_cmp(X509_get_subject_name(X509_STORE_CTX_get_current_cert(x509_context)), @@ -1372,7 +1379,7 @@ globus_i_gsi_callback_check_signing_policy( } exit: - + GLOBUS_I_GSI_CALLBACK_DEBUG_EXIT; return result; } @@ -1401,7 +1408,7 @@ globus_i_gsi_callback_check_gaa_auth( "globus_i_gsi_callback_check_gaa_auth"; GLOBUS_I_GSI_CALLBACK_DEBUG_ENTER; - + subject_name = X509_NAME_oneline( X509_get_subject_name(X509_STORE_CTX_get_current_cert(x509_context)), NULL, @@ -1410,7 +1417,7 @@ globus_i_gsi_callback_check_gaa_auth( X509_get_issuer_name(X509_STORE_CTX_get_current_cert(x509_context)), NULL, 0); - + result = GLOBUS_GSI_SYSCONFIG_GET_SIGNING_POLICY_FILENAME( X509_get_issuer_name(X509_STORE_CTX_get_current_cert(x509_context)), @@ -1429,7 +1436,7 @@ globus_i_gsi_callback_check_gaa_auth( if(ca_policy_file_path == NULL) { /* signing policy file doesn't exist or can't be read */ - + GLOBUS_GSI_CALLBACK_ERROR_RESULT( result, GLOBUS_GSI_CALLBACK_ERROR_WITH_SIGNING_POLICY, @@ -1451,7 +1458,7 @@ globus_i_gsi_callback_check_gaa_auth( issuer_name, subject_name, ca_policy_file_path) - != OLDGAA_SUCCESS) + != OLDGAA_SUCCESS) { GLOBUS_GSI_CALLBACK_ERROR_RESULT( result, @@ -1462,9 +1469,9 @@ globus_i_gsi_callback_check_gaa_auth( globus_mutex_unlock(&globus_l_gsi_callback_oldgaa_mutex); goto exit; } - + if(oldgaa_get_object_policy_info( - &minor_status, + &minor_status, OLDGAA_NO_DATA, policy_db, oldgaa_globus_policy_retrieve, @@ -1478,14 +1485,14 @@ globus_i_gsi_callback_check_gaa_auth( oldgaa_globus_cleanup(&oldgaa_sc, &rights, options, - &detailed_answer, + &detailed_answer, policy_db, NULL); X509_STORE_CTX_set_error(x509_context, X509_V_ERR_APPLICATION_VERIFICATION); globus_mutex_unlock(&globus_l_gsi_callback_oldgaa_mutex); goto exit; } - + policy_result = oldgaa_check_authorization( &minor_status, oldgaa_sc, @@ -1493,7 +1500,7 @@ globus_i_gsi_callback_check_gaa_auth( rights, options, &detailed_answer); - + if (!detailed_answer) { GLOBUS_GSI_CALLBACK_ERROR_RESULT( @@ -1504,11 +1511,11 @@ globus_i_gsi_callback_check_gaa_auth( issuer_name == NULL ? "NULL" : issuer_name, ca_policy_file_path == NULL ? "NULL" : ca_policy_file_path)); X509_STORE_CTX_set_error(x509_context, X509_V_ERR_INVALID_PURPOSE); - + oldgaa_globus_cleanup(&oldgaa_sc, &rights, options, - &detailed_answer, + &detailed_answer, policy_db, NULL); globus_mutex_unlock(&globus_l_gsi_callback_oldgaa_mutex); @@ -1517,15 +1524,15 @@ globus_i_gsi_callback_check_gaa_auth( if(GLOBUS_I_GSI_CALLBACK_DEBUG(2)) { - + fprintf(globus_i_gsi_callback_debug_fstream, "oldgaa result: %d(0 yes, 1 no, -1 maybe)\n", policy_result); - - if(detailed_answer) - { + + if(detailed_answer) + { fprintf(globus_i_gsi_callback_debug_fstream, "\nprint detailed answer:\n\n"); - + #ifndef WIN32 if(detailed_answer->rights) { @@ -1534,21 +1541,21 @@ globus_i_gsi_callback_check_gaa_auth( #endif } } - + if (policy_handle) { oldgaa_release_principals(&minor_status, &policy_handle); } - + oldgaa_globus_cleanup(&oldgaa_sc, &rights, options, - &detailed_answer, + &detailed_answer, policy_db, NULL); globus_mutex_unlock(&globus_l_gsi_callback_oldgaa_mutex); - + if (policy_result != 0) { GLOBUS_GSI_CALLBACK_ERROR_RESULT( @@ -1592,8 +1599,12 @@ globus_i_gsi_callback_check_critical_extensions( X509_STORE_CTX * x509_context, globus_gsi_callback_data_t callback_data) { - ASN1_OBJECT * extension_object = NULL; + const ASN1_OBJECT * extension_object = NULL; +#if OPENSSL_VERSION_NUMBER < 0x40000000L X509_EXTENSION * extension = NULL; +#else + const X509_EXTENSION * extension = NULL; +#endif PROXY_CERT_INFO_EXTENSION * proxycertinfo = NULL; PROXY_POLICY * policy = NULL; int nid; @@ -1610,8 +1621,8 @@ globus_i_gsi_callback_check_critical_extensions( pci_NID = NID_proxyCertInfo; pci_old_NID = OBJ_txt2nid("1.3.6.1.4.1.3536.1.222"); - while((critical_position = - X509_get_ext_by_critical(X509_STORE_CTX_get_current_cert(x509_context), + while((critical_position = + X509_get_ext_by_critical(X509_STORE_CTX_get_current_cert(x509_context), 1, critical_position)) >= 0) { extension = X509_get_ext(X509_STORE_CTX_get_current_cert(x509_context), critical_position); @@ -1671,7 +1682,7 @@ globus_i_gsi_callback_check_critical_extensions( policy = proxycertinfo->proxyPolicy; } - + if((nid != NID_basic_constraints && nid != NID_key_usage && nid != NID_ext_key_usage && @@ -1728,7 +1739,7 @@ globus_i_gsi_callback_check_path_length( X509 * cert = NULL; globus_result_t result = GLOBUS_SUCCESS; int i; - + static char * _function_name_ = "globus_i_gsi_callback_check_path_length"; @@ -1737,11 +1748,11 @@ globus_i_gsi_callback_check_path_length( /* * We ignored any path length restriction errors because * OpenSSL was counting proxies against the limit. - * If we are on the last cert in the chain, we - * know how many are proxies, so we can do the - * path length check now. + * If we are on the last cert in the chain, we + * know how many are proxies, so we can do the + * path length check now. * See x509_vfy.c check_chain_purpose - * all we do is substract off the proxy_depth + * all we do is substract off the proxy_depth */ if(X509_STORE_CTX_get_current_cert(x509_context) == X509_STORE_CTX_get0_cert(x509_context)) @@ -1755,7 +1766,7 @@ globus_i_gsi_callback_check_path_length( "pathlen=:i=%d x=%p pl=%ld\n", i, cert, X509_get_pathlen(cert))); - if (((i - callback_data->proxy_depth) > 1) && + if (((i - callback_data->proxy_depth) > 1) && (X509_get_pathlen(cert) != -1) && ((i - callback_data->proxy_depth) > (X509_get_pathlen(cert) + 1)) && (X509_get_extension_flags(cert) & EXFLAG_BCONS)) @@ -1768,7 +1779,7 @@ globus_i_gsi_callback_check_path_length( } } } - + GLOBUS_I_GSI_CALLBACK_DEBUG_EXIT; return result; } diff --git a/gsi/callback/source/library/globus_gsi_callback.h b/gsi/callback/source/library/globus_gsi_callback.h index 9bbf5900c6..f7c41bb650 100644 --- a/gsi/callback/source/library/globus_gsi_callback.h +++ b/gsi/callback/source/library/globus_gsi_callback.h @@ -74,7 +74,7 @@ * @endcode * * This function should be called once for each time Globus GSI Callback - * was activated. + * was activated. * */ @@ -89,16 +89,16 @@ extern "C" { */ #define GLOBUS_GSI_CALLBACK_MODULE (&globus_i_gsi_callback_module) -extern +extern globus_module_descriptor_t globus_i_gsi_callback_module; #define _CLS(s) globus_common_i18n_get_string(GLOBUS_GSI_CALLBACK_MODULE,\ - s) + s) /** * @defgroup globus_gsi_callback_functions Callback Functions * @ingroup globus_gsi_callback * @brief Callback Functions - * + * * Functions that plug into various plug points in the OpenSSL path validation * mechanism. These functions add CRL checking, X509 Extension handling and * proxy validation. @@ -110,7 +110,7 @@ globus_module_descriptor_t globus_i_gsi_callback_module; * @brief Callback Data Functions * * Functions that deal with the data structure that contains state associated - * with the path validation callback. + * with the path validation callback. */ @@ -125,9 +125,15 @@ typedef struct globus_l_gsi_callback_data_s * * Typedef for a callback that may be registered for dealing with unhandled X.509 extension * @ingroup globus_gsi_callback */ +#if OPENSSL_VERSION_NUMBER < 0x40000000L typedef int (*globus_gsi_extension_callback_t)( globus_gsi_callback_data_t callback_data, X509_EXTENSION * extension); +#else +typedef int (*globus_gsi_extension_callback_t)( + globus_gsi_callback_data_t callback_data, + const X509_EXTENSION * extension); +#endif #ifndef DOXYGEN @@ -149,12 +155,19 @@ globus_gsi_callback_handshake_callback( int preverify_ok, X509_STORE_CTX * x509_context); +#if OPENSSL_VERSION_NUMBER < 0x40000000L int globus_gsi_callback_check_issued( X509_STORE_CTX * context, X509 * cert, X509 * issuer); +#else +int globus_gsi_callback_check_issued( + X509_STORE_CTX * context, + const X509 * cert, + const X509 * issuer); +#endif -int +int globus_gsi_callback_X509_verify_cert( X509_STORE_CTX * context, void * arg); @@ -291,7 +304,7 @@ globus_result_t globus_gsi_callback_set_allow_missing_signing_policy( globus_gsi_callback_data_t callback_data, globus_bool_t allow); - + #endif /* DOXYGEN */ #ifdef __cplusplus diff --git a/gsi/callback/source/library/oldgaa/globus_oldgaa_utils.c b/gsi/callback/source/library/oldgaa/globus_oldgaa_utils.c index 7884cf61d9..880ca62e94 100644 --- a/gsi/callback/source/library/oldgaa/globus_oldgaa_utils.c +++ b/gsi/callback/source/library/oldgaa/globus_oldgaa_utils.c @@ -15,7 +15,7 @@ */ /********************************************************************** - globus_oldgaa-utils.c: + globus_oldgaa-utils.c: Description: Globus-OLDGAA routines @@ -27,17 +27,17 @@ **********************************************************************/ #include "globus_oldgaa.h" -#include "globus_oldgaa_utils.h" +#include "globus_oldgaa_utils.h" #include "oldgaa_gl_internal_err.h" #include "oldgaa_policy_evaluator.h" #include "oldgaa_utils.h" #include "globus_i_gsi_callback_config.h" -#include /* for strerror() */ +#include /* for strerror() */ #include #include -#include +#include /********************************************************************** Define module specific variables @@ -61,10 +61,10 @@ oldgaa_globus_read_string (policy_file_context_ptr pcontext, static oldgaa_error_code oldgaa_globus_parse_principals(policy_file_context_ptr pcontext, - oldgaa_policy_ptr *policy, - char *tmp_str /* IN&OUT */, - oldgaa_principals_ptr *start, - oldgaa_principals_ptr *added_principal); + oldgaa_policy_ptr *policy, + char *tmp_str /* IN&OUT */, + oldgaa_principals_ptr *start, + oldgaa_principals_ptr *added_principal); static int @@ -77,25 +77,25 @@ oldgaa_globus_omit_comment_line(policy_file_context_ptr pcontext); static void oldgaa_bind_rights_to_condition(oldgaa_rights_ptr right, - oldgaa_cond_bindings_ptr cond_bind) + oldgaa_cond_bindings_ptr cond_bind) { right->cond_bindings = cond_bind; cond_bind->reference_count++; #ifdef DEBUG fprintf(stderr,"oldgaa_bind_rights_to_conditions:rights:%p->cond_bind:%p\n", - right, cond_bind); + right, cond_bind); #endif -} +} static void -oldgaa_bind_rights_to_principal(oldgaa_principals_ptr principal, +oldgaa_bind_rights_to_principal(oldgaa_principals_ptr principal, oldgaa_rights_ptr rights) { if (principal->rights) - oldgaa_add_rights(&(principal->rights), rights); + oldgaa_add_rights(&(principal->rights), rights); else { - principal->rights = rights; - rights->reference_count++; + principal->rights = rights; + rights->reference_count++; } } @@ -106,51 +106,51 @@ print_condition_binding(oldgaa_cond_bindings_ptr cb) { oldgaa_conditions_ptr c; for (; cb; cb = cb->next) { - fprintf(stderr, " condition binding %x\n", cb); - for (c = cb->condition; c; c = c->next) { - fprintf(stderr, " condition (%s, %s, %s)\n", - NN(c->type), NN(c->authority), NN(c->value)); - } + fprintf(stderr, " condition binding %x\n", cb); + for (c = cb->condition; c; c = c->next) { + fprintf(stderr, " condition (%s, %s, %s)\n", + NN(c->type), NN(c->authority), NN(c->value)); + } } } static void print_oldgaa_principal_ptr(oldgaa_principals_ptr pr) { oldgaa_rights_ptr r; - + for (; pr; pr = pr->next) { - fprintf(stderr, "principal (%s, %s, %s): %x\n", - NN(pr->type), NN(pr->authority), NN(pr->value), - pr->rights); - for (r = pr->rights; r; r = r->next) { - fprintf(stderr, " right (%s, %s, %s)\n", - NN(r->type), NN(r->authority), NN(r->value)); - print_condition_binding(r->cond_bindings); - } + fprintf(stderr, "principal (%s, %s, %s): %x\n", + NN(pr->type), NN(pr->authority), NN(pr->value), + pr->rights); + for (r = pr->rights; r; r = r->next) { + fprintf(stderr, " right (%s, %s, %s)\n", + NN(r->type), NN(r->authority), NN(r->value)); + print_condition_binding(r->cond_bindings); + } } } #endif /* LDEBUG */ /********************************************************************** - OLDGAA Cleanup Functions + OLDGAA Cleanup Functions **********************************************************************/ oldgaa_error_code oldgaa_globus_cleanup(oldgaa_sec_context_ptr *oldgaa_sc, oldgaa_rights_ptr *rights, oldgaa_options_ptr options, - oldgaa_answer_ptr *answer, - oldgaa_data_ptr policy_db, + oldgaa_answer_ptr *answer, + oldgaa_data_ptr policy_db, oldgaa_sec_attrb_ptr *attributes) { oldgaa_error_code oldgaa_status = OLDGAA_SUCCESS; - uint32 minor_status; - - if(oldgaa_sc) oldgaa_status = oldgaa_release_sec_context(&minor_status, oldgaa_sc); - if(rights) oldgaa_status = oldgaa_release_rights(&minor_status, rights); - if(options) oldgaa_status = oldgaa_release_options(&minor_status, options); + uint32 minor_status; + + if(oldgaa_sc) oldgaa_status = oldgaa_release_sec_context(&minor_status, oldgaa_sc); + if(rights) oldgaa_status = oldgaa_release_rights(&minor_status, rights); + if(options) oldgaa_status = oldgaa_release_options(&minor_status, options); if(answer) oldgaa_status = oldgaa_release_answer(&minor_status, answer); if(policy_db) oldgaa_status = oldgaa_release_data(&minor_status, policy_db); - if(attributes)oldgaa_status = oldgaa_release_sec_attrb(&minor_status, attributes); + if(attributes)oldgaa_status = oldgaa_release_sec_attrb(&minor_status, attributes); return oldgaa_status; } @@ -158,44 +158,44 @@ oldgaa_globus_cleanup(oldgaa_sec_context_ptr *oldgaa_sc, /********************************************************************** - OLDGAA Initialization Functions + OLDGAA Initialization Functions **********************************************************************/ oldgaa_error_code oldgaa_globus_initialize(oldgaa_sec_context_ptr *oldgaa_sc, oldgaa_rights_ptr *rights, oldgaa_options_ptr *options, - oldgaa_data_ptr *policy_db, - char *signer, - char *subject, - char *path) -{ + oldgaa_data_ptr *policy_db, + char *signer, + char *subject, + char *path) +{ int error=0; /* Allocate and fill in OLDGAA-Globus data structures */ - if(oldgaa_sc) *oldgaa_sc = oldgaa_globus_allocate_sec_context(signer); + if(oldgaa_sc) *oldgaa_sc = oldgaa_globus_allocate_sec_context(signer); if(rights) *rights = oldgaa_globus_allocate_rights(); - - if(options) + + if(options) { oldgaa_allocate_options(options); - (*options)->value = oldgaa_strcopy(subject, (*options)->value); - (*options)->length = strlen(subject); + (*options)->value = oldgaa_strcopy(subject, (*options)->value); + (*options)->length = strlen(subject); } if(policy_db) - { + { oldgaa_allocate_data(policy_db); - + if(path) (*policy_db)->str = oldgaa_strcopy(path,(*policy_db)->str); else - error = get_default_policy_file(*policy_db); + error = get_default_policy_file(*policy_db); } if(error)return OLDGAA_FAILURE; else - return OLDGAA_SUCCESS; + return OLDGAA_SUCCESS; } @@ -204,44 +204,44 @@ oldgaa_globus_initialize(oldgaa_sec_context_ptr *oldgaa_sc, Function: oldgaa_globus_allocate_sec_context Description: - Allocates OLDGAA security context and fills in globus-specific + Allocates OLDGAA security context and fills in globus-specific information. Parameters: - signer, pointer to string with name of credential signer. + signer, pointer to string with name of credential signer. Returns: - Pointer to a oldgaa_sec_context if successful + Pointer to a oldgaa_sec_context if successful **********************************************************************/ oldgaa_sec_context_ptr oldgaa_globus_allocate_sec_context(char *signer) { oldgaa_sec_context_ptr sc = NULL; - + oldgaa_allocate_sec_context(&sc); - - if(strcmp(signer, OLDGAA_ANYBODY) == 0) + + if(strcmp(signer, OLDGAA_ANYBODY) == 0) { - sc->identity_cred->principal->type = oldgaa_strcopy(OLDGAA_ANYBODY, + sc->identity_cred->principal->type = oldgaa_strcopy(OLDGAA_ANYBODY, sc->identity_cred->principal->type); sc->identity_cred->principal->authority = oldgaa_strcopy(" ", sc->identity_cred->principal->authority); - sc->identity_cred->principal->value = oldgaa_strcopy(" ", + sc->identity_cred->principal->value = oldgaa_strcopy(" ", sc->identity_cred->principal->value); } else { - sc->identity_cred->principal->type = oldgaa_strcopy(OLDGAA_CA, + sc->identity_cred->principal->type = oldgaa_strcopy(OLDGAA_CA, sc->identity_cred->principal->type); - - sc->identity_cred->principal->authority = oldgaa_strcopy(OLDGAA_X509_AUTHORITY, + + sc->identity_cred->principal->authority = oldgaa_strcopy(OLDGAA_X509_AUTHORITY, sc->identity_cred->principal->authority); - - sc->identity_cred->principal->value = oldgaa_strcopy(signer, - sc->identity_cred->principal->value); + + sc->identity_cred->principal->value = oldgaa_strcopy(signer, + sc->identity_cred->principal->value); } return sc; @@ -249,17 +249,17 @@ oldgaa_globus_allocate_sec_context(char *signer) /********************************************************************** -Function: oldgaa_globus_allocate_rights() +Function: oldgaa_globus_allocate_rights() Description: - Allocates OLDGAA rights stracture and fills in globus-specific + Allocates OLDGAA rights stracture and fills in globus-specific information.. Parameters: - none + none Returns: - Pointer to a oldgaa_rights if successful + Pointer to a oldgaa_rights if successful **********************************************************************/ oldgaa_rights_ptr @@ -269,7 +269,7 @@ oldgaa_globus_allocate_rights() oldgaa_allocate_rights(&rights); rights->reference_count++; - + rights->type = oldgaa_strcopy(POSITIVE_RIGHTS, rights->type); rights->authority = oldgaa_strcopy(AUTH_GLOBUS, rights->authority); rights->value = oldgaa_strcopy(GLOBUS_RIGHTS_VALUE, rights->value); @@ -279,34 +279,34 @@ oldgaa_globus_allocate_rights() } /********************************************************************** - Policy Retrieving Functions + Policy Retrieving Functions **********************************************************************/ /********************************************************************** -Function: oldgaa_globus_policy_retrieve() +Function: oldgaa_globus_policy_retrieve() Description: Upcall function for the retrieval of the object policy. Parameters: - object, pointer to string with name of protected object, + object, pointer to string with name of protected object, can be NULL - policy_db, pointer to string with name of policy file + policy_db, pointer to string with name of policy file Returns: - Pointer to a policy_file_context_ptr if successful - NULL on error, setting errno. + Pointer to a policy_file_context_ptr if successful + NULL on error, setting errno. **********************************************************************/ -oldgaa_policy_ptr +oldgaa_policy_ptr oldgaa_globus_policy_retrieve(uint32 *minor_status, oldgaa_data_ptr object, oldgaa_data_ptr policy_db, ...) -{ - policy_file_context_ptr pcontext = NULL; - oldgaa_policy_ptr policy_handle = NULL; +{ + policy_file_context_ptr pcontext = NULL; + oldgaa_policy_ptr policy_handle = NULL; int error_type = 1; #ifdef DEBUG @@ -319,22 +319,22 @@ oldgaa_globus_policy_retrieve(uint32 *minor_status, if (pcontext) /* parse policy */ { - if(oldgaa_globus_parse_policy(pcontext, + if(oldgaa_globus_parse_policy(pcontext, &policy_handle) == OLDGAA_SUCCESS) { #ifdef DEBUG { - oldgaa_principals_ptr pp; - oldgaa_rights_ptr rp; - oldgaa_cond_bindings_ptr bp; - oldgaa_conditions_ptr cp; + oldgaa_principals_ptr pp; + oldgaa_rights_ptr rp; + oldgaa_cond_bindings_ptr bp; + oldgaa_conditions_ptr cp; - pp = policy_handle; - while (pp) { + pp = policy_handle; + while (pp) { fprintf(stderr,"principal:%p\n",pp); rp = pp->rights; while(rp) { - fprintf(stderr," rights:%p ref:%d\n", + fprintf(stderr," rights:%p ref:%d\n", rp, rp->reference_count); bp = rp->cond_bindings; while(bp) { @@ -351,17 +351,17 @@ oldgaa_globus_policy_retrieve(uint32 *minor_status, rp = rp->next; } pp = pp->next; - } + } } #endif return policy_handle; } - else error_type = 0; + else error_type = 0; } /* error handling */ - + if(error_type) /* policy retrieve error */ { policy_db->error_code = ERROR_WHILE_RETRIEVING_POLICY; @@ -374,15 +374,15 @@ oldgaa_globus_policy_retrieve(uint32 *minor_status, sprintf(policy_db->error_str,"error retrieving file %s",policy_db->str); } else /* policy parsing error */ - { + { policy_db->error_code = m_status; } - + *minor_status = m_status; return NULL; } - + /**********************************************************************/ static @@ -415,41 +415,41 @@ get_default_policy_file(oldgaa_data_ptr policy_db) free(ca_policy_file_path); } else - { - policy_db->error_str = + { + policy_db->error_str = oldgaa_strcopy("Can not find default policy location. X509_CERT_DIR is not defined.\n", policy_db->error_str); policy_db->error_code = ERROR_WHILE_GETTING_DEFAULT_POLICY_LOCATION; rc = 1; } - - return rc; + + return rc; } /********************************************************************** -Function: oldgaa_globus_policy_file_open() +Function: oldgaa_globus_policy_file_open() Description: - Open the specified policy file for reading, returning a - context. + Open the specified policy file for reading, returning a + context. Parameters: - filename, pointer to string with name of policy file + filename, pointer to string with name of policy file Returns: - Pointer to a policy_file_context if successful - NULL on error, setting errno. + Pointer to a policy_file_context if successful + NULL on error, setting errno. **********************************************************************/ -policy_file_context_ptr +policy_file_context_ptr oldgaa_globus_policy_file_open(const char *filename) { - char * open_mode = "r"; + char * open_mode = "r"; policy_file_context_ptr pcontext = NULL; FILE * stream = NULL; int rc; @@ -499,7 +499,7 @@ oldgaa_globus_policy_file_open(const char *filename) pcontext->buf = malloc(pcontext->buflen + 1); if (!pcontext->buf) out_of_memory(); - + rc = fread(pcontext->buf, pcontext->buflen, 1, stream); pcontext->buf[pcontext->buflen] = 0; @@ -524,14 +524,14 @@ oldgaa_globus_policy_file_open(const char *filename) Function: oldgaa_globus_policy_file_close() Description: - Close the policy file and deallocate memory assigned to the - context. + Close the policy file and deallocate memory assigned to the + context. Parameters: - pcontext, pointer to the context + pcontext, pointer to the context Returns: - Nothing + Nothing **********************************************************************/ @@ -550,29 +550,29 @@ oldgaa_globus_policy_file_close(policy_file_context_ptr pcontext) free(pcontext->parse_error); free(pcontext); } -} +} /********************************************************************** - Policy Parsing Functions + Policy Parsing Functions **********************************************************************/ /**********************************************************************/ static int -oldgaa_globus_help_read_string(policy_file_context_ptr pcontext, - char *str, +oldgaa_globus_help_read_string(policy_file_context_ptr pcontext, + char *str, const char *message) { if (oldgaa_globus_read_string(pcontext, str, NULL)) return 1; - if (end_of_file == TRUE) - { + if (end_of_file == TRUE) + { oldgaa_handle_error(&(pcontext->parse_error), message); - return 1; - } - + return 1; + } + return 0; } @@ -583,17 +583,17 @@ oldgaa_globus_help_read_string(policy_file_context_ptr pcontext, Function: oldgaa_globus_read_string Description: - Read a string from a given stream up to and including the newline - and return it in an allocated buffer. + Read a string from a given stream up to and including the newline + and return it in an allocated buffer. Parameters: - pcontext, handle to a structure, containing the stream to read from. + pcontext, handle to a structure, containing the stream to read from. - str, pointer to string to be filled in. + str, pointer to string to be filled in. - errstring, pointer to the pointer to be filled in with - a pointer to a string describing an error that occurs. - May be NULL. + errstring, pointer to the pointer to be filled in with + a pointer to a string describing an error that occurs. + May be NULL. Returns: 0 on success @@ -606,14 +606,14 @@ int oldgaa_globus_read_string (policy_file_context_ptr pcontext, char *str, char **errstring) -{ +{ int len; int rc; if (pcontext->index >= (pcontext->buflen - 1)) { - end_of_file = TRUE; - return 0; + end_of_file = TRUE; + return 0; } rc = sscanf(pcontext->buf + pcontext->index, "%s%n", str, &len); @@ -628,36 +628,36 @@ oldgaa_globus_read_string (policy_file_context_ptr pcontext, oldgaa_handle_error(&(pcontext->str),str); /* set the string value to report it in the case there is an error */ - + if (str[0]== STRING_DELIMITER) /* get strings with white spaces */ { if(oldgaa_globus_get_string_with_whitespaces(pcontext, str) == -1) { oldgaa_handle_error(&(pcontext->parse_error), - "error while reading string"); + "error while reading string"); return 1; } } if (str[0]== COMMENT) /* omit comment line */ - { + { if(oldgaa_globus_omit_comment_line(pcontext)) { oldgaa_handle_error(&(pcontext->parse_error), - "error while reading string"); + "error while reading string"); return 1; } if(oldgaa_globus_read_string(pcontext, str, errstring)) { - + oldgaa_handle_error(&(pcontext->parse_error), - "error while reading string"); + "error while reading string"); return 1; } - } - + } + return 0; } @@ -667,12 +667,12 @@ oldgaa_globus_read_string (policy_file_context_ptr pcontext, Function: oldgaa_globus_get_string_with_whitespaces Description: - Read a string from a given stream up to it finds STRING_DELIMITER. + Read a string from a given stream up to it finds STRING_DELIMITER. Parameters: - pcontext, handle to a structure, containing the stream to read from. + pcontext, handle to a structure, containing the stream to read from. - str, pointer to string to be filled in. + str, pointer to string to be filled in. Returns: 0 on success @@ -687,19 +687,19 @@ oldgaa_globus_get_string_with_whitespaces(policy_file_context_ptr pcontext, int i=0, j=1, len = strlen(str); /* j=1 because ignore first ' */ int chr, esc = 0; - while(i < pcontext->buflen) /* read chars from the stream + while(i < pcontext->buflen) /* read chars from the stream untill see STRING_DELIMITER */ - { + { chr = (jbuf[pcontext->index++]; - if(pcontext->index == pcontext->buflen) - { + if(pcontext->index == pcontext->buflen) + { end_of_file = TRUE; oldgaa_handle_error(&(pcontext->parse_error), "oldgaa_globus_get_string_with_white_spaces: Missing string delimiter \'"); return -1; - } + } if (!esc && chr == STRING_DELIMITER) break; /* don't check if escaped*/ esc = !esc && (chr == ESCAPE_CHARACTER); /* !esc takes care of \\ */ if (!esc) { str[i] = chr; i++; } /* don't print out the \ */ @@ -722,10 +722,10 @@ oldgaa_globus_get_string_with_whitespaces(policy_file_context_ptr pcontext, Function: oldgaa_globus_omit_comment_line Description: - omit comment from the stream + omit comment from the stream Parameters: - pcontext, handle to a structure, containing the stream to read from. + pcontext, handle to a structure, containing the stream to read from. Returns: 0 on success @@ -737,8 +737,8 @@ static int oldgaa_globus_omit_comment_line(policy_file_context_ptr pcontext) { - int chr; - + int chr; + while(pcontext->index < pcontext->buflen) { chr = pcontext->buf[pcontext->index++]; @@ -748,13 +748,13 @@ oldgaa_globus_omit_comment_line(policy_file_context_ptr pcontext) if (pcontext->index == pcontext->buflen) end_of_file = TRUE; return 0; -} +} /********************************************************************** -Function: oldgaa_globus_parse_policy() +Function: oldgaa_globus_parse_policy() Description: Parses the policy file, filling oldgaa_policy structure. The format of @@ -763,16 +763,16 @@ Function: oldgaa_globus_parse_policy() Parameters: minor_status, mechanism-specific status code pcontext, handle to a structure, containing the stream to read from. - policy_handle, pointer to oldgaa_policy structure to be filled in. - + policy_handle, pointer to oldgaa_policy structure to be filled in. + Returns: - OLDGAA_SUCCESS or OLDGAA_RETREIVE_ERROR + OLDGAA_SUCCESS or OLDGAA_RETREIVE_ERROR **********************************************************************/ -oldgaa_error_code +oldgaa_error_code oldgaa_globus_parse_policy (policy_file_context_ptr pcontext, - oldgaa_policy_ptr *policy_handle) + oldgaa_policy_ptr *policy_handle) { oldgaa_conditions_ptr all_conditions = NULL; @@ -788,8 +788,7 @@ oldgaa_globus_parse_policy (policy_file_context_ptr pcontext, char *str; int cond_present = FALSE; - int new_entry = TRUE; - oldgaa_rights_ptr old_rights = 0; + int new_entry = TRUE; str = malloc(pcontext->buflen); str[0] = 0; @@ -800,22 +799,22 @@ oldgaa_globus_parse_policy (policy_file_context_ptr pcontext, #ifdef DEBUG fprintf(stderr, "\noldgaa_globus_parse_policy:\n"); #endif /* DEBUG */ - - while (!end_of_file) - { + + while (!end_of_file) + { if (new_entry == TRUE) /* start parsing new entry */ { cond_present = FALSE; new_entry = FALSE; /* get principals */ - + if(oldgaa_globus_parse_principals(pcontext, policy_handle, str, &start_principals, &added_principal) != OLDGAA_SUCCESS) - { + { oldgaa_handle_error(&(pcontext->parse_error), "oldgaa_globus_parse_policy: error while parsing principal: "); m_status = ERROR_WHILE_PARSING_PRINCIPALS; @@ -829,27 +828,26 @@ oldgaa_globus_parse_policy (policy_file_context_ptr pcontext, /* get rights */ - old_rights = start_rights; - oldgaa_error = oldgaa_globus_parse_rights(pcontext, + oldgaa_error = oldgaa_globus_parse_rights(pcontext, str, - &start_rights, + &start_rights, &cond_present, &new_entry); if(oldgaa_error != OLDGAA_SUCCESS) - { + { oldgaa_handle_error(&(pcontext->parse_error), - "oldgaa_globus_parse_policy: error while parsing right: "); + "oldgaa_globus_parse_policy: error while parsing right: "); m_status = ERROR_WHILE_PARSING_RIGHTS; goto err; } - /* bind paresed rights for this entry to the paresed principals + /* bind paresed rights for this entry to the paresed principals from this entry */ oldgaa_bind_rights_to_principal(added_principal, start_rights); - + /* get conditions, if any */ - + if(cond_present == TRUE) { oldgaa_error = oldgaa_globus_parse_conditions(pcontext, @@ -862,47 +860,47 @@ oldgaa_globus_parse_policy (policy_file_context_ptr pcontext, if (oldgaa_error == OLDGAA_SUCCESS) { fprintf(stderr, "parsed condition_binding\n"); if (cond_bind) - print_condition_binding(cond_bind); + print_condition_binding(cond_bind); } else - fprintf(stderr, "didn't parse condition binding\n"); + fprintf(stderr, "didn't parse condition binding\n"); #endif /* LDEBUG */ - - if (oldgaa_error != OLDGAA_SUCCESS) + + if (oldgaa_error != OLDGAA_SUCCESS) { oldgaa_handle_error(&(pcontext->parse_error), "oldgaa_globus_parse_policy: error while parsing condition: "); - - m_status = ERROR_WHILE_PARSING_CONDITIONS; + + m_status = ERROR_WHILE_PARSING_CONDITIONS; goto err; } - - /* bind paresed conditions for this entry to the paresed rights + + /* bind paresed conditions for this entry to the paresed rights from this entry */ - else oldgaa_bind_rights_to_condition(start_rights, cond_bind); - + else oldgaa_bind_rights_to_condition(start_rights, cond_bind); + } /* if(cond_present == TRUE) */ - + #ifdef LDEBUG printf("start_principals:\n"); if (start_principals) - print_oldgaa_principal_ptr(start_principals); + print_oldgaa_principal_ptr(start_principals); #endif /* LDEBUG */ - + }/* end of while */ - /* - * Since the conditions are now all bound to cond_bindings, + /* + * Since the conditions are now all bound to cond_bindings, * we can remove the next chain pointers so they don't get - * in the way during free if there are other chains - * using conditions. + * in the way during free if there are other chains + * using conditions. */ { - oldgaa_conditions_ptr c1p, c2p; + oldgaa_conditions_ptr c1p, c2p; - c1p = all_conditions; + c1p = all_conditions; while(c1p) { c2p = c1p->next; @@ -910,13 +908,13 @@ oldgaa_globus_parse_policy (policy_file_context_ptr pcontext, c1p = c2p; } } - + if (pcontext) oldgaa_globus_policy_file_close(pcontext); #ifdef LDEBUG printf("policy_handle:\n"); if (*policy_handle) - print_oldgaa_principal_ptr(*policy_handle); + print_oldgaa_principal_ptr(*policy_handle); #endif /* LDEBUG */ free(str); @@ -933,19 +931,19 @@ oldgaa_globus_parse_policy (policy_file_context_ptr pcontext, /********************************************************************** -Function: oldgaa_globus_parse_principals() +Function: oldgaa_globus_parse_principals() Description: - Parses the policy file, filling oldgaa_rincipals structure. + Parses the policy file, filling oldgaa_rincipals structure. Parameters: pcontext, handle to a structure, containing the stream to read from. - policy, pointer to oldgaa_policy structure to be filled in. + policy, pointer to oldgaa_policy structure to be filled in. tmp_str, contains a string which will be evaluated and in the end, new value is stored here. start, stores a pointer to oldgaa_principals structure of the set of principals which will be read by this invokation. This is needed - by the bind_rights_to_principals function. + by the bind_rights_to_principals function. Returns: OLDGAA_SUCCESS or OLDGAA_PARSE_ERROR @@ -954,13 +952,13 @@ Function: oldgaa_globus_parse_principals() static oldgaa_error_code oldgaa_globus_parse_principals(policy_file_context_ptr pcontext, - oldgaa_policy_ptr *policy, + oldgaa_policy_ptr *policy, char *tmp_str /* IN&OUT */, - oldgaa_principals_ptr *start, - oldgaa_principals_ptr *added_principal) + oldgaa_principals_ptr *start, + oldgaa_principals_ptr *added_principal) { char *str, *type; - uint32 minor_status; + uint32 minor_status; oldgaa_principals_ptr principal = NULL; oldgaa_error_code error_code = OLDGAA_SUCCESS; @@ -980,23 +978,23 @@ oldgaa_globus_parse_principals(policy_file_context_ptr pcontext, if (oldgaa_globus_help_read_string(pcontext, str, "parse principals: Empty policy")) { - error_code = OLDGAA_RETRIEVE_ERROR; + error_code = OLDGAA_RETRIEVE_ERROR; goto free_str; } } - else + else { /* get the value of read principal from tmp_str */ strcpy(str, tmp_str); } - do + do { /* get principal's type */ if (strcmp(str, OLDGAA_ANYBODY) == 0) { - /* do not check for authority and value */ - type = OLDGAA_ANYBODY; + /* do not check for authority and value */ + type = OLDGAA_ANYBODY; } else if(strcmp(str,OLDGAA_USER) == 0) { @@ -1018,21 +1016,21 @@ oldgaa_globus_parse_principals(policy_file_context_ptr pcontext, { type = OLDGAA_APPLICATION; } - else + else { - oldgaa_handle_error(&(pcontext->parse_error), + oldgaa_handle_error(&(pcontext->parse_error), "parse_principals: Bad principal type"); error_code = OLDGAA_RETRIEVE_ERROR; goto free_str; } - + oldgaa_allocate_principals(&principal); - if (type) + if (type) { principal->type = oldgaa_strcopy(type, principal->type); } - + if (strcmp(type, OLDGAA_ANYBODY)== 0) { /* fill in default values */ @@ -1048,11 +1046,11 @@ oldgaa_globus_parse_principals(policy_file_context_ptr pcontext, error_code = OLDGAA_RETRIEVE_ERROR; goto release_principal; } - + if (str) { /* expecting defining authority */ - principal->authority = oldgaa_strcopy(str, principal->authority); + principal->authority = oldgaa_strcopy(str, principal->authority); } if (oldgaa_globus_help_read_string(pcontext, str, @@ -1061,13 +1059,13 @@ oldgaa_globus_parse_principals(policy_file_context_ptr pcontext, error_code = OLDGAA_RETRIEVE_ERROR; goto release_principal; } - + if (str) { /* expecting value */ principal->value = oldgaa_strcopy(str, principal->value); } - } /* end of if(type != "access_id_ANYBODY")*/ + } /* end of if(type != "access_id_ANYBODY")*/ if (*policy == NULL) { @@ -1085,7 +1083,7 @@ oldgaa_globus_parse_principals(policy_file_context_ptr pcontext, { oldgaa_release_principals(&minor_status, &principal); } - /* In either case, the principal is now pointed to by either the + /* In either case, the principal is now pointed to by either the * *start list or has been freed, so we don't need it any more */ principal = NULL; @@ -1101,13 +1099,13 @@ oldgaa_globus_parse_principals(policy_file_context_ptr pcontext, strcpy(tmp_str, str); /* return the read string */ if( !strcmp(str,POSITIVE_RIGHTS) || - !strcmp(str,NEGATIVE_RIGHTS) ) /* operation set starts */ + !strcmp(str,NEGATIVE_RIGHTS) ) /* operation set starts */ { goto release_principal; } } while(!end_of_file); - + release_principal: if (principal) { @@ -1123,10 +1121,10 @@ oldgaa_globus_parse_principals(policy_file_context_ptr pcontext, /********************************************************************** -Function: oldgaa_globus_parse_rights() +Function: oldgaa_globus_parse_rights() Description: - Parses the policy file, filling oldgaa_rights structure. + Parses the policy file, filling oldgaa_rights structure. Parameters: pcontext, handle to a structure, containing the stream to read from. @@ -1136,7 +1134,7 @@ Function: oldgaa_globus_parse_rights() of rights which will be read by this invokation. This is needed by the bind_rights_to_conditions function. cond_present, indicates if condition set starts - end_of_entry, indicates if new entry starts + end_of_entry, indicates if new entry starts Returns: OLDGAA_SUCCESS or OLDGAA_RETRIEVE_ERROR @@ -1155,7 +1153,7 @@ oldgaa_globus_parse_rights( oldgaa_rights_ptr rights = NULL; oldgaa_error_code error_code = OLDGAA_SUCCESS; uint32 minor_status; - + str = malloc(pcontext->buflen); if (str == NULL) { @@ -1168,78 +1166,78 @@ oldgaa_globus_parse_rights( fprintf(stderr, "\noldgaa_globus_parse rights:\n"); #endif /* DEBUG */ - strcpy(str, tmp_str); + strcpy(str, tmp_str); do { if ((oldgaa_strings_match(str,POSITIVE_RIGHTS) || - oldgaa_strings_match(str,NEGATIVE_RIGHTS))== FALSE) + oldgaa_strings_match(str,NEGATIVE_RIGHTS))== FALSE) { /* expecting operation set starts */ error_code = OLDGAA_RETRIEVE_ERROR; oldgaa_handle_error(&(pcontext->parse_error), "Bad right type"); goto free_str; - } - + } + /* allocate fill in the oldgaa_rights structure */ oldgaa_allocate_rights(&rights); if (str) { rights->type = oldgaa_strcopy(str, rights->type); } - + if (oldgaa_globus_help_read_string(pcontext, str, "parse_rights: Missing right authority")) { - error_code = OLDGAA_RETRIEVE_ERROR; + error_code = OLDGAA_RETRIEVE_ERROR; goto free_rights; } - + if (str) { - /* expecting defining authority */ + /* expecting defining authority */ rights->authority = oldgaa_strcopy(str, rights->authority); } - + if (oldgaa_globus_help_read_string(pcontext, str, "parse_rights: Missing right value")) { - error_code = OLDGAA_RETRIEVE_ERROR; + error_code = OLDGAA_RETRIEVE_ERROR; goto free_rights; } - + if (str) { - /* expecting value */ + /* expecting value */ rights->value = oldgaa_strcopy(str, rights->value); } - - if(first == TRUE) { *start = rights; first = FALSE; } + + if(first == TRUE) { *start = rights; first = FALSE; } else oldgaa_add_rights(start, rights); rights = NULL; - if (oldgaa_globus_read_string(pcontext, str, NULL)) + if (oldgaa_globus_read_string(pcontext, str, NULL)) { error_code = OLDGAA_RETRIEVE_ERROR; goto free_str; } - + strcpy(tmp_str, str); /* return the read string */ - + if (!strncmp(str,COND_PREFIX, 5)) /* condition set starts */ { *cond_present = TRUE; goto free_str; } - + if(!strncmp(str,PRINCIPAL_ACCESS_PREFIX, 6) || - !strncmp(str,PRINCIPAL_GRANTOR_PREFIX, 7)) /* new entry starts */ + !strncmp(str,PRINCIPAL_GRANTOR_PREFIX, 7)) /* new entry starts */ { - *end_of_entry = TRUE; + *end_of_entry = TRUE; goto free_str; - } + } } while(!end_of_file); @@ -1258,20 +1256,20 @@ oldgaa_globus_parse_rights( /********************************************************************** -Function: oldgaa_globus_parse_conditions() +Function: oldgaa_globus_parse_conditions() Description: - Parses the policy file, filling oldgaa_conditions structure. + Parses the policy file, filling oldgaa_conditions structure. Parameters: pcontext, handle to a structure, containing the stream to read from. - conditions, pointer to oldgaa_conditions structure to be filled in. + conditions, pointer to oldgaa_conditions structure to be filled in. tmp_str, contains a string which will be evaluated and in the end, new value is stored here. list, stores a pointer to oldgaa_cond_bindings structure of the set - of conditions which will be read by this invokation. + of conditions which will be read by this invokation. This is needed by the bind_rights_to_conditions function. - end_of_entry, indicates if new entry starts + end_of_entry, indicates if new entry starts Returns: OLDGAA_SUCCESS or OLDGAA_RETRIEVE_ERROR @@ -1281,7 +1279,7 @@ Function: oldgaa_globus_parse_conditions() oldgaa_error_code oldgaa_globus_parse_conditions( policy_file_context_ptr pcontext, - oldgaa_conditions_ptr *conditions, + oldgaa_conditions_ptr *conditions, char *tmp_str, oldgaa_cond_bindings_ptr *list, int *end_of_entry) @@ -1304,8 +1302,8 @@ oldgaa_globus_parse_conditions( fprintf(stderr, "\noldgaa_globus_parse conditions:\n"); #endif /* DEBUG */ - strcpy(str, tmp_str); - + strcpy(str, tmp_str); + do { if(strncmp(str,"cond_", 5) != 0)/* expecting condition set starts */ @@ -1318,11 +1316,11 @@ oldgaa_globus_parse_conditions( /* allocate fill in the oldgaa_conditions structure */ oldgaa_allocate_conditions(&cond); - if (str) + if (str) { cond->type = oldgaa_strcopy(str,cond->type) ; } - + if (oldgaa_globus_help_read_string(pcontext, str, "parse_conditions: Missing condition authority")) { @@ -1334,7 +1332,7 @@ oldgaa_globus_parse_conditions( { cond->authority = oldgaa_strcopy(str, cond->authority); } - + if (oldgaa_globus_help_read_string(pcontext, str, "parse_conditions: Missing condition value")) { @@ -1346,7 +1344,7 @@ oldgaa_globus_parse_conditions( { cond->value = oldgaa_strcopy(str, cond->value); } - + oldgaa_allocate_cond_bindings(&cond_bind); if(*conditions == NULL) { *conditions = cond; } @@ -1367,29 +1365,29 @@ oldgaa_globus_parse_conditions( } cond = NULL; - if(first == TRUE){ *list = cond_bind; first = FALSE; } + if(first == TRUE){ *list = cond_bind; first = FALSE; } else oldgaa_add_cond_binding(list, cond_bind); - - if (oldgaa_globus_read_string(pcontext, str, NULL)) + + if (oldgaa_globus_read_string(pcontext, str, NULL)) { error_code = OLDGAA_RETRIEVE_ERROR; goto release_conditions; } - + if(end_of_file == TRUE) { goto release_conditions; } - + strcpy(tmp_str, str); /* return the read string */ if(!strncmp(str,PRINCIPAL_ACCESS_PREFIX, 6) || - !strncmp(str,PRINCIPAL_GRANTOR_PREFIX, 7)) /* new entry starts */ + !strncmp(str,PRINCIPAL_GRANTOR_PREFIX, 7)) /* new entry starts */ { - *end_of_entry = TRUE; + *end_of_entry = TRUE; goto release_conditions; - } + } if(!strncmp(str,POS_RIGHTS_PREFIX, 3) || !strncmp(str,NEG_RIGHTS_PREFIX, 3)) /* new rights set starts */ @@ -1410,7 +1408,7 @@ oldgaa_globus_parse_conditions( /*****************************************************************************/ - + void oldgaa_globus_print_rights(oldgaa_rights_ptr rights) { @@ -1418,18 +1416,18 @@ oldgaa_globus_print_rights(oldgaa_rights_ptr rights) oldgaa_cond_bindings_ptr cond; while(ptr != NULL) - { + { fprintf(stderr, "ACCESS RIGHT\n"); - fprintf(stderr, "type : %s\n", ptr->type); + fprintf(stderr, "type : %s\n", ptr->type); fprintf(stderr, "authority : %s\n", ptr->authority); fprintf(stderr, "value : %s\n\n", ptr->value); - cond = ptr->cond_bindings; + cond = ptr->cond_bindings; while(cond != NULL) { fprintf(stderr, "CONDITION\n"); - fprintf(stderr, "type : %s\n", cond->condition->type); + fprintf(stderr, "type : %s\n", cond->condition->type); fprintf(stderr, "authority : %s\n", cond->condition->authority); fprintf(stderr, "value : %s\n", cond->condition->value); fprintf(stderr, "status : %08x\n\n", cond->condition->status); @@ -1450,13 +1448,13 @@ oldgaa_globus_print_attributes(oldgaa_sec_attrb_ptr attributes) while(ptr != NULL) - { + { fprintf(stderr, "ATTRIBUTE\n"); - fprintf(stderr, "type : %s\n", ptr->type); + fprintf(stderr, "type : %s\n", ptr->type); fprintf(stderr, "authority : %s\n", ptr->authority); fprintf(stderr, "value : %s\n\n", ptr->value); - ptr = ptr->next; + ptr = ptr->next; } } @@ -1467,28 +1465,28 @@ oldgaa_globus_get_trusted_ca_list(oldgaa_sec_attrb_ptr *attributes, oldgaa_policy_ptr policy_handle, oldgaa_rights_ptr rights) { - oldgaa_error_code oldgaa_status = OLDGAA_SUCCESS; - uint32 minor_status = 0; - oldgaa_principals_ptr principal= NULL; - + oldgaa_error_code oldgaa_status = OLDGAA_SUCCESS; + uint32 minor_status = 0; + oldgaa_principals_ptr principal = NULL; + #ifdef DEBUG fprintf(stderr, "\noldgaa_globus_get_trusted_ca_list:\n"); #endif /* DEBUG */ oldgaa_allocate_principals(&principal); - principal->type = oldgaa_strcopy(OLDGAA_CA, principal->type); + principal->type = oldgaa_strcopy(OLDGAA_CA, principal->type); principal->authority = oldgaa_strcopy(OLDGAA_X509_AUTHORITY, principal->authority); /* principal->value = oldgaa_strcopy("\"*\"", principal->value); */ - oldgaa_status = oldgaa_get_authorized_principals(attributes, + oldgaa_status = oldgaa_get_authorized_principals(attributes, policy_handle, - principal, + principal, rights); oldgaa_status = oldgaa_release_principals(&minor_status, &principal); - return oldgaa_status; + return oldgaa_status; } diff --git a/gsi/callback/source/library/oldgaa/oldgaa_policy_evaluator.c b/gsi/callback/source/library/oldgaa/oldgaa_policy_evaluator.c index b7bc78d0b2..821f02d716 100644 --- a/gsi/callback/source/library/oldgaa/oldgaa_policy_evaluator.c +++ b/gsi/callback/source/library/oldgaa/oldgaa_policy_evaluator.c @@ -260,23 +260,18 @@ oldgaa_get_authorized_principals(oldgaa_sec_attrb_ptr *attributes, { oldgaa_policy_ptr entry = policy; int was_anybody = 0; - int was_neg_rights = 0; int number_of_entries = 1; oldgaa_sec_attrb_ptr attrb = NULL; - uint32 minor_status; oldgaa_error_code oldgaa_status = OLDGAA_SUCCESS; #ifdef DEBUG fprintf(stderr, "\noldgaa_get_authorized_principals:\n"); #endif /* DEBUG */ - minor_status = 0; - /* Check arguments */ if (!policy && !attributes) { errno = ERRNO_INVALID_ARGUMENT; - minor_status = -1; return OLDGAA_FAILURE; } @@ -302,14 +297,6 @@ fprintf(stderr, "\noldgaa_get_authorized_principals:\n"); oldgaa_add_attribute(attributes, attrb); number_of_entries++; } - else - { - if(oldgaa_strings_match(entry->rights->type, NEGATIVE_RIGHTS) && - oldgaa_strings_match(entry->rights->authority, rights->authority) && - oldgaa_strings_match(entry->rights->value, rights->value) ) was_neg_rights = 1; - } - - } entry = entry->next; diff --git a/gsi/callback/source/library/oldgaa/oldgaa_release.c b/gsi/callback/source/library/oldgaa/oldgaa_release.c index 8585ac3838..f4aae9cdcb 100644 --- a/gsi/callback/source/library/oldgaa/oldgaa_release.c +++ b/gsi/callback/source/library/oldgaa/oldgaa_release.c @@ -15,10 +15,10 @@ */ /********************************************************************** - oldgaa_release.c: + oldgaa_release.c: Description: - This file used internally by the oldgaa routines + This file used internally by the oldgaa routines **********************************************************************/ #include "globus_oldgaa.h" #include "stdio.h" /* for fprintf() */ @@ -27,56 +27,56 @@ Function: oldgaa_release_buffer_contents Description: - Release the contents of a buffer + Release the contents of a buffer Parameters: Returns: **********************************************************************/ -oldgaa_error_code -oldgaa_release_buffer_contents (uint32 *minor_status, - oldgaa_buffer_ptr buffer) +oldgaa_error_code +oldgaa_release_buffer_contents (uint32 *minor_status, + oldgaa_buffer_ptr buffer) { #ifdef DEBUG -fprintf(stderr, "\noldgaa_release_buffer_contents:\n"); + fprintf(stderr, "\noldgaa_release_buffer_contents:\n"); #endif /* DEBUG */ - if (buffer == NULL || buffer == OLDGAA_NO_BUFFER) return OLDGAA_SUCCESS; - - if (buffer->value) free(buffer->value); - buffer->length = 0; + if (buffer == NULL || buffer == OLDGAA_NO_BUFFER) return OLDGAA_SUCCESS; - return OLDGAA_SUCCESS; + if (buffer->value) free(buffer->value); + buffer->length = 0; + + return OLDGAA_SUCCESS; } /* oldgaa_release_buffer_contents */ /********************************************************************** Function: oldgaa_release_buffer Description: - Release the buffer + Release the buffer Parameters: Returns: **********************************************************************/ -oldgaa_error_code -oldgaa_release_buffer(uint32 *minor_status, - oldgaa_buffer_ptr * buffer) +oldgaa_error_code +oldgaa_release_buffer(uint32 *minor_status, + oldgaa_buffer_ptr *buffer) { #ifdef DEBUG -fprintf(stderr, "\noldgaa_release_buffer:\n"); + fprintf(stderr, "\noldgaa_release_buffer:\n"); #endif /* DEBUG */ - if (buffer == NULL || *buffer == NULL) return OLDGAA_SUCCESS; - + if (buffer == NULL || *buffer == NULL) return OLDGAA_SUCCESS; + free(*buffer); - *buffer = NULL; + *buffer = NULL; - return OLDGAA_SUCCESS; + return OLDGAA_SUCCESS; } /* oldgaa_release_buffer */ @@ -84,61 +84,61 @@ fprintf(stderr, "\noldgaa_release_buffer:\n"); Function: oldgaa_release_options Description: - Release the contents of a buffer + Release the contents of a buffer Parameters: Returns: **********************************************************************/ -oldgaa_error_code -oldgaa_release_options(uint32 *minor_status, - oldgaa_options_ptr buffer) +oldgaa_error_code +oldgaa_release_options(uint32 *minor_status, + oldgaa_options_ptr buffer) { #ifdef DEBUG -fprintf(stderr, "\noldgaa_release_options:\n"); + fprintf(stderr, "\noldgaa_release_options:\n"); #endif /* DEBUG */ - if (buffer == NULL || buffer == OLDGAA_NO_OPTIONS) return OLDGAA_SUCCESS; - - if (buffer->value) free(buffer->value); - buffer->length = 0; + if (buffer == NULL || buffer == OLDGAA_NO_OPTIONS) return OLDGAA_SUCCESS; + + if (buffer->value) free(buffer->value); + buffer->length = 0; - free(buffer); + free(buffer); - return OLDGAA_SUCCESS; + return OLDGAA_SUCCESS; } /* oldgaa_release_options */ - + /********************************************************************** Function: oldgaa_release_data Description: - Release the contents of a buffer + Release the contents of a buffer Parameters: Returns: **********************************************************************/ -oldgaa_error_code -oldgaa_release_data (uint32 *minor_status, - oldgaa_data_ptr buffer) +oldgaa_error_code +oldgaa_release_data (uint32 *minor_status, + oldgaa_data_ptr buffer) { #ifdef DEBUG -fprintf(stderr, "\noldgaa_release_data:\n"); + fprintf(stderr, "\noldgaa_release_data:\n"); #endif /* DEBUG */ - if (buffer == NULL || buffer == OLDGAA_NO_DATA) return OLDGAA_SUCCESS; - - if (buffer->str) free(buffer->str); - if (buffer->error_str) free(buffer->error_str); + if (buffer == NULL || buffer == OLDGAA_NO_DATA) return OLDGAA_SUCCESS; + + if (buffer->str) free(buffer->str); + if (buffer->error_str) free(buffer->error_str); - free(buffer); + free(buffer); - return OLDGAA_SUCCESS; + return OLDGAA_SUCCESS; } /* oldgaa_release_data */ @@ -149,74 +149,74 @@ fprintf(stderr, "\noldgaa_release_data:\n"); Function: oldgaa_delete_sec_context() Description: - delete the security context + delete the security context Parameters: Returns: **********************************************************************/ -oldgaa_error_code -oldgaa_release_sec_context(uint32 *minor_status, - oldgaa_sec_context_ptr *sec_context) +oldgaa_error_code +oldgaa_release_sec_context(uint32 *minor_status, + oldgaa_sec_context_ptr *sec_context) { - oldgaa_sec_context_ptr *context_handle = sec_context; - uint32 inv_minor_status = 0, inv_major_status = 0; + oldgaa_sec_context_ptr *context_handle = sec_context; + uint32 inv_minor_status = 0; #ifdef DEBUG -fprintf(stderr, "\noldgaa_release_sec_context:\n"); + fprintf(stderr, "\noldgaa_release_sec_context:\n"); #endif /* DEBUG */ - if (*context_handle == NULL || *context_handle == OLDGAA_NO_SEC_CONTEXT) - return OLDGAA_SUCCESS ; + if (*context_handle == NULL || *context_handle == OLDGAA_NO_SEC_CONTEXT) + return OLDGAA_SUCCESS ; + + /* ignore errors to allow for incomplete context handles */ + + if ((*context_handle)->identity_cred!= NULL) + oldgaa_release_identity_cred(&inv_minor_status, + &((*context_handle)->identity_cred)); - /* ignore errors to allow for incomplete context handles */ - if ((*context_handle)->identity_cred!= NULL) - inv_major_status = oldgaa_release_identity_cred(&inv_minor_status, - &((*context_handle)->identity_cred)); - + if ((*context_handle)->authr_cred!= NULL) + oldgaa_release_authr_cred(&inv_minor_status, + &((*context_handle)->authr_cred)); - if ((*context_handle)->authr_cred!= NULL) - inv_major_status = oldgaa_release_authr_cred(&inv_minor_status, - &((*context_handle)->authr_cred)); - - if ((*context_handle)->group_membership!= NULL) - inv_major_status = oldgaa_release_identity_cred(&inv_minor_status, - &((*context_handle)->group_membership)); - + if ((*context_handle)->group_membership!= NULL) + oldgaa_release_identity_cred(&inv_minor_status, + &((*context_handle)->group_membership)); - if ((*context_handle)->group_non_membership!= NULL) - inv_major_status = oldgaa_release_identity_cred(&inv_minor_status, - &((*context_handle)->group_non_membership)); - - if ((*context_handle)->attributes!= NULL) - inv_major_status = oldgaa_release_attributes(&inv_minor_status, - &((*context_handle)->attributes)); - + if ((*context_handle)->group_non_membership!= NULL) + oldgaa_release_identity_cred(&inv_minor_status, + &((*context_handle)->group_non_membership)); - if ((*context_handle)->unevl_cred!= NULL) - inv_major_status = oldgaa_release_uneval_cred(&inv_minor_status, - &((*context_handle)->unevl_cred)); - - if ((*context_handle)->connection_state!= NULL) - { - inv_major_status = oldgaa_release_buffer_contents(&inv_minor_status, - (*context_handle)->connection_state); + if ((*context_handle)->attributes!= NULL) + oldgaa_release_attributes(&inv_minor_status, + &((*context_handle)->attributes)); - inv_major_status = oldgaa_release_buffer(&inv_minor_status, - &((*context_handle)->connection_state)); - } - free(*context_handle); + if ((*context_handle)->unevl_cred!= NULL) + oldgaa_release_uneval_cred(&inv_minor_status, + &((*context_handle)->unevl_cred)); + + + if ((*context_handle)->connection_state!= NULL) + { + oldgaa_release_buffer_contents(&inv_minor_status, + (*context_handle)->connection_state); + + oldgaa_release_buffer(&inv_minor_status, + &((*context_handle)->connection_state)); + } + + free(*context_handle); *context_handle = OLDGAA_NO_SEC_CONTEXT; - return OLDGAA_SUCCESS; + return OLDGAA_SUCCESS; } /* oldgaa_delete_sec_context */ @@ -224,119 +224,108 @@ fprintf(stderr, "\noldgaa_release_sec_context:\n"); Function: oldgaa_release_identity_cred() Description: - delete the security context + delete the security context Parameters: Returns: **********************************************************************/ -oldgaa_error_code -oldgaa_release_identity_cred (uint32 *minor_status, - oldgaa_identity_cred_ptr *identity_cred) +oldgaa_error_code +oldgaa_release_identity_cred (uint32 *minor_status, + oldgaa_identity_cred_ptr *identity_cred) { - oldgaa_identity_cred_ptr *cred = identity_cred; - uint32 inv_minor_status = 0, inv_major_status = 0; + oldgaa_identity_cred_ptr *cred = identity_cred; + uint32 inv_minor_status = 0; #ifdef DEBUG -fprintf(stderr, "\noldgaa_release_identity_cred:\n"); + fprintf(stderr, "\noldgaa_release_identity_cred:\n"); #endif /* DEBUG */ - if (*cred == NULL || *cred == OLDGAA_NO_IDENTITY_CRED) - return OLDGAA_SUCCESS; - - /* ignore errors to allow for incomplete context handles */ - - if ((*cred)->principal!= NULL) - inv_major_status = oldgaa_release_principals(&inv_minor_status, - &((*cred)->principal)); - - if ((*cred)->conditions!= NULL) - inv_major_status = oldgaa_release_conditions(&inv_minor_status, - &((*cred)->conditions)); - - if ((*cred)->mech_spec_cred!= NULL) - { - inv_major_status = - oldgaa_release_buffer_contents(&inv_minor_status, - (*cred)->mech_spec_cred); - inv_major_status = oldgaa_release_buffer(&inv_minor_status, - &((*cred)->mech_spec_cred)); - } - - if ((*cred)->next!= NULL) - inv_major_status = oldgaa_release_identity_cred(&inv_minor_status, - &((*cred)->next)); + if (*cred == NULL || *cred == OLDGAA_NO_IDENTITY_CRED) + return OLDGAA_SUCCESS; + + /* ignore errors to allow for incomplete context handles */ + + if ((*cred)->principal!= NULL) + oldgaa_release_principals(&inv_minor_status, &((*cred)->principal)); + + if ((*cred)->conditions!= NULL) + oldgaa_release_conditions(&inv_minor_status, &((*cred)->conditions)); + + if ((*cred)->mech_spec_cred!= NULL) + { + oldgaa_release_buffer_contents(&inv_minor_status, + (*cred)->mech_spec_cred); + oldgaa_release_buffer(&inv_minor_status, &((*cred)->mech_spec_cred)); + } + + if ((*cred)->next!= NULL) + oldgaa_release_identity_cred(&inv_minor_status, &((*cred)->next)); free(*cred); - return OLDGAA_SUCCESS; + return OLDGAA_SUCCESS; -} +} /********************************************************************** Function: oldgaa_release_authr_cred() Description: - delete the security context + delete the security context Parameters: Returns: **********************************************************************/ -oldgaa_error_code -oldgaa_release_authr_cred(uint32 *minor_status, - oldgaa_authr_cred_ptr *authr_cred) +oldgaa_error_code +oldgaa_release_authr_cred(uint32 *minor_status, + oldgaa_authr_cred_ptr *authr_cred) { - oldgaa_authr_cred_ptr *cred = authr_cred; - uint32 inv_minor_status = 0, inv_major_status = 0; + oldgaa_authr_cred_ptr *cred = authr_cred; + uint32 inv_minor_status = 0; #ifdef DEBUG -fprintf(stderr, "\noldgaa_release_authr_cred:\n"); + fprintf(stderr, "\noldgaa_release_authr_cred:\n"); #endif /* DEBUG */ - if (*cred == NULL || *cred == OLDGAA_NO_AUTHORIZATION_CRED) - return OLDGAA_SUCCESS; + if (*cred == NULL || *cred == OLDGAA_NO_AUTHORIZATION_CRED) + return OLDGAA_SUCCESS; + + /* ignore errors to allow for incomplete context handles */ + + if ((*cred)->grantor != NULL) + oldgaa_release_principals(&inv_minor_status, &((*cred)->grantor)); - /* ignore errors to allow for incomplete context handles */ - if ((*cred)->grantor != NULL) - inv_major_status = oldgaa_release_principals(&inv_minor_status, - &((*cred)->grantor)); - + if ((*cred)->grantee != NULL) + oldgaa_release_principals(&inv_minor_status, &((*cred)->grantee)); - if ((*cred)->grantee != NULL) - inv_major_status = oldgaa_release_principals(&inv_minor_status, - &((*cred)->grantee)); - /* - *DEE what about release of objects? + *DEE what about release of objects? * Since There are is no oldgaa_allocate_authr_cred - * that can be fixed when this routine is actually used. + * that can be fixed when this routine is actually used. */ - if ((*cred)->access_rights!= NULL) - inv_major_status = oldgaa_release_rights(&inv_minor_status, - &((*cred)->access_rights)); - - if ((*cred)->mech_spec_cred!= NULL) - { - inv_major_status = - oldgaa_release_buffer_contents(&inv_minor_status, - (*cred)->mech_spec_cred); - inv_major_status = oldgaa_release_buffer(&inv_minor_status, - &((*cred)->mech_spec_cred)); - } - - if ((*cred)->next!= NULL) - inv_major_status = oldgaa_release_authr_cred(&inv_minor_status, - &((*cred)->next)); - - free(*cred); + if ((*cred)->access_rights!= NULL) + oldgaa_release_rights(&inv_minor_status, &((*cred)->access_rights)); + + if ((*cred)->mech_spec_cred!= NULL) + { + oldgaa_release_buffer_contents(&inv_minor_status, + (*cred)->mech_spec_cred); + oldgaa_release_buffer(&inv_minor_status, &((*cred)->mech_spec_cred)); + } + + if ((*cred)->next!= NULL) + oldgaa_release_authr_cred(&inv_minor_status, &((*cred)->next)); + + free(*cred); return OLDGAA_SUCCESS; @@ -346,56 +335,53 @@ fprintf(stderr, "\noldgaa_release_authr_cred:\n"); Function: oldgaa_release_attributes() Description: - delete the security context + delete the security context Parameters: Returns: **********************************************************************/ -oldgaa_error_code -oldgaa_release_attributes(uint32 *minor_status, - oldgaa_attributes_ptr *attributes) +oldgaa_error_code +oldgaa_release_attributes(uint32 *minor_status, + oldgaa_attributes_ptr *attributes) { -oldgaa_attributes_ptr *cred = attributes; -uint32 inv_minor_status = 0, inv_major_status = 0; + oldgaa_attributes_ptr *cred = attributes; + uint32 inv_minor_status = 0; #ifdef DEBUG -fprintf(stderr, "\noldgaa_release_attributes:\n"); + fprintf(stderr, "\noldgaa_release_attributes:\n"); #endif /* DEBUG */ - if (*cred == NULL || *cred == OLDGAA_NO_ATTRIBUTES) - return OLDGAA_SUCCESS; + if (*cred == NULL || *cred == OLDGAA_NO_ATTRIBUTES) + return OLDGAA_SUCCESS; - /* ignore errors to allow for incomplete context handles */ + /* ignore errors to allow for incomplete context handles */ - if ((*cred)->mech_type != NULL) free((*cred)->mech_type); - if ((*cred)->type != NULL) free((*cred)->type); - if ((*cred)->value != NULL) free((*cred)->value); + if ((*cred)->mech_type != NULL) free((*cred)->mech_type); + if ((*cred)->type != NULL) free((*cred)->type); + if ((*cred)->value != NULL) free((*cred)->value); - - if ((*cred)->conditions!= NULL) - inv_major_status = oldgaa_release_cond_bindings(&inv_minor_status, - &((*cred)->conditions)); - if ((*cred)->mech_spec_cred!= NULL) - { - inv_major_status = - oldgaa_release_buffer_contents(&inv_minor_status, - (*cred)->mech_spec_cred); - inv_major_status =oldgaa_release_buffer(&inv_minor_status, - &((*cred)->mech_spec_cred)); - } + if ((*cred)->conditions!= NULL) + oldgaa_release_cond_bindings(&inv_minor_status, + &((*cred)->conditions)); - if ((*cred)->next!= NULL) - inv_major_status = oldgaa_release_attributes(&inv_minor_status, - &((*cred)->next)); + if ((*cred)->mech_spec_cred!= NULL) + { + oldgaa_release_buffer_contents(&inv_minor_status, + (*cred)->mech_spec_cred); + oldgaa_release_buffer(&inv_minor_status, &((*cred)->mech_spec_cred)); + } - free(*cred); + if ((*cred)->next!= NULL) + oldgaa_release_attributes(&inv_minor_status, &((*cred)->next)); - return OLDGAA_SUCCESS; + free(*cred); + + return OLDGAA_SUCCESS; } /* oldgaa_rlease_attributes */ @@ -403,56 +389,51 @@ fprintf(stderr, "\noldgaa_release_attributes:\n"); Function: oldgaa_rlease_uneval_cred() Description: - delete the security context + delete the security context Parameters: Returns: **********************************************************************/ -oldgaa_error_code -oldgaa_release_uneval_cred(uint32 *minor_status, - oldgaa_uneval_cred_ptr *uneval_cred) +oldgaa_error_code +oldgaa_release_uneval_cred(uint32 *minor_status, + oldgaa_uneval_cred_ptr *uneval_cred) { - oldgaa_uneval_cred_ptr *cred = uneval_cred; - uint32 inv_minor_status = 0, inv_major_status = 0; + oldgaa_uneval_cred_ptr *cred = uneval_cred; + uint32 inv_minor_status = 0; #ifdef DEBUG -fprintf(stderr, "\noldgaa_release_uneval_cred:\n"); + fprintf(stderr, "\noldgaa_release_uneval_cred:\n"); #endif /* DEBUG */ - if (*cred == NULL || *cred == OLDGAA_NO_UNEVAL_CRED) - return OLDGAA_SUCCESS; + if (*cred == NULL || *cred == OLDGAA_NO_UNEVAL_CRED) + return OLDGAA_SUCCESS; + + /* ignore errors to allow for incomplete context handles */ - /* ignore errors to allow for incomplete context handles */ - - if ((*cred)->grantor != NULL) - inv_major_status = oldgaa_release_principals(&inv_minor_status, - &((*cred)->grantor)); - + if ((*cred)->grantor != NULL) + oldgaa_release_principals(&inv_minor_status, &((*cred)->grantor)); - if ((*cred)->grantee != NULL) - inv_major_status = oldgaa_release_principals(&inv_minor_status, - &((*cred)->grantee)); + if ((*cred)->grantee != NULL) + oldgaa_release_principals(&inv_minor_status, &((*cred)->grantee)); - if ((*cred)->mech_spec_cred!= NULL) - { - inv_major_status = - oldgaa_release_buffer_contents(&inv_minor_status, - (*cred)->mech_spec_cred); - inv_major_status = oldgaa_release_buffer(&inv_minor_status, - &((*cred)->mech_spec_cred)); - } - if ((*cred)->next!= NULL) - inv_major_status = oldgaa_release_uneval_cred(&inv_minor_status, - &((*cred)->next)); + if ((*cred)->mech_spec_cred!= NULL) + { + oldgaa_release_buffer_contents(&inv_minor_status, + (*cred)->mech_spec_cred); + oldgaa_release_buffer(&inv_minor_status, &((*cred)->mech_spec_cred)); + } - free(*cred); + if ((*cred)->next!= NULL) + oldgaa_release_uneval_cred(&inv_minor_status, &((*cred)->next)); + + free(*cred); return OLDGAA_SUCCESS; @@ -462,47 +443,45 @@ fprintf(stderr, "\noldgaa_release_uneval_cred:\n"); Function: oldgaa_rlease_principals() Description: - delete the security context + delete the security context Parameters: Returns: **********************************************************************/ -oldgaa_error_code -oldgaa_release_principals(uint32 *minor_status, - oldgaa_principals_ptr *principals) +oldgaa_error_code +oldgaa_release_principals(uint32 *minor_status, + oldgaa_principals_ptr *principals) { -oldgaa_principals_ptr *cred = principals; -uint32 inv_minor_status = 0, inv_major_status = 0; + oldgaa_principals_ptr *cred = principals; + uint32 inv_minor_status = 0; #ifdef DEBUG -fprintf(stderr, "\noldgaa_release_principals:\n"); + fprintf(stderr, "\noldgaa_release_principals:\n"); #endif /* DEBUG */ - if (*cred == NULL || *cred == OLDGAA_NO_PRINCIPALS) - return OLDGAA_SUCCESS; + if (*cred == NULL || *cred == OLDGAA_NO_PRINCIPALS) + return OLDGAA_SUCCESS; - /* ignore errors to allow for incomplete context handles */ + /* ignore errors to allow for incomplete context handles */ - if ((*cred)->rights != NULL) - inv_major_status = oldgaa_release_rights(&inv_minor_status, - &((*cred)->rights)); + if ((*cred)->rights != NULL) + oldgaa_release_rights(&inv_minor_status, &((*cred)->rights)); - if ((*cred)->next != NULL) - inv_major_status = oldgaa_release_principals(&inv_minor_status, - &((*cred)->next)); - - if ((*cred)->type != NULL) free((*cred)->type); - if ((*cred)->authority != NULL) free((*cred)->authority); - if ((*cred)->value != NULL) free((*cred)->value); - + if ((*cred)->next != NULL) + oldgaa_release_principals(&inv_minor_status, &((*cred)->next)); + + if ((*cred)->type != NULL) free((*cred)->type); + if ((*cred)->authority != NULL) free((*cred)->authority); + if ((*cred)->value != NULL) free((*cred)->value); + free(*cred); - return OLDGAA_SUCCESS; + return OLDGAA_SUCCESS; } /* oldgaa_rlease_principals */ @@ -510,31 +489,31 @@ fprintf(stderr, "\noldgaa_release_principals:\n"); Function: oldgaa_rlease_rights() Description: - delete the security context + delete the security context Parameters: Returns: **********************************************************************/ -oldgaa_error_code -oldgaa_release_rights(uint32 *minor_status, - oldgaa_rights_ptr *rights) +oldgaa_error_code +oldgaa_release_rights(uint32 *minor_status, + oldgaa_rights_ptr *rights) { -oldgaa_rights_ptr *cred = rights; -uint32 inv_minor_status = 0, inv_major_status = 0; + oldgaa_rights_ptr *cred = rights; + uint32 inv_minor_status = 0; #ifdef DEBUG -fprintf(stderr, "\noldgaa_release_rights:\n"); + fprintf(stderr, "\noldgaa_release_rights:\n"); #endif /* DEBUG */ - if (*cred == NULL || *cred == OLDGAA_NO_RIGHTS) - return OLDGAA_SUCCESS; + if (*cred == NULL || *cred == OLDGAA_NO_RIGHTS) + return OLDGAA_SUCCESS; #ifdef DEBUG -fprintf(stderr, "rights:%p:ref:%d\n",*cred,(*cred)->reference_count); + fprintf(stderr, "rights:%p:ref:%d\n",*cred,(*cred)->reference_count); #endif /* DEBUG */ (*cred)->reference_count--; @@ -543,27 +522,26 @@ fprintf(stderr, "rights:%p:ref:%d\n",*cred,(*cred)->reference_count); return OLDGAA_SUCCESS; } - /* ignore errors to allow for incomplete context handles */ + /* ignore errors to allow for incomplete context handles */ - - if ((*cred)->cond_bindings != NULL) - inv_major_status = oldgaa_release_cond_bindings(&inv_minor_status, - &((*cred)->cond_bindings)); - - if ((*cred)->next != NULL) - inv_major_status = oldgaa_release_rights(&inv_minor_status, - &((*cred)->next)); - - if ((*cred)->type != NULL) free((*cred)->type); - if ((*cred)->authority != NULL) free((*cred)->authority); - if ((*cred)->value != NULL) free((*cred)->value); + if ((*cred)->cond_bindings != NULL) + oldgaa_release_cond_bindings(&inv_minor_status, + &((*cred)->cond_bindings)); + + + if ((*cred)->next != NULL) + oldgaa_release_rights(&inv_minor_status, &((*cred)->next)); + + if ((*cred)->type != NULL) free((*cred)->type); + if ((*cred)->authority != NULL) free((*cred)->authority); + if ((*cred)->value != NULL) free((*cred)->value); + - free(*cred); *rights = NULL; - return OLDGAA_SUCCESS; + return OLDGAA_SUCCESS; } /* oldgaa_rlease_rights */ @@ -571,82 +549,80 @@ fprintf(stderr, "rights:%p:ref:%d\n",*cred,(*cred)->reference_count); Function: oldgaa_rlease_cond_bindings() Description: - delete the security context + delete the security context Parameters: Returns: **********************************************************************/ -oldgaa_error_code -oldgaa_release_cond_bindings(uint32 *minor_status, - oldgaa_cond_bindings_ptr *cond_bind) +oldgaa_error_code +oldgaa_release_cond_bindings(uint32 *minor_status, + oldgaa_cond_bindings_ptr *cond_bind) { - oldgaa_cond_bindings_ptr *cred = cond_bind; - uint32 inv_minor_status = 0, inv_major_status = 0; + oldgaa_cond_bindings_ptr *cred = cond_bind; + uint32 inv_minor_status = 0; #ifdef DEBUG -fprintf(stderr, "\noldgaa_release_cond_bindings:\n"); + fprintf(stderr, "\noldgaa_release_cond_bindings:\n"); #endif /* DEBUG */ - if (*cred == NULL || *cred == OLDGAA_NO_COND_BINDINGS) - return OLDGAA_SUCCESS; + if (*cred == NULL || *cred == OLDGAA_NO_COND_BINDINGS) + return OLDGAA_SUCCESS; #ifdef DEBUG -fprintf(stderr, "cond:%p:ref:%d\n",*cred,(*cred)->reference_count); + fprintf(stderr, "cond:%p:ref:%d\n",*cred,(*cred)->reference_count); #endif /* DEBUG */ - (*cred)->reference_count--; - if ((*cred)->reference_count > 0) { - *cond_bind = NULL; - return OLDGAA_SUCCESS; + (*cred)->reference_count--; + if ((*cred)->reference_count > 0) { + *cond_bind = NULL; + return OLDGAA_SUCCESS; } - /* ignore errors to allow for incomplete context handles */ + /* ignore errors to allow for incomplete context handles */ + + if ((*cred)->condition != NULL) + oldgaa_release_conditions(&inv_minor_status, &((*cred)->condition)); - if ((*cred)->condition != NULL) - inv_major_status = oldgaa_release_conditions(&inv_minor_status, - &((*cred)->condition)); + if ((*cred)->next != NULL) + oldgaa_release_cond_bindings(&inv_minor_status, &((*cred)->next)); - if ((*cred)->next != NULL) - inv_major_status = oldgaa_release_cond_bindings(&inv_minor_status, - &((*cred)->next)); - free(*cred); - *cond_bind = NULL; + *cond_bind = NULL; - return OLDGAA_SUCCESS; + return OLDGAA_SUCCESS; -} +} /********************************************************************** Function: oldgaa_rlease_conditions() Description: - delete the security context + delete the security context Parameters: Returns: **********************************************************************/ -oldgaa_error_code -oldgaa_release_conditions(uint32 *minor_status, - oldgaa_conditions_ptr *cond) +oldgaa_error_code +oldgaa_release_conditions(uint32 *minor_status, + oldgaa_conditions_ptr *cond) { - oldgaa_conditions_ptr *cred = cond; - uint32 inv_minor_status = 0, inv_major_status = 0; + oldgaa_conditions_ptr *cred = cond; + uint32 inv_minor_status = 0; #ifdef DEBUG -fprintf(stderr, "\noldgaa_release_conditions:\n"); + fprintf(stderr, "\noldgaa_release_conditions:\n"); #endif /* DEBUG */ - if (*cred == NULL || *cred == OLDGAA_NO_CONDITIONS) - return OLDGAA_SUCCESS; + if (*cred == NULL || *cred == OLDGAA_NO_CONDITIONS) + return OLDGAA_SUCCESS; #ifdef DEBUG -fprintf(stderr, "conditions:%p:ref:%d\n",*cred,(*cred)->reference_count); + fprintf(stderr, "conditions:%p:ref:%d\n",*cred,(*cred)->reference_count); #endif /* DEBUG */ (*cred)->reference_count--; @@ -654,57 +630,54 @@ fprintf(stderr, "conditions:%p:ref:%d\n",*cred,(*cred)->reference_count); *cond = NULL; return OLDGAA_SUCCESS; } - /* ignore errors to allow for incomplete context handles */ + /* ignore errors to allow for incomplete context handles */ - if ((*cred)->next != NULL) - inv_major_status = oldgaa_release_conditions(&inv_minor_status, - &((*cred)->next)); - - if ((*cred)->type != NULL) free((*cred)->type); - if ((*cred)->authority != NULL) free((*cred)->authority); - if ((*cred)->value != NULL) free((*cred)->value); + if ((*cred)->next != NULL) + oldgaa_release_conditions(&inv_minor_status, &((*cred)->next)); + + if ((*cred)->type != NULL) free((*cred)->type); + if ((*cred)->authority != NULL) free((*cred)->authority); + if ((*cred)->value != NULL) free((*cred)->value); free(*cred); - return OLDGAA_SUCCESS; + return OLDGAA_SUCCESS; -} +} /********************************************************************** Function: oldgaa_rlease_answer() Description: - delete the security context + delete the security context Parameters: Returns: **********************************************************************/ -oldgaa_error_code -oldgaa_release_answer(uint32 *minor_status, - oldgaa_answer_ptr *answer) +oldgaa_error_code +oldgaa_release_answer(uint32 *minor_status, + oldgaa_answer_ptr *answer) { oldgaa_answer_ptr * cred = answer; uint32 inv_minor_status = 0; - uint32 inv_major_status = 0; #ifdef DEBUG fprintf(stderr, "\noldgaa_release_answer:\n"); #endif /* DEBUG */ - if (*cred == NULL || *cred == OLDGAA_NO_ANSWER) + if (*cred == NULL || *cred == OLDGAA_NO_ANSWER) { return OLDGAA_SUCCESS; } - if ((*cred)->rights!= NULL) - { - /* ignore errors to allow for incomplete context handles */ - inv_major_status = - oldgaa_release_rights(&inv_minor_status, &((*cred)->rights)); - } - + if ((*cred)->rights!= NULL) + { + /* ignore errors to allow for incomplete context handles */ + oldgaa_release_rights(&inv_minor_status, &((*cred)->rights)); + } + if ((*cred)->valid_time != NULL) { free((*cred)->valid_time); @@ -720,35 +693,33 @@ oldgaa_release_answer(uint32 *minor_status, Function: oldgaa_rlease_principals() Description: - delete the security context + delete the security context Parameters: Returns: **********************************************************************/ -oldgaa_error_code -oldgaa_release_sec_attrb(uint32 *minor_status, - oldgaa_sec_attrb_ptr *attributes) +oldgaa_error_code +oldgaa_release_sec_attrb(uint32 *minor_status, + oldgaa_sec_attrb_ptr *attributes) { oldgaa_sec_attrb_ptr * cred = attributes; - uint32 inv_minor_status = 0; - uint32 inv_major_status = 0; + uint32 inv_minor_status = 0; #ifdef DEBUG fprintf(stderr, "\noldgaa_release_sec_attrb:\n"); #endif /* DEBUG */ - if (*cred == NULL || *cred == OLDGAA_NO_SEC_ATTRB) + if (*cred == NULL || *cred == OLDGAA_NO_SEC_ATTRB) { return OLDGAA_SUCCESS; } - if ((*cred)->next != NULL) + if ((*cred)->next != NULL) { /* ignore errors to allow for incomplete context handles */ - inv_major_status = - oldgaa_release_sec_attrb(&inv_minor_status, &((*cred)->next)); + oldgaa_release_sec_attrb(&inv_minor_status, &((*cred)->next)); } if ((*cred)->type != NULL) free((*cred)->type); @@ -758,6 +729,6 @@ oldgaa_release_sec_attrb(uint32 *minor_status, free(*cred); return OLDGAA_SUCCESS; -} +} /**********************************************************************/ diff --git a/gsi/callback/source/library/oldgaa/oldgaa_utils.c b/gsi/callback/source/library/oldgaa/oldgaa_utils.c index 1f5c2a1eef..7c9fd6df28 100644 --- a/gsi/callback/source/library/oldgaa/oldgaa_utils.c +++ b/gsi/callback/source/library/oldgaa/oldgaa_utils.c @@ -477,7 +477,7 @@ oldgaa_regex_matches_string( { /* Our result (1 == match) */ int result = 0; - char * star; + const char * star; /* Check arguments */ if (!string || !regex) diff --git a/gsi/cert_utils/source/configure.ac b/gsi/cert_utils/source/configure.ac index 9280827ee0..d892a13262 100644 --- a/gsi/cert_utils/source/configure.ac +++ b/gsi/cert_utils/source/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ([2.60]) -AC_INIT([globus_gsi_cert_utils], [10.11], [https://github.com/gridcf/gct/issues]) +AC_INIT([globus_gsi_cert_utils], [10.12], [https://github.com/gridcf/gct/issues]) AC_CONFIG_MACRO_DIR([m4]) AC_SUBST([MAJOR_VERSION], [${PACKAGE_VERSION%%.*}]) AC_SUBST([MINOR_VERSION], [${PACKAGE_VERSION##*.}]) diff --git a/gsi/cert_utils/source/library/globus_gsi_cert_utils.c b/gsi/cert_utils/source/library/globus_gsi_cert_utils.c index a898f54d89..602ba1bf44 100644 --- a/gsi/cert_utils/source/library/globus_gsi_cert_utils.c +++ b/gsi/cert_utils/source/library/globus_gsi_cert_utils.c @@ -73,7 +73,7 @@ globus_l_gsi_cert_utils_activate(void) if(tmp_string != GLOBUS_NULL) { globus_i_gsi_cert_utils_debug_level = atoi(tmp_string); - + if(globus_i_gsi_cert_utils_debug_level < 0) { globus_i_gsi_cert_utils_debug_level = 0; @@ -103,7 +103,7 @@ globus_l_gsi_cert_utils_activate(void) { goto activate_openssl_fail; } - + result = globus_module_activate(GLOBUS_GSI_OPENSSL_ERROR_MODULE); if (result != GLOBUS_SUCCESS) { @@ -220,7 +220,7 @@ globus_gsi_cert_utils_make_time( * values returned, see globus_gsi_cert_utils_cert_type_t. * * @param cert - * The X509 certificate + * The X509 certificate * @param type * The returned X509 certificate type * @@ -229,15 +229,23 @@ globus_gsi_cert_utils_make_time( */ globus_result_t globus_gsi_cert_utils_get_cert_type( +#if OPENSSL_VERSION_NUMBER < 0x40000000L X509 * cert, +#else + const X509 * cert, +#endif globus_gsi_cert_utils_cert_type_t * type) { - X509_NAME * subject = NULL; + const X509_NAME * subject = NULL; X509_NAME * name = NULL; - X509_NAME_ENTRY * ne = NULL; + const X509_NAME_ENTRY * ne = NULL; X509_NAME_ENTRY * new_ne = NULL; +#if OPENSSL_VERSION_NUMBER < 0x40000000L X509_EXTENSION * pci_ext = NULL; - ASN1_STRING * data = NULL; +#else + const X509_EXTENSION * pci_ext = NULL; +#endif + const ASN1_STRING * data = NULL; PROXY_CERT_INFO_EXTENSION * pci = NULL; PROXY_POLICY * policy = NULL; ASN1_OBJECT * policy_lang = NULL; @@ -248,13 +256,13 @@ globus_gsi_cert_utils_get_cert_type( BASIC_CONSTRAINTS * x509v3_bc = NULL; static char * _function_name_ = "globus_gsi_cert_utils_get_cert_type"; - + GLOBUS_I_GSI_CERT_UTILS_DEBUG_ENTER; /* assume it is a EEC if nothing else matches */ - + *type = GLOBUS_GSI_CERT_UTILS_TYPE_EEC; - + if((x509v3_bc = X509_get_ext_d2i(cert, NID_basic_constraints, &critical, @@ -263,9 +271,9 @@ globus_gsi_cert_utils_get_cert_type( *type = GLOBUS_GSI_CERT_UTILS_TYPE_CA; goto exit; } - + subject = X509_get_subject_name(cert); - + if((ne = X509_NAME_get_entry(subject, X509_NAME_entry_count(subject)-1)) == NULL) { @@ -280,11 +288,13 @@ globus_gsi_cert_utils_get_cert_type( { /* the name entry is of the type: common name */ data = X509_NAME_ENTRY_get_data(ne); - if(data->length == 5 && !memcmp(data->data,"proxy",5)) + if(ASN1_STRING_length(data) == 5 && + !memcmp(ASN1_STRING_get0_data(data), "proxy", 5)) { *type = GLOBUS_GSI_CERT_UTILS_TYPE_GSI_2_PROXY; } - else if(data->length == 13 && !memcmp(data->data,"limited proxy",13)) + else if(ASN1_STRING_length(data) == 13 && + !memcmp(ASN1_STRING_get0_data(data), "limited proxy", 13)) { *type = GLOBUS_GSI_CERT_UTILS_TYPE_GSI_2_LIMITED_PROXY; } @@ -303,7 +313,7 @@ globus_gsi_cert_utils_get_cert_type( "extension to internal form"))); goto exit; } - + if((policy = pci->proxyPolicy) == NULL) { GLOBUS_GSI_CERT_UTILS_OPENSSL_ERROR_RESULT( @@ -324,7 +334,7 @@ globus_gsi_cert_utils_get_cert_type( } policy_nid = OBJ_obj2nid(policy_lang); - + if (policy_nid == NID_id_ppl_inheritAll) { *type = GLOBUS_GSI_CERT_UTILS_TYPE_RFC_IMPERSONATION_PROXY; @@ -341,11 +351,11 @@ globus_gsi_cert_utils_get_cert_type( { *type = GLOBUS_GSI_CERT_UTILS_TYPE_RFC_RESTRICTED_PROXY; } - + if(X509_get_ext_by_NID(cert, NID_proxyCertInfo, index) != -1) - { + { GLOBUS_GSI_CERT_UTILS_OPENSSL_ERROR_RESULT( result, GLOBUS_GSI_CERT_UTILS_ERROR_NON_COMPLIANT_PROXY, @@ -368,7 +378,7 @@ globus_gsi_cert_utils_get_cert_type( "extension to internal form"))); goto exit; } - + if((policy = pci->proxyPolicy) == NULL) { GLOBUS_GSI_CERT_UTILS_OPENSSL_ERROR_RESULT( @@ -389,7 +399,7 @@ globus_gsi_cert_utils_get_cert_type( } policy_nid = OBJ_obj2nid(policy_lang); - + if (policy_nid == NID_id_ppl_inheritAll) { *type = GLOBUS_GSI_CERT_UTILS_TYPE_GSI_3_IMPERSONATION_PROXY; @@ -406,11 +416,11 @@ globus_gsi_cert_utils_get_cert_type( { *type = GLOBUS_GSI_CERT_UTILS_TYPE_GSI_3_RESTRICTED_PROXY; } - + if(X509_get_ext_by_NID(cert, OBJ_txt2nid(PROXYCERTINFO_OLD_OID), index) != -1) - { + { GLOBUS_GSI_CERT_UTILS_OPENSSL_ERROR_RESULT( result, GLOBUS_GSI_CERT_UTILS_ERROR_NON_COMPLIANT_PROXY, @@ -427,8 +437,8 @@ globus_gsi_cert_utils_get_cert_type( */ GLOBUS_I_GSI_CERT_UTILS_DEBUG_FPRINTF( - 2, (globus_i_gsi_cert_utils_debug_fstream, - "Subject is %s\n", data->data)); + 2, (globus_i_gsi_cert_utils_debug_fstream, + "Subject is %s\n", ASN1_STRING_get0_data(data))); if((name = X509_NAME_dup( X509_get_issuer_name(cert))) == NULL) @@ -439,18 +449,20 @@ globus_gsi_cert_utils_get_cert_type( (_CUSL("Error copying X509_NAME struct"))); goto exit; } - + if((new_ne = X509_NAME_ENTRY_create_by_NID(NULL, NID_commonName, - data->type, - data->data, -1)) == NULL) + ASN1_STRING_type(data), + ASN1_STRING_get0_data(data), + -1)) == NULL) { GLOBUS_GSI_CERT_UTILS_OPENSSL_ERROR_RESULT( result, GLOBUS_GSI_CERT_UTILS_ERROR_GETTING_CN_ENTRY, - (_CUSL("Error creating X509 name entry of: %s"), data->data)); + (_CUSL("Error creating X509 name entry of: %s"), + ASN1_STRING_get0_data(data))); goto exit; } - + if(!X509_NAME_add_entry(name, new_ne, X509_NAME_entry_count(name),0)) { X509_NAME_ENTRY_free(new_ne); @@ -459,16 +471,16 @@ globus_gsi_cert_utils_get_cert_type( result, GLOBUS_GSI_CERT_UTILS_ERROR_ADDING_CN_TO_SUBJECT, (_CUSL("Error adding name entry with value: %s, to subject"), - data->data)); + ASN1_STRING_get0_data(data))); goto exit; } - + if(new_ne) { X509_NAME_ENTRY_free(new_ne); new_ne = NULL; } - + if (X509_NAME_cmp(name,subject)) { /* @@ -535,7 +547,7 @@ globus_gsi_cert_utils_get_cert_type( * The resulting X509_NAME object * * @return - * GLOBUS_SUCCESS unless an error occurred, in which case, + * GLOBUS_SUCCESS unless an error occurred, in which case, * a globus error object ID is returned */ globus_result_t @@ -573,7 +585,7 @@ globus_gsi_cert_utils_get_x509_name( if (*index == '/') { /* skip first / */ - name_entry_str = index + 1; + name_entry_str = index + 1; while ((index != NULL) && (*index != '\0')) { /* point at name = */ @@ -588,35 +600,35 @@ globus_gsi_cert_utils_get_x509_name( goto exit; } /* terminate name string */ - *index = '\0'; + *index = '\0'; name_value_str = index + 1; /* find next =, then last / */ - index = strchr(name_value_str, '='); + index = strchr(name_value_str, '='); if (index != NULL) { /* for now set = to \0 */ - *index = '\0'; - + *index = '\0'; + /* find last / in value */ - index2 = strrchr(name_value_str, '/'); + index2 = strrchr(name_value_str, '/'); /* reset = */ - *index = '='; + *index = '='; if (index2 != NULL) { /* terminate value string */ - *index2 = '\0'; + *index2 = '\0'; } } nid = OBJ_txt2nid(name_entry_str); - + if (nid == NID_undef) { - /* + /* * not found, lets try upper case instead */ uc_index = name_entry_str; @@ -641,7 +653,7 @@ globus_gsi_cert_utils_get_x509_name( x509_name_entry = X509_NAME_ENTRY_create_by_NID( &x509_name_entry, nid, - V_ASN1_APP_CHOOSE, + V_ASN1_APP_CHOOSE, (unsigned char *) name_value_str, -1); @@ -654,8 +666,8 @@ globus_gsi_cert_utils_get_x509_name( name_entry_str, name_value_str)); goto exit; } - - res = X509_NAME_add_entry(x509_name, x509_name_entry, + + res = X509_NAME_add_entry(x509_name, x509_name_entry, X509_NAME_entry_count(x509_name), 0); if (!res) { @@ -665,7 +677,7 @@ globus_gsi_cert_utils_get_x509_name( (_CUSL("Couldn't add name entry to X509_NAME object"))); goto exit; } - + X509_NAME_ENTRY_free(x509_name_entry); x509_name_entry = NULL; @@ -763,9 +775,9 @@ globus_gsi_cert_utils_get_base_name( break; } } - - /* - * drop all the proxy related /CN=* entries + + /* + * drop all the proxy related /CN=* entries */ for(i=0;iattrs); + result = globus_gsi_cred_handle_attrs_init(&(*handle)->attrs); } else { result = globus_gsi_cred_handle_attrs_copy( - handle_attrs, - & (*handle)->attrs); + handle_attrs, + & (*handle)->attrs); } if(result != GLOBUS_SUCCESS) @@ -130,7 +130,7 @@ globus_gsi_cred_handle_init( * * @param handle * The credential handle to be destroyed - * @return + * @return * GLOBUS_SUCCESS */ globus_result_t @@ -160,7 +160,7 @@ globus_gsi_cred_handle_destroy( globus_libc_free(handle); } - + GLOBUS_I_GSI_CRED_DEBUG_EXIT; return GLOBUS_SUCCESS; @@ -198,7 +198,7 @@ globus_gsi_cred_handle_copy( (_GCRSL("Null parameter passed to function"))); goto exit; } - + if(source->attrs) { result = globus_gsi_cred_handle_init(dest, source->attrs); @@ -254,13 +254,13 @@ globus_gsi_cred_handle_copy( { int chain_index = 0; (*dest)->cert_chain = sk_X509_new_null(); - for(chain_index = 0; - chain_index < sk_X509_num(source->cert_chain); + for(chain_index = 0; + chain_index < sk_X509_num(source->cert_chain); ++chain_index) { - sk_X509_insert((*dest)->cert_chain, + sk_X509_insert((*dest)->cert_chain, X509_dup(sk_X509_value(source->cert_chain, - chain_index)), + chain_index)), chain_index); } } @@ -272,7 +272,7 @@ globus_gsi_cred_handle_copy( GLOBUS_I_GSI_CRED_DEBUG_EXIT; return result; } - + /** * @brief Get the handle attributes * @ingroup globus_gsi_cred_handle @@ -361,7 +361,7 @@ globus_gsi_cred_get_goodtill( GLOBUS_GSI_CRED_ERROR_RESULT( result, GLOBUS_GSI_CRED_ERROR_WITH_CRED, - (_GCRSL("NULL cred handle parameter passed to function: %s"), + (_GCRSL("NULL cred handle parameter passed to function: %s"), __func__)); goto error_exit; } @@ -406,7 +406,7 @@ globus_gsi_cred_get_lifetime( GLOBUS_GSI_CRED_ERROR_RESULT( result, GLOBUS_GSI_CRED_ERROR_WITH_CRED, - (_GCRSL("NULL credential handle passed to function: %s"), + (_GCRSL("NULL credential handle passed to function: %s"), __func__)); goto error_exit; } @@ -437,7 +437,7 @@ globus_gsi_cred_get_lifetime( * @return * GLOBUS_SUCCESS or an error captured in a globus_result_t */ -globus_result_t +globus_result_t globus_gsi_cred_get_key_bits( globus_gsi_cred_handle_t cred_handle, int * key_bits) @@ -452,21 +452,21 @@ globus_gsi_cred_get_key_bits( GLOBUS_GSI_CRED_ERROR_RESULT( result, GLOBUS_GSI_CRED_ERROR_WITH_CRED, - (_GCRSL("NULL cred handle parameter passed to function: %s"), + (_GCRSL("NULL cred handle parameter passed to function: %s"), __func__)); goto error_exit; } - + if(key_bits == NULL) { GLOBUS_GSI_CRED_ERROR_RESULT( result, GLOBUS_GSI_CRED_ERROR_WITH_CRED, - (_GCRSL("NULL key_bits parameter passed to function: %s"), + (_GCRSL("NULL key_bits parameter passed to function: %s"), __func__)); goto error_exit; } - + if(cred_handle->cert == NULL) { GLOBUS_GSI_CRED_OPENSSL_ERROR_RESULT( @@ -475,7 +475,7 @@ globus_gsi_cred_get_key_bits( (_GCRSL("The credential's cert is NULL"))); goto error_exit; } - + pkey = X509_get_pubkey(cred_handle->cert); if(pkey == NULL) { @@ -520,7 +520,7 @@ globus_gsi_cred_get_key_bits( * passed in can be NULL which will set the cert in * the handle to NULL, freeing the current cert in the * handle. - * @return + * @return * GLOBUS_SUCCESS or an error object id if an error */ globus_result_t @@ -537,7 +537,7 @@ globus_gsi_cred_set_cert( GLOBUS_GSI_CRED_ERROR_RESULT( result, GLOBUS_GSI_CRED_ERROR_WITH_CRED, - (_GCRSL("NULL credential handle passed to function: %s"), + (_GCRSL("NULL credential handle passed to function: %s"), __func__)); goto error_exit; } @@ -580,7 +580,7 @@ globus_gsi_cred_set_cert( * @brief Get the credential's certificate * @ingroup globus_gsi_cred_handle * @details - * Get the certificate of a credential + * Get the certificate of a credential * * @param handle * The credential handle to get the certificate from @@ -647,10 +647,10 @@ globus_gsi_cred_get_cert( * * @param handle * The handle on which to set the key. - * @param key + * @param key * The private key to set the handle's key to. This * value can be NULL, in which case the current handle's - * key is freed. + * key is freed. */ globus_result_t globus_gsi_cred_set_key( @@ -720,7 +720,7 @@ globus_gsi_cred_set_key( GLOBUS_I_GSI_CRED_DEBUG_EXIT; return result; -} +} /* globus_gsi_cred_set_key() */ /** @@ -733,9 +733,9 @@ globus_gsi_cred_set_key( * The credential handle containing the private key to get * @param key * The private key which after this function returns is set - * to a duplicate of the private key of the credential + * to a duplicate of the private key of the credential * handle. This variable needs to be freed by the user when - * it is no longer used via the function EVP_PKEY_free. + * it is no longer used via the function EVP_PKEY_free. * * @return * GLOBUS_SUCCESS or an error object identifier @@ -801,7 +801,7 @@ globus_gsi_cred_get_key( return result; } /* globus_gsi_cred_get_key() */ - + /** * @brief Set the certificate chain * @ingroup globus_gsi_cred_handle @@ -865,7 +865,7 @@ globus_gsi_cred_set_cert_chain( (_GCRSL("Couldn't initialize credential's cert chain"))); goto error_exit; } - + for(i = 0; i < numcerts; ++i) { if((tmp_cert = X509_dup(sk_X509_value(cert_chain, i))) == NULL) @@ -940,7 +940,7 @@ globus_gsi_cred_get_cert_chain( GLOBUS_GSI_CRED_ERROR_RESULT( result, GLOBUS_GSI_CRED_ERROR_WITH_CRED, - (_GCRSL("NULL cert chain parameter passed to function: %s"), + (_GCRSL("NULL cert chain parameter passed to function: %s"), __func__)); goto error_exit; } @@ -988,7 +988,7 @@ globus_gsi_cred_get_cert_chain( * @param subject_name * The subject name as an X509_NAME object. This should be freed * using X509_NAME_free when the user is finished with it - * @return + * @return * GLOBUS_SUCCESS if no error, a error object id otherwise */ globus_result_t @@ -1014,12 +1014,12 @@ globus_gsi_cred_get_X509_subject_name( GLOBUS_GSI_CRED_ERROR_RESULT( result, GLOBUS_GSI_CRED_ERROR_WITH_CRED, - (_GCRSL("NULL subject name parameter passed to function: %s"), + (_GCRSL("NULL subject name parameter passed to function: %s"), __func__)); goto error_exit; } - if((*subject_name = + if((*subject_name = X509_NAME_dup(X509_get_subject_name(handle->cert))) == NULL) { GLOBUS_GSI_CRED_OPENSSL_ERROR_RESULT( @@ -1064,7 +1064,7 @@ globus_gsi_cred_get_X509_identity_name( STACK_OF(X509) * cert_chain = NULL; GLOBUS_I_GSI_CRED_DEBUG_ENTER; - + if(handle == NULL) { GLOBUS_GSI_CRED_ERROR_RESULT( @@ -1082,7 +1082,7 @@ globus_gsi_cred_get_X509_identity_name( (_GCRSL("NULL identity name passed to function: %s"), __func__)); goto error_exit; } - + identity = X509_NAME_dup(X509_get_subject_name(handle->cert)); if(handle->cert_chain == NULL) @@ -1120,7 +1120,7 @@ globus_gsi_cred_get_X509_identity_name( { sk_X509_free(cert_chain); } - + GLOBUS_I_GSI_CRED_DEBUG_EXIT; return result; } @@ -1138,7 +1138,7 @@ globus_gsi_cred_get_X509_identity_name( * @param subject_name * The subject name as a string. This should be freed * using OPENSSL_free() when the user is finished with it - * @return + * @return * GLOBUS_SUCCESS if no error, a error object id otherwise */ globus_result_t @@ -1161,7 +1161,7 @@ globus_gsi_cred_get_subject_name( } /* ToDo: This logic needs fixing. The subject_name is passed up and is - freed by the caller - but it must be freed with OPENSSL_free(), + freed by the caller - but it must be freed with OPENSSL_free(), not free() and the caller cant be expected to know that */ if((*subject_name = X509_NAME_oneline(x509_subject, NULL, 0)) == NULL) { @@ -1202,7 +1202,7 @@ globus_gsi_cred_get_subject_name( * the stack of policies retrieved from the handle's cert chain * @return * GLOBUS_SUCCESS or an error object if an error occurred - */ + */ globus_result_t globus_gsi_cred_get_policies( globus_gsi_cred_handle_t handle, @@ -1263,7 +1263,7 @@ globus_gsi_cred_get_policies( { /* no proxycertinfo extension = so no policy for this cert */ policy_string = (unsigned char *) GLOBUS_NULL_POLICY; - policy_string_length = strlen(GLOBUS_NULL_POLICY); + policy_string_length = strlen(GLOBUS_NULL_POLICY); } else { @@ -1278,7 +1278,7 @@ globus_gsi_cred_get_policies( goto exit; } memcpy(policy_string, - ASN1_STRING_data(policy->policy), + ASN1_STRING_get0_data(policy->policy), policy_string_length); } @@ -1311,7 +1311,7 @@ globus_gsi_cred_get_policies( goto error_exit; } - final_policy_string = NULL; + final_policy_string = NULL; PROXY_CERT_INFO_EXTENSION_free(pci); pci = NULL; @@ -1336,9 +1336,9 @@ globus_gsi_cred_get_policies( sk_OPENSSL_STRING_pop_free(*policies, (void (*) (char *)) free); } *policies = NULL; - + exit: - + if(pci != NULL) { PROXY_CERT_INFO_EXTENSION_free(pci); @@ -1362,7 +1362,7 @@ globus_gsi_cred_get_policies( * the stack of policies retrieved from the handle's cert chain * @return * GLOBUS_SUCCESS or an error object if an error occurred - */ + */ globus_result_t globus_gsi_cred_get_policy_languages( globus_gsi_cred_handle_t handle, @@ -1419,7 +1419,7 @@ globus_gsi_cred_get_policy_languages( if(pci == NULL || (policy = pci->proxyPolicy) == NULL) { - /* no proxycertinfo extension, so no policy + /* no proxycertinfo extension, so no policy * language for this cert */ policy_language = GLOBUS_NULL; } @@ -1428,7 +1428,7 @@ globus_gsi_cred_get_policy_languages( policy_language = policy->policyLanguage; } - if(sk_ASN1_OBJECT_push(*policy_languages, + if(sk_ASN1_OBJECT_push(*policy_languages, OBJ_dup(policy_language)) == 0) { GLOBUS_GSI_CRED_OPENSSL_ERROR_RESULT( @@ -1454,9 +1454,9 @@ globus_gsi_cred_get_policy_languages( } *policy_languages = NULL; - + exit: - + GLOBUS_I_GSI_CRED_DEBUG_EXIT; return result; @@ -1475,7 +1475,7 @@ globus_gsi_cred_get_policy_languages( * @param issuer_name * The issuer name as an X509_NAME object. This should be freed * using X509_NAME_free when the user is finished with it - * @return + * @return * GLOBUS_SUCCESS if no error, a error object id otherwise */ globus_result_t @@ -1501,12 +1501,12 @@ globus_gsi_cred_get_X509_issuer_name( GLOBUS_GSI_CRED_ERROR_RESULT( result, GLOBUS_GSI_CRED_ERROR_WITH_CRED, - (_GCRSL("NULL issuer name parameter passed to function: %s"), + (_GCRSL("NULL issuer name parameter passed to function: %s"), __func__)); goto error_exit; } - if((*issuer_name = + if((*issuer_name = X509_NAME_dup(X509_get_issuer_name(handle->cert))) == NULL) { GLOBUS_GSI_CRED_OPENSSL_ERROR_RESULT( @@ -1567,9 +1567,9 @@ globus_gsi_cred_get_issuer_name( (_GCRSL("NULL issuer name passed to function: %s"), __func__)); goto error_exit; } - + /* TODO: This logic needs fixing. The issuer_name is passed up and is - freed by the caller - but it must be freed with OPENSSL_free(), + freed by the caller - but it must be freed with OPENSSL_free(), not free() and the caller cant be expected to know that */ if((*issuer_name = X509_NAME_oneline( X509_get_issuer_name(handle->cert), NULL, 0)) == NULL) @@ -1580,9 +1580,9 @@ globus_gsi_cred_get_issuer_name( (_GCRSL("Couldn't get subject name of credential's cert"))); goto error_exit; } - + result = GLOBUS_SUCCESS; - + error_exit: GLOBUS_I_GSI_CRED_DEBUG_EXIT; @@ -1635,7 +1635,7 @@ globus_gsi_cred_get_identity_name( } result = globus_gsi_cred_get_X509_identity_name(handle, &identity); - + if(result != GLOBUS_SUCCESS) { GLOBUS_GSI_CRED_ERROR_CHAIN_RESULT( @@ -1645,7 +1645,7 @@ globus_gsi_cred_get_identity_name( } /* ToDo: This logic needs fixing. The identity_name is passed up and is - freed by the caller - but it must be freed with OPENSSL_free(), + freed by the caller - but it must be freed with OPENSSL_free(), not free() and the caller cant be expected to know that */ *identity_name = X509_NAME_oneline(identity, NULL, 0); @@ -1656,7 +1656,7 @@ globus_gsi_cred_get_identity_name( GLOBUS_GSI_CRED_ERROR_WITH_CRED_CERT_NAME, (_GCRSL("Unable to convert X509_NAME to string"))); } - + error_exit: if(identity) @@ -1700,7 +1700,7 @@ globus_gsi_cred_verify_cert_chain( globus_result_t result = GLOBUS_SUCCESS; GLOBUS_I_GSI_CRED_DEBUG_ENTER; - + cert_store = X509_STORE_new(); if (cert_store == NULL) { @@ -1710,7 +1710,7 @@ globus_gsi_cred_verify_cert_chain( goto exit; } - X509_STORE_set_verify_cb_func(cert_store, + X509_STORE_set_verify_cb_func(cert_store, globus_gsi_callback_create_proxy_callback); X509_STORE_set_depth(cert_store, GLOBUS_GSI_CALLBACK_VERIFY_DEPTH); @@ -1725,7 +1725,7 @@ globus_gsi_cred_verify_cert_chain( tmp_cert = cred_handle->cert; cert = tmp_cert; - + if (X509_STORE_load_locations(cert_store, NULL, cert_dir)) { #if OPENSSL_VERSION_NUMBER < 0x10100000L @@ -1746,17 +1746,17 @@ globus_gsi_cred_verify_cert_chain( X509_STORE_CTX_set_ex_data( store_context, - callback_data_index, + callback_data_index, (void *)callback_data); - + /* * If this is not set, OpenSSL-0.9.8 (check_chain_extensions() * called by x509_verify_cert()) treats the cert next to proxy * in the chain to be CA cert and throws invalid CA error - */ + */ #if defined(X509_V_FLAG_ALLOW_PROXY_CERTS) - X509_STORE_CTX_set_flags( + X509_STORE_CTX_set_flags( store_context, X509_V_FLAG_ALLOW_PROXY_CERTS); #endif @@ -1783,7 +1783,7 @@ globus_gsi_cred_verify_cert_chain( { local_result = callback_error; } - + result = globus_i_gsi_cred_error_join_chains_result( result, local_result); @@ -1791,7 +1791,7 @@ globus_gsi_cred_verify_cert_chain( goto exit; } } - + exit: if(cert_store) @@ -1852,8 +1852,8 @@ globus_gsi_cred_verify_cert_chain_when( globus_result_t result = GLOBUS_SUCCESS; GLOBUS_I_GSI_CRED_DEBUG_ENTER; - - + + if(callback_data_in != NULL) { callback_data = callback_data_in; @@ -1861,7 +1861,7 @@ globus_gsi_cred_verify_cert_chain_when( else { char * certdir = NULL; - + /* initialize the callback data */ result = globus_gsi_callback_data_init(&callback_data); if(result != GLOBUS_SUCCESS) @@ -1869,8 +1869,8 @@ globus_gsi_cred_verify_cert_chain_when( GLOBUS_GSI_CRED_ERROR_CHAIN_RESULT( result, GLOBUS_GSI_CRED_ERROR_WITH_CALLBACK_DATA); goto exit; - } - + } + /* set the cert_dir in the callback data */ result = GLOBUS_GSI_SYSCONFIG_GET_CERT_DIR(&certdir); if(result != GLOBUS_SUCCESS) @@ -1882,7 +1882,7 @@ globus_gsi_cred_verify_cert_chain_when( if(certdir) { result = globus_gsi_callback_set_cert_dir( - callback_data, + callback_data, certdir); free(certdir); if(result != GLOBUS_SUCCESS) @@ -1893,7 +1893,7 @@ globus_gsi_cred_verify_cert_chain_when( } } } - + cert_store = X509_STORE_new(); if(cert_store == NULL) { @@ -1902,7 +1902,7 @@ globus_gsi_cred_verify_cert_chain_when( goto exit; } - X509_STORE_set_verify_cb_func(cert_store, + X509_STORE_set_verify_cb_func(cert_store, globus_gsi_callback_create_proxy_callback); X509_STORE_set_depth(cert_store, GLOBUS_GSI_CALLBACK_VERIFY_DEPTH); @@ -1917,7 +1917,7 @@ globus_gsi_cred_verify_cert_chain_when( tmp_cert = cred_handle->cert; cert = tmp_cert; - + if (X509_STORE_load_locations(cert_store, NULL, cert_dir)) { /* override the check_issued with our version */ @@ -1938,17 +1938,17 @@ globus_gsi_cred_verify_cert_chain_when( X509_STORE_CTX_set_ex_data( store_context, - callback_data_index, + callback_data_index, (void *)callback_data); - + /* * If this is not set, OpenSSL-0.9.8 (check_chain_extensions() * called by x509_verify_cert()) treats the cert next to proxy * in the chain to be CA cert and throws invalid CA error - */ + */ #if defined(X509_V_FLAG_ALLOW_PROXY_CERTS) - X509_STORE_CTX_set_flags( + X509_STORE_CTX_set_flags( store_context, X509_V_FLAG_ALLOW_PROXY_CERTS); #endif @@ -1985,7 +1985,7 @@ globus_gsi_cred_verify_cert_chain_when( { local_result = callback_error; } - + result = globus_i_gsi_cred_error_join_chains_result( result, local_result); @@ -1993,14 +1993,14 @@ globus_gsi_cred_verify_cert_chain_when( goto exit; } } - + exit: if(callback_data && !callback_data_in) { globus_gsi_callback_data_destroy(callback_data); } - + if(cert_store) { X509_STORE_free(cert_store); @@ -2069,7 +2069,7 @@ globus_gsi_cred_verify( (_GCRSL("Error getting public key from issuer certificate"))); goto error; } - + if(!X509_verify(handle->cert,issuer_pkey)) { GLOBUS_GSI_CRED_OPENSSL_ERROR_RESULT( @@ -2081,7 +2081,7 @@ globus_gsi_cred_verify( EVP_PKEY_free(issuer_pkey); error: - + GLOBUS_I_GSI_CRED_DEBUG_EXIT; return result; } @@ -2124,11 +2124,11 @@ globus_i_gsi_cred_goodtill( { cert_count = sk_X509_num(cred_handle->cert_chain); } - + while(current_cert) { result = globus_gsi_cert_utils_make_time( - X509_get_notAfter(current_cert), + X509_get_notAfter(current_cert), &tmp_goodtill); if(result != GLOBUS_SUCCESS) { @@ -2142,7 +2142,7 @@ globus_i_gsi_cred_goodtill( { *goodtill = tmp_goodtill; } - + if(cred_handle->cert_chain && cert_count) { cert_count--; diff --git a/gsi/credential/source/library/globus_gsi_credential.c b/gsi/credential/source/library/globus_gsi_credential.c index ee83d55ec9..319c7a7a9b 100644 --- a/gsi/credential/source/library/globus_gsi_credential.c +++ b/gsi/credential/source/library/globus_gsi_credential.c @@ -70,7 +70,7 @@ globus_l_gsi_credential_activate(void) if(tmp_string != GLOBUS_NULL) { globus_i_gsi_cred_debug_level = atoi(tmp_string); - + if(globus_i_gsi_cred_debug_level < 0) { globus_i_gsi_cred_debug_level = 0; @@ -101,7 +101,7 @@ globus_l_gsi_credential_activate(void) { goto exit; } - + result = globus_module_activate(GLOBUS_GSI_SYSCONFIG_MODULE); if(result != GLOBUS_SUCCESS) @@ -115,11 +115,11 @@ globus_l_gsi_credential_activate(void) { goto exit; } - + OpenSSL_add_all_algorithms(); GLOBUS_I_GSI_CRED_DEBUG_EXIT; - + exit: return result; @@ -173,7 +173,7 @@ globus_l_gsi_cred_subject_cmp( * @details * Read a credential from a filesystem location. The credential * to read will be determined by the search order specified in the handle - * attributes. + * attributes. * @param handle * The credential handle to set. This credential handle * should already be initialized using globus_gsi_cred_handle_init. @@ -211,7 +211,7 @@ globus_gsi_cred_read( char * key = NULL; char * proxy = NULL; char * service_name = NULL; - + GLOBUS_I_GSI_CRED_DEBUG_ENTER; for(result_index = 0; result_index < 4; ++result_index) @@ -238,7 +238,7 @@ globus_gsi_cred_read( case GLOBUS_PROXY: results[result_index] = GLOBUS_GSI_SYSCONFIG_GET_PROXY_FILENAME( - &proxy, + &proxy, GLOBUS_PROXY_FILE_INPUT); if(results[result_index] != GLOBUS_SUCCESS) { @@ -248,7 +248,7 @@ globus_gsi_cred_read( GLOBUS_GSI_CRED_ERROR_READING_PROXY_CRED); break; } - + results[result_index] = globus_gsi_cred_read_proxy(handle, proxy); if(results[result_index] != GLOBUS_SUCCESS) { @@ -257,11 +257,11 @@ globus_gsi_cred_read( GLOBUS_GSI_CRED_ERROR_READING_PROXY_CRED); goto exit; } - + if(desired_subject != NULL) { results[result_index] = globus_gsi_cred_get_X509_subject_name( - handle, + handle, &found_subject); if(results[result_index] != GLOBUS_SUCCESS) { @@ -275,8 +275,8 @@ globus_gsi_cred_read( desired_subject); X509_NAME_free(found_subject); - found_subject = NULL; - + found_subject = NULL; + if(results[result_index] != GLOBUS_SUCCESS) { GLOBUS_GSI_CRED_ERROR_CHAIN_RESULT( @@ -296,15 +296,15 @@ globus_gsi_cred_read( GLOBUS_GSI_CRED_ERROR_WITH_CRED); goto exit; } - + if(lifetime <= 0) { char * subject = NULL; - + subject = X509_NAME_oneline( X509_get_subject_name(handle->cert), NULL, 0); - + GLOBUS_GSI_CRED_ERROR_RESULT( results[result_index], GLOBUS_GSI_CRED_ERROR_WITH_CRED, @@ -313,18 +313,18 @@ globus_gsi_cred_read( proxy, subject, (-lifetime)/60)); - + OPENSSL_free(subject); goto exit; } GLOBUS_I_GSI_CRED_DEBUG_FPRINTF(1, (globus_i_gsi_cred_debug_fstream, - "Using Proxy file (%s)\n", proxy)); + "Using Proxy file (%s)\n", proxy)); goto exit; case GLOBUS_USER: - - results[result_index] = + + results[result_index] = GLOBUS_GSI_SYSCONFIG_GET_USER_CERT_FILENAME(&cert, &key); if(results[result_index] != GLOBUS_SUCCESS) { @@ -334,7 +334,7 @@ globus_gsi_cred_read( results[result_index], GLOBUS_GSI_CRED_ERROR_READING_CRED); break; - } + } results[result_index] = globus_gsi_cred_read_cert(handle, cert); if(results[result_index] != GLOBUS_SUCCESS) @@ -346,14 +346,14 @@ globus_gsi_cred_read( } results[result_index] = globus_gsi_cred_read_key( - handle, - key, + handle, + key, globus_i_gsi_cred_password_callback_no_prompt); if(results[result_index] != GLOBUS_SUCCESS) { globus_object_t * error_obj; error_obj = globus_error_peek(results[result_index]); - if(globus_error_get_type(error_obj) == + if(globus_error_get_type(error_obj) == GLOBUS_GSI_CRED_ERROR_KEY_IS_PASS_PROTECTED) { GLOBUS_GSI_CRED_ERROR_CHAIN_RESULT( @@ -382,7 +382,7 @@ globus_gsi_cred_read( if(desired_subject != NULL) { results[result_index] = globus_gsi_cred_get_X509_subject_name( - handle, + handle, &found_subject); if(results[result_index] != GLOBUS_SUCCESS) { @@ -391,14 +391,14 @@ globus_gsi_cred_read( GLOBUS_GSI_CRED_ERROR_READING_CRED); goto exit; } - + results[result_index] = globus_l_gsi_cred_subject_cmp( found_subject, desired_subject); X509_NAME_free(found_subject); found_subject = NULL; - + if(results[result_index] != GLOBUS_SUCCESS) { GLOBUS_GSI_CRED_ERROR_CHAIN_RESULT( @@ -418,15 +418,15 @@ globus_gsi_cred_read( GLOBUS_GSI_CRED_ERROR_WITH_CRED); goto exit; } - + if(lifetime <= 0) { char * subject = NULL; - + subject = X509_NAME_oneline( X509_get_subject_name(handle->cert), NULL, 0); - + GLOBUS_GSI_CRED_ERROR_RESULT( results[result_index], GLOBUS_GSI_CRED_ERROR_WITH_CRED, @@ -435,18 +435,18 @@ globus_gsi_cred_read( cert, subject, (-lifetime)/60)); - + OPENSSL_free(subject); goto exit; } GLOBUS_I_GSI_CRED_DEBUG_FPRINTF(1, (globus_i_gsi_cred_debug_fstream, - "Using User cert file (%s), key file (%s)\n", cert, key)); + "Using User cert file (%s), key file (%s)\n", cert, key)); goto exit; case GLOBUS_HOST: - - results[result_index] = + + results[result_index] = GLOBUS_GSI_SYSCONFIG_GET_HOST_CERT_FILENAME(&cert, &key); if(results[result_index] != GLOBUS_SUCCESS) { @@ -456,7 +456,7 @@ globus_gsi_cred_read( results[result_index], GLOBUS_GSI_CRED_ERROR_READING_HOST_CRED); break; - } + } results[result_index] = globus_gsi_cred_read_cert(handle, cert); if(results[result_index] != GLOBUS_SUCCESS) @@ -468,14 +468,14 @@ globus_gsi_cred_read( } results[result_index] = globus_gsi_cred_read_key( - handle, - key, + handle, + key, globus_i_gsi_cred_password_callback_no_prompt); if(results[result_index] != GLOBUS_SUCCESS) { globus_object_t * error_obj; error_obj = globus_error_peek(results[result_index]); - if(globus_error_get_type(error_obj) == + if(globus_error_get_type(error_obj) == GLOBUS_GSI_CRED_ERROR_KEY_IS_PASS_PROTECTED) { GLOBUS_GSI_CRED_ERROR_CHAIN_RESULT( @@ -504,9 +504,9 @@ globus_gsi_cred_read( if(desired_subject != NULL) { results[result_index] = globus_gsi_cred_get_X509_subject_name( - handle, + handle, &found_subject); - + if(results[result_index] != GLOBUS_SUCCESS) { GLOBUS_GSI_CRED_ERROR_CHAIN_RESULT( @@ -514,13 +514,13 @@ globus_gsi_cred_read( GLOBUS_GSI_CRED_ERROR_READING_HOST_CRED); goto exit; } - + results[result_index] = globus_l_gsi_cred_subject_cmp(found_subject, desired_subject); X509_NAME_free(found_subject); - found_subject = NULL; - + found_subject = NULL; + if(results[result_index] != GLOBUS_SUCCESS) { GLOBUS_GSI_CRED_ERROR_CHAIN_RESULT( @@ -529,7 +529,7 @@ globus_gsi_cred_read( goto exit; } } - + results[result_index] = globus_gsi_cred_get_lifetime( handle, &lifetime); @@ -540,15 +540,15 @@ globus_gsi_cred_read( GLOBUS_GSI_CRED_ERROR_WITH_CRED); goto exit; } - + if(lifetime <= 0) { char * subject = NULL; - + subject = X509_NAME_oneline( X509_get_subject_name(handle->cert), NULL, 0); - + GLOBUS_GSI_CRED_ERROR_RESULT( results[result_index], GLOBUS_GSI_CRED_ERROR_WITH_CRED, @@ -557,23 +557,23 @@ globus_gsi_cred_read( cert, subject, (-lifetime)/60)); - + OPENSSL_free(subject); goto exit; } GLOBUS_I_GSI_CRED_DEBUG_FPRINTF(1, (globus_i_gsi_cred_debug_fstream, - "Using Host cert file (%s), key file (%s)\n", cert, key)); + "Using Host cert file (%s), key file (%s)\n", cert, key)); goto exit; - + case GLOBUS_SERVICE: if(desired_subject != NULL) - { + { results[result_index] = globus_l_gsi_cred_get_service(desired_subject, &service_name); - + if(results[result_index] != GLOBUS_SUCCESS) { service_name = NULL; @@ -581,9 +581,9 @@ globus_gsi_cred_read( results[result_index], GLOBUS_GSI_CRED_ERROR_READING_SERVICE_CRED); break; - } - - results[result_index] = + } + + results[result_index] = GLOBUS_GSI_SYSCONFIG_GET_SERVICE_CERT_FILENAME( service_name, &cert, &key); if(results[result_index] != GLOBUS_SUCCESS) @@ -594,9 +594,9 @@ globus_gsi_cred_read( results[result_index], GLOBUS_GSI_CRED_ERROR_READING_SERVICE_CRED); break; - } + } - results[result_index] = + results[result_index] = globus_gsi_cred_read_cert(handle, cert); if(results[result_index] != GLOBUS_SUCCESS) { @@ -605,16 +605,16 @@ globus_gsi_cred_read( GLOBUS_GSI_CRED_ERROR_READING_SERVICE_CRED); goto exit; } - + results[result_index] = globus_gsi_cred_read_key( - handle, - key, + handle, + key, globus_i_gsi_cred_password_callback_no_prompt); if(results[result_index] != GLOBUS_SUCCESS) { globus_object_t * error_obj; error_obj = globus_error_peek(results[result_index]); - if(globus_error_get_type(error_obj) == + if(globus_error_get_type(error_obj) == GLOBUS_GSI_CRED_ERROR_KEY_IS_PASS_PROTECTED) { GLOBUS_GSI_CRED_ERROR_CHAIN_RESULT( @@ -628,7 +628,7 @@ globus_gsi_cred_read( GLOBUS_GSI_CRED_ERROR_READING_SERVICE_CRED); goto exit; } - + results[result_index] = globus_i_gsi_cred_goodtill( handle, &(handle->goodtill)); @@ -643,7 +643,7 @@ globus_gsi_cred_read( if(desired_subject != NULL) { results[result_index] = globus_gsi_cred_get_X509_subject_name( - handle, + handle, &found_subject); if(results[result_index] != GLOBUS_SUCCESS) { @@ -652,13 +652,13 @@ globus_gsi_cred_read( GLOBUS_GSI_CRED_ERROR_READING_SERVICE_CRED); goto exit; } - + results[result_index] = globus_l_gsi_cred_subject_cmp(found_subject, desired_subject); X509_NAME_free(found_subject); - found_subject = NULL; - + found_subject = NULL; + if(results[result_index] != GLOBUS_SUCCESS) { GLOBUS_GSI_CRED_ERROR_CHAIN_RESULT( @@ -667,7 +667,7 @@ globus_gsi_cred_read( break; } } - + results[result_index] = globus_gsi_cred_get_lifetime( handle, &lifetime); @@ -678,15 +678,15 @@ globus_gsi_cred_read( GLOBUS_GSI_CRED_ERROR_WITH_CRED); goto exit; } - + if(lifetime <= 0) { char * subject = NULL; - + subject = X509_NAME_oneline( X509_get_subject_name(handle->cert), NULL, 0); - + GLOBUS_GSI_CRED_ERROR_RESULT( results[result_index], GLOBUS_GSI_CRED_ERROR_WITH_CRED, @@ -695,13 +695,13 @@ globus_gsi_cred_read( cert, subject, (-lifetime)/60)); - + OPENSSL_free(subject); goto exit; } GLOBUS_I_GSI_CRED_DEBUG_FPRINTF(1, (globus_i_gsi_cred_debug_fstream, - "Using Service cert file (%s), key file (%s)\n", cert, key)); + "Using Service cert file (%s), key file (%s)\n", cert, key)); goto exit; } else @@ -709,17 +709,17 @@ globus_gsi_cred_read( result_index--; break; } - + case GLOBUS_SO_END: { globus_object_t * multiple_obj; - + multiple_obj = globus_error_construct_multiple( GLOBUS_GSI_CREDENTIAL_MODULE, GLOBUS_GSI_CRED_ERROR_NO_CRED_FOUND, _GCRSL(globus_l_gsi_cred_error_strings[ GLOBUS_GSI_CRED_ERROR_NO_CRED_FOUND])); - + while(result_index--) { globus_error_mutliple_add_chain( @@ -728,11 +728,11 @@ globus_gsi_cred_read( _GCRSL("Attempt %d"), result_index + 1); } - + result_index = 0; results[result_index] = globus_error_put(multiple_obj); } - + GLOBUS_GSI_CRED_ERROR_CHAIN_RESULT( results[result_index], GLOBUS_GSI_CRED_ERROR_NO_CRED_FOUND); @@ -744,28 +744,28 @@ globus_gsi_cred_read( free(proxy); proxy = NULL; } - + if(cert) { free(cert); cert = NULL; } - + if(key) { free(key); key = NULL; } - + if(service_name) { free(service_name); service_name = NULL; } - + result_index++; } while(++index); - + exit: result = results[result_index]; @@ -783,7 +783,7 @@ globus_gsi_cred_read( { free(proxy); } - + if(cert) { free(cert); @@ -793,7 +793,7 @@ globus_gsi_cred_read( { free(key); } - + if(service_name) { free(service_name); @@ -826,7 +826,7 @@ globus_gsi_cred_read_proxy( { BIO * proxy_bio = NULL; globus_result_t result; - + GLOBUS_I_GSI_CRED_DEBUG_ENTER; if(handle == NULL) @@ -874,10 +874,10 @@ globus_gsi_cred_read_proxy( * @brief Read proxy credential from a BIO * @ingroup globus_gsi_cred_operations * @details - * Read a Proxy Credential from a BIO stream and set the + * Read a Proxy Credential from a BIO stream and set the * credential handle to represent the read credential. * The values read from the stream, in order, will be - * the signed certificate, the private key, + * the signed certificate, the private key, * and the certificate chain. * * @param handle @@ -1118,7 +1118,7 @@ globus_gsi_cred_read_proxy_bio( * @param key_filename * the filename of the key to read * @param pw_cb - * the callback for obtaining a password for decrypting the key. + * the callback for obtaining a password for decrypting the key. * * @return * GLOBUS_SUCCESS or an error object identifier @@ -1152,7 +1152,7 @@ globus_gsi_cred_read_key( "key file: %s for reading"), key_filename)); goto exit; } - + /* read in the key */ if(handle->key != NULL) @@ -1294,7 +1294,7 @@ globus_gsi_cred_read_cert_bio( } /* read in the cert */ - + if(handle->cert != NULL) { X509_free(handle->cert); @@ -1314,7 +1314,7 @@ globus_gsi_cred_read_cert_bio( { sk_X509_pop_free(handle->cert_chain, X509_free); } - + if((handle->cert_chain = sk_X509_new_null()) == NULL) { GLOBUS_GSI_CRED_OPENSSL_ERROR_RESULT( @@ -1323,7 +1323,7 @@ globus_gsi_cred_read_cert_bio( (_GCRSL("Can't initialize cert chain\n"))); goto exit; } - + while(!BIO_eof(bio)) { X509 * tmp_cert = NULL; @@ -1346,7 +1346,7 @@ globus_gsi_cred_read_cert_bio( } ++i; } - + result = globus_i_gsi_cred_goodtill(handle, &(handle->goodtill)); if(result != GLOBUS_SUCCESS) @@ -1356,7 +1356,7 @@ globus_gsi_cred_read_cert_bio( GLOBUS_GSI_CRED_ERROR_WITH_CRED); goto exit; } - + result = GLOBUS_SUCCESS; exit: @@ -1415,19 +1415,19 @@ globus_gsi_cred_read_cert_buffer( bp = BIO_new(BIO_s_mem()); BIO_write(bp, pem_buf, strlen(pem_buf)); - + result = globus_gsi_cred_handle_init(&handle, NULL); if(result != GLOBUS_SUCCESS) { goto error; } - + result = globus_gsi_cred_read_cert_bio(handle, bp); if(result != GLOBUS_SUCCESS) { goto error; } - + if(out_cert) { result = globus_gsi_cred_get_cert(handle, &cert); @@ -1437,7 +1437,7 @@ globus_gsi_cred_read_cert_buffer( } *out_cert = cert; } - + if(out_cert_chain) { result = globus_gsi_cred_get_cert_chain(handle, &cert_chain); @@ -1447,7 +1447,7 @@ globus_gsi_cred_read_cert_buffer( } *out_cert_chain = cert_chain; } - + if(out_subject) { result = globus_gsi_cred_get_identity_name(handle, &subject); @@ -1455,9 +1455,9 @@ globus_gsi_cred_read_cert_buffer( { goto error; } - *out_subject = subject; + *out_subject = subject; } - + if(out_handle) { *out_handle = handle; @@ -1466,11 +1466,11 @@ globus_gsi_cred_read_cert_buffer( { globus_gsi_cred_handle_destroy(handle); } - + BIO_free(bp); return GLOBUS_SUCCESS; - + error: if(bp) { @@ -1495,7 +1495,7 @@ globus_gsi_cred_read_cert_buffer( { globus_gsi_cred_handle_destroy(handle); } - + return result; } /* globus_gsi_cred_read_cert_buffer() */ @@ -1529,6 +1529,7 @@ globus_gsi_cred_read_pkcs12( PKCS7 * pkcs7 = NULL; STACK_OF(PKCS7) * auth_safes = NULL; PKCS8_PRIV_KEY_INFO * pkcs8 = NULL; + const PKCS8_PRIV_KEY_INFO * pkcs8c = NULL; BIO * pkcs12_bio = NULL; int i, j, bag_NID; @@ -1542,7 +1543,7 @@ globus_gsi_cred_read_pkcs12( (_GCRSL("NULL handle passed to function: %s"), __func__)); goto exit; } - + pkcs12_bio = BIO_new_file(pkcs12_filename, "r"); if(!pkcs12_bio) { @@ -1575,7 +1576,7 @@ globus_gsi_cred_read_pkcs12( } auth_safes = PKCS12_unpack_authsafes(pkcs12); - + if(!auth_safes) { GLOBUS_GSI_CRED_OPENSSL_ERROR_RESULT( @@ -1586,13 +1587,13 @@ globus_gsi_cred_read_pkcs12( } pkcs12_certs = sk_X509_new_null(); - + for (i = 0; i < sk_PKCS7_num(auth_safes); i++) { pkcs7 = sk_PKCS7_value(auth_safes, i); - + bag_NID = OBJ_obj2nid(pkcs7->type); - + if(bag_NID == NID_pkcs7_data) { pkcs12_safebags = PKCS12_unpack_p7data(pkcs7); @@ -1624,18 +1625,18 @@ globus_gsi_cred_read_pkcs12( for (j = 0; j < sk_PKCS12_SAFEBAG_num(pkcs12_safebags); j++) { bag = sk_PKCS12_SAFEBAG_value(pkcs12_safebags, j); - + if(PKCS12_bag_type(bag) == NID_certBag && PKCS12_cert_bag_type(bag) == NID_x509Certificate) { - sk_X509_push(pkcs12_certs, + sk_X509_push(pkcs12_certs, PKCS12_certbag2x509(bag)); } else if(PKCS12_bag_type(bag) == NID_keyBag && handle->key == NULL) { - pkcs8 = PKCS12_SAFEBAG_get0_p8inf(bag); - handle->key = EVP_PKCS82PKEY(pkcs8); + pkcs8c = PKCS12_SAFEBAG_get0_p8inf(bag); + handle->key = EVP_PKCS82PKEY(pkcs8c); if (!handle->key) { GLOBUS_GSI_CRED_OPENSSL_ERROR_RESULT( @@ -1646,7 +1647,7 @@ globus_gsi_cred_read_pkcs12( goto exit; } } - else if(PKCS12_bag_type(bag) == + else if(PKCS12_bag_type(bag) == NID_pkcs8ShroudedKeyBag && handle->key == NULL) { @@ -1661,7 +1662,7 @@ globus_gsi_cred_read_pkcs12( (_GCRSL("Couldn't get PKCS8 key from PKCS12 credential"))); goto exit; } - + handle->key = EVP_PKCS82PKEY(pkcs8); if (!handle->key) { @@ -1671,7 +1672,7 @@ globus_gsi_cred_read_pkcs12( (_GCRSL("Couldn't get private key from PKCS12 credential"))); goto exit; } - + PKCS8_PRIV_KEY_INFO_free(pkcs8); } } @@ -1687,12 +1688,12 @@ globus_gsi_cred_read_pkcs12( goto exit; } - j = sk_X509_num(pkcs12_certs); + j = sk_X509_num(pkcs12_certs); for(i = 0 ; i < j; i++) { handle->cert = sk_X509_pop(pkcs12_certs); - if(X509_check_private_key(handle->cert, handle->key)) + if(X509_check_private_key(handle->cert, handle->key)) { sk_X509_pop_free(pkcs12_certs, X509_free); pkcs12_certs = NULL; @@ -1752,7 +1753,7 @@ globus_gsi_cred_read_pkcs12( * Write out a credential to a BIO. The credential parameters written, * in order, are the signed certificate, the RSA private key, * and the certificate chain (a set of X509 certificates). - * the credential is written out in PEM format. + * the credential is written out in PEM format. * * @param handle * The credential to write out @@ -1780,7 +1781,7 @@ globus_gsi_cred_write( (_GCRSL("NULL handle passed to function: %s"), __func__)); goto error_exit; } - + if(bio == NULL) { GLOBUS_GSI_CRED_ERROR_RESULT( @@ -1789,7 +1790,7 @@ globus_gsi_cred_write( (_GCRSL("NULL bio variable passed to function: %s"), __func__)); goto error_exit; } - + if(!PEM_write_bio_X509(bio, handle->cert)) { GLOBUS_GSI_CRED_OPENSSL_ERROR_RESULT( @@ -1798,7 +1799,7 @@ globus_gsi_cred_write( (_GCRSL("Can't write PEM formatted X509 cert to BIO stream"))); goto error_exit; } - + if(!PEM_write_bio_PrivateKey(bio, handle->key, NULL, NULL, 0, NULL, NULL)) { @@ -1808,7 +1809,7 @@ globus_gsi_cred_write( (_GCRSL("Can't write PEM formatted private key to BIO stream"))); goto error_exit; } - + for(i = 0; i < sk_X509_num(handle->cert_chain); ++i) { if(!PEM_write_bio_X509(bio, sk_X509_value(handle->cert_chain, i))) @@ -1821,14 +1822,14 @@ globus_gsi_cred_write( goto error_exit; } } - + error_exit: GLOBUS_I_GSI_CRED_DEBUG_EXIT; return result; -} +} /* globus_gsi_cred_write() */ - + /** * @brief Write a proxy credential * @ingroup globus_gsi_cred_operations @@ -1836,7 +1837,7 @@ globus_gsi_cred_write( * Write out a credential to a file. The credential parameters written, * in order, are the signed certificate, the RSA private key, * and the certificate chain (a set of X509 certificates). - * the credential is written out in PEM format. + * the credential is written out in PEM format. * * @param handle * The credential to write out @@ -1856,7 +1857,7 @@ globus_gsi_cred_write_proxy( mode_t oldmask; FILE * temp_proxy_fp = NULL; int temp_proxy_fd = -1; - + GLOBUS_I_GSI_CRED_DEBUG_ENTER; /* @@ -1873,10 +1874,10 @@ globus_gsi_cred_write_proxy( goto exit; } - /* + /* * We always unlink the file first; it is the only way to be * certain that the file we open has never in its entire lifetime - * had the world-readable bit set. + * had the world-readable bit set. */ #if _WIN32 /* Win32 API won't allow removing a read-only file */ @@ -1884,8 +1885,8 @@ globus_gsi_cred_write_proxy( #endif temp_proxy_fd = remove(proxy_filename); - /* - * Now, we must open w/ O_EXCL to make certain that WE are + /* + * Now, we must open w/ O_EXCL to make certain that WE are * creating the file, so we know that the file was BORN w/ mode 0600. * As a bonus, O_EXCL flag will cause a failure in the presence * of a symlink, so we are safe from zaping a file due to the @@ -1904,18 +1905,18 @@ globus_gsi_cred_write_proxy( temp_proxy_fp = fdopen(temp_proxy_fd,"w"); /* Hand the stream over to ssl */ - if( !(temp_proxy_fp) || + if( !(temp_proxy_fp) || !(proxy_bio = BIO_new_fp(temp_proxy_fp, BIO_CLOSE))) { GLOBUS_GSI_CRED_OPENSSL_ERROR_RESULT( result, GLOBUS_GSI_CRED_ERROR_WRITING_PROXY_CRED, (_GCRSL("Can't open bio stream for writing to file: %s"), proxy_filename)); - if ( temp_proxy_fp ) + if ( temp_proxy_fp ) { fclose(temp_proxy_fp); - } - else if (temp_proxy_fd >= 0 ) + } + else if (temp_proxy_fd >= 0 ) { /* close underlying fd if we do not have a stream */ close(temp_proxy_fd); @@ -1924,7 +1925,7 @@ globus_gsi_cred_write_proxy( goto exit; } - /* + /* * Note: at this point, calling BIO_free(proxy_bio) will * fclose the temp_proxy_fp, which in turn should close temp_proxy_fd. */ @@ -1957,7 +1958,7 @@ globus_gsi_cred_write_proxy( globus_libc_umask(oldmask); GLOBUS_I_GSI_CRED_DEBUG_EXIT; return result; -} +} /* globus_gsi_cred_write_proxy() */ /** @@ -1983,7 +1984,7 @@ globus_gsi_cred_get_cert_type( globus_result_t result; GLOBUS_I_GSI_CRED_DEBUG_ENTER; - + result = globus_gsi_cert_utils_get_cert_type(handle->cert, type); if(result != GLOBUS_SUCCESS) { @@ -2026,7 +2027,11 @@ globus_i_gsi_cred_get_proxycertinfo( { globus_result_t result = GLOBUS_SUCCESS; int pci_old_NID; +#if OPENSSL_VERSION_NUMBER < 0x40000000L X509_EXTENSION * pci_extension = NULL; +#else + const X509_EXTENSION * pci_extension = NULL; +#endif int extension_loc; GLOBUS_I_GSI_CRED_DEBUG_ENTER; @@ -2048,7 +2053,7 @@ globus_i_gsi_cred_get_proxycertinfo( GLOBUS_GSI_CRED_ERROR_RESULT( result, GLOBUS_GSI_CRED_ERROR_WITH_CRED, - (_GCRSL("NULL X509 cert parameter passed to function: %s"), + (_GCRSL("NULL X509 cert parameter passed to function: %s"), __func__)); goto exit; } @@ -2061,7 +2066,7 @@ globus_i_gsi_cred_get_proxycertinfo( goto exit; } - if((pci_extension = X509_get_ext(cert, + if((pci_extension = X509_get_ext(cert, extension_loc)) == NULL) { GLOBUS_GSI_CRED_OPENSSL_ERROR_RESULT( @@ -2081,9 +2086,9 @@ globus_i_gsi_cred_get_proxycertinfo( "extension to internal form"))); goto exit; } - + exit: - + GLOBUS_I_GSI_CRED_DEBUG_EXIT; return result; } @@ -2125,16 +2130,16 @@ globus_l_gsi_cred_subject_cmp( GLOBUS_I_GSI_CRED_DEBUG_ENTER; - + /* if desired subject is NULL return success */ - + if(!desired_subject) { goto exit; } /* check for single /CN entry */ - + if(X509_NAME_entry_count(desired_subject) == 1) { /* make sure we actually got a common name */ @@ -2156,7 +2161,7 @@ globus_l_gsi_cred_subject_cmp( cn_index = X509_NAME_get_index_by_NID(actual_subject, NID_commonName, -1); /* error if no common name was found */ - + if(cn_index < 0) { actual_str = X509_NAME_oneline(actual_subject, NULL, 0); @@ -2168,7 +2173,7 @@ globus_l_gsi_cred_subject_cmp( } /* check that actual subject only has one CN entry */ - + if(X509_NAME_get_index_by_NID(actual_subject, NID_commonName, cn_index) != -1) { actual_str = X509_NAME_oneline(actual_subject, NULL, 0); @@ -2183,7 +2188,7 @@ globus_l_gsi_cred_subject_cmp( length = X509_NAME_get_text_by_NID(desired_subject, NID_commonName, NULL, 1024) + 1; - + desired_cn = malloc(length); X509_NAME_get_text_by_NID(desired_subject, NID_commonName, @@ -2193,7 +2198,7 @@ globus_l_gsi_cred_subject_cmp( length = X509_NAME_get_text_by_NID(actual_subject, NID_commonName, NULL, 1024) + 1; - + actual_cn = malloc(length); X509_NAME_get_text_by_NID(actual_subject, NID_commonName, @@ -2219,7 +2224,7 @@ globus_l_gsi_cred_subject_cmp( actual_service = actual_cn; actual_host++; } - + desired_host = strchr(desired_cn,'/'); if(desired_host == NULL) @@ -2233,7 +2238,7 @@ globus_l_gsi_cred_subject_cmp( desired_service = desired_cn; desired_host++; } - + if(desired_service == NULL && actual_service == NULL) { @@ -2258,7 +2263,7 @@ globus_l_gsi_cred_subject_cmp( { actual_str = X509_NAME_oneline(actual_subject, NULL, 0); desired_str = X509_NAME_oneline(desired_subject, NULL, 0); - + GLOBUS_GSI_CRED_ERROR_RESULT( result, GLOBUS_GSI_CRED_ERROR_SUBJECT_CMP, @@ -2269,7 +2274,7 @@ globus_l_gsi_cred_subject_cmp( desired_str, actual_str)); } - + goto exit; } else if(actual_service == NULL) @@ -2278,7 +2283,7 @@ globus_l_gsi_cred_subject_cmp( { actual_str = X509_NAME_oneline(actual_subject, NULL, 0); desired_str = X509_NAME_oneline(desired_subject, NULL, 0); - + GLOBUS_GSI_CRED_ERROR_RESULT( result, GLOBUS_GSI_CRED_ERROR_SUBJECT_CMP, @@ -2289,8 +2294,8 @@ globus_l_gsi_cred_subject_cmp( desired_str, actual_str)); } - - goto exit; + + goto exit; } else { @@ -2298,7 +2303,7 @@ globus_l_gsi_cred_subject_cmp( { actual_str = X509_NAME_oneline(actual_subject, NULL, 0); desired_str = X509_NAME_oneline(desired_subject, NULL, 0); - + GLOBUS_GSI_CRED_ERROR_RESULT( result, GLOBUS_GSI_CRED_ERROR_SUBJECT_CMP, @@ -2309,7 +2314,7 @@ globus_l_gsi_cred_subject_cmp( desired_str, actual_str)); } - + goto exit; } @@ -2322,7 +2327,7 @@ globus_l_gsi_cred_subject_cmp( { actual_str = X509_NAME_oneline(actual_subject, NULL, 0); desired_str = X509_NAME_oneline(desired_subject, NULL, 0); - + GLOBUS_GSI_CRED_ERROR_RESULT( result, GLOBUS_GSI_CRED_ERROR_SUBJECT_CMP, @@ -2335,7 +2340,7 @@ globus_l_gsi_cred_subject_cmp( } goto exit; } - + exit: if(actual_cn) @@ -2347,7 +2352,7 @@ globus_l_gsi_cred_subject_cmp( { free(desired_cn); } - + if(actual_str) { OPENSSL_free(actual_str); @@ -2359,7 +2364,7 @@ globus_l_gsi_cred_subject_cmp( } GLOBUS_I_GSI_CRED_DEBUG_EXIT; - + return result; } @@ -2378,9 +2383,9 @@ globus_l_gsi_cred_get_service( GLOBUS_I_GSI_CRED_DEBUG_ENTER; *service = NULL; - + /* if desired subject is NULL return success */ - + if(!subject) { goto exit; @@ -2391,7 +2396,7 @@ globus_l_gsi_cred_get_service( cn_index = X509_NAME_get_index_by_NID(subject, NID_commonName, -1); /* error if no common name was found */ - + if(cn_index < 0) { subject_str = X509_NAME_oneline(subject, NULL, 0); @@ -2403,7 +2408,7 @@ globus_l_gsi_cred_get_service( } /* check that subject only has one CN entry */ - + if(X509_NAME_get_index_by_NID(subject, NID_commonName, cn_index) != -1) { subject_str = X509_NAME_oneline(subject, NULL, 0); @@ -2418,12 +2423,12 @@ globus_l_gsi_cred_get_service( length = X509_NAME_get_text_by_NID(subject, NID_commonName, NULL, 1024) + 1; - + cn = malloc(length); - + X509_NAME_get_text_by_NID(subject, NID_commonName, cn, length); - + host = strchr(cn,'/'); if(host == NULL) @@ -2455,9 +2460,9 @@ globus_l_gsi_cred_get_service( GLOBUS_GSI_CRED_ERROR_RESULT( result, GLOBUS_GSI_CRED_ERROR_GETTING_SERVICE_NAME, - (_GCRSL("No service name found in subject %s.\n"), subject_str)); + (_GCRSL("No service name found in subject %s.\n"), subject_str)); } - + goto exit; exit: @@ -2473,7 +2478,7 @@ globus_l_gsi_cred_get_service( } GLOBUS_I_GSI_CRED_DEBUG_EXIT; - + return result; } @@ -2484,8 +2489,8 @@ globus_l_credential_sort_cert_list( { X509 * tmp_cert = NULL; X509 * tmp_signer = NULL; - X509_NAME * candidate_issuer; - X509_NAME * signer_subject; + const X509_NAME * candidate_issuer; + const X509_NAME * signer_subject; STACK_OF(X509) * ordered_certs; int i, j, issuer_idx; diff --git a/gsi/gridmap_eppn_callout/configure.ac b/gsi/gridmap_eppn_callout/configure.ac index 534ece6ba4..09dd5ea3f5 100644 --- a/gsi/gridmap_eppn_callout/configure.ac +++ b/gsi/gridmap_eppn_callout/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ([2.60]) -AC_INIT([globus_gridmap_eppn_callout],[2.2],[https://github.com/gridcf/gct/issues]) +AC_INIT([globus_gridmap_eppn_callout],[2.3],[https://github.com/gridcf/gct/issues]) AC_CONFIG_MACRO_DIR([m4]) AC_SUBST([MAJOR_VERSION], [${PACKAGE_VERSION%%.*}]) AC_SUBST([MINOR_VERSION], [${PACKAGE_VERSION##*.}]) diff --git a/gsi/gridmap_eppn_callout/globus_gridmap_eppn.c b/gsi/gridmap_eppn_callout/globus_gridmap_eppn.c index deff089c8a..65e9dc1714 100644 --- a/gsi/gridmap_eppn_callout/globus_gridmap_eppn.c +++ b/gsi/gridmap_eppn_callout/globus_gridmap_eppn.c @@ -294,9 +294,13 @@ ggvm_get_eppn( { ASN1_OBJECT * eppn_obj; int extpos; +#if OPENSSL_VERSION_NUMBER < 0x40000000L X509_EXTENSION * eppn_ext; - ASN1_STRING * eppn_str; - unsigned char * eppn_data; +#else + const X509_EXTENSION * eppn_ext; +#endif + const ASN1_STRING * eppn_str; + const unsigned char * eppn_data; int tag; int xclass; @@ -312,14 +316,14 @@ ggvm_get_eppn( if (!(eppn_str = X509_EXTENSION_get_data(eppn_ext))) return GLOBUS_FAILURE; - eppn_data = eppn_str->data; + eppn_data = ASN1_STRING_get0_data(eppn_str); if (ASN1_get_object(GT_ASN1_GET_OBJECT_CAST &eppn_data, - length, &tag, &xclass, eppn_str->length) == 0x80) + length, &tag, &xclass, ASN1_STRING_length(eppn_str)) == 0x80) return GLOBUS_FAILURE; *data = (char *) eppn_data; - *length = eppn_str->length; + *length = ASN1_STRING_length(eppn_str); return GLOBUS_SUCCESS; } diff --git a/gsi/gss_assist/source/configure.ac b/gsi/gss_assist/source/configure.ac index 551b250f9e..287d27da55 100644 --- a/gsi/gss_assist/source/configure.ac +++ b/gsi/gss_assist/source/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ([2.60]) -AC_INIT([globus_gss_assist], [12.7],[https://github.com/gridcf/gct/issues]) +AC_INIT([globus_gss_assist], [12.8],[https://github.com/gridcf/gct/issues]) AC_CONFIG_MACRO_DIR([m4]) AC_SUBST([MAJOR_VERSION], [${PACKAGE_VERSION%%.*}]) AC_SUBST([MINOR_VERSION], [${PACKAGE_VERSION##*.}]) diff --git a/gsi/gss_assist/source/hostname.c b/gsi/gss_assist/source/hostname.c index 4a80b298d7..47e955b163 100644 --- a/gsi/gss_assist/source/hostname.c +++ b/gsi/gss_assist/source/hostname.c @@ -25,22 +25,22 @@ #ifndef GLOBUS_DONT_DOCUMENT_INTERNAL #define BUFFER_SIZE 8192 -#ifndef NI_MAXHOST +#ifndef NI_MAXHOST #define NI_MAXHOST 255 #endif #endif /** - * @ingroup globus_gss_assist_name + * @ingroup globus_gss_assist * Create a GSS Name structure from the given hostname. This function tries to * resolve the given host name string to the canonical DNS name for the host. * * @param hostname - * The host name or numerical address to be resolved and transform + * The host name or numerical address to be resolved and transform * into a GSS Name * @param authorization_hostname * The resulting GSS Name - * + * * @return GLOBUS_SUCCESS on successful completion, a error object otherwise */ globus_result_t @@ -55,7 +55,7 @@ globus_gss_assist_authorization_host_name( OM_uint32 major_status; OM_uint32 minor_status; globus_result_t result = GLOBUS_SUCCESS; - int i; + int i; globus_addrinfo_t hints; globus_addrinfo_t * addrinfo; @@ -65,13 +65,13 @@ globus_gss_assist_authorization_host_name( hints.ai_protocol = 0; /* If hostname is an ip address, do a non-canonname getaddrinfo to get - * the sockaddr, then getnameinfo to get the hostname from that addr */ + * the sockaddr, then getnameinfo to get the hostname from that addr */ hints.ai_flags = GLOBUS_AI_NUMERICHOST; result = globus_libc_getaddrinfo(hostname, NULL, &hints, &addrinfo); /* if this succeeds then the hostname must be numeric */ if(result == GLOBUS_SUCCESS) - { + { if(addrinfo == NULL || addrinfo->ai_addr == NULL) { GLOBUS_GSI_GSS_ASSIST_ERROR_CHAIN_RESULT( @@ -79,12 +79,12 @@ globus_gss_assist_authorization_host_name( GLOBUS_GSI_GSS_ASSIST_ERROR_CANONICALIZING_HOSTNAME); goto error_exit; } - - /* + + /* * For connections to localhost, check for certificate * matching our real hostname, not "localhost" */ - + if(globus_libc_addr_is_loopback( (const globus_sockaddr_t *) addrinfo->ai_addr) == GLOBUS_TRUE) { @@ -93,8 +93,8 @@ globus_gss_assist_authorization_host_name( } else { - /* use GLOBUS_NI_NAMEREQD to fail if address can't be looked up? - * if not, realhostname will just be the same ip address + /* use GLOBUS_NI_NAMEREQD to fail if address can't be looked up? + * if not, realhostname will just be the same ip address * we pass in */ result = globus_libc_getnameinfo( (const globus_sockaddr_t *) addrinfo->ai_addr, @@ -112,16 +112,16 @@ globus_gss_assist_authorization_host_name( goto error_exit; } } - + globus_libc_freeaddrinfo(addrinfo); - } - - /* else just do a getaddrinfo lookup of the hostname */ + } + + /* else just do a getaddrinfo lookup of the hostname */ else { hints.ai_flags = GLOBUS_AI_CANONNAME; result = globus_libc_getaddrinfo(hostname, NULL, &hints, &addrinfo); - + if(result != GLOBUS_SUCCESS || addrinfo == NULL || addrinfo->ai_canonname == NULL) @@ -130,13 +130,13 @@ globus_gss_assist_authorization_host_name( result, GLOBUS_GSI_GSS_ASSIST_ERROR_CANONICALIZING_HOSTNAME); goto error_exit; - } + } - /* + /* * For connections to localhost, check for certificate * matching our real hostname, not "localhost" */ - + if(globus_libc_addr_is_loopback( (const globus_sockaddr_t *) addrinfo->ai_addr) == GLOBUS_TRUE) { @@ -145,30 +145,30 @@ globus_gss_assist_authorization_host_name( } else { - strncpy(&realhostname[5], addrinfo->ai_canonname, + strncpy(&realhostname[5], addrinfo->ai_canonname, sizeof(realhostname) - 5); realhostname[sizeof(realhostname) - 1] = '\0'; } - + globus_libc_freeaddrinfo(addrinfo); } - + /* * To work around the GSI GSSAPI library being case sensitive * convert the hostname to lower case as no one seems to * request uppercase name certificates. */ - + for (i = 5; realhostname[i] && (i < sizeof(realhostname)); i++) { realhostname[i] = tolower(realhostname[i]); } - + name_tok.value = realhostname; name_tok.length = strlen(realhostname) + 1; - major_status = gss_import_name(&minor_status, - &name_tok, - GSS_C_NT_HOSTBASED_SERVICE, + major_status = gss_import_name(&minor_status, + &name_tok, + GSS_C_NT_HOSTBASED_SERVICE, authorization_hostname); if(GSS_ERROR(major_status)) diff --git a/gsi/gss_assist/source/test/gridmap_test.c b/gsi/gss_assist/source/test/gridmap_test.c index 782f93c7ca..11dbd9242a 100644 --- a/gsi/gss_assist/source/test/gridmap_test.c +++ b/gsi/gss_assist/source/test/gridmap_test.c @@ -129,6 +129,10 @@ create_contexts(void) NULL, NULL); } + else + { + maj_stat = 0; + } if (GSS_ERROR(maj_stat)) { @@ -153,7 +157,7 @@ int gridmap_bad_params_test(void) char * userid = "userid"; int rc; char * gridmap; - + gridmap = create_file_path(gridmap_dir, "grid-mapfile"); rc = globus_libc_setenv("GRIDMAP", gridmap, 1); @@ -194,7 +198,7 @@ userok_bad_params_test(void) char * userid = "userid"; int rc; char * gridmap; - + gridmap = create_file_path(gridmap_dir, "grid-mapfile"); rc = globus_libc_setenv("GRIDMAP", gridmap, 1); @@ -235,7 +239,7 @@ map_local_user_bad_params_test(void) char * userid = "joe"; int rc; char * gridmap; - + gridmap = create_file_path(gridmap_dir, "grid-mapfile"); rc = globus_libc_setenv("GRIDMAP", gridmap, 1); @@ -277,7 +281,7 @@ lookup_all_globusid_bad_params_test(void) int dn_count; int rc; char * gridmap; - + gridmap = create_file_path(gridmap_dir, "grid-mapfile"); rc = globus_libc_setenv("GRIDMAP", gridmap, 1); @@ -328,7 +332,7 @@ map_and_authorize_bad_params_test(void) char * identity_buffer = "id"; unsigned int identity_buffer_length = 2; char * gridmap; - + gridmap = create_file_path(gridmap_dir, "grid-mapfile"); @@ -388,7 +392,7 @@ gridmap_test(void) int failed; int rc; char * gridmap; - + for (i = 0, failed = 0; i < SIZEOF_ARRAY(tests); i++) { diff --git a/gsi/gss_assist/source/wrap.c b/gsi/gss_assist/source/wrap.c index 61df54f8b2..dffb3857ad 100644 --- a/gsi/gss_assist/source/wrap.c +++ b/gsi/gss_assist/source/wrap.c @@ -29,24 +29,24 @@ /** * @brief Wrap - * @ingroup globus_gsi_gss_assist + * @ingroup globus_gss_assist * * @param minor_status - * GSSAPI return code. If the call was successful, the minor + * GSSAPI return code. If the call was successful, the minor * status is equal to GLOBUS_SUCCESS. Otherwise, it is an - * error object ID for which + * error object ID for which * globus_error_get() and globus_object_free() * can be used to get and destroy it. * @param context_handle - * the context. + * the context. * @param data * pointer to application data to wrap and send * @param length * length of the @a data array * @param token_status - * assist routine get/send token status + * assist routine get/send token status * @param gss_assist_send_token - * a send_token routine + * a send_token routine * @param gss_assist_send_context * first arg for the send_token * @param fperr @@ -54,7 +54,7 @@ * * @return * GSS_S_COMPLETE on success - * Other GSSAPI errors on failure. + * Other GSSAPI errors on failure. * * @see gss_wrap() */ @@ -62,9 +62,9 @@ OM_uint32 globus_gss_assist_wrap_send( OM_uint32 * minor_status, const gss_ctx_id_t context_handle, - char * data, - size_t length, - int * token_status, + char * data, + size_t length, + int * token_status, int (*gss_assist_send_token)(void *, void *, size_t), void * gss_assist_send_context, FILE * fperr) @@ -91,12 +91,12 @@ globus_gss_assist_wrap_send( input_token, NULL, output_token); - + GLOBUS_I_GSI_GSS_ASSIST_DEBUG_FPRINTF( 3, (globus_i_gsi_gss_assist_debug_fstream, _GASL("Wrap_send:maj:%8.8x min:%8.8x inlen:%u outlen:%u\n"), - (unsigned int) major_status, - (unsigned int) *minor_status, + (unsigned int) major_status, + (unsigned int) *minor_status, input_token->length = length, output_token->length)); @@ -118,7 +118,7 @@ globus_gss_assist_wrap_send( local_minor_status, *token_status); } - + local_result = globus_error_put(error_copy); GLOBUS_GSI_GSS_ASSIST_ERROR_CHAIN_RESULT( local_result, @@ -135,7 +135,7 @@ globus_gss_assist_wrap_send( GLOBUS_GSI_GSS_ASSIST_ERROR_RESULT( local_result, GLOBUS_GSI_GSS_ASSIST_ERROR_WITH_WRAP, - (_GASL("Error sending output token. token status: %d\n"), + (_GASL("Error sending output token. token status: %d\n"), *token_status)); *minor_status = (OM_uint32) local_result; major_status = GSS_S_FAILURE; @@ -160,7 +160,7 @@ globus_gss_assist_wrap_send( output_token); exit: - + GLOBUS_I_GSI_GSS_ASSIST_DEBUG_EXIT; return major_status; } diff --git a/gsi/gssapi/source/configure.ac b/gsi/gssapi/source/configure.ac index 1f313cdceb..523152edc0 100644 --- a/gsi/gssapi/source/configure.ac +++ b/gsi/gssapi/source/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ([2.60]) -AC_INIT([globus_gssapi_gsi],[14.20],[https://github.com/gridcf/gct/issues]) +AC_INIT([globus_gssapi_gsi],[14.21],[https://github.com/gridcf/gct/issues]) AC_CONFIG_MACRO_DIR([m4]) AC_SUBST([MAJOR_VERSION], [${PACKAGE_VERSION%%.*}]) AC_SUBST([MINOR_VERSION], [${PACKAGE_VERSION##*.}]) diff --git a/gsi/gssapi/source/library/compare_name.c b/gsi/gssapi/source/library/compare_name.c index 5ddc5aebbb..d08528d3b9 100644 --- a/gsi/gssapi/source/library/compare_name.c +++ b/gsi/gssapi/source/library/compare_name.c @@ -37,7 +37,7 @@ #endif /* Comparison types */ -typedef enum +typedef enum { GSS_I_COMPARE_NT_ANONYMOUS, GSS_I_COMPARE_NT_X509, @@ -174,7 +174,7 @@ gss_l_get_oid_type( * @ingroup globus_gsi_gssapi * @details * Compare two names. GSSAPI names in this implementation - * are pointers to X.509 names. + * are pointers to X.509 names. * * @param minor_status * currently is always set to GLOBUS_SUCCESS @@ -185,7 +185,7 @@ gss_l_get_oid_type( * @return * currently always returns GSS_S_COMPLETE */ -OM_uint32 +OM_uint32 GSS_CALLCONV gss_compare_name( OM_uint32 * minor_status, const gss_name_t name1_P, @@ -272,7 +272,7 @@ GSS_CALLCONV gss_compare_name( _GGSL("Name 2 is of type %s:\n"), gss_l_name_types[type2])); - /* Normalize order of name1 and name2 so we can have fewer comparisons + /* Normalize order of name1 and name2 so we can have fewer comparisons * below */ if (type1 > type2) @@ -377,7 +377,7 @@ GSS_CALLCONV gss_compare_name( GLOBUS_I_GSI_GSSAPI_DEBUG_EXIT; return major_status; -} +} /* gss_compare_name */ static @@ -415,7 +415,7 @@ gss_l_compare_x509_to_x509( { dns_alt_name_found1 = GLOBUS_TRUE; - ns1 = (char *) ASN1_STRING_data(gn1->d.dNSName); + ns1 = (char *) ASN1_STRING_get0_data(gn1->d.dNSName); for (i2 = 0; i2 < name_count2; i2++) { @@ -423,7 +423,7 @@ gss_l_compare_x509_to_x509( if (gn2->type == GEN_DNS) { - ns2 = (char *) ASN1_STRING_data(gn2->d.dNSName); + ns2 = (char *) ASN1_STRING_get0_data(gn2->d.dNSName); dns_alt_name_found2 = GLOBUS_TRUE; major_status = gss_l_compare_hostnames_with_wildcards( @@ -472,7 +472,7 @@ gss_l_compare_x509_to_x509( if (gn2->type == GEN_DNS) { - ns2 = (char *) ASN1_STRING_data(gn2->d.dNSName); + ns2 = (char *) ASN1_STRING_get0_data(gn2->d.dNSName); major_status = gss_l_compare_hostnames_with_wildcards( minor_status, @@ -596,7 +596,7 @@ gss_l_compare_x509_to_hostbased_service( gn1 = sk_GENERAL_NAME_value(name1->subjectAltNames, i1); if (gn1->type == GEN_DNS) { - ns1 = (char *) ASN1_STRING_data(gn1->d.dNSName); + ns1 = (char *) ASN1_STRING_get0_data(gn1->d.dNSName); /* In strict RFC mode, we're going to require the service * portion of the hostbased service name to be "host" (the @@ -691,7 +691,7 @@ gss_l_compare_x509_to_host_ip( gn1 = sk_GENERAL_NAME_value(name1->subjectAltNames, i1); if (gn1->type == GEN_DNS) { - ns1 = (char *) ASN1_STRING_data(gn1->d.dNSName); + ns1 = (char *) ASN1_STRING_get0_data(gn1->d.dNSName); major_status = gss_l_compare_hostnames_with_wildcards( minor_status, @@ -714,7 +714,7 @@ gss_l_compare_x509_to_host_ip( { int ip_as_ints[16], j; int len = ASN1_STRING_length(gn1->d.iPAddress); - ns1 = (char *) ASN1_STRING_data(gn1->d.iPAddress); + ns1 = (char *) ASN1_STRING_get0_data(gn1->d.iPAddress); for (j = 0; j < len; j++) { @@ -911,7 +911,7 @@ gss_l_compare_hostbased_service_to_hostbased_service( ns1 = name1->host_name; ns2 = name2->host_name; - /* In strict mode, we compare service names, for backward compatibility, + /* In strict mode, we compare service names, for backward compatibility, * we ignore them. */ if (gss_i_name_compatibility_mode == GSS_I_COMPATIBILITY_STRICT_RFC2818 && @@ -1012,7 +1012,7 @@ gss_l_compare_host_ip_to_host_ip( { *name_equal = GSS_NAMES_EQUAL; } - else if (gss_i_name_compatibility_mode != GSS_I_COMPATIBILITY_STRICT_RFC2818) + else if (gss_i_name_compatibility_mode != GSS_I_COMPATIBILITY_STRICT_RFC2818) { ns1 = name1->ip_name; major_status = gss_l_compare_hostnames_with_wildcards( @@ -1182,7 +1182,7 @@ gss_l_compare_hostnames_with_wildcards( } } - else if (wildcards2 == GSS_I_WILDCARD_GT2 && *tok2 == '-' + else if (wildcards2 == GSS_I_WILDCARD_GT2 && *tok2 == '-' && first_token) { if (*tok1 != '\0') @@ -1243,7 +1243,7 @@ gss_l_strsep(char **stringp, const char * delim) /* Convert oid struct to integer * * @param oid - * OID to convert to a gss_l_compare_type_t (or -1 if the + * OID to convert to a gss_l_compare_type_t (or -1 if the * name type is not supported. */ static @@ -1259,7 +1259,7 @@ gss_l_get_oid_type( { return GSS_I_COMPARE_NT_X509; } - else if (g_OID_equal(oid, GSS_C_NO_OID) || + else if (g_OID_equal(oid, GSS_C_NO_OID) || g_OID_equal(oid, GSS_C_NT_USER_NAME)) { return GSS_I_COMPARE_NT_NO_OID; diff --git a/gsi/gssapi/source/library/display_name.c b/gsi/gssapi/source/library/display_name.c index 0a3d76a2ef..f1523be295 100644 --- a/gsi/gssapi/source/library/display_name.c +++ b/gsi/gssapi/source/library/display_name.c @@ -34,15 +34,15 @@ * @details * Produces a single line version of the internal X.509 name * - * @param minor_status + * @param minor_status * @param input_name_P * @param output_name * @param output_name_type * - * @return + * @return */ -OM_uint32 -GSS_CALLCONV +OM_uint32 +GSS_CALLCONV gss_display_name( OM_uint32 * minor_status, const gss_name_t input_name_P, @@ -51,7 +51,7 @@ gss_display_name( { OM_uint32 major_status = GSS_S_COMPLETE; - const gss_name_desc* input_name = + const gss_name_desc* input_name = (gss_name_desc*) input_name_P; GLOBUS_I_GSI_GSSAPI_DEBUG_ENTER; @@ -62,7 +62,7 @@ gss_display_name( { major_status = GSS_S_FAILURE; GLOBUS_GSI_GSSAPI_ERROR_RESULT( - minor_status, + minor_status, GLOBUS_GSI_GSSAPI_ERROR_BAD_ARGUMENT, ("Bad argument")); goto exit; @@ -146,7 +146,7 @@ gss_display_name( { int name_length; GENERAL_NAME * name; - unsigned char * dns; + const unsigned char * dns; int i; name_length = sk_GENERAL_NAME_num(input_name->subjectAltNames); @@ -156,9 +156,9 @@ gss_display_name( if (name->type == GEN_DNS) { - dns = ASN1_STRING_data(name->d.dNSName); + dns = ASN1_STRING_get0_data(name->d.dNSName); output_name->value = - globus_common_create_string("/CN=%s", (char *) dns); + globus_common_create_string("/CN=%s", (const char *) dns); if (output_name->value == NULL) { GLOBUS_GSI_GSSAPI_MALLOC_ERROR(minor_status); @@ -174,7 +174,7 @@ gss_display_name( { major_status = GSS_S_BAD_NAME; GLOBUS_GSI_GSSAPI_ERROR_RESULT( - minor_status, + minor_status, GLOBUS_GSI_GSSAPI_ERROR_BAD_NAME, ("X.509 Name contains no SubjectName and no dNSName.")); goto exit; @@ -184,12 +184,12 @@ gss_display_name( { major_status = GSS_S_FAILURE; GLOBUS_GSI_GSSAPI_ERROR_RESULT( - minor_status, + minor_status, GLOBUS_GSI_GSSAPI_ERROR_BAD_NAME, ("Bad Name")); goto exit; } - + if(output_name_type) { *output_name_type = input_name->name_oid; @@ -199,5 +199,5 @@ gss_display_name( GLOBUS_I_GSI_GSSAPI_DEBUG_EXIT; return major_status; -} +} /* gss_display_name */ diff --git a/gsi/gssapi/source/library/globus_i_gsi_gss_utils.c b/gsi/gssapi/source/library/globus_i_gsi_gss_utils.c index 6e40d8aa1e..5a3a79e8eb 100644 --- a/gsi/gssapi/source/library/globus_i_gsi_gss_utils.c +++ b/gsi/gssapi/source/library/globus_i_gsi_gss_utils.c @@ -2690,12 +2690,18 @@ globus_i_gsi_gss_get_context_goodtill( * * @return */ +#if OPENSSL_VERSION_NUMBER < 0x40000000L int globus_i_gsi_gss_verify_extensions_callback( globus_gsi_callback_data_t callback_data, X509_EXTENSION * extension) +#else +int globus_i_gsi_gss_verify_extensions_callback( + globus_gsi_callback_data_t callback_data, + const X509_EXTENSION * extension) +#endif { gss_OID_set extension_oids; - ASN1_OBJECT * extension_obj; + const ASN1_OBJECT * extension_obj; int index; int return_val = 0; globus_result_t local_result; @@ -2756,9 +2762,9 @@ globus_i_gsi_gssapi_get_hostname( int common_name_NID; int index; unsigned int length; - unsigned char * data; - unsigned char * p; - X509_NAME_ENTRY * name_entry = NULL; + const unsigned char * data; + const unsigned char * p; + const X509_NAME_ENTRY * name_entry = NULL; name->service_name = name->host_name = NULL; *minor_status = GLOBUS_SUCCESS; @@ -2769,9 +2775,9 @@ globus_i_gsi_gssapi_get_hostname( name_entry = X509_NAME_get_entry(name->x509n, index); if (OBJ_obj2nid(X509_NAME_ENTRY_get_object(name_entry)) == common_name_NID) { - ASN1_STRING *s = X509_NAME_ENTRY_get_data(name_entry); + const ASN1_STRING *s = X509_NAME_ENTRY_get_data(name_entry); length = ASN1_STRING_length(s); - data = ASN1_STRING_data(s); + data = ASN1_STRING_get0_data(s); p = memchr(data, '/', length); diff --git a/gsi/gssapi/source/library/globus_i_gsi_gss_utils.h b/gsi/gssapi/source/library/globus_i_gsi_gss_utils.h index c8b81e3997..9a136162c8 100644 --- a/gsi/gssapi/source/library/globus_i_gsi_gss_utils.h +++ b/gsi/gssapi/source/library/globus_i_gsi_gss_utils.h @@ -128,7 +128,7 @@ extern globus_bool_t globus_i_gssapi_active; { \ globus_libc_fprintf _MESSAGE_; \ } \ -} +} #define GLOBUS_I_GSI_GSSAPI_DEBUG_FNPRINTF(_LEVEL_, _MESSAGE_) \ { \ @@ -151,7 +151,7 @@ extern globus_bool_t globus_i_gssapi_active; "%s", _MESSAGE_); \ } \ } - + #define GLOBUS_I_GSI_GSSAPI_DEBUG_PRINT_OBJECT(_LEVEL_, _TYPE_, _OBJ_) \ { \ if (GLOBUS_I_GSI_GSSAPI_DEBUG(_LEVEL_)) \ @@ -245,9 +245,15 @@ globus_i_gsi_gss_create_cred( globus_gsi_cred_handle_t * cred_handle, globus_bool_t sni_context); +#if OPENSSL_VERSION_NUMBER < 0x40000000L int globus_i_gsi_gss_verify_extensions_callback( globus_gsi_callback_data_t callback_data, X509_EXTENSION * extension); +#else +int globus_i_gsi_gss_verify_extensions_callback( + globus_gsi_callback_data_t callback_data, + const X509_EXTENSION * extension); +#endif OM_uint32 globus_i_gsi_gss_handshake( diff --git a/gsi/gssapi/source/library/import_name.c b/gsi/gssapi/source/library/import_name.c index f13e345050..d873ae1fb6 100644 --- a/gsi/gssapi/source/library/import_name.c +++ b/gsi/gssapi/source/library/import_name.c @@ -41,7 +41,7 @@ gss_l_resolve_ip( * * Creates a new gss_name_t which contains a mechanism-specific representation * of the input name. GSSAPI OpenSSL implements the following name types, based - * on the input_name_type OID: + * on the input_name_type OID: * * - GSS_C_NT_ANONYMOUS (input_name_buffer is ignored) * - GSS_C_NT_HOSTBASED_SERVICE (input_name_buffer contains a string @@ -84,7 +84,7 @@ gss_l_resolve_ip( * indicates that the requested operation could not be performed for * reasons unspecified at the GSS-API level. */ -OM_uint32 +OM_uint32 GSS_CALLCONV gss_import_name( OM_uint32 * minor_status, const gss_buffer_t input_name_buffer, @@ -119,14 +119,14 @@ GSS_CALLCONV gss_import_name( *minor_status = (OM_uint32) GLOBUS_SUCCESS; output_name = calloc(1, sizeof(gss_name_desc)); - + if (output_name == NULL) { GLOBUS_GSI_GSSAPI_MALLOC_ERROR(minor_status); major_status = GSS_S_FAILURE; goto out; - } - + } + output_name->name_oid = input_name_type; output_name->x509n = X509_NAME_new(); if (output_name->x509n == NULL) @@ -289,7 +289,7 @@ GSS_CALLCONV gss_import_name( goto release_name_out; } memcpy(output_name->user_name, - input_name_buffer->value, + input_name_buffer->value, input_name_buffer->length); output_name->user_name[input_name_buffer->length] = '\0'; @@ -411,7 +411,7 @@ GSS_CALLCONV gss_import_name( } else if (g_OID_equal(GLOBUS_GSS_C_NT_X509, input_name_type)) { - X509_NAME *n; + const X509_NAME *n; X509 *x509_input; GENERAL_NAMES *subject_alt_name; int idx; @@ -465,7 +465,7 @@ GSS_CALLCONV gss_import_name( idx != -1; idx = X509_get_ext_by_NID(x509_input, NID_subject_alt_name, idx)) { - X509_EXTENSION * ext_value; + const X509_EXTENSION * ext_value; ext_value = X509_get_ext(x509_input, idx); if (!ext_value) @@ -493,7 +493,7 @@ GSS_CALLCONV gss_import_name( else { GLOBUS_GSI_GSSAPI_ERROR_RESULT( - minor_status, + minor_status, GLOBUS_GSI_GSSAPI_ERROR_BAD_NAME, (_GGSL("Bad name type"))); @@ -510,12 +510,12 @@ GSS_CALLCONV gss_import_name( } *output_name_P = output_name; - + out: GLOBUS_I_GSI_GSSAPI_DEBUG_EXIT; return major_status; -} +} /* gss_import_name */ diff --git a/gsi/gssapi/source/library/inquire_cred_by_oid.c b/gsi/gssapi/source/library/inquire_cred_by_oid.c index 668b93b9ee..a22ebd17cb 100644 --- a/gsi/gssapi/source/library/inquire_cred_by_oid.c +++ b/gsi/gssapi/source/library/inquire_cred_by_oid.c @@ -31,8 +31,8 @@ /** * @brief Inquire Cred By OID * @ingroup globus_gsi_gssapi_extensions - * @details - * NOTE: Checks both the cert in the credential and + * @details + * NOTE: Checks both the cert in the credential and * the certs in the cert chain for a valid extension * that matches the desired OID. The first one found * is used, starting with the endpoint cert, and then @@ -55,24 +55,24 @@ GSS_CALLCONV gss_inquire_cred_by_oid( { OM_uint32 major_status = GSS_S_COMPLETE; OM_uint32 local_minor_status; - X509_EXTENSION * extension; + const X509_EXTENSION * extension; X509 * cert = NULL; STACK_OF(X509) * cert_chain = NULL; ASN1_OBJECT * desired_asn1_obj; - ASN1_OCTET_STRING * asn1_oct_string; + const ASN1_OCTET_STRING * asn1_oct_string; gss_buffer_desc data_set_buffer; int chain_index; int found_index; globus_result_t local_result = GLOBUS_SUCCESS; GLOBUS_I_GSI_GSSAPI_DEBUG_ENTER; - + if(minor_status == NULL) { major_status = GSS_S_FAILURE; goto exit; } - + *minor_status = (OM_uint32) GLOBUS_SUCCESS; /* parameter checking goes here */ @@ -121,7 +121,7 @@ GSS_CALLCONV gss_inquire_cred_by_oid( } major_status = gss_create_empty_buffer_set( - &local_minor_status, + &local_minor_status, data_set); if(GSS_ERROR(major_status)) @@ -199,9 +199,9 @@ GSS_CALLCONV gss_inquire_cred_by_oid( goto exit; } - data_set_buffer.value = asn1_oct_string->data; - data_set_buffer.length = asn1_oct_string->length; - + data_set_buffer.value = (unsigned char *) ASN1_STRING_get0_data(asn1_oct_string); + data_set_buffer.length = ASN1_STRING_length(asn1_oct_string); + major_status = gss_add_buffer_set_member( &local_minor_status, &data_set_buffer, @@ -224,9 +224,9 @@ GSS_CALLCONV gss_inquire_cred_by_oid( { sk_X509_pop_free(cert_chain, X509_free); } - + GLOBUS_I_GSI_GSSAPI_DEBUG_EXIT; return major_status; } - + #endif /* _HAVE_GSI_EXTENDED_GSSAPI */ diff --git a/gsi/gssapi/source/library/inquire_sec_context_by_oid.c b/gsi/gssapi/source/library/inquire_sec_context_by_oid.c index ebd3cefc10..4f33cdee16 100644 --- a/gsi/gssapi/source/library/inquire_sec_context_by_oid.c +++ b/gsi/gssapi/source/library/inquire_sec_context_by_oid.c @@ -47,11 +47,12 @@ GSS_CALLCONV gss_inquire_sec_context_by_oid( int found_index; int chain_index; int cert_count; - X509_EXTENSION * extension; + const X509_EXTENSION * extension; X509 * cert = NULL; STACK_OF(X509) * cert_chain = NULL; ASN1_OBJECT * asn1_desired_obj = NULL; ASN1_OCTET_STRING * asn1_oct_string; + const ASN1_OCTET_STRING * asn1_oct_string_c; gss_buffer_desc data_set_buffer = GSS_C_EMPTY_BUFFER; globus_result_t local_result = GLOBUS_SUCCESS; unsigned char * tmp_ptr; @@ -69,7 +70,7 @@ GSS_CALLCONV gss_inquire_sec_context_by_oid( major_status = GSS_S_FAILURE; goto exit; } - + if(context_handle == GSS_C_NO_CONTEXT) { GLOBUS_GSI_GSSAPI_ERROR_RESULT( @@ -108,7 +109,7 @@ GSS_CALLCONV gss_inquire_sec_context_by_oid( /* lock the context mutex */ globus_mutex_lock(&context->mutex); - local_result = + local_result = globus_gsi_callback_get_cert_depth(context->callback_data, &cert_count); if(local_result != GLOBUS_SUCCESS) @@ -124,7 +125,7 @@ GSS_CALLCONV gss_inquire_sec_context_by_oid( { goto unlock_exit; } - + major_status = gss_create_empty_buffer_set(&local_minor_status, data_set); if(GSS_ERROR(major_status)) @@ -134,7 +135,7 @@ GSS_CALLCONV gss_inquire_sec_context_by_oid( GLOBUS_GSI_GSSAPI_ERROR_WITH_BUFFER); goto unlock_exit; } - + local_result = globus_gsi_callback_get_cert_chain( context->callback_data, &cert_chain); @@ -260,7 +261,7 @@ GSS_CALLCONV gss_inquire_sec_context_by_oid( gss_ext_x509_cert_chain_oid->length)) { /* figure out what object was asked for */ - + asn1_desired_obj = ASN1_OBJECT_create( NID_undef, desired_object->elements, @@ -285,10 +286,10 @@ GSS_CALLCONV gss_inquire_sec_context_by_oid( data_set_buffer.value = NULL; data_set_buffer.length = 0; - found_index = X509_get_ext_by_OBJ(cert, - asn1_desired_obj, + found_index = X509_get_ext_by_OBJ(cert, + asn1_desired_obj, found_index); - + if(found_index >= 0) { extension = X509_get_ext(cert, found_index); @@ -303,8 +304,8 @@ GSS_CALLCONV gss_inquire_sec_context_by_oid( goto unlock_exit; } - asn1_oct_string = X509_EXTENSION_get_data(extension); - if(!asn1_oct_string) + asn1_oct_string_c = X509_EXTENSION_get_data(extension); + if(!asn1_oct_string_c) { GLOBUS_GSI_GSSAPI_OPENSSL_ERROR_RESULT( minor_status, @@ -315,7 +316,7 @@ GSS_CALLCONV gss_inquire_sec_context_by_oid( goto unlock_exit; } - asn1_oct_string = ASN1_OCTET_STRING_dup(asn1_oct_string); + asn1_oct_string = ASN1_OCTET_STRING_dup(asn1_oct_string_c); if(!asn1_oct_string) { @@ -327,11 +328,11 @@ GSS_CALLCONV gss_inquire_sec_context_by_oid( goto unlock_exit; } - data_set_buffer.value = asn1_oct_string->data; - data_set_buffer.length = asn1_oct_string->length; + data_set_buffer.value = (unsigned char *) ASN1_STRING_get0_data(asn1_oct_string); + data_set_buffer.length = ASN1_STRING_length(asn1_oct_string); OPENSSL_free(asn1_oct_string); - + major_status = gss_add_buffer_set_member( &local_minor_status, &data_set_buffer, @@ -344,7 +345,7 @@ GSS_CALLCONV gss_inquire_sec_context_by_oid( goto unlock_exit; } } - } + } } else { @@ -363,9 +364,9 @@ GSS_CALLCONV gss_inquire_sec_context_by_oid( GLOBUS_GSI_GSSAPI_ERROR_WITH_OPENSSL, (_GGSL("Failed to serialize certificate"))); major_status = GSS_S_FAILURE; - goto unlock_exit; + goto unlock_exit; } - + tmp_ptr = realloc(data_set_buffer.value, data_set_buffer.length); @@ -373,11 +374,11 @@ GSS_CALLCONV gss_inquire_sec_context_by_oid( { GLOBUS_GSI_GSSAPI_MALLOC_ERROR(minor_status); major_status = GSS_S_FAILURE; - goto unlock_exit; + goto unlock_exit; } data_set_buffer.value = tmp_ptr; - + if(i2d_X509(cert,&tmp_ptr) < 0) { free(data_set_buffer.value); @@ -386,7 +387,7 @@ GSS_CALLCONV gss_inquire_sec_context_by_oid( GLOBUS_GSI_GSSAPI_ERROR_WITH_OPENSSL, (_GGSL("Failed to serialize certificate"))); major_status = GSS_S_FAILURE; - goto unlock_exit; + goto unlock_exit; } major_status = gss_add_buffer_set_member( @@ -401,7 +402,7 @@ GSS_CALLCONV gss_inquire_sec_context_by_oid( goto unlock_exit; } } - + if(data_set_buffer.value != NULL) { free(data_set_buffer.value); @@ -421,7 +422,7 @@ GSS_CALLCONV gss_inquire_sec_context_by_oid( { sk_X509_pop_free(cert_chain, X509_free); } - + GLOBUS_I_GSI_GSSAPI_DEBUG_EXIT; return major_status; } diff --git a/gsi/gssapi/source/test/alpn-test.c b/gsi/gssapi/source/test/alpn-test.c index a0870b5e71..87ad9968cd 100644 --- a/gsi/gssapi/source/test/alpn-test.c +++ b/gsi/gssapi/source/test/alpn-test.c @@ -54,7 +54,6 @@ init_no_client_alpn(void) { 3, 'g', 's', 'i', }; - const char *why = ""; major_status = gss_set_sec_context_option( &minor_status, @@ -67,9 +66,7 @@ init_no_client_alpn(void) }); if (major_status != GSS_S_COMPLETE) { - why = "gss_set_sec_context_option"; result = false; - goto fail; } do @@ -95,7 +92,6 @@ init_no_client_alpn(void) if (GSS_ERROR(major_status)) { - why = "gss_init_sec_context"; result = false; break; } @@ -120,7 +116,6 @@ init_no_client_alpn(void) if (GSS_ERROR(major_status)) { - why = "accept_sec_context"; result = false; } } @@ -139,15 +134,12 @@ init_no_client_alpn(void) if (major_status != GSS_S_COMPLETE) { - why = "inquire_context_by_oid"; result = false; - goto fail; } if (data->count != 0) { - why = "inquire_result"; result = false; goto fail; } @@ -212,7 +204,6 @@ init_no_server_alpn(void) gss_buffer_desc accept_generated_token = {0}; bool result = true; OM_uint32 ignore_minor_status = 0; - const char *why = ""; unsigned char client_alpn[] = { 3, 'g', 's', 'i', @@ -229,9 +220,7 @@ init_no_server_alpn(void) }); if (major_status != GSS_S_COMPLETE) { - why = "gss_set_sec_context_option"; result = false; - goto fail; } do @@ -257,7 +246,6 @@ init_no_server_alpn(void) if (GSS_ERROR(major_status)) { - why = "gss_init_sec_context"; result = false; break; } @@ -282,7 +270,6 @@ init_no_server_alpn(void) if (GSS_ERROR(major_status)) { - why = "accept_sec_context"; result = false; } } @@ -300,15 +287,12 @@ init_no_server_alpn(void) &data); if (major_status != GSS_S_COMPLETE) { - why = "inquire_context_by_oid"; result = false; - goto fail; } if (data->count != 0) { - why = "inquire_result"; result = false; goto fail; } @@ -387,7 +371,6 @@ init_alpn1(void) gss_buffer_desc accept_generated_token = {0}; bool result = true; OM_uint32 ignore_minor_status = 0; - const char *why = ""; unsigned char server_alpn[] = { 3, 'g', 's', 'i', @@ -408,9 +391,7 @@ init_alpn1(void) }); if (major_status != GSS_S_COMPLETE) { - why = "gss_set_sec_context_option"; result = false; - goto fail; } major_status = gss_set_sec_context_option( @@ -424,9 +405,7 @@ init_alpn1(void) }); if (major_status != GSS_S_COMPLETE) { - why = "gss_set_sec_context_option"; result = false; - goto fail; } @@ -453,7 +432,6 @@ init_alpn1(void) if (GSS_ERROR(major_status)) { - why = "gss_init_sec_context"; result = false; break; } @@ -478,7 +456,6 @@ init_alpn1(void) if (GSS_ERROR(major_status)) { - why = "accept_sec_context"; result = false; } } @@ -495,9 +472,7 @@ init_alpn1(void) &data); if (major_status != GSS_S_COMPLETE) { - why = "inquire_context_by_oid"; result = false; - goto fail; } @@ -508,7 +483,6 @@ init_alpn1(void) &server_alpn[1], server_alpn[0]) != 0) { - why = "inquire_result"; result = false; goto fail; } @@ -521,9 +495,7 @@ init_alpn1(void) &data); if (major_status != GSS_S_COMPLETE) { - why = "inquire_context_by_oid"; result = false; - goto fail; } @@ -534,7 +506,6 @@ init_alpn1(void) &client_alpn[1], client_alpn[0]) != 0) { - why = "inquire_result"; result = false; goto fail; } @@ -611,7 +582,6 @@ init_alpn_secondary_match(void) gss_buffer_desc accept_generated_token = {0}; bool result = true; OM_uint32 ignore_minor_status = 0; - const char *why = ""; unsigned char server_alpn[] = { 3, 'g', 's', 's', @@ -633,9 +603,7 @@ init_alpn_secondary_match(void) }); if (major_status != GSS_S_COMPLETE) { - why = "gss_set_sec_context_option"; result = false; - goto fail; } @@ -650,9 +618,7 @@ init_alpn_secondary_match(void) }); if (major_status != GSS_S_COMPLETE) { - why = "gss_set_sec_context_option"; result = false; - goto fail; } do @@ -678,7 +644,6 @@ init_alpn_secondary_match(void) if (GSS_ERROR(major_status)) { - why = "gss_init_sec_context"; result = false; break; } @@ -703,7 +668,6 @@ init_alpn_secondary_match(void) if (GSS_ERROR(major_status)) { - why = "accept_sec_context"; result = false; } } @@ -721,9 +685,7 @@ init_alpn_secondary_match(void) &data); if (major_status != GSS_S_COMPLETE) { - why = "inquire_context_by_oid"; result = false; - goto fail; } @@ -734,7 +696,6 @@ init_alpn_secondary_match(void) &server_alpn[5], server_alpn[4]) != 0) { - why = "inquire_result"; result = false; goto fail; } @@ -747,9 +708,7 @@ init_alpn_secondary_match(void) &data); if (major_status != GSS_S_COMPLETE) { - why = "inquire_context_by_oid"; result = false; - goto fail; } @@ -760,7 +719,6 @@ init_alpn_secondary_match(void) &client_alpn[1], client_alpn[0]) != 0) { - why = "inquire_result"; result = false; goto fail; } @@ -856,7 +814,6 @@ init_alpn_nomatch(void) { why = "gss_set_sec_context_option"; result = false; - goto fail; } @@ -873,7 +830,6 @@ init_alpn_nomatch(void) { why = "gss_set_sec_context_option"; result = false; - goto fail; } do @@ -946,7 +902,6 @@ init_alpn_nomatch(void) { why = "inquire_context_by_oid"; result = false; - goto fail; } @@ -1095,7 +1050,7 @@ main(int argc, char *argv[]) fprintf(stderr, "ALPN not supported\n"); exit(77); } - + size_t num_test_cases = sizeof(test_cases)/sizeof(test_cases[0]); printf("1..%zu\n", num_test_cases); diff --git a/gsi/gssapi/source/test/duplicate_name_test.c b/gsi/gssapi/source/test/duplicate_name_test.c index 97ac37334e..68d0743b07 100644 --- a/gsi/gssapi/source/test/duplicate_name_test.c +++ b/gsi/gssapi/source/test/duplicate_name_test.c @@ -37,7 +37,7 @@ duplicate_bad_params_test(void) name_tok.value = subject; name_tok.length = strlen(subject) + 1; name_type = GSS_C_NT_HOSTBASED_SERVICE; - + major_status = gss_import_name(&minor_status, &name_tok, name_type, @@ -96,7 +96,7 @@ duplicate_username_test(void) name_tok.value = subject; name_tok.length = strlen(subject) + 1; name_type = GSS_C_NO_OID; - + major_status = gss_import_name(&minor_status, &name_tok, name_type, @@ -165,7 +165,7 @@ duplicate_anonymous_test(void) name_tok.value = NULL; name_tok.length = 0; name_type = GSS_C_NT_ANONYMOUS; - + major_status = gss_import_name(&minor_status, &name_tok, name_type, @@ -178,7 +178,7 @@ duplicate_anonymous_test(void) return 1; } - + major_status = gss_duplicate_name(&minor_status, gss_name, &name_copy); if(major_status != GSS_S_COMPLETE) { @@ -191,7 +191,7 @@ duplicate_anonymous_test(void) name_copy, &name_tok, NULL); - + if(major_status != GSS_S_COMPLETE) { globus_gsi_gssapi_test_print_error(stderr, major_status, minor_status); @@ -253,7 +253,7 @@ duplicate_hostbase_service_test(void) name_tok.value = subject; name_tok.length = strlen(subject) + 1; name_type = GSS_C_NT_HOSTBASED_SERVICE; - + major_status = gss_import_name(&minor_status, &name_tok, name_type, @@ -325,7 +325,7 @@ duplicate_host_ip_test(void) name_tok.value = subject; name_tok.length = strlen(subject) + 1; name_type = GLOBUS_GSS_C_NT_HOST_IP; - + major_status = gss_import_name(&minor_status, &name_tok, name_type, @@ -407,7 +407,7 @@ duplicate_x509_test(void) for (i = 0; i < SIZEOF_ARRAY(test_certs); i++) { char * test_cert; - + if (test_cert_dir) { test_cert = globus_common_create_string("%s/%s", @@ -417,15 +417,15 @@ duplicate_x509_test(void) { test_cert = test_certs[i]; } - + result = globus_gsi_cred_handle_init(&cred_handle, NULL); if (result != GLOBUS_SUCCESS) { globus_gsi_gssapi_test_print_result(stderr, result); if (test_cert_dir) - { - free(test_cert); + { + free(test_cert); } return 2; @@ -454,7 +454,7 @@ duplicate_x509_test(void) name_tok.value = x509; name_tok.length = sizeof(x509); name_type = GLOBUS_GSS_C_NT_X509; - + major_status = gss_import_name(&minor_status, &name_tok, name_type, @@ -532,7 +532,7 @@ duplicate_x509_test(void) int main() { - int i, rc = 0, failed = 0; + int i, rc = 0; globus_module_descriptor_t *modules[] = { GLOBUS_COMMON_MODULE, @@ -562,10 +562,6 @@ int main() { rc = (*(tests[i].func))(); - if (rc != 0) - { - failed++; - } printf("%s %s\n", rc == 0 ? "ok" : "not ok", tests[i].name); } diff --git a/gsi/gssapi/source/test/gssapi_test_utils.c b/gsi/gssapi/source/test/gssapi_test_utils.c index 0a87c3489f..62aff00808 100644 --- a/gsi/gssapi/source/test/gssapi_test_utils.c +++ b/gsi/gssapi/source/test/gssapi_test_utils.c @@ -72,13 +72,13 @@ init_sec_context( gss_ctx_id_t * context); -gss_cred_id_t +gss_cred_id_t globus_gsi_gssapi_test_acquire_credential() { gss_cred_id_t credential = GSS_C_NO_CREDENTIAL; OM_uint32 major_status = GSS_S_COMPLETE; OM_uint32 minor_status; - + major_status = gss_acquire_cred(&minor_status, GSS_C_NO_NAME, GSS_C_INDEFINITE, @@ -87,18 +87,18 @@ globus_gsi_gssapi_test_acquire_credential() &credential, NULL, NULL); - + if(major_status != GSS_S_COMPLETE) { globus_gsi_gssapi_test_print_error(stderr, major_status, minor_status); globus_gsi_gssapi_test_print_result(stderr, minor_status); return GSS_C_NO_CREDENTIAL; } - + return credential; } -void +void globus_gsi_gssapi_test_release_credential( gss_cred_id_t * credential) { @@ -110,27 +110,27 @@ globus_gsi_gssapi_test_release_credential( globus_bool_t globus_gsi_gssapi_test_authenticate( int fd, - globus_bool_t server, - gss_cred_id_t credential, - gss_ctx_id_t * context_handle, - char ** user_id, + globus_bool_t server, + gss_cred_id_t credential, + gss_ctx_id_t * context_handle, + char ** user_id, gss_cred_id_t * delegated_cred) { OM_uint32 major_status = GSS_S_COMPLETE; - - if (server == GLOBUS_TRUE) + + if (server == GLOBUS_TRUE) { - major_status = accept_sec_context(fd, - user_id, - context_handle, - delegated_cred, - credential); + major_status = accept_sec_context(fd, + user_id, + context_handle, + delegated_cred, + credential); } - else + else { major_status = init_sec_context(fd, - credential, - context_handle); + credential, + context_handle); } return major_status == GSS_S_COMPLETE ? GLOBUS_TRUE : GLOBUS_FALSE; @@ -144,7 +144,7 @@ test_establish_contexts_with_mechs( OM_uint32 flags, OM_uint32 *major_status, OM_uint32 *minor_status) - + { int rc = 0; OM_uint32 init_major_status; @@ -225,7 +225,7 @@ test_establish_contexts_with_mechs( } while (init_major_status == GSS_S_CONTINUE_NEEDED && accept_major_status == GSS_S_CONTINUE_NEEDED); - + if (rc != 0) { init_fail: @@ -261,7 +261,7 @@ test_establish_contexts( OM_uint32 flags, OM_uint32 *major_status, OM_uint32 *minor_status) - + { return test_establish_contexts_with_mechs( init_context, @@ -273,18 +273,18 @@ test_establish_contexts( } -void +void globus_gsi_gssapi_test_cleanup( gss_ctx_id_t * context_handle, char * userid, gss_cred_id_t * delegated_cred) { OM_uint32 minor_status; - + free(userid); - + gss_delete_sec_context(&minor_status, context_handle, GSS_C_NO_BUFFER); - + if (delegated_cred != NULL) { gss_release_cred(&minor_status, delegated_cred); @@ -321,11 +321,11 @@ globus_gsi_gssapi_test_export_context( __LINE__); gss_release_buffer(&minor_status, &export_token); result = GLOBUS_FALSE; - goto exit; + goto exit; } gss_release_buffer(&minor_status, &export_token); - + exit: return result; } @@ -346,7 +346,7 @@ globus_gsi_gssapi_test_import_context( import_token.value = malloc(import_token.length); fread(import_token.value, import_token.length, 1, context_file); - + major_status = gss_import_sec_context( &minor_status, (gss_buffer_t) & import_token, @@ -360,9 +360,9 @@ globus_gsi_gssapi_test_import_context( result = GLOBUS_FALSE; goto exit; } - + gss_release_buffer(&minor_status, &import_token); - + exit: return result; @@ -379,12 +379,12 @@ globus_gsi_gssapi_test_send_hello( static char * hello = "HelloHello"; gss_buffer_desc send_token = GSS_C_EMPTY_BUFFER; gss_buffer_desc input_token; - long rc; + long rc = 0; long written = 0; - + input_token.length = 11; input_token.value = hello; - + major_status = gss_wrap(&minor_status, context, 0, @@ -392,7 +392,7 @@ globus_gsi_gssapi_test_send_hello( (gss_buffer_t) &input_token, NULL, (gss_buffer_t) &send_token); - + if(GSS_ERROR(major_status)) { globus_gsi_gssapi_test_print_error( @@ -412,10 +412,10 @@ globus_gsi_gssapi_test_send_hello( } /*printf("Wrote %d out of %d bytes\n", written, send_token.length); */ - + gss_release_buffer(&minor_status, &send_token); - + exit: return result; } @@ -432,7 +432,7 @@ globus_gsi_gssapi_test_receive_hello( long rc; gss_buffer_desc recv_token = GSS_C_EMPTY_BUFFER; gss_buffer_desc output_token = GSS_C_EMPTY_BUFFER; - + while((rc = recv(fd,&buffer[recv_token.length],128,0)) > 0 && (recv_token.length += rc)); @@ -444,7 +444,7 @@ globus_gsi_gssapi_test_receive_hello( } /* printf("Read %d bytes\n", recv_token.length); */ - + recv_token.value = buffer; major_status = gss_unwrap(&minor_status, @@ -466,7 +466,7 @@ globus_gsi_gssapi_test_receive_hello( result = GLOBUS_FALSE; } - gss_release_buffer(&minor_status, &output_token); + gss_release_buffer(&minor_status, &output_token); exit: return result; @@ -483,11 +483,11 @@ globus_gsi_gssapi_test_dump_cert_chain( globus_bool_t result = GLOBUS_TRUE; FILE * dump_file; gss_OID_desc cert_chain_oid = - {11, "\x2b\x06\x01\x04\x01\x9b\x50\x01\x01\x01\x08"}; + {11, "\x2b\x06\x01\x04\x01\x9b\x50\x01\x01\x01\x08"}; gss_buffer_set_t cert_chain_buffers; X509 * cert; const unsigned char * tmp_ptr; - + dump_file = fopen(filename,"w"); if(dump_file == NULL) @@ -526,7 +526,7 @@ globus_gsi_gssapi_test_dump_cert_chain( &cert_chain_buffers); goto exit; } - + X509_print_fp(dump_file, cert); X509_free(cert); @@ -539,7 +539,7 @@ globus_gsi_gssapi_test_dump_cert_chain( { fclose(dump_file); } - + return result; } @@ -562,20 +562,20 @@ get_token( if(n_read < 0) { if(errno == EINTR) - { + { continue; } else - { + { return errno; } } else - { + { num_read += n_read; } } - + /* decode the token length from network byte order: 4 byte, big endian */ *token_length = (((size_t) token_length_buffer[0]) << 24) & 0xffff; @@ -588,7 +588,7 @@ get_token( /* token too large */ return 1; } - + *token = malloc(*token_length); if(*token == NULL) @@ -607,20 +607,20 @@ get_token( if(n_read < 0) { if(errno == EINTR) - { + { continue; } else - { + { return errno; } } else - { + { num_read += n_read; } } - + return 0; } @@ -649,20 +649,20 @@ put_token( if(n_written < 0) { if(errno == EINTR) - { + { continue; } else - { + { return errno; } } else - { + { num_written += n_written; } } - + num_written = 0; while(num_written < token_length) @@ -673,16 +673,16 @@ put_token( if(n_written < 0) { if(errno == EINTR) - { + { continue; } else - { + { return errno; } } else - { + { num_written += n_written; } } @@ -710,7 +710,7 @@ accept_sec_context( gss_buffer_desc name_buffer; gss_OID mech_type = GSS_C_NO_OID; OM_uint32 time_ret; - + if(credential == GSS_C_NO_CREDENTIAL) { globus_libc_printf("Failed to acquire credentials\n"); @@ -740,9 +740,9 @@ accept_sec_context( &time_ret, delegated_cred); - if(major_status != GSS_S_COMPLETE && - major_status != GSS_S_CONTINUE_NEEDED) - { + if(major_status != GSS_S_COMPLETE && + major_status != GSS_S_CONTINUE_NEEDED) + { char * error_string = NULL; globus_object_t * error_obj = NULL; @@ -751,8 +751,8 @@ accept_sec_context( fprintf(stderr, "ERROR CHAIN:\n%s\n", error_string); free(error_string); globus_object_free(error_obj); - abort(); - } + abort(); + } if(output_token.length != 0) { @@ -764,7 +764,7 @@ accept_sec_context( major_status = GSS_S_DEFECTIVE_TOKEN|GSS_S_CALL_INACCESSIBLE_WRITE; } - + gss_release_buffer(&minor_status2, &output_token); } @@ -799,9 +799,9 @@ accept_sec_context( /* authentication succeeded, figure out who it is */ major_status = gss_display_name(&minor_status, - client_name, - &name_buffer, - NULL); + client_name, + &name_buffer, + NULL); *name = (char *)name_buffer.value; @@ -817,50 +817,50 @@ init_sec_context( gss_cred_id_t credential, gss_ctx_id_t * context) { - OM_uint32 minor_status2 = 0; - OM_uint32 minor_status = 0; - OM_uint32 major_status = GSS_S_COMPLETE; - OM_uint32 req_flags = GSS_C_MUTUAL_FLAG|GSS_C_DELEG_FLAG; - OM_uint32 ret_flags = 0; - int token_status = 0; - gss_name_t target_name = GSS_C_NO_NAME; - globus_bool_t context_established = GLOBUS_FALSE; - gss_OID * actual_mech_type = NULL; - OM_uint32 time_ret; - gss_buffer_desc input_token = GSS_C_EMPTY_BUFFER; - gss_buffer_desc output_token = GSS_C_EMPTY_BUFFER; + OM_uint32 minor_status2 = 0; + OM_uint32 minor_status = 0; + OM_uint32 major_status = GSS_S_COMPLETE; + OM_uint32 req_flags = GSS_C_MUTUAL_FLAG|GSS_C_DELEG_FLAG; + OM_uint32 ret_flags = 0; + int token_status = 0; + gss_name_t target_name = GSS_C_NO_NAME; + globus_bool_t context_established = GLOBUS_FALSE; + gss_OID * actual_mech_type = NULL; + OM_uint32 time_ret; + gss_buffer_desc input_token = GSS_C_EMPTY_BUFFER; + gss_buffer_desc output_token = GSS_C_EMPTY_BUFFER; major_status = gss_inquire_cred(&minor_status, - credential, - &target_name, - NULL, - NULL, - NULL); + credential, + &target_name, + NULL, + NULL, + NULL); if(major_status != GSS_S_COMPLETE) { - globus_libc_printf("Failed to determine my name\n"); - return 1; + globus_libc_printf("Failed to determine my name\n"); + return 1; } while(!context_established) { - major_status = gss_init_sec_context(&minor_status, - credential, - context, - target_name, - GSS_C_NO_OID, /*mech_type*/ - req_flags, - 0, /* default time */ - GSS_C_NO_CHANNEL_BINDINGS, - &input_token, - actual_mech_type, - &output_token, - &ret_flags, - &time_ret); - if(major_status != GSS_S_COMPLETE && - major_status != GSS_S_CONTINUE_NEEDED) - { + major_status = gss_init_sec_context(&minor_status, + credential, + context, + target_name, + GSS_C_NO_OID, /*mech_type*/ + req_flags, + 0, /* default time */ + GSS_C_NO_CHANNEL_BINDINGS, + &input_token, + actual_mech_type, + &output_token, + &ret_flags, + &time_ret); + if(major_status != GSS_S_COMPLETE && + major_status != GSS_S_CONTINUE_NEEDED) + { char * error_string = NULL; globus_object_t * error_obj = NULL; @@ -869,61 +869,61 @@ init_sec_context( fprintf(stderr, "ERROR CHAIN:\n%s\n", error_string); free(error_string); globus_object_free(error_obj); - abort(); - } - /* free any token we've just processed */ - if(input_token.length > 0) - { - gss_release_buffer(&minor_status2, + abort(); + } + /* free any token we've just processed */ + if(input_token.length > 0) + { + gss_release_buffer(&minor_status2, &input_token); - } - - /* and send any new token to the server */ - if(output_token.length != 0) - { - token_status = put_token(client_fd, - output_token.value, - output_token.length); - if(token_status != 0) - { - major_status = - GSS_S_DEFECTIVE_TOKEN|GSS_S_CALL_INACCESSIBLE_WRITE; - } + } + + /* and send any new token to the server */ + if(output_token.length != 0) + { + token_status = put_token(client_fd, + output_token.value, + output_token.length); + if(token_status != 0) + { + major_status = + GSS_S_DEFECTIVE_TOKEN|GSS_S_CALL_INACCESSIBLE_WRITE; + } gss_release_buffer(&minor_status, &output_token); - } - - if (GSS_ERROR(major_status)) - { - printf(" Failed to establish security context (init).\n"); + } + + if (GSS_ERROR(major_status)) + { + printf(" Failed to establish security context (init).\n"); globus_gsi_gssapi_test_print_error( stderr, major_status, minor_status); - if (*context != GSS_C_NO_CONTEXT) - { - gss_delete_sec_context(&minor_status2, - context, - GSS_C_NO_BUFFER); - break; - } - } - - if(major_status & GSS_S_CONTINUE_NEEDED) - { - token_status = get_token(client_fd, - (unsigned char **) &input_token.value, - &input_token.length); - if(token_status != 0) - { - major_status = - GSS_S_DEFECTIVE_TOKEN | GSS_S_CALL_INACCESSIBLE_READ; - break; - } - } - else - { - context_established = 1; - } + if (*context != GSS_C_NO_CONTEXT) + { + gss_delete_sec_context(&minor_status2, + context, + GSS_C_NO_BUFFER); + break; + } + } + + if(major_status & GSS_S_CONTINUE_NEEDED) + { + token_status = get_token(client_fd, + (unsigned char **) &input_token.value, + &input_token.length); + if(token_status != 0) + { + major_status = + GSS_S_DEFECTIVE_TOKEN | GSS_S_CALL_INACCESSIBLE_READ; + break; + } + } + else + { + context_established = 1; + } } /* while() */ if (target_name != GSS_C_NO_NAME) diff --git a/gsi/gssapi/source/test/indicate_mechs_test.c b/gsi/gssapi/source/test/indicate_mechs_test.c index 2cd888e443..a6bf4489ed 100644 --- a/gsi/gssapi/source/test/indicate_mechs_test.c +++ b/gsi/gssapi/source/test/indicate_mechs_test.c @@ -69,7 +69,7 @@ indicate_mechs_test(void) for (i = 0; i < oids->count; i++) { - static gss_OID_desc gssapi_mech_gsi = + static gss_OID_desc gssapi_mech_gsi = {9, "\x2b\x06\x01\x04\x01\x9b\x50\x01\x01"}; if (oids->elements[i].length == gssapi_mech_gsi.length && memcmp(oids->elements[i].elements, @@ -105,8 +105,8 @@ indicate_mechs_v2_test(void) OM_uint32 major_status = 0; OM_uint32 minor_status = 0; int i; - static gss_OID_desc gssapi_mech_gsi = - {10, "\x2b\x06\x01\x04\x01\x9b\x50\x01\x01\x01"}; + static gss_OID_desc gssapi_mech_gsi = + {10, "\x2b\x06\x01\x04\x01\x9b\x50\x01\x01\x01"}; if (OPENSSL_VERSION_NUMBER < 0x10001000L) { @@ -150,7 +150,7 @@ indicate_mechs_v2_test(void) int main() { - int i, rc = 0, failed = 0; + int i, rc = 0; globus_module_descriptor_t *modules[] = { GLOBUS_COMMON_MODULE, @@ -189,7 +189,6 @@ int main() } else { - failed++; format = "not ok %d - %s\n"; } diff --git a/gsi/gssapi/source/test/release_name_test.c b/gsi/gssapi/source/test/release_name_test.c index 5a30a43f43..60b203fc99 100644 --- a/gsi/gssapi/source/test/release_name_test.c +++ b/gsi/gssapi/source/test/release_name_test.c @@ -36,7 +36,7 @@ release_bad_params(void) name_tok.value = subject; name_tok.length = strlen(subject) + 1; name_type = GSS_C_NT_HOSTBASED_SERVICE; - + major_status = gss_import_name(&minor_status, &name_tok, name_type, @@ -90,7 +90,7 @@ release_username(void) name_tok.value = subject; name_tok.length = strlen(subject) + 1; name_type = GSS_C_NO_OID; - + major_status = gss_import_name(&minor_status, &name_tok, name_type, @@ -127,7 +127,7 @@ release_anonymous(void) name_tok.value = NULL; name_tok.length = 0; name_type = GSS_C_NT_ANONYMOUS; - + major_status = gss_import_name(&minor_status, &name_tok, name_type, @@ -166,7 +166,7 @@ release_hostbase_service(void) name_tok.value = subject; name_tok.length = strlen(subject) + 1; name_type = GSS_C_NT_HOSTBASED_SERVICE; - + major_status = gss_import_name(&minor_status, &name_tok, name_type, @@ -205,7 +205,7 @@ release_host_ip(void) name_tok.value = subject; name_tok.length = strlen(subject) + 1; name_type = GSS_C_NT_HOSTBASED_SERVICE; - + major_status = gss_import_name(&minor_status, &name_tok, name_type, @@ -258,7 +258,7 @@ release_x509(void) for (i = 0; i < SIZEOF_ARRAY(test_certs); i++) { char * test_cert; - + test_cert = globus_common_create_string("%s/%s", test_cert_dir, test_certs[i]); @@ -290,7 +290,7 @@ release_x509(void) name_tok.value = x509; name_tok.length = sizeof(x509); name_type = GLOBUS_GSS_C_NT_X509; - + major_status = gss_import_name(&minor_status, &name_tok, name_type, @@ -326,7 +326,7 @@ release_x509(void) int main() { - int i, rc = 0, failed = 0; + int i, rc = 0; globus_module_descriptor_t *modules[] = { GLOBUS_COMMON_MODULE, @@ -356,10 +356,6 @@ int main() { rc = (*(tests[i].func))(); - if (rc != 0) - { - failed++; - } printf("%s %s\n", rc == 0 ? "ok" : "not ok", tests[i].name); } diff --git a/gsi/openssl_module/source/configure.ac b/gsi/openssl_module/source/configure.ac index 9018db9484..920ed91d68 100644 --- a/gsi/openssl_module/source/configure.ac +++ b/gsi/openssl_module/source/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ([2.60]) -AC_INIT([globus_openssl_module],[5.2],[https://github.com/gridcf/gct/issues]) +AC_INIT([globus_openssl_module],[5.3],[https://github.com/gridcf/gct/issues]) AC_CONFIG_MACRO_DIR([m4]) AC_SUBST([MAJOR_VERSION], [${PACKAGE_VERSION%%.*}]) AC_SUBST([MINOR_VERSION], [${PACKAGE_VERSION##*.}]) diff --git a/gsi/openssl_module/source/library/globus_openssl.c b/gsi/openssl_module/source/library/globus_openssl.c index 4393432c4d..510549ab23 100644 --- a/gsi/openssl_module/source/library/globus_openssl.c +++ b/gsi/openssl_module/source/library/globus_openssl.c @@ -38,7 +38,7 @@ globus_l_openssl_deactivate(void); #if OPENSSL_VERSION_NUMBER < 0x10100000L static unsigned long globus_l_openssl_thread_id(void); - + static void globus_l_openssl_locking_cb( int mode, @@ -71,9 +71,8 @@ globus_l_openssl_activate(void) { int pci_NID; int pci_old_NID; - X509V3_EXT_METHOD * pci_x509v3_ext_meth = NULL; X509V3_EXT_METHOD * pci_old_x509v3_ext_meth = NULL; - + SSL_library_init(); globus_module_activate(GLOBUS_COMMON_MODULE); globus_module_activate(GLOBUS_GSI_OPENSSL_ERROR_MODULE); @@ -161,7 +160,9 @@ static int globus_l_openssl_deactivate(void) { +#if OPENSSL_VERSION_NUMBER < 0x10100000L int i; +#endif OBJ_cleanup(); diff --git a/gsi/proxy/proxy_core/source/configure.ac b/gsi/proxy/proxy_core/source/configure.ac index cc2a4a2f66..04aaa11dbf 100644 --- a/gsi/proxy/proxy_core/source/configure.ac +++ b/gsi/proxy/proxy_core/source/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ([2.60]) -AC_INIT([globus_gsi_proxy_core],[9.9],[https://github.com/gridcf/gct/issues]) +AC_INIT([globus_gsi_proxy_core],[9.10],[https://github.com/gridcf/gct/issues]) AC_CONFIG_MACRO_DIR([m4]) AC_SUBST([MAJOR_VERSION], [${PACKAGE_VERSION%%.*}]) AC_SUBST([MINOR_VERSION], [${PACKAGE_VERSION##*.}]) diff --git a/gsi/proxy/proxy_core/source/library/globus_gsi_proxy.c b/gsi/proxy/proxy_core/source/library/globus_gsi_proxy.c index 0a4878436e..b07c1fecd7 100644 --- a/gsi/proxy/proxy_core/source/library/globus_gsi_proxy.c +++ b/gsi/proxy/proxy_core/source/library/globus_gsi_proxy.c @@ -73,7 +73,7 @@ globus_l_gsi_proxy_determine_type( /** * Module descriptor static initializer. */ -globus_module_descriptor_t globus_i_gsi_proxy_module = +globus_module_descriptor_t globus_i_gsi_proxy_module = { "globus_gsi_proxy", globus_l_gsi_proxy_activate, @@ -98,7 +98,7 @@ globus_l_gsi_proxy_activate(void) /* set the debug level */ tmpstring = globus_module_getenv("GLOBUS_GSI_PROXY_DEBUG_LEVEL"); - + if(tmpstring != GLOBUS_NULL) { globus_i_gsi_proxy_debug_level = atoi(tmpstring); @@ -109,7 +109,7 @@ globus_l_gsi_proxy_activate(void) } } - /* set the location for the debugging for the + /* set the location for the debugging for the * debugging output (file or stderr) */ tmpstring = globus_module_getenv("GLOBUS_GSI_PROXY_DEBUG_FILE"); @@ -151,7 +151,7 @@ globus_l_gsi_proxy_activate(void) { goto exit; } - + result = globus_module_activate(GLOBUS_GSI_CREDENTIAL_MODULE); if(result != GLOBUS_SUCCESS) { @@ -192,19 +192,19 @@ globus_l_gsi_proxy_deactivate(void) /* globus_l_gsi_proxy_deactivate() */ #endif /* GLOBUS_DONT_DOCUMENT_INTERNAL */ - + /** * @brief Create a proxy credential request * @ingroup globus_gsi_proxy_operations * @details - * This function creates a proxy credential request, an unsigned + * This function creates a proxy credential request, an unsigned * certificate and the corresponding private key, based on the handle * that is passed in. * * The public part of the request is written to the BIO supplied in * the output_bio parameter. After the request is written, the * PROXYCERTINFO extension contained in the handle is written - * to the BIO. + * to the BIO. * * The proxy handle is updated with the private key. * @@ -213,7 +213,7 @@ globus_l_gsi_proxy_deactivate(void) * @param[out] output_bio * A BIO to write the resulting request structure to. * @return - * GLOBUS_SUCCESS unless an error occurred, in which case, + * GLOBUS_SUCCESS unless an error occurred, in which case, * a globus error object ID is returned */ globus_result_t @@ -231,7 +231,7 @@ globus_gsi_proxy_create_req( int rc = 0; GLOBUS_I_GSI_PROXY_DEBUG_ENTER; - + if(handle == NULL) { GLOBUS_GSI_PROXY_ERROR_RESULT( @@ -275,7 +275,7 @@ globus_gsi_proxy_create_req( { GLOBUS_GSI_PROXY_OPENSSL_ERROR_RESULT( result, - GLOBUS_GSI_PROXY_ERROR_WITH_PRIVATE_KEY, + GLOBUS_GSI_PROXY_ERROR_WITH_PRIVATE_KEY, (_PCSL("Couldn't generate RSA key pair for proxy handle"))); goto exit; } @@ -285,7 +285,7 @@ globus_gsi_proxy_create_req( { GLOBUS_GSI_PROXY_OPENSSL_ERROR_RESULT( result, - GLOBUS_GSI_PROXY_ERROR_WITH_PRIVATE_KEY, + GLOBUS_GSI_PROXY_ERROR_WITH_PRIVATE_KEY, (_PCSL("Couldn't generate RSA key pair for proxy handle"))); goto exit; } @@ -294,7 +294,7 @@ globus_gsi_proxy_create_req( { GLOBUS_GSI_PROXY_OPENSSL_ERROR_RESULT( result, - GLOBUS_GSI_PROXY_ERROR_WITH_PRIVATE_KEY, + GLOBUS_GSI_PROXY_ERROR_WITH_PRIVATE_KEY, (_PCSL("Couldn't generate RSA key pair for proxy handle"))); goto exit; } @@ -303,7 +303,7 @@ globus_gsi_proxy_create_req( { GLOBUS_GSI_PROXY_OPENSSL_ERROR_RESULT( result, - GLOBUS_GSI_PROXY_ERROR_WITH_PRIVATE_KEY, + GLOBUS_GSI_PROXY_ERROR_WITH_PRIVATE_KEY, (_PCSL("Couldn't generate RSA key pair for proxy handle"))); goto exit; } @@ -317,7 +317,7 @@ globus_gsi_proxy_create_req( { GLOBUS_GSI_PROXY_OPENSSL_ERROR_RESULT( result, - GLOBUS_GSI_PROXY_ERROR_WITH_PRIVATE_KEY, + GLOBUS_GSI_PROXY_ERROR_WITH_PRIVATE_KEY, (_PCSL("Couldn't generate RSA key pair for proxy handle"))); goto exit; } @@ -361,7 +361,7 @@ globus_gsi_proxy_create_req( } req_name_entry = X509_NAME_ENTRY_create_by_NID( - NULL, + NULL, NID_commonName, V_ASN1_APP_CHOOSE, (unsigned char *) "NULL SUBJECT NAME ENTRY", @@ -398,7 +398,7 @@ globus_gsi_proxy_create_req( X509_REQ_set_subject_name(handle->req, req_name); X509_NAME_free(req_name); req_name = NULL; - + if(GLOBUS_GSI_CERT_UTILS_IS_GSI_3_PROXY(handle->type)) { pci_NID = OBJ_txt2nid(PROXYCERTINFO_OLD_OID); @@ -422,7 +422,7 @@ globus_gsi_proxy_create_req( if (ext_method->i2d) { - + length = ext_method->i2d(handle->proxy_cert_info, NULL); if(length < 0) { @@ -433,7 +433,7 @@ globus_gsi_proxy_create_req( " to DER encoded form"))); goto error_exit; } - + data = malloc(length); if(!data) @@ -443,9 +443,9 @@ globus_gsi_proxy_create_req( } der_data = data; - + length = ext_method->i2d(handle->proxy_cert_info, &der_data); - + if(length < 0) { GLOBUS_GSI_PROXY_OPENSSL_ERROR_RESULT( @@ -458,7 +458,7 @@ globus_gsi_proxy_create_req( } ext_data = ASN1_OCTET_STRING_new(); - + if(!ASN1_OCTET_STRING_set(ext_data, data, length)) { GLOBUS_GSI_PROXY_OPENSSL_ERROR_RESULT( @@ -468,11 +468,11 @@ globus_gsi_proxy_create_req( " to DER encoded form"))); ASN1_OCTET_STRING_free(ext_data); free(data); - goto error_exit; + goto error_exit; } free(data); - + pci_ext = X509_EXTENSION_create_by_NID(NULL, pci_NID, 1, @@ -486,7 +486,7 @@ globus_gsi_proxy_create_req( ASN1_OCTET_STRING_free(ext_data); goto error_exit; } - + ASN1_OCTET_STRING_free(ext_data); } @@ -548,7 +548,7 @@ globus_gsi_proxy_create_req( } memcpy( policy, - ASN1_STRING_data(handle->proxy_cert_info->proxyPolicy->policy), + ASN1_STRING_get0_data(handle->proxy_cert_info->proxyPolicy->policy), policy_len); policy[policy_len] = '\0'; tmp = globus_common_create_string("%s,policy:text:%s", @@ -593,7 +593,7 @@ globus_gsi_proxy_create_req( GLOBUS_I_GSI_PROXY_DEBUG_PRINT_PCI(3, handle->proxy_cert_info); GLOBUS_I_GSI_PROXY_DEBUG_PRINT(3, "****** END PROXYCERTINFO ******\n"); } - + if (!X509_REQ_sign(handle->req, handle->proxy_key, handle->attrs->signing_algorithm ? handle->attrs->signing_algorithm @@ -665,7 +665,7 @@ globus_gsi_proxy_create_req( * @param[in] input_bio * A BIO to read a request structure from. * @return - * GLOBUS_SUCCESS unless an error occurred, in which case, + * GLOBUS_SUCCESS unless an error occurred, in which case, * a globus error object ID is returned */ globus_result_t @@ -676,7 +676,7 @@ globus_gsi_proxy_inquire_req( globus_result_t result = GLOBUS_SUCCESS; PROXY_POLICY * policy = NULL; ASN1_OBJECT * policy_lang = NULL; - ASN1_OBJECT * extension_oid = NULL; + const ASN1_OBJECT * extension_oid = NULL; int policy_nid = NID_undef; int pci_NID = NID_undef; int pci_old_NID = NID_undef; @@ -684,7 +684,7 @@ globus_gsi_proxy_inquire_req( int i = 0; STACK_OF(X509_EXTENSION) * req_extensions = NULL; X509_EXTENSION * extension = NULL; - + GLOBUS_I_GSI_PROXY_DEBUG_ENTER; if(handle == NULL) @@ -725,13 +725,13 @@ globus_gsi_proxy_inquire_req( pci_NID = OBJ_txt2nid(PROXYCERTINFO_OID); pci_old_NID = OBJ_txt2nid(PROXYCERTINFO_OLD_OID); - + for(i=0;iproxy_cert_info) @@ -752,7 +752,7 @@ globus_gsi_proxy_inquire_req( break; } } - + if(handle->proxy_cert_info != NULL) { if((policy = handle->proxy_cert_info->proxyPolicy) == NULL) @@ -763,7 +763,7 @@ globus_gsi_proxy_inquire_req( (_PCSL("Can't get policy from PROXYCERTINFO extension"))); goto done; } - + if((policy_lang = policy->policyLanguage) == NULL) { GLOBUS_GSI_PROXY_OPENSSL_ERROR_RESULT( @@ -773,11 +773,11 @@ globus_gsi_proxy_inquire_req( " PROXYCERTINFO extension"))); goto done; } - + policy_nid = OBJ_obj2nid(policy_lang); if(nid == pci_old_NID) - { + { if(policy_nid == OBJ_txt2nid(IMPERSONATION_PROXY_OID)) { handle->type= @@ -843,7 +843,7 @@ globus_gsi_proxy_inquire_req( { sk_X509_EXTENSION_pop_free(req_extensions, X509_EXTENSION_free); } - + GLOBUS_I_GSI_PROXY_DEBUG_EXIT; return result; } @@ -863,7 +863,7 @@ globus_gsi_proxy_inquire_req( * A GSI Proxy handle to use for the signing operation. * @param[in] issuer_credential * The credential structure to be used for signing the proxy - * certificate. + * certificate. * @param[in] peer_credential * The credential structure that contains the certificate to * be resigned. @@ -871,7 +871,7 @@ globus_gsi_proxy_inquire_req( * A credential structure that upon return will contain the resigned * certificate and associated certificate chain. * @return - * GLOBUS_SUCCESS unless an error occurred, in which case, + * GLOBUS_SUCCESS unless an error occurred, in which case, * a globus error object ID is returned */ globus_result_t @@ -887,9 +887,9 @@ globus_gsi_proxy_resign_cert( EVP_PKEY * peer_pubkey = NULL; X509 * new_pc = NULL; STACK_OF(X509) * issuer_cert_chain = NULL; - + GLOBUS_I_GSI_PROXY_DEBUG_ENTER; - + if(handle == NULL) { GLOBUS_GSI_PROXY_OPENSSL_ERROR_RESULT( @@ -928,7 +928,7 @@ globus_gsi_proxy_resign_cert( __func__)); goto done; } - + result = globus_gsi_cred_get_cert(peer_credential, &peer_cert); if(result != GLOBUS_SUCCESS) { @@ -980,7 +980,7 @@ globus_gsi_proxy_resign_cert( result = globus_gsi_cred_get_cert_chain(issuer_credential, &issuer_cert_chain); - + if(result != GLOBUS_SUCCESS) { GLOBUS_GSI_PROXY_ERROR_CHAIN_RESULT( @@ -992,8 +992,8 @@ globus_gsi_proxy_resign_cert( if(issuer_cert_chain == NULL) { issuer_cert_chain = sk_X509_new_null(); - } - + } + result = globus_gsi_cred_get_cert(issuer_credential, &issuer_cert); if(result != GLOBUS_SUCCESS) @@ -1006,7 +1006,7 @@ globus_gsi_proxy_resign_cert( sk_X509_unshift(issuer_cert_chain, issuer_cert); issuer_cert = NULL; - + result = globus_gsi_cred_set_cert_chain(*resigned_credential, issuer_cert_chain); @@ -1055,11 +1055,11 @@ globus_gsi_proxy_resign_cert( * A GSI Proxy handle to use for the signing operation. * @param[in] issuer_credential * The credential structure to be used for signing the proxy - * certificate. + * certificate. * @param[out] output_bio * A BIO to write the resulting certificate to. * @return - * GLOBUS_SUCCESS unless an error occurred, in which case, + * GLOBUS_SUCCESS unless an error occurred, in which case, * a globus error object ID is returned */ globus_result_t @@ -1072,9 +1072,9 @@ globus_gsi_proxy_sign_req( EVP_PKEY * req_pubkey = NULL; globus_result_t result = GLOBUS_SUCCESS; int res; - + GLOBUS_I_GSI_PROXY_DEBUG_ENTER; - + if(handle == NULL || issuer_credential == NULL) { GLOBUS_GSI_PROXY_OPENSSL_ERROR_RESULT( @@ -1083,7 +1083,7 @@ globus_gsi_proxy_sign_req( (_PCSL("NULL handle passed to function: %s"), __func__)); goto done; } - + if(output_bio == NULL) { GLOBUS_GSI_PROXY_ERROR_RESULT( @@ -1140,14 +1140,14 @@ globus_gsi_proxy_sign_req( if(new_pc) { - X509_free(new_pc); + X509_free(new_pc); } - + if(req_pubkey) { EVP_PKEY_free(req_pubkey); } - + GLOBUS_I_GSI_PROXY_DEBUG_EXIT; return result; } @@ -1169,6 +1169,7 @@ globus_l_gsi_proxy_sign_key( X509 * issuer_cert = NULL; X509_EXTENSION * pci_ext = NULL; X509_EXTENSION * extension; + const X509_EXTENSION * extension_c; const EVP_MD * issuer_digest; int position; EVP_PKEY * issuer_pkey = NULL; @@ -1176,9 +1177,9 @@ globus_l_gsi_proxy_sign_key( ASN1_INTEGER * serial_number = NULL; globus_gsi_cert_utils_cert_type_t proxy_type = 0; globus_gsi_cert_utils_cert_type_t old_type = 0; - + GLOBUS_I_GSI_PROXY_DEBUG_ENTER; - + if(handle == NULL || issuer_credential == NULL) { GLOBUS_GSI_PROXY_OPENSSL_ERROR_RESULT( @@ -1187,7 +1188,7 @@ globus_l_gsi_proxy_sign_key( (_PCSL("NULL handle passed to function: %s"), __func__)); goto done; } - + if(signed_cert == NULL) { GLOBUS_GSI_PROXY_ERROR_RESULT( @@ -1217,7 +1218,7 @@ globus_l_gsi_proxy_sign_key( } *signed_cert = NULL; - + result = globus_gsi_cred_get_cert(issuer_credential, &issuer_cert); if(result != GLOBUS_SUCCESS) { @@ -1274,7 +1275,7 @@ globus_l_gsi_proxy_sign_key( { pci_NID = OBJ_txt2nid(PROXYCERTINFO_OID); } - + if(pci_NID != NID_undef) { const EVP_MD * sha1 = EVP_sha1(); @@ -1287,8 +1288,8 @@ globus_l_gsi_proxy_sign_key( ASN1_digest((i2d_of_void *) i2d_PUBKEY,sha1,(char *) public_key,md,&len); - sub_hash = md[0] + (md[1] + (md[2] + (md[3] >> 1) * 256) * 256) * 256; - + sub_hash = md[0] + (md[1] + (md[2] + (md[3] >> 1) * 256) * 256) * 256; + if(handle->common_name) { common_name = strdup(handle->common_name); @@ -1300,7 +1301,7 @@ globus_l_gsi_proxy_sign_key( } } else - { + { common_name = malloc(sizeof(long)*4 + 1); if(!common_name) @@ -1310,17 +1311,17 @@ globus_l_gsi_proxy_sign_key( goto done; } - sprintf(common_name, "%ld", sub_hash); + sprintf(common_name, "%ld", sub_hash); } serial_number = ASN1_INTEGER_new(); ASN1_INTEGER_set(serial_number, sub_hash); - + if(ext_method->i2d) { - pci_DER_length = ext_method->i2d(handle->proxy_cert_info, + pci_DER_length = ext_method->i2d(handle->proxy_cert_info, NULL); if(pci_DER_length < 0) { @@ -1331,7 +1332,7 @@ globus_l_gsi_proxy_sign_key( " to DER encoded form"))); goto done; } - + pci_DER = malloc(pci_DER_length); if(!pci_DER) @@ -1339,7 +1340,7 @@ globus_l_gsi_proxy_sign_key( GLOBUS_GSI_PROXY_MALLOC_ERROR(pci_DER_length); goto done; } - + mod_pci_DER = pci_DER; pci_DER_length = ext_method->i2d(handle->proxy_cert_info, (unsigned char **) &mod_pci_DER); @@ -1352,7 +1353,7 @@ globus_l_gsi_proxy_sign_key( " to DER encoded form"))); goto done; } - + pci_DER_string = ASN1_OCTET_STRING_new(); if(pci_DER_string == NULL) { @@ -1363,13 +1364,12 @@ globus_l_gsi_proxy_sign_key( " of a PROXYCERTINFO struct"))); goto done; } - - pci_DER_string->data = pci_DER; - pci_DER_string->length = pci_DER_length; - + + ASN1_OCTET_STRING_set(pci_DER_string, pci_DER, pci_DER_length); + pci_ext = X509_EXTENSION_create_by_NID( - &pci_ext, - pci_NID, + &pci_ext, + pci_NID, 1, pci_DER_string); @@ -1442,7 +1442,7 @@ globus_l_gsi_proxy_sign_key( } memcpy( policy, - ASN1_STRING_data(handle->proxy_cert_info->proxyPolicy->policy), + ASN1_STRING_get0_data(handle->proxy_cert_info->proxyPolicy->policy), policy_len); policy[policy_len] = '\0'; tmp = globus_common_create_string("%s,policy:text:%s", @@ -1474,7 +1474,7 @@ globus_l_gsi_proxy_sign_key( X509_EXTENSION_set_critical(pci_ext, 1); } } - + if(!X509_add_ext(*signed_cert, pci_ext, 0)) { GLOBUS_GSI_PROXY_OPENSSL_ERROR_RESULT( @@ -1507,15 +1507,15 @@ globus_l_gsi_proxy_sign_key( unsigned char * mod_ku_DER; int ku_DER_length; - if(!(extension = X509_get_ext(issuer_cert, position))) + if(!(extension_c = X509_get_ext(issuer_cert, position))) { GLOBUS_GSI_PROXY_OPENSSL_ERROR_RESULT( result, GLOBUS_GSI_PROXY_ERROR_WITH_X509_EXTENSIONS, (_PCSL("Couldn't get keyUsage extension from issuer cert"))); - goto done; + goto done; } - + if(!(usage = X509_get_ext_d2i(issuer_cert, NID_key_usage, NULL, NULL))) { GLOBUS_GSI_PROXY_OPENSSL_ERROR_RESULT( @@ -1527,10 +1527,10 @@ globus_l_gsi_proxy_sign_key( } /* clear bits specified in draft */ - + ASN1_BIT_STRING_set_bit(usage, 1, 0); /* Non Repudiation */ ASN1_BIT_STRING_set_bit(usage, 5, 0); /* Certificate Sign */ - + ku_DER_length = i2d_ASN1_BIT_STRING(usage, NULL); if(ku_DER_length < 0) @@ -1543,7 +1543,7 @@ globus_l_gsi_proxy_sign_key( ASN1_BIT_STRING_free(usage); goto done; } - + ku_DER = malloc(ku_DER_length); if(!ku_DER) @@ -1552,7 +1552,7 @@ globus_l_gsi_proxy_sign_key( ASN1_BIT_STRING_free(usage); goto done; } - + mod_ku_DER = ku_DER; ku_DER_length = i2d_ASN1_BIT_STRING(usage, @@ -1569,8 +1569,8 @@ globus_l_gsi_proxy_sign_key( goto done; } - ASN1_BIT_STRING_free(usage); - + ASN1_BIT_STRING_free(usage); + ku_DER_string = ASN1_OCTET_STRING_new(); if(ku_DER_string == NULL) { @@ -1582,9 +1582,9 @@ globus_l_gsi_proxy_sign_key( free(ku_DER); goto done; } - - ku_DER_string->data = ku_DER; - ku_DER_string->length = ku_DER_length; + + ASN1_OCTET_STRING_set(ku_DER_string, ku_DER, ku_DER_length); + free(ku_DER); extension = X509_EXTENSION_create_by_NID( NULL, @@ -1593,7 +1593,7 @@ globus_l_gsi_proxy_sign_key( ku_DER_string); ASN1_OCTET_STRING_free(ku_DER_string); - + if(extension == NULL) { GLOBUS_GSI_PROXY_OPENSSL_ERROR_RESULT( @@ -1602,7 +1602,7 @@ globus_l_gsi_proxy_sign_key( (_PCSL("Couldn't create new keyUsage extension"))); goto done; } - + if(!X509_add_ext(*signed_cert, extension, 0)) { GLOBUS_GSI_PROXY_OPENSSL_ERROR_RESULT( @@ -1619,16 +1619,16 @@ globus_l_gsi_proxy_sign_key( if((position = X509_get_ext_by_NID(issuer_cert, NID_ext_key_usage, -1)) > -1) { - if(!(extension = X509_get_ext(issuer_cert, position))) + if(!(extension_c = X509_get_ext(issuer_cert, position))) { GLOBUS_GSI_PROXY_OPENSSL_ERROR_RESULT( result, GLOBUS_GSI_PROXY_ERROR_WITH_X509_EXTENSIONS, (_PCSL("Couldn't get extendedKeyUsage extension form issuer cert"))); - goto done; + goto done; } - extension = X509_EXTENSION_dup(extension); + extension = X509_EXTENSION_dup(extension_c); if(extension == NULL) { @@ -1655,7 +1655,7 @@ globus_l_gsi_proxy_sign_key( if (handle->extensions != NULL) { int index; - + /* * There doesn't seem to be a function to add a stack of extensions * to a X509 structure, so we do it iteratively. @@ -1667,7 +1667,7 @@ globus_l_gsi_proxy_sign_key( X509_EXTENSION *ext; ext = sk_X509_EXTENSION_value(handle->extensions, index); - + if(!X509_add_ext( *signed_cert, ext, @@ -1678,7 +1678,7 @@ globus_l_gsi_proxy_sign_key( GLOBUS_GSI_PROXY_ERROR_WITH_X509_EXTENSIONS, (_PCSL("Couldn't add X.509 extension to new proxy cert"))); goto done; - } + } } } @@ -1719,8 +1719,8 @@ globus_l_gsi_proxy_sign_key( goto done; } - result = globus_i_gsi_proxy_set_pc_times(*signed_cert, issuer_cert, - handle->attrs->clock_skew, + result = globus_i_gsi_proxy_set_pc_times(*signed_cert, issuer_cert, + handle->attrs->clock_skew, handle->time_valid); if(result != GLOBUS_SUCCESS) { @@ -1729,7 +1729,7 @@ globus_l_gsi_proxy_sign_key( GLOBUS_GSI_PROXY_ERROR_WITH_X509); goto done; } - + if(!X509_set_pubkey(*signed_cert, public_key)) { GLOBUS_GSI_PROXY_OPENSSL_ERROR_RESULT( @@ -1748,7 +1748,7 @@ globus_l_gsi_proxy_sign_key( GLOBUS_GSI_PROXY_ERROR_WITH_CREDENTIAL); goto done; } - + /* right now if MD5 isn't requested as the signing algorithm, * we throw an error */ @@ -1763,7 +1763,7 @@ globus_l_gsi_proxy_sign_key( " be used to sign a proxy."))); goto done; } - if (handle->attrs->signing_algorithm != NULL && + if (handle->attrs->signing_algorithm != NULL && EVP_MD_type(handle->attrs->signing_algorithm) != EVP_MD_type(issuer_digest)) { @@ -1776,7 +1776,7 @@ globus_l_gsi_proxy_sign_key( OBJ_nid2sn(EVP_MD_type(issuer_digest)))); goto done; } - + if(!X509_sign(*signed_cert, issuer_pkey, issuer_digest)) { GLOBUS_GSI_PROXY_OPENSSL_ERROR_RESULT( @@ -1806,44 +1806,27 @@ globus_l_gsi_proxy_sign_key( if(result != GLOBUS_SUCCESS && *signed_cert) { - X509_free(*signed_cert); + X509_free(*signed_cert); *signed_cert = NULL; } - + if(pci_NID != NID_undef) { if(pci_ext) { X509_EXTENSION_free(pci_ext); } - - #ifdef WIN32 - /* In Win32 can't mix library and OpenSSL versions of free */ - /* so pci_DER can't be freed in ASN1_OCTET_STRING_free */ - if(pci_DER_string) - { - if(pci_DER) - { - free(pci_DER); - pci_DER = NULL; - } - pci_DER_string->data = NULL; - pci_DER_string->length = 0; - ASN1_OCTET_STRING_free(pci_DER_string); - pci_DER_string = NULL; - } - #else - + if(pci_DER_string) { ASN1_OCTET_STRING_free(pci_DER_string); } - else if(pci_DER) + + if(pci_DER) { free(pci_DER); } - #endif - + if(serial_number) { ASN1_INTEGER_free(serial_number); @@ -1865,9 +1848,9 @@ globus_l_gsi_proxy_sign_key( * @param issuer * The issuing credential, used for signing the proxy certificate * @param proxy_credential - * The new proxy credential, containing the signed cert, + * The new proxy credential, containing the signed cert, * private key, etc. - * + * * @return * GLOBUS_SUCCESS if no error occurred, an error object ID otherwise */ @@ -1929,7 +1912,7 @@ globus_gsi_proxy_create_signed( (_PCSL("Can't create memory BIO for reading and writing"))); goto exit; } - + result = globus_gsi_proxy_create_req(handle, rw_mem_bio); if(result != GLOBUS_SUCCESS) { @@ -2004,7 +1987,7 @@ globus_gsi_proxy_create_signed( GLOBUS_GSI_PROXY_ERROR_WITH_HANDLE); goto exit; } - + result = globus_gsi_proxy_handle_set_extensions( inquire_handle, handle->extensions); @@ -2052,7 +2035,7 @@ globus_gsi_proxy_create_signed( ++chain_index) { X509 * chain_cert = - sk_X509_value(issuer_cert_chain, + sk_X509_value(issuer_cert_chain, chain_index); if(!i2d_X509_bio(rw_mem_bio, chain_cert)) { @@ -2070,8 +2053,8 @@ globus_gsi_proxy_create_signed( result = globus_gsi_proxy_handle_destroy(inquire_handle); inquire_handle = NULL; - result = globus_gsi_proxy_assemble_cred(handle, - proxy_credential, + result = globus_gsi_proxy_assemble_cred(handle, + proxy_credential, rw_mem_bio); if(result != GLOBUS_SUCCESS) { @@ -2170,17 +2153,17 @@ globus_gsi_proxy_assemble_cred( "DER encoded to internal form"))); goto done; } - + result = globus_gsi_cred_handle_attrs_init(&cred_handle_attrs); if(result != GLOBUS_SUCCESS) { GLOBUS_GSI_PROXY_ERROR_CHAIN_RESULT( result, - GLOBUS_GSI_PROXY_ERROR_WITH_CRED_HANDLE_ATTRS); + GLOBUS_GSI_PROXY_ERROR_WITH_CRED_HANDLE_ATTRS); goto free_signed_cert; } - result = globus_gsi_cred_handle_init(proxy_credential, + result = globus_gsi_cred_handle_init(proxy_credential, cred_handle_attrs); if(result != GLOBUS_SUCCESS) { @@ -2231,7 +2214,7 @@ globus_gsi_proxy_assemble_cred( (_PCSL("Can't read DER encoded X.509 cert from BIO"))); goto free_cred_handle; } - + sk_X509_push(cert_chain, tmp_cert); } @@ -2277,7 +2260,7 @@ globus_gsi_proxy_assemble_cred( * this could be modified to return more status information * if required. */ -void +void globus_i_gsi_proxy_create_private_key_cb( int num1, int num2, @@ -2293,7 +2276,7 @@ globus_i_gsi_proxy_create_private_key_cb( * Takes the new proxy cert and sets the valid start * and end times of the cert */ -globus_result_t +globus_result_t globus_i_gsi_proxy_set_pc_times( X509 * new_pc, X509 * issuer_cert, @@ -2314,9 +2297,9 @@ globus_i_gsi_proxy_set_pc_times( result, GLOBUS_GSI_PROXY_INVALID_PARAMETER, (_PCSL("Overflow in time value"))); - goto exit; + goto exit; } - + /* adjust for the allowable skew */ if(X509_gmtime_adj(X509_get_notBefore(new_pc), (- skew_allowable)) == NULL) { @@ -2333,7 +2316,7 @@ globus_i_gsi_proxy_set_pc_times( if(time_valid == 0 || X509_cmp_time(X509_get_notAfter(issuer_cert), & tmp_time) < 0) { - if((pc_notAfter = + if((pc_notAfter = ASN1_dup_of(ASN1_UTCTIME, i2d_ASN1_UTCTIME, d2i_ASN1_UTCTIME, X509_get_notAfter(issuer_cert))) == NULL) { GLOBUS_GSI_PROXY_OPENSSL_ERROR_RESULT( @@ -2354,7 +2337,7 @@ globus_i_gsi_proxy_set_pc_times( (_PCSL("Error creating new ASN1_UTCTIME for expiration date " "of proxy cert"))); } - + if(X509_gmtime_adj(pc_notAfter, ((long) 60 * time_valid)) == NULL) { GLOBUS_GSI_PROXY_OPENSSL_ERROR_RESULT( @@ -2364,7 +2347,7 @@ globus_i_gsi_proxy_set_pc_times( goto free_pc_notafter; } } - + if(!X509_set_notAfter(new_pc, pc_notAfter)) { GLOBUS_GSI_PROXY_OPENSSL_ERROR_RESULT( @@ -2377,7 +2360,7 @@ globus_i_gsi_proxy_set_pc_times( result = GLOBUS_SUCCESS; free_pc_notafter: - + if(pc_notAfter != NULL) { ASN1_UTCTIME_free(pc_notAfter); @@ -2393,7 +2376,7 @@ globus_i_gsi_proxy_set_pc_times( * Takes the new proxy cert and sets the subject * based on the subject of the issuer cert */ -globus_result_t +globus_result_t globus_i_gsi_proxy_set_subject( X509 * new_pc, X509 * issuer_cert, @@ -2414,14 +2397,14 @@ globus_i_gsi_proxy_set_subject( (_PCSL("Error copying subject name of proxy cert"))); goto done; } - - if((pc_name_entry = + + if((pc_name_entry = X509_NAME_ENTRY_create_by_NID(& pc_name_entry, NID_commonName, V_ASN1_APP_CHOOSE, (unsigned char *) common_name, -1)) == NULL) { - + GLOBUS_GSI_PROXY_OPENSSL_ERROR_RESULT( result, GLOBUS_GSI_PROXY_ERROR_WITH_X509, @@ -2439,7 +2422,7 @@ globus_i_gsi_proxy_set_subject( (_PCSL("Error setting common name of subject in proxy cert"))); goto free_pc_name_entry; } - + result = GLOBUS_SUCCESS; free_pc_name_entry: @@ -2654,7 +2637,7 @@ globus_l_gsi_proxy_determine_type( } } /* Verify that the selected proxy type is compatible with the issuer's - * type. Impersonation or EEC can sign anything, otherwise, the type + * type. Impersonation or EEC can sign anything, otherwise, the type * must be the same? */ if (((requested_cert_type & GLOBUS_GSI_CERT_UTILS_TYPE_PROXY_MASK) != diff --git a/gsi/proxy/proxy_core/source/library/globus_gsi_proxy_handle.c b/gsi/proxy/proxy_core/source/library/globus_gsi_proxy_handle.c index 0e0ddf0187..0e7e751a20 100644 --- a/gsi/proxy/proxy_core/source/library/globus_gsi_proxy_handle.c +++ b/gsi/proxy/proxy_core/source/library/globus_gsi_proxy_handle.c @@ -60,7 +60,7 @@ sk_X509_EXTENSION_deep_copy( return newe; } #endif - + /** * @brief Initialize a GSI Proxy handle * @ingroup globus_gsi_proxy_handle @@ -73,11 +73,11 @@ sk_X509_EXTENSION_deep_copy( * A pointer to the handle to be initialized. If the * handle is originally NULL, space is allocated for it. * Otherwise, the current values of the handle are overwritten. - * + * * @param[in] handle_attrs * Initial attributes to be used to create this handle. * @return - * GLOBUS_SUCCESS unless an error occurred, in which case, + * GLOBUS_SUCCESS unless an error occurred, in which case, * a globus error object ID is returned * * @see globus_gsi_proxy_handle_destroy() @@ -111,7 +111,7 @@ globus_gsi_proxy_handle_init( goto exit; } - handle_i = *handle; + handle_i = *handle; /* initialize the X509 request structure */ if((handle_i->req = X509_REQ_new()) == NULL) @@ -133,12 +133,12 @@ globus_gsi_proxy_handle_init( goto free_handle; } - ASN1_OBJECT_free(handle_i->proxy_cert_info->proxyPolicy->policyLanguage); + ASN1_OBJECT_free(handle_i->proxy_cert_info->proxyPolicy->policyLanguage); handle_i->proxy_cert_info->proxyPolicy->policyLanguage = NULL; handle_i->proxy_cert_info->proxyPolicy->policyLanguage = OBJ_dup( OBJ_nid2obj(NID_id_ppl_inheritAll)); - + /* initialize the handle attributes */ if(handle_attrs == NULL) { @@ -153,7 +153,7 @@ globus_gsi_proxy_handle_init( } else { - result = globus_gsi_proxy_handle_attrs_copy(handle_attrs, + result = globus_gsi_proxy_handle_attrs_copy(handle_attrs, &handle_i->attrs); if(result != GLOBUS_SUCCESS) { @@ -170,7 +170,7 @@ globus_gsi_proxy_handle_init( handle_i->extensions = NULL; - + goto exit; free_handle: @@ -196,7 +196,7 @@ globus_gsi_proxy_handle_init( * @param[in] handle * The handle to be destroyed. * @return - * GLOBUS_SUCCESS unless an error occurred, in which case, + * GLOBUS_SUCCESS unless an error occurred, in which case, * a globus error object ID is returned * * @see globus_gsi_proxy_handle_init() @@ -214,13 +214,13 @@ globus_gsi_proxy_handle_destroy( EVP_PKEY_free(handle->proxy_key); globus_gsi_proxy_handle_attrs_destroy(handle->attrs); PROXY_CERT_INFO_EXTENSION_free(handle->proxy_cert_info); - + free(handle->common_name); if (handle->extensions != NULL) { sk_X509_EXTENSION_free(handle->extensions); } - + /* free the handle struct memory */ free(handle); handle = NULL; @@ -245,7 +245,7 @@ globus_gsi_proxy_handle_destroy( * Parameter used to return the request. It is the users responsibility * to free the returned request. * @return - * GLOBUS_SUCCESS unless an error occurred, in which case, + * GLOBUS_SUCCESS unless an error occurred, in which case, * a globus error object ID is returned * * @see globus_gsi_proxy_handle_set_req() @@ -304,7 +304,7 @@ globus_gsi_proxy_handle_get_req( * @param[in] req * Request to be copied to handle. * @return - * GLOBUS_SUCCESS unless an error occurred, in which case, + * GLOBUS_SUCCESS unless an error occurred, in which case, * a globus error object ID is returned * * @see globus_gsi_proxy_handle_get_req() @@ -326,7 +326,7 @@ globus_gsi_proxy_handle_set_req( (_PCSL("Invalid handle (NULL) passed to function"))); goto exit; } - + if(handle->req) { X509_REQ_free(handle->req); @@ -345,7 +345,7 @@ globus_gsi_proxy_handle_set_req( goto exit; } } - + exit: GLOBUS_I_GSI_PROXY_DEBUG_EXIT; @@ -366,7 +366,7 @@ globus_gsi_proxy_handle_set_req( * Parameter used to return the key. It is the users responsibility to * free the returned key by calling EVP_PKEY_free(). * @return - * GLOBUS_SUCCESS unless an error occurred, in which case, + * GLOBUS_SUCCESS unless an error occurred, in which case, * a globus error object ID is returned * * @see globus_gsi_proxy_handle_set_private_key() @@ -391,7 +391,7 @@ globus_gsi_proxy_handle_get_private_key( (_PCSL("Invalid handle (NULL) passed to function"))); goto exit; } - + if(!proxy_key) { GLOBUS_GSI_PROXY_ERROR_RESULT( @@ -422,9 +422,9 @@ globus_gsi_proxy_handle_get_private_key( (_PCSL("Couldn't convert private key from internal" "to DER encoded form"))); goto exit; - + } - + der_encoded = malloc(length); if(!der_encoded) @@ -445,12 +445,12 @@ globus_gsi_proxy_handle_get_private_key( (_PCSL("Couldn't convert private key from internal" "to DER encoded form"))); goto exit; - + } tmp = der_encoded; - - if(!d2i_PrivateKey(EVP_PKEY_id(handle->proxy_key), proxy_key, + + if(!d2i_PrivateKey(EVP_PKEY_id(handle->proxy_key), proxy_key, (const unsigned char **) &tmp, length)) { GLOBUS_GSI_PROXY_OPENSSL_ERROR_RESULT( @@ -459,14 +459,14 @@ globus_gsi_proxy_handle_get_private_key( (_PCSL("Error converting DER encoded private key to internal form"))); goto exit; } - + exit: if(der_encoded) { free(der_encoded); } - + GLOBUS_I_GSI_PROXY_DEBUG_EXIT; return result; } @@ -475,14 +475,14 @@ globus_gsi_proxy_handle_get_private_key( /** * @brief Set the private key in a GSI Proxy handle * @details - * Copies the private key pointed to by proxy_key to the + * Copies the private key pointed to by proxy_key to the * handle. * @param[in] handle * The handle for which to set the private key * @param[in] proxy_key * Parameter used to pass the key * @return - * GLOBUS_SUCCESS unless an error occurred, in which case, + * GLOBUS_SUCCESS unless an error occurred, in which case, * a globus error object ID is returned * * @see globus_gsi_proxy_handle_get_private_key() @@ -510,13 +510,13 @@ globus_gsi_proxy_handle_set_private_key( EVP_PKEY_free(handle->proxy_key); handle->proxy_key = NULL; } - + if (proxy_key != NULL) { handle->proxy_key = ASN1_dup_of( EVP_PKEY, i2d_PrivateKey, d2i_AutoPrivateKey, proxy_key); - + if(handle->proxy_key == NULL) { GLOBUS_GSI_PROXY_OPENSSL_ERROR_RESULT( @@ -537,14 +537,14 @@ globus_gsi_proxy_handle_set_private_key( * @brief Get Proxy Type * @ingroup globus_gsi_proxy_handle * @details - * Determine the type of proxy that will be generated when using this handle. + * Determine the type of proxy that will be generated when using this handle. * * @param[in] handle * The handle from which to get the type * @param[out] type * Parameter used to return the type. * @return - * GLOBUS_SUCCESS unless an error occurred, in which case, + * GLOBUS_SUCCESS unless an error occurred, in which case, * a globus error object ID is returned * * @see globus_gsi_proxy_handle_set_type() @@ -596,7 +596,7 @@ globus_gsi_proxy_handle_get_type( * @param type * Parameter used to pass the type. * @return - * GLOBUS_SUCCESS unless an error occurred, in which case, + * GLOBUS_SUCCESS unless an error occurred, in which case, * a globus error object ID is returned * * @see globus_gsi_proxy_handle_set_type() @@ -687,7 +687,7 @@ globus_gsi_proxy_handle_set_policy( globus_result_t result = GLOBUS_SUCCESS; GLOBUS_I_GSI_PROXY_DEBUG_ENTER; - + if(handle == NULL) { GLOBUS_GSI_PROXY_ERROR_RESULT( @@ -696,7 +696,7 @@ globus_gsi_proxy_handle_set_policy( (_PCSL("NULL handle passed to function: %s"), __func__)); goto exit; } - + if (handle->proxy_cert_info->proxyPolicy == NULL) { handle->proxy_cert_info->proxyPolicy = PROXY_POLICY_new(); @@ -749,7 +749,7 @@ globus_gsi_proxy_handle_set_policy( * @details * Get the policy from the GSI Proxy handle. * - * This function gets the policy that is being used in the + * This function gets the policy that is being used in the * proxy cert info extension. * * @param handle @@ -817,9 +817,9 @@ globus_gsi_proxy_handle_get_policy( *policy_length = ASN1_STRING_length( handle->proxy_cert_info->proxyPolicy->policy); *policy_data = malloc(*policy_length + 1); - + memcpy(*policy_data, - ASN1_STRING_data(handle->proxy_cert_info->proxyPolicy->policy), + ASN1_STRING_get0_data(handle->proxy_cert_info->proxyPolicy->policy), *policy_length); (*policy_data)[*policy_length] = 0; } @@ -831,7 +831,7 @@ globus_gsi_proxy_handle_get_policy( *policy_NID = OBJ_obj2nid( handle->proxy_cert_info->proxyPolicy->policyLanguage); - + exit: GLOBUS_I_GSI_PROXY_DEBUG_EXIT; return result; @@ -897,7 +897,7 @@ globus_gsi_proxy_handle_add_extension( goto exit; } } - + sk_X509_EXTENSION_push(handle->extensions, X509_EXTENSION_dup(ext)); result = GLOBUS_SUCCESS; @@ -951,7 +951,7 @@ globus_gsi_proxy_handle_set_extensions( { sk_X509_EXTENSION_free(handle->extensions); } - + if (exts == NULL) { handle->extensions = NULL; @@ -962,7 +962,7 @@ globus_gsi_proxy_handle_set_extensions( exts, (X509_EXTENSION *(*)(const X509_EXTENSION *)) X509_EXTENSION_dup, X509_EXTENSION_free); - + if (handle->extensions == NULL) { GLOBUS_GSI_PROXY_OPENSSL_ERROR_RESULT( @@ -1030,7 +1030,7 @@ globus_gsi_proxy_handle_get_extensions( (_PCSL("NULL exts passed to function: %s"), __func__)); goto exit; } - + if (handle->extensions == NULL) { *exts = sk_X509_EXTENSION_new_null(); @@ -1039,7 +1039,7 @@ globus_gsi_proxy_handle_get_extensions( { *exts = sk_X509_EXTENSION_dup(handle->extensions); } - + if (*exts == NULL) { GLOBUS_GSI_PROXY_OPENSSL_ERROR_RESULT( @@ -1125,7 +1125,7 @@ globus_gsi_proxy_handle_set_pathlen( * @details * Get the path length from the GSI Proxy handle. * - * This function gets the path length that is being used in the + * This function gets the path length that is being used in the * proxy cert info extension. * * @param handle @@ -1172,7 +1172,7 @@ globus_gsi_proxy_handle_get_pathlen( *pathlen = ASN1_INTEGER_get( handle->proxy_cert_info->pcPathLengthConstraint); } - + exit: GLOBUS_I_GSI_PROXY_DEBUG_EXIT; return result; @@ -1189,9 +1189,9 @@ globus_gsi_proxy_handle_get_pathlen( * The proxy handle to get the expiration date of * @param time_valid * expiration date of the proxy handle - * + * * @result - * GLOBUS_SUCCESS unless an error occurred, in which case, + * GLOBUS_SUCCESS unless an error occurred, in which case, * a globus error object ID is returned */ globus_result_t @@ -1222,7 +1222,7 @@ globus_gsi_proxy_handle_get_time_valid( *time_valid = handle->time_valid; - exit: + exit: GLOBUS_I_GSI_PROXY_DEBUG_EXIT; return result; } @@ -1238,9 +1238,9 @@ globus_gsi_proxy_handle_get_time_valid( * The proxy handle to set the expiration date for * @param time_valid * desired expiration date of the proxy - * + * * @result - * GLOBUS_SUCCESS unless an error occurred, in which case, + * GLOBUS_SUCCESS unless an error occurred, in which case, * a globus error object ID is returned * GLOBUS_SUCCESS */ @@ -1250,7 +1250,7 @@ globus_gsi_proxy_handle_set_time_valid( int time_valid) { globus_result_t result = GLOBUS_SUCCESS; - + GLOBUS_I_GSI_PROXY_DEBUG_ENTER; if(handle == NULL) @@ -1312,7 +1312,7 @@ globus_gsi_proxy_handle_clear_cert_info( (_PCSL("PROXYCERTINFO could not be initialized"))); goto exit; } - ASN1_OBJECT_free(handle->proxy_cert_info->proxyPolicy->policyLanguage); + ASN1_OBJECT_free(handle->proxy_cert_info->proxyPolicy->policyLanguage); handle->proxy_cert_info->proxyPolicy->policyLanguage = NULL; handle->proxy_cert_info->proxyPolicy->policyLanguage = OBJ_dup( @@ -1361,7 +1361,7 @@ __asm__(".symver globus_gsi_proxy_handle_get_proxy_cert_info_openssl," * Get the proxy cert info extension stored in the GSI Proxy handle. * * This function retrieves the proxy cert info extension from the GSI Proxy - * handle. + * handle. * * @param handle * The handle from which to get the proxy cert info extension. @@ -1386,7 +1386,7 @@ globus_gsi_proxy_handle_get_proxy_cert_info_openssl( globus_result_t result = GLOBUS_SUCCESS; GLOBUS_I_GSI_PROXY_DEBUG_ENTER; - + if(!handle) { GLOBUS_GSI_PROXY_ERROR_RESULT( @@ -1406,7 +1406,7 @@ globus_gsi_proxy_handle_get_proxy_cert_info_openssl( } if(handle->proxy_cert_info) - { + { *pci = ASN1_dup_of(PROXY_CERT_INFO_EXTENSION, i2d_PROXY_CERT_INFO_EXTENSION, d2i_PROXY_CERT_INFO_EXTENSION, @@ -1455,7 +1455,7 @@ globus_gsi_proxy_handle_get_proxy_cert_info_proxy_ssl( goto exit; } *pci = NULL; - + if (!handle) { GLOBUS_GSI_PROXY_ERROR_RESULT( @@ -1570,7 +1570,7 @@ globus_gsi_proxy_handle_set_proxy_cert_info_openssl( PROXY_CERT_INFO_EXTENSION_free(handle->proxy_cert_info); handle->proxy_cert_info = NULL; } - + if(pci) { handle->proxy_cert_info = ASN1_dup_of(PROXY_CERT_INFO_EXTENSION, @@ -1597,7 +1597,7 @@ globus_gsi_proxy_handle_set_proxy_cert_info_openssl( goto exit; } - ASN1_OBJECT_free(handle->proxy_cert_info->proxyPolicy->policyLanguage); + ASN1_OBJECT_free(handle->proxy_cert_info->proxyPolicy->policyLanguage); handle->proxy_cert_info->proxyPolicy->policyLanguage = NULL; handle->proxy_cert_info->proxyPolicy->policyLanguage = OBJ_dup( @@ -1637,10 +1637,10 @@ globus_gsi_proxy_handle_set_proxy_cert_info_proxy_ssl( PROXY_CERT_INFO_EXTENSION_free(handle->proxy_cert_info); handle->proxy_cert_info = NULL; } - + if(pci) { - PROXY_POLICY pp = + PROXY_POLICY pp = { .policyLanguage = pci->policy ? pci->policy->policy_language : NULL, .policy = pci->policy ? pci->policy->policy : NULL, @@ -1681,9 +1681,9 @@ globus_gsi_proxy_handle_set_proxy_cert_info_proxy_ssl( * The proxy handle containing the type of signing algorithm used * @param signing_algorithm * signing algorithm of the proxy handle - * + * * @retval - * GLOBUS_SUCCESS unless an error occurred, in which case, + * GLOBUS_SUCCESS unless an error occurred, in which case, * a globus error object ID is returned */ globus_result_t @@ -1692,7 +1692,7 @@ globus_gsi_proxy_handle_get_signing_algorithm( const EVP_MD ** signing_algorithm) { globus_result_t result = GLOBUS_SUCCESS; - + GLOBUS_I_GSI_PROXY_DEBUG_ENTER; if(!handle) @@ -1720,7 +1720,7 @@ globus_gsi_proxy_handle_get_signing_algorithm( result, GLOBUS_GSI_PROXY_ERROR_WITH_HANDLE_ATTRS); } - + exit: GLOBUS_I_GSI_PROXY_DEBUG_EXIT; return result; @@ -1736,9 +1736,9 @@ globus_gsi_proxy_handle_get_signing_algorithm( * The proxy handle to get the key bits of * @param key_bits * key bits of the proxy handle - * + * * @result - * GLOBUS_SUCCESS unless an error occurred, in which case, + * GLOBUS_SUCCESS unless an error occurred, in which case, * a globus error object ID is returned * GLOBUS_SUCCESS */ @@ -1775,7 +1775,7 @@ globus_gsi_proxy_handle_get_keybits( result, GLOBUS_GSI_PROXY_ERROR_WITH_HANDLE_ATTRS); } - + exit: GLOBUS_I_GSI_PROXY_DEBUG_EXIT; return result; @@ -1783,7 +1783,7 @@ globus_gsi_proxy_handle_get_keybits( /** * @brief Get Init Prime - * @ingroup globus_gsi_proxy_handle + * @ingroup globus_gsi_proxy_handle * @details * Get the init prime of the proxy handle * @@ -1839,7 +1839,7 @@ globus_gsi_proxy_handle_get_init_prime( /** * @brief Get Clock Skew - * @ingroup globus_gsi_proxy_handle + * @ingroup globus_gsi_proxy_handle * @details * Get the clock skew of the proxy handle * @@ -1895,7 +1895,7 @@ globus_gsi_proxy_handle_get_clock_skew_allowable( /** * @brief Get Callback for Creating Keys - * @ingroup globus_gsi_proxy_handle + * @ingroup globus_gsi_proxy_handle * @details * Get the callback for creating the public/private key pair * @@ -1945,7 +1945,7 @@ globus_gsi_proxy_handle_get_key_gen_callback( exit: GLOBUS_I_GSI_PROXY_DEBUG_EXIT; return result; -} +} /** @@ -1975,7 +1975,7 @@ globus_gsi_proxy_handle_get_common_name( globus_result_t result = GLOBUS_SUCCESS; GLOBUS_I_GSI_PROXY_DEBUG_ENTER; - + if(!handle) { GLOBUS_GSI_PROXY_ERROR_RESULT( @@ -1995,7 +1995,7 @@ globus_gsi_proxy_handle_get_common_name( } if(handle->common_name) - { + { *common_name = strdup(handle->common_name); if(!*common_name) { @@ -2053,7 +2053,7 @@ globus_gsi_proxy_handle_set_common_name( free(handle->common_name); handle->common_name = NULL; } - + if(common_name) { handle->common_name = strdup(common_name); @@ -2063,7 +2063,7 @@ globus_gsi_proxy_handle_set_common_name( strlen(common_name)); goto exit; } - } + } exit: @@ -2085,7 +2085,7 @@ globus_gsi_proxy_handle_set_common_name( * boolean value to set on the proxy handle * * @return - * GLOBUS_SUCCESS unless an error occurred, in which case, + * GLOBUS_SUCCESS unless an error occurred, in which case, * a globus error object ID is returned */ globus_result_t @@ -2146,7 +2146,7 @@ globus_gsi_proxy_handle_set_is_limited( result = globus_gsi_proxy_handle_set_type( handle, GLOBUS_GSI_CERT_UTILS_TYPE_GSI_2_PROXY); - } + } } exit: @@ -2157,15 +2157,15 @@ globus_gsi_proxy_handle_set_is_limited( /** - * Check to see the proxy is a limited proxy + * Check to see the proxy is a limited proxy * * @param handle * the proxy handle to check * @param is_limited - * boolean value to set depending on the type of proxy + * boolean value to set depending on the type of proxy * * @return - * GLOBUS_SUCCESS unless an error occurred, in which case, + * GLOBUS_SUCCESS unless an error occurred, in which case, * a globus error object ID is returned */ globus_result_t diff --git a/gsi/proxy/proxy_ssl/source/configure.ac b/gsi/proxy/proxy_ssl/source/configure.ac index 5e46eac326..1195e92d29 100644 --- a/gsi/proxy/proxy_ssl/source/configure.ac +++ b/gsi/proxy/proxy_ssl/source/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ([2.60]) -AC_INIT([globus_gsi_proxy_ssl], [6.6],[https://github.com/gridcf/gct/issues]) +AC_INIT([globus_gsi_proxy_ssl], [6.7],[https://github.com/gridcf/gct/issues]) AC_CONFIG_MACRO_DIR([m4]) AC_SUBST([MAJOR_VERSION], [${PACKAGE_VERSION%%.*}]) AC_SUBST([MINOR_VERSION], [${PACKAGE_VERSION##*.}]) diff --git a/gsi/proxy/proxy_ssl/source/library/proxypolicy.c b/gsi/proxy/proxy_ssl/source/library/proxypolicy.c index 09c00a4aeb..1c9bd1dbbb 100644 --- a/gsi/proxy/proxy_ssl/source/library/proxypolicy.c +++ b/gsi/proxy/proxy_ssl/source/library/proxypolicy.c @@ -34,7 +34,7 @@ IMPLEMENT_ASN1_DUP_FUNCTION(PROXYPOLICY) #if OPENSSL_VERSION_NUMBER < 0x10000000L /** * @ingroup proxypolicy - * + * * Creates an ASN1_METHOD structure, which contains * pointers to routines that convert any PROXYPOLICY * structure to its associated ASN.1 DER encoded form @@ -70,7 +70,7 @@ int PROXYPOLICY_cmp( const PROXYPOLICY * a, const PROXYPOLICY * b) { - + if((OBJ_obj2nid(a->policy_language) != OBJ_obj2nid(b->policy_language)) || ASN1_STRING_cmp((ASN1_STRING *)a->policy, (ASN1_STRING *)b->policy)) { @@ -99,9 +99,9 @@ int PROXYPOLICY_print( values = i2v_PROXYPOLICY(PROXYPOLICY_x509v3_ext_meth(), policy, values); - + X509V3_EXT_val_prn(bp, values, 0, 1); - + sk_CONF_VALUE_pop_free(values, X509V3_conf_free); return 1; } @@ -123,7 +123,7 @@ int PROXYPOLICY_print_fp( { int ret; - BIO * bp = BIO_new(BIO_s_file()); + BIO * bp = BIO_new(BIO_s_file()); BIO_set_fp(bp, fp, BIO_NOCLOSE); ret = PROXYPOLICY_print(bp, policy); BIO_free(bp); @@ -146,7 +146,7 @@ int PROXYPOLICY_set_policy_language( PROXYPOLICY * policy, ASN1_OBJECT * policy_language) { - if(policy_language != NULL) + if(policy_language != NULL) { ASN1_OBJECT_free(policy->policy_language); policy->policy_language = OBJ_dup(policy_language); @@ -157,14 +157,14 @@ int PROXYPOLICY_set_policy_language( /** * @ingroup proxypolicy - * + * * Gets the policy language of the PROXYPOLICY * * @param policy the proxy policy to get the policy language * of - * + * * @return the policy language as an ASN1_OBJECT - */ + */ ASN1_OBJECT * PROXYPOLICY_get_policy_language( PROXYPOLICY * policy) { @@ -196,7 +196,7 @@ int PROXYPOLICY_set_policy( { proxypolicy->policy = ASN1_OCTET_STRING_new(); } - + ASN1_OCTET_STRING_set(proxypolicy->policy, copy, length); } @@ -228,16 +228,16 @@ unsigned char * PROXYPOLICY_get_policy( int * length) { if(policy->policy) - { - (*length) = policy->policy->length; - if(*length > 0 && policy->policy->data) + { + (*length) = ASN1_STRING_length(policy->policy); + if(*length > 0 && ASN1_STRING_get0_data(policy->policy)) { unsigned char * copy = malloc(*length); - memcpy(copy, policy->policy->data, *length); + memcpy(copy, ASN1_STRING_get0_data(policy->policy), *length); return copy; } } - + return NULL; } @@ -289,13 +289,13 @@ STACK_OF(CONF_VALUE) * i2v_PROXYPOLICY( 127, PROXYPOLICY_get_policy_language(ext)); } - - X509V3_add_value(" Policy Language", + + X509V3_add_value(" Policy Language", policy_lang, &extlist); - + policy = PROXYPOLICY_get_policy(ext, &policy_length); - + if(!policy) { X509V3_add_value(" Policy", " EMPTY", &extlist); @@ -332,16 +332,16 @@ STACK_OF(CONF_VALUE) * i2v_PROXYPOLICY( { *(index++) = '\0'; policy_line_length = index - tmp_string; - + X509V3_add_value(NULL, (char *) tmp_string, &extlist); - + tmp_string = index; } policy_length -= policy_line_length; } - + free(policy); } - + return extlist; } diff --git a/gsi/proxy/proxy_utils/source/configure.ac b/gsi/proxy/proxy_utils/source/configure.ac index dd335c16f2..f99e033574 100644 --- a/gsi/proxy/proxy_utils/source/configure.ac +++ b/gsi/proxy/proxy_utils/source/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ([2.60]) -AC_INIT([globus_proxy_utils],[7.4],[https://github.com/gridcf/gct/issues]) +AC_INIT([globus_proxy_utils],[7.5],[https://github.com/gridcf/gct/issues]) AC_CONFIG_MACRO_DIR([m4]) AC_SUBST([MAJOR_VERSION], [${PACKAGE_VERSION%%.*}]) AC_SUBST([MINOR_VERSION], [${PACKAGE_VERSION##*.}]) diff --git a/gsi/proxy/proxy_utils/source/programs/grid-cert-diagnostics.c b/gsi/proxy/proxy_utils/source/programs/grid-cert-diagnostics.c index ec72a0e788..daa8a515e9 100644 --- a/gsi/proxy/proxy_utils/source/programs/grid-cert-diagnostics.c +++ b/gsi/proxy/proxy_utils/source/programs/grid-cert-diagnostics.c @@ -176,7 +176,7 @@ main(int argc, char * argv[]) (strcmp(optarg, "HYBRID") == 0)) { globus_libc_setenv( - "GLOBUS_GSSAPI_NAME_COMPATIBILITY", + "GLOBUS_GSSAPI_NAME_COMPATIBILITY", optarg, 1); } @@ -481,7 +481,7 @@ time_check(void) goto sendto_fail; } now = time(NULL); - rc = recv(sfd, buf, 4, 0); + rc = recv(sfd, buf, 4, 0); if (rc < 4) { printf("WARNING: Unparsable response from time.nist.gov\n"); @@ -528,7 +528,7 @@ time_check(void) + (((uint32_t) buf[3]))) - INTMAX_C(2208988800); local_seconds_since_unix_epoch = (intmax_t) - difftime(now, unix_epoch_time) - tz_off; + difftime(now, unix_epoch_time) - tz_off; delta = imaxabs(local_seconds_since_unix_epoch - seconds_since_unix_epoch); @@ -1103,7 +1103,7 @@ check_trusted_certs(void) char hash_string[16]; printf("Checking CA file %s... ", ca_cert_file); - + result = globus_gsi_cred_read_cert(handle, ca_cert_file); if (result != GLOBUS_SUCCESS) { @@ -1128,7 +1128,7 @@ check_trusted_certs(void) if (strstr(ca_cert_file, hash_string) == 0) { - printf("failed\n CA hash '%s' does not match CA filename\n", hash_string); + printf("failed\n CA hash '%s' does not match CA filename\n", hash_string); continue; } printf("ok\nChecking CA certificate name for %s...", hash_string); @@ -1532,7 +1532,7 @@ check_service_cert_chain( globus_result_t result; globus_gsi_cred_handle_t handle = NULL; globus_gsi_callback_data_t callback_data = NULL; - X509_NAME *n = NULL; + const X509_NAME *n = NULL; size_t host_len; const char *no_extensions = " no"; OM_uint32 major_status, minor_status; @@ -1666,7 +1666,11 @@ check_service_cert_chain( idx != -1; idx = X509_get_ext_by_NID(cert, NID_subject_alt_name, idx)) { +#if OPENSSL_VERSION_NUMBER < 0x40000000L X509_EXTENSION *ext_value; +#else + const X509_EXTENSION *ext_value; +#endif GENERAL_NAMES *subject_alt_names; no_extensions = ""; @@ -1688,15 +1692,14 @@ check_service_cert_chain( if (subject_alt_name->type == GEN_DNS) { printf(" dns:%.*s", - (int) subject_alt_name->d.dNSName->length, - subject_alt_name->d.dNSName->data); - + (int) ASN1_STRING_length(subject_alt_name->d.dNSName), + ASN1_STRING_get0_data(subject_alt_name->d.dNSName)); } else if (subject_alt_name->type == GEN_IPADD) { printf(" ip:%.*s", - (int) subject_alt_name->d.iPAddress->length, - subject_alt_name->d.iPAddress->data); + (int) ASN1_STRING_length(subject_alt_name->d.iPAddress), + ASN1_STRING_get0_data(subject_alt_name->d.iPAddress)); } else { @@ -1828,8 +1831,8 @@ static char * indent_string(const char * str) { - char * new_line; - char * old_line; + const char * new_line; + const char * old_line; char * output; int i=1; @@ -1838,7 +1841,7 @@ indent_string(const char * str) return NULL; } - for (new_line = (char *) str; new_line != NULL; new_line = strchr(new_line+1, '\n')) + for (new_line = str; new_line != NULL; new_line = strchr(new_line+1, '\n')) { i++; } @@ -1846,7 +1849,7 @@ indent_string(const char * str) output = malloc(strlen(str) + (i*4) + 1); i = 0; - for (new_line = strchr(str, '\n'), old_line = (char *) str; + for (new_line = strchr(str, '\n'), old_line = str; new_line != NULL; old_line = new_line+1, new_line = strchr(new_line+1, '\n')) { diff --git a/gsi/proxy/proxy_utils/source/programs/grid_proxy_init.c b/gsi/proxy/proxy_utils/source/programs/grid_proxy_init.c index dc2d99995a..0fc3f305e7 100644 --- a/gsi/proxy/proxy_utils/source/programs/grid_proxy_init.c +++ b/gsi/proxy/proxy_utils/source/programs/grid_proxy_init.c @@ -124,23 +124,30 @@ globus_i_gsi_proxy_utils_print_error( static int globus_i_gsi_proxy_utils_pwstdin_callback( - char * buf, - int num, + char * buf, + int num, int w, void * u); static void globus_i_gsi_proxy_utils_key_gen_callback( - int p, + int p, int n, void * dummy); -static int +#if OPENSSL_VERSION_NUMBER < 0x40000000L +static int globus_l_gsi_proxy_utils_extension_callback( globus_gsi_callback_data_t callback_data, X509_EXTENSION * extension); +#else +static int +globus_l_gsi_proxy_utils_extension_callback( + globus_gsi_callback_data_t callback_data, + const X509_EXTENSION * extension); +#endif -int +int main( int argc, char ** argv) @@ -177,7 +184,7 @@ main( long path_length = -1; pem_password_cb * pw_cb = NULL; int return_value = 0; - + if(globus_module_activate(GLOBUS_GSI_PROXY_MODULE) != (int)GLOBUS_SUCCESS) { globus_libc_fprintf( @@ -276,7 +283,7 @@ main( { int hours; int minutes; - args_verify_next(arg_index, argp, + args_verify_next(arg_index, argp, "valid time argument H:M missing"); if(sscanf(argv[++arg_index], "%d:%d", &hours, &minutes) < 2) { @@ -292,12 +299,12 @@ main( "be in the range 0-60"); } /* error on overflow */ - + if(hours > (((time_t)(~0U>>1))/3600-1)) { hours = (((time_t)(~0U>>1))/3600-1); } - + valid = (hours * 60) + minutes; } @@ -318,7 +325,7 @@ main( { args_verify_next(arg_index, argp, "integer argument missing"); key_bits = atoi(argv[arg_index + 1]); - if((key_bits != 512) && (key_bits != 1024) && + if((key_bits != 512) && (key_bits != 1024) && (key_bits != 2048) && (key_bits != 4096)) { args_error(argp, "value must be one of 512,1024,2048,4096"); @@ -333,7 +340,7 @@ main( { if (cert_type & GLOBUS_GSI_CERT_UTILS_TYPE_PROXY_MASK) { - args_error(argp, + args_error(argp, "-independent, -limited and -policy/-policy-language are mutually exclusive"); } else @@ -345,7 +352,7 @@ main( { if (cert_type & GLOBUS_GSI_CERT_UTILS_TYPE_PROXY_MASK) { - args_error(argp, + args_error(argp, "-independent, -limited and -policy/-policy-language are mutually exclusive"); } else @@ -357,7 +364,7 @@ main( { if ((cert_type & GLOBUS_GSI_CERT_UTILS_TYPE_FORMAT_MASK) != 0) { - args_error(argp, + args_error(argp, "-old, -rfc, and -draft are mutually exclusive"); } else @@ -407,7 +414,7 @@ main( args_error(argp, "-independent, -limited and -policy/-policy-language are mutually exclusive"); } - args_verify_next(arg_index, argp, + args_verify_next(arg_index, argp, "policy file name missing"); policy_filename = argv[++arg_index]; cert_type |= GLOBUS_GSI_CERT_UTILS_TYPE_RESTRICTED_PROXY; @@ -418,7 +425,7 @@ main( if ((cert_type & GLOBUS_GSI_CERT_UTILS_TYPE_PROXY_MASK) != 0 && (cert_type & GLOBUS_GSI_CERT_UTILS_TYPE_PROXY_MASK) != GLOBUS_GSI_CERT_UTILS_TYPE_RESTRICTED_PROXY) { - args_error(argp, + args_error(argp, "-independent, -limited and -policy/-policy-language are mutually exclusive"); } args_verify_next(arg_index, argp, "policy language missing"); @@ -447,14 +454,14 @@ main( /* A few sanity checks */ if(policy_filename && !policy_language) { - globus_libc_fprintf(stderr, + globus_libc_fprintf(stderr, "\nERROR: If you specify a policy file " "you also need to specify a policy language.\n"); exit(1); } result = globus_gsi_proxy_handle_attrs_init(&proxy_handle_attrs); - + if(result != GLOBUS_SUCCESS) { globus_i_gsi_proxy_utils_print_error(result, debug, __FILE__, __LINE__, @@ -474,9 +481,9 @@ main( "Couldn't set the key bits for " "the private key of the proxy certificate."); } - + result = globus_gsi_proxy_handle_attrs_set_key_gen_callback( - proxy_handle_attrs, + proxy_handle_attrs, globus_i_gsi_proxy_utils_key_gen_callback); if(result != GLOBUS_SUCCESS) { @@ -500,9 +507,9 @@ main( result, debug, __FILE__, __LINE__, "Couldn't destroy proxy handle attributes."); } - + /* set the time valid in the proxy handle - * used to be hours - now the time valid needs to be set in minutes + * used to be hours - now the time valid needs to be set in minutes */ result = globus_gsi_proxy_handle_set_time_valid(proxy_handle, valid); @@ -524,7 +531,7 @@ main( result, debug, __FILE__, __LINE__, "Couldn't set the type of the proxy cert."); } - + if(!user_cert_filename || !user_key_filename) { result = GLOBUS_GSI_SYSCONFIG_GET_USER_CERT_FILENAME( @@ -555,7 +562,7 @@ main( { user_key_filename = tmp_user_key_filename; } - + if(debug) { globus_libc_fprintf(stderr, @@ -587,8 +594,8 @@ main( if(debug) { - globus_libc_fprintf(stderr, - "\nTrusted CA Cert Dir: %s\n", + globus_libc_fprintf(stderr, + "\nTrusted CA Cert Dir: %s\n", ca_cert_dir ? ca_cert_dir : "(null)"); } @@ -631,7 +638,7 @@ main( { free(proxy_out_filename); } - + proxy_out_filename = proxy_absolute_path; /* then split */ @@ -644,7 +651,7 @@ main( globus_i_gsi_proxy_utils_print_error( result, debug, __FILE__, __LINE__, "Can't split the full path into " - "directory and filename. The full path is: %s", + "directory and filename. The full path is: %s", proxy_absolute_path); if(proxy_absolute_path) { @@ -652,7 +659,7 @@ main( proxy_absolute_path = NULL; } } - + result = GLOBUS_GSI_SYSCONFIG_DIR_EXISTS(temp_dir); if(result != GLOBUS_SUCCESS) { @@ -666,7 +673,7 @@ main( } else { - globus_module_deactivate_all(); + globus_module_deactivate_all(); exit(1); } } @@ -676,7 +683,7 @@ main( free(temp_dir); temp_dir = NULL; } - + if(temp_filename) { free(temp_filename); @@ -731,7 +738,7 @@ main( "user certificate could " "not be retrieved."); } - + printf("Your identity: %s\n", subject); if(subject) { @@ -750,7 +757,7 @@ main( globus_i_gsi_proxy_utils_print_error( result, debug, __FILE__, __LINE__, "Couldn't read user certificate\n" - "cert file location: %s.", + "cert file location: %s.", user_cert_filename); } @@ -766,7 +773,7 @@ main( "user certificate could " "not be retrieved."); } - + printf("Your identity: %s\n", subject); if(subject) { @@ -778,7 +785,7 @@ main( subject = NULL; } } - + result = globus_gsi_cred_read_key( cred_handle, user_key_filename, @@ -794,7 +801,7 @@ main( PEM_F_PEM_DO_HEADER, PEM_R_BAD_DECRYPT) == GLOBUS_TRUE) - { + { globus_i_gsi_proxy_utils_print_error( result, debug, __FILE__, __LINE__, "Couldn't read user key: Bad passphrase for key in %s", @@ -823,41 +830,41 @@ main( "Can't set the path length in the proxy handle."); } } - + /* add policies now */ if(policy_filename) { int policy_buf_size = 0; FILE * policy_fp = NULL; - + policy_fp = fopen(policy_filename, "r"); if(!policy_fp) { - fprintf(stderr, + fprintf(stderr, "\nERROR: Unable to open policies " " file: %s\n\n", policy_filename); exit(1); } - do + do { policy_buf_size += 512; - + /* First time through this is a essentially a malloc() */ policy_buf = realloc(policy_buf, policy_buf_size); if (policy_buf == NULL) { - fprintf(stderr, + fprintf(stderr, "\nAllocation of space for " "policy buffer failed\n\n"); exit(1); } - policy_buf_len += - fread(&policy_buf[policy_buf_len], 1, + policy_buf_len += + fread(&policy_buf[policy_buf_len], 1, 512, policy_fp); /* @@ -869,13 +876,13 @@ main( */ } while (policy_buf_len == policy_buf_size); - + if (policy_buf_len > 0) { - policy_NID = - OBJ_create(policy_language, - policy_language, - policy_language); + policy_NID = + OBJ_create(policy_language, + policy_language, + policy_language); result = globus_gsi_proxy_handle_set_policy( proxy_handle, @@ -888,11 +895,11 @@ main( result, debug, __FILE__, __LINE__, "Can't set the policy in the proxy handle."); } - } + } fclose(policy_fp); } - + if (!quiet) { printf("Creating proxy "); @@ -937,7 +944,7 @@ main( "Couldn't set the X.509 extension callback in the callback " "data."); } - + result = globus_gsi_callback_set_cert_dir( callback_data, ca_cert_dir); @@ -967,7 +974,7 @@ main( else { result = globus_gsi_cred_verify(proxy_cred_handle); - + if(result != GLOBUS_SUCCESS) { globus_i_gsi_proxy_utils_print_error( @@ -1025,7 +1032,7 @@ main( { globus_libc_fprintf( stderr, - "\nERROR: Your certificate has expired: %s\n\n", + "\nERROR: Your certificate has expired: %s\n\n", asctime(localtime(&goodtill))); globus_module_deactivate_all(); exit(2); @@ -1033,7 +1040,7 @@ main( else if(lifetime < (valid * 60)) { globus_libc_fprintf( - stderr, + stderr, "\nWarning: your certificate and proxy will expire %s " "which is within the requested lifetime of the proxy\n", asctime(localtime(&goodtill))); @@ -1042,7 +1049,7 @@ main( { globus_libc_fprintf( stdout, - "Your proxy is valid until: %s", + "Your proxy is valid until: %s", asctime(localtime(&goodtill))); } @@ -1069,8 +1076,8 @@ main( static int globus_i_gsi_proxy_utils_pwstdin_callback( - char * buf, - int num, + char * buf, + int num, int w, void * u) { @@ -1086,7 +1093,7 @@ globus_i_gsi_proxy_utils_pwstdin_callback( buf[i-1] = '\0'; i--; } - return i; + return i; } @@ -1139,7 +1146,7 @@ globus_i_gsi_proxy_utils_print_error( { globus_libc_fprintf(stderr, " %s:%d: %s", filename, line, error_string); } - else + else { globus_libc_fprintf(stderr, "Use -debug for further information.\n"); } @@ -1152,13 +1159,19 @@ globus_i_gsi_proxy_utils_print_error( exit(1); } -static -int +#if OPENSSL_VERSION_NUMBER < 0x40000000L +static int globus_l_gsi_proxy_utils_extension_callback( globus_gsi_callback_data_t callback_data, X509_EXTENSION * extension) +#else +static int +globus_l_gsi_proxy_utils_extension_callback( + globus_gsi_callback_data_t callback_data, + const X509_EXTENSION * extension) +#endif { - ASN1_OBJECT * extension_object = NULL; + const ASN1_OBJECT * extension_object = NULL; int nid = NID_undef; int pci_old_NID = NID_undef; diff --git a/gsi/sysconfig/source/configure.ac b/gsi/sysconfig/source/configure.ac index 4b1f83861b..da4cbdfaf5 100644 --- a/gsi/sysconfig/source/configure.ac +++ b/gsi/sysconfig/source/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ([2.60]) -AC_INIT([globus_gsi_sysconfig], [9.6],[https://github.com/gridcf/gct/issues]) +AC_INIT([globus_gsi_sysconfig], [9.7],[https://github.com/gridcf/gct/issues]) AC_CONFIG_MACRO_DIR([m4]) AC_SUBST([MAJOR_VERSION], [${PACKAGE_VERSION%%.*}]) AC_SUBST([MINOR_VERSION], [${PACKAGE_VERSION##*.}]) diff --git a/gsi/sysconfig/source/library/globus_gsi_system_config.c b/gsi/sysconfig/source/library/globus_gsi_system_config.c index fa97964bfa..e428d6cc19 100644 --- a/gsi/sysconfig/source/library/globus_gsi_system_config.c +++ b/gsi/sysconfig/source/library/globus_gsi_system_config.c @@ -258,7 +258,7 @@ globus_l_gsi_sysconfig_activate(void) GLOBUS_I_GSI_SYSCONFIG_DEBUG_ENTER; #ifdef TARGET_ARCH_CYGWIN - /* windows permissions are a pain, and cygwin won't give reliable + /* windows permissions are a pain, and cygwin won't give reliable permissions when a non-posix path is used anyways */ if(getenv("GLOBUS_IGNORE_CRED_PERMS")) { @@ -301,10 +301,10 @@ globus_l_gsi_sysconfig_activate(void) */ GLOBUS_GSI_SYSCONFIG_FILE_EXISTS(DEFAULT_RANDOM_FILE); - /* ToDo: look at return code? */ + /* ToDo: look at return code? */ /* probably overestimating the entropy in the below */ -#ifndef WIN32 /* ToDo: Do this for Win32? */ +#ifndef WIN32 /* ToDo: Do this for Win32? */ uptime = times(&proc_times); RAND_add((void *) &uptime, sizeof(clock_t), 2); @@ -520,7 +520,7 @@ globus_gsi_sysconfig_set_key_permissions_win32( char * filename) { globus_result_t result = GLOBUS_SUCCESS; - int fd = -1; + int fd = -1; struct _stat stx; GLOBUS_I_GSI_SYSCONFIG_DEBUG_ENTER; @@ -554,8 +554,8 @@ globus_gsi_sysconfig_set_key_permissions_win32( } /* - * use any stat output as random data, as it will - * have file sizes, and last use times in it. + * use any stat output as random data, as it will + * have file sizes, and last use times in it. */ RAND_add((void*)&stx, sizeof(stx), 2); @@ -594,7 +594,7 @@ globus_gsi_sysconfig_set_key_permissions_win32( __FILE__, __func__, __LINE__, - "Error setting permissions to user read only of file: %s\n", + "Error setting permissions to user read only of file: %s\n", filename)); goto exit; } @@ -602,7 +602,7 @@ globus_gsi_sysconfig_set_key_permissions_win32( exit: if (fd >= 0) { - close(fd); + close(fd); } GLOBUS_I_GSI_SYSCONFIG_DEBUG_EXIT; @@ -616,7 +616,7 @@ globus_gsi_sysconfig_set_key_permissions_win32( * @ingroup globus_i_gsi_sysconfig_win32 * @details * Get the HOME directory, currently c:\windows - * + * * @param home_dir * The home directory of the current user * @return @@ -641,7 +641,7 @@ globus_gsi_sysconfig_get_home_dir_win32( if(home_drive == NULL) { GLOBUS_GSI_SYSCONFIG_ERROR_RESULT( - result, + result, GLOBUS_GSI_SYSCONFIG_ERROR_GETTING_HOME_DIR, (_GSSL("Could not get a home directory for this machine"))); @@ -652,7 +652,7 @@ globus_gsi_sysconfig_get_home_dir_win32( if(home_path == NULL) { GLOBUS_GSI_SYSCONFIG_ERROR_RESULT( - result, + result, GLOBUS_GSI_SYSCONFIG_ERROR_GETTING_HOME_DIR, (_GSSL("Could not get a home directory for this machine"))); @@ -706,7 +706,7 @@ globus_gsi_sysconfig_get_home_dir_win32( * * @param filename the file to check * - * @return + * @return * GLOBUS_SUCCESS (even if the file doesn't exist) - in some * abortive cases an error object identifier is returned */ @@ -729,7 +729,7 @@ globus_gsi_sysconfig_file_exists_win32( GLOBUS_GSI_SYSCONFIG_ERROR_RESULT( result, GLOBUS_GSI_SYSCONFIG_ERROR_FILE_DOES_NOT_EXIST, - (_GSSL("%s is not a valid file"), filename)); + (_GSSL("%s is not a valid file"), filename)); goto exit; case EACCES: @@ -737,7 +737,7 @@ globus_gsi_sysconfig_file_exists_win32( GLOBUS_GSI_SYSCONFIG_ERROR_RESULT( result, GLOBUS_GSI_SYSCONFIG_ERROR_FILE_BAD_PERMISSIONS, - (_GSSL("Could not read %s"), filename)); + (_GSSL("Could not read %s"), filename)); goto exit; default: @@ -757,8 +757,8 @@ globus_gsi_sysconfig_file_exists_win32( } /* - * use any stat output as random data, as it will - * have file sizes, and last use times in it. + * use any stat output as random data, as it will + * have file sizes, and last use times in it. */ RAND_add((void*)&stx,sizeof(stx),2); @@ -767,16 +767,16 @@ globus_gsi_sysconfig_file_exists_win32( GLOBUS_GSI_SYSCONFIG_ERROR_RESULT( result, GLOBUS_GSI_SYSCONFIG_ERROR_FILE_ZERO_LENGTH, - (_GSSL("File: %s"), filename)); + (_GSSL("File: %s"), filename)); goto exit; } if(stx.st_mode & S_IFDIR) - { + { GLOBUS_GSI_SYSCONFIG_ERROR_RESULT( result, GLOBUS_GSI_SYSCONFIG_ERROR_FILE_IS_DIR, - (_GSSL("File: %s"), filename)); + (_GSSL("File: %s"), filename)); } else if((stx.st_mode & S_IFMT) & ~ (S_IFREG | S_IFDIR)) @@ -791,7 +791,7 @@ globus_gsi_sysconfig_file_exists_win32( GLOBUS_I_GSI_SYSCONFIG_DEBUG_EXIT; return result; -} +} /** * @brief Win32 - Directory Exists @@ -801,7 +801,7 @@ globus_gsi_sysconfig_file_exists_win32( * * @param filename the file to check * - * @return + * @return * GLOBUS_SUCCESS if the directory exists, otherwise an error * object identifier. */ @@ -824,7 +824,7 @@ globus_gsi_sysconfig_dir_exists_win32( GLOBUS_GSI_SYSCONFIG_ERROR_RESULT( result, GLOBUS_GSI_SYSCONFIG_ERROR_FILE_DOES_NOT_EXIST, - (_GSSL("%s is not a valid directory"), filename)); + (_GSSL("%s is not a valid directory"), filename)); goto exit; case EACCES: @@ -832,7 +832,7 @@ globus_gsi_sysconfig_dir_exists_win32( GLOBUS_GSI_SYSCONFIG_ERROR_RESULT( result, GLOBUS_GSI_SYSCONFIG_ERROR_FILE_BAD_PERMISSIONS, - (_GSSL("Could not read %s"), filename)); + (_GSSL("Could not read %s"), filename)); goto exit; default: @@ -852,40 +852,40 @@ globus_gsi_sysconfig_dir_exists_win32( } /* - * use any stat output as random data, as it will - * have file sizes, and last use times in it. + * use any stat output as random data, as it will + * have file sizes, and last use times in it. */ RAND_add((void*)&stx,sizeof(stx),2); /* != 0 size test will always fail in windows so it was removed */ if(!(stx.st_mode & S_IFDIR)) - { + { GLOBUS_GSI_SYSCONFIG_ERROR_RESULT( result, GLOBUS_GSI_SYSCONFIG_ERROR_FILE_NOT_DIR, - (_GSSL("%s is not a directory"), filename)); + (_GSSL("%s is not a directory"), filename)); } exit: GLOBUS_I_GSI_SYSCONFIG_DEBUG_EXIT; return result; -} +} /** * @brief Win32 - Check File Status for Key * @ingroup globus_i_gsi_sysconfig_win32 * @details - * This is a convenience function used to check the status of a + * This is a convenience function used to check the status of a * private key file. The desired status is only the current user has * ownership and read permissions, everyone else should not be able * to access it. - * + * * @param filename * The name of the file to check the status of * - * @return + * @return * GLOBUS_SUCCESS if the status of the file was able * to be determined. Otherwise, an error object * identifier @@ -902,15 +902,15 @@ globus_gsi_sysconfig_check_keyfile_win32( * @brief Win32 - Check File Status for Key * @ingroup globus_i_gsi_sysconfig_win32 * @details - * This is a convenience function used to check the status of a + * This is a convenience function used to check the status of a * private key file. The desired status is only the current user has * ownership and read permissions, everyone else should not be able * to access it. - * + * * @param filename * The name of the file to check the status of * - * @return + * @return * GLOBUS_SUCCESS if the status of the file was able * to be determined. Otherwise, an error object * identifier @@ -944,7 +944,7 @@ globus_gsi_sysconfig_check_keyfile_uid_win32( GLOBUS_GSI_SYSCONFIG_ERROR_RESULT( result, GLOBUS_GSI_SYSCONFIG_ERROR_FILE_BAD_PERMISSIONS, - (_GSSL("Could not read %s"), filename)); + (_GSSL("Could not read %s"), filename)); goto exit; default: @@ -963,8 +963,8 @@ globus_gsi_sysconfig_check_keyfile_uid_win32( } /* - * use any stat output as random data, as it will - * have file sizes, and last use times in it. + * use any stat output as random data, as it will + * have file sizes, and last use times in it. */ RAND_add((void*)&stx,sizeof(stx),2); @@ -982,7 +982,7 @@ globus_gsi_sysconfig_check_keyfile_uid_win32( GLOBUS_GSI_SYSCONFIG_ERROR_RESULT( result, GLOBUS_GSI_SYSCONFIG_ERROR_FILE_ZERO_LENGTH, - (_GSSL("File: %s"), filename)); + (_GSSL("File: %s"), filename)); goto exit; } @@ -992,7 +992,7 @@ globus_gsi_sysconfig_check_keyfile_uid_win32( GLOBUS_GSI_SYSCONFIG_ERROR_RESULT( result, GLOBUS_GSI_SYSCONFIG_ERROR_FILE_IS_DIR, - (_GSSL("File: %s"), filename)); + (_GSSL("File: %s"), filename)); } else if((stx.st_mode & S_IFMT) & ~(S_IFREG | S_IFDIR)) @@ -1016,15 +1016,15 @@ globus_gsi_sysconfig_check_keyfile_uid_win32( * @brief Win32 - Check File Status for Cert * @ingroup globus_i_gsi_sysconfig_win32 * @details - * This is a convenience function used to check the status of a + * This is a convenience function used to check the status of a * certificate file. The desired status is the current user has * ownership and read/write permissions, while group and others only * have read permissions. - * + * * @param filename * The name of the file to check the status of * - * @return + * @return * GLOBUS_SUCCESS if the status of the file was able * to be determined. Otherwise, an error object * identifier @@ -1041,15 +1041,15 @@ globus_gsi_sysconfig_check_certfile_win32( * @brief Win32 - Check File Status for Cert * @ingroup globus_i_gsi_sysconfig_win32 * @details - * This is a convenience function used to check the status of a + * This is a convenience function used to check the status of a * certificate file. The desired status is the current user has * ownership and read/write permissions, while group and others only * have read permissions. - * + * * @param filename * The name of the file to check the status of * - * @return + * @return * GLOBUS_SUCCESS if the status of the file was able * to be determined. Otherwise, an error object * identifier @@ -1101,14 +1101,14 @@ globus_gsi_sysconfig_check_certfile_uid_win32( } /* - * use any stat output as random data, as it will - * have file sizes, and last use times in it. + * use any stat output as random data, as it will + * have file sizes, and last use times in it. */ RAND_add((void*)&stx,sizeof(stx),2); /* * Note that unix-like ownership and permissions are not suppored by Windows so - * geteuid() and rwx mode tests are not done. Maybe later Win32 file security + * geteuid() and rwx mode tests are not done. Maybe later Win32 file security * using Access Control Lists can be incorporated, but this is an architectural * and would need to be considered and implemented in a comprehensive way. */ @@ -1119,7 +1119,7 @@ globus_gsi_sysconfig_check_certfile_uid_win32( GLOBUS_GSI_SYSCONFIG_ERROR_RESULT( result, GLOBUS_GSI_SYSCONFIG_ERROR_FILE_ZERO_LENGTH, - (_GSSL("File: %s"), filename)); + (_GSSL("File: %s"), filename)); goto exit; } @@ -1193,7 +1193,7 @@ globus_gsi_sysconfig_get_current_working_dir_win32( } else if(!result_buffer) { - result = + result = globus_error_put(globus_error_wrap_errno_error( GLOBUS_GSI_SYSCONFIG_MODULE, errno, @@ -1225,7 +1225,7 @@ globus_gsi_sysconfig_get_current_working_dir_win32( * on the current working directory. * * @param filename - * the filename to get the absolute path of. + * the filename to get the absolute path of. * @param absolute_path * The resulting absolute path * @return @@ -1330,8 +1330,8 @@ globus_gsi_sysconfig_split_dir_and_filename_win32( goto exit; } - globus_libc_snprintf(*filename_string, filename_string_length, - "%s", full_filename); + globus_libc_snprintf(*filename_string, filename_string_length, + "%s", full_filename); } else { @@ -1377,7 +1377,7 @@ globus_gsi_sysconfig_split_dir_and_filename_win32( * @brief Win32 - Get User ID * @ingroup globus_i_gsi_sysconfig_win32 * @details - * Get a unique string representing the current user. + * Get a unique string representing the current user. */ globus_result_t globus_gsi_sysconfig_get_user_id_string_win32( @@ -1399,7 +1399,7 @@ globus_gsi_sysconfig_get_user_id_string_win32( * @brief Win32 - Get Username * @ingroup globus_i_gsi_sysconfig_win32 * @details - * Get the username of the current user. + * Get the username of the current user. */ globus_result_t globus_gsi_sysconfig_get_username_win32( @@ -1411,26 +1411,26 @@ globus_gsi_sysconfig_get_username_win32( GLOBUS_I_GSI_SYSCONFIG_DEBUG_ENTER; - if(name = getenv("USERNAME")) + if(name = getenv("USERNAME")) { size = strlen(name) + 1; *username = malloc(size); - if(*username) + if(*username) { strncpy(*username,name,size); } - else + else { result = GLOBUS_GSI_SYSTEM_CONFIG_MALLOC_ERROR; } } /* getenv failed */ - else + else { *username = NULL; GLOBUS_GSI_SYSCONFIG_ERROR_RESULT( - result, + result, GLOBUS_GSI_SYSCONFIG_ERROR_GETTING_HOME_DIR, (_GSSL("Could not find username for this use"))); } @@ -1444,7 +1444,7 @@ globus_gsi_sysconfig_get_username_win32( * @brief Win32 - Get Process ID * @ingroup globus_i_gsi_sysconfig_win32 * @details - * Get a unique string representing the current process. + * Get a unique string representing the current process. */ globus_result_t globus_gsi_sysconfig_get_proc_id_string_win32( @@ -1498,19 +1498,19 @@ globus_gsi_sysconfig_get_proc_id_string_win32( * software\\Globus\\GSI *
  • \\<user home directory>\\.globus\\certificates - If this * directory exists, and the previous methods of determining the trusted - * certs directory failed, this directory will be used. + * certs directory failed, this directory will be used. *
  • Host Trusted Cert Dir - This location is intended - * to be independent of the globus installation ($GLOBUS_LOCATION), and - * is generally only writeable by the host system administrator. + * to be independent of the globus installation ($GLOBUS_LOCATION), and + * is generally only writeable by the host system administrator. *
  • Globus Install Trusted Cert Dir - this - * is $GLOBUS_LOCATION\\share\\certificates. + * is $GLOBUS_LOCATION\\share\\certificates. * * * @param cert_dir * The trusted certificates directory * @return * GLOBUS_SUCCESS if no error occurred, and a sufficient trusted - * certificates directory was found. Otherwise, an error object + * certificates directory was found. Otherwise, an error object * identifier returned. */ globus_result_t @@ -1533,7 +1533,7 @@ globus_gsi_sysconfig_get_cert_dir_win32( if(getenv(X509_CERT_DIR)) { result = globus_i_gsi_sysconfig_create_cert_dir_string( - cert_dir, + cert_dir, &env_cert_dir, "%s", getenv(X509_CERT_DIR)); @@ -1552,9 +1552,9 @@ globus_gsi_sysconfig_get_cert_dir_win32( result = GLOBUS_GSI_SYSCONFIG_GET_HOME_DIR(&home); if(result == GLOBUS_SUCCESS) - { + { result = globus_i_gsi_sysconfig_create_cert_dir_string( - cert_dir, + cert_dir, &local_cert_dir, "%s%s%s", home, @@ -1580,7 +1580,7 @@ globus_gsi_sysconfig_get_cert_dir_win32( else if(!GLOBUS_GSI_SYSCONFIG_FILE_DOES_NOT_EXIST(result) && !GLOBUS_GSI_SYSCONFIG_FILE_HAS_BAD_PERMISSIONS(result)) { - home = NULL; + home = NULL; GLOBUS_GSI_SYSCONFIG_ERROR_CHAIN_RESULT( result, GLOBUS_GSI_SYSCONFIG_ERROR_GETTING_CERT_DIR); @@ -1671,7 +1671,7 @@ globus_gsi_sysconfig_get_cert_dir_win32( } GLOBUS_I_GSI_SYSCONFIG_DEBUG_FPRINTF( - 2, (stderr, "Using cert_dir = %s\n", + 2, (stderr, "Using cert_dir = %s\n", (*cert_dir ? *cert_dir : "null"))); result = GLOBUS_SUCCESS; @@ -1685,7 +1685,7 @@ globus_gsi_sysconfig_get_cert_dir_win32( if(home != NULL) { - free(home); + free(home); } GLOBUS_I_GSI_SYSCONFIG_DEBUG_EXIT; @@ -1700,11 +1700,11 @@ globus_gsi_sysconfig_get_cert_dir_win32( * Get the User Certificate Filename based on the current user's * environment. The following locations are searched for cert and key * files in order: - * + * *
      *
    1. environment variables X509_USER_CERT and X509_USER_KEY *
    2. registry keys x509_user_cert and x509_user_key in software\\Globus\\GSI - *
    3. <users home directory>\\.globus\\usercert.pem and + *
    4. <users home directory>\\.globus\\usercert.pem and * <users home directory>\\.globus\\userkey.pem *
    5. <users home directory>\\.globus\\usercred.p12 - this is a PKCS12 credential *
    @@ -1752,7 +1752,7 @@ globus_gsi_sysconfig_get_user_cert_filename_win32( result, GLOBUS_GSI_SYSCONFIG_ERROR_GETTING_CERT_STRING); goto done; - } + } } if(!(*user_cert)) @@ -1789,7 +1789,7 @@ globus_gsi_sysconfig_get_user_cert_filename_win32( } if(user_key) - { + { *user_key = NULL; result = GLOBUS_SUCCESS; @@ -1853,7 +1853,7 @@ globus_gsi_sysconfig_get_user_cert_filename_win32( { result = GLOBUS_SUCCESS; if(!home) - { + { result = GLOBUS_GSI_SYSCONFIG_GET_HOME_DIR(&home); } @@ -1882,7 +1882,7 @@ globus_gsi_sysconfig_get_user_cert_filename_win32( GLOBUS_GSI_SYSCONFIG_ERROR_CHAIN_RESULT( result, GLOBUS_GSI_SYSCONFIG_ERROR_GETTING_KEY_STRING); - goto done; + goto done; } } @@ -1937,7 +1937,7 @@ globus_gsi_sysconfig_get_user_cert_filename_win32( * @ingroup globus_gsi_sysconfig_win32 * @details * Get the Host Certificate and Key Filenames based on the current user's - * environment. The host cert and key are searched for in the following + * environment. The host cert and key are searched for in the following * locations (in order): * *
      @@ -1946,7 +1946,7 @@ globus_gsi_sysconfig_get_user_cert_filename_win32( *
    1. <GLOBUS_LOCATION>\\etc\\host[cert|key].pem *
    2. <users home directory>\\.globus\\host[cert|key].pem *
    - * + * * @param host_cert * pointer to the host certificate filename * @param host_key @@ -1954,7 +1954,7 @@ globus_gsi_sysconfig_get_user_cert_filename_win32( * * @return * GLOBUS_SUCCESS if the host cert and key were found, otherwise - * an error object identifier is returned + * an error object identifier is returned */ globus_result_t globus_gsi_sysconfig_get_host_cert_filename_win32( @@ -2022,7 +2022,7 @@ globus_gsi_sysconfig_get_host_cert_filename_win32( X509_CERT_SUFFIX); if(result == GLOBUS_SUCCESS) - { + { result = globus_i_gsi_sysconfig_create_key_string( host_key, & default_host_key, @@ -2050,7 +2050,7 @@ globus_gsi_sysconfig_get_host_cert_filename_win32( } /* now check installed location for host cert */ - if(!(*host_cert) && !(*host_key)) + if(!(*host_cert) && !(*host_key)) { result = globus_location(&location); @@ -2068,7 +2068,7 @@ globus_gsi_sysconfig_get_host_cert_filename_win32( X509_CERT_SUFFIX); if(result == GLOBUS_SUCCESS) - { + { result = globus_i_gsi_sysconfig_create_key_string( host_key, &installed_host_key, @@ -2098,7 +2098,7 @@ globus_gsi_sysconfig_get_host_cert_filename_win32( } } - if(!(*host_cert) && !(*host_key)) + if(!(*host_cert) && !(*host_key)) { result = GLOBUS_GSI_SYSCONFIG_GET_HOME_DIR(&home); @@ -2116,7 +2116,7 @@ globus_gsi_sysconfig_get_host_cert_filename_win32( X509_CERT_SUFFIX); if(result == GLOBUS_SUCCESS) - { + { result = globus_i_gsi_sysconfig_create_key_string( host_key, & local_host_key, @@ -2199,7 +2199,7 @@ globus_gsi_sysconfig_get_host_cert_filename_win32( * @ingroup globus_gsi_sysconfig_win32 * @details * Get the Service Certificate Filename based on the current user's - * environment. The host cert and key are searched for in the following + * environment. The host cert and key are searched for in the following * locations (in order): * *
      @@ -2207,11 +2207,11 @@ globus_gsi_sysconfig_get_host_cert_filename_win32( *
    1. registry keys x509_user_cert and x509_user_key in software\\Globus\\GSI *
    2. GLOBUS_LOCATION\\etc\\{service_name}\\{service_name}[cert|key].pem * So for example, if my service was named: myservice, the location - * of the certificate would be: + * of the certificate would be: * <GLOBUS_LOCATION>\\etc\\myservice\\myservicecert.pem *
    3. <users home>\\.globus\\{service_name}\\{service_name}[cert|key].pem *
    - * + * * @param service_name * The name of the service which allows us to determine the * locations of cert and key files to look for @@ -2222,7 +2222,7 @@ globus_gsi_sysconfig_get_host_cert_filename_win32( * * @return * GLOBUS_SUCCESS if the service cert and key were found, otherwise - * an error object identifier + * an error object identifier */ globus_result_t globus_gsi_sysconfig_get_service_cert_filename_win32( @@ -2267,7 +2267,7 @@ globus_gsi_sysconfig_get_service_cert_filename_win32( getenv(X509_USER_CERT)); if(result != GLOBUS_SUCCESS) - { + { GLOBUS_GSI_SYSCONFIG_ERROR_CHAIN_RESULT( result, GLOBUS_GSI_SYSCONFIG_ERROR_GETTING_CERT_STRING); @@ -2308,7 +2308,7 @@ globus_gsi_sysconfig_get_service_cert_filename_win32( X509_CERT_SUFFIX); if(result == GLOBUS_SUCCESS) - { + { result = globus_i_gsi_sysconfig_create_key_string( service_key, & default_service_key, @@ -2334,7 +2334,7 @@ globus_gsi_sysconfig_get_service_cert_filename_win32( GLOBUS_GSI_SYSCONFIG_ERROR_CHAIN_RESULT( result, GLOBUS_GSI_SYSCONFIG_ERROR_GETTING_CERT_STRING); - goto done; + goto done; } } else if(!GLOBUS_GSI_SYSCONFIG_FILE_DOES_NOT_EXIST(result)) @@ -2368,7 +2368,7 @@ globus_gsi_sysconfig_get_service_cert_filename_win32( X509_CERT_SUFFIX); if(result == GLOBUS_SUCCESS) - { + { result = globus_i_gsi_sysconfig_create_key_string( service_key, &installed_service_key, @@ -2424,7 +2424,7 @@ globus_gsi_sysconfig_get_service_cert_filename_win32( X509_CERT_SUFFIX); if(result == GLOBUS_SUCCESS) - { + { result = globus_i_gsi_sysconfig_create_key_string( service_key, &local_service_key, @@ -2460,7 +2460,7 @@ globus_gsi_sysconfig_get_service_cert_filename_win32( result, GLOBUS_GSI_SYSCONFIG_ERROR_GETTING_CERT_STRING); home = NULL; - goto done; + goto done; } } @@ -2516,29 +2516,29 @@ globus_gsi_sysconfig_get_service_cert_filename_win32( * @details * Get the proxy cert filename based on the following * search order: - * + * *
      *
    1. X509_USER_PROXY environment variable - This environment variable * is set by the at run time for the specific application. If * the proxy_file_type variable is set to GLOBUS_PROXY_OUTPUT - * (a proxy filename for writing is requested), - * and the X509_USER_PROXY is set, this will be the + * (a proxy filename for writing is requested), + * and the X509_USER_PROXY is set, this will be the * resulting value of the user_proxy filename string passed in. If the - * proxy_file_type is set to GLOBUS_PROXY_INPUT and X509_USER_PROXY is - * set, but the file it points to does not exist, - * or has some other readability issues, the + * proxy_file_type is set to GLOBUS_PROXY_INPUT and X509_USER_PROXY is + * set, but the file it points to does not exist, + * or has some other readability issues, the * function will continue checking using the other methods available. - * + * *
    2. check the registry key: x509_user_proxy. Just as with * the environment variable, if the registry key is set, and proxy_file_type - * is GLOBUS_PROXY_OUTPUT, the string set to be the proxy + * is GLOBUS_PROXY_OUTPUT, the string set to be the proxy * filename will be this registry - * key's value. If proxy_file_type is GLOBUS_PROXY_INPUT, and the - * file doesn't exist, the function will check the next method + * key's value. If proxy_file_type is GLOBUS_PROXY_INPUT, and the + * file doesn't exist, the function will check the next method * for the proxy's filename. - * + * *
    3. Check the default location for the proxy file. The default - * location should be + * location should be * set to reside in the temp directory on that host, with the filename * taking the format: x509_u<user id> * where <user id> is some unique string for that user on the host @@ -2580,7 +2580,7 @@ globus_gsi_sysconfig_get_proxy_filename_win32( } } else - { + { result = globus_i_gsi_sysconfig_create_key_string( user_proxy, &env_user_proxy, @@ -2644,7 +2644,7 @@ globus_gsi_sysconfig_get_proxy_filename_win32( if(!(*user_proxy)) { - GLOBUS_GSI_SYSCONFIG_ERROR_RESULT( + GLOBUS_GSI_SYSCONFIG_ERROR_RESULT( result, GLOBUS_GSI_SYSCONFIG_ERROR_GETTING_PROXY_FILENAME, (_GSSL("A file location for%s the proxy cert could not be found in: \n" @@ -2677,14 +2677,14 @@ globus_gsi_sysconfig_get_proxy_filename_win32( * @brief Win32 - Get CA Cert Filenames * @ingroup globus_gsi_sysconfig_win32 * @details - * Gets a list of trusted CA certificate filenames in - * a trusted CA certificate directory. + * Gets a list of trusted CA certificate filenames in + * a trusted CA certificate directory. * * @param ca_cert_dir * The trusted CA certificate directory to get the filenames from * @param ca_cert_list * The resulting list of CA certificate filenames. This is - * a globus list structure. + * a globus list structure. * @see globus_fifo_t * @return * GLOBUS_SUCCESS if no error occurred, otherwise an error object ID @@ -2724,7 +2724,7 @@ globus_gsi_sysconfig_get_ca_cert_files_win32( goto exit; } - /* build a wild card search string */ + /* build a wild card search string */ sprintf(file_search_string,"%s\\*.*",ca_cert_dir); /* search the directory for the first file */ @@ -2748,14 +2748,14 @@ globus_gsi_sysconfig_get_ca_cert_files_win32( { file_length = strlen(file_data.cFileName); /* check the following: - * + * * - file length is greater than or equal to 10 * - first 8 characters are alpha-numeric * - 9th character is '.' * - characters after the '.' are numeric */ - full_filename_path = + full_filename_path = globus_common_create_string( "%s%s%s", ca_cert_dir, FILE_SEPARATOR, file_data.cFileName); @@ -2779,9 +2779,9 @@ globus_gsi_sysconfig_get_ca_cert_files_win32( if(file_length >= (X509_HASH_LENGTH + 2) && (*(file_data.cFileName + X509_HASH_LENGTH) == '.') && - (strspn(file_data.cFileName, "0123456789abcdefABCDEF") + (strspn(file_data.cFileName, "0123456789abcdefABCDEF") == X509_HASH_LENGTH) && - (strspn((file_data.cFileName + (X509_HASH_LENGTH + 1)), + (strspn((file_data.cFileName + (X509_HASH_LENGTH + 1)), "0123456789") == (file_length - 9))) { globus_fifo_enqueue(ca_cert_list, (void *)full_filename_path); @@ -2842,7 +2842,7 @@ globus_gsi_sysconfig_remove_all_owned_files_win32( GLOBUS_I_GSI_SYSCONFIG_DEBUG_ENTER; - /* build a wild card search string */ + /* build a wild card search string */ sprintf(search_string,"%s\\*.*",DEFAULT_SECURE_TMP_DIR); /* search the directory for the first file */ @@ -2864,7 +2864,7 @@ globus_gsi_sysconfig_remove_all_owned_files_win32( /* go through all the files in the directory (first one's already there) */ do { - if((default_filename && + if((default_filename && !strcmp(file_data.cFileName, default_filename)) || !strncmp(file_data.cFileName, X509_UNIQUE_PROXY_FILE, @@ -2884,11 +2884,11 @@ globus_gsi_sysconfig_remove_all_owned_files_win32( RAND_add((void *) &stx, sizeof(stx), 2); f = _open(full_filename, O_RDWR); - if (f) + if (f) { size = lseek(f, 0L, SEEK_END); lseek(f, 0L, SEEK_SET); - if (size > 0) + if (size > 0) { rec = size / 64; left = size - rec * 64; @@ -2898,7 +2898,7 @@ globus_gsi_sysconfig_remove_all_owned_files_win32( rec--; } if (left) - { + { write(f, msg, left); } } @@ -3000,7 +3000,7 @@ globus_gsi_sysconfig_get_gridmap_filename_win32( GLOBUS_GSI_SYSCONFIG_ERROR_CHAIN_RESULT( result, GLOBUS_GSI_SYSCONFIG_ERROR_GETTING_GRIDMAP_FILENAME); - goto exit; + goto exit; } } } @@ -3032,7 +3032,7 @@ globus_gsi_sysconfig_get_gridmap_filename_win32( * @ingroup globus_gsi_sysconfig_win32 * @details * Get the path and file name of the authorization callback - * configuration file + * configuration file * * @param filename * Contains the location of the authorization callback configuration @@ -3076,7 +3076,7 @@ globus_gsi_sysconfig_get_authz_conf_filename_win32( } } else - { + { authz_filename = globus_common_create_string( "%s", DEFAULT_AUTHZ_FILE); @@ -3097,7 +3097,7 @@ globus_gsi_sysconfig_get_authz_conf_filename_win32( authz_filename = NULL; } else - { + { GLOBUS_GSI_SYSCONFIG_ERROR_CHAIN_RESULT( result, GLOBUS_GSI_SYSCONFIG_ERROR_GETTING_AUTHZ_FILENAME); @@ -3133,7 +3133,7 @@ globus_gsi_sysconfig_get_authz_conf_filename_win32( authz_filename = NULL; } else - { + { GLOBUS_GSI_SYSCONFIG_ERROR_CHAIN_RESULT( result, GLOBUS_GSI_SYSCONFIG_ERROR_GETTING_AUTHZ_FILENAME); @@ -3208,7 +3208,7 @@ globus_gsi_sysconfig_get_authz_conf_filename_win32( * @ingroup globus_gsi_sysconfig_win32 * @details * Get the path and file name of the authorization callback library - * configuration file + * configuration file * * @param filename * Contains the location of the authorization callback library @@ -3240,7 +3240,7 @@ globus_gsi_sysconfig_get_authz_lib_conf_filename_win32( goto exit; } - result = GLOBUS_GSI_SYSCONFIG_FILE_EXISTS( + result = GLOBUS_GSI_SYSCONFIG_FILE_EXISTS( authz_lib_filename); if(result != GLOBUS_SUCCESS) @@ -3252,12 +3252,12 @@ globus_gsi_sysconfig_get_authz_lib_conf_filename_win32( } } else - { + { authz_lib_filename = globus_common_create_string( "%s%s_%s%s", - DEFAULT_AUTHZ_LIB_FILE_DIR, - DEFAULT_AUTHZ_LIB_FILE_BASE, - flavor, + DEFAULT_AUTHZ_LIB_FILE_DIR, + DEFAULT_AUTHZ_LIB_FILE_BASE, + flavor, DEFAULT_AUTHZ_LIB_FILE_EXTENSION); if(!authz_lib_filename) { @@ -3265,7 +3265,7 @@ globus_gsi_sysconfig_get_authz_lib_conf_filename_win32( goto exit; } - result = GLOBUS_GSI_SYSCONFIG_FILE_EXISTS( + result = GLOBUS_GSI_SYSCONFIG_FILE_EXISTS( authz_lib_filename); if(result != GLOBUS_SUCCESS) @@ -3276,7 +3276,7 @@ globus_gsi_sysconfig_get_authz_lib_conf_filename_win32( authz_lib_filename = NULL; } else - { + { GLOBUS_GSI_SYSCONFIG_ERROR_CHAIN_RESULT( result, GLOBUS_GSI_SYSCONFIG_ERROR_GETTING_AUTHZ_LIB_FILENAME); @@ -3294,17 +3294,17 @@ globus_gsi_sysconfig_get_authz_lib_conf_filename_win32( "%s%s%s%s_%s%s", location, FILE_SEPARATOR, - INSTALLED_AUTHZ_LIB_DIR, - DEFAULT_AUTHZ_LIB_FILE_BASE, - flavor, - DEFAULT_AUTHZ_LIB_FILE_EXTENSION); + INSTALLED_AUTHZ_LIB_DIR, + DEFAULT_AUTHZ_LIB_FILE_BASE, + flavor, + DEFAULT_AUTHZ_LIB_FILE_EXTENSION); if(!authz_lib_filename) { GLOBUS_GSI_SYSTEM_CONFIG_MALLOC_ERROR; goto exit; } - result = GLOBUS_GSI_SYSCONFIG_FILE_EXISTS( + result = GLOBUS_GSI_SYSCONFIG_FILE_EXISTS( authz_lib_filename); if(result != GLOBUS_SUCCESS) @@ -3315,7 +3315,7 @@ globus_gsi_sysconfig_get_authz_lib_conf_filename_win32( authz_lib_filename = NULL; } else - { + { GLOBUS_GSI_SYSCONFIG_ERROR_CHAIN_RESULT( result, GLOBUS_GSI_SYSCONFIG_ERROR_GETTING_AUTHZ_LIB_FILENAME); @@ -3336,8 +3336,8 @@ globus_gsi_sysconfig_get_authz_lib_conf_filename_win32( home_dir, FILE_SEPARATOR, HOME_AUTHZ_LIB_FILE_BASE, - flavor, - DEFAULT_AUTHZ_LIB_FILE_EXTENSION); + flavor, + DEFAULT_AUTHZ_LIB_FILE_EXTENSION); if(!authz_lib_filename) { GLOBUS_GSI_SYSTEM_CONFIG_MALLOC_ERROR; @@ -3436,7 +3436,7 @@ globus_gsi_sysconfig_get_gaa_conf_filename_win32( } } else - { + { gaa_filename = globus_common_create_string( "%s", DEFAULT_GAA_FILE); @@ -3457,7 +3457,7 @@ globus_gsi_sysconfig_get_gaa_conf_filename_win32( gaa_filename = NULL; } else - { + { GLOBUS_GSI_SYSCONFIG_ERROR_CHAIN_RESULT( result, GLOBUS_GSI_SYSCONFIG_ERROR_GETTING_GAA_FILENAME); @@ -3493,7 +3493,7 @@ globus_gsi_sysconfig_get_gaa_conf_filename_win32( gaa_filename = NULL; } else - { + { GLOBUS_GSI_SYSCONFIG_ERROR_CHAIN_RESULT( result, GLOBUS_GSI_SYSCONFIG_ERROR_GETTING_GAA_FILENAME); @@ -3576,7 +3576,7 @@ globus_gsi_sysconfig_get_gaa_conf_filename_win32( * @return * GLOBUS_SUCCESS if no error occurred, otherwise an error object ID * is returned - */ + */ globus_result_t globus_gsi_sysconfig_is_superuser_win32( int * is_superuser) @@ -3609,12 +3609,16 @@ globus_gsi_sysconfig_is_superuser_win32( * * @param signing_policy_filename * The resulting singing_policy filename - * @return + * @return * GLOBUS_SUCCESS if no error occurred, otherwise an error object ID */ globus_result_t globus_gsi_sysconfig_get_signing_policy_filename_win32( +#if OPENSSL_VERSION_NUMBER < 0x40000000L X509_NAME * ca_name, +#else + const X509_NAME * ca_name, +#endif char * cert_dir, char ** signing_policy_filename) { @@ -3655,7 +3659,7 @@ globus_gsi_sysconfig_get_signing_policy_filename_win32( hash = X509_NAME_hash(ca_name); signing_policy = globus_common_create_string( - "%s%s%08lx%s", + "%s%s%08lx%s", ca_cert_dir, FILE_SEPARATOR, hash, SIGNING_POLICY_FILE_EXTENSION); if(signing_policy == NULL) @@ -3718,7 +3722,7 @@ globus_gsi_sysconfig_set_key_permissions_unix( char * filename) { globus_result_t result = GLOBUS_SUCCESS; - int fd = -1; + int fd = -1; mode_t oldmask; struct stat stx, stx2; @@ -3726,7 +3730,7 @@ globus_gsi_sysconfig_set_key_permissions_unix( oldmask = globus_libc_umask(0077); if((fd = globus_libc_open( - filename, O_RDONLY|O_CREAT|O_EXCL, S_IRUSR|S_IWUSR)) < 0) + filename, O_RDONLY|O_CREAT|O_EXCL, S_IRUSR|S_IWUSR)) < 0) { result = globus_error_put( globus_error_wrap_errno_error( @@ -3755,8 +3759,8 @@ globus_gsi_sysconfig_set_key_permissions_unix( } /* - * use any stat output as random data, as it will - * have file sizes, and last use times in it. + * use any stat output as random data, as it will + * have file sizes, and last use times in it. */ RAND_add((void*)&stx, sizeof(stx), 2); @@ -3803,7 +3807,7 @@ globus_gsi_sysconfig_set_key_permissions_unix( __FILE__, __func__, __LINE__, - "Error setting permissions to user read only of file: %s\n", + "Error setting permissions to user read only of file: %s\n", filename)); goto exit; } @@ -3811,7 +3815,7 @@ globus_gsi_sysconfig_set_key_permissions_unix( exit: if (fd >= 0) { - close(fd); + close(fd); } globus_libc_umask(oldmask); GLOBUS_I_GSI_SYSCONFIG_DEBUG_EXIT; @@ -3823,7 +3827,7 @@ globus_gsi_sysconfig_set_key_permissions_unix( * @ingroup globus_gsi_sysconfig_unix * @details * Get a unique string representing the current user. This is just - * the uid converted to a string. + * the uid converted to a string. * * @param user_id_string * A unique string representing the user @@ -3950,7 +3954,7 @@ globus_gsi_sysconfig_get_username_unix( goto exit; } - strncpy(*username, pwd_result->pw_name, + strncpy(*username, pwd_result->pw_name, strlen(pwd_result->pw_name) + 1); exit: @@ -3969,7 +3973,7 @@ globus_gsi_sysconfig_get_username_unix( * @ingroup globus_gsi_sysconfig_unix * @details * Get a unique string representing the current process. This is just - * the pid converted to a string. + * the pid converted to a string. * * @param proc_id_string * A unique string representing the process @@ -4017,9 +4021,9 @@ globus_gsi_sysconfig_get_proc_id_string_unix( * on the current working directory. * * @param filename - * the filename to get the absolute path of. + * the filename to get the absolute path of. * @param absolute_path - * The resulting absolute path. This needs to + * The resulting absolute path. This needs to * be freed when no longer needed. * @return * GLOBUS_SUCCESS if no error occurred, otherwise @@ -4093,13 +4097,13 @@ globus_gsi_sysconfig_make_absolute_path_for_filename_unix( * The filename to split. Splits on the last occurrence of '/' * where the directory is everything before the last '/', and * the filename is everything after. - * @param dir_string + * @param dir_string * The directory portion of the filename string. If no '/' is found * throughout the string, this variable points to NULL. * This needs to be freed when no longer needed. * @param filename_string * The filename portion of the filename string. If no '/' is found - * throughout, this variable is a duplicate of the full_filename + * throughout, this variable is a duplicate of the full_filename * parameter. This needs to be freed when no longer needed. * * @return @@ -4134,8 +4138,8 @@ globus_gsi_sysconfig_split_dir_and_filename_unix( goto exit; } - globus_libc_snprintf(*filename_string, filename_string_length, - "%s", full_filename); + globus_libc_snprintf(*filename_string, filename_string_length, + "%s", full_filename); } else { @@ -4181,7 +4185,7 @@ globus_gsi_sysconfig_split_dir_and_filename_unix( * @brief UNIX - Get Current Working Directory * @ingroup globus_gsi_sysconfig_unix * @details - * Get the current working directory on the system. + * Get the current working directory on the system. * * @param working_dir * The current working directory @@ -4223,7 +4227,7 @@ globus_gsi_sysconfig_get_current_working_dir_unix( } else if(!result_buffer) { - result = + result = globus_error_put(globus_error_wrap_errno_error( GLOBUS_GSI_SYSCONFIG_MODULE, errno, @@ -4319,7 +4323,7 @@ globus_gsi_sysconfig_get_home_dir_unix( temp_home_dir = malloc(strlen(pwd_result->pw_dir) + 1); if(temp_home_dir) { - strncpy(temp_home_dir, pwd_result->pw_dir, + strncpy(temp_home_dir, pwd_result->pw_dir, strlen(pwd_result->pw_dir) + 1); result = GLOBUS_GSI_SYSCONFIG_DIR_EXISTS(temp_home_dir); @@ -4389,7 +4393,7 @@ globus_gsi_sysconfig_file_exists_unix( GLOBUS_GSI_SYSCONFIG_ERROR_RESULT( result, GLOBUS_GSI_SYSCONFIG_ERROR_FILE_DOES_NOT_EXIST, - (_GSSL("%s is not a valid file"), filename)); + (_GSSL("%s is not a valid file"), filename)); goto exit; case EACCES: @@ -4397,7 +4401,7 @@ globus_gsi_sysconfig_file_exists_unix( GLOBUS_GSI_SYSCONFIG_ERROR_RESULT( result, GLOBUS_GSI_SYSCONFIG_ERROR_FILE_BAD_PERMISSIONS, - (_GSSL("Could not read %s"), filename)); + (_GSSL("Could not read %s"), filename)); goto exit; default: @@ -4417,8 +4421,8 @@ globus_gsi_sysconfig_file_exists_unix( } /* - * use any stat output as random data, as it will - * have file sizes, and last use times in it. + * use any stat output as random data, as it will + * have file sizes, and last use times in it. */ RAND_add((void*)&stx,sizeof(stx),2); @@ -4427,16 +4431,16 @@ globus_gsi_sysconfig_file_exists_unix( GLOBUS_GSI_SYSCONFIG_ERROR_RESULT( result, GLOBUS_GSI_SYSCONFIG_ERROR_FILE_ZERO_LENGTH, - (_GSSL("File: %s"), filename)); + (_GSSL("File: %s"), filename)); goto exit; } if(stx.st_mode & S_IFDIR) - { + { GLOBUS_GSI_SYSCONFIG_ERROR_RESULT( result, GLOBUS_GSI_SYSCONFIG_ERROR_FILE_IS_DIR, - (_GSSL("File: %s"), filename)); + (_GSSL("File: %s"), filename)); } else if((stx.st_mode & S_IFMT) & ~ (S_IFREG | S_IFLNK | S_IFDIR)) @@ -4451,7 +4455,7 @@ globus_gsi_sysconfig_file_exists_unix( GLOBUS_I_GSI_SYSCONFIG_DEBUG_EXIT; return result; -} +} /** * @brief UNIX - Directory Exists @@ -4485,7 +4489,7 @@ globus_gsi_sysconfig_dir_exists_unix( GLOBUS_GSI_SYSCONFIG_ERROR_RESULT( result, GLOBUS_GSI_SYSCONFIG_ERROR_FILE_DOES_NOT_EXIST, - (_GSSL("%s is not a valid directory"), filename)); + (_GSSL("%s is not a valid directory"), filename)); goto exit; case EACCES: @@ -4493,7 +4497,7 @@ globus_gsi_sysconfig_dir_exists_unix( GLOBUS_GSI_SYSCONFIG_ERROR_RESULT( result, GLOBUS_GSI_SYSCONFIG_ERROR_FILE_BAD_PERMISSIONS, - (_GSSL("Could not read %s"), filename)); + (_GSSL("Could not read %s"), filename)); goto exit; default: @@ -4513,39 +4517,39 @@ globus_gsi_sysconfig_dir_exists_unix( } /* - * use any stat output as random data, as it will - * have file sizes, and last use times in it. + * use any stat output as random data, as it will + * have file sizes, and last use times in it. */ RAND_add((void*)&stx,sizeof(stx),2); if(!(stx.st_mode & S_IFDIR)) - { + { GLOBUS_GSI_SYSCONFIG_ERROR_RESULT( result, GLOBUS_GSI_SYSCONFIG_ERROR_FILE_NOT_DIR, - (_GSSL("%s is not a directory"), filename)); + (_GSSL("%s is not a directory"), filename)); } exit: GLOBUS_I_GSI_SYSCONFIG_DEBUG_EXIT; return result; -} +} /** * @brief UNIX - Check File Status for Key * @ingroup globus_gsi_sysconfig_unix * @details - * This is a convenience function used to check the status of a + * This is a convenience function used to check the status of a * private key file. The desired status is only the current user has * ownership and read permissions, everyone else should not be able * to access it. - * + * * @param filename * The name of the file to check the status of * - * @return + * @return * GLOBUS_SUCCESS if the status of the file was able * to be determined. Otherwise, an error object * identifier @@ -4562,17 +4566,17 @@ globus_gsi_sysconfig_check_keyfile_unix( * @brief UNIX - Check File Status for Key * @ingroup globus_gsi_sysconfig_unix * @details - * This is a convenience function used to check the status of a + * This is a convenience function used to check the status of a * private key file. The desired status is only the specified user has * ownership and read permissions, everyone else should not be able * to access it. - * + * * @param filename * The name of the file to check the status of * @param uid * The owner of the file to check the status of * - * @return + * @return * GLOBUS_SUCCESS if the status of the file was able * to be determined. Otherwise, an error object * identifier @@ -4613,7 +4617,7 @@ globus_gsi_sysconfig_check_keyfile_uid_unix( GLOBUS_GSI_SYSCONFIG_ERROR_RESULT( result, GLOBUS_GSI_SYSCONFIG_ERROR_FILE_BAD_PERMISSIONS, - (_GSSL("Could not read %s"), filename)); + (_GSSL("Could not read %s"), filename)); goto exit; default: @@ -4632,8 +4636,8 @@ globus_gsi_sysconfig_check_keyfile_uid_unix( } /* - * use any stat output as random data, as it will - * have file sizes, and last use times in it. + * use any stat output as random data, as it will + * have file sizes, and last use times in it. */ RAND_add((void*)&stx,sizeof(stx),2); @@ -4642,17 +4646,17 @@ globus_gsi_sysconfig_check_keyfile_uid_unix( GLOBUS_GSI_SYSCONFIG_ERROR_RESULT( result, GLOBUS_GSI_SYSCONFIG_ERROR_FILE_NOT_OWNED, - (_GSSL("%s is not owned by current user"), filename)); + (_GSSL("%s is not owned by current user"), filename)); goto exit; } /* check that the key file is not x by user, or rwx by group or others */ - if (stx.st_mode & (S_IXUSR | + if (stx.st_mode & (S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH)) { GLOBUS_I_GSI_SYSCONFIG_DEBUG_FPRINTF( - 2, (stderr, "checkstat:%s:mode:%o\n", filename, stx.st_mode)); + 2, (stderr, "checkstat:%s:mode:%o\n", filename, stx.st_mode)); GLOBUS_GSI_SYSCONFIG_ERROR_RESULT( result, @@ -4666,7 +4670,7 @@ globus_gsi_sysconfig_check_keyfile_uid_unix( GLOBUS_GSI_SYSCONFIG_ERROR_RESULT( result, GLOBUS_GSI_SYSCONFIG_ERROR_FILE_ZERO_LENGTH, - (_GSSL("File: %s"), filename)); + (_GSSL("File: %s"), filename)); goto exit; } @@ -4675,7 +4679,7 @@ globus_gsi_sysconfig_check_keyfile_uid_unix( GLOBUS_GSI_SYSCONFIG_ERROR_RESULT( result, GLOBUS_GSI_SYSCONFIG_ERROR_FILE_IS_DIR, - (_GSSL("File: %s"), filename)); + (_GSSL("File: %s"), filename)); } else if((stx.st_mode & S_IFMT) & ~(S_IFLNK | S_IFREG | S_IFDIR)) @@ -4698,15 +4702,15 @@ globus_gsi_sysconfig_check_keyfile_uid_unix( * @brief UNIX - Check File Status for Cert * @ingroup globus_gsi_sysconfig_unix * @details - * This is a convenience function used to check the status of a + * This is a convenience function used to check the status of a * certificate file. The desired status is the current user has * ownership and read/write permissions, while group and others only * have read permissions. - * + * * @param filename * The name of the file to check the status of * - * @return + * @return * GLOBUS_SUCCESS if the status of the file was able * to be determined. Otherwise, an error object * identifier @@ -4724,17 +4728,17 @@ globus_gsi_sysconfig_check_certfile_unix( * @brief UNIX - Check File Status for Cert * @ingroup globus_gsi_sysconfig_unix * @details - * This is a convenience function used to check the status of a + * This is a convenience function used to check the status of a * certificate file. The desired status is the current user has * ownership and read/write permissions, while group and others only * have read permissions. - * + * * @param filename * The name of the file to check the status of * @param uid * The user id that may be the owner of the file * - * @return + * @return * GLOBUS_SUCCESS if the status of the file was able * to be determined. Otherwise, an error object * identifier @@ -4793,8 +4797,8 @@ globus_gsi_sysconfig_check_certfile_uid_unix( } /* - * use any stat output as random data, as it will - * have file sizes, and last use times in it. + * use any stat output as random data, as it will + * have file sizes, and last use times in it. */ RAND_add((void*)&stx,sizeof(stx),2); @@ -4803,7 +4807,7 @@ globus_gsi_sysconfig_check_certfile_uid_unix( GLOBUS_GSI_SYSCONFIG_ERROR_RESULT( result, GLOBUS_GSI_SYSCONFIG_ERROR_FILE_NOT_OWNED, - (_GSSL("%s is not owned by current user"), filename)); + (_GSSL("%s is not owned by current user"), filename)); goto exit; } @@ -4827,7 +4831,7 @@ globus_gsi_sysconfig_check_certfile_uid_unix( GLOBUS_GSI_SYSCONFIG_ERROR_RESULT( result, GLOBUS_GSI_SYSCONFIG_ERROR_FILE_ZERO_LENGTH, - (_GSSL("File: %s"), filename)); + (_GSSL("File: %s"), filename)); goto exit; } @@ -4869,10 +4873,10 @@ globus_gsi_sysconfig_check_certfile_uid_unix( * certificates. *
    4. $HOME/.globus/certificates - If this * directory exists, and the previous methods of determining the trusted - * certs directory failed, this directory will be used. + * certs directory failed, this directory will be used. *
    5. /etc/grid-security/certificates - This location is intended - * to be independent of the globus installation ($GLOBUS_LOCATION), and - * is generally only writeable by the host system administrator. + * to be independent of the globus installation ($GLOBUS_LOCATION), and + * is generally only writeable by the host system administrator. *
    6. $GLOBUS_LOCATION/share/certificates *
    * @@ -4880,7 +4884,7 @@ globus_gsi_sysconfig_check_certfile_uid_unix( * The trusted certificates directory * @return * GLOBUS_SUCCESS if no error occurred, and a sufficient trusted - * certificates directory was found. Otherwise, an error object + * certificates directory was found. Otherwise, an error object * identifier returned. */ globus_result_t @@ -4903,7 +4907,7 @@ globus_gsi_sysconfig_get_cert_dir_unix( if(getenv(X509_CERT_DIR)) { result = globus_i_gsi_sysconfig_create_cert_dir_string( - cert_dir, + cert_dir, & env_cert_dir, "%s", getenv(X509_CERT_DIR)); @@ -4922,9 +4926,9 @@ globus_gsi_sysconfig_get_cert_dir_unix( result = GLOBUS_GSI_SYSCONFIG_GET_HOME_DIR(&home); if(result == GLOBUS_SUCCESS) - { + { result = globus_i_gsi_sysconfig_create_cert_dir_string( - cert_dir, + cert_dir, &local_cert_dir, "%s%s%s", home, @@ -4951,7 +4955,7 @@ globus_gsi_sysconfig_get_cert_dir_unix( else if(!GLOBUS_GSI_SYSCONFIG_FILE_DOES_NOT_EXIST(result) && !GLOBUS_GSI_SYSCONFIG_FILE_HAS_BAD_PERMISSIONS(result)) { - home = NULL; + home = NULL; GLOBUS_GSI_SYSCONFIG_ERROR_CHAIN_RESULT( result, GLOBUS_GSI_SYSCONFIG_ERROR_GETTING_CERT_DIR); @@ -5044,7 +5048,7 @@ globus_gsi_sysconfig_get_cert_dir_unix( } GLOBUS_I_GSI_SYSCONFIG_DEBUG_FPRINTF( - 2, (stderr, "Using cert_dir = %s\n", + 2, (stderr, "Using cert_dir = %s\n", (*cert_dir ? *cert_dir : "null"))); result = GLOBUS_SUCCESS; @@ -5058,7 +5062,7 @@ globus_gsi_sysconfig_get_cert_dir_unix( if(home != NULL) { - free(home); + free(home); } GLOBUS_I_GSI_SYSCONFIG_DEBUG_EXIT; @@ -5073,10 +5077,10 @@ globus_gsi_sysconfig_get_cert_dir_unix( * Get the User Certificate Filename based on the current user's * environment. The following locations are searched for cert and key * files in order: - * + * *
      *
    1. environment variables X509_USER_CERT and X509_USER_KEY - *
    2. $HOME/.globus/usercert.pem and + *
    3. $HOME/.globus/usercert.pem and * $HOME/.globus/userkey.pem *
    4. $HOME/.globus/usercred.p12 - this is a PKCS12 credential *
    @@ -5124,7 +5128,7 @@ globus_gsi_sysconfig_get_user_cert_filename_unix( result, GLOBUS_GSI_SYSCONFIG_ERROR_GETTING_CERT_STRING); goto done; - } + } } if(!(*user_cert)) @@ -5161,7 +5165,7 @@ globus_gsi_sysconfig_get_user_cert_filename_unix( } if(user_key) - { + { *user_key = NULL; result = GLOBUS_SUCCESS; @@ -5225,7 +5229,7 @@ globus_gsi_sysconfig_get_user_cert_filename_unix( { result = GLOBUS_SUCCESS; if(!home) - { + { result = GLOBUS_GSI_SYSCONFIG_GET_HOME_DIR(&home); } @@ -5254,7 +5258,7 @@ globus_gsi_sysconfig_get_user_cert_filename_unix( GLOBUS_GSI_SYSCONFIG_ERROR_CHAIN_RESULT( result, GLOBUS_GSI_SYSCONFIG_ERROR_GETTING_KEY_STRING); - goto done; + goto done; } } @@ -5309,7 +5313,7 @@ globus_gsi_sysconfig_get_user_cert_filename_unix( * @ingroup globus_gsi_sysconfig_unix * @details * Get the Host Certificate and Key Filenames based on the current user's - * environment. The host cert and key are searched for in the following + * environment. The host cert and key are searched for in the following * locations (in order): * *
      @@ -5317,7 +5321,7 @@ globus_gsi_sysconfig_get_user_cert_filename_unix( *
    1. $GLOBUS_LOCATION/etc/host[cert|key].pem
    2. *
    3. $HOME/.globus/host[cert|key].pem
    4. *
    - * + * * @param host_cert * pointer to the host certificate filename * @param host_key @@ -5325,7 +5329,7 @@ globus_gsi_sysconfig_get_user_cert_filename_unix( * * @return * GLOBUS_SUCCESS if the host cert and key were found, otherwise - * an error object identifier is returned + * an error object identifier is returned */ globus_result_t globus_gsi_sysconfig_get_host_cert_filename_unix( @@ -5393,7 +5397,7 @@ globus_gsi_sysconfig_get_host_cert_filename_unix( X509_CERT_SUFFIX); if(result == GLOBUS_SUCCESS) - { + { result = globus_i_gsi_sysconfig_create_key_string( host_key, & default_host_key, @@ -5421,7 +5425,7 @@ globus_gsi_sysconfig_get_host_cert_filename_unix( } /* now check installed location for host cert */ - if(!(*host_cert) && !(*host_key)) + if(!(*host_cert) && !(*host_key)) { globus_location(&location); @@ -5439,7 +5443,7 @@ globus_gsi_sysconfig_get_host_cert_filename_unix( X509_CERT_SUFFIX); if(result == GLOBUS_SUCCESS) - { + { result = globus_i_gsi_sysconfig_create_key_string( host_key, &installed_host_key, @@ -5469,7 +5473,7 @@ globus_gsi_sysconfig_get_host_cert_filename_unix( } } - if(!(*host_cert) && !(*host_key)) + if(!(*host_cert) && !(*host_key)) { result = GLOBUS_GSI_SYSCONFIG_GET_HOME_DIR(&home); @@ -5487,7 +5491,7 @@ globus_gsi_sysconfig_get_host_cert_filename_unix( X509_CERT_SUFFIX); if(result == GLOBUS_SUCCESS) - { + { result = globus_i_gsi_sysconfig_create_key_string( host_key, & local_host_key, @@ -5570,7 +5574,7 @@ globus_gsi_sysconfig_get_host_cert_filename_unix( * @ingroup globus_gsi_sysconfig_unix * @details * Get the Service Certificate Filename based on the current user's - * environment. The host cert and key are searched for in the following + * environment. The host cert and key are searched for in the following * locations (in order): * *
      @@ -5578,11 +5582,11 @@ globus_gsi_sysconfig_get_host_cert_filename_unix( *
    1. \/etc\/grid-security\/{service_name}\/{service_name}[cert|key].pem *
    2. GLOBUS_LOCATION\/etc\/{service_name}\/{service_name}[cert|key].pem * So for example, if my service was named: myservice, the location - * of the certificate would be: + * of the certificate would be: * GLOBUS_LOCATION\/etc\/myservice\/myservicecert.pem *
    3. \\\/.globus\/{service_name}\/{service_name}[cert|key].pem *
    - * + * * @param service_name * The name of the service which allows us to determine the * locations of cert and key files to look for @@ -5593,7 +5597,7 @@ globus_gsi_sysconfig_get_host_cert_filename_unix( * * @return * GLOBUS_SUCCESS if the service cert and key were found, otherwise - * an error object identifier + * an error object identifier */ globus_result_t globus_gsi_sysconfig_get_service_cert_filename_unix( @@ -5638,7 +5642,7 @@ globus_gsi_sysconfig_get_service_cert_filename_unix( getenv(X509_USER_CERT)); if(result != GLOBUS_SUCCESS) - { + { GLOBUS_GSI_SYSCONFIG_ERROR_CHAIN_RESULT( result, GLOBUS_GSI_SYSCONFIG_ERROR_GETTING_CERT_STRING); @@ -5679,7 +5683,7 @@ globus_gsi_sysconfig_get_service_cert_filename_unix( X509_CERT_SUFFIX); if(result == GLOBUS_SUCCESS) - { + { result = globus_i_gsi_sysconfig_create_key_string( service_key, & default_service_key, @@ -5705,7 +5709,7 @@ globus_gsi_sysconfig_get_service_cert_filename_unix( GLOBUS_GSI_SYSCONFIG_ERROR_CHAIN_RESULT( result, GLOBUS_GSI_SYSCONFIG_ERROR_GETTING_CERT_STRING); - goto done; + goto done; } } else if(!GLOBUS_GSI_SYSCONFIG_FILE_DOES_NOT_EXIST(result)) @@ -5739,7 +5743,7 @@ globus_gsi_sysconfig_get_service_cert_filename_unix( X509_CERT_SUFFIX); if(result == GLOBUS_SUCCESS) - { + { result = globus_i_gsi_sysconfig_create_key_string( service_key, &installed_service_key, @@ -5795,7 +5799,7 @@ globus_gsi_sysconfig_get_service_cert_filename_unix( X509_CERT_SUFFIX); if(result == GLOBUS_SUCCESS) - { + { result = globus_i_gsi_sysconfig_create_key_string( service_key, &local_service_key, @@ -5831,7 +5835,7 @@ globus_gsi_sysconfig_get_service_cert_filename_unix( result, GLOBUS_GSI_SYSCONFIG_ERROR_GETTING_CERT_STRING); home = NULL; - goto done; + goto done; } } @@ -5887,22 +5891,22 @@ globus_gsi_sysconfig_get_service_cert_filename_unix( * @details * Get the proxy cert filename based on the following * search order: - * + * *
      *
    1. X509_USER_PROXY environment variable - This environment variable * is set by the at run time for the specific application. If * the proxy_file_type variable is set to GLOBUS_PROXY_OUTPUT - * (a proxy filename for writing is requested), - * and the X509_USER_PROXY is set, this will be the + * (a proxy filename for writing is requested), + * and the X509_USER_PROXY is set, this will be the * resulting value of the user_proxy filename string passed in. If the - * proxy_file_type is set to GLOBUS_PROXY_INPUT and X509_USER_PROXY is - * set, but the file it points to does not exist, - * or has some other readability issues, the + * proxy_file_type is set to GLOBUS_PROXY_INPUT and X509_USER_PROXY is + * set, but the file it points to does not exist, + * or has some other readability issues, the * function will continue checking using the other methods available. - * + * *
    2. Check the default location for the proxy file of * \/tmp\/x509_u\\ where \\ is some unique string for - * that user on the host + * that user on the host *
    * * @param user_proxy @@ -5941,7 +5945,7 @@ globus_gsi_sysconfig_get_proxy_filename_unix( } } else - { + { result = globus_i_gsi_sysconfig_create_key_string( user_proxy, &env_user_proxy, @@ -6005,7 +6009,7 @@ globus_gsi_sysconfig_get_proxy_filename_unix( if(!(*user_proxy)) { - GLOBUS_GSI_SYSCONFIG_ERROR_RESULT( + GLOBUS_GSI_SYSCONFIG_ERROR_RESULT( result, GLOBUS_GSI_SYSCONFIG_ERROR_GETTING_PROXY_FILENAME, (_GSSL("A file location for%s the proxy cert could not be found in: \n" @@ -6052,12 +6056,16 @@ globus_gsi_sysconfig_get_proxy_filename_unix( * * @param signing_policy_filename * The resulting singing_policy filename - * @return + * @return * GLOBUS_SUCCESS if no error occurred, otherwise an error object ID */ globus_result_t globus_gsi_sysconfig_get_signing_policy_filename_unix( +#if OPENSSL_VERSION_NUMBER < 0x40000000L X509_NAME * ca_name, +#else + const X509_NAME * ca_name, +#endif char * cert_dir, char ** signing_policy_filename) { @@ -6098,7 +6106,7 @@ globus_gsi_sysconfig_get_signing_policy_filename_unix( hash = X509_NAME_hash(ca_name); signing_policy = globus_common_create_string( - "%s%s%08lx%s", + "%s%s%08lx%s", ca_cert_dir, FILE_SEPARATOR, hash, SIGNING_POLICY_FILE_EXTENSION); if(signing_policy == NULL) @@ -6141,19 +6149,19 @@ globus_gsi_sysconfig_get_signing_policy_filename_unix( * @brief UNIX - Get CA Cert Filenames * @ingroup globus_gsi_sysconfig_unix * @details - * Gets a list of trusted CA certificate filenames in - * a trusted CA certificate directory. + * Gets a list of trusted CA certificate filenames in + * a trusted CA certificate directory. * * @param ca_cert_dir * The trusted CA certificate directory to get the filenames from * @param ca_cert_list * The resulting list of CA certificate filenames. This is a - * a globus list structure. + * a globus list structure. * @see globus_fifo_t * @return * GLOBUS_SUCCESS if no error occurred, otherwise an error object ID * is returned - */ + */ globus_result_t globus_gsi_sysconfig_get_ca_cert_files_unix( char * ca_cert_dir, @@ -6207,14 +6215,14 @@ globus_gsi_sysconfig_get_ca_cert_files_unix( { file_length = strlen(tmp_entry->d_name); /* check the following: - * + * * - file length is greater than or equal to 10 * - first 8 characters are alpha-numeric * - 9th character is '.' * - characters after the '.' are numeric */ - full_filename_path = + full_filename_path = globus_common_create_string( "%s%s%s", ca_cert_dir, FILE_SEPARATOR, tmp_entry->d_name); @@ -6238,9 +6246,9 @@ globus_gsi_sysconfig_get_ca_cert_files_unix( if(file_length >= (X509_HASH_LENGTH + 2) && (*(tmp_entry->d_name + X509_HASH_LENGTH) == '.') && - (strspn(tmp_entry->d_name, "0123456789abcdefABCDEF") + (strspn(tmp_entry->d_name, "0123456789abcdefABCDEF") == X509_HASH_LENGTH) && - (strspn((tmp_entry->d_name + (X509_HASH_LENGTH + 1)), + (strspn((tmp_entry->d_name + (X509_HASH_LENGTH + 1)), "0123456789") == (file_length - 9))) { globus_fifo_enqueue(ca_cert_list, (void *)full_filename_path); @@ -6269,7 +6277,7 @@ globus_gsi_sysconfig_get_ca_cert_files_unix( if(tmp_entry != NULL) { - globus_libc_free(tmp_entry); + globus_libc_free(tmp_entry); } GLOBUS_I_GSI_SYSCONFIG_DEBUG_EXIT; @@ -6290,7 +6298,7 @@ globus_gsi_sysconfig_get_ca_cert_files_unix( * @return * GLOBUS_SUCCESS if no error occurred, otherwise an error object ID * is returned - */ + */ globus_result_t globus_gsi_sysconfig_remove_all_owned_files_unix( char * default_filename) @@ -6322,7 +6330,7 @@ globus_gsi_sysconfig_remove_all_owned_files_unix( while(globus_libc_readdir_r(secure_tmp_dir, &dir_entry) == 0 && dir_entry != NULL) { - if((default_filename && + if((default_filename && !strcmp(dir_entry->d_name, default_filename)) || !strncmp(dir_entry->d_name, X509_UNIQUE_PROXY_FILE, @@ -6350,11 +6358,11 @@ globus_gsi_sysconfig_remove_all_owned_files_unix( = "DESTROYED BY GLOBUS\r\n"; int f = open(full_filename, O_RDWR); int size, rec, left; - if (f) + if (f) { size = lseek(f, 0L, SEEK_END); lseek(f, 0L, SEEK_SET); - if (size > 0) + if (size > 0) { rec = size / 64; left = size - rec * 64; @@ -6364,7 +6372,7 @@ globus_gsi_sysconfig_remove_all_owned_files_unix( rec--; } if (left) - { + { write(f, msg, left); } } @@ -6401,7 +6409,7 @@ globus_gsi_sysconfig_remove_all_owned_files_unix( * @return * GLOBUS_SUCCESS if no error occurred, otherwise an error object ID * is returned - */ + */ globus_result_t globus_gsi_sysconfig_is_superuser_unix( int * is_superuser) @@ -6437,7 +6445,7 @@ globus_gsi_sysconfig_is_superuser_unix( * @return * GLOBUS_SUCCESS if no error occurred, otherwise an error object ID * is returned - */ + */ globus_result_t globus_gsi_sysconfig_get_gridmap_filename_unix( char ** filename) @@ -6502,7 +6510,7 @@ globus_gsi_sysconfig_get_gridmap_filename_unix( GLOBUS_GSI_SYSCONFIG_ERROR_CHAIN_RESULT( result, GLOBUS_GSI_SYSCONFIG_ERROR_GETTING_GRIDMAP_FILENAME); - goto exit; + goto exit; } } } @@ -6535,15 +6543,15 @@ globus_gsi_sysconfig_get_gridmap_filename_unix( * @ingroup globus_gsi_sysconfig_unix * @details * Get the path and file name of the authorization callback - * configuration file + * configuration file * * @param filename * Contains the location of the authorization callback configuration - * file upon successful return + * file upon successful return * @return * GLOBUS_SUCCESS if no error occurred, otherwise an error object ID * is returned - */ + */ globus_result_t globus_gsi_sysconfig_get_authz_conf_filename_unix( char ** filename) @@ -6579,7 +6587,7 @@ globus_gsi_sysconfig_get_authz_conf_filename_unix( } } else - { + { authz_filename = globus_common_create_string( "%s", DEFAULT_AUTHZ_FILE); @@ -6600,7 +6608,7 @@ globus_gsi_sysconfig_get_authz_conf_filename_unix( authz_filename = NULL; } else - { + { GLOBUS_GSI_SYSCONFIG_ERROR_CHAIN_RESULT( result, GLOBUS_GSI_SYSCONFIG_ERROR_GETTING_AUTHZ_FILENAME); @@ -6636,7 +6644,7 @@ globus_gsi_sysconfig_get_authz_conf_filename_unix( authz_filename = NULL; } else - { + { GLOBUS_GSI_SYSCONFIG_ERROR_CHAIN_RESULT( result, GLOBUS_GSI_SYSCONFIG_ERROR_GETTING_AUTHZ_FILENAME); @@ -6707,19 +6715,19 @@ globus_gsi_sysconfig_get_authz_conf_filename_unix( } /** - * @brief UNIX - Get the path and file name of the authorization callback configuration file + * @brief UNIX - Get the path and file name of the authorization callback configuration file * @ingroup globus_gsi_sysconfig_unix * @details * Get the path and file name of the authorization callback - * configuration file + * configuration file * * @param filename * Contains the location of the authorization callback configuration - * file upon successful return + * file upon successful return * @return * GLOBUS_SUCCESS if no error occurred, otherwise an error object ID * is returned - */ + */ globus_result_t globus_gsi_sysconfig_get_authz_lib_conf_filename_unix( char ** filename) @@ -6754,12 +6762,12 @@ globus_gsi_sysconfig_get_authz_lib_conf_filename_unix( } } else - { + { authz_lib_filename = globus_common_create_string( "%s%s_%s%s", - DEFAULT_AUTHZ_LIB_FILE_DIR, - DEFAULT_AUTHZ_LIB_FILE_BASE, - flavor, + DEFAULT_AUTHZ_LIB_FILE_DIR, + DEFAULT_AUTHZ_LIB_FILE_BASE, + flavor, DEFAULT_AUTHZ_LIB_FILE_EXTENSION); if(!authz_lib_filename) { @@ -6777,7 +6785,7 @@ globus_gsi_sysconfig_get_authz_lib_conf_filename_unix( authz_lib_filename = NULL; } else - { + { GLOBUS_GSI_SYSCONFIG_ERROR_CHAIN_RESULT( result, GLOBUS_GSI_SYSCONFIG_ERROR_GETTING_AUTHZ_LIB_FILENAME); @@ -6795,17 +6803,17 @@ globus_gsi_sysconfig_get_authz_lib_conf_filename_unix( "%s%s%s%s_%s%s", location, FILE_SEPARATOR, - INSTALLED_AUTHZ_LIB_DIR, - DEFAULT_AUTHZ_LIB_FILE_BASE, - flavor, - DEFAULT_AUTHZ_LIB_FILE_EXTENSION); + INSTALLED_AUTHZ_LIB_DIR, + DEFAULT_AUTHZ_LIB_FILE_BASE, + flavor, + DEFAULT_AUTHZ_LIB_FILE_EXTENSION); if(!authz_lib_filename) { GLOBUS_GSI_SYSTEM_CONFIG_MALLOC_ERROR; goto exit; } - result = GLOBUS_GSI_SYSCONFIG_FILE_EXISTS(authz_lib_filename); + result = GLOBUS_GSI_SYSCONFIG_FILE_EXISTS(authz_lib_filename); if(result != GLOBUS_SUCCESS) { @@ -6815,7 +6823,7 @@ globus_gsi_sysconfig_get_authz_lib_conf_filename_unix( authz_lib_filename = NULL; } else - { + { GLOBUS_GSI_SYSCONFIG_ERROR_CHAIN_RESULT( result, GLOBUS_GSI_SYSCONFIG_ERROR_GETTING_AUTHZ_LIB_FILENAME); @@ -6836,8 +6844,8 @@ globus_gsi_sysconfig_get_authz_lib_conf_filename_unix( home_dir, FILE_SEPARATOR, HOME_AUTHZ_LIB_FILE_BASE, - flavor, - DEFAULT_AUTHZ_LIB_FILE_EXTENSION); + flavor, + DEFAULT_AUTHZ_LIB_FILE_EXTENSION); if(!authz_lib_filename) { GLOBUS_GSI_SYSTEM_CONFIG_MALLOC_ERROR; @@ -6887,18 +6895,18 @@ globus_gsi_sysconfig_get_authz_lib_conf_filename_unix( } /** - * @brief UNIX - Get the path and file name of the gaa configuration file + * @brief UNIX - Get the path and file name of the gaa configuration file * @ingroup globus_gsi_sysconfig_unix * @details - * Get the path and file name of the GAA configuration file + * Get the path and file name of the GAA configuration file * * @param filename * Contains the location of the GAA callback configuration - * file upon successful return + * file upon successful return * @return * GLOBUS_SUCCESS if no error occurred, otherwise an error object ID * is returned - */ + */ globus_result_t globus_gsi_sysconfig_get_gaa_conf_filename_unix( char ** filename) @@ -6922,7 +6930,7 @@ globus_gsi_sysconfig_get_gaa_conf_filename_unix( goto exit; } - result = GLOBUS_GSI_SYSCONFIG_FILE_EXISTS( + result = GLOBUS_GSI_SYSCONFIG_FILE_EXISTS( gaa_filename); if(result != GLOBUS_SUCCESS) @@ -6934,7 +6942,7 @@ globus_gsi_sysconfig_get_gaa_conf_filename_unix( } } else - { + { gaa_filename = globus_common_create_string( "%s", DEFAULT_GAA_FILE); @@ -6944,7 +6952,7 @@ globus_gsi_sysconfig_get_gaa_conf_filename_unix( goto exit; } - result = GLOBUS_GSI_SYSCONFIG_FILE_EXISTS( + result = GLOBUS_GSI_SYSCONFIG_FILE_EXISTS( gaa_filename); if(result != GLOBUS_SUCCESS) @@ -6955,7 +6963,7 @@ globus_gsi_sysconfig_get_gaa_conf_filename_unix( gaa_filename = NULL; } else - { + { GLOBUS_GSI_SYSCONFIG_ERROR_CHAIN_RESULT( result, GLOBUS_GSI_SYSCONFIG_ERROR_GETTING_GAA_FILENAME); @@ -6980,7 +6988,7 @@ globus_gsi_sysconfig_get_gaa_conf_filename_unix( goto exit; } - result = GLOBUS_GSI_SYSCONFIG_FILE_EXISTS( + result = GLOBUS_GSI_SYSCONFIG_FILE_EXISTS( gaa_filename); if(result != GLOBUS_SUCCESS) @@ -6991,7 +6999,7 @@ globus_gsi_sysconfig_get_gaa_conf_filename_unix( gaa_filename = NULL; } else - { + { GLOBUS_GSI_SYSCONFIG_ERROR_CHAIN_RESULT( result, GLOBUS_GSI_SYSCONFIG_ERROR_GETTING_GAA_FILENAME); @@ -7069,7 +7077,7 @@ globus_gsi_sysconfig_get_gaa_conf_filename_unix( * Get a unique proxy cert filename. This is mostly used * for delegated proxy credentials. Each filename returned * is going to be unique for each time the function is called. - * + * * @param unique_filename * the unique filename for a delegated proxy cert * @@ -7317,7 +7325,7 @@ globus_gsi_sysconfig_get_vhost_cred_dir( /* globus_gsi_sysconfig_get_vhost_cred_dir() */ -/* +/* * Windows Default Directory And File Routines */ #ifdef WIN32 @@ -7354,7 +7362,7 @@ const char *win32_cwd(void) char * cwd = NULL; static char buffer[MAX_PATH]; - /* Collect environment all variables we might need */ + /* Collect environment all variables we might need */ tmp_path = getenv("TMP"); temp_path = getenv("TEMP"); globus_location(&location); @@ -7364,17 +7372,17 @@ const char *win32_cwd(void) { return location; } - else if(cwd) + else if(cwd) { return buffer; } - /* Use $TMP */ - else if(tmp_path) + /* Use $TMP */ + else if(tmp_path) { return tmp_path; } - /* Use $TEMP */ - else if(temp_path) + /* Use $TEMP */ + else if(temp_path) { return temp_path; } diff --git a/gsi/sysconfig/source/library/globus_gsi_system_config.h b/gsi/sysconfig/source/library/globus_gsi_system_config.h index 07bee399f4..d9b9886dd6 100644 --- a/gsi/sysconfig/source/library/globus_gsi_system_config.h +++ b/gsi/sysconfig/source/library/globus_gsi_system_config.h @@ -76,7 +76,7 @@ extern "C" { */ /** - * @defgroup globus_gsi_sysconfig_win32 Functions for Win32 platforms + * @defgroup globus_gsi_sysconfig_win32 Functions for Win32 platforms * @ingroup globus_gsi_sysconfig * @brief Functions for Win32 platforms * @@ -91,7 +91,7 @@ extern "C" { * @brief Functions for all platforms * * These functions are platform independent members of the Globus GSI System - * Configuration API. + * Configuration API. * */ @@ -137,14 +137,14 @@ extern "C" { * subsequently called. This function may be called multiple times. * * To deactivate Globus GSI System Configuration API, the following function - * must be called: + * must be called: * * @code * globus_module_deactivate(GLOBUS_GSI_SYSCONFIG_MODULE) * @endcode * * This function should be called once for each time Globus GSI System - * Configuration API was activated. + * Configuration API was activated. */ /** Module descriptor @@ -153,7 +153,7 @@ extern "C" { */ #define GLOBUS_GSI_SYSCONFIG_MODULE (&globus_i_gsi_sysconfig_module) -extern +extern globus_module_descriptor_t globus_i_gsi_sysconfig_module; #ifdef WIN32 @@ -340,7 +340,7 @@ globus_module_descriptor_t globus_i_gsi_sysconfig_module; globus_gsi_sysconfig_get_signing_policy_filename_unix /** * Get a list of of trusted CA certificate filenames in a trusted CA - * certificate directory. + * certificate directory. * @ingroup globus_gsi_system_config_defines * @hideinitializer * See globus_gsi_sysconfig_get_ca_cert_files_unix() and @@ -376,7 +376,7 @@ globus_module_descriptor_t globus_i_gsi_sysconfig_module; # define GLOBUS_GSI_SYSCONFIG_SPLIT_DIR_AND_FILENAME \ globus_gsi_sysconfig_split_dir_and_filename_unix /** - * Remove all proxies owned by current uid + * Remove all proxies owned by current uid * @ingroup globus_gsi_system_config_defines * @hideinitializer * See globus_gsi_sysconfig_remove_all_owned_files_unix() and @@ -385,7 +385,7 @@ globus_module_descriptor_t globus_i_gsi_sysconfig_module; # define GLOBUS_GSI_SYSCONFIG_REMOVE_ALL_OWNED_FILES \ globus_gsi_sysconfig_remove_all_owned_files_unix /** - * Determine the location of the grid map file. + * Determine the location of the grid map file. * @ingroup globus_gsi_system_config_defines * @hideinitializer * See globus_gsi_sysconfig_get_gridmap_filename_unix() and @@ -394,7 +394,7 @@ globus_module_descriptor_t globus_i_gsi_sysconfig_module; # define GLOBUS_GSI_SYSCONFIG_GET_GRIDMAP_FILENAME \ globus_gsi_sysconfig_get_gridmap_filename_unix /** - * Determine the location of the authorization callout config file. + * Determine the location of the authorization callout config file. * @ingroup globus_gsi_system_config_defines * @hideinitializer * See globus_gsi_sysconfig_get_authz_conf_filename_unix() @@ -403,7 +403,7 @@ globus_module_descriptor_t globus_i_gsi_sysconfig_module; globus_gsi_sysconfig_get_authz_conf_filename_unix /** - * Determine the location of the GAA callout config file. + * Determine the location of the GAA callout config file. * @ingroup globus_gsi_system_config_defines * @hideinitializer * See globus_gsi_sysconfig_get_gaa_conf_filename_unix() @@ -438,7 +438,7 @@ globus_module_descriptor_t globus_i_gsi_sysconfig_module; # define GLOBUS_GSI_SYSCONFIG_GET_PROC_ID_STRING \ globus_gsi_sysconfig_get_proc_id_string_unix /** - * Get the current user name + * Get the current user name * @ingroup globus_gsi_system_config_defines * @hideinitializer * See globus_gsi_sysconfig_get_username_unix() and @@ -452,7 +452,7 @@ globus_module_descriptor_t globus_i_gsi_sysconfig_module; * Generate a unique proxy file name * @ingroup globus_gsi_system_config_defines * @hideinitializer - * See globus_gsi_sysconfig_get_unique_proxy_filename() + * See globus_gsi_sysconfig_get_unique_proxy_filename() */ #define GLOBUS_GSI_SYSCONFIG_GET_UNIQUE_PROXY_FILENAME \ globus_gsi_sysconfig_get_unique_proxy_filename @@ -527,7 +527,11 @@ GLOBUS_GSI_SYSCONFIG_GET_PROXY_FILENAME( globus_result_t GLOBUS_GSI_SYSCONFIG_GET_SIGNING_POLICY_FILENAME( +#if OPENSSL_VERSION_NUMBER < 0x40000000L X509_NAME * ca_name, +#else + const X509_NAME * ca_name, +#endif char * cert_dir, char ** signing_policy_filename); diff --git a/io/compat/configure.ac b/io/compat/configure.ac index c6ac4c7061..23bec1a8d3 100644 --- a/io/compat/configure.ac +++ b/io/compat/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ([2.60]) -AC_INIT([globus_io],[12.4],[https://github.com/gridcf/gct/issues]) +AC_INIT([globus_io],[12.5],[https://github.com/gridcf/gct/issues]) AC_CONFIG_MACRO_DIR([m4]) AC_SUBST([MAJOR_VERSION], [${PACKAGE_VERSION%%.*}]) AC_SUBST([MINOR_VERSION], [${PACKAGE_VERSION##*.}]) diff --git a/io/compat/globus_io_xio_compat.c b/io/compat/globus_io_xio_compat.c index 84cf6264d2..5cda082321 100644 --- a/io/compat/globus_io_xio_compat.c +++ b/io/compat/globus_io_xio_compat.c @@ -138,8 +138,8 @@ typedef struct globus_l_io_secure_authorization_data_s { gss_name_t identity; globus_io_secure_authorization_callback_t callback; - void * callback_arg; -} globus_l_io_secure_authorization_data_t; + void * callback_arg; +} globus_l_io_secure_authorization_data_t; typedef struct globus_l_io_attr_s { @@ -162,12 +162,12 @@ typedef struct globus_l_io_handle_s globus_io_handle_t * io_handle; globus_xio_handle_t xio_handle; globus_callback_space_t space; - + globus_list_t * pending_ops; globus_mutex_t pending_lock; void * user_pointer; globus_io_attr_t attr; - + /* used only for listener */ globus_xio_server_t xio_server; globus_xio_handle_t accepted_handle; @@ -247,7 +247,7 @@ int globus_l_io_activate(void) { globus_result_t result; - + if(globus_module_activate(GLOBUS_XIO_MODULE) != GLOBUS_SUCCESS) { goto error_activate; @@ -258,7 +258,7 @@ globus_l_io_activate(void) { goto error_load_file; } - + if(globus_xio_driver_load( "tcp", &globus_l_io_tcp_driver) != GLOBUS_SUCCESS) { @@ -270,78 +270,78 @@ globus_l_io_activate(void) { goto error_load_gsi; } - + result = globus_xio_stack_init(&globus_l_io_file_stack, GLOBUS_NULL); if(result != GLOBUS_SUCCESS) { goto error_file_stack; } - + result = globus_xio_stack_push_driver( globus_l_io_file_stack, globus_l_io_file_driver); if(result != GLOBUS_SUCCESS) { goto error_file_push; } - + result = globus_xio_stack_init(&globus_l_io_tcp_stack, GLOBUS_NULL); if(result != GLOBUS_SUCCESS) { goto error_tcp_stack; } - + result = globus_xio_stack_push_driver( globus_l_io_tcp_stack, globus_l_io_tcp_driver); if(result != GLOBUS_SUCCESS) { goto error_tcp_push; } - + result = globus_xio_stack_init(&globus_l_io_gsi_stack, GLOBUS_NULL); if(result != GLOBUS_SUCCESS) { goto error_gsi_stack; } - + result = globus_xio_stack_push_driver( globus_l_io_gsi_stack, globus_l_io_tcp_driver); if(result != GLOBUS_SUCCESS) { goto error_gsi_push; } - + result = globus_xio_stack_push_driver( globus_l_io_gsi_stack, globus_l_io_gsi_driver); if(result != GLOBUS_SUCCESS) { goto error_gsi_push; } - + return GLOBUS_SUCCESS; error_gsi_push: globus_xio_stack_destroy(globus_l_io_gsi_stack); - + error_gsi_stack: error_tcp_push: globus_xio_stack_destroy(globus_l_io_tcp_stack); - + error_tcp_stack: error_file_push: globus_xio_stack_destroy(globus_l_io_file_stack); - + error_file_stack: globus_xio_driver_unload(globus_l_io_gsi_driver); - + error_load_gsi: globus_xio_driver_unload(globus_l_io_tcp_driver); error_load_tcp: globus_xio_driver_unload(globus_l_io_file_driver); - + error_load_file: globus_module_deactivate(GLOBUS_XIO_MODULE); - + error_activate: return GLOBUS_FAILURE; } @@ -353,11 +353,11 @@ globus_l_io_deactivate(void) globus_xio_stack_destroy(globus_l_io_gsi_stack); globus_xio_stack_destroy(globus_l_io_tcp_stack); globus_xio_stack_destroy(globus_l_io_file_stack); - + globus_xio_driver_unload(globus_l_io_gsi_driver); globus_xio_driver_unload(globus_l_io_tcp_driver); globus_xio_driver_unload(globus_l_io_file_driver); - + return globus_module_deactivate(GLOBUS_XIO_MODULE); } @@ -372,13 +372,13 @@ globus_l_io_handle_init( globus_result_t result; globus_l_io_handle_t * ihandle; GlobusIOName(globus_l_io_handle_init); - + result = GlobusLIOMalloc(ihandle, globus_l_io_handle_t); if(result != GLOBUS_SUCCESS) { goto error_alloc; } - + ihandle->type = type; ihandle->refs = 1; ihandle->io_handle = io_handle; @@ -391,11 +391,11 @@ globus_l_io_handle_init( ihandle->user_pointer = GLOBUS_NULL; globus_mutex_init(&ihandle->pending_lock, GLOBUS_NULL); globus_callback_space_reference(ihandle->space); - + *_ihandle = ihandle; - + return GLOBUS_SUCCESS; - + error_alloc: return result; } @@ -407,7 +407,7 @@ globus_l_io_handle_destroy( { globus_bool_t destroy; GlobusIOName(globus_l_io_handle_destroy); - + globus_mutex_lock(&ihandle->pending_lock); { if(--ihandle->refs == 0) @@ -420,7 +420,7 @@ globus_l_io_handle_destroy( } } globus_mutex_unlock(&ihandle->pending_lock); - + if(destroy) { if(ihandle->attr) @@ -452,7 +452,7 @@ globus_l_io_attr_check( const char * func_name) { globus_l_io_attr_t * iattr; - + if(!attr) { return globus_error_put( @@ -463,9 +463,9 @@ globus_l_io_attr_check( 1, (char *) func_name)); } - + iattr = (globus_l_io_attr_t *) *attr; - + if(!iattr || !(iattr->type & types)) { return globus_error_put( @@ -476,7 +476,7 @@ globus_l_io_attr_check( 1, (char *) func_name)); } - + return GLOBUS_SUCCESS; } @@ -491,17 +491,17 @@ globus_l_io_iattr_copy( globus_io_secure_authorization_data_t data; globus_result_t result; GlobusIOName(globus_l_io_iattr_copy); - + source_iattr = (globus_l_io_attr_t *) *source; - + result = GlobusLIOMalloc(dest_iattr, globus_l_io_attr_t); if(result != GLOBUS_SUCCESS) { goto error_alloc; } - + memset(dest_iattr, 0, sizeof(globus_l_io_attr_t)); - + dest_iattr->type = source_iattr->type; if(dest_iattr->type == GLOBUS_I_IO_TCP_ATTR) { @@ -517,7 +517,7 @@ globus_l_io_iattr_copy( { goto error_auth_copy; } - + dest_iattr->authz_data.identity = data->identity; dest_iattr->authz_data.callback = data->callback; dest_iattr->authz_data.callback_arg = data->callback_arg; @@ -528,7 +528,7 @@ globus_l_io_iattr_copy( globus_assert(dest_iattr->type == GLOBUS_I_IO_FILE_ATTR); dest_iattr->file_flags = source_iattr->file_flags; } - + result = globus_xio_attr_copy(&dest_iattr->attr, source_iattr->attr); if(result != GLOBUS_SUCCESS) { @@ -545,7 +545,7 @@ globus_l_io_iattr_copy( } dest_iattr->space = source_iattr->space; globus_callback_space_reference(dest_iattr->space); - + *dest = dest_iattr; return GLOBUS_SUCCESS; @@ -558,10 +558,10 @@ globus_l_io_iattr_copy( gss_release_name(&minor_status, &dest_iattr->authz_data.identity); } - + error_auth_copy: globus_free(dest_iattr); - + error_alloc: *dest = GLOBUS_NULL; return result; @@ -584,9 +584,9 @@ globus_l_io_cancel_precallback( { globus_l_io_handle_t * ihandle; globus_bool_t perform_callback; - + ihandle = bounce_info->handle; - + globus_mutex_lock(&ihandle->pending_lock); { perform_callback = GLOBUS_TRUE; @@ -605,7 +605,7 @@ globus_l_io_cancel_precallback( } } globus_mutex_unlock(&ihandle->pending_lock); - + return perform_callback; } @@ -615,9 +615,9 @@ globus_l_io_cancel_kickout( void * user_arg) { globus_l_io_cancel_info_t * cancel_info; - + cancel_info = (globus_l_io_cancel_info_t *) user_arg; - + if(cancel_info->callback) { cancel_info->callback( @@ -625,7 +625,7 @@ globus_l_io_cancel_kickout( cancel_info->handle, GLOBUS_SUCCESS); } - + globus_free(cancel_info); } @@ -638,10 +638,10 @@ globus_l_io_cancel_complete( globus_l_io_cancel_info_t * cancel_info; globus_bool_t call_cancel; GlobusIOName(globus_l_io_cancel_complete); - + ihandle = bounce_info->handle; cancel_info = bounce_info->cancel_info; - + globus_mutex_lock(&ihandle->pending_lock); { if(cancel_info && --cancel_info->refs == 0) @@ -654,18 +654,18 @@ globus_l_io_cancel_complete( } } globus_mutex_unlock(&ihandle->pending_lock); - + if(call_cancel) { globus_callback_space_t space; - + if(ihandle->space != GLOBUS_CALLBACK_GLOBAL_SPACE && globus_callback_space_get(&space) == GLOBUS_SUCCESS && ( (cancel_info->blocking && space != GLOBUS_CALLBACK_GLOBAL_SPACE) || (!cancel_info->blocking && space != ihandle->space))) { globus_result_t result; - + result = globus_callback_space_register_oneshot( GLOBUS_NULL, GLOBUS_NULL, @@ -692,11 +692,11 @@ globus_l_io_cancel_complete( cancel_info->handle, GLOBUS_SUCCESS); } - + globus_free(cancel_info); } } - + /* removes reference added in cancel_insert and destroys if necessary */ globus_l_io_handle_destroy(ihandle); } @@ -707,7 +707,7 @@ globus_l_io_should_bounce( globus_l_io_bounce_t * bounce_info) { globus_callback_space_t space; - + if(bounce_info->handle->space != GLOBUS_CALLBACK_GLOBAL_SPACE && globus_callback_space_get(&space) == GLOBUS_SUCCESS && ((bounce_info->blocking && space != GLOBUS_CALLBACK_GLOBAL_SPACE) || @@ -715,18 +715,18 @@ globus_l_io_should_bounce( { return GLOBUS_TRUE; } - + return GLOBUS_FALSE; } static void globus_l_io_bounce_io_cb( - globus_xio_handle_t xio_handle, + globus_xio_handle_t xio_handle, globus_result_t result, globus_byte_t * buffer, globus_size_t len, - globus_size_t nbytes, + globus_size_t nbytes, globus_xio_data_descriptor_t data_desc, void * user_arg); @@ -737,11 +737,11 @@ globus_l_io_bounce_io_kickout( { globus_l_io_bounce_t * bounce_info; GlobusIOName(globus_l_io_bounce_io_kickout); - + bounce_info = (globus_l_io_bounce_t *) user_arg; globus_l_io_bounce_io_cb( GLOBUS_NULL, - bounce_info->error + bounce_info->error ? globus_error_put(bounce_info->error) : GLOBUS_SUCCESS, bounce_info->buffer, 0, @@ -753,24 +753,24 @@ globus_l_io_bounce_io_kickout( static void globus_l_io_bounce_io_cb( - globus_xio_handle_t xio_handle, + globus_xio_handle_t xio_handle, globus_result_t result, globus_byte_t * buffer, globus_size_t len, - globus_size_t nbytes, + globus_size_t nbytes, globus_xio_data_descriptor_t data_desc, void * user_arg) { globus_l_io_bounce_t * bounce_info; globus_l_io_handle_t * ihandle; GlobusIOName(globus_l_io_bounce_io_cb); - + bounce_info = (globus_l_io_bounce_t *) user_arg; ihandle = bounce_info->handle; - + if(globus_l_io_should_bounce(bounce_info)) { - bounce_info->error = result == GLOBUS_SUCCESS + bounce_info->error = result == GLOBUS_SUCCESS ? GLOBUS_NULL : globus_error_get(result); bounce_info->buffer = buffer; bounce_info->nbytes = nbytes; @@ -791,7 +791,7 @@ globus_l_io_bounce_io_cb( } return; } - + if(result != GLOBUS_SUCCESS) { if(globus_xio_error_is_eof(result)) @@ -811,7 +811,7 @@ globus_l_io_bounce_io_cb( ihandle->io_handle)); } } - + if(globus_l_io_cancel_precallback(bounce_info)) { bounce_info->cb.read_write( @@ -821,7 +821,7 @@ globus_l_io_bounce_io_cb( buffer, nbytes); } - + globus_l_io_cancel_complete(bounce_info); globus_free(bounce_info); } @@ -844,11 +844,11 @@ globus_l_io_bounce_iovec_kickout( { globus_l_io_bounce_t * bounce_info; GlobusIOName(globus_l_io_bounce_iovec_kickout); - + bounce_info = (globus_l_io_bounce_t *) user_arg; globus_l_io_bounce_iovec_cb( GLOBUS_NULL, - bounce_info->error + bounce_info->error ? globus_error_put(bounce_info->error) : GLOBUS_SUCCESS, bounce_info->iov, bounce_info->iovc, @@ -871,13 +871,13 @@ globus_l_io_bounce_iovec_cb( globus_l_io_bounce_t * bounce_info; globus_l_io_handle_t * ihandle; GlobusIOName(globus_l_io_bounce_iovec_cb); - + bounce_info = (globus_l_io_bounce_t *) user_arg; ihandle = bounce_info->handle; - + if(globus_l_io_should_bounce(bounce_info)) { - bounce_info->error = result == GLOBUS_SUCCESS + bounce_info->error = result == GLOBUS_SUCCESS ? GLOBUS_NULL : globus_error_get(result); bounce_info->iov = iovec; bounce_info->iovc = count; @@ -899,7 +899,7 @@ globus_l_io_bounce_iovec_cb( } return; } - + if(result != GLOBUS_SUCCESS) { if(globus_xio_error_is_eof(result)) @@ -919,7 +919,7 @@ globus_l_io_bounce_iovec_cb( ihandle->io_handle)); } } - + if(globus_l_io_cancel_precallback(bounce_info)) { bounce_info->cb.writev( @@ -930,7 +930,7 @@ globus_l_io_bounce_iovec_cb( count, nbytes); } - + globus_l_io_cancel_complete(bounce_info); globus_free(bounce_info); } @@ -949,12 +949,12 @@ globus_l_io_bounce_authz_kickout( { globus_l_io_bounce_t * bounce_info; GlobusIOName(globus_l_io_bounce_authz_kickout); - + bounce_info = (globus_l_io_bounce_t *) user_arg; - + globus_l_io_bounce_authz_cb( GLOBUS_NULL, - bounce_info->error + bounce_info->error ? globus_error_put(bounce_info->error) : GLOBUS_SUCCESS, user_arg); } @@ -975,13 +975,13 @@ globus_l_io_bounce_authz_cb( gss_ctx_id_t context; globus_bool_t perform_callback; GlobusIOName(globus_l_io_bounce_authz_cb); - + bounce_info = (globus_l_io_bounce_t *) user_arg; - + if(globus_l_io_should_bounce(bounce_info) || (handle != NULL && bounce_info->handle->attr->authz_data.callback)) { - bounce_info->error = result == GLOBUS_SUCCESS + bounce_info->error = result == GLOBUS_SUCCESS ? GLOBUS_NULL : globus_error_get(result); result = globus_callback_space_register_oneshot( GLOBUS_NULL, @@ -1001,12 +1001,12 @@ globus_l_io_bounce_authz_cb( } return; } - + ihandle = bounce_info->handle; perform_callback = globus_l_io_cancel_precallback(bounce_info); - + if(result != GLOBUS_SUCCESS) - { + { if(globus_xio_error_is_eof(result)) { result = globus_error_put( @@ -1023,7 +1023,7 @@ globus_l_io_bounce_authz_cb( globus_error_get(result), ihandle->io_handle)); } - else + else { globus_object_t * error = globus_error_get(result); if(globus_error_gssapi_match(error, @@ -1033,7 +1033,7 @@ globus_l_io_bounce_authz_cb( globus_l_io_gsi_driver, error, GLOBUS_XIO_GSI_AUTHORIZATION_FAILED)) - { + { result = globus_error_put( globus_io_error_construct_authorization_failed( GLOBUS_IO_MODULE, @@ -1063,24 +1063,24 @@ globus_l_io_bounce_authz_cb( { result = globus_error_put(error); } - } + } goto done; } if(ihandle->attr->authorization_mode == GLOBUS_IO_SECURE_AUTHORIZATION_MODE_CALLBACK) - { + { result = globus_xio_handle_cntl( ihandle->xio_handle, globus_l_io_gsi_driver, GLOBUS_XIO_GSI_GET_PEER_NAME, &peer_identity); - + if(result != GLOBUS_SUCCESS) { goto done; } - + result = globus_xio_handle_cntl( ihandle->xio_handle, globus_l_io_gsi_driver, @@ -1104,7 +1104,7 @@ globus_l_io_bounce_authz_cb( minor_status); goto done; } - + if(!perform_callback || !ihandle->attr->authz_data.callback( ihandle->attr->authz_data.callback_arg, ihandle->io_handle, @@ -1119,21 +1119,21 @@ globus_l_io_bounce_authz_cb( ihandle->io_handle, 0, 0, - 0)); + 0)); } free(peer_name_buffer.value); } - + done: - + if(result != GLOBUS_SUCCESS) { globus_xio_close(ihandle->xio_handle, GLOBUS_NULL); ihandle->xio_handle = GLOBUS_NULL; *ihandle->io_handle = GLOBUS_NULL; } - + if(perform_callback) { bounce_info->cb.non_io( @@ -1141,10 +1141,10 @@ globus_l_io_bounce_authz_cb( ihandle->io_handle, result); } - + globus_l_io_cancel_complete(bounce_info); globus_free(bounce_info); - + if(result != GLOBUS_SUCCESS) { globus_l_io_handle_destroy(ihandle); @@ -1166,13 +1166,13 @@ globus_l_io_bounce_listen_kickout( { globus_l_io_bounce_t * bounce_info; GlobusIOName(globus_l_io_bounce_authz_kickout); - + bounce_info = (globus_l_io_bounce_t *) user_arg; - + globus_l_io_bounce_listen_cb( GLOBUS_NULL, bounce_info->handle->accepted_handle, - bounce_info->error + bounce_info->error ? globus_error_put(bounce_info->error) : GLOBUS_SUCCESS, user_arg); } @@ -1188,14 +1188,14 @@ globus_l_io_bounce_listen_cb( globus_l_io_bounce_t * bounce_info; globus_l_io_handle_t * ihandle; GlobusIOName(globus_l_io_bounce_listen_cb); - + bounce_info = (globus_l_io_bounce_t *) user_arg; ihandle = bounce_info->handle; ihandle->accepted_handle = handle; - + if(globus_l_io_should_bounce(bounce_info)) { - bounce_info->error = result == GLOBUS_SUCCESS + bounce_info->error = result == GLOBUS_SUCCESS ? GLOBUS_NULL : globus_error_get(result); result = globus_callback_space_register_oneshot( GLOBUS_NULL, @@ -1215,7 +1215,7 @@ globus_l_io_bounce_listen_cb( } return; } - + if(globus_l_io_cancel_precallback(bounce_info)) { if(result != GLOBUS_SUCCESS && globus_xio_error_is_canceled(result)) @@ -1226,7 +1226,7 @@ globus_l_io_bounce_listen_cb( globus_error_get(result), ihandle->io_handle)); } - + bounce_info->cb.non_io( bounce_info->user_arg, ihandle->io_handle, @@ -1246,9 +1246,9 @@ globus_l_io_blocking_cb( { globus_l_io_monitor_t * monitor; GlobusIOName(globus_l_io_blocking_cb); - + monitor = (globus_l_io_monitor_t *) user_arg; - + globus_mutex_lock(&monitor->lock); { monitor->done = GLOBUS_TRUE; @@ -1264,13 +1264,13 @@ globus_io_attr_set_callback_space( globus_callback_space_t space) { GlobusIOName(globus_io_attr_set_callback_space); - + GlobusLIOCheckAttr(attr, GLOBUS_I_IO_FILE_ATTR | GLOBUS_I_IO_TCP_ATTR); - + globus_callback_space_destroy((*attr)->space); globus_callback_space_reference(space); (*attr)->space = space; - + return GLOBUS_SUCCESS; } @@ -1280,10 +1280,10 @@ globus_io_attr_get_callback_space( globus_callback_space_t * space) { GlobusIOName(globus_io_attr_get_callback_space); - + GlobusLIOCheckAttr(attr, GLOBUS_I_IO_FILE_ATTR | GLOBUS_I_IO_TCP_ATTR); GlobusLIOCheckNullParam(space); - + *space = (*attr)->space; return GLOBUS_SUCCESS; } @@ -1297,32 +1297,32 @@ globus_io_fileattr_init( globus_l_io_attr_t * iattr; globus_result_t result; GlobusIOName(globus_io_fileattr_init); - + GlobusLIOCheckNullParam(attr); - + result = GlobusLIOMalloc(iattr, globus_l_io_attr_t); if(result != GLOBUS_SUCCESS) { goto error_alloc; } - + iattr->type = GLOBUS_I_IO_FILE_ATTR; iattr->space = GLOBUS_CALLBACK_GLOBAL_SPACE; - + result = globus_xio_attr_init(&iattr->attr); if(result != GLOBUS_SUCCESS) { goto error_attr; } - + iattr->file_flags = GLOBUS_IO_FILE_TYPE_BINARY; *attr = iattr; - + return GLOBUS_SUCCESS; error_attr: globus_free(iattr); - + error_alloc: *attr = GLOBUS_NULL; return result; @@ -1334,11 +1334,11 @@ globus_io_fileattr_destroy( { globus_l_io_attr_t * iattr; GlobusIOName(globus_io_fileattr_destroy); - + GlobusLIOCheckAttr(attr, GLOBUS_I_IO_FILE_ATTR); - + iattr = (globus_l_io_attr_t *) *attr; - + globus_callback_space_destroy(iattr->space); globus_xio_attr_destroy(iattr->attr); if(iattr->stack) @@ -1347,7 +1347,7 @@ globus_io_fileattr_destroy( } globus_free(iattr); *attr = GLOBUS_NULL; - + return GLOBUS_SUCCESS; } @@ -1357,11 +1357,11 @@ globus_io_attr_set_file_type( globus_io_file_type_t file_type) { GlobusIOName(globus_io_attr_set_file_type); - + GlobusLIOCheckAttr(attr, GLOBUS_I_IO_FILE_ATTR); - + (*attr)->file_flags = file_type; - + return GLOBUS_SUCCESS; } @@ -1371,11 +1371,11 @@ globus_io_attr_get_file_type( globus_io_file_type_t * file_type) { GlobusIOName(globus_io_attr_get_file_type); - + GlobusLIOCheckAttr(attr, GLOBUS_I_IO_FILE_ATTR); - + *file_type = (*attr)->file_flags; - + return GLOBUS_SUCCESS; } @@ -1388,15 +1388,15 @@ globus_io_tcpattr_init( globus_l_io_attr_t * iattr; globus_result_t result; GlobusIOName(globus_io_tcpattr_init); - + GlobusLIOCheckNullParam(attr); - + result = GlobusLIOMalloc(iattr, globus_l_io_attr_t); if(result != GLOBUS_SUCCESS) { goto error_alloc; } - + iattr->type = GLOBUS_I_IO_TCP_ATTR; iattr->space = GLOBUS_CALLBACK_GLOBAL_SPACE; iattr->file_flags = 0; @@ -1412,8 +1412,8 @@ globus_io_tcpattr_init( } result = globus_xio_attr_cntl( - iattr->attr, - globus_l_io_gsi_driver, + iattr->attr, + globus_l_io_gsi_driver, GLOBUS_XIO_GSI_SET_PROTECTION_LEVEL, GLOBUS_XIO_GSI_PROTECTION_LEVEL_NONE); @@ -1421,17 +1421,17 @@ globus_io_tcpattr_init( { goto error_xio_attr; } - + *attr = iattr; - + return GLOBUS_SUCCESS; error_xio_attr: globus_xio_attr_destroy(iattr->attr); - + error_attr: globus_free(iattr); - + error_alloc: *attr = GLOBUS_NULL; return result; @@ -1443,18 +1443,18 @@ globus_io_tcpattr_destroy( { globus_l_io_attr_t * iattr; GlobusIOName(globus_io_tcpattr_destroy); - + GlobusLIOCheckAttr(attr, GLOBUS_I_IO_TCP_ATTR); - + iattr = (globus_l_io_attr_t *) *attr; - + if(iattr->authz_data.identity != GSS_C_NO_NAME) { OM_uint32 minor_status; gss_release_name(&minor_status, &iattr->authz_data.identity); } - + globus_callback_space_destroy(iattr->space); globus_xio_attr_destroy(iattr->attr); if(iattr->stack) @@ -1463,7 +1463,7 @@ globus_io_tcpattr_destroy( } globus_free(iattr); *attr = GLOBUS_NULL; - + return GLOBUS_SUCCESS; } @@ -1473,13 +1473,13 @@ globus_io_attr_set_tcp_restrict_port( globus_bool_t restrict_port) { GlobusIOName(globus_io_attr_set_tcp_restrict_port); - + GlobusLIOCheckAttr(attr, GLOBUS_I_IO_TCP_ATTR); - + return globus_xio_attr_cntl( - (*attr)->attr, - globus_l_io_tcp_driver, - GLOBUS_XIO_TCP_SET_RESTRICT_PORT, + (*attr)->attr, + globus_l_io_tcp_driver, + GLOBUS_XIO_TCP_SET_RESTRICT_PORT, restrict_port); } @@ -1489,13 +1489,13 @@ globus_io_attr_get_tcp_restrict_port( globus_bool_t * restrict_port) { GlobusIOName(globus_io_attr_get_tcp_restrict_port); - + GlobusLIOCheckAttr(attr, GLOBUS_I_IO_TCP_ATTR); - + return globus_xio_attr_cntl( - (*attr)->attr, - globus_l_io_tcp_driver, - GLOBUS_XIO_TCP_GET_RESTRICT_PORT, + (*attr)->attr, + globus_l_io_tcp_driver, + GLOBUS_XIO_TCP_GET_RESTRICT_PORT, restrict_port); } @@ -1505,13 +1505,13 @@ globus_io_attr_set_tcp_nodelay( globus_bool_t nodelay) { GlobusIOName(globus_io_attr_set_tcp_nodelay); - + GlobusLIOCheckAttr(attr, GLOBUS_I_IO_TCP_ATTR); - + return globus_xio_attr_cntl( - (*attr)->attr, - globus_l_io_tcp_driver, - GLOBUS_XIO_TCP_SET_NODELAY, + (*attr)->attr, + globus_l_io_tcp_driver, + GLOBUS_XIO_TCP_SET_NODELAY, nodelay); } @@ -1521,13 +1521,13 @@ globus_io_attr_get_tcp_nodelay( globus_bool_t * nodelay) { GlobusIOName(globus_io_attr_get_tcp_nodelay); - + GlobusLIOCheckAttr(attr, GLOBUS_I_IO_TCP_ATTR); - + return globus_xio_attr_cntl( - (*attr)->attr, - globus_l_io_tcp_driver, - GLOBUS_XIO_TCP_GET_NODELAY, + (*attr)->attr, + globus_l_io_tcp_driver, + GLOBUS_XIO_TCP_GET_NODELAY, nodelay); } @@ -1537,13 +1537,13 @@ globus_io_attr_set_tcp_interface( const char * interface_addr) { GlobusIOName(globus_io_attr_set_tcp_interface); - + GlobusLIOCheckAttr(attr, GLOBUS_I_IO_TCP_ATTR); - + return globus_xio_attr_cntl( - (*attr)->attr, - globus_l_io_tcp_driver, - GLOBUS_XIO_TCP_SET_INTERFACE, + (*attr)->attr, + globus_l_io_tcp_driver, + GLOBUS_XIO_TCP_SET_INTERFACE, interface_addr); } @@ -1553,13 +1553,13 @@ globus_io_attr_get_tcp_interface( char ** interface_addr) { GlobusIOName(globus_io_attr_get_tcp_interface); - + GlobusLIOCheckAttr(attr, GLOBUS_I_IO_TCP_ATTR); - + return globus_xio_attr_cntl( - (*attr)->attr, - globus_l_io_tcp_driver, - GLOBUS_XIO_TCP_GET_INTERFACE, + (*attr)->attr, + globus_l_io_tcp_driver, + GLOBUS_XIO_TCP_GET_INTERFACE, interface_addr); } @@ -1570,9 +1570,9 @@ globus_io_attr_set_tcp_allow_ipv6( { globus_l_io_attr_t * iattr; GlobusIOName(globus_io_attr_set_tcp_allow_ipv6); - + GlobusLIOCheckAttr(attr, GLOBUS_I_IO_TCP_ATTR); - + iattr = (globus_l_io_attr_t *) *attr; iattr->allow_ipv6 = allow; @@ -1586,12 +1586,12 @@ globus_io_attr_set_socket_reuseaddr( globus_bool_t reuseaddr) { GlobusIOName(globus_io_attr_set_socket_reuseaddr); - + GlobusLIOCheckAttr(attr, GLOBUS_I_IO_TCP_ATTR); - + return globus_xio_attr_cntl( - (*attr)->attr, - globus_l_io_tcp_driver, + (*attr)->attr, + globus_l_io_tcp_driver, GLOBUS_XIO_TCP_SET_REUSEADDR, reuseaddr); } @@ -1602,12 +1602,12 @@ globus_io_attr_get_socket_reuseaddr( globus_bool_t * reuseaddr) { GlobusIOName(globus_io_attr_get_socket_reuseaddr); - + GlobusLIOCheckAttr(attr, GLOBUS_I_IO_TCP_ATTR); return globus_xio_attr_cntl( - (*attr)->attr, - globus_l_io_tcp_driver, + (*attr)->attr, + globus_l_io_tcp_driver, GLOBUS_XIO_TCP_GET_REUSEADDR, reuseaddr); } @@ -1618,13 +1618,13 @@ globus_io_attr_set_socket_keepalive( globus_bool_t keepalive) { GlobusIOName(globus_io_attr_set_socket_keepalive); - + GlobusLIOCheckAttr(attr, GLOBUS_I_IO_TCP_ATTR); - + return globus_xio_attr_cntl( - (*attr)->attr, - globus_l_io_tcp_driver, - GLOBUS_XIO_TCP_SET_KEEPALIVE, + (*attr)->attr, + globus_l_io_tcp_driver, + GLOBUS_XIO_TCP_SET_KEEPALIVE, keepalive); } @@ -1634,13 +1634,13 @@ globus_io_attr_get_socket_keepalive( globus_bool_t * keepalive) { GlobusIOName(globus_io_attr_get_socket_keepalive); - + GlobusLIOCheckAttr(attr, GLOBUS_I_IO_TCP_ATTR); - + return globus_xio_attr_cntl( - (*attr)->attr, - globus_l_io_tcp_driver, - GLOBUS_XIO_TCP_GET_KEEPALIVE, + (*attr)->attr, + globus_l_io_tcp_driver, + GLOBUS_XIO_TCP_GET_KEEPALIVE, keepalive); } @@ -1651,12 +1651,12 @@ globus_io_attr_set_socket_linger( int linger_time) { GlobusIOName(globus_io_attr_set_socket_linger); - + GlobusLIOCheckAttr(attr, GLOBUS_I_IO_TCP_ATTR); return globus_xio_attr_cntl( - (*attr)->attr, - globus_l_io_tcp_driver, + (*attr)->attr, + globus_l_io_tcp_driver, GLOBUS_XIO_TCP_SET_LINGER, linger, linger_time); @@ -1669,12 +1669,12 @@ globus_io_attr_get_socket_linger( int * linger_time) { GlobusIOName(globus_io_attr_get_socket_linger); - + GlobusLIOCheckAttr(attr, GLOBUS_I_IO_TCP_ATTR); - + return globus_xio_attr_cntl( - (*attr)->attr, - globus_l_io_tcp_driver, + (*attr)->attr, + globus_l_io_tcp_driver, GLOBUS_XIO_TCP_GET_LINGER, linger, linger_time); @@ -1686,12 +1686,12 @@ globus_io_attr_set_socket_oobinline( globus_bool_t oobinline) { GlobusIOName(globus_io_attr_set_socket_oobinline); - + GlobusLIOCheckAttr(attr, GLOBUS_I_IO_TCP_ATTR); - + return globus_xio_attr_cntl( - (*attr)->attr, - globus_l_io_tcp_driver, + (*attr)->attr, + globus_l_io_tcp_driver, GLOBUS_XIO_TCP_SET_OOBINLINE, oobinline); } @@ -1702,13 +1702,13 @@ globus_io_attr_get_socket_oobinline( globus_bool_t * oobinline) { GlobusIOName(globus_io_attr_get_socket_oobinline); - + GlobusLIOCheckAttr(attr, GLOBUS_I_IO_TCP_ATTR); - + return globus_xio_attr_cntl( - (*attr)->attr, - globus_l_io_tcp_driver, - GLOBUS_XIO_TCP_GET_OOBINLINE, + (*attr)->attr, + globus_l_io_tcp_driver, + GLOBUS_XIO_TCP_GET_OOBINLINE, oobinline); } @@ -1718,12 +1718,12 @@ globus_io_attr_set_socket_sndbuf( int sndbuf) { GlobusIOName(globus_io_attr_set_socket_sndbuf); - + GlobusLIOCheckAttr(attr, GLOBUS_I_IO_TCP_ATTR); - + return globus_xio_attr_cntl( - (*attr)->attr, - globus_l_io_tcp_driver, + (*attr)->attr, + globus_l_io_tcp_driver, GLOBUS_XIO_TCP_SET_SNDBUF, sndbuf); } @@ -1734,12 +1734,12 @@ globus_io_attr_get_socket_sndbuf( int * sndbuf) { GlobusIOName(globus_io_attr_get_socket_sndbuf); - + GlobusLIOCheckAttr(attr, GLOBUS_I_IO_TCP_ATTR); - + return globus_xio_attr_cntl( - (*attr)->attr, - globus_l_io_tcp_driver, + (*attr)->attr, + globus_l_io_tcp_driver, GLOBUS_XIO_TCP_GET_SNDBUF, sndbuf); } @@ -1750,12 +1750,12 @@ globus_io_attr_set_socket_rcvbuf( int rcvbuf) { GlobusIOName(globus_io_attr_set_socket_rcvbuf); - + GlobusLIOCheckAttr(attr, GLOBUS_I_IO_TCP_ATTR); - + return globus_xio_attr_cntl( - (*attr)->attr, - globus_l_io_tcp_driver, + (*attr)->attr, + globus_l_io_tcp_driver, GLOBUS_XIO_TCP_SET_RCVBUF, rcvbuf); } @@ -1766,12 +1766,12 @@ globus_io_attr_get_socket_rcvbuf( int * rcvbuf) { GlobusIOName(globus_io_attr_get_socket_rcvbuf); - + GlobusLIOCheckAttr(attr, GLOBUS_I_IO_TCP_ATTR); - + return globus_xio_attr_cntl( - (*attr)->attr, - globus_l_io_tcp_driver, + (*attr)->attr, + globus_l_io_tcp_driver, GLOBUS_XIO_TCP_GET_RCVBUF, rcvbuf); } @@ -1784,7 +1784,7 @@ globus_io_handle_get_socket_buf( { globus_result_t res = GLOBUS_SUCCESS; GlobusIOName(globus_io_handle_get_socket_buf); - + GlobusLIOCheckHandle(handle, GLOBUS_I_IO_TCP_HANDLE); if(rcvbuf != NULL) @@ -1835,10 +1835,10 @@ globus_l_io_file_open( globus_l_io_attr_t * iattr; globus_l_io_handle_t * ihandle; GlobusIOName(globus_l_io_file_open); - + GlobusLIOCheckNullParam(handle); *handle = GLOBUS_NULL; - + if(attr) { GlobusLIOCheckAttr(attr, GLOBUS_I_IO_FILE_ATTR); @@ -1853,7 +1853,7 @@ globus_l_io_file_open( goto error_attr; } iattr = (globus_l_io_attr_t *) myattr; - + if(path) { result = globus_xio_attr_cntl( @@ -1865,7 +1865,7 @@ globus_l_io_file_open( { goto error_cntl; } - + result = globus_xio_attr_cntl( iattr->attr, globus_l_io_file_driver, @@ -1902,21 +1902,21 @@ globus_l_io_file_open( goto error_cntl; } } - + result = globus_l_io_handle_init( &ihandle, handle, GLOBUS_I_IO_FILE_HANDLE, iattr->space); if(result != GLOBUS_SUCCESS) { goto error_alloc; } - + result = globus_xio_handle_create( &ihandle->xio_handle, globus_l_io_file_stack); if(result != GLOBUS_SUCCESS) { goto error_handle; } - + result = globus_xio_open( ihandle->xio_handle, path, @@ -1925,10 +1925,10 @@ globus_l_io_file_open( { goto error_open; } - + *handle = ihandle; globus_io_fileattr_destroy(&myattr); - + return GLOBUS_SUCCESS; error_open: @@ -1951,9 +1951,9 @@ globus_io_file_open( globus_io_handle_t * handle) { GlobusIOName(globus_io_file_open); - + GlobusLIOCheckNullParam(path); - + return globus_l_io_file_open(handle, attr, path, flags, mode, -1, 0); } @@ -1964,9 +1964,9 @@ globus_io_file_seek( globus_io_whence_t whence) { GlobusIOName(globus_io_file_seek); - + GlobusLIOCheckHandle(handle, GLOBUS_I_IO_FILE_HANDLE); - + return globus_xio_handle_cntl( (*handle)->xio_handle, globus_l_io_file_driver, @@ -1982,7 +1982,7 @@ globus_io_file_posix_convert( globus_io_handle_t * handle) { GlobusIOName(globus_io_file_posix_convert); - + return globus_l_io_file_open( handle, attr, @@ -2001,7 +2001,7 @@ globus_io_file_windows_convert( globus_io_handle_t * handle) { GlobusIOName(globus_io_file_posix_convert); - + return globus_l_io_file_open( handle, attr, @@ -2064,21 +2064,21 @@ globus_l_io_tcp_register_connect( globus_xio_stack_t stack; char * cs = GLOBUS_NULL; GlobusIOName(globus_l_io_tcp_register_connect); - + GlobusLIOCheckNullParam(handle); GlobusLIOCheckNullParam(callback); - + if(attr) { GlobusLIOCheckAttr(attr, GLOBUS_I_IO_TCP_ATTR); } - + result = GlobusLIOMalloc(bounce_info, globus_l_io_bounce_t); if(result != GLOBUS_SUCCESS) { goto error_bounce; } - + result = globus_l_io_handle_init( &ihandle, handle, GLOBUS_I_IO_TCP_HANDLE, attr ? (*attr)->space : GLOBUS_CALLBACK_GLOBAL_SPACE); @@ -2116,7 +2116,7 @@ globus_l_io_tcp_register_connect( goto error_attr; } } - + if(!ihandle->attr->allow_ipv6) { result = globus_xio_attr_cntl( @@ -2129,7 +2129,7 @@ globus_l_io_tcp_register_connect( goto error_attr; } } - + result = globus_xio_attr_cntl( ihandle->attr->attr, GLOBUS_NULL, @@ -2141,7 +2141,7 @@ globus_l_io_tcp_register_connect( { goto error_attr; } - + if(host) { if(strchr(host, ':')) @@ -2166,7 +2166,7 @@ globus_l_io_tcp_register_connect( goto error_attr; } } - + result = globus_xio_handle_create(&ihandle->xio_handle, stack); if(result != GLOBUS_SUCCESS) { @@ -2179,7 +2179,7 @@ globus_l_io_tcp_register_connect( bounce_info->blocking = blocking; bounce_info->cancel_info = GLOBUS_NULL; *handle = ihandle; - + globus_mutex_lock(&ihandle->pending_lock); { result = globus_xio_register_open( @@ -2193,11 +2193,11 @@ globus_l_io_tcp_register_connect( globus_mutex_unlock(&ihandle->pending_lock); goto error_open; } - + globus_l_io_cancel_insert(bounce_info); } globus_mutex_unlock(&ihandle->pending_lock); - + return GLOBUS_SUCCESS; error_open: @@ -2222,9 +2222,9 @@ globus_io_tcp_register_connect( globus_io_handle_t * handle) { GlobusIOName(globus_io_tcp_register_connect); - + GlobusLIOCheckNullParam(host); - + return globus_l_io_tcp_register_connect( host, port, @@ -2248,11 +2248,11 @@ globus_l_io_tcp_connect( globus_result_t result; globus_l_io_monitor_t monitor; GlobusIOName(globus_l_io_tcp_connect); - + monitor.done = GLOBUS_FALSE; globus_mutex_init(&monitor.lock, GLOBUS_NULL); globus_cond_init(&monitor.cond, GLOBUS_NULL); - + result = globus_l_io_tcp_register_connect( host, port, @@ -2267,7 +2267,7 @@ globus_l_io_tcp_connect( monitor.done = GLOBUS_TRUE; monitor.error = globus_error_get(result); } - + globus_mutex_lock(&monitor.lock); { while(!monitor.done) @@ -2276,18 +2276,18 @@ globus_l_io_tcp_connect( } } globus_mutex_unlock(&monitor.lock); - + globus_mutex_destroy(&monitor.lock); globus_cond_destroy(&monitor.cond); - + if(monitor.error != GLOBUS_NULL) { result = globus_error_put(monitor.error); goto error_register; } - + return GLOBUS_SUCCESS; - + error_register: *handle = GLOBUS_NULL; return result; @@ -2301,9 +2301,9 @@ globus_io_tcp_connect( globus_io_handle_t * handle) { GlobusIOName(globus_io_tcp_connect); - + GlobusLIOCheckNullParam(host); - + return globus_l_io_tcp_connect(host, port, -1, attr, handle); } @@ -2322,9 +2322,9 @@ globus_l_io_tcp_create_listener( globus_l_io_handle_t * ihandle; globus_xio_stack_t stack; GlobusIOName(globus_l_io_tcp_create_listener); - + GlobusLIOCheckNullParam(handle); - + if(attr) { GlobusLIOCheckAttr(attr, GLOBUS_I_IO_TCP_ATTR); @@ -2334,12 +2334,12 @@ globus_l_io_tcp_create_listener( { result = globus_io_tcpattr_init(&myattr); } - + if(result != GLOBUS_SUCCESS) { goto error_attr; } - + iattr = (globus_l_io_attr_t *) myattr; if(port) { @@ -2352,7 +2352,7 @@ globus_l_io_tcp_create_listener( { goto error_cntl; } - + result = globus_xio_attr_cntl( iattr->attr, globus_l_io_tcp_driver, @@ -2371,7 +2371,7 @@ globus_l_io_tcp_create_listener( { goto error_cntl; } - + if(!iattr->allow_ipv6) { result = globus_xio_attr_cntl( @@ -2384,7 +2384,7 @@ globus_l_io_tcp_create_listener( goto error_cntl; } } - + result = globus_l_io_handle_init( &ihandle, handle, GLOBUS_I_IO_TCP_HANDLE, iattr->space); if(result != GLOBUS_SUCCESS) @@ -2395,7 +2395,7 @@ globus_l_io_tcp_create_listener( if(iattr->stack != NULL) { stack = iattr->stack; - } + } else if(iattr->authentication_mode == GLOBUS_IO_SECURE_AUTHENTICATION_MODE_NONE) { @@ -2405,48 +2405,48 @@ globus_l_io_tcp_create_listener( { stack = globus_l_io_gsi_stack; } - + result = globus_xio_server_create( &ihandle->xio_server, iattr->attr, stack); if(result != GLOBUS_SUCCESS) { goto error_server; } - + if(port && !*port) { char * contact_string; char * s; - + result = globus_xio_server_get_contact_string( ihandle->xio_server, &contact_string); if(result != GLOBUS_SUCCESS) { goto error_server_cntl; } - + s = strrchr(contact_string, ':'); globus_assert(s); *port = atoi(s + 1); - + globus_free(contact_string); } - + ihandle->attr = iattr; *handle = ihandle; - + return GLOBUS_SUCCESS; error_server_cntl: globus_xio_server_close(ihandle->xio_server); - + error_server: globus_l_io_handle_destroy(ihandle); - + error_alloc: error_cntl: globus_io_tcpattr_destroy(&myattr); - + error_attr: *handle = GLOBUS_NULL; return result; @@ -2460,9 +2460,9 @@ globus_io_tcp_create_listener( globus_io_handle_t * handle) { GlobusIOName(globus_io_tcp_create_listener); - + GlobusLIOCheckNullParam(port); - + return globus_l_io_tcp_create_listener( port, backlog, -1, attr, handle); } @@ -2479,10 +2479,10 @@ globus_l_io_tcp_register_listen( globus_l_io_handle_t * ihandle; globus_l_io_bounce_t * bounce_info; GlobusIOName(globus_l_io_tcp_register_listen); - + GlobusLIOCheckNullParam(callback); GlobusLIOCheckHandle(handle, GLOBUS_I_IO_TCP_HANDLE); - + ihandle = *handle; if(ihandle->accepted_handle) { @@ -2492,22 +2492,22 @@ globus_l_io_tcp_register_listen( GLOBUS_IO_MODULE, GLOBUS_NULL, ihandle->io_handle)); - + goto error_registered; } - + result = GlobusLIOMalloc(bounce_info, globus_l_io_bounce_t); if(result != GLOBUS_SUCCESS) { goto error_bounce; } - + bounce_info->handle = ihandle; bounce_info->cb.non_io = callback; bounce_info->user_arg = callback_arg; bounce_info->blocking = blocking; bounce_info->cancel_info = GLOBUS_NULL; - + globus_mutex_lock(&ihandle->pending_lock); { result = globus_xio_server_register_accept( @@ -2519,16 +2519,16 @@ globus_l_io_tcp_register_listen( globus_mutex_unlock(&ihandle->pending_lock); goto error_register; } - + globus_l_io_cancel_insert(bounce_info); } globus_mutex_unlock(&ihandle->pending_lock); - + return GLOBUS_SUCCESS; error_register: globus_free(bounce_info); - + error_bounce: error_registered: return result; @@ -2551,11 +2551,11 @@ globus_io_tcp_listen( globus_result_t result; globus_l_io_monitor_t monitor; GlobusIOName(globus_io_tcp_listen); - + monitor.done = GLOBUS_FALSE; globus_mutex_init(&monitor.lock, GLOBUS_NULL); globus_cond_init(&monitor.cond, GLOBUS_NULL); - + result = globus_l_io_tcp_register_listen( handle, globus_l_io_blocking_cb, &monitor, GLOBUS_TRUE); if(result != GLOBUS_SUCCESS) @@ -2563,7 +2563,7 @@ globus_io_tcp_listen( monitor.done = GLOBUS_TRUE; monitor.error = globus_error_get(result); } - + globus_mutex_lock(&monitor.lock); { while(!monitor.done) @@ -2572,18 +2572,18 @@ globus_io_tcp_listen( } } globus_mutex_unlock(&monitor.lock); - + globus_mutex_destroy(&monitor.lock); globus_cond_destroy(&monitor.cond); - + if(monitor.error != GLOBUS_NULL) { result = globus_error_put(monitor.error); goto error_register; } - + return GLOBUS_SUCCESS; - + error_register: return result; } @@ -2609,11 +2609,11 @@ globus_l_io_tcp_register_accept( globus_l_io_bounce_t * bounce_info; char * contact_string = GLOBUS_NULL; GlobusIOName(globus_io_tcp_register_accept); - + GlobusLIOCheckNullParam(new_handle); GlobusLIOCheckNullParam(callback); GlobusLIOCheckHandle(listener_handle, GLOBUS_I_IO_TCP_HANDLE); - + ilistener_handle = *listener_handle; if(!ilistener_handle->accepted_handle) { @@ -2624,15 +2624,15 @@ globus_l_io_tcp_register_accept( "listener_handle", 1, (char *) _io_name)); - + goto error_handle; } - + if(attr) { GlobusLIOCheckAttr(attr, GLOBUS_I_IO_TCP_ATTR); } - + result = globus_l_io_handle_init( &ihandle, new_handle, GLOBUS_I_IO_TCP_HANDLE, attr ? (*attr)->space : ilistener_handle->space); @@ -2640,20 +2640,20 @@ globus_l_io_tcp_register_accept( { goto error_handle; } - + result = GlobusLIOMalloc(bounce_info, globus_l_io_bounce_t); if(result != GLOBUS_SUCCESS) { goto error_bounce; } - + bounce_info->handle = ihandle; bounce_info->cb.non_io = callback; bounce_info->user_arg = callback_arg; bounce_info->blocking = blocking; bounce_info->cancel_info = GLOBUS_NULL; *new_handle = ihandle; - + if(attr) { result = globus_l_io_iattr_copy(&ihandle->attr, attr); @@ -2661,12 +2661,12 @@ globus_l_io_tcp_register_accept( { goto error_gsi; } - - if((ilistener_handle->attr->authentication_mode == + + if((ilistener_handle->attr->authentication_mode == GLOBUS_IO_SECURE_AUTHENTICATION_MODE_NONE || - ihandle->attr->authentication_mode == + ihandle->attr->authentication_mode == GLOBUS_IO_SECURE_AUTHENTICATION_MODE_NONE) && - ilistener_handle->attr->authentication_mode != + ilistener_handle->attr->authentication_mode != ihandle->attr->authentication_mode) { result = globus_error_put( @@ -2693,7 +2693,7 @@ globus_l_io_tcp_register_accept( goto error_gsi; } } - + ihandle->xio_handle = ilistener_handle->accepted_handle; ilistener_handle->accepted_handle = GLOBUS_NULL; @@ -2708,7 +2708,7 @@ globus_l_io_tcp_register_accept( { goto error_gsi; } - + globus_mutex_lock(&ihandle->pending_lock); { result = globus_xio_register_open( @@ -2719,20 +2719,20 @@ globus_l_io_tcp_register_accept( bounce_info); if(contact_string != GLOBUS_NULL) - { + { globus_free(contact_string); } - + if(result != GLOBUS_SUCCESS) { globus_mutex_unlock(&ihandle->pending_lock); goto error_open; } - + globus_l_io_cancel_insert(bounce_info); } globus_mutex_unlock(&ihandle->pending_lock); - + return GLOBUS_SUCCESS; error_open: @@ -2772,11 +2772,11 @@ globus_io_tcp_accept( globus_result_t result; globus_l_io_monitor_t monitor; GlobusIOName(globus_io_tcp_accept); - + monitor.done = GLOBUS_FALSE; globus_mutex_init(&monitor.lock, GLOBUS_NULL); globus_cond_init(&monitor.cond, GLOBUS_NULL); - + result = globus_l_io_tcp_register_accept( listener_handle, attr, @@ -2789,7 +2789,7 @@ globus_io_tcp_accept( monitor.done = GLOBUS_TRUE; monitor.error = globus_error_get(result); } - + globus_mutex_lock(&monitor.lock); { while(!monitor.done) @@ -2798,18 +2798,18 @@ globus_io_tcp_accept( } } globus_mutex_unlock(&monitor.lock); - + globus_mutex_destroy(&monitor.lock); globus_cond_destroy(&monitor.cond); - + if(monitor.error != GLOBUS_NULL) { result = globus_error_put(monitor.error); goto error_register; } - + return GLOBUS_SUCCESS; - + error_register: return result; } @@ -2827,12 +2827,12 @@ globus_io_tcp_get_local_address_ex( globus_result_t result; char * cs; GlobusIOName(globus_io_tcp_get_local_address_ex); - + GlobusLIOCheckNullParam(host); GlobusLIOCheckNullParam(count); GlobusLIOCheckNullParam(port); GlobusLIOCheckHandle(handle, GLOBUS_I_IO_TCP_HANDLE); - + if((*handle)->xio_handle) { result = globus_xio_handle_cntl( @@ -2853,20 +2853,20 @@ globus_io_tcp_get_local_address_ex( { goto error_cntl; } - + result = globus_libc_contact_string_to_ints(cs, host, count, port); if(result != GLOBUS_SUCCESS) { goto error_parse; } - + globus_free(cs); - + return GLOBUS_SUCCESS; error_parse: globus_free(cs); - + error_cntl: return result; } @@ -2881,12 +2881,12 @@ globus_io_tcp_get_remote_address_ex( globus_result_t result; char * cs; GlobusIOName(globus_io_tcp_get_remote_address_ex); - + GlobusLIOCheckNullParam(host); GlobusLIOCheckNullParam(count); GlobusLIOCheckNullParam(port); GlobusLIOCheckHandle(handle, GLOBUS_I_IO_TCP_HANDLE); - + if((*handle)->xio_handle) { result = globus_xio_handle_cntl( @@ -2907,20 +2907,20 @@ globus_io_tcp_get_remote_address_ex( { goto error_cntl; } - + result = globus_libc_contact_string_to_ints(cs, host, count, port); if(result != GLOBUS_SUCCESS) { goto error_parse; } - + globus_free(cs); - + return GLOBUS_SUCCESS; error_parse: globus_free(cs); - + error_cntl: return result; } @@ -2935,17 +2935,17 @@ globus_io_tcp_get_local_address( int count; globus_result_t result; GlobusIOName(globus_io_tcp_get_local_address); - + GlobusLIOCheckNullParam(host); GlobusLIOCheckNullParam(port); GlobusLIOCheckHandle(handle, GLOBUS_I_IO_TCP_HANDLE); - + result = globus_io_tcp_get_local_address_ex(handle, myhost, &count, port); if(result != GLOBUS_SUCCESS) { goto error_cntl; } - + if(count != 4) { /* interface doesnt support ipv6 addresses */ @@ -2954,15 +2954,15 @@ globus_io_tcp_get_local_address( GLOBUS_IO_MODULE, GLOBUS_NULL, (char *) _io_name)); - + goto error_ipv6; } - + while(count--) { host[count] = myhost[count]; } - + return GLOBUS_SUCCESS; error_ipv6: @@ -2980,17 +2980,17 @@ globus_io_tcp_get_remote_address( int count; globus_result_t result; GlobusIOName(globus_io_tcp_get_remote_address); - + GlobusLIOCheckNullParam(host); GlobusLIOCheckNullParam(port); GlobusLIOCheckHandle(handle, GLOBUS_I_IO_TCP_HANDLE); - + result = globus_io_tcp_get_remote_address_ex(handle, myhost, &count, port); if(result != GLOBUS_SUCCESS) { goto error_cntl; } - + if(count != 4) { /* interface doesnt support ipv6 addresses */ @@ -2999,15 +2999,15 @@ globus_io_tcp_get_remote_address( GLOBUS_IO_MODULE, GLOBUS_NULL, (char *) _io_name)); - + goto error_ipv6; } - + while(count--) { host[count] = myhost[count]; } - + return GLOBUS_SUCCESS; error_ipv6: @@ -3030,23 +3030,23 @@ globus_io_register_read( globus_l_io_handle_t * ihandle; globus_result_t result; GlobusIOName(globus_io_register_read); - + GlobusLIOCheckNullParam(callback); GlobusLIOCheckHandle(handle, 0); - + ihandle = *handle; result = GlobusLIOMalloc(bounce_info, globus_l_io_bounce_t); if(result != GLOBUS_SUCCESS) { goto error_alloc; } - + bounce_info->handle = ihandle; bounce_info->cb.read_write = callback; bounce_info->user_arg = callback_arg; bounce_info->blocking = GLOBUS_FALSE; bounce_info->cancel_info = GLOBUS_NULL; - + globus_mutex_lock(&ihandle->pending_lock); { result = globus_xio_register_read( @@ -3062,16 +3062,16 @@ globus_io_register_read( globus_mutex_unlock(&ihandle->pending_lock); goto error_register; } - + globus_l_io_cancel_insert(bounce_info); } globus_mutex_unlock(&ihandle->pending_lock); - + return GLOBUS_SUCCESS; error_register: globus_free(bounce_info); - + error_alloc: return result; } @@ -3085,11 +3085,11 @@ globus_io_try_read( { globus_result_t result; GlobusIOName(globus_io_try_read); - + GlobusLIOCheckNullParam(nbytes_read); *nbytes_read = 0; GlobusLIOCheckHandle(handle, 0); - + result = globus_xio_read( (*handle)->xio_handle, buf, @@ -3101,9 +3101,9 @@ globus_io_try_read( { goto error_read; } - + return GLOBUS_SUCCESS; - + error_read: if(globus_xio_error_is_eof(result)) { @@ -3121,7 +3121,7 @@ globus_io_try_read( globus_error_get(result), (*handle)->io_handle)); } - + return result; } @@ -3135,11 +3135,11 @@ globus_io_read( { globus_result_t result; GlobusIOName(globus_io_read); - + GlobusLIOCheckNullParam(nbytes_read); *nbytes_read = 0; GlobusLIOCheckHandle(handle, 0); - + result = globus_xio_read( (*handle)->xio_handle, buf, @@ -3151,9 +3151,9 @@ globus_io_read( { goto error_read; } - + return GLOBUS_SUCCESS; - + error_read: if(globus_xio_error_is_eof(result)) { @@ -3171,7 +3171,7 @@ globus_io_read( globus_error_get(result), (*handle)->io_handle)); } - + return result; } @@ -3189,23 +3189,23 @@ globus_io_register_write( globus_l_io_handle_t * ihandle; globus_result_t result; GlobusIOName(globus_io_register_write); - + GlobusLIOCheckNullParam(write_callback); GlobusLIOCheckHandle(handle, 0); - + ihandle = *handle; result = GlobusLIOMalloc(bounce_info, globus_l_io_bounce_t); if(result != GLOBUS_SUCCESS) { goto error_alloc; } - + bounce_info->handle = ihandle; bounce_info->cb.read_write = write_callback; bounce_info->user_arg = callback_arg; bounce_info->blocking = GLOBUS_FALSE; bounce_info->cancel_info = GLOBUS_NULL; - + globus_mutex_lock(&ihandle->pending_lock); { result = globus_xio_register_write( @@ -3221,16 +3221,16 @@ globus_io_register_write( globus_mutex_unlock(&ihandle->pending_lock); goto error_register; } - + globus_l_io_cancel_insert(bounce_info); } globus_mutex_unlock(&ihandle->pending_lock); - + return GLOBUS_SUCCESS; error_register: globus_free(bounce_info); - + error_alloc: return result; } @@ -3249,17 +3249,17 @@ globus_io_register_send( globus_result_t result; globus_xio_data_descriptor_t dd; GlobusIOName(globus_io_register_send); - + GlobusLIOCheckNullParam(write_callback); GlobusLIOCheckHandle(handle, GLOBUS_I_IO_TCP_HANDLE); - + ihandle = *handle; result = GlobusLIOMalloc(bounce_info, globus_l_io_bounce_t); if(result != GLOBUS_SUCCESS) { goto error_alloc; } - + if(flags) { result = globus_xio_data_descriptor_init(&dd, ihandle->xio_handle); @@ -3267,7 +3267,7 @@ globus_io_register_send( { goto error_dd; } - + result = globus_xio_data_descriptor_cntl( dd, globus_l_io_tcp_driver, @@ -3282,13 +3282,13 @@ globus_io_register_send( { dd = GLOBUS_NULL; } - + bounce_info->handle = ihandle; bounce_info->cb.read_write = write_callback; bounce_info->user_arg = callback_arg; bounce_info->blocking = GLOBUS_FALSE; bounce_info->cancel_info = GLOBUS_NULL; - + globus_mutex_lock(&ihandle->pending_lock); { result = globus_xio_register_write( @@ -3305,11 +3305,11 @@ globus_io_register_send( globus_mutex_unlock(&ihandle->pending_lock); goto error_register; } - + globus_l_io_cancel_insert(bounce_info); } globus_mutex_unlock(&ihandle->pending_lock); - + return GLOBUS_SUCCESS; error_register: @@ -3318,10 +3318,10 @@ globus_io_register_send( { globus_xio_data_descriptor_destroy(dd); } - + error_dd: globus_free(bounce_info); - + error_alloc: return result; } @@ -3340,30 +3340,30 @@ globus_io_register_writev( int i; globus_size_t nbytes; GlobusIOName(globus_io_register_writev); - + GlobusLIOCheckNullParam(writev_callback); GlobusLIOCheckNullParam(iov); GlobusLIOCheckHandle(handle, 0); - + ihandle = *handle; result = GlobusLIOMalloc(bounce_info, globus_l_io_bounce_t); if(result != GLOBUS_SUCCESS) { goto error_alloc; } - + bounce_info->handle = ihandle; bounce_info->cb.writev = writev_callback; bounce_info->user_arg = callback_arg; bounce_info->blocking = GLOBUS_FALSE; bounce_info->cancel_info = GLOBUS_NULL; - + nbytes = 0; for(i = 0; i < iovcnt; i++) { nbytes += iov[i].iov_len; } - + globus_mutex_lock(&ihandle->pending_lock); { result = globus_xio_register_writev( @@ -3379,16 +3379,16 @@ globus_io_register_writev( globus_mutex_unlock(&ihandle->pending_lock); goto error_register; } - + globus_l_io_cancel_insert(bounce_info); } globus_mutex_unlock(&ihandle->pending_lock); - + return GLOBUS_SUCCESS; error_register: globus_free(bounce_info); - + error_alloc: return result; } @@ -3402,11 +3402,11 @@ globus_io_try_write( { globus_result_t result; GlobusIOName(globus_io_try_write); - + GlobusLIOCheckNullParam(nbytes_written); *nbytes_written = 0; GlobusLIOCheckHandle(handle, 0); - + result = globus_xio_write( (*handle)->xio_handle, buf, @@ -3418,9 +3418,9 @@ globus_io_try_write( { goto error_write; } - + return GLOBUS_SUCCESS; - + error_write: if(globus_xio_error_is_canceled(result)) { @@ -3430,7 +3430,7 @@ globus_io_try_write( globus_error_get(result), (*handle)->io_handle)); } - + return result; } @@ -3445,11 +3445,11 @@ globus_io_try_send( globus_result_t result; globus_xio_data_descriptor_t dd; GlobusIOName(globus_io_try_send); - + GlobusLIOCheckNullParam(nbytes_sent); *nbytes_sent = 0; GlobusLIOCheckHandle(handle, GLOBUS_I_IO_TCP_HANDLE); - + if(flags) { result = globus_xio_data_descriptor_init(&dd, (*handle)->xio_handle); @@ -3457,7 +3457,7 @@ globus_io_try_send( { goto error_dd; } - + result = globus_xio_data_descriptor_cntl( dd, globus_l_io_tcp_driver, @@ -3472,7 +3472,7 @@ globus_io_try_send( { dd = GLOBUS_NULL; } - + result = globus_xio_write( (*handle)->xio_handle, buf, @@ -3486,7 +3486,7 @@ globus_io_try_send( goto error_write; } return GLOBUS_SUCCESS; - + error_write: if(globus_xio_error_is_canceled(result)) { @@ -3502,7 +3502,7 @@ globus_io_try_send( { globus_xio_data_descriptor_destroy(dd); } - + error_dd: return result; } @@ -3516,11 +3516,11 @@ globus_io_write( { globus_result_t result; GlobusIOName(globus_io_write); - + GlobusLIOCheckNullParam(nbytes_written); *nbytes_written = 0; GlobusLIOCheckHandle(handle, 0); - + result = globus_xio_write( (*handle)->xio_handle, buf, @@ -3532,9 +3532,9 @@ globus_io_write( { goto error_write; } - + return GLOBUS_SUCCESS; - + error_write: if(globus_xio_error_is_canceled(result)) { @@ -3544,7 +3544,7 @@ globus_io_write( globus_error_get(result), (*handle)->io_handle)); } - + return result; } @@ -3559,11 +3559,11 @@ globus_io_send( globus_result_t result; globus_xio_data_descriptor_t dd; GlobusIOName(globus_io_send); - + GlobusLIOCheckNullParam(nbytes_sent); *nbytes_sent = 0; GlobusLIOCheckHandle(handle, GLOBUS_I_IO_TCP_HANDLE); - + if(flags) { result = globus_xio_data_descriptor_init(&dd, (*handle)->xio_handle); @@ -3571,7 +3571,7 @@ globus_io_send( { goto error_dd; } - + result = globus_xio_data_descriptor_cntl( dd, globus_l_io_tcp_driver, @@ -3586,7 +3586,7 @@ globus_io_send( { dd = GLOBUS_NULL; } - + result = globus_xio_write( (*handle)->xio_handle, buf, @@ -3601,7 +3601,7 @@ globus_io_send( } return GLOBUS_SUCCESS; - + error_write: if(globus_xio_error_is_canceled(result)) { @@ -3617,7 +3617,7 @@ globus_io_send( { globus_xio_data_descriptor_destroy(dd); } - + error_dd: return result; } @@ -3633,18 +3633,18 @@ globus_io_writev( int i; globus_size_t nbytes; GlobusIOName(globus_io_writev); - + GlobusLIOCheckNullParam(bytes_written); *bytes_written = 0; GlobusLIOCheckNullParam(iov); GlobusLIOCheckHandle(handle, 0); - + nbytes = 0; for(i = 0; i < iovcnt; i++) { nbytes += iov[i].iov_len; } - + result = globus_xio_writev( (*handle)->xio_handle, iov, @@ -3656,9 +3656,9 @@ globus_io_writev( { goto error_write; } - + return GLOBUS_SUCCESS; - + error_write: if(globus_xio_error_is_canceled(result)) { @@ -3668,7 +3668,7 @@ globus_io_writev( globus_error_get(result), (*handle)->io_handle)); } - + return result; } @@ -3680,7 +3680,7 @@ globus_l_io_bounce_close_cb( globus_xio_handle_t handle, globus_result_t result, void * user_arg); - + static void globus_l_io_bounce_close_kickout( @@ -3688,12 +3688,12 @@ globus_l_io_bounce_close_kickout( { globus_l_io_bounce_t * bounce_info; GlobusIOName(globus_l_io_bounce_close_kickout); - + bounce_info = (globus_l_io_bounce_t *) user_arg; - + globus_l_io_bounce_close_cb( GLOBUS_NULL, - bounce_info->error + bounce_info->error ? globus_error_put(bounce_info->error) : GLOBUS_SUCCESS, user_arg); } @@ -3707,12 +3707,12 @@ globus_l_io_bounce_close_cb( { globus_l_io_bounce_t * bounce_info; GlobusIOName(globus_l_io_bounce_close_cb); - + bounce_info = (globus_l_io_bounce_t *) user_arg; - + if(globus_l_io_should_bounce(bounce_info)) { - bounce_info->error = result == GLOBUS_SUCCESS + bounce_info->error = result == GLOBUS_SUCCESS ? GLOBUS_NULL : globus_error_get(result); result = globus_callback_space_register_oneshot( GLOBUS_NULL, @@ -3732,18 +3732,18 @@ globus_l_io_bounce_close_cb( } return; } - + bounce_info->cb.non_io( bounce_info->user_arg, bounce_info->handle->io_handle, result); - + globus_mutex_lock(&bounce_info->handle->pending_lock); { bounce_info->handle->refs--; } globus_mutex_unlock(&bounce_info->handle->pending_lock); - + globus_l_io_handle_destroy(bounce_info->handle); globus_free(bounce_info); } @@ -3753,17 +3753,14 @@ void globus_l_io_server_close_cb( globus_xio_server_t xio_server, void * user_arg); - + static void globus_l_io_server_close_kickout( void * user_arg) { - globus_l_io_bounce_t * bounce_info; GlobusIOName(globus_l_io_server_close_kickout); - - bounce_info = (globus_l_io_bounce_t *) user_arg; - + globus_l_io_server_close_cb(GLOBUS_NULL, user_arg); } @@ -3775,13 +3772,13 @@ globus_l_io_server_close_cb( { globus_l_io_bounce_t * bounce_info; GlobusIOName(globus_l_io_server_close_cb); - + bounce_info = (globus_l_io_bounce_t *) user_arg; - + if(globus_l_io_should_bounce(bounce_info)) { globus_result_t result; - + result = globus_callback_space_register_oneshot( GLOBUS_NULL, GLOBUS_NULL, @@ -3800,18 +3797,18 @@ globus_l_io_server_close_cb( } return; } - + bounce_info->cb.non_io( bounce_info->user_arg, bounce_info->handle->io_handle, GLOBUS_SUCCESS); - + globus_mutex_lock(&bounce_info->handle->pending_lock); { bounce_info->handle->refs--; } globus_mutex_unlock(&bounce_info->handle->pending_lock); - + globus_l_io_handle_destroy(bounce_info->handle); globus_free(bounce_info); } @@ -3827,31 +3824,31 @@ globus_l_io_register_close( globus_l_io_handle_t * ihandle; globus_result_t result; GlobusIOName(globus_io_register_close); - + GlobusLIOCheckNullParam(callback); GlobusLIOCheckHandle(handle, 0); ihandle = *handle; - + result = GlobusLIOMalloc(bounce_info, globus_l_io_bounce_t); if(result != GLOBUS_SUCCESS) { goto error_alloc; } - + bounce_info->handle = ihandle; bounce_info->cb.non_io = callback; bounce_info->user_arg = callback_arg; bounce_info->blocking = blocking; - + globus_mutex_lock(&ihandle->pending_lock); { if(ihandle->xio_handle) { globus_xio_handle_t xio_handle; - + xio_handle = ihandle->xio_handle; ihandle->xio_handle = GLOBUS_NULL; - + result = globus_xio_register_close( xio_handle, GLOBUS_NULL, @@ -3861,10 +3858,10 @@ globus_l_io_register_close( else if(ihandle->xio_server) { globus_xio_server_t xio_server; - + xio_server = ihandle->xio_server; ihandle->xio_server = GLOBUS_NULL; - + result = globus_xio_server_register_close( xio_server, globus_l_io_server_close_cb, @@ -3880,24 +3877,24 @@ globus_l_io_register_close( 1, (char *) _io_name)); } - + if(result == GLOBUS_SUCCESS) { ihandle->refs++; } } globus_mutex_unlock(&ihandle->pending_lock); - + if(result != GLOBUS_SUCCESS) { goto error_register; } - + return GLOBUS_SUCCESS; error_register: globus_free(bounce_info); - + error_alloc: *handle = GLOBUS_NULL; return result; @@ -3920,11 +3917,11 @@ globus_io_close( globus_result_t result; globus_l_io_monitor_t monitor; GlobusIOName(globus_io_close); - + monitor.done = GLOBUS_FALSE; globus_mutex_init(&monitor.lock, GLOBUS_NULL); globus_cond_init(&monitor.cond, GLOBUS_NULL); - + result = globus_l_io_register_close( handle, globus_l_io_blocking_cb, &monitor, GLOBUS_TRUE); if(result != GLOBUS_SUCCESS) @@ -3932,7 +3929,7 @@ globus_io_close( monitor.done = GLOBUS_TRUE; monitor.error = globus_error_get(result); } - + globus_mutex_lock(&monitor.lock); { while(!monitor.done) @@ -3941,18 +3938,18 @@ globus_io_close( } } globus_mutex_unlock(&monitor.lock); - + globus_mutex_destroy(&monitor.lock); globus_cond_destroy(&monitor.cond); - + if(monitor.error != GLOBUS_NULL) { result = globus_error_put(monitor.error); goto error_register; } - + return GLOBUS_SUCCESS; - + error_register: return result; } @@ -3962,7 +3959,7 @@ globus_io_eof( globus_object_t * eof) { GlobusIOName(globus_io_eof); - + if(eof && globus_object_get_type(eof) == GLOBUS_IO_ERROR_TYPE_EOF) { return GLOBUS_TRUE; @@ -3980,7 +3977,7 @@ globus_io_tcp_posix_convert( globus_io_handle_t * handle) { GlobusIOName(globus_io_tcp_posix_convert); - + return globus_l_io_tcp_connect(GLOBUS_NULL, 0, socket, attr, handle); } @@ -3991,7 +3988,7 @@ globus_io_tcp_posix_convert_listener( globus_io_handle_t * handle) { GlobusIOName(globus_io_tcp_posix_convert_listener); - + return globus_l_io_tcp_create_listener( GLOBUS_NULL, 0, socket, attr, handle); } @@ -4010,23 +4007,23 @@ globus_l_io_register_cancel( globus_l_io_cancel_info_t * cancel_info; globus_l_io_bounce_t * bounce_info; GlobusIOName(globus_io_register_cancel); - + GlobusLIOCheckHandle(handle, 0); ihandle = *handle; - + result = GlobusLIOMalloc(cancel_info, globus_l_io_cancel_info_t); if(result != GLOBUS_SUCCESS) { goto error_cancel_info; } - + cancel_info->handle = handle; cancel_info->refs = 0; cancel_info->blocking = blocking; cancel_info->perform_callbacks = perform_callbacks; cancel_info->callback = cancel_callback; cancel_info->user_arg = cancel_arg; - + globus_mutex_lock(&ihandle->pending_lock); { if(ihandle->xio_handle) @@ -4048,16 +4045,16 @@ globus_l_io_register_cancel( GLOBUS_NULL, "handle", 1, - (char *) _io_name)); + (char *) _io_name)); } - + if(result == GLOBUS_SUCCESS) { globus_list_t * pending; - + pending = ihandle->pending_ops; ihandle->pending_ops = GLOBUS_NULL; - + while(!globus_list_empty(pending)) { bounce_info = globus_list_remove(&pending, pending); @@ -4065,7 +4062,7 @@ globus_l_io_register_cancel( cancel_info->refs++; } } - + if(cancel_info->refs == 0) { result = globus_callback_space_register_oneshot( @@ -4082,13 +4079,13 @@ globus_l_io_register_cancel( } } globus_mutex_unlock(&ihandle->pending_lock); - + return GLOBUS_SUCCESS; error_oneshot: globus_mutex_unlock(&ihandle->pending_lock); globus_free(cancel_info); - + error_cancel_info: return result; } @@ -4112,11 +4109,11 @@ globus_io_cancel( globus_result_t result; globus_l_io_monitor_t monitor; GlobusIOName(globus_io_cancel); - + monitor.done = GLOBUS_FALSE; globus_mutex_init(&monitor.lock, GLOBUS_NULL); globus_cond_init(&monitor.cond, GLOBUS_NULL); - + result = globus_l_io_register_cancel( handle, perform_callbacks, @@ -4128,7 +4125,7 @@ globus_io_cancel( monitor.done = GLOBUS_TRUE; monitor.error = globus_error_get(result); } - + globus_mutex_lock(&monitor.lock); { while(!monitor.done) @@ -4137,18 +4134,18 @@ globus_io_cancel( } } globus_mutex_unlock(&monitor.lock); - + globus_mutex_destroy(&monitor.lock); globus_cond_destroy(&monitor.cond); - + if(monitor.error != GLOBUS_NULL) { result = globus_error_put(monitor.error); goto error_register; } - + return GLOBUS_SUCCESS; - + error_register: return result; } @@ -4163,10 +4160,10 @@ globus_l_io_bounce_select_cb( globus_size_t nbytes) { globus_io_callback_t cb; - + /* callback is buried in buffer... bad me */ cb = (globus_io_callback_t) buf; - + cb(arg, handle, result); } @@ -4180,13 +4177,11 @@ globus_io_register_select( globus_io_callback_t except_callback_func, void * except_callback_arg) { - globus_l_io_handle_t * ihandle; globus_result_t result; GlobusIOName(globus_io_register_select); - + GlobusLIOCheckHandle(handle, 0); - ihandle = *handle; - + if(except_callback_func) { result = globus_error_put( @@ -4200,7 +4195,7 @@ globus_io_register_select( _IOSL("Globus IO-XIO does not support use of the except callback"))); goto error_notsupported; } - + if(read_callback_func) { result = globus_io_register_read( @@ -4215,7 +4210,7 @@ globus_io_register_select( goto error_register; } } - + if(write_callback_func) { result = globus_io_register_write( @@ -4232,7 +4227,7 @@ globus_io_register_select( goto error_register; } } - + return GLOBUS_SUCCESS; error_register: @@ -4246,10 +4241,10 @@ globus_io_get_handle_type( { globus_l_io_handle_t * ihandle; GlobusIOName(globus_io_get_handle_type); - + GlobusLIOCheckHandle(handle, 0); ihandle = *handle; - + if(ihandle->type == GLOBUS_I_IO_FILE_HANDLE) return GLOBUS_IO_HANDLE_TYPE_FILE; else @@ -4262,12 +4257,12 @@ globus_io_handle_get_user_pointer( void ** user_pointer) { GlobusIOName(globus_io_handle_get_user_pointer); - + GlobusLIOCheckHandle(handle, 0); GlobusLIOCheckNullParam(user_pointer); - + *user_pointer = (*handle)->user_pointer; - + return GLOBUS_SUCCESS; } @@ -4277,11 +4272,11 @@ globus_io_handle_set_user_pointer( void * user_pointer) { GlobusIOName(globus_io_handle_set_user_pointer); - + GlobusLIOCheckHandle(handle, 0); - + (*handle)->user_pointer = user_pointer; - + return GLOBUS_SUCCESS; } @@ -4291,12 +4286,12 @@ globus_io_handle_get_xio_handle( globus_xio_handle_t * xio_handle) { GlobusIOName(globus_io_handle_get_xio_handle); - + GlobusLIOCheckHandle(handle, 0); GlobusLIOCheckNullParam(xio_handle); - + *xio_handle = (*handle)->xio_handle; - + return GLOBUS_SUCCESS; } @@ -4306,10 +4301,10 @@ globus_io_tcp_get_security_context( gss_ctx_id_t * context) { GlobusIOName(globus_io_tcp_get_security_context); - + GlobusLIOCheckHandle(handle, GLOBUS_I_IO_TCP_HANDLE); GlobusLIOCheckNullParam(context); - + return globus_xio_handle_cntl( (*handle)->xio_handle, globus_l_io_gsi_driver, @@ -4323,10 +4318,10 @@ globus_io_tcp_get_delegated_credential( gss_cred_id_t * cred) { GlobusIOName(globus_io_tcp_get_delegated_credential); - + GlobusLIOCheckHandle(handle, GLOBUS_I_IO_TCP_HANDLE); GlobusLIOCheckNullParam(cred); - + return globus_xio_handle_cntl( (*handle)->xio_handle, globus_l_io_gsi_driver, @@ -4341,23 +4336,23 @@ globus_io_tcp_set_credential( gss_cred_id_t credential) { GlobusIOName(globus_io_tcp_set_credential); - + GlobusLIOCheckHandle(handle, GLOBUS_I_IO_TCP_HANDLE); - + if ((*handle)->xio_handle) { return globus_xio_handle_cntl( - (*handle)->xio_handle, - globus_l_io_gsi_driver, - GLOBUS_XIO_GSI_SET_CREDENTIAL, + (*handle)->xio_handle, + globus_l_io_gsi_driver, + GLOBUS_XIO_GSI_SET_CREDENTIAL, credential); } else { return globus_xio_attr_cntl( - (*handle)->attr->attr, - globus_l_io_gsi_driver, - GLOBUS_XIO_GSI_SET_CREDENTIAL, + (*handle)->attr->attr, + globus_l_io_gsi_driver, + GLOBUS_XIO_GSI_SET_CREDENTIAL, credential); } } @@ -4369,22 +4364,22 @@ globus_io_tcp_get_credential( gss_cred_id_t * credential) { GlobusIOName(globus_io_tcp_get_credential); - + GlobusLIOCheckHandle(handle, GLOBUS_I_IO_TCP_HANDLE); GlobusLIOCheckNullParam(credential); - + return globus_xio_handle_cntl( - (*handle)->xio_handle, - globus_l_io_gsi_driver, + (*handle)->xio_handle, + globus_l_io_gsi_driver, GLOBUS_XIO_GSI_GET_CREDENTIAL, credential); } static -void +void globus_l_io_init_delegation_cb( - globus_result_t result, - void * user_arg) + globus_result_t result, + void * user_arg) { globus_l_io_delegation_cb_arg_t * wrapper; GlobusIOName(globus_l_io_init_delegation_cb); @@ -4403,16 +4398,16 @@ globus_l_io_init_delegation_cb( } static -void +void globus_l_io_accept_delegation_cb( - globus_result_t result, + globus_result_t result, gss_cred_id_t delegated_cred, OM_uint32 time_rec, - void * user_arg) + void * user_arg) { globus_l_io_delegation_cb_arg_t * wrapper; GlobusIOName(globus_l_io_accept_delegation_cb); - + wrapper = (globus_l_io_delegation_cb_arg_t *) user_arg; wrapper->callback(wrapper->user_arg, @@ -4454,7 +4449,7 @@ globus_io_register_init_delegation( wrapper->handle = handle; wrapper->user_arg = callback_arg; wrapper->callback = callback; - + result = globus_xio_handle_cntl( ihandle->xio_handle, globus_l_io_gsi_driver, @@ -4469,7 +4464,7 @@ globus_io_register_init_delegation( { free(wrapper); } - + return result; } @@ -4482,12 +4477,12 @@ globus_io_init_delegation( OM_uint32 time_req) { globus_result_t result; - globus_l_io_handle_t * ihandle; + globus_l_io_handle_t * ihandle; GlobusIOName(globus_io_init_delegation); - + GlobusLIOCheckHandle(handle, GLOBUS_I_IO_TCP_HANDLE); ihandle = *handle; - + result = globus_xio_handle_cntl( ihandle->xio_handle, globus_l_io_gsi_driver, @@ -4495,8 +4490,8 @@ globus_io_init_delegation( cred_handle, restriction_oids, restriction_buffers, - time_req); - + time_req); + return result; } @@ -4513,7 +4508,7 @@ globus_io_register_accept_delegation( globus_l_io_handle_t * ihandle; globus_l_io_delegation_cb_arg_t * wrapper; GlobusIOName(globus_io_register_accept_delegation); - + GlobusLIOCheckNullParam(callback); GlobusLIOCheckHandle(handle, GLOBUS_I_IO_TCP_HANDLE); ihandle = *handle; @@ -4536,7 +4531,7 @@ globus_io_register_accept_delegation( restriction_buffers, time_req, globus_l_io_accept_delegation_cb, - wrapper); + wrapper); if(result != GLOBUS_SUCCESS) { free(wrapper); @@ -4555,12 +4550,12 @@ globus_io_accept_delegation( OM_uint32 * time_rec) { globus_result_t result; - globus_l_io_handle_t * ihandle; + globus_l_io_handle_t * ihandle; GlobusIOName(globus_io_accept_delegation); - + GlobusLIOCheckHandle(handle, GLOBUS_I_IO_TCP_HANDLE); ihandle = *handle; - + result = globus_xio_handle_cntl( ihandle->xio_handle, globus_l_io_gsi_driver, @@ -4570,9 +4565,9 @@ globus_io_accept_delegation( restriction_buffers, time_req, time_rec); - + return result; - + } globus_result_t @@ -4584,7 +4579,7 @@ globus_io_attr_set_secure_authentication_mode( { globus_result_t result = GLOBUS_SUCCESS; GlobusIOName(globus_io_attr_set_secure_authentication_mode); - + GlobusLIOCheckAttr(attr, GLOBUS_I_IO_TCP_ATTR); (*attr)->authentication_mode = mode; @@ -4593,18 +4588,18 @@ globus_io_attr_set_secure_authentication_mode( case GLOBUS_IO_SECURE_AUTHENTICATION_MODE_GSSAPI: case GLOBUS_IO_SECURE_AUTHENTICATION_MODE_MUTUAL: if(credential != GSS_C_NO_CREDENTIAL) - { + { result = globus_xio_attr_cntl( - (*attr)->attr, - globus_l_io_gsi_driver, - GLOBUS_XIO_GSI_SET_CREDENTIAL, + (*attr)->attr, + globus_l_io_gsi_driver, + GLOBUS_XIO_GSI_SET_CREDENTIAL, credential); } break; case GLOBUS_IO_SECURE_AUTHENTICATION_MODE_ANONYMOUS: result = globus_xio_attr_cntl( - (*attr)->attr, - globus_l_io_gsi_driver, + (*attr)->attr, + globus_l_io_gsi_driver, GLOBUS_XIO_GSI_SET_ANON); break; case GLOBUS_IO_SECURE_AUTHENTICATION_MODE_NONE: @@ -4613,7 +4608,7 @@ globus_io_attr_set_secure_authentication_mode( globus_assert(0 && "Unexpected state"); break; } - + return result; } @@ -4625,10 +4620,10 @@ globus_io_attr_get_secure_authentication_mode( gss_cred_id_t * credential) { GlobusIOName(globus_io_attr_get_secure_authentication_mode); - + GlobusLIOCheckAttr(attr, GLOBUS_I_IO_TCP_ATTR); GlobusLIOCheckNullParam(mode); - + *mode = (*attr)->authentication_mode; return GLOBUS_SUCCESS; } @@ -4645,7 +4640,7 @@ globus_io_attr_set_secure_authorization_mode( OM_uint32 major_status; OM_uint32 minor_status; GlobusIOName(globus_io_attr_set_secure_authorization_mode); - + GlobusLIOCheckAttr(attr, GLOBUS_I_IO_TCP_ATTR); (*attr)->authorization_mode = mode; @@ -4661,9 +4656,9 @@ globus_io_attr_set_secure_authorization_mode( (*attr)->authz_data.identity = GSS_C_NO_NAME; } result = globus_xio_attr_cntl( - (*attr)->attr, - globus_l_io_gsi_driver, - GLOBUS_XIO_GSI_SET_AUTHORIZATION_MODE, + (*attr)->attr, + globus_l_io_gsi_driver, + GLOBUS_XIO_GSI_SET_AUTHORIZATION_MODE, mode); break; case GLOBUS_IO_SECURE_AUTHORIZATION_MODE_IDENTITY: @@ -4672,7 +4667,7 @@ globus_io_attr_set_secure_authorization_mode( { gss_release_name(&minor_status, &(*attr)->authz_data.identity); - } + } major_status = gss_duplicate_name(&minor_status, (*data)->identity, @@ -4685,34 +4680,34 @@ globus_io_attr_set_secure_authorization_mode( minor_status); goto error; } - + result = globus_xio_attr_cntl( - (*attr)->attr, - globus_l_io_gsi_driver, - GLOBUS_XIO_GSI_SET_AUTHORIZATION_MODE, + (*attr)->attr, + globus_l_io_gsi_driver, + GLOBUS_XIO_GSI_SET_AUTHORIZATION_MODE, mode); if(result != GLOBUS_SUCCESS) { goto error; } - + result = globus_xio_attr_cntl( - (*attr)->attr, - globus_l_io_gsi_driver, - GLOBUS_XIO_GSI_SET_TARGET_NAME, + (*attr)->attr, + globus_l_io_gsi_driver, + GLOBUS_XIO_GSI_SET_TARGET_NAME, (*attr)->authz_data.identity); - break; + break; case GLOBUS_IO_SECURE_AUTHORIZATION_MODE_CALLBACK: GlobusLIOCheckNullParam(data); - (*attr)->authz_data.callback = (*data)->callback; - (*attr)->authz_data.callback_arg = (*data)->callback_arg; + (*attr)->authz_data.callback = (*data)->callback; + (*attr)->authz_data.callback_arg = (*data)->callback_arg; result = globus_xio_attr_cntl( - (*attr)->attr, - globus_l_io_gsi_driver, - GLOBUS_XIO_GSI_SET_AUTHORIZATION_MODE, + (*attr)->attr, + globus_l_io_gsi_driver, + GLOBUS_XIO_GSI_SET_AUTHORIZATION_MODE, GLOBUS_IO_SECURE_AUTHORIZATION_MODE_NONE); - break; + break; } error: @@ -4731,28 +4726,28 @@ globus_io_attr_get_secure_authorization_mode( OM_uint32 major_status; OM_uint32 minor_status; GlobusIOName(globus_io_attr_get_secure_authorization_mode); - + GlobusLIOCheckAttr(attr, GLOBUS_I_IO_TCP_ATTR); GlobusLIOCheckNullParam(data); GlobusLIOCheckNullParam(mode); - + result = GlobusLIOMalloc(*data, globus_l_io_secure_authorization_data_t); if(result != GLOBUS_SUCCESS) { goto done; } - + memset(*data, 0, sizeof(globus_l_io_secure_authorization_data_t)); *mode = (*attr)->authorization_mode; switch((*attr)->authorization_mode) { case GLOBUS_IO_SECURE_AUTHORIZATION_MODE_NONE: - break; + break; case GLOBUS_IO_SECURE_AUTHORIZATION_MODE_SELF: - break; + break; case GLOBUS_IO_SECURE_AUTHORIZATION_MODE_HOST: - break; + break; case GLOBUS_IO_SECURE_AUTHORIZATION_MODE_IDENTITY: major_status = gss_duplicate_name(&minor_status, (*attr)->authz_data.identity, @@ -4763,15 +4758,15 @@ globus_io_attr_get_secure_authorization_mode( major_status, minor_status); } - break; + break; case GLOBUS_IO_SECURE_AUTHORIZATION_MODE_CALLBACK: - (*data)->callback = (*attr)->authz_data.callback; - (*data)->callback_arg = (*attr)->authz_data.callback_arg; - break; + (*data)->callback = (*attr)->authz_data.callback; + (*data)->callback_arg = (*attr)->authz_data.callback_arg; + break; } done: - + return result; } @@ -4781,7 +4776,7 @@ globus_io_attr_set_secure_extension_oids( gss_OID_set extension_oids) { GlobusIOName(globus_io_attr_set_secure_extension_oids); - return GLOBUS_SUCCESS; + return GLOBUS_SUCCESS; } globus_result_t @@ -4790,7 +4785,7 @@ globus_io_attr_get_secure_extension_oids( gss_OID_set * extension_oids) { GlobusIOName(globus_io_attr_get_secure_extension_oids); - return GLOBUS_SUCCESS; + return GLOBUS_SUCCESS; } globus_result_t @@ -4801,13 +4796,13 @@ globus_io_secure_authorization_data_initialize( GlobusIOName(globus_io_secure_authorization_data_initialize); GlobusLIOCheckNullParam(data); - + result = GlobusLIOMalloc(*data, globus_l_io_secure_authorization_data_t); if(result == GLOBUS_SUCCESS) { memset(*data, 0, sizeof(globus_l_io_secure_authorization_data_t)); } - + return result; } @@ -4817,9 +4812,9 @@ globus_io_secure_authorization_data_destroy( data) { GlobusIOName(globus_io_secure_authorization_data_destroy); - + GlobusLIOCheckNullParam(data); - + if((*data)->identity != GSS_C_NO_NAME) { OM_uint32 minor_status; @@ -4830,7 +4825,7 @@ globus_io_secure_authorization_data_destroy( globus_free(*data); *data = GLOBUS_NULL; - + return GLOBUS_SUCCESS; } @@ -4849,7 +4844,7 @@ globus_io_secure_authorization_data_set_identity( GlobusLIOCheckNullParam(data); GlobusLIOCheckNullParam(identity); - + if(!strncmp("GSI-NO-TARGET", identity, 13)) { (*data)->identity = GSS_C_NO_NAME; @@ -4858,24 +4853,24 @@ globus_io_secure_authorization_data_set_identity( { name_buffer.value = identity; name_buffer.length = strlen(identity); - - /* + + /* * A GSS_C_NT_HOSTBASED_SERVICE is of the form service@FQDN - * At least the Globus gssapi, and the Kerberos gssapi - * use the same form. We will check for + * At least the Globus gssapi, and the Kerberos gssapi + * use the same form. We will check for * two special forms here: host@FQDN and ftp@FQDN */ - if (strchr(identity,'@') && + if (strchr(identity,'@') && !strstr(identity,"CN=")) - { + { name_type = GSS_C_NT_HOSTBASED_SERVICE; } else if(!strncmp("",identity, 11)) { name_type = GSS_C_NT_ANONYMOUS; } - + major_status = gss_import_name(&minor_status, &name_buffer, name_type, @@ -4887,7 +4882,7 @@ globus_io_secure_authorization_data_set_identity( minor_status); } } - + return result; } @@ -4899,16 +4894,16 @@ globus_io_secure_authorization_data_get_identity( { globus_result_t result = GLOBUS_SUCCESS; GlobusIOName(globus_io_secure_authorization_data_get_identity); - + GlobusLIOCheckNullParam(data); GlobusLIOCheckNullParam(identity); - + if((*data)->identity != GSS_C_NO_NAME) - { + { OM_uint32 major_status; OM_uint32 minor_status; gss_buffer_desc name_buffer; - + major_status = gss_display_name(&minor_status, (*data)->identity, &name_buffer, @@ -4922,7 +4917,7 @@ globus_io_secure_authorization_data_get_identity( } /* could probably just realloc the buffer contents */ - + result = GlobusLIOMallocSize(*identity, name_buffer.length + 1); if(result != GLOBUS_SUCCESS) @@ -4945,7 +4940,7 @@ globus_io_secure_authorization_data_get_identity( } done: - + return result; } @@ -4958,12 +4953,12 @@ globus_io_secure_authorization_data_set_callback( void * callback_arg) { GlobusIOName(globus_io_secure_authorization_data_set_callback); - + GlobusLIOCheckNullParam(data); - + (*data)->callback = callback; (*data)->callback_arg = callback_arg; - + return GLOBUS_SUCCESS; } @@ -4976,14 +4971,14 @@ globus_io_secure_authorization_data_get_callback( void ** callback_arg) { GlobusIOName(globus_io_secure_authorization_data_get_callback); - + GlobusLIOCheckNullParam(data); GlobusLIOCheckNullParam(callback); GlobusLIOCheckNullParam(callback_arg); - + *callback = (*data)->callback; *callback_arg = (*data)->callback_arg; - + return GLOBUS_SUCCESS; } @@ -4994,18 +4989,18 @@ globus_io_attr_set_secure_channel_mode( { globus_result_t result = GLOBUS_SUCCESS; globus_xio_gsi_protection_level_t protection_level; - + GlobusIOName(globus_io_attr_set_secure_channel_mode); - + GlobusLIOCheckAttr(attr, GLOBUS_I_IO_TCP_ATTR); - + (*attr)->channel_mode = mode; switch(mode) { case GLOBUS_IO_SECURE_CHANNEL_MODE_CLEAR: result = globus_xio_attr_cntl( - (*attr)->attr, - globus_l_io_gsi_driver, + (*attr)->attr, + globus_l_io_gsi_driver, GLOBUS_XIO_GSI_SET_SSL_COMPATIBLE, GLOBUS_FALSE); if(result != GLOBUS_SUCCESS) @@ -5014,8 +5009,8 @@ globus_io_attr_set_secure_channel_mode( } result = globus_xio_attr_cntl( - (*attr)->attr, - globus_l_io_gsi_driver, + (*attr)->attr, + globus_l_io_gsi_driver, GLOBUS_XIO_GSI_SET_PROTECTION_LEVEL, GLOBUS_XIO_GSI_PROTECTION_LEVEL_NONE); break; @@ -5032,18 +5027,18 @@ globus_io_attr_set_secure_channel_mode( case GLOBUS_IO_SECURE_CHANNEL_MODE_GSI_WRAP: result = globus_xio_attr_cntl( - (*attr)->attr, - globus_l_io_gsi_driver, + (*attr)->attr, + globus_l_io_gsi_driver, GLOBUS_XIO_GSI_SET_WRAP_MODE, GLOBUS_TRUE); if(result != GLOBUS_SUCCESS) { goto error; } - + result = globus_xio_attr_cntl( - (*attr)->attr, - globus_l_io_gsi_driver, + (*attr)->attr, + globus_l_io_gsi_driver, GLOBUS_XIO_GSI_GET_PROTECTION_LEVEL, &protection_level); @@ -5053,10 +5048,10 @@ globus_io_attr_set_secure_channel_mode( } if(protection_level == GLOBUS_XIO_GSI_PROTECTION_LEVEL_NONE) - { + { result = globus_xio_attr_cntl( - (*attr)->attr, - globus_l_io_gsi_driver, + (*attr)->attr, + globus_l_io_gsi_driver, GLOBUS_XIO_GSI_SET_PROTECTION_LEVEL, GLOBUS_XIO_GSI_PROTECTION_LEVEL_INTEGRITY); } @@ -5064,18 +5059,18 @@ globus_io_attr_set_secure_channel_mode( case GLOBUS_IO_SECURE_CHANNEL_MODE_SSL_WRAP: result = globus_xio_attr_cntl( - (*attr)->attr, - globus_l_io_gsi_driver, + (*attr)->attr, + globus_l_io_gsi_driver, GLOBUS_XIO_GSI_SET_SSL_COMPATIBLE, GLOBUS_TRUE); if(result != GLOBUS_SUCCESS) { goto error; } - + result = globus_xio_attr_cntl( - (*attr)->attr, - globus_l_io_gsi_driver, + (*attr)->attr, + globus_l_io_gsi_driver, GLOBUS_XIO_GSI_GET_PROTECTION_LEVEL, &protection_level); @@ -5085,16 +5080,16 @@ globus_io_attr_set_secure_channel_mode( } if(protection_level == GLOBUS_XIO_GSI_PROTECTION_LEVEL_NONE) - { + { result = globus_xio_attr_cntl( - (*attr)->attr, - globus_l_io_gsi_driver, + (*attr)->attr, + globus_l_io_gsi_driver, GLOBUS_XIO_GSI_SET_PROTECTION_LEVEL, GLOBUS_XIO_GSI_PROTECTION_LEVEL_INTEGRITY); } break; } - + error: return result; } @@ -5105,10 +5100,10 @@ globus_io_attr_get_secure_channel_mode( globus_io_secure_channel_mode_t * mode) { GlobusIOName(globus_io_attr_get_secure_channel_mode); - + GlobusLIOCheckAttr(attr, GLOBUS_I_IO_TCP_ATTR); GlobusLIOCheckNullParam(mode); - + *mode = (*attr)->channel_mode; return GLOBUS_SUCCESS; } @@ -5119,12 +5114,12 @@ globus_io_attr_set_secure_protection_mode( globus_io_secure_protection_mode_t mode) { GlobusIOName(globus_io_attr_set_secure_protection_mode); - + GlobusLIOCheckAttr(attr, GLOBUS_I_IO_TCP_ATTR); - + return globus_xio_attr_cntl( - (*attr)->attr, - globus_l_io_gsi_driver, + (*attr)->attr, + globus_l_io_gsi_driver, GLOBUS_XIO_GSI_SET_PROTECTION_LEVEL, mode); } @@ -5135,13 +5130,13 @@ globus_io_attr_get_secure_protection_mode( globus_io_secure_protection_mode_t *mode) { GlobusIOName(globus_io_attr_get_secure_protection_mode); - + GlobusLIOCheckAttr(attr, GLOBUS_I_IO_TCP_ATTR); GlobusLIOCheckNullParam(mode); - + return globus_xio_attr_cntl( - (*attr)->attr, - globus_l_io_gsi_driver, + (*attr)->attr, + globus_l_io_gsi_driver, GLOBUS_XIO_GSI_GET_PROTECTION_LEVEL, mode); } @@ -5152,12 +5147,12 @@ globus_io_attr_set_secure_delegation_mode( globus_io_secure_delegation_mode_t mode) { GlobusIOName(globus_io_attr_set_secure_delegation_mode); - + GlobusLIOCheckAttr(attr, GLOBUS_I_IO_TCP_ATTR); - + return globus_xio_attr_cntl( - (*attr)->attr, - globus_l_io_gsi_driver, + (*attr)->attr, + globus_l_io_gsi_driver, GLOBUS_XIO_GSI_SET_DELEGATION_MODE, mode); } @@ -5170,13 +5165,13 @@ globus_io_attr_get_secure_delegation_mode( mode) { GlobusIOName(globus_io_attr_set_secure_delegation_mode); - + GlobusLIOCheckAttr(attr, GLOBUS_I_IO_TCP_ATTR); GlobusLIOCheckNullParam(mode); - + return globus_xio_attr_cntl( - (*attr)->attr, - globus_l_io_gsi_driver, + (*attr)->attr, + globus_l_io_gsi_driver, GLOBUS_XIO_GSI_GET_DELEGATION_MODE, mode); } @@ -5187,12 +5182,12 @@ globus_io_attr_set_secure_proxy_mode( globus_io_secure_proxy_mode_t mode) { GlobusIOName(globus_io_attr_set_secure_proxy_mode); - + GlobusLIOCheckAttr(attr, GLOBUS_I_IO_TCP_ATTR); - + return globus_xio_attr_cntl( - (*attr)->attr, - globus_l_io_gsi_driver, + (*attr)->attr, + globus_l_io_gsi_driver, GLOBUS_XIO_GSI_SET_PROXY_MODE, mode); } @@ -5203,13 +5198,13 @@ globus_io_attr_get_secure_proxy_mode( globus_io_secure_proxy_mode_t * mode) { GlobusIOName(globus_io_attr_get_secure_proxy_mode); - + GlobusLIOCheckAttr(attr, GLOBUS_I_IO_TCP_ATTR); GlobusLIOCheckNullParam(mode); - + return globus_xio_attr_cntl( - (*attr)->attr, - globus_l_io_gsi_driver, + (*attr)->attr, + globus_l_io_gsi_driver, GLOBUS_XIO_GSI_GET_PROXY_MODE, mode); } diff --git a/myproxy/source/certauth_extensions.c b/myproxy/source/certauth_extensions.c index 14af33e542..47a12116a3 100644 --- a/myproxy/source/certauth_extensions.c +++ b/myproxy/source/certauth_extensions.c @@ -43,10 +43,10 @@ RSA_get0_key(const RSA *r, const BIGNUM **n, const BIGNUM **e, const BIGNUM **d) #endif -static int +static int read_cert_request(GSI_SOCKET *self, - unsigned char **buffer, - size_t *length) { + unsigned char **buffer, + size_t *length) { int return_value = 1; unsigned char * input_buffer = NULL; @@ -58,7 +58,7 @@ read_cert_request(GSI_SOCKET *self, } if (GSI_SOCKET_read_token(self, &input_buffer, - &input_buffer_length) == GSI_SOCKET_ERROR) { + &input_buffer_length) == GSI_SOCKET_ERROR) { verror_put_string("read_cert_request(): Read from socket failed"); goto error; } @@ -81,13 +81,13 @@ read_cert_request(GSI_SOCKET *self, } -static int +static int send_certificate(GSI_SOCKET *self, - unsigned char *buffer, - size_t length) { + unsigned char *buffer, + size_t length) { - if (GSI_SOCKET_write_buffer(self, (const char *)buffer, - length) == GSI_SOCKET_ERROR) { + if (GSI_SOCKET_write_buffer(self, (const char *)buffer, + length) == GSI_SOCKET_ERROR) { verror_put_string("Error writing certificate to client!"); return 1; } @@ -96,7 +96,7 @@ send_certificate(GSI_SOCKET *self, } -static void +static void add_key_value( char * key, char * value, char buffer[] ) { strcat( buffer, key ); @@ -110,11 +110,11 @@ add_key_value( char * key, char * value, char buffer[] ) { } -static int -external_callout( X509_REQ *request, - X509 **cert, - myproxy_request_t *client_request, - myproxy_server_context_t *server_context) { +static int +external_callout( X509_REQ *request, + X509 **cert, + myproxy_request_t *client_request, + myproxy_server_context_t *server_context) { int return_value = 1; @@ -131,12 +131,12 @@ external_callout( X509_REQ *request, memset(buffer, '\0', BUF_SIZE); memset(intbuf, '\0', 128); - myproxy_debug("callout using: %s", - server_context->certificate_issuer_program); + myproxy_debug("callout using: %s", + server_context->certificate_issuer_program); if ((pid = myproxy_popen(fds, - server_context->certificate_issuer_program, - NULL)) < 0) { + server_context->certificate_issuer_program, + NULL)) < 0) { return -1; /* myproxy_popen will set verror */ } @@ -162,7 +162,7 @@ external_callout( X509_REQ *request, add_key_value( "authzcreds", client_request->authzcreds, buffer ); add_key_value( "keyretrieve", client_request->keyretrieve, buffer ); add_key_value( "trusted_retrievers", client_request->trusted_retrievers, - buffer ); + buffer ); sprintf( intbuf, "%d", server_context->max_cert_lifetime ); add_key_value( "max_cert_lifetime", (char*)intbuf, buffer ); @@ -253,10 +253,10 @@ lock_file(int fd) while( fcntl( fd, F_SETLKW, &fl ) < 0 ) { - if ( errno != EINTR ) - { - return -1; - } + if ( errno != EINTR ) + { + return -1; + } } return 0; } @@ -266,9 +266,9 @@ lock_file(int fd) * of file locking */ -static int -assign_serial_number( X509 *cert, - myproxy_server_context_t *server_context ) { +static int +assign_serial_number( X509 *cert, + myproxy_server_context_t *server_context ) { int retval = 1; long serialset; @@ -301,7 +301,7 @@ assign_serial_number( X509 *cert, const char *sdir; sdir = myproxy_get_storage_dir(); if (sdir == NULL) { - goto error; + goto error; } serialfile = malloc(strlen(sdir)+strlen("/serial")+1); sprintf(serialfile, "%s/serial", sdir); @@ -351,17 +351,17 @@ assign_serial_number( X509 *cert, if (serialset) { if (!a2i_ASN1_INTEGER(serialbio, current, buf, sizeof(buf))) { - verror_put_string("Asn1 int read/conversion error\n"); + verror_put_string("Asn1 int read/conversion error\n"); ssl_error_to_verror(); - goto error; + goto error; } else { - myproxy_debug("Loaded serial number 0x%s from %s", buf, serialfile); + myproxy_debug("Loaded serial number 0x%s from %s", buf, serialfile); } } else { ASN1_INTEGER_set(current, server_context->certificate_serial_skip); } - serial = BN_bin2bn( current->data, current->length, serial ); + serial = BN_bin2bn( ASN1_STRING_get0_data(current), ASN1_STRING_length(current), serial ); if ( serial == NULL ) { verror_put_string("Error converting to bignum\n"); ssl_error_to_verror(); @@ -393,7 +393,7 @@ assign_serial_number( X509 *cert, * the underlying file stream and close()ing the file descriptor, * which will release the lock. */ - + BIO_free(serialbio); serialbio = NULL; serialstream = NULL; @@ -447,7 +447,7 @@ write_certificate(X509 *cert, const char serial[], const char dir[]) { goto error; } close(fd); - if ((bp=BIO_new(BIO_s_file())) == NULL) { + if ((bp=BIO_new(BIO_s_file())) == NULL) { myproxy_debug("BIO_new(BIO_s_file()) failed"); goto error; } @@ -463,7 +463,7 @@ write_certificate(X509 *cert, const char serial[], const char dir[]) { error: free(path); - BIO_free_all(bp); + BIO_free_all(bp); return rval; } @@ -474,14 +474,14 @@ static ENGINE *engine=NULL; static int engine_used=0; #endif -static int -generate_certificate( X509_REQ *request, - X509 **certificate, - EVP_PKEY *pkey, - myproxy_request_t *client_request, - myproxy_server_context_t *server_context) { +static int +generate_certificate( X509_REQ *request, + X509 **certificate, + EVP_PKEY *pkey, + myproxy_request_t *client_request, + myproxy_server_context_t *server_context) { - int return_value = 1; + int return_value = 1; int not_after; int lockfd = -1; int i; @@ -503,7 +503,7 @@ generate_certificate( X509_REQ *request, cert = X509_new(); - ctxp = &ctx; /* needed for X509V3 macros */ + ctxp = &ctx; /* needed for X509V3 macros */ X509V3_set_ctx_nodb(ctxp); if (cert == NULL) { @@ -517,12 +517,12 @@ generate_certificate( X509_REQ *request, /* this has already been called successfully, but... */ if ( user_dn_lookup( client_request->username, &userdn, - server_context ) ) { + server_context ) ) { verror_put_string("unknown username: %s", client_request->username); goto error; } - subject = X509_get_subject_name(cert); + subject = X509_NAME_dup(X509_get_subject_name(cert)); globus_result = globus_gsi_cert_utils_get_x509_name(userdn, strlen(userdn), subject); @@ -536,23 +536,21 @@ generate_certificate( X509_REQ *request, problems we find.*/ for (i = 0; i < X509_NAME_entry_count(subject); i++) { - X509_NAME_ENTRY *ne = NULL; - ASN1_STRING *str = NULL; - ASN1_OBJECT *obj = NULL; + const X509_NAME_ENTRY *ne = NULL; + const ASN1_STRING *str = NULL; + const ASN1_OBJECT *obj = NULL; ne = X509_NAME_get_entry(subject, i); str = X509_NAME_ENTRY_get_data(ne); obj = X509_NAME_ENTRY_get_object(ne); if ((OBJ_obj2nid(obj) == NID_domainComponent) && - (str->type == V_ASN1_PRINTABLESTRING)) { - myproxy_debug("Setting DC type to IA5String."); - str->type = V_ASN1_IA5STRING; + (ASN1_STRING_type(str) == V_ASN1_PRINTABLESTRING)) { + myproxy_debug("Can't set DC type to IA5String."); } if ((OBJ_obj2nid(obj) == NID_pkcs9_emailAddress) && - (str->type == V_ASN1_PRINTABLESTRING)) { - myproxy_debug("Setting emailAddress type to IA5String."); - str->type = V_ASN1_IA5STRING; + (ASN1_STRING_type(str) == V_ASN1_PRINTABLESTRING)) { + myproxy_debug("Can't set emailAddress type to IA5String."); } } @@ -561,16 +559,19 @@ generate_certificate( X509_REQ *request, issuer_cert_file = fopen(server_context->certificate_issuer_cert, "r"); if (issuer_cert_file == NULL) { verror_put_string("Error opening certificate file %s", - server_context->certificate_issuer_cert); + server_context->certificate_issuer_cert); verror_put_errno(errno); goto error; } - + + X509_set_subject_name(cert, subject); + X509_NAME_free(subject); + if ((issuer_cert = PEM_read_X509(issuer_cert_file, - NULL, NULL, NULL)) == NULL) + NULL, NULL, NULL)) == NULL) { verror_put_string("Error reading certificate %s", - server_context->certificate_issuer_cert); + server_context->certificate_issuer_cert); ssl_error_to_verror(); fclose(issuer_cert_file); goto error; @@ -595,10 +596,10 @@ generate_certificate( X509_REQ *request, if (!server_context->max_cert_lifetime) { not_after = MIN(client_request->proxy_lifetime, - SECONDS_PER_HOUR * MYPROXY_DEFAULT_DELEG_HOURS); + SECONDS_PER_HOUR * MYPROXY_DEFAULT_DELEG_HOURS); } else { not_after = MIN(client_request->proxy_lifetime, - server_context->max_cert_lifetime); + server_context->max_cert_lifetime); } myproxy_debug("cert lifetime: %d", not_after ); @@ -606,7 +607,7 @@ generate_certificate( X509_REQ *request, /* allow 5m clock skew */ X509_gmtime_adj(X509_get_notBefore(cert), -(MYPROXY_DEFAULT_CLOCK_SKEW)); X509_gmtime_adj(X509_get_notAfter(cert), (long)not_after); - + X509_set_pubkey(cert, pkey); /* extensions */ @@ -617,77 +618,77 @@ generate_certificate( X509_REQ *request, long errorline = -1; extconf = NCONF_new(NULL); if (server_context->certificate_extfile) { - if (NCONF_load(extconf, server_context->certificate_extfile, - &errorline) <= 0) { - if (errorline <= 0) { - verror_put_string("OpenSSL error loading the certificate_extfile '%s'", server_context->certificate_extfile); - } else { - verror_put_string("OpenSSL error on line %ld of certificate_extfile '%s'\n", errorline, server_context->certificate_extfile); - } - goto error; - } - myproxy_debug("Successfully loaded extensions file %s.", - server_context->certificate_extfile); + if (NCONF_load(extconf, server_context->certificate_extfile, + &errorline) <= 0) { + if (errorline <= 0) { + verror_put_string("OpenSSL error loading the certificate_extfile '%s'", server_context->certificate_extfile); + } else { + verror_put_string("OpenSSL error on line %ld of certificate_extfile '%s'\n", errorline, server_context->certificate_extfile); + } + goto error; + } + myproxy_debug("Successfully loaded extensions file %s.", + server_context->certificate_extfile); } else { - pid_t childpid; - int fds[3]; - int exit_status; - FILE *nconf_stream = NULL; - myproxy_debug("calling %s", server_context->certificate_extapp); - if ((childpid = myproxy_popen(fds, - server_context->certificate_extapp, - client_request->username, - NULL)) < 0) { - return -1; /* myproxy_popen will set verror */ - } - close(fds[0]); - if (waitpid(childpid, &exit_status, 0) == -1) { - verror_put_string("wait() failed for extapp child"); - verror_put_errno(errno); - return -1; - } - if (exit_status != 0) { - FILE *fp = NULL; - char buf[100]; - verror_put_string("Certificate extension call-out returned non-zero."); - fp = fdopen(fds[1], "r"); - if (fp) { - while (fgets(buf, 100, fp) != NULL) { - verror_put_string("%s", buf); - } - fclose(fp); - } - fp = fdopen(fds[2], "r"); - if (fp) { - while (fgets(buf, 100, fp) != NULL) { - verror_put_string("%s", buf); - } - fclose(fp); - } - goto error; - } - close(fds[2]); - nconf_stream = fdopen(fds[1], "r"); - if (NCONF_load_fp(extconf, nconf_stream, &errorline) <= 0) { - if (errorline <= 0) { - verror_put_string("OpenSSL error parsing output of certificate_extapp call-out."); - } else { - verror_put_string("OpenSSL error parsing line %ld of of certificate_extapp call-out output.", errorline); - } - fclose(nconf_stream); - goto error; - } - fclose(nconf_stream); + pid_t childpid; + int fds[3]; + int exit_status; + FILE *nconf_stream = NULL; + myproxy_debug("calling %s", server_context->certificate_extapp); + if ((childpid = myproxy_popen(fds, + server_context->certificate_extapp, + client_request->username, + NULL)) < 0) { + return -1; /* myproxy_popen will set verror */ + } + close(fds[0]); + if (waitpid(childpid, &exit_status, 0) == -1) { + verror_put_string("wait() failed for extapp child"); + verror_put_errno(errno); + return -1; + } + if (exit_status != 0) { + FILE *fp = NULL; + char buf[100]; + verror_put_string("Certificate extension call-out returned non-zero."); + fp = fdopen(fds[1], "r"); + if (fp) { + while (fgets(buf, 100, fp) != NULL) { + verror_put_string("%s", buf); + } + fclose(fp); + } + fp = fdopen(fds[2], "r"); + if (fp) { + while (fgets(buf, 100, fp) != NULL) { + verror_put_string("%s", buf); + } + fclose(fp); + } + goto error; + } + close(fds[2]); + nconf_stream = fdopen(fds[1], "r"); + if (NCONF_load_fp(extconf, nconf_stream, &errorline) <= 0) { + if (errorline <= 0) { + verror_put_string("OpenSSL error parsing output of certificate_extapp call-out."); + } else { + verror_put_string("OpenSSL error parsing line %ld of of certificate_extapp call-out output.", errorline); + } + fclose(nconf_stream); + goto error; + } + fclose(nconf_stream); } X509V3_set_nconf(&ctx, extconf); if (!X509V3_EXT_add_nconf(extconf, &ctx, "default", cert)) { - verror_put_string("OpenSSL error adding extensions."); + verror_put_string("OpenSSL error adding extensions."); ssl_error_to_verror(); - goto error; + goto error; } myproxy_debug("Successfully added extensions."); - } else { /* add some defaults */ + } else { /* add some defaults */ add_ext(ctxp, cert, NID_key_usage, "critical,Digital Signature, Key Encipherment, Data Encipherment"); add_ext(ctxp, cert, NID_ext_key_usage, "clientAuth"); add_ext(ctxp, cert, NID_basic_constraints, "critical,CA:FALSE"); @@ -696,9 +697,9 @@ generate_certificate( X509_REQ *request, if (server_context->certificate_issuer_email_domain) { char *email; email = malloc(strlen(client_request->username)+strlen("email:@")+1+ - strlen(server_context->certificate_issuer_email_domain)); + strlen(server_context->certificate_issuer_email_domain)); sprintf(email, "email:%s@%s", client_request->username, - server_context->certificate_issuer_email_domain); + server_context->certificate_issuer_email_domain); add_ext(ctxp, cert, NID_subject_alt_name, email); free(email); } @@ -739,13 +740,13 @@ generate_certificate( X509_REQ *request, if (!inkey) { verror_put_string("Could not open cakey file handle: %s", - server_context->certificate_issuer_key); + server_context->certificate_issuer_key); verror_put_errno(errno); goto error; } cakey = PEM_read_PrivateKey( inkey, NULL, NULL, - (char *)server_context->certificate_issuer_key_passphrase ); + (char *)server_context->certificate_issuer_key_passphrase ); fclose(inkey); } @@ -774,7 +775,7 @@ generate_certificate( X509_REQ *request, verror_put_string("Certificate/cakey sign failed."); ssl_error_to_verror(); goto error; - } + } serial = i2s_ASN1_OCTET_STRING(NULL, X509_get_serialNumber(cert)); #ifndef OPENSSL_NO_ENGINE if (engine) { @@ -794,7 +795,7 @@ generate_certificate( X509_REQ *request, myproxy_log("Issued certificate for user \"%s\", with DN \"%s\", " "lifetime \"%d\", and serial number \"0x%s\"", - client_request->username, userdn, + client_request->username, userdn, not_after, serial ); @@ -824,7 +825,8 @@ generate_certificate( X509_REQ *request, } -static int +#ifndef OPENSSL_NO_ENGINE +static int arraylen(char **options) { char **ptr; int c = 0; @@ -835,7 +837,6 @@ arraylen(char **options) { return c; } -#ifndef OPENSSL_NO_ENGINE void shutdown_openssl_engine(void) { if (e_cakey) EVP_PKEY_free( e_cakey ); if (engine) ENGINE_finish(engine); @@ -846,39 +847,37 @@ void shutdown_openssl_engine(void) { if (engine_used) ENGINE_cleanup(); } -#endif static int ui_read_fn(UI *ui, UI_STRING *ui_string) { switch(UI_get_string_type(ui_string)) { - case UIT_PROMPT: - case UIT_VERIFY: - if(UI_get_input_flags(ui_string) & UI_INPUT_FLAG_ECHO) { - UI_set_result(ui, ui_string, (char *) UI_get0_user_data(ui)); - return 1; - } else { + case UIT_PROMPT: + case UIT_VERIFY: + if(UI_get_input_flags(ui_string) & UI_INPUT_FLAG_ECHO) { + UI_set_result(ui, ui_string, (char *) UI_get0_user_data(ui)); + return 1; + } else { + return 0; /* not supported! */ + } + case UIT_BOOLEAN: + default: return 0; /* not supported! */ - } - case UIT_BOOLEAN: - default: - return 0; /* not supported! */ } } static int ui_write_fn(UI *ui, UI_STRING *ui_string) { switch(UI_get_string_type(ui_string)) { - case UIT_ERROR: - verror_put_string("%s", UI_get0_output_string(ui_string)); - break; - case UIT_INFO: - myproxy_log("%s", UI_get0_output_string(ui_string)); - break; - default: - break; + case UIT_ERROR: + verror_put_string("%s", UI_get0_output_string(ui_string)); + break; + case UIT_INFO: + myproxy_log("%s", UI_get0_output_string(ui_string)); + break; + default: + break; } return 1; } -#ifndef OPENSSL_NO_ENGINE int initialise_openssl_engine(myproxy_server_context_t *server_context) { ENGINE *e; EVP_PKEY *cakey; @@ -889,7 +888,7 @@ int initialise_openssl_engine(myproxy_server_context_t *server_context) { UI_method_set_reader(ui_method, ui_read_fn); UI_method_set_writer(ui_method, ui_write_fn); - SSL_load_error_strings(); + SSL_load_error_strings(); ENGINE_load_builtin_engines(); myproxy_log("Initialising OpenSSL signing engine '%s'....", engine_id); @@ -900,12 +899,12 @@ int initialise_openssl_engine(myproxy_server_context_t *server_context) { UI_destroy_method(ui_method); return 0; } - if(server_context->certificate_openssl_engine_pre) { - char **pre_cmds; - int pre_num; + if(server_context->certificate_openssl_engine_pre) { + char **pre_cmds; + int pre_num; pre_cmds = server_context->certificate_openssl_engine_pre; - pre_num = arraylen(pre_cmds); - while(pre_num--) { + pre_num = arraylen(pre_cmds); + while(pre_num--) { char *name, *value=NULL; char *n = strchr(pre_cmds[0], ':'); if(n==NULL) { @@ -915,19 +914,19 @@ int initialise_openssl_engine(myproxy_server_context_t *server_context) { name=pre_cmds[0]; value=n+1; } - if(!ENGINE_ctrl_cmd_string(e, name, value, 0)) { + if(!ENGINE_ctrl_cmd_string(e, name, value, 0)) { fprintf(stderr, "Failed pre command (%s - %s:%s)\n", engine_id, name, value ? value : "(NULL)"); ENGINE_free(e); ENGINE_cleanup(); - UI_destroy_method(ui_method); + UI_destroy_method(ui_method); return 0; - } - pre_cmds++; - } + } + pre_cmds++; + } } if(!ENGINE_init(e)) { - verror_put_string("Could not initialise engine '%s'.", engine_id); + verror_put_string("Could not initialise engine '%s'.", engine_id); ssl_error_to_verror(); ENGINE_free(e); ENGINE_cleanup(); @@ -958,7 +957,7 @@ int initialise_openssl_engine(myproxy_server_context_t *server_context) { engine_id, name, value ? value : "(NULL)"); ENGINE_free(e); ENGINE_cleanup(); - UI_destroy_method(ui_method); + UI_destroy_method(ui_method); return 0; } post_cmds++; @@ -967,31 +966,31 @@ int initialise_openssl_engine(myproxy_server_context_t *server_context) { cakey = ENGINE_load_private_key(e, server_context->certificate_issuer_key, ui_method, (char *)server_context->certificate_issuer_key_passphrase); - if (cakey == NULL) { /* may not be fatal... */ + if (cakey == NULL) { /* may not be fatal... */ verror_put_string("WARNING: Could not load ENGINE cakey at %s.", server_context->certificate_issuer_key); ssl_error_to_verror(); myproxy_log_verror(); verror_clear(); - } + } if(atexit(&shutdown_openssl_engine)!=0) { verror_put_string("Could not register shutdown handler for engine '%s'.", engine_id); - if (cakey) EVP_PKEY_free( cakey ); + if (cakey) EVP_PKEY_free( cakey ); ENGINE_finish(e); ENGINE_cleanup(); UI_destroy_method(ui_method); return 0; - } + } myproxy_log("Initialised engine '%s' (CAKey=%s)", engine_id, server_context->certificate_issuer_key); - /* Share with the other functions in this module. */ - e_cakey = cakey; - engine = e; + /* Share with the other functions in this module. */ + e_cakey = cakey; + engine = e; - UI_destroy_method(ui_method); - return 1; + UI_destroy_method(ui_method); + return 1; } #endif @@ -1067,13 +1066,13 @@ check_newcert(const char *callout, const X509 *cert) return do_check(callout, NULL, cert); } -static int +static int handle_certificate(unsigned char *input_buffer, - size_t input_buffer_length, - unsigned char **output_buffer, - int *output_buffer_length, - myproxy_request_t *client_request, - myproxy_server_context_t *server_context) { + size_t input_buffer_length, + unsigned char **output_buffer, + int *output_buffer_length, + myproxy_request_t *client_request, + myproxy_server_context_t *server_context) { int return_value = 1; int verify; @@ -1122,7 +1121,7 @@ handle_certificate(unsigned char *input_buffer, verror_put_string("Could not extract public key from request."); ssl_error_to_verror(); goto error; - } + } if (EVP_PKEY_id(pkey) != EVP_PKEY_RSA) { verror_put_string("Public key in certificate request is not of type RSA."); @@ -1155,15 +1154,15 @@ handle_certificate(unsigned char *input_buffer, verror_put_string("Req/key did not verify: %d", verify ); ssl_error_to_verror(); goto error; - } + } /* convert pkey into string for output to log */ ASN1_digest((i2d_of_void*)i2d_PUBKEY, EVP_sha1(), (char*)pkey, md, &md_len); - sub_hash = md[0] + (md[1] + (md[2] + (md[3] >> 1) * 256) * 256) * 256; + sub_hash = md[0] + (md[1] + (md[2] + (md[3] >> 1) * 256) * 256) * 256; myproxy_log("Got a cert request for user \"%s\", " "with pubkey hash \"0x%lx\", and lifetime \"%d\"", - client_request->username, + client_request->username, sub_hash, client_request->proxy_lifetime ); @@ -1177,30 +1176,30 @@ handle_certificate(unsigned char *input_buffer, * these checks are duplicated in check_config(). */ - if ( ( server_context->certificate_issuer_program != NULL ) && + if ( ( server_context->certificate_issuer_program != NULL ) && ( server_context->certificate_issuer_cert != NULL ) ) { verror_put_string("CA config error: both issuer and program defined"); goto error; - } + } - if ( ( server_context->certificate_issuer_program == NULL ) && + if ( ( server_context->certificate_issuer_program == NULL ) && ( server_context->certificate_issuer_cert == NULL ) ) { verror_put_string("CA config error: neither issuer or program defined"); goto error; } - if ( ( server_context->certificate_issuer_cert != NULL ) && + if ( ( server_context->certificate_issuer_cert != NULL ) && ( server_context->certificate_issuer_key == NULL ) ) { verror_put_string("CA config error: issuer defined but no key defined"); goto error; } - if ( ( server_context->certificate_issuer_cert != NULL ) && + if ( ( server_context->certificate_issuer_cert != NULL ) && ( server_context->certificate_issuer_key != NULL ) ) { myproxy_debug("Using internal openssl/generate_certificate() code"); - if ( generate_certificate( req, &cert, pkey, - client_request, server_context ) ) { + if ( generate_certificate( req, &cert, pkey, + client_request, server_context ) ) { verror_put_string("Internal cert generation failed"); goto error; } @@ -1283,16 +1282,16 @@ int is_certificate_authority_configured(myproxy_server_context_t } -void get_certificate_authority(myproxy_socket_attrs_t *server_attrs, - myproxy_creds_t *creds, - myproxy_request_t *client_request, - myproxy_response_t *response, - myproxy_server_context_t *server_context) { +void get_certificate_authority(myproxy_socket_attrs_t *server_attrs, + myproxy_creds_t *creds, + myproxy_request_t *client_request, + myproxy_response_t *response, + myproxy_server_context_t *server_context) { unsigned char * input_buffer = NULL; - size_t input_buffer_length; - unsigned char * output_buffer = NULL; - int output_buffer_length; + size_t input_buffer_length; + unsigned char * output_buffer = NULL; + int output_buffer_length; myproxy_debug("Calling CA Extensions"); @@ -1300,8 +1299,8 @@ void get_certificate_authority(myproxy_socket_attrs_t *server_attrs, verror_clear(); - if ( read_cert_request( server_attrs->gsi_socket, - &input_buffer, &input_buffer_length) ) { + if ( read_cert_request( server_attrs->gsi_socket, + &input_buffer, &input_buffer_length) ) { verror_put_string("Unable to read request from client"); myproxy_log_verror(); response->error_string = \ @@ -1310,8 +1309,8 @@ void get_certificate_authority(myproxy_socket_attrs_t *server_attrs, } if ( handle_certificate( input_buffer, input_buffer_length, - &output_buffer, &output_buffer_length, - client_request, server_context ) ) { + &output_buffer, &output_buffer_length, + client_request, server_context ) ) { verror_put_string("CA failed to generate certificate"); response->error_string = strdup("Certificate generation failure.\n"); myproxy_log_verror(); @@ -1319,7 +1318,7 @@ void get_certificate_authority(myproxy_socket_attrs_t *server_attrs, } if ( send_certificate( server_attrs->gsi_socket, - output_buffer, output_buffer_length ) ) { + output_buffer, output_buffer_length ) ) { myproxy_log_verror(); myproxy_debug("Failure to send response to client!"); goto error; diff --git a/myproxy/source/configure.ac b/myproxy/source/configure.ac index 032b40c71b..802618ce88 100644 --- a/myproxy/source/configure.ac +++ b/myproxy/source/configure.ac @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_INIT([myproxy],[6.2.20]) +AC_INIT([myproxy],[6.2.21]) AC_CONFIG_AUX_DIR([build-aux]) AM_INIT_AUTOMAKE([foreign]) LT_INIT([dlopen win32-dll]) diff --git a/myproxy/source/gssapi.c b/myproxy/source/gssapi.c index e176392e4e..e78229f4eb 100644 --- a/myproxy/source/gssapi.c +++ b/myproxy/source/gssapi.c @@ -4,7 +4,7 @@ * Rob Siemborski (SASL v2 Conversion) * $Id: gssapi.c,v 1.9 2007/09/27 15:40:54 basney Exp $ */ -/* +/* * Copyright (c) 1998-2003 Carnegie Mellon University. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -12,7 +12,7 @@ * are met: * * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in @@ -22,7 +22,7 @@ * 3. The name "Carnegie Mellon University" must not be used to * endorse or promote products derived from this software without * prior written permission. For permission or any other legal - * details, please contact + * details, please contact * Office of Technology Transfer * Carnegie Mellon University * 5000 Forbes Avenue @@ -96,25 +96,25 @@ extern gss_OID gss_nt_service_name; #ifdef WANT_KERBEROS5_3DES /* Check if CyberSafe flag is defined */ #ifdef CSF_GSS_C_DES3_FLAG -#define K5_MAX_SSF 112 +#define K5_MAX_SSF 112 #endif /* Heimdal and MIT use the following */ #ifdef GSS_KRB5_CONF_C_QOP_DES3_KD -#define K5_MAX_SSF 112 +#define K5_MAX_SSF 112 #endif #endif #ifndef K5_MAX_SSF /* All Kerberos implementations support DES */ -#define K5_MAX_SSF 56 +#define K5_MAX_SSF 56 #endif /* GSSAPI SASL Mechanism by Leif Johansson * inspired by the kerberos mechanism and the gssapi_server and * gssapi_client from the heimdal distribution by Assar Westerlund - * and Johan Danielsson . + * and Johan Danielsson . * See the configure.in file for details on dependencies. * * Important contributions from Sam Hartman . @@ -126,18 +126,18 @@ extern gss_OID gss_nt_service_name; typedef struct context { int state; - + gss_ctx_id_t gss_ctx; gss_name_t client_name; gss_name_t server_name; gss_cred_id_t server_creds; sasl_ssf_t limitssf, requiressf; /* application defined bounds, for the - server */ + server */ const sasl_utils_t *utils; - + /* layers buffering */ decode_context_t decode_context; - + char *encode_buf; /* For encoding/decoding mem management */ char *decode_buf; char *decode_once_buf; @@ -145,10 +145,10 @@ typedef struct context { unsigned decode_buf_len; unsigned decode_once_buf_len; buffer_info_t *enc_in_buf; - + char *out_buf; /* per-step mem management */ - unsigned out_buf_len; - + unsigned out_buf_len; + char *authid; /* hold the authid between steps - server */ const char *user; /* hold the userid between steps - client */ } context_t; @@ -210,7 +210,7 @@ static OM_uint32 (*p_krb5_gss_wrap_size_limit) (OM_uint32 *, gss_ctx_id_t, int, gss_qop_t, OM_uint32, OM_uint32 *); static OM_uint32 (*p_krb5_gss_add_cred) (OM_uint32 *, gss_cred_id_t, gss_name_t, gss_OID, gss_cred_usage_t, - OM_uint32, OM_uint32, gss_cred_id_t *, gss_OID_set *, OM_uint32 *, + OM_uint32, OM_uint32, gss_cred_id_t *, gss_OID_set *, OM_uint32 *, OM_uint32 *); static OM_uint32 (*p_krb5_gss_seal) (OM_uint32 *, gss_ctx_id_t, int, int, gss_buffer_t, int *, @@ -226,15 +226,15 @@ sasl_gss_lib_init(const sasl_utils_t *utils) if (h_krb5lib) return SASL_OK; if ((h_krb5lib = dlopen(KRB5_LIB_NAME, RTLD_LAZY)) == NULL) { - errmsg = "Failed to open GSSAPI library"; - goto error; + errmsg = "Failed to open GSSAPI library"; + goto error; } -#define SASL_GSS_DLSYM(x) \ - p_krb5_ ## x = dlsym(h_krb5lib, #x); \ - if (p_krb5_ ## x == NULL) { \ - errmsg = "Failed to dlsym(" #x ")"; \ - goto error; \ +#define SASL_GSS_DLSYM(x) \ + p_krb5_ ## x = dlsym(h_krb5lib, #x); \ + if (p_krb5_ ## x == NULL) { \ + errmsg = "Failed to dlsym(" #x ")"; \ + goto error; \ } SASL_GSS_DLSYM(gss_accept_sec_context); @@ -261,24 +261,24 @@ sasl_gss_lib_init(const sasl_utils_t *utils) error: dlerr = dlerror(); if (dlerr) { - char *saslerr; - saslerr = malloc(strlen(errmsg)+strlen(dlerr)+3); - sprintf(saslerr, "%s: %s", errmsg, dlerr); - SETERROR(utils, saslerr); - free(saslerr); + char *saslerr; + saslerr = malloc(strlen(errmsg)+strlen(dlerr)+3); + sprintf(saslerr, "%s: %s", errmsg, dlerr); + SETERROR(utils, saslerr); + free(saslerr); } else { - SETERROR(utils, errmsg); + SETERROR(utils, errmsg); } if (h_krb5lib) { - dlclose(h_krb5lib); - h_krb5lib = NULL; + dlclose(h_krb5lib); + h_krb5lib = NULL; } return SASL_FAIL; } static void sasl_gss_seterror_(const sasl_utils_t *utils, OM_uint32 maj, OM_uint32 min, - int logonly) + int logonly) { OM_uint32 maj_stat, min_stat; gss_buffer_desc msg; @@ -288,116 +288,116 @@ sasl_gss_seterror_(const sasl_utils_t *utils, OM_uint32 maj, OM_uint32 min, size_t len; unsigned int curlen = 0; const char prefix[] = "GSSAPI Error: "; - + if(!utils) return; if (sasl_gss_lib_init(utils) != SASL_OK) return; - + len = sizeof(prefix); ret = _plug_buf_alloc(utils, &out, &curlen, 256); if(ret != SASL_OK) return; - + strcpy(out, prefix); - + msg_ctx = 0; while (1) { - maj_stat = (*p_krb5_gss_display_status)(&min_stat, maj, - GSS_C_GSS_CODE, GSS_C_NULL_OID, - &msg_ctx, &msg); - if(GSS_ERROR(maj_stat)) { - if (logonly) { - utils->log(utils->conn, SASL_LOG_FAIL, - "GSSAPI Failure: (could not get major error message)"); - } else { - utils->seterror(utils->conn, 0, - "GSSAPI Failure " - "(could not get major error message)"); - } - utils->free(out); - return; - } - - len += len + msg.length; - ret = _plug_buf_alloc(utils, &out, &curlen, len); - - if(ret != SASL_OK) { - utils->free(out); - return; - } - - strcat(out, msg.value); - - (*p_krb5_gss_release_buffer)(&min_stat, &msg); - - if (!msg_ctx) - break; + maj_stat = (*p_krb5_gss_display_status)(&min_stat, maj, + GSS_C_GSS_CODE, GSS_C_NULL_OID, + &msg_ctx, &msg); + if(GSS_ERROR(maj_stat)) { + if (logonly) { + utils->log(utils->conn, SASL_LOG_FAIL, + "GSSAPI Failure: (could not get major error message)"); + } else { + utils->seterror(utils->conn, 0, + "GSSAPI Failure " + "(could not get major error message)"); + } + utils->free(out); + return; + } + + len += len + msg.length; + ret = _plug_buf_alloc(utils, &out, &curlen, len); + + if(ret != SASL_OK) { + utils->free(out); + return; + } + + strcat(out, msg.value); + + (*p_krb5_gss_release_buffer)(&min_stat, &msg); + + if (!msg_ctx) + break; } - + /* Now get the minor status */ - + len += 2; ret = _plug_buf_alloc(utils, &out, &curlen, len); if(ret != SASL_OK) { - utils->free(out); - return; + utils->free(out); + return; } - + strcat(out, " ("); - + msg_ctx = 0; while (1) { - maj_stat = (*p_krb5_gss_display_status)(&min_stat, min, - GSS_C_MECH_CODE, GSS_C_NULL_OID, - &msg_ctx, &msg); - if(GSS_ERROR(maj_stat)) { - if (logonly) { - utils->log(utils->conn, SASL_LOG_FAIL, - "GSSAPI Failure: (could not get minor error message)"); - } else { - utils->seterror(utils->conn, 0, - "GSSAPI Failure " - "(could not get minor error message)"); - } - utils->free(out); - return; - } - - len += len + msg.length; - ret = _plug_buf_alloc(utils, &out, &curlen, len); - - if(ret != SASL_OK) { - utils->free(out); - return; - } - - strcat(out, msg.value); - - (*p_krb5_gss_release_buffer)(&min_stat, &msg); - - if (!msg_ctx) - break; + maj_stat = (*p_krb5_gss_display_status)(&min_stat, min, + GSS_C_MECH_CODE, GSS_C_NULL_OID, + &msg_ctx, &msg); + if(GSS_ERROR(maj_stat)) { + if (logonly) { + utils->log(utils->conn, SASL_LOG_FAIL, + "GSSAPI Failure: (could not get minor error message)"); + } else { + utils->seterror(utils->conn, 0, + "GSSAPI Failure " + "(could not get minor error message)"); + } + utils->free(out); + return; + } + + len += len + msg.length; + ret = _plug_buf_alloc(utils, &out, &curlen, len); + + if(ret != SASL_OK) { + utils->free(out); + return; + } + + strcat(out, msg.value); + + (*p_krb5_gss_release_buffer)(&min_stat, &msg); + + if (!msg_ctx) + break; } - + len += 1; ret = _plug_buf_alloc(utils, &out, &curlen, len); if(ret != SASL_OK) { - utils->free(out); - return; + utils->free(out); + return; } - + strcat(out, ")"); - + if (logonly) { - utils->log(utils->conn, SASL_LOG_FAIL, "%s", out); + utils->log(utils->conn, SASL_LOG_FAIL, "%s", out); } else { - utils->seterror(utils->conn, 0, "%s", out); + utils->seterror(utils->conn, 0, "%s", out); } utils->free(out); } -static int +static int sasl_gss_encode(void *context, const struct iovec *invec, unsigned numiov, - const char **output, unsigned *outputlen, int privacy) + const char **output, unsigned *outputlen, int privacy) { context_t *text = (context_t *)context; OM_uint32 maj_stat, min_stat; @@ -405,244 +405,244 @@ sasl_gss_encode(void *context, const struct iovec *invec, unsigned numiov, gss_buffer_desc real_input_token, real_output_token; int ret; struct buffer_info *inblob, bufinfo; - + if(!output) return SASL_BADPARAM; - + if (sasl_gss_lib_init(text->utils) != SASL_OK) return SASL_FAIL; - + if(numiov > 1) { - ret = _plug_iovec_to_buf(text->utils, invec, numiov, &text->enc_in_buf); - if(ret != SASL_OK) return ret; - inblob = text->enc_in_buf; + ret = _plug_iovec_to_buf(text->utils, invec, numiov, &text->enc_in_buf); + if(ret != SASL_OK) return ret; + inblob = text->enc_in_buf; } else { - bufinfo.data = invec[0].iov_base; - bufinfo.curlen = invec[0].iov_len; - inblob = &bufinfo; + bufinfo.data = invec[0].iov_base; + bufinfo.curlen = invec[0].iov_len; + inblob = &bufinfo; } - + if (text->state != SASL_GSSAPI_STATE_AUTHENTICATED) return SASL_NOTDONE; - + input_token = &real_input_token; - + real_input_token.value = inblob->data; real_input_token.length = inblob->curlen; - + output_token = &real_output_token; output_token->value = NULL; output_token->length = 0; - + maj_stat = (*p_krb5_gss_wrap) (&min_stat, - text->gss_ctx, - privacy, - GSS_C_QOP_DEFAULT, - input_token, - NULL, - output_token); - + text->gss_ctx, + privacy, + GSS_C_QOP_DEFAULT, + input_token, + NULL, + output_token); + if (GSS_ERROR(maj_stat)) - { - sasl_gss_seterror(text->utils, maj_stat, min_stat); - if (output_token->value) - (*p_krb5_gss_release_buffer)(&min_stat, output_token); - return SASL_FAIL; - } - + { + sasl_gss_seterror(text->utils, maj_stat, min_stat); + if (output_token->value) + (*p_krb5_gss_release_buffer)(&min_stat, output_token); + return SASL_FAIL; + } + if (output_token->value && output) { - int len; - - ret = _plug_buf_alloc(text->utils, &(text->encode_buf), - &(text->encode_buf_len), output_token->length + 4); - - if (ret != SASL_OK) { - (*p_krb5_gss_release_buffer)(&min_stat, output_token); - return ret; - } - - len = htonl(output_token->length); - memcpy(text->encode_buf, &len, 4); - memcpy(text->encode_buf + 4, output_token->value, output_token->length); + int len; + + ret = _plug_buf_alloc(text->utils, &(text->encode_buf), + &(text->encode_buf_len), output_token->length + 4); + + if (ret != SASL_OK) { + (*p_krb5_gss_release_buffer)(&min_stat, output_token); + return ret; + } + + len = htonl(output_token->length); + memcpy(text->encode_buf, &len, 4); + memcpy(text->encode_buf + 4, output_token->value, output_token->length); } - + if (outputlen) { - *outputlen = output_token->length + 4; + *outputlen = output_token->length + 4; } - + *output = text->encode_buf; - + if (output_token->value) - (*p_krb5_gss_release_buffer)(&min_stat, output_token); - + (*p_krb5_gss_release_buffer)(&min_stat, output_token); + return SASL_OK; } static int gssapi_privacy_encode(void *context, const struct iovec *invec, - unsigned numiov, const char **output, - unsigned *outputlen) + unsigned numiov, const char **output, + unsigned *outputlen) { return sasl_gss_encode(context,invec,numiov,output,outputlen,1); } static int gssapi_integrity_encode(void *context, const struct iovec *invec, - unsigned numiov, const char **output, - unsigned *outputlen) + unsigned numiov, const char **output, + unsigned *outputlen) { return sasl_gss_encode(context,invec,numiov,output,outputlen,0); } static int gssapi_decode_packet(void *context, - const char *input, unsigned inputlen, - char **output, unsigned *outputlen) + const char *input, unsigned inputlen, + char **output, unsigned *outputlen) { context_t *text = (context_t *) context; OM_uint32 maj_stat, min_stat; gss_buffer_t input_token, output_token; gss_buffer_desc real_input_token, real_output_token; int result; - + if (sasl_gss_lib_init(text->utils) != SASL_OK) return SASL_FAIL; - + if (text->state != SASL_GSSAPI_STATE_AUTHENTICATED) { - SETERROR(text->utils, "GSSAPI Failure"); - return SASL_NOTDONE; + SETERROR(text->utils, "GSSAPI Failure"); + return SASL_NOTDONE; } - - input_token = &real_input_token; + + input_token = &real_input_token; real_input_token.value = (char *) input; real_input_token.length = inputlen; - + output_token = &real_output_token; output_token->value = NULL; output_token->length = 0; - + maj_stat = (*p_krb5_gss_unwrap) (&min_stat, - text->gss_ctx, - input_token, - output_token, - NULL, - NULL); - + text->gss_ctx, + input_token, + output_token, + NULL, + NULL); + if (GSS_ERROR(maj_stat)) - { - sasl_gss_seterror(text->utils,maj_stat,min_stat); - if (output_token->value) - (*p_krb5_gss_release_buffer)(&min_stat, output_token); - return SASL_FAIL; - } - + { + sasl_gss_seterror(text->utils,maj_stat,min_stat); + if (output_token->value) + (*p_krb5_gss_release_buffer)(&min_stat, output_token); + return SASL_FAIL; + } + if (outputlen) - *outputlen = output_token->length; - + *outputlen = output_token->length; + if (output_token->value) { - if (output) { - result = _plug_buf_alloc(text->utils, &text->decode_once_buf, - &text->decode_once_buf_len, - *outputlen); - if(result != SASL_OK) { - (*p_krb5_gss_release_buffer)(&min_stat, output_token); - return result; - } - *output = text->decode_once_buf; - memcpy(*output, output_token->value, *outputlen); - } - (*p_krb5_gss_release_buffer)(&min_stat, output_token); + if (output) { + result = _plug_buf_alloc(text->utils, &text->decode_once_buf, + &text->decode_once_buf_len, + *outputlen); + if(result != SASL_OK) { + (*p_krb5_gss_release_buffer)(&min_stat, output_token); + return result; + } + *output = text->decode_once_buf; + memcpy(*output, output_token->value, *outputlen); + } + (*p_krb5_gss_release_buffer)(&min_stat, output_token); } - + return SASL_OK; } static int gssapi_decode(void *context, - const char *input, unsigned inputlen, - const char **output, unsigned *outputlen) + const char *input, unsigned inputlen, + const char **output, unsigned *outputlen) { context_t *text = (context_t *) context; int ret; - + ret = _plug_decode(&text->decode_context, input, inputlen, - &text->decode_buf, &text->decode_buf_len, outputlen, - gssapi_decode_packet, text); - + &text->decode_buf, &text->decode_buf_len, outputlen, + gssapi_decode_packet, text); + *output = text->decode_buf; - + return ret; } static context_t *gss_new_context(const sasl_utils_t *utils) { context_t *ret; - + ret = utils->malloc(sizeof(context_t)); if(!ret) return NULL; - + memset(ret,0,sizeof(context_t)); ret->utils = utils; - + return ret; } static void sasl_gss_free_context_contents(context_t *text) { - OM_uint32 maj_stat, min_stat; - + OM_uint32 min_stat; + if (!text) return; - + if (sasl_gss_lib_init(text->utils) != SASL_OK) return; - + if (text->gss_ctx != GSS_C_NO_CONTEXT) { - maj_stat = (*p_krb5_gss_delete_sec_context)(&min_stat,&text->gss_ctx,GSS_C_NO_BUFFER); - text->gss_ctx = GSS_C_NO_CONTEXT; + (*p_krb5_gss_delete_sec_context)(&min_stat,&text->gss_ctx,GSS_C_NO_BUFFER); + text->gss_ctx = GSS_C_NO_CONTEXT; } - + if (text->client_name != GSS_C_NO_NAME) { - maj_stat = (*p_krb5_gss_release_name)(&min_stat,&text->client_name); - text->client_name = GSS_C_NO_NAME; + (*p_krb5_gss_release_name)(&min_stat,&text->client_name); + text->client_name = GSS_C_NO_NAME; } - + if (text->server_name != GSS_C_NO_NAME) { - maj_stat = (*p_krb5_gss_release_name)(&min_stat,&text->server_name); - text->server_name = GSS_C_NO_NAME; + (*p_krb5_gss_release_name)(&min_stat,&text->server_name); + text->server_name = GSS_C_NO_NAME; } - + if ( text->server_creds != GSS_C_NO_CREDENTIAL) { - maj_stat = (*p_krb5_gss_release_cred)(&min_stat, &text->server_creds); - text->server_creds = GSS_C_NO_CREDENTIAL; + (*p_krb5_gss_release_cred)(&min_stat, &text->server_creds); + text->server_creds = GSS_C_NO_CREDENTIAL; } if (text->out_buf) { - text->utils->free(text->out_buf); - text->out_buf = NULL; + text->utils->free(text->out_buf); + text->out_buf = NULL; } - + if (text->encode_buf) { - text->utils->free(text->encode_buf); - text->encode_buf = NULL; + text->utils->free(text->encode_buf); + text->encode_buf = NULL; } - + if (text->decode_buf) { - text->utils->free(text->decode_buf); - text->decode_buf = NULL; + text->utils->free(text->decode_buf); + text->decode_buf = NULL; } - + if (text->decode_once_buf) { - text->utils->free(text->decode_once_buf); - text->decode_once_buf = NULL; + text->utils->free(text->decode_once_buf); + text->decode_once_buf = NULL; } - + if (text->enc_in_buf) { - if(text->enc_in_buf->data) text->utils->free(text->enc_in_buf->data); - text->utils->free(text->enc_in_buf); - text->enc_in_buf = NULL; + if(text->enc_in_buf->data) text->utils->free(text->enc_in_buf->data); + text->utils->free(text->enc_in_buf); + text->enc_in_buf = NULL; } _plug_decode_free(&text->decode_context); - + if (text->authid) { /* works for both client and server */ - text->utils->free(text->authid); - text->authid = NULL; + text->utils->free(text->authid); + text->authid = NULL; } } static void gssapi_common_mech_dispose(void *conn_context, - const sasl_utils_t *utils) + const sasl_utils_t *utils) { sasl_gss_free_context_contents((context_t *)(conn_context)); utils->free(conn_context); @@ -650,40 +650,40 @@ static void gssapi_common_mech_dispose(void *conn_context, /***************************** Server Section *****************************/ -static int -gssapi_server_mech_new(void *glob_context __attribute__((unused)), - sasl_server_params_t *params, - const char *challenge __attribute__((unused)), - unsigned challen __attribute__((unused)), - void **conn_context) +static int +gssapi_server_mech_new(void *glob_context __attribute__((unused)), + sasl_server_params_t *params, + const char *challenge __attribute__((unused)), + unsigned challen __attribute__((unused)), + void **conn_context) { context_t *text; - + text = gss_new_context(params->utils); if (text == NULL) { - MEMERROR(params->utils); - return SASL_NOMEM; + MEMERROR(params->utils); + return SASL_NOMEM; } - + text->gss_ctx = GSS_C_NO_CONTEXT; text->client_name = GSS_C_NO_NAME; text->server_name = GSS_C_NO_NAME; text->server_creds = GSS_C_NO_CREDENTIAL; text->state = SASL_GSSAPI_STATE_AUTHNEG; - + *conn_context = text; - + return SASL_OK; } -static int +static int gssapi_server_mech_step(void *conn_context, - sasl_server_params_t *params, - const char *clientin, - unsigned clientinlen, - const char **serverout, - unsigned *serveroutlen, - sasl_out_params_t *oparams) + sasl_server_params_t *params, + const char *clientin, + unsigned clientinlen, + const char **serverout, + unsigned *serveroutlen, + sasl_out_params_t *oparams) { context_t *text = (context_t *)conn_context; gss_buffer_t input_token, output_token; @@ -692,257 +692,257 @@ gssapi_server_mech_step(void *conn_context, OM_uint32 max_input; gss_buffer_desc name_token; int ret; - + input_token = &real_input_token; output_token = &real_output_token; output_token->value = NULL; output_token->length = 0; input_token->value = NULL; input_token->length = 0; - + if(!serverout) { - PARAMERROR(text->utils); - return SASL_BADPARAM; + PARAMERROR(text->utils); + return SASL_BADPARAM; } - + *serverout = NULL; - *serveroutlen = 0; - + *serveroutlen = 0; + if (sasl_gss_lib_init(text->utils) != SASL_OK) return SASL_FAIL; - + switch (text->state) { case SASL_GSSAPI_STATE_AUTHNEG: - if (text->server_name == GSS_C_NO_NAME) { /* only once */ - name_token.length = strlen(params->service) + 1 + strlen(params->serverFQDN); - name_token.value = (char *)params->utils->malloc((name_token.length + 1) * sizeof(char)); - if (name_token.value == NULL) { - MEMERROR(text->utils); - sasl_gss_free_context_contents(text); - return SASL_NOMEM; - } - sprintf(name_token.value,"%s@%s", params->service, params->serverFQDN); - - maj_stat = (*p_krb5_gss_import_name) (&min_stat, - &name_token, - GSS_C_NT_HOSTBASED_SERVICE, - &text->server_name); - - params->utils->free(name_token.value); - name_token.value = NULL; - - if (GSS_ERROR(maj_stat)) { - sasl_gss_seterror(text->utils, maj_stat, min_stat); - sasl_gss_free_context_contents(text); - return SASL_FAIL; - } - - if ( text->server_creds != GSS_C_NO_CREDENTIAL) { - maj_stat = (*p_krb5_gss_release_cred)(&min_stat, &text->server_creds); - text->server_creds = GSS_C_NO_CREDENTIAL; - } - - maj_stat = (*p_krb5_gss_acquire_cred)(&min_stat, - text->server_name, - GSS_C_INDEFINITE, - GSS_C_NO_OID_SET, - GSS_C_ACCEPT, - &text->server_creds, - NULL, - NULL); - - if (GSS_ERROR(maj_stat)) { - sasl_gss_seterror(text->utils, maj_stat, min_stat); - sasl_gss_free_context_contents(text); - return SASL_FAIL; - } - } - - if (clientinlen) { - real_input_token.value = (void *)clientin; - real_input_token.length = clientinlen; - } - - - maj_stat = - (*p_krb5_gss_accept_sec_context)(&min_stat, - &(text->gss_ctx), - text->server_creds, - input_token, - GSS_C_NO_CHANNEL_BINDINGS, - &text->client_name, - NULL, - output_token, - NULL, - NULL, - NULL); - - if (GSS_ERROR(maj_stat)) { - sasl_gss_log(text->utils, maj_stat, min_stat); - text->utils->seterror(text->utils->conn, SASL_NOLOG, "GSSAPI Failure: gss_accept_sec_context"); - if (output_token->value) { - (*p_krb5_gss_release_buffer)(&min_stat, output_token); - } - sasl_gss_free_context_contents(text); - return SASL_BADAUTH; - } - - - if (serveroutlen) - *serveroutlen = output_token->length; - if (output_token->value) { - if (serverout) { - ret = _plug_buf_alloc(text->utils, &(text->out_buf), - &(text->out_buf_len), *serveroutlen); - if(ret != SASL_OK) { - (*p_krb5_gss_release_buffer)(&min_stat, output_token); - return ret; - } - memcpy(text->out_buf, output_token->value, *serveroutlen); - *serverout = text->out_buf; - } - - (*p_krb5_gss_release_buffer)(&min_stat, output_token); - } else { - /* No output token, send an empty string */ - *serverout = GSSAPI_BLANK_STRING; - serveroutlen = 0; - } - - if (maj_stat == GSS_S_COMPLETE) { - /* Switch to ssf negotiation */ - text->state = SASL_GSSAPI_STATE_SSFCAP; - } - - return SASL_CONTINUE; + if (text->server_name == GSS_C_NO_NAME) { /* only once */ + name_token.length = strlen(params->service) + 1 + strlen(params->serverFQDN); + name_token.value = (char *)params->utils->malloc((name_token.length + 1) * sizeof(char)); + if (name_token.value == NULL) { + MEMERROR(text->utils); + sasl_gss_free_context_contents(text); + return SASL_NOMEM; + } + sprintf(name_token.value,"%s@%s", params->service, params->serverFQDN); + + maj_stat = (*p_krb5_gss_import_name) (&min_stat, + &name_token, + GSS_C_NT_HOSTBASED_SERVICE, + &text->server_name); + + params->utils->free(name_token.value); + name_token.value = NULL; + + if (GSS_ERROR(maj_stat)) { + sasl_gss_seterror(text->utils, maj_stat, min_stat); + sasl_gss_free_context_contents(text); + return SASL_FAIL; + } + + if ( text->server_creds != GSS_C_NO_CREDENTIAL) { + maj_stat = (*p_krb5_gss_release_cred)(&min_stat, &text->server_creds); + text->server_creds = GSS_C_NO_CREDENTIAL; + } + + maj_stat = (*p_krb5_gss_acquire_cred)(&min_stat, + text->server_name, + GSS_C_INDEFINITE, + GSS_C_NO_OID_SET, + GSS_C_ACCEPT, + &text->server_creds, + NULL, + NULL); + + if (GSS_ERROR(maj_stat)) { + sasl_gss_seterror(text->utils, maj_stat, min_stat); + sasl_gss_free_context_contents(text); + return SASL_FAIL; + } + } + + if (clientinlen) { + real_input_token.value = (void *)clientin; + real_input_token.length = clientinlen; + } + + + maj_stat = + (*p_krb5_gss_accept_sec_context)(&min_stat, + &(text->gss_ctx), + text->server_creds, + input_token, + GSS_C_NO_CHANNEL_BINDINGS, + &text->client_name, + NULL, + output_token, + NULL, + NULL, + NULL); + + if (GSS_ERROR(maj_stat)) { + sasl_gss_log(text->utils, maj_stat, min_stat); + text->utils->seterror(text->utils->conn, SASL_NOLOG, "GSSAPI Failure: gss_accept_sec_context"); + if (output_token->value) { + (*p_krb5_gss_release_buffer)(&min_stat, output_token); + } + sasl_gss_free_context_contents(text); + return SASL_BADAUTH; + } + + + if (serveroutlen) + *serveroutlen = output_token->length; + if (output_token->value) { + if (serverout) { + ret = _plug_buf_alloc(text->utils, &(text->out_buf), + &(text->out_buf_len), *serveroutlen); + if(ret != SASL_OK) { + (*p_krb5_gss_release_buffer)(&min_stat, output_token); + return ret; + } + memcpy(text->out_buf, output_token->value, *serveroutlen); + *serverout = text->out_buf; + } + + (*p_krb5_gss_release_buffer)(&min_stat, output_token); + } else { + /* No output token, send an empty string */ + *serverout = GSSAPI_BLANK_STRING; + serveroutlen = 0; + } + + if (maj_stat == GSS_S_COMPLETE) { + /* Switch to ssf negotiation */ + text->state = SASL_GSSAPI_STATE_SSFCAP; + } + + return SASL_CONTINUE; case SASL_GSSAPI_STATE_SSFCAP: { - unsigned char sasldata[4]; - gss_buffer_desc name_token; - gss_buffer_desc name_without_realm; - gss_name_t without = NULL; - int equal; - - name_token.value = NULL; - name_without_realm.value = NULL; - - /* We ignore whatever the client sent us at this stage */ - - maj_stat = (*p_krb5_gss_display_name) (&min_stat, - text->client_name, - &name_token, - NULL); - - if (GSS_ERROR(maj_stat)) { - if (name_without_realm.value) - params->utils->free(name_without_realm.value); - - if (name_token.value) - (*p_krb5_gss_release_buffer)(&min_stat, &name_token); - if (without) - (*p_krb5_gss_release_name)(&min_stat, &without); - SETERROR(text->utils, "GSSAPI Failure"); - sasl_gss_free_context_contents(text); - return SASL_BADAUTH; - } - - /* If the id contains a realm get the identifier for the user - without the realm and see if it's the same id (i.e. - tmartin == tmartin@ANDREW.CMU.EDU. If this is the case we just want - to return the id (i.e. just "tmartin" */ - if (strchr((char *) name_token.value, (int) '@') != NULL) { - /* NOTE: libc malloc, as it is freed below by a gssapi internal - * function! */ - name_without_realm.value = malloc(strlen(name_token.value)+1); - if (name_without_realm.value == NULL) { - MEMERROR(text->utils); - return SASL_NOMEM; - } - - strcpy(name_without_realm.value, name_token.value); - - /* cut off string at '@' */ - (strchr(name_without_realm.value,'@'))[0] = '\0'; - - name_without_realm.length = strlen( (char *) name_without_realm.value ); - - maj_stat = (*p_krb5_gss_import_name) (&min_stat, - &name_without_realm, - /* Solaris 8/9 gss_import_name doesn't accept GSS_C_NULL_OID here, - so use GSS_C_NT_USER_NAME instead if available. */ + unsigned char sasldata[4]; + gss_buffer_desc name_token; + gss_buffer_desc name_without_realm; + gss_name_t without = NULL; + int equal; + + name_token.value = NULL; + name_without_realm.value = NULL; + + /* We ignore whatever the client sent us at this stage */ + + maj_stat = (*p_krb5_gss_display_name) (&min_stat, + text->client_name, + &name_token, + NULL); + + if (GSS_ERROR(maj_stat)) { + if (name_without_realm.value) + params->utils->free(name_without_realm.value); + + if (name_token.value) + (*p_krb5_gss_release_buffer)(&min_stat, &name_token); + if (without) + (*p_krb5_gss_release_name)(&min_stat, &without); + SETERROR(text->utils, "GSSAPI Failure"); + sasl_gss_free_context_contents(text); + return SASL_BADAUTH; + } + + /* If the id contains a realm get the identifier for the user + without the realm and see if it's the same id (i.e. + tmartin == tmartin@ANDREW.CMU.EDU. If this is the case we just want + to return the id (i.e. just "tmartin" */ + if (strchr((char *) name_token.value, (int) '@') != NULL) { + /* NOTE: libc malloc, as it is freed below by a gssapi internal + * function! */ + name_without_realm.value = malloc(strlen(name_token.value)+1); + if (name_without_realm.value == NULL) { + MEMERROR(text->utils); + return SASL_NOMEM; + } + + strcpy(name_without_realm.value, name_token.value); + + /* cut off string at '@' */ + (strchr(name_without_realm.value,'@'))[0] = '\0'; + + name_without_realm.length = strlen( (char *) name_without_realm.value ); + + maj_stat = (*p_krb5_gss_import_name) (&min_stat, + &name_without_realm, + /* Solaris 8/9 gss_import_name doesn't accept GSS_C_NULL_OID here, + so use GSS_C_NT_USER_NAME instead if available. */ #ifdef HAVE_GSS_C_NT_USER_NAME - GSS_C_NT_USER_NAME, + GSS_C_NT_USER_NAME, #else - GSS_C_NULL_OID, + GSS_C_NULL_OID, #endif - &without); - - if (GSS_ERROR(maj_stat)) { - params->utils->free(name_without_realm.value); - if (name_token.value) - (*p_krb5_gss_release_buffer)(&min_stat, &name_token); - if (without) - (*p_krb5_gss_release_name)(&min_stat, &without); - SETERROR(text->utils, "GSSAPI Failure"); - sasl_gss_free_context_contents(text); - return SASL_BADAUTH; - } - - maj_stat = (*p_krb5_gss_compare_name)(&min_stat, - text->client_name, - without, - &equal); - - if (GSS_ERROR(maj_stat)) { - params->utils->free(name_without_realm.value); - if (name_token.value) - (*p_krb5_gss_release_buffer)(&min_stat, &name_token); - if (without) - (*p_krb5_gss_release_name)(&min_stat, &without); - SETERROR(text->utils, "GSSAPI Failure"); - sasl_gss_free_context_contents(text); - return SASL_BADAUTH; - } - - (*p_krb5_gss_release_name)(&min_stat,&without); - } else { - equal = 0; - } - - if (equal) { - text->authid = strdup(name_without_realm.value); - - if (text->authid == NULL) { - MEMERROR(params->utils); - return SASL_NOMEM; - } - } else { - text->authid = strdup(name_token.value); - - if (text->authid == NULL) { - MEMERROR(params->utils); - return SASL_NOMEM; - } - } - - if (name_token.value) - (*p_krb5_gss_release_buffer)(&min_stat, &name_token); - if (name_without_realm.value) - params->utils->free(name_without_realm.value); - - - /* we have to decide what sort of encryption/integrity/etc., - we support */ - if (params->props.max_ssf < params->external_ssf) { - text->limitssf = 0; - } else { - text->limitssf = params->props.max_ssf - params->external_ssf; - } - if (params->props.min_ssf < params->external_ssf) { - text->requiressf = 0; - } else { - text->requiressf = params->props.min_ssf - params->external_ssf; - } - - /* build up our security properties token */ + &without); + + if (GSS_ERROR(maj_stat)) { + params->utils->free(name_without_realm.value); + if (name_token.value) + (*p_krb5_gss_release_buffer)(&min_stat, &name_token); + if (without) + (*p_krb5_gss_release_name)(&min_stat, &without); + SETERROR(text->utils, "GSSAPI Failure"); + sasl_gss_free_context_contents(text); + return SASL_BADAUTH; + } + + maj_stat = (*p_krb5_gss_compare_name)(&min_stat, + text->client_name, + without, + &equal); + + if (GSS_ERROR(maj_stat)) { + params->utils->free(name_without_realm.value); + if (name_token.value) + (*p_krb5_gss_release_buffer)(&min_stat, &name_token); + if (without) + (*p_krb5_gss_release_name)(&min_stat, &without); + SETERROR(text->utils, "GSSAPI Failure"); + sasl_gss_free_context_contents(text); + return SASL_BADAUTH; + } + + (*p_krb5_gss_release_name)(&min_stat,&without); + } else { + equal = 0; + } + + if (equal) { + text->authid = strdup(name_without_realm.value); + + if (text->authid == NULL) { + MEMERROR(params->utils); + return SASL_NOMEM; + } + } else { + text->authid = strdup(name_token.value); + + if (text->authid == NULL) { + MEMERROR(params->utils); + return SASL_NOMEM; + } + } + + if (name_token.value) + (*p_krb5_gss_release_buffer)(&min_stat, &name_token); + if (name_without_realm.value) + params->utils->free(name_without_realm.value); + + + /* we have to decide what sort of encryption/integrity/etc., + we support */ + if (params->props.max_ssf < params->external_ssf) { + text->limitssf = 0; + } else { + text->limitssf = params->props.max_ssf - params->external_ssf; + } + if (params->props.min_ssf < params->external_ssf) { + text->requiressf = 0; + } else { + text->requiressf = params->props.min_ssf - params->external_ssf; + } + + /* build up our security properties token */ if (params->props.maxbufsize > 0xFFFFFF) { /* make sure maxbufsize isn't too large */ /* maxbufsize = 0xFFFFFF */ @@ -952,226 +952,226 @@ gssapi_server_mech_step(void *conn_context, sasldata[2] = (params->props.maxbufsize >> 8) & 0xFF; sasldata[3] = (params->props.maxbufsize >> 0) & 0xFF; } - sasldata[0] = 0; - if(text->requiressf != 0 && !params->props.maxbufsize) { - params->utils->seterror(params->utils->conn, 0, - "GSSAPI needs a security layer but one is forbidden"); - return SASL_TOOWEAK; - } - - if (text->requiressf == 0) { - sasldata[0] |= 1; /* authentication */ - } - if (text->requiressf <= 1 && text->limitssf >= 1 - && params->props.maxbufsize) { - sasldata[0] |= 2; - } - if (text->requiressf <= K5_MAX_SSF && text->limitssf >= K5_MAX_SSF - && params->props.maxbufsize) { - sasldata[0] |= 4; - } - - real_input_token.value = (void *)sasldata; - real_input_token.length = 4; - - maj_stat = (*p_krb5_gss_wrap)(&min_stat, - text->gss_ctx, - 0, /* Just integrity checking here */ - GSS_C_QOP_DEFAULT, - input_token, - NULL, - output_token); - - if (GSS_ERROR(maj_stat)) { - sasl_gss_seterror(text->utils, maj_stat, min_stat); - if (output_token->value) - (*p_krb5_gss_release_buffer)(&min_stat, output_token); - sasl_gss_free_context_contents(text); - return SASL_FAIL; - } - - - if (serveroutlen) - *serveroutlen = output_token->length; - if (output_token->value) { - if (serverout) { - ret = _plug_buf_alloc(text->utils, &(text->out_buf), - &(text->out_buf_len), *serveroutlen); - if(ret != SASL_OK) { - (*p_krb5_gss_release_buffer)(&min_stat, output_token); - return ret; - } - memcpy(text->out_buf, output_token->value, *serveroutlen); - *serverout = text->out_buf; - } - - (*p_krb5_gss_release_buffer)(&min_stat, output_token); - } - - /* Wait for ssf request and authid */ - text->state = SASL_GSSAPI_STATE_SSFREQ; - - return SASL_CONTINUE; + sasldata[0] = 0; + if(text->requiressf != 0 && !params->props.maxbufsize) { + params->utils->seterror(params->utils->conn, 0, + "GSSAPI needs a security layer but one is forbidden"); + return SASL_TOOWEAK; + } + + if (text->requiressf == 0) { + sasldata[0] |= 1; /* authentication */ + } + if (text->requiressf <= 1 && text->limitssf >= 1 + && params->props.maxbufsize) { + sasldata[0] |= 2; + } + if (text->requiressf <= K5_MAX_SSF && text->limitssf >= K5_MAX_SSF + && params->props.maxbufsize) { + sasldata[0] |= 4; + } + + real_input_token.value = (void *)sasldata; + real_input_token.length = 4; + + maj_stat = (*p_krb5_gss_wrap)(&min_stat, + text->gss_ctx, + 0, /* Just integrity checking here */ + GSS_C_QOP_DEFAULT, + input_token, + NULL, + output_token); + + if (GSS_ERROR(maj_stat)) { + sasl_gss_seterror(text->utils, maj_stat, min_stat); + if (output_token->value) + (*p_krb5_gss_release_buffer)(&min_stat, output_token); + sasl_gss_free_context_contents(text); + return SASL_FAIL; + } + + + if (serveroutlen) + *serveroutlen = output_token->length; + if (output_token->value) { + if (serverout) { + ret = _plug_buf_alloc(text->utils, &(text->out_buf), + &(text->out_buf_len), *serveroutlen); + if(ret != SASL_OK) { + (*p_krb5_gss_release_buffer)(&min_stat, output_token); + return ret; + } + memcpy(text->out_buf, output_token->value, *serveroutlen); + *serverout = text->out_buf; + } + + (*p_krb5_gss_release_buffer)(&min_stat, output_token); + } + + /* Wait for ssf request and authid */ + text->state = SASL_GSSAPI_STATE_SSFREQ; + + return SASL_CONTINUE; } case SASL_GSSAPI_STATE_SSFREQ: { - int layerchoice; - - real_input_token.value = (void *)clientin; - real_input_token.length = clientinlen; - - maj_stat = (*p_krb5_gss_unwrap)(&min_stat, - text->gss_ctx, - input_token, - output_token, - NULL, - NULL); - - if (GSS_ERROR(maj_stat)) { - sasl_gss_seterror(text->utils, maj_stat, min_stat); - sasl_gss_free_context_contents(text); - return SASL_FAIL; - } - - layerchoice = (int)(((char *)(output_token->value))[0]); - if (layerchoice == 1 && text->requiressf == 0) { /* no encryption */ - oparams->encode = NULL; - oparams->decode = NULL; - oparams->mech_ssf = 0; - } else if (layerchoice == 2 && text->requiressf <= 1 && - text->limitssf >= 1) { /* integrity */ - oparams->encode=&gssapi_integrity_encode; - oparams->decode=&gssapi_decode; - oparams->mech_ssf=1; - } else if (layerchoice == 4 && text->requiressf <= K5_MAX_SSF && - text->limitssf >= K5_MAX_SSF) { /* privacy */ - oparams->encode = &gssapi_privacy_encode; - oparams->decode = &gssapi_decode; - /* FIX ME: Need to extract the proper value here */ - oparams->mech_ssf = K5_MAX_SSF; - } else { - /* not a supported encryption layer */ - SETERROR(text->utils, - "protocol violation: client requested invalid layer"); - /* Mark that we attempted negotiation */ - oparams->mech_ssf = 2; - if (output_token->value) - (*p_krb5_gss_release_buffer)(&min_stat, output_token); - sasl_gss_free_context_contents(text); - return SASL_FAIL; - } - - if (output_token->length > 4) { - int ret; - - ret = params->canon_user(params->utils->conn, - ((char *) output_token->value) + 4, - (output_token->length - 4) * sizeof(char), - SASL_CU_AUTHZID, oparams); - - if (ret != SASL_OK) { - sasl_gss_free_context_contents(text); - return ret; - } - - ret = params->canon_user(params->utils->conn, - text->authid, - 0, /* strlen(text->authid) */ - SASL_CU_AUTHID, oparams); - if (ret != SASL_OK) { - sasl_gss_free_context_contents(text); - return ret; - } - } else if(output_token->length == 4) { - /* null authzid */ - int ret; - - ret = params->canon_user(params->utils->conn, - text->authid, - 0, /* strlen(text->authid) */ - SASL_CU_AUTHZID | SASL_CU_AUTHID, - oparams); - - if (ret != SASL_OK) { - sasl_gss_free_context_contents(text); - return ret; - } - } else { - SETERROR(text->utils, - "token too short"); - (*p_krb5_gss_release_buffer)(&min_stat, output_token); - sasl_gss_free_context_contents(text); - return SASL_FAIL; - } - - /* No matter what, set the rest of the oparams */ - + int layerchoice; + + real_input_token.value = (void *)clientin; + real_input_token.length = clientinlen; + + maj_stat = (*p_krb5_gss_unwrap)(&min_stat, + text->gss_ctx, + input_token, + output_token, + NULL, + NULL); + + if (GSS_ERROR(maj_stat)) { + sasl_gss_seterror(text->utils, maj_stat, min_stat); + sasl_gss_free_context_contents(text); + return SASL_FAIL; + } + + layerchoice = (int)(((char *)(output_token->value))[0]); + if (layerchoice == 1 && text->requiressf == 0) { /* no encryption */ + oparams->encode = NULL; + oparams->decode = NULL; + oparams->mech_ssf = 0; + } else if (layerchoice == 2 && text->requiressf <= 1 && + text->limitssf >= 1) { /* integrity */ + oparams->encode=&gssapi_integrity_encode; + oparams->decode=&gssapi_decode; + oparams->mech_ssf=1; + } else if (layerchoice == 4 && text->requiressf <= K5_MAX_SSF && + text->limitssf >= K5_MAX_SSF) { /* privacy */ + oparams->encode = &gssapi_privacy_encode; + oparams->decode = &gssapi_decode; + /* FIX ME: Need to extract the proper value here */ + oparams->mech_ssf = K5_MAX_SSF; + } else { + /* not a supported encryption layer */ + SETERROR(text->utils, + "protocol violation: client requested invalid layer"); + /* Mark that we attempted negotiation */ + oparams->mech_ssf = 2; + if (output_token->value) + (*p_krb5_gss_release_buffer)(&min_stat, output_token); + sasl_gss_free_context_contents(text); + return SASL_FAIL; + } + + if (output_token->length > 4) { + int ret; + + ret = params->canon_user(params->utils->conn, + ((char *) output_token->value) + 4, + (output_token->length - 4) * sizeof(char), + SASL_CU_AUTHZID, oparams); + + if (ret != SASL_OK) { + sasl_gss_free_context_contents(text); + return ret; + } + + ret = params->canon_user(params->utils->conn, + text->authid, + 0, /* strlen(text->authid) */ + SASL_CU_AUTHID, oparams); + if (ret != SASL_OK) { + sasl_gss_free_context_contents(text); + return ret; + } + } else if(output_token->length == 4) { + /* null authzid */ + int ret; + + ret = params->canon_user(params->utils->conn, + text->authid, + 0, /* strlen(text->authid) */ + SASL_CU_AUTHZID | SASL_CU_AUTHID, + oparams); + + if (ret != SASL_OK) { + sasl_gss_free_context_contents(text); + return ret; + } + } else { + SETERROR(text->utils, + "token too short"); + (*p_krb5_gss_release_buffer)(&min_stat, output_token); + sasl_gss_free_context_contents(text); + return SASL_FAIL; + } + + /* No matter what, set the rest of the oparams */ + oparams->maxoutbuf = - (((unsigned char *) output_token->value)[1] << 16) | + (((unsigned char *) output_token->value)[1] << 16) | (((unsigned char *) output_token->value)[2] << 8) | (((unsigned char *) output_token->value)[3] << 0); - if (oparams->mech_ssf) { - maj_stat = (*p_krb5_gss_wrap_size_limit)(&min_stat, - text->gss_ctx, - 1, - GSS_C_QOP_DEFAULT, - (OM_uint32) oparams->maxoutbuf, - &max_input); - - if(max_input > oparams->maxoutbuf) { - /* Heimdal appears to get this wrong */ - oparams->maxoutbuf -= (max_input - oparams->maxoutbuf); - } else { - /* This code is actually correct */ - oparams->maxoutbuf = max_input; - } - } - - (*p_krb5_gss_release_buffer)(&min_stat, output_token); - - text->state = SASL_GSSAPI_STATE_AUTHENTICATED; - - /* used by layers */ - _plug_decode_init(&text->decode_context, text->utils, - (params->props.maxbufsize > 0xFFFFFF) ? 0xFFFFFF : - params->props.maxbufsize); - - oparams->doneflag = 1; - - return SASL_OK; + if (oparams->mech_ssf) { + maj_stat = (*p_krb5_gss_wrap_size_limit)(&min_stat, + text->gss_ctx, + 1, + GSS_C_QOP_DEFAULT, + (OM_uint32) oparams->maxoutbuf, + &max_input); + + if(max_input > oparams->maxoutbuf) { + /* Heimdal appears to get this wrong */ + oparams->maxoutbuf -= (max_input - oparams->maxoutbuf); + } else { + /* This code is actually correct */ + oparams->maxoutbuf = max_input; + } + } + + (*p_krb5_gss_release_buffer)(&min_stat, output_token); + + text->state = SASL_GSSAPI_STATE_AUTHENTICATED; + + /* used by layers */ + _plug_decode_init(&text->decode_context, text->utils, + (params->props.maxbufsize > 0xFFFFFF) ? 0xFFFFFF : + params->props.maxbufsize); + + oparams->doneflag = 1; + + return SASL_OK; } - + default: - params->utils->log(NULL, SASL_LOG_ERR, - "Invalid GSSAPI server step %d\n", text->state); - return SASL_FAIL; + params->utils->log(NULL, SASL_LOG_ERR, + "Invalid GSSAPI server step %d\n", text->state); + return SASL_FAIL; } - + return SASL_FAIL; /* should never get here */ } -static sasl_server_plug_t gssapi_server_plugins[] = +static sasl_server_plug_t gssapi_server_plugins[] = { { - "GSSAPI", /* mech_name */ - K5_MAX_SSF, /* max_ssf */ - SASL_SEC_NOPLAINTEXT - | SASL_SEC_NOACTIVE - | SASL_SEC_NOANONYMOUS - | SASL_SEC_MUTUAL_AUTH, /* security_flags */ - SASL_FEAT_WANT_CLIENT_FIRST - | SASL_FEAT_ALLOWS_PROXY, /* features */ - NULL, /* glob_context */ - &gssapi_server_mech_new, /* mech_new */ - &gssapi_server_mech_step, /* mech_step */ - &gssapi_common_mech_dispose, /* mech_dispose */ - NULL, /* mech_free */ - NULL, /* setpass */ - NULL, /* user_query */ - NULL, /* idle */ - NULL, /* mech_avail */ - NULL /* spare */ + "GSSAPI", /* mech_name */ + K5_MAX_SSF, /* max_ssf */ + SASL_SEC_NOPLAINTEXT + | SASL_SEC_NOACTIVE + | SASL_SEC_NOANONYMOUS + | SASL_SEC_MUTUAL_AUTH, /* security_flags */ + SASL_FEAT_WANT_CLIENT_FIRST + | SASL_FEAT_ALLOWS_PROXY, /* features */ + NULL, /* glob_context */ + &gssapi_server_mech_new, /* mech_new */ + &gssapi_server_mech_step, /* mech_step */ + &gssapi_common_mech_dispose, /* mech_dispose */ + NULL, /* mech_free */ + NULL, /* setpass */ + NULL, /* user_query */ + NULL, /* idle */ + NULL, /* mech_avail */ + NULL /* spare */ } }; @@ -1180,7 +1180,7 @@ int gssapiv2_server_plug_init( const sasl_utils_t *utils __attribute__((unused)), #else const sasl_utils_t *utils, -#endif +#endif int maxversion, int *out_version, sasl_server_plug_t **pluglist, @@ -1191,78 +1191,78 @@ int gssapiv2_server_plug_init( char keytab_path[1024]; unsigned int rl; #endif - + if (maxversion < SASL_SERVER_PLUG_VERSION) { - return SASL_BADVERS; + return SASL_BADVERS; } - + #ifdef HAVE_GSSKRB5_REGISTER_ACCEPTOR_IDENTITY /* unfortunately, we don't check for readability of keytab if it's the standard one, since we don't know where it is */ - + /* FIXME: This code is broken */ - + utils->getopt(utils->getopt_context, "GSSAPI", "keytab", &keytab, &rl); if (keytab != NULL) { - if (access(keytab, R_OK) != 0) { - utils->log(NULL, SASL_LOG_ERR, - "Could not find keytab file: %s: %m", - keytab, errno); - return SASL_FAIL; - } - - if(strlen(keytab) > 1024) { - utils->log(NULL, SASL_LOG_ERR, - "path to keytab is > 1024 characters"); - return SASL_BUFOVER; - } - - strncpy(keytab_path, keytab, 1024); - - gsskrb5_register_acceptor_identity(keytab_path); + if (access(keytab, R_OK) != 0) { + utils->log(NULL, SASL_LOG_ERR, + "Could not find keytab file: %s: %m", + keytab, errno); + return SASL_FAIL; + } + + if(strlen(keytab) > 1024) { + utils->log(NULL, SASL_LOG_ERR, + "path to keytab is > 1024 characters"); + return SASL_BUFOVER; + } + + strncpy(keytab_path, keytab, 1024); + + gsskrb5_register_acceptor_identity(keytab_path); } #endif - + *out_version = SASL_SERVER_PLUG_VERSION; *pluglist = gssapi_server_plugins; - *plugcount = 1; - + *plugcount = 1; + return SASL_OK; } /***************************** Client Section *****************************/ -static int gssapi_client_mech_new(void *glob_context __attribute__((unused)), - sasl_client_params_t *params, - void **conn_context) +static int gssapi_client_mech_new(void *glob_context __attribute__((unused)), + sasl_client_params_t *params, + void **conn_context) { context_t *text; - + /* holds state are in */ text = gss_new_context(params->utils); if (text == NULL) { - MEMERROR(params->utils); - return SASL_NOMEM; + MEMERROR(params->utils); + return SASL_NOMEM; } - + text->state = SASL_GSSAPI_STATE_AUTHNEG; text->gss_ctx = GSS_C_NO_CONTEXT; text->client_name = GSS_C_NO_NAME; text->server_creds = GSS_C_NO_CREDENTIAL; *conn_context = text; - + return SASL_OK; } static int gssapi_client_mech_step(void *conn_context, - sasl_client_params_t *params, - const char *serverin, - unsigned serverinlen, - sasl_interact_t **prompt_need, - const char **clientout, - unsigned *clientoutlen, - sasl_out_params_t *oparams) + sasl_client_params_t *params, + const char *serverin, + unsigned serverinlen, + sasl_interact_t **prompt_need, + const char **clientout, + unsigned *clientoutlen, + sasl_out_params_t *oparams) { context_t *text = (context_t *)conn_context; gss_buffer_t input_token, output_token; @@ -1275,286 +1275,286 @@ static int gssapi_client_mech_step(void *conn_context, input_token = &real_input_token; output_token = &real_output_token; output_token->value = NULL; - input_token->value = NULL; + input_token->value = NULL; input_token->length = 0; - + *clientout = NULL; *clientoutlen = 0; - + if (sasl_gss_lib_init(text->utils) != SASL_OK) return SASL_FAIL; - + switch (text->state) { case SASL_GSSAPI_STATE_AUTHNEG: - /* try to get the userid */ - if (text->user == NULL) { - int user_result = SASL_OK; - - user_result = _plug_get_userid(params->utils, &text->user, - prompt_need); - - if ((user_result != SASL_OK) && (user_result != SASL_INTERACT)) { - sasl_gss_free_context_contents(text); - return user_result; - } - - /* free prompts we got */ - if (prompt_need && *prompt_need) { - params->utils->free(*prompt_need); - *prompt_need = NULL; - } - - /* if there are prompts not filled in */ - if (user_result == SASL_INTERACT) { - /* make the prompt list */ - int result = - _plug_make_prompts(params->utils, prompt_need, - user_result == SASL_INTERACT ? - "Please enter your authorization name" : NULL, NULL, - NULL, NULL, - NULL, NULL, - NULL, NULL, NULL, - NULL, NULL, NULL); - if (result != SASL_OK) return result; - - return SASL_INTERACT; - } - } - - if (text->server_name == GSS_C_NO_NAME) { /* only once */ - name_token.length = strlen(params->service) + 1 + strlen(params->serverFQDN); - name_token.value = (char *)params->utils->malloc((name_token.length + 1) * sizeof(char)); - if (name_token.value == NULL) { - sasl_gss_free_context_contents(text); - return SASL_NOMEM; - } - if (params->serverFQDN == NULL - || strlen(params->serverFQDN) == 0) { - SETERROR(text->utils, "GSSAPI Failure: no serverFQDN"); - return SASL_FAIL; - } - - sprintf(name_token.value,"%s@%s", params->service, params->serverFQDN); - - maj_stat = (*p_krb5_gss_import_name) (&min_stat, - &name_token, - GSS_C_NT_HOSTBASED_SERVICE, - &text->server_name); - - params->utils->free(name_token.value); - name_token.value = NULL; - - if (GSS_ERROR(maj_stat)) { - sasl_gss_seterror(text->utils, maj_stat, min_stat); - sasl_gss_free_context_contents(text); - return SASL_FAIL; - } - } - - if (serverinlen == 0) - input_token = GSS_C_NO_BUFFER; - - if (serverinlen) { - real_input_token.value = (void *)serverin; - real_input_token.length = serverinlen; - } - else if (text->gss_ctx != GSS_C_NO_CONTEXT ) { - /* This can't happen under GSSAPI: we have a non-null context - * and no input from the server. However, thanks to Imap, - * which discards our first output, this happens all the time. - * Throw away the context and try again. */ - maj_stat = (*p_krb5_gss_delete_sec_context) (&min_stat,&text->gss_ctx,GSS_C_NO_BUFFER); - text->gss_ctx = GSS_C_NO_CONTEXT; - } - - /* Setup req_flags properly */ - req_flags = GSS_C_MUTUAL_FLAG | GSS_C_SEQUENCE_FLAG; - if(params->props.max_ssf > params->external_ssf) { - /* We are requesting a security layer */ - req_flags |= GSS_C_INTEG_FLAG; - /* Any SSF bigger than 1 is confidentiality. */ - /* Let's check if the client of the API requires confidentiality, - and it wasn't already provided by an external layer */ - if(params->props.max_ssf - params->external_ssf > 1) { - /* We want to try for privacy */ - req_flags |= GSS_C_CONF_FLAG; - } - } - - maj_stat = (*p_krb5_gss_init_sec_context)(&min_stat, - GSS_C_NO_CREDENTIAL, - &text->gss_ctx, - text->server_name, - GSS_C_NO_OID, - req_flags, - 0, - GSS_C_NO_CHANNEL_BINDINGS, - input_token, - NULL, - output_token, - &out_req_flags, - NULL); - - if (GSS_ERROR(maj_stat)) { - sasl_gss_seterror(text->utils, maj_stat, min_stat); - if (output_token->value) - (*p_krb5_gss_release_buffer)(&min_stat, output_token); - sasl_gss_free_context_contents(text); - return SASL_FAIL; - } - - *clientoutlen = output_token->length; - - if (output_token->value) { - if (clientout) { - ret = _plug_buf_alloc(text->utils, &(text->out_buf), - &(text->out_buf_len), *clientoutlen); - if(ret != SASL_OK) { - (*p_krb5_gss_release_buffer)(&min_stat, output_token); - return ret; - } - memcpy(text->out_buf, output_token->value, *clientoutlen); - *clientout = text->out_buf; - } - - (*p_krb5_gss_release_buffer)(&min_stat, output_token); - } - - if (maj_stat == GSS_S_COMPLETE) { - maj_stat = (*p_krb5_gss_inquire_context)(&min_stat, - text->gss_ctx, - &text->client_name, - NULL, /* targ_name */ - NULL, /* lifetime */ - NULL, /* mech */ - /* FIX ME: Should check the resulting flags here */ - NULL, /* flags */ - NULL, /* local init */ - NULL); /* open */ - - if (GSS_ERROR(maj_stat)) { - sasl_gss_seterror(text->utils, maj_stat, min_stat); - sasl_gss_free_context_contents(text); - return SASL_FAIL; - } - - name_token.length = 0; - maj_stat = (*p_krb5_gss_display_name)(&min_stat, - text->client_name, - &name_token, - NULL); - - if (GSS_ERROR(maj_stat)) { - if (name_token.value) - (*p_krb5_gss_release_buffer)(&min_stat, &name_token); - SETERROR(text->utils, "GSSAPI Failure"); - sasl_gss_free_context_contents(text); - return SASL_FAIL; - } - - if (text->user && text->user[0]) { - ret = params->canon_user(params->utils->conn, - text->user, 0, - SASL_CU_AUTHZID, oparams); - if (ret == SASL_OK) - ret = params->canon_user(params->utils->conn, - name_token.value, 0, - SASL_CU_AUTHID, oparams); - } else { - ret = params->canon_user(params->utils->conn, - name_token.value, 0, - SASL_CU_AUTHID | SASL_CU_AUTHZID, - oparams); - } - (*p_krb5_gss_release_buffer)(&min_stat, &name_token); - - if (ret != SASL_OK) return ret; - - /* Switch to ssf negotiation */ - text->state = SASL_GSSAPI_STATE_SSFCAP; - } - - return SASL_CONTINUE; + /* try to get the userid */ + if (text->user == NULL) { + int user_result = SASL_OK; + + user_result = _plug_get_userid(params->utils, &text->user, + prompt_need); + + if ((user_result != SASL_OK) && (user_result != SASL_INTERACT)) { + sasl_gss_free_context_contents(text); + return user_result; + } + + /* free prompts we got */ + if (prompt_need && *prompt_need) { + params->utils->free(*prompt_need); + *prompt_need = NULL; + } + + /* if there are prompts not filled in */ + if (user_result == SASL_INTERACT) { + /* make the prompt list */ + int result = + _plug_make_prompts(params->utils, prompt_need, + user_result == SASL_INTERACT ? + "Please enter your authorization name" : NULL, NULL, + NULL, NULL, + NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL); + if (result != SASL_OK) return result; + + return SASL_INTERACT; + } + } + + if (text->server_name == GSS_C_NO_NAME) { /* only once */ + name_token.length = strlen(params->service) + 1 + strlen(params->serverFQDN); + name_token.value = (char *)params->utils->malloc((name_token.length + 1) * sizeof(char)); + if (name_token.value == NULL) { + sasl_gss_free_context_contents(text); + return SASL_NOMEM; + } + if (params->serverFQDN == NULL + || strlen(params->serverFQDN) == 0) { + SETERROR(text->utils, "GSSAPI Failure: no serverFQDN"); + return SASL_FAIL; + } + + sprintf(name_token.value,"%s@%s", params->service, params->serverFQDN); + + maj_stat = (*p_krb5_gss_import_name) (&min_stat, + &name_token, + GSS_C_NT_HOSTBASED_SERVICE, + &text->server_name); + + params->utils->free(name_token.value); + name_token.value = NULL; + + if (GSS_ERROR(maj_stat)) { + sasl_gss_seterror(text->utils, maj_stat, min_stat); + sasl_gss_free_context_contents(text); + return SASL_FAIL; + } + } + + if (serverinlen == 0) + input_token = GSS_C_NO_BUFFER; + + if (serverinlen) { + real_input_token.value = (void *)serverin; + real_input_token.length = serverinlen; + } + else if (text->gss_ctx != GSS_C_NO_CONTEXT ) { + /* This can't happen under GSSAPI: we have a non-null context + * and no input from the server. However, thanks to Imap, + * which discards our first output, this happens all the time. + * Throw away the context and try again. */ + maj_stat = (*p_krb5_gss_delete_sec_context) (&min_stat,&text->gss_ctx,GSS_C_NO_BUFFER); + text->gss_ctx = GSS_C_NO_CONTEXT; + } + + /* Setup req_flags properly */ + req_flags = GSS_C_MUTUAL_FLAG | GSS_C_SEQUENCE_FLAG; + if(params->props.max_ssf > params->external_ssf) { + /* We are requesting a security layer */ + req_flags |= GSS_C_INTEG_FLAG; + /* Any SSF bigger than 1 is confidentiality. */ + /* Let's check if the client of the API requires confidentiality, + and it wasn't already provided by an external layer */ + if(params->props.max_ssf - params->external_ssf > 1) { + /* We want to try for privacy */ + req_flags |= GSS_C_CONF_FLAG; + } + } + + maj_stat = (*p_krb5_gss_init_sec_context)(&min_stat, + GSS_C_NO_CREDENTIAL, + &text->gss_ctx, + text->server_name, + GSS_C_NO_OID, + req_flags, + 0, + GSS_C_NO_CHANNEL_BINDINGS, + input_token, + NULL, + output_token, + &out_req_flags, + NULL); + + if (GSS_ERROR(maj_stat)) { + sasl_gss_seterror(text->utils, maj_stat, min_stat); + if (output_token->value) + (*p_krb5_gss_release_buffer)(&min_stat, output_token); + sasl_gss_free_context_contents(text); + return SASL_FAIL; + } + + *clientoutlen = output_token->length; + + if (output_token->value) { + if (clientout) { + ret = _plug_buf_alloc(text->utils, &(text->out_buf), + &(text->out_buf_len), *clientoutlen); + if(ret != SASL_OK) { + (*p_krb5_gss_release_buffer)(&min_stat, output_token); + return ret; + } + memcpy(text->out_buf, output_token->value, *clientoutlen); + *clientout = text->out_buf; + } + + (*p_krb5_gss_release_buffer)(&min_stat, output_token); + } + + if (maj_stat == GSS_S_COMPLETE) { + maj_stat = (*p_krb5_gss_inquire_context)(&min_stat, + text->gss_ctx, + &text->client_name, + NULL, /* targ_name */ + NULL, /* lifetime */ + NULL, /* mech */ + /* FIX ME: Should check the resulting flags here */ + NULL, /* flags */ + NULL, /* local init */ + NULL); /* open */ + + if (GSS_ERROR(maj_stat)) { + sasl_gss_seterror(text->utils, maj_stat, min_stat); + sasl_gss_free_context_contents(text); + return SASL_FAIL; + } + + name_token.length = 0; + maj_stat = (*p_krb5_gss_display_name)(&min_stat, + text->client_name, + &name_token, + NULL); + + if (GSS_ERROR(maj_stat)) { + if (name_token.value) + (*p_krb5_gss_release_buffer)(&min_stat, &name_token); + SETERROR(text->utils, "GSSAPI Failure"); + sasl_gss_free_context_contents(text); + return SASL_FAIL; + } + + if (text->user && text->user[0]) { + ret = params->canon_user(params->utils->conn, + text->user, 0, + SASL_CU_AUTHZID, oparams); + if (ret == SASL_OK) + ret = params->canon_user(params->utils->conn, + name_token.value, 0, + SASL_CU_AUTHID, oparams); + } else { + ret = params->canon_user(params->utils->conn, + name_token.value, 0, + SASL_CU_AUTHID | SASL_CU_AUTHZID, + oparams); + } + (*p_krb5_gss_release_buffer)(&min_stat, &name_token); + + if (ret != SASL_OK) return ret; + + /* Switch to ssf negotiation */ + text->state = SASL_GSSAPI_STATE_SSFCAP; + } + + return SASL_CONTINUE; case SASL_GSSAPI_STATE_SSFCAP: { - sasl_security_properties_t *secprops = &(params->props); - unsigned int alen, external = params->external_ssf; - sasl_ssf_t need, allowed; - char serverhas, mychoice; - - real_input_token.value = (void *) serverin; - real_input_token.length = serverinlen; - - maj_stat = (*p_krb5_gss_unwrap)(&min_stat, - text->gss_ctx, - input_token, - output_token, - NULL, - NULL); - - if (GSS_ERROR(maj_stat)) { - sasl_gss_seterror(text->utils, maj_stat, min_stat); - sasl_gss_free_context_contents(text); - if (output_token->value) - (*p_krb5_gss_release_buffer)(&min_stat, output_token); - return SASL_FAIL; - } - - /* taken from kerberos.c */ - if (secprops->min_ssf > (K5_MAX_SSF + external)) { - return SASL_TOOWEAK; - } else if (secprops->min_ssf > secprops->max_ssf) { - return SASL_BADPARAM; - } - - /* need bits of layer -- sasl_ssf_t is unsigned so be careful */ - if (secprops->max_ssf >= external) { - allowed = secprops->max_ssf - external; - } else { - allowed = 0; - } - if (secprops->min_ssf >= external) { - need = secprops->min_ssf - external; - } else { - /* good to go */ - need = 0; - } - - /* bit mask of server support */ - serverhas = ((char *)output_token->value)[0]; - - /* if client didn't set use strongest layer available */ - if (allowed >= K5_MAX_SSF && need <= K5_MAX_SSF && (serverhas & 4)) { - /* encryption */ - oparams->encode = &gssapi_privacy_encode; - oparams->decode = &gssapi_decode; - /* FIX ME: Need to extract the proper value here */ - oparams->mech_ssf = K5_MAX_SSF; - mychoice = 4; - } else if (allowed >= 1 && need <= 1 && (serverhas & 2)) { - /* integrity */ - oparams->encode = &gssapi_integrity_encode; - oparams->decode = &gssapi_decode; - oparams->mech_ssf = 1; - mychoice = 2; - } else if (need <= 0 && (serverhas & 1)) { - /* no layer */ - oparams->encode = NULL; - oparams->decode = NULL; - oparams->mech_ssf = 0; - mychoice = 1; - } else { - /* there's no appropriate layering for us! */ - sasl_gss_free_context_contents(text); - return SASL_TOOWEAK; - } - + sasl_security_properties_t *secprops = &(params->props); + unsigned int alen, external = params->external_ssf; + sasl_ssf_t need, allowed; + char serverhas, mychoice; + + real_input_token.value = (void *) serverin; + real_input_token.length = serverinlen; + + maj_stat = (*p_krb5_gss_unwrap)(&min_stat, + text->gss_ctx, + input_token, + output_token, + NULL, + NULL); + + if (GSS_ERROR(maj_stat)) { + sasl_gss_seterror(text->utils, maj_stat, min_stat); + sasl_gss_free_context_contents(text); + if (output_token->value) + (*p_krb5_gss_release_buffer)(&min_stat, output_token); + return SASL_FAIL; + } + + /* taken from kerberos.c */ + if (secprops->min_ssf > (K5_MAX_SSF + external)) { + return SASL_TOOWEAK; + } else if (secprops->min_ssf > secprops->max_ssf) { + return SASL_BADPARAM; + } + + /* need bits of layer -- sasl_ssf_t is unsigned so be careful */ + if (secprops->max_ssf >= external) { + allowed = secprops->max_ssf - external; + } else { + allowed = 0; + } + if (secprops->min_ssf >= external) { + need = secprops->min_ssf - external; + } else { + /* good to go */ + need = 0; + } + + /* bit mask of server support */ + serverhas = ((char *)output_token->value)[0]; + + /* if client didn't set use strongest layer available */ + if (allowed >= K5_MAX_SSF && need <= K5_MAX_SSF && (serverhas & 4)) { + /* encryption */ + oparams->encode = &gssapi_privacy_encode; + oparams->decode = &gssapi_decode; + /* FIX ME: Need to extract the proper value here */ + oparams->mech_ssf = K5_MAX_SSF; + mychoice = 4; + } else if (allowed >= 1 && need <= 1 && (serverhas & 2)) { + /* integrity */ + oparams->encode = &gssapi_integrity_encode; + oparams->decode = &gssapi_decode; + oparams->mech_ssf = 1; + mychoice = 2; + } else if (need <= 0 && (serverhas & 1)) { + /* no layer */ + oparams->encode = NULL; + oparams->decode = NULL; + oparams->mech_ssf = 0; + mychoice = 1; + } else { + /* there's no appropriate layering for us! */ + sasl_gss_free_context_contents(text); + return SASL_TOOWEAK; + } + oparams->maxoutbuf = - (((unsigned char *) output_token->value)[1] << 16) | + (((unsigned char *) output_token->value)[1] << 16) | (((unsigned char *) output_token->value)[2] << 8) | (((unsigned char *) output_token->value)[3] << 0); - if(oparams->mech_ssf) { + if(oparams->mech_ssf) { maj_stat = (*p_krb5_gss_wrap_size_limit)(&min_stat, text->gss_ctx, 1, @@ -1562,38 +1562,38 @@ static int gssapi_client_mech_step(void *conn_context, (OM_uint32) oparams->maxoutbuf, &max_input); - if(max_input > oparams->maxoutbuf) { - /* Heimdal appears to get this wrong */ - oparams->maxoutbuf -= (max_input - oparams->maxoutbuf); - } else { - /* This code is actually correct */ - oparams->maxoutbuf = max_input; - } - } - - (*p_krb5_gss_release_buffer)(&min_stat, output_token); - - /* oparams->user is always set, due to canon_user requirements. - * Make sure the client actually requested it though, by checking - * if our context was set. - */ - if (text->user && text->user[0]) - alen = strlen(oparams->user); - else - alen = 0; - - input_token->length = 4 + alen; - input_token->value = - (char *)params->utils->malloc((input_token->length + 1)*sizeof(char)); - if (input_token->value == NULL) { - sasl_gss_free_context_contents(text); - return SASL_NOMEM; - } - - if (alen) - memcpy((char *)input_token->value+4,oparams->user,alen); - - /* build up our security properties token */ + if(max_input > oparams->maxoutbuf) { + /* Heimdal appears to get this wrong */ + oparams->maxoutbuf -= (max_input - oparams->maxoutbuf); + } else { + /* This code is actually correct */ + oparams->maxoutbuf = max_input; + } + } + + (*p_krb5_gss_release_buffer)(&min_stat, output_token); + + /* oparams->user is always set, due to canon_user requirements. + * Make sure the client actually requested it though, by checking + * if our context was set. + */ + if (text->user && text->user[0]) + alen = strlen(oparams->user); + else + alen = 0; + + input_token->length = 4 + alen; + input_token->value = + (char *)params->utils->malloc((input_token->length + 1)*sizeof(char)); + if (input_token->value == NULL) { + sasl_gss_free_context_contents(text); + return SASL_NOMEM; + } + + if (alen) + memcpy((char *)input_token->value+4,oparams->user,alen); + + /* build up our security properties token */ if (params->props.maxbufsize > 0xFFFFFF) { /* make sure maxbufsize isn't too large */ /* maxbufsize = 0xFFFFFF */ @@ -1601,115 +1601,115 @@ static int gssapi_client_mech_step(void *conn_context, ((unsigned char *)input_token->value)[2] = 0xFF; ((unsigned char *)input_token->value)[3] = 0xFF; } else { - ((unsigned char *)input_token->value)[1] = + ((unsigned char *)input_token->value)[1] = (params->props.maxbufsize >> 16) & 0xFF; - ((unsigned char *)input_token->value)[2] = + ((unsigned char *)input_token->value)[2] = (params->props.maxbufsize >> 8) & 0xFF; - ((unsigned char *)input_token->value)[3] = + ((unsigned char *)input_token->value)[3] = (params->props.maxbufsize >> 0) & 0xFF; } - ((unsigned char *)input_token->value)[0] = mychoice; - - maj_stat = (*p_krb5_gss_wrap) (&min_stat, - text->gss_ctx, - 0, /* Just integrity checking here */ - GSS_C_QOP_DEFAULT, - input_token, - NULL, - output_token); - - params->utils->free(input_token->value); - input_token->value = NULL; - - if (GSS_ERROR(maj_stat)) { - sasl_gss_seterror(text->utils, maj_stat, min_stat); - if (output_token->value) - (*p_krb5_gss_release_buffer)(&min_stat, output_token); - sasl_gss_free_context_contents(text); - return SASL_FAIL; - } - - if (clientoutlen) - *clientoutlen = output_token->length; - if (output_token->value) { - if (clientout) { - ret = _plug_buf_alloc(text->utils, &(text->out_buf), - &(text->out_buf_len), *clientoutlen); - if (ret != SASL_OK) { - (*p_krb5_gss_release_buffer)(&min_stat, output_token); - return ret; - } - memcpy(text->out_buf, output_token->value, *clientoutlen); - *clientout = text->out_buf; - } - - (*p_krb5_gss_release_buffer)(&min_stat, output_token); - } - - text->state = SASL_GSSAPI_STATE_AUTHENTICATED; - - oparams->doneflag = 1; - - /* used by layers */ - _plug_decode_init(&text->decode_context, text->utils, - (params->props.maxbufsize > 0xFFFFFF) ? 0xFFFFFF : - params->props.maxbufsize); - - return SASL_OK; + ((unsigned char *)input_token->value)[0] = mychoice; + + maj_stat = (*p_krb5_gss_wrap) (&min_stat, + text->gss_ctx, + 0, /* Just integrity checking here */ + GSS_C_QOP_DEFAULT, + input_token, + NULL, + output_token); + + params->utils->free(input_token->value); + input_token->value = NULL; + + if (GSS_ERROR(maj_stat)) { + sasl_gss_seterror(text->utils, maj_stat, min_stat); + if (output_token->value) + (*p_krb5_gss_release_buffer)(&min_stat, output_token); + sasl_gss_free_context_contents(text); + return SASL_FAIL; + } + + if (clientoutlen) + *clientoutlen = output_token->length; + if (output_token->value) { + if (clientout) { + ret = _plug_buf_alloc(text->utils, &(text->out_buf), + &(text->out_buf_len), *clientoutlen); + if (ret != SASL_OK) { + (*p_krb5_gss_release_buffer)(&min_stat, output_token); + return ret; + } + memcpy(text->out_buf, output_token->value, *clientoutlen); + *clientout = text->out_buf; + } + + (*p_krb5_gss_release_buffer)(&min_stat, output_token); + } + + text->state = SASL_GSSAPI_STATE_AUTHENTICATED; + + oparams->doneflag = 1; + + /* used by layers */ + _plug_decode_init(&text->decode_context, text->utils, + (params->props.maxbufsize > 0xFFFFFF) ? 0xFFFFFF : + params->props.maxbufsize); + + return SASL_OK; } - + default: - params->utils->log(NULL, SASL_LOG_ERR, - "Invalid GSSAPI client step %d\n", text->state); - return SASL_FAIL; + params->utils->log(NULL, SASL_LOG_ERR, + "Invalid GSSAPI client step %d\n", text->state); + return SASL_FAIL; } - + return SASL_FAIL; /* should never get here */ } static const unsigned long gssapi_required_prompts[] = { SASL_CB_LIST_END -}; +}; -static sasl_client_plug_t gssapi_client_plugins[] = +static sasl_client_plug_t gssapi_client_plugins[] = { { - "GSSAPI", /* mech_name */ - K5_MAX_SSF, /* max_ssf */ - SASL_SEC_NOPLAINTEXT - | SASL_SEC_NOACTIVE - | SASL_SEC_NOANONYMOUS - | SASL_SEC_MUTUAL_AUTH, /* security_flags */ - SASL_FEAT_NEEDSERVERFQDN - | SASL_FEAT_WANT_CLIENT_FIRST - | SASL_FEAT_ALLOWS_PROXY, /* features */ - gssapi_required_prompts, /* required_prompts */ - NULL, /* glob_context */ - &gssapi_client_mech_new, /* mech_new */ - &gssapi_client_mech_step, /* mech_step */ - &gssapi_common_mech_dispose, /* mech_dispose */ - NULL, /* mech_free */ - NULL, /* idle */ - NULL, /* spare */ - NULL /* spare */ + "GSSAPI", /* mech_name */ + K5_MAX_SSF, /* max_ssf */ + SASL_SEC_NOPLAINTEXT + | SASL_SEC_NOACTIVE + | SASL_SEC_NOANONYMOUS + | SASL_SEC_MUTUAL_AUTH, /* security_flags */ + SASL_FEAT_NEEDSERVERFQDN + | SASL_FEAT_WANT_CLIENT_FIRST + | SASL_FEAT_ALLOWS_PROXY, /* features */ + gssapi_required_prompts, /* required_prompts */ + NULL, /* glob_context */ + &gssapi_client_mech_new, /* mech_new */ + &gssapi_client_mech_step, /* mech_step */ + &gssapi_common_mech_dispose, /* mech_dispose */ + NULL, /* mech_free */ + NULL, /* idle */ + NULL, /* spare */ + NULL /* spare */ } }; -int gssapiv2_client_plug_init(const sasl_utils_t *utils __attribute__((unused)), - int maxversion, - int *out_version, - sasl_client_plug_t **pluglist, - int *plugcount) +int gssapiv2_client_plug_init(const sasl_utils_t *utils __attribute__((unused)), + int maxversion, + int *out_version, + sasl_client_plug_t **pluglist, + int *plugcount) { if (maxversion < SASL_CLIENT_PLUG_VERSION) { - SETERROR(utils, "Version mismatch in GSSAPI"); - return SASL_BADVERS; + SETERROR(utils, "Version mismatch in GSSAPI"); + return SASL_BADVERS; } - + *out_version = SASL_CLIENT_PLUG_VERSION; *pluglist = gssapi_client_plugins; *plugcount = 1; - + return SASL_OK; } @@ -1728,17 +1728,17 @@ int gssapiv2_client_plug_init(const sasl_utils_t *utils __attribute__((unused)), OM_uint32 gss_add_cred( - OM_uint32 *minor_status, - gss_cred_id_t input_cred_handle, - gss_name_t desired_name, - gss_OID desired_mech, - gss_cred_usage_t cred_usage, - OM_uint32 initiator_time_req, - OM_uint32 acceptor_time_req, - gss_cred_id_t *output_cred_handle, - gss_OID_set *actual_mechs, - OM_uint32 *initiator_time_rec, - OM_uint32 *acceptor_time_rec) + OM_uint32 *minor_status, + gss_cred_id_t input_cred_handle, + gss_name_t desired_name, + gss_OID desired_mech, + gss_cred_usage_t cred_usage, + OM_uint32 initiator_time_req, + OM_uint32 acceptor_time_req, + gss_cred_id_t *output_cred_handle, + gss_OID_set *actual_mechs, + OM_uint32 *initiator_time_rec, + OM_uint32 *acceptor_time_rec) { return((*p_krb5_gss_add_cred)(minor_status, input_cred_handle, desired_name, @@ -1758,8 +1758,8 @@ gss_seal(OM_uint32 *minor_status, gss_buffer_t output_message_buffer) { return((*p_krb5_gss_seal)(minor_status, context_handle, - conf_req_flag, qop_req, input_message_buffer, - conf_state, output_message_buffer)); + conf_req_flag, qop_req, input_message_buffer, + conf_state, output_message_buffer)); } OM_uint32 @@ -1771,8 +1771,8 @@ gss_unseal(OM_uint32 *minor_status, int *qop_state) { return((*p_krb5_gss_unseal)(minor_status, context_handle, - input_message_buffer, output_message_buffer, - conf_state, qop_state)); + input_message_buffer, output_message_buffer, + conf_state, qop_state)); } #endif diff --git a/myproxy/source/myproxy.c b/myproxy/source/myproxy.c index 963449d6a0..34e8041270 100644 --- a/myproxy/source/myproxy.c +++ b/myproxy/source/myproxy.c @@ -896,30 +896,30 @@ myproxy_authenticate_init(myproxy_socket_attrs_t *attrs, gss_buffer_desc name_buf; const char *services[] = { "myproxy", "host" }; int s; - OM_uint32 major_status, minor_status; + OM_uint32 minor_status; - fqhn = GSI_SOCKET_get_peer_hostname(attrs->gsi_socket); - if (!fqhn) { - GSI_SOCKET_get_error_string(attrs->gsi_socket, error_string, - sizeof(error_string)); - verror_put_string("Error getting name of remote party: %s\n", - error_string); - goto error; - } - for (s = 0; s < (sizeof services)/(sizeof *services); s++) - { + fqhn = GSI_SOCKET_get_peer_hostname(attrs->gsi_socket); + if (!fqhn) { + GSI_SOCKET_get_error_string(attrs->gsi_socket, error_string, + sizeof(error_string)); + verror_put_string("Error getting name of remote party: %s\n", + error_string); + goto error; + } + for (s = 0; s < (sizeof services)/(sizeof *services); s++) + { name_buf.value = globus_common_create_string("%s@%s", services[s], fqhn); name_buf.length = strlen(name_buf.value); - major_status = gss_import_name( + gss_import_name( &minor_status, &name_buf, GSS_C_NT_HOSTBASED_SERVICE, &accepted_peer_names[s]); - } + } - free(fqhn); + free(fqhn); } } @@ -2812,7 +2812,7 @@ convert_message(const char *buffer, char **line) { int foundone = 0; - char *varname_start; + const char *varname_start; int return_value = -1; int line_index = 0; const char *buffer_p; @@ -2836,7 +2836,7 @@ convert_message(const char *buffer, while ((varname_start = strstr(buffer_p, varname)) != NULL) { - char *value_start; + const char *value_start; int value_length; /* Have is this the first varname we've found? */ diff --git a/myproxy/source/myproxy_alcf.c b/myproxy/source/myproxy_alcf.c index 308fd3498b..e67ea464e8 100644 --- a/myproxy/source/myproxy_alcf.c +++ b/myproxy/source/myproxy_alcf.c @@ -5,10 +5,10 @@ * */ -#include "myproxy_common.h" /* all needed headers included here */ +#include "myproxy_common.h" /* all needed headers included here */ #define MYPROXY_DEFAULT_PROXY "/tmp/myproxy-proxy" -#define SECONDS_PER_HOUR (60 * 60) +#define SECONDS_PER_HOUR (60 * 60) static int dn_as_username = 0; static char usage[] = \ @@ -26,7 +26,7 @@ static char usage[] = \ " -c | --certfile Certificate file name\n" " -y | --keyfile Key file name\n" " -l | --username Username for the delegated proxy\n" -" -t | --proxy_lifetime Lifetime of proxies delegated by\n" +" -t | --proxy_lifetime Lifetime of proxies delegated by\n" " server (default 12 hours)\n" " -a | --allow_anonymous_retrievers Allow credentials to be retrieved\n" " with just username/passphrase\n" @@ -55,8 +55,8 @@ struct option long_options[] = { {"help", no_argument, NULL, 'h'}, {"usage", no_argument, NULL, 'u'}, - {"certfile", required_argument, NULL, 'c'}, - {"keyfile", required_argument, NULL, 'y'}, + {"certfile", required_argument, NULL, 'c'}, + {"keyfile", required_argument, NULL, 'y'}, {"proxy_lifetime", required_argument, NULL, 't'}, {"storage", required_argument, NULL, 's'}, {"username", required_argument, NULL, 'l'}, @@ -68,9 +68,9 @@ struct option long_options[] = {"retrievable_by", required_argument, NULL, 'r'}, {"renewable_by", required_argument, NULL, 'R'}, {"regex_dn_match", no_argument, NULL, 'x'}, - {"match_cn_only", no_argument, NULL, 'X'}, - {"credname", required_argument, NULL, 'k'}, - {"creddesc", required_argument, NULL, 'K'}, + {"match_cn_only", no_argument, NULL, 'X'}, + {"credname", required_argument, NULL, 'k'}, + {"creddesc", required_argument, NULL, 'K'}, {"retrievable_by_cert", required_argument, NULL, 'Z'}, {"retrieve_key", required_argument, NULL, 'E'}, {0, 0, 0, 0} @@ -90,7 +90,7 @@ static char version[] = void init_arguments(int argc, char *argv[], myproxy_creds_t *my_creds); int makeproxy(const char certfile[], const char keyfile[], - const char proxyfile[]); + const char proxyfile[]); int get_storage_dir_owner(uid_t *owner); int main(int argc, char *argv[]) @@ -101,10 +101,10 @@ int main(int argc, char *argv[]) /* check library version */ if (myproxy_check_version()) { - fprintf(stderr, "MyProxy library version mismatch.\n" - "Expecting %s. Found %s.\n", - MYPROXY_VERSION_DATE, myproxy_version(0,0,0)); - exit(1); + fprintf(stderr, "MyProxy library version mismatch.\n" + "Expecting %s. Found %s.\n", + MYPROXY_VERSION_DATE, myproxy_version(0,0,0)); + exit(1); } myproxy_log_use_stream (stderr); @@ -112,61 +112,61 @@ int main(int argc, char *argv[]) init_arguments (argc, argv, &my_creds); if (certfile == NULL) { - fprintf (stderr, "Specify certificate file with -c option\n"); - fprintf(stderr, "%s", usage); - goto cleanup; + fprintf (stderr, "Specify certificate file with -c option\n"); + fprintf(stderr, "%s", usage); + goto cleanup; } if (keyfile == NULL) { - fprintf (stderr, "Specify key file with -y option\n"); - fprintf(stderr, "%s", usage); - goto cleanup; + fprintf (stderr, "Specify key file with -y option\n"); + fprintf(stderr, "%s", usage); + goto cleanup; } sprintf(proxyfile, "%s.%u.%u", MYPROXY_DEFAULT_PROXY, - (unsigned)getuid(), (unsigned)getpid()); + (unsigned)getuid(), (unsigned)getpid()); /* Remove proxyfile if it already exists. */ ssl_proxy_file_destroy(proxyfile); verror_clear(); if (makeproxy(certfile, keyfile, proxyfile) < 0) { - fprintf(stderr, "Failed to create temporary credentials file.\n"); - goto cleanup; + fprintf(stderr, "Failed to create temporary credentials file.\n"); + goto cleanup; } - + if (my_creds.username == NULL) { /* set default username */ - if (dn_as_username) { - if (ssl_get_base_subject_file(proxyfile, - &my_creds.username)) { - fprintf(stderr, - "Cannot get subject name from your certificate\n"); - goto cleanup; - } - } else { - char *username = NULL; - if (!(username = getenv("LOGNAME"))) { - fprintf(stderr, "Please specify a username.\n"); - goto cleanup; - } - my_creds.username = strdup(username); - } + if (dn_as_username) { + if (ssl_get_base_subject_file(proxyfile, + &my_creds.username)) { + fprintf(stderr, + "Cannot get subject name from your certificate\n"); + goto cleanup; + } + } else { + char *username = NULL; + if (!(username = getenv("LOGNAME"))) { + fprintf(stderr, "Please specify a username.\n"); + goto cleanup; + } + my_creds.username = strdup(username); + } } if (ssl_get_base_subject_file(proxyfile, - &my_creds.owner_name)) { - fprintf(stderr, - "Cannot get subject name from certificate.\n"); - goto cleanup; + &my_creds.owner_name)) { + fprintf(stderr, + "Cannot get subject name from certificate.\n"); + goto cleanup; } my_creds.location = strdup(proxyfile); if (myproxy_creds_store(&my_creds) < 0) { - myproxy_log_verror(); - fprintf (stderr, "Unable to store credentials. %s\n", - verror_get_string()); + myproxy_log_verror(); + fprintf (stderr, "Unable to store credentials. %s\n", + verror_get_string()); goto cleanup; } else { - fprintf (stdout, "Credential stored successfully\n"); + fprintf (stdout, "Credential stored successfully\n"); } rval = 0; @@ -176,9 +176,9 @@ int main(int argc, char *argv[]) } -void -init_arguments(int argc, - char *argv[], myproxy_creds_t *my_creds) +void +init_arguments(int argc, + char *argv[], myproxy_creds_t *my_creds) { extern char *optarg; int arg; @@ -186,176 +186,176 @@ init_arguments(int argc, my_creds->lifetime = SECONDS_PER_HOUR * MYPROXY_DEFAULT_DELEG_HOURS; - while((arg = getopt_long(argc, argv, short_options, - long_options, NULL)) != EOF) + while((arg = getopt_long(argc, argv, short_options, + long_options, NULL)) != EOF) { - switch(arg) - { + switch(arg) + { case 's': /* set the credential storage directory */ - myproxy_set_storage_dir(optarg); + myproxy_set_storage_dir(optarg); storage_dir = optarg; - break; - - case 'c': /* credential file name*/ - certfile = strdup (optarg); - break; - case 'y': /* key file name */ - keyfile = strdup (optarg); - break; - case 'u': /* print help and exit */ + break; + + case 'c': /* credential file name*/ + certfile = strdup (optarg); + break; + case 'y': /* key file name */ + keyfile = strdup (optarg); + break; + case 'u': /* print help and exit */ printf("%s", usage); exit(0); - break; - case 't': /* Specify proxy lifetime in hours */ - my_creds->lifetime = SECONDS_PER_HOUR * atoi(optarg); - break; - case 'h': /* print help and exit */ + break; + case 't': /* Specify proxy lifetime in hours */ + my_creds->lifetime = SECONDS_PER_HOUR * atoi(optarg); + break; + case 'h': /* print help and exit */ printf("%s", usage); exit(0); break; - case 'l': /* username */ - my_creds->username = strdup (optarg); - break; - case 'v': /* verbose */ - myproxy_debug_set_level(1); - break; + case 'l': /* username */ + my_creds->username = strdup (optarg); + break; + case 'v': /* verbose */ + myproxy_debug_set_level(1); + break; case 'V': /* print version and exit */ printf("%s", version); exit(0); break; - - - case 'r': /* retrievers list */ - if (my_creds->renewers) { - fprintf(stderr, "-r is incompatible with -A and -R. A credential may not be used for both\nretrieval and renewal. If both are desired, upload multiple credentials with\ndifferent names, using the -k option.\n"); - exit(1); - } - if (my_creds->retrievers) { - fprintf(stderr, "Only one -a or -r option may be specified.\n"); - exit(1); - } - if (expr_type == REGULAR_EXP) /*copy as is */ - my_creds->retrievers = strdup (optarg); - else - { - my_creds->retrievers = (char *)malloc(strlen(optarg)+6); - strcpy (my_creds->retrievers, "*/CN="); - my_creds->retrievers = strcat(my_creds->retrievers, - optarg); - myproxy_debug("authorized retriever %s", - my_creds->retrievers); - } - break; - case 'Z': /* retrievers list */ - if (my_creds->trusted_retrievers) { - fprintf(stderr, "Only one -Z option may be specified.\n"); - exit(1); - } - if (expr_type == REGULAR_EXP) /*copy as is */ - my_creds->trusted_retrievers = strdup (optarg); - else - { - my_creds->trusted_retrievers = (char *)malloc(strlen(optarg)+6); - strcpy (my_creds->trusted_retrievers, "*/CN="); - my_creds->trusted_retrievers = strcat(my_creds->trusted_retrievers, - optarg); - myproxy_debug("trusted retriever %s", - my_creds->trusted_retrievers); - } - break; - case 'R': /* renewers list */ - if (my_creds->retrievers) { - fprintf(stderr, "-R is incompatible with -a and -r. A credential may not be used for both\nretrieval and renewal. If both are desired, upload multiple credentials with\ndifferent names, using the -k option.\n"); - exit(1); - } - if (my_creds->renewers) { - fprintf(stderr, "Only one -A or -R option may be specified.\n"); - exit(1); - } - if (expr_type == REGULAR_EXP) /*copy as is */ - my_creds->renewers = strdup (optarg); - else - { - my_creds->renewers = (char *)malloc(strlen(optarg)+6); - strcpy (my_creds->renewers, "*/CN="); - my_creds->renewers = strcat (my_creds->renewers,optarg); - myproxy_debug("authorized renewer %s", - my_creds->renewers); - } - break; - case 'd': /* use the certificate subject (DN) as the default - username instead of LOGNAME */ - dn_as_username = 1; - break; - case 'x': /*set expression type to regex*/ - expr_type = REGULAR_EXP; - myproxy_debug("expr-type = regex"); - break; - case 'X': /*set expression type to common name*/ - expr_type = MATCH_CN_ONLY; - myproxy_debug("expr-type = CN"); - break; - case 'a': /*allow anonymous retrievers*/ - if (my_creds->renewers) { - fprintf(stderr, "-a is incompatible with -A and -R. A credential may not be used for both\nretrieval and renewal. If both are desired, upload multiple credentials with\ndifferent names, using the -k option.\n"); - exit(1); - } - if (my_creds->retrievers) { - fprintf(stderr, "Only one -a or -r option may be specified.\n"); - exit(1); - } - my_creds->retrievers = strdup ("*"); - myproxy_debug("anonymous retrievers allowed"); - break; - case 'A': /*allow anonymous renewers*/ - if (my_creds->retrievers) { - fprintf(stderr, "-A is incompatible with -a and -r. A credential may not be used for both\nretrieval and renewal. If both are desired, upload multiple credentials with\ndifferent names, using the -k option.\n"); - exit(1); - } - if (my_creds->renewers) { - fprintf(stderr, "Only one -A or -R option may be specified.\n"); - exit(1); - } - my_creds->renewers = strdup ("*"); - myproxy_debug("anonymous renewers allowed"); - break; - case 'E' : /* key retriever list */ - if (expr_type == REGULAR_EXP) { - /* Copy as is */ - my_creds->keyretrieve = strdup(optarg); - } else { - my_creds->keyretrieve = - (char *) malloc(strlen(optarg) + 6); - strcpy(my_creds->keyretrieve, "*/CN="); - my_creds->keyretrieve = - strcat(my_creds->keyretrieve, optarg); - myproxy_debug("authorized key retriever %s", - my_creds->keyretrieve); - } - break; - case 'k': /*credential name*/ - my_creds->credname = strdup (optarg); - break; - case 'K': /*credential description*/ - my_creds->creddesc = strdup (optarg); - break; - - default: /* print usage and exit */ + + + case 'r': /* retrievers list */ + if (my_creds->renewers) { + fprintf(stderr, "-r is incompatible with -A and -R. A credential may not be used for both\nretrieval and renewal. If both are desired, upload multiple credentials with\ndifferent names, using the -k option.\n"); + exit(1); + } + if (my_creds->retrievers) { + fprintf(stderr, "Only one -a or -r option may be specified.\n"); + exit(1); + } + if (expr_type == REGULAR_EXP) /*copy as is */ + my_creds->retrievers = strdup (optarg); + else + { + my_creds->retrievers = (char *)malloc(strlen(optarg)+6); + strcpy (my_creds->retrievers, "*/CN="); + my_creds->retrievers = strcat(my_creds->retrievers, + optarg); + myproxy_debug("authorized retriever %s", + my_creds->retrievers); + } + break; + case 'Z': /* retrievers list */ + if (my_creds->trusted_retrievers) { + fprintf(stderr, "Only one -Z option may be specified.\n"); + exit(1); + } + if (expr_type == REGULAR_EXP) /*copy as is */ + my_creds->trusted_retrievers = strdup (optarg); + else + { + my_creds->trusted_retrievers = (char *)malloc(strlen(optarg)+6); + strcpy (my_creds->trusted_retrievers, "*/CN="); + my_creds->trusted_retrievers = strcat(my_creds->trusted_retrievers, + optarg); + myproxy_debug("trusted retriever %s", + my_creds->trusted_retrievers); + } + break; + case 'R': /* renewers list */ + if (my_creds->retrievers) { + fprintf(stderr, "-R is incompatible with -a and -r. A credential may not be used for both\nretrieval and renewal. If both are desired, upload multiple credentials with\ndifferent names, using the -k option.\n"); + exit(1); + } + if (my_creds->renewers) { + fprintf(stderr, "Only one -A or -R option may be specified.\n"); + exit(1); + } + if (expr_type == REGULAR_EXP) /*copy as is */ + my_creds->renewers = strdup (optarg); + else + { + my_creds->renewers = (char *)malloc(strlen(optarg)+6); + strcpy (my_creds->renewers, "*/CN="); + my_creds->renewers = strcat (my_creds->renewers,optarg); + myproxy_debug("authorized renewer %s", + my_creds->renewers); + } + break; + case 'd': /* use the certificate subject (DN) as the default + username instead of LOGNAME */ + dn_as_username = 1; + break; + case 'x': /*set expression type to regex*/ + expr_type = REGULAR_EXP; + myproxy_debug("expr-type = regex"); + break; + case 'X': /*set expression type to common name*/ + expr_type = MATCH_CN_ONLY; + myproxy_debug("expr-type = CN"); + break; + case 'a': /*allow anonymous retrievers*/ + if (my_creds->renewers) { + fprintf(stderr, "-a is incompatible with -A and -R. A credential may not be used for both\nretrieval and renewal. If both are desired, upload multiple credentials with\ndifferent names, using the -k option.\n"); + exit(1); + } + if (my_creds->retrievers) { + fprintf(stderr, "Only one -a or -r option may be specified.\n"); + exit(1); + } + my_creds->retrievers = strdup ("*"); + myproxy_debug("anonymous retrievers allowed"); + break; + case 'A': /*allow anonymous renewers*/ + if (my_creds->retrievers) { + fprintf(stderr, "-A is incompatible with -a and -r. A credential may not be used for both\nretrieval and renewal. If both are desired, upload multiple credentials with\ndifferent names, using the -k option.\n"); + exit(1); + } + if (my_creds->renewers) { + fprintf(stderr, "Only one -A or -R option may be specified.\n"); + exit(1); + } + my_creds->renewers = strdup ("*"); + myproxy_debug("anonymous renewers allowed"); + break; + case 'E' : /* key retriever list */ + if (expr_type == REGULAR_EXP) { + /* Copy as is */ + my_creds->keyretrieve = strdup(optarg); + } else { + my_creds->keyretrieve = + (char *) malloc(strlen(optarg) + 6); + strcpy(my_creds->keyretrieve, "*/CN="); + my_creds->keyretrieve = + strcat(my_creds->keyretrieve, optarg); + myproxy_debug("authorized key retriever %s", + my_creds->keyretrieve); + } + break; + case 'k': /*credential name*/ + my_creds->credname = strdup (optarg); + break; + case 'K': /*credential description*/ + my_creds->creddesc = strdup (optarg); + break; + + default: /* print usage and exit */ fprintf(stderr, "%s", usage); - exit(1); - break; + exit(1); + break; } } if (optind != argc) { - fprintf(stderr, "%s: invalid option -- %s\n", argv[0], - argv[optind]); - fprintf(stderr, "%s", usage); - exit(1); + fprintf(stderr, "%s: invalid option -- %s\n", argv[0], + argv[optind]); + fprintf(stderr, "%s", usage); + exit(1); } } int makeproxy(const char certfile[], const char keyfile[], - const char proxyfile[]) + const char proxyfile[]) { static char BEGINCERT[] = "-----BEGIN CERTIFICATE-----"; static char ENDCERT[] = "-----END CERTIFICATE-----"; @@ -366,20 +366,20 @@ int makeproxy(const char certfile[], const char keyfile[], static char ENDKEY2[] = "-----END PRIVATE KEY-----"; static char ENDKEY3[] = "-----END ENCRYPTED PRIVATE KEY-----"; unsigned char *certbuf=NULL, *keybuf=NULL; - char *certstart, *certend, *keystart, *keyend; + const char *certstart, *certend, *keystart, *keyend; int return_value = -1, size, rval, fd=0; uid_t owner; /* Read the certificate(s) into a buffer. */ if (buffer_from_file(certfile, &certbuf, NULL) < 0) { - fprintf(stderr, "Failed to read %s\n", certfile); - goto cleanup; + fprintf(stderr, "Failed to read %s\n", certfile); + goto cleanup; } /* Read the key into a buffer. */ if (buffer_from_file(keyfile, &keybuf, NULL) < 0) { - fprintf(stderr, "Failed to read %s\n", keyfile); - goto cleanup; + fprintf(stderr, "Failed to read %s\n", keyfile); + goto cleanup; } /* special case: run as root w/ non-root storage dir */ @@ -390,96 +390,96 @@ int makeproxy(const char certfile[], const char keyfile[], /* Open the output file. */ if ((fd = open(proxyfile, O_CREAT | O_EXCL | O_WRONLY, - S_IRUSR | S_IWUSR)) < 0) { - fprintf(stderr, "open(%s) failed: %s\n", proxyfile, strerror(errno)); - goto cleanup; + S_IRUSR | S_IWUSR)) < 0) { + fprintf(stderr, "open(%s) failed: %s\n", proxyfile, strerror(errno)); + goto cleanup; } /* Write the first certificate. */ if ((certstart = strstr((const char *)certbuf, BEGINCERT)) == NULL) { - fprintf(stderr, "%s doesn't contain '%s'.\n", certfile, BEGINCERT); - goto cleanup; + fprintf(stderr, "%s doesn't contain '%s'.\n", certfile, BEGINCERT); + goto cleanup; } if ((certend = strstr((const char *)certstart, ENDCERT)) == NULL) { - fprintf(stderr, "%s doesn't contain '%s'.\n", certfile, ENDCERT); - goto cleanup; + fprintf(stderr, "%s doesn't contain '%s'.\n", certfile, ENDCERT); + goto cleanup; } certend += strlen(ENDCERT); size = certend-certstart; while (size) { - if ((rval = write(fd, certstart, size)) < 0) { - perror("write"); - goto cleanup; - } - size -= rval; - certstart += rval; + if ((rval = write(fd, certstart, size)) < 0) { + perror("write"); + goto cleanup; + } + size -= rval; + certstart += rval; } if (write(fd, "\n", 1) < 0) { - perror("write"); - goto cleanup; + perror("write"); + goto cleanup; } /* Write the key. */ if ((keystart = strstr((const char *)keybuf, BEGINKEY1)) == NULL - && (keystart = strstr((const char *)keybuf, BEGINKEY2)) == NULL - && (keystart = strstr((const char *)keybuf, BEGINKEY3)) == NULL) { - fprintf(stderr, "%s doesn't contain '%s' nor '%s' nor '%s'.\n", keyfile, - BEGINKEY1, BEGINKEY2, BEGINKEY3); - goto cleanup; + && (keystart = strstr((const char *)keybuf, BEGINKEY2)) == NULL + && (keystart = strstr((const char *)keybuf, BEGINKEY3)) == NULL) { + fprintf(stderr, "%s doesn't contain '%s' nor '%s' nor '%s'.\n", keyfile, + BEGINKEY1, BEGINKEY2, BEGINKEY3); + goto cleanup; } if ((keyend = strstr((const char *)keystart, ENDKEY1)) != NULL) - keyend += strlen(ENDKEY1); + keyend += strlen(ENDKEY1); else if ((keyend = strstr((const char *)keystart, ENDKEY2)) != NULL) - keyend += strlen(ENDKEY2); + keyend += strlen(ENDKEY2); else if ((keyend = strstr((const char *)keystart, ENDKEY3)) != NULL) - keyend += strlen(ENDKEY3); + keyend += strlen(ENDKEY3); else { - fprintf(stderr, "%s doesn't contain '%s' nor '%s' nor '%s'.\n", keyfile, - ENDKEY1, ENDKEY2, ENDKEY3); - goto cleanup; + fprintf(stderr, "%s doesn't contain '%s' nor '%s' nor '%s'.\n", keyfile, + ENDKEY1, ENDKEY2, ENDKEY3); + goto cleanup; } size = keyend-keystart; while (size) { - if ((rval = write(fd, keystart, size)) < 0) { - perror("write"); - goto cleanup; - } - size -= rval; - keystart += rval; + if ((rval = write(fd, keystart, size)) < 0) { + perror("write"); + goto cleanup; + } + size -= rval; + keystart += rval; } if (write(fd, "\n", 1) < 0) { - perror("write"); - goto cleanup; + perror("write"); + goto cleanup; } /* Write any remaining certificates. */ while ((certstart = strstr((const char *)certstart, BEGINCERT)) != NULL) { - if ((certend = strstr((const char *)certstart, ENDCERT)) == NULL) { - fprintf(stderr, "Can't find matching '%s' in %s.\n", ENDCERT, - certfile); - goto cleanup; - } - certend += strlen(ENDCERT); - size = certend-certstart; - - while (size) { - if ((rval = write(fd, certstart, size)) < 0) { - perror("write"); - goto cleanup; - } - size -= rval; - certstart += rval; - } - if (write(fd, "\n", 1) < 0) { - perror("write"); - goto cleanup; - } + if ((certend = strstr((const char *)certstart, ENDCERT)) == NULL) { + fprintf(stderr, "Can't find matching '%s' in %s.\n", ENDCERT, + certfile); + goto cleanup; + } + certend += strlen(ENDCERT); + size = certend-certstart; + + while (size) { + if ((rval = write(fd, certstart, size)) < 0) { + perror("write"); + goto cleanup; + } + size -= rval; + certstart += rval; + } + if (write(fd, "\n", 1) < 0) { + perror("write"); + goto cleanup; + } } return_value = 0; diff --git a/myproxy/source/myproxy_get_credential.c b/myproxy/source/myproxy_get_credential.c index 298856dbf2..b60efaf381 100644 --- a/myproxy/source/myproxy_get_credential.c +++ b/myproxy/source/myproxy_get_credential.c @@ -4,7 +4,7 @@ * Webserver program to retrieve a end-entity credential from a myproxy-server */ -#include "myproxy_common.h" /* all needed headers included here */ +#include "myproxy_common.h" /* all needed headers included here */ #ifndef MAXPATHLEN #define MAXPATHLEN 4096 @@ -48,7 +48,7 @@ struct option long_options[] = {"version", no_argument, NULL, 'V'}, {"authorization", required_argument, NULL, 'r'}, {"dn_as_username", no_argument, NULL, 'd'}, - {"credname", required_argument, NULL, 'k'}, + {"credname", required_argument, NULL, 'k'}, {"stdin_pass", no_argument, NULL, 'S'}, {"no_passphrase", no_argument, NULL, 'n'}, {"certfile", required_argument, NULL, 'c'}, @@ -62,18 +62,18 @@ static char short_options[] = "hus:p:l:t:c:y:vVa:dk:SnT"; static char version[] = "myproxy-retrieve version " MYPROXY_VERSION " (" MYPROXY_VERSION_DATE ") " "\n"; -void -init_arguments(int argc, char *argv[], - myproxy_socket_attrs_t *attrs, - myproxy_request_t *request); - +void +init_arguments(int argc, char *argv[], + myproxy_socket_attrs_t *attrs, + myproxy_request_t *request); + int store_credential( char *delegfile, char *certfile, char *keyfile ); int -buffer2file( char *buffer, +buffer2file( const char *buffer, int size, int fd ); @@ -92,7 +92,7 @@ mkpath( char *path ); * Use setvbuf() instead of setlinebuf() since cygwin doesn't support * setlinebuf(). */ -#define my_setlinebuf(stream) setvbuf((stream), (char *) NULL, _IOLBF, 0) +#define my_setlinebuf(stream) setvbuf((stream), (char *) NULL, _IOLBF, 0) /* location of delegated proxy */ static char *certfile = NULL; /* certificate file name */ @@ -102,8 +102,8 @@ static int read_passwd_from_stdin = 0; static int use_empty_passwd = 0; int -main(int argc, char *argv[]) -{ +main(int argc, char *argv[]) +{ myproxy_socket_attrs_t *socket_attrs; myproxy_request_t *client_request; myproxy_response_t *server_response; @@ -116,10 +116,10 @@ main(int argc, char *argv[]) /* check library version */ if (myproxy_check_version()) { - fprintf(stderr, "MyProxy library version mismatch.\n" - "Expecting %s. Found %s.\n", - MYPROXY_VERSION_DATE, myproxy_version(0,0,0)); - exit(1); + fprintf(stderr, "MyProxy library version mismatch.\n" + "Expecting %s. Found %s.\n", + MYPROXY_VERSION_DATE, myproxy_version(0,0,0)); + exit(1); } myproxy_log_use_stream (stderr); @@ -154,36 +154,36 @@ main(int argc, char *argv[]) } if (getuid() == 0) { - get_host_credential_filenames( &certfile, &keyfile ); + get_host_credential_filenames( &certfile, &keyfile ); } else { - get_user_credential_filenames( &certfile, &keyfile ); + get_user_credential_filenames( &certfile, &keyfile ); } /* Initialize client arguments and create client request object */ init_arguments(argc, argv, socket_attrs, client_request); if (!certfile && !keyfile) { - fprintf(stderr, "Unable to determine credential output locations.\n" - "Use --certfile and --keyfile options.\n"); - goto error; + fprintf(stderr, "Unable to determine credential output locations.\n" + "Use --certfile and --keyfile options.\n"); + goto error; } else if (!certfile) { - fprintf(stderr, "Unable to determine certificate output location.\n" - "Use --certfile option.\n"); - goto error; + fprintf(stderr, "Unable to determine certificate output location.\n" + "Use --certfile option.\n"); + goto error; } else if (!keyfile) { - fprintf(stderr, "Unable to determine private key output location.\n" - "Use --keyfile option.\n"); - goto error; + fprintf(stderr, "Unable to determine private key output location.\n" + "Use --keyfile option.\n"); + goto error; } if (access(certfile, F_OK) == 0) { - fprintf(stderr, "%s exists.\n", certfile); - goto error; + fprintf(stderr, "%s exists.\n", certfile); + goto error; } if (access(keyfile, F_OK) == 0) { - fprintf(stderr, "%s exists.\n", keyfile); - goto error; + fprintf(stderr, "%s exists.\n", keyfile); + goto error; } /* Bootstrap trusted certificate directory if none exists. */ @@ -205,7 +205,7 @@ main(int argc, char *argv[]) verror_print_error(stderr); goto error; } - + /* Attempt anonymous-mode credential retrieval if we don't have a credential. */ GSI_SOCKET_allow_anonymous(socket_attrs->gsi_socket, 1); @@ -239,60 +239,60 @@ main(int argc, char *argv[]) if (!use_empty_passwd) { /* Allow user to provide a passphrase */ - int rval; - if (read_passwd_from_stdin) { - rval = myproxy_read_passphrase_stdin( - client_request->passphrase, - sizeof(client_request->passphrase), - NULL); - } else { - rval = myproxy_read_passphrase(client_request->passphrase, - sizeof(client_request->passphrase), - NULL); - } - if (rval == -1) { - verror_print_error(stderr); + int rval; + if (read_passwd_from_stdin) { + rval = myproxy_read_passphrase_stdin( + client_request->passphrase, + sizeof(client_request->passphrase), + NULL); + } else { + rval = myproxy_read_passphrase(client_request->passphrase, + sizeof(client_request->passphrase), + NULL); + } + if (rval == -1) { + verror_print_error(stderr); goto error; - } + } } if (client_request->username == NULL) { /* set default username */ - if (dn_as_username) { - if (client_request->authzcreds) { - if (ssl_get_base_subject_file(client_request->authzcreds, - &client_request->username)) { - fprintf(stderr, "Cannot get subject name from %s\n", - client_request->authzcreds); + if (dn_as_username) { + if (client_request->authzcreds) { + if (ssl_get_base_subject_file(client_request->authzcreds, + &client_request->username)) { + fprintf(stderr, "Cannot get subject name from %s\n", + client_request->authzcreds); goto error; - } - } else { - if (ssl_get_base_subject_file(NULL, - &client_request->username)) { - fprintf(stderr, - "Cannot get subject name from your certificate\n"); + } + } else { + if (ssl_get_base_subject_file(NULL, + &client_request->username)) { + fprintf(stderr, + "Cannot get subject name from your certificate\n"); goto error; - } - } - } else { - char *username = NULL; - if (!(username = getenv("LOGNAME"))) { - fprintf(stderr, "Please specify a username.\n"); + } + } + } else { + char *username = NULL; + if (!(username = getenv("LOGNAME"))) { + fprintf(stderr, "Please specify a username.\n"); goto error; - } - client_request->username = strdup(username); - } + } + client_request->username = strdup(username); + } } /* Serialize client request object */ requestlen = myproxy_serialize_request_ex(client_request, &request_buffer); if (requestlen < 0) { - verror_print_error(stderr); + verror_print_error(stderr); goto error; } /* Send request to the myproxy-server */ if (myproxy_send(socket_attrs, request_buffer, requestlen) < 0) { - verror_print_error(stderr); + verror_print_error(stderr); goto error; } free(request_buffer); @@ -308,8 +308,8 @@ main(int argc, char *argv[]) /* Accept delegated credentials from server */ deletefile = 1; if (myproxy_accept_credentials(socket_attrs, delegfile, - sizeof(delegfile)) < 0) { - verror_print_error(stderr); + sizeof(delegfile)) < 0) { + verror_print_error(stderr); goto error; } @@ -338,22 +338,22 @@ main(int argc, char *argv[]) /* Store file in trusted directory if requested and returned */ if (client_request->want_trusted_certs) { if (server_response->trusted_certs != NULL) { - if (myproxy_install_trusted_cert_files(server_response->trusted_certs) != 0) { - verror_print_error(stderr); - goto error; + if (myproxy_install_trusted_cert_files(server_response->trusted_certs) != 0) { + verror_print_error(stderr); + goto error; } else { - char *path; - path = get_trusted_certs_path(); + char *path; + path = get_trusted_certs_path(); if (path) { printf("Trust roots have been installed in %s.\n", path); free(path); } - } + } } else { myproxy_debug("Requested trusted certs but didn't get any.\n"); } } - + retval = 0; error: @@ -372,89 +372,89 @@ main(int argc, char *argv[]) return retval; } -void -init_arguments(int argc, - char *argv[], - myproxy_socket_attrs_t *attrs, - myproxy_request_t *request) -{ +void +init_arguments(int argc, + char *argv[], + myproxy_socket_attrs_t *attrs, + myproxy_request_t *request) +{ extern char *optarg; int arg; - while((arg = getopt_long(argc, argv, short_options, - long_options, NULL)) != EOF) + while((arg = getopt_long(argc, argv, short_options, + long_options, NULL)) != EOF) { - switch(arg) + switch(arg) { - case 's': /* pshost name */ - attrs->pshost = strdup(optarg); + case 's': /* pshost name */ + attrs->pshost = strdup(optarg); break; - case 'p': /* psport */ + case 'p': /* psport */ attrs->psport = atoi(optarg); break; - case 'h': /* print help and exit */ - case 'u': /* print help and exit */ + case 'h': /* print help and exit */ + case 'u': /* print help and exit */ printf("%s", usage); exit(0); break; - case 'l': /* username */ + case 'l': /* username */ request->username = strdup(optarg); break; - case 'a': /* special authorization */ - request->authzcreds = strdup(optarg); - use_empty_passwd = 1; - break; - case 'n': /* no passphrase */ - use_empty_passwd = 1; - break; - case 'v': - myproxy_debug_set_level(1); - break; + case 'a': /* special authorization */ + request->authzcreds = strdup(optarg); + use_empty_passwd = 1; + break; + case 'n': /* no passphrase */ + use_empty_passwd = 1; + break; + case 'v': + myproxy_debug_set_level(1); + break; case 'V': /* print version and exit */ printf("%s", version); exit(0); break; - case 'd': /* use the certificate subject (DN) as the default - username instead of LOGNAME */ - dn_as_username = 1; - break; - case 'k': /* credential name */ - request->credname = strdup (optarg); - break; - case 'S': - read_passwd_from_stdin = 1; - break; - case 'T': - request->want_trusted_certs = 1; + case 'd': /* use the certificate subject (DN) as the default + username instead of LOGNAME */ + dn_as_username = 1; + break; + case 'k': /* credential name */ + request->credname = strdup (optarg); + break; + case 'S': + read_passwd_from_stdin = 1; + break; + case 'T': + request->want_trusted_certs = 1; myproxy_debug("Requesting trusted certificates.\n"); - break; + break; case 'c': /* credential file name */ - if (certfile) free(certfile); + if (certfile) free(certfile); certfile = strdup(optarg); break; case 'y': /* key file name */ - if (keyfile) free(keyfile); + if (keyfile) free(keyfile); keyfile = strdup(optarg); break; - default: /* print usage and exit */ + default: /* print usage and exit */ fprintf(stderr, "%s", usage); - exit(1); - break; + exit(1); + break; } } /* Check to see if myproxy-server specified */ if (attrs->pshost == NULL) { - fprintf(stderr, "Unspecified myproxy-server. Set the MYPROXY_SERVER environment variable to\nthe hostname of the myproxy-server or run with '-s server-hostname'.\n"); - exit(1); + fprintf(stderr, "Unspecified myproxy-server. Set the MYPROXY_SERVER environment variable to\nthe hostname of the myproxy-server or run with '-s server-hostname'.\n"); + exit(1); } return; } int -store_credential( char *delegfile, - char *certfile, +store_credential( char *delegfile, + char *certfile, char *keyfile ) { unsigned char *input_buffer = NULL; @@ -488,13 +488,13 @@ store_credential( char *delegfile, } int -write_cert( char *path, +write_cert( char *path, const char *buffer ) { int fd = 0; static char BEGINCERT[] = "-----BEGIN CERTIFICATE-----"; static char ENDCERT[] = "-----END CERTIFICATE-----"; - char *certstart, + const char *certstart, *certend; int retval = -1; int size; @@ -570,7 +570,7 @@ write_cert( char *path, } int -write_key( char *path, +write_key( char *path, const char *buffer ) { int fd = 0; @@ -580,7 +580,7 @@ write_key( char *path, static char ENDKEY1[] = "-----END RSA PRIVATE KEY-----"; static char ENDKEY2[] = "-----END PRIVATE KEY-----"; static char ENDKEY3[] = "-----END ENCRYPTED PRIVATE KEY-----"; - char *keystart, + const char *keystart, *keyend; int retval = -1; int size; @@ -607,24 +607,24 @@ write_key( char *path, /* Write the key. */ if ((keystart = strstr(buffer, BEGINKEY1)) == NULL - && (keystart = strstr(buffer, BEGINKEY2)) == NULL - && (keystart = strstr(buffer, BEGINKEY3)) == NULL) + && (keystart = strstr(buffer, BEGINKEY2)) == NULL + && (keystart = strstr(buffer, BEGINKEY3)) == NULL) { fprintf(stderr, "CREDKEY doesn't contain '%s' nor '%s' nor '%s'.\n", - BEGINKEY1, BEGINKEY2, BEGINKEY3); + BEGINKEY1, BEGINKEY2, BEGINKEY3); goto error; } if ((keyend = strstr(keystart, ENDKEY1)) != NULL) - keyend += strlen(ENDKEY1); + keyend += strlen(ENDKEY1); else if ((keyend = strstr(keystart, ENDKEY2)) != NULL) - keyend += strlen(ENDKEY2); + keyend += strlen(ENDKEY2); else if ((keyend = strstr(keystart, ENDKEY3)) != NULL) - keyend += strlen(ENDKEY3); + keyend += strlen(ENDKEY3); else { fprintf(stderr, "CREDKEY doesn't contain '%s' nor '%s' nor '%s'.\n", - ENDKEY1, ENDKEY2, ENDKEY3); + ENDKEY1, ENDKEY2, ENDKEY3); goto error; } @@ -648,12 +648,12 @@ write_key( char *path, } int -buffer2file( char *buffer, +buffer2file( const char *buffer, int size, int fd ) { int rval; - char *certstart; + const char *certstart; certstart = buffer; diff --git a/myproxy/source/myproxy_ocsp.c b/myproxy/source/myproxy_ocsp.c index cd584a3f3d..1cde641c74 100644 --- a/myproxy/source/myproxy_ocsp.c +++ b/myproxy/source/myproxy_ocsp.c @@ -4,19 +4,19 @@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are - * met: + * met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * 3. Neither the names of the authors nor the names of the * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -86,7 +86,7 @@ myproxy_ocsp_set_responder_cert(const char *path) { int count; int rval = -1; - sk_X509_pop_free(responder_cert, X509_free); + sk_X509_pop_free(responder_cert, X509_free); responder_cert = NULL; in = BIO_new(BIO_s_file()); @@ -164,11 +164,15 @@ static int verify_cert_hostname(X509 *cert, char *hostname) { int extcount, i, j, ok = 0; char name[256]; - X509_NAME *subj; + const X509_NAME *subj; const char *extstr; CONF_VALUE *nval; const unsigned char *data; +#if OPENSSL_VERSION_NUMBER < 0x40000000L X509_EXTENSION *ext; +#else + const X509_EXTENSION *ext; +#endif X509V3_EXT_METHOD *meth; STACK_OF(CONF_VALUE) *val; @@ -178,9 +182,9 @@ verify_cert_hostname(X509 *cert, char *hostname) { extstr = OBJ_nid2sn(OBJ_obj2nid(X509_EXTENSION_get_object(ext))); if (!strcasecmp(extstr, "subjectAltName")) { if (!(meth = (X509V3_EXT_METHOD *)X509V3_EXT_get(ext))) break; - data = X509_EXTENSION_get_data(ext)->data; + data = ASN1_STRING_get0_data(X509_EXTENSION_get_data(ext)); - val = meth->i2v(meth, meth->d2i(0, &data, X509_EXTENSION_get_data(ext)->length), 0); + val = meth->i2v(meth, meth->d2i(0, &data, ASN1_STRING_length(X509_EXTENSION_get_data(ext))), 0); for (j = 0; j < sk_CONF_VALUE_num(val); j++) { nval = sk_CONF_VALUE_value(val, j); if (!strcasecmp(nval->name, "DNS") && !strcasecmp(nval->value, hostname)) { @@ -365,7 +369,7 @@ int myproxy_ocsp_verify(X509 *cert, X509 *issuer) { if (!responder_cert || (rc = OCSP_basic_verify(basic, responder_cert, store, OCSP_TRUSTOTHER)) <= 0) - if ((rc = OCSP_basic_verify(basic, NULL, store, 0)) <= 0) + if ((rc = OCSP_basic_verify(basic, NULL, store, 0)) <= 0) goto end; if (!OCSP_resp_find_status(basic, id, &status, &reason, &producedAt, diff --git a/myproxy/source/myproxy_ocsp_aia.c b/myproxy/source/myproxy_ocsp_aia.c index 91ee306b19..4a62465f54 100644 --- a/myproxy/source/myproxy_ocsp_aia.c +++ b/myproxy/source/myproxy_ocsp_aia.c @@ -35,79 +35,95 @@ #include #include +#if OPENSSL_VERSION_NUMBER < 0x40000000L static AUTHORITY_INFO_ACCESS * -my_aia_get(X509_EXTENSION *ext) { - const X509V3_EXT_METHOD *method = NULL; - void *ext_str = NULL; - const unsigned char *p; - int len; - - if (ext == NULL) { - verror_put_string("my_aia_get: ext is NULL"); - return(NULL); - } - - method = X509V3_EXT_get(ext); - if (method == NULL) { - myproxy_debug("my_aia_get: cannot get method"); - return(NULL); - } - - p = X509_EXTENSION_get_data(ext)->data; - len = X509_EXTENSION_get_data(ext)->length; - if (method->it) { - ext_str = ASN1_item_d2i(NULL, &p, len, ASN1_ITEM_ptr(method->it)); - } else { - ext_str = method->d2i(NULL, &p, len); - } - if (ext_str == NULL) { - myproxy_debug("my_aia_get: null ext_str!"); - return(NULL); - } - - return((AUTHORITY_INFO_ACCESS*)ext_str); +my_aia_get(X509_EXTENSION *ext) +#else +static AUTHORITY_INFO_ACCESS * +my_aia_get(const X509_EXTENSION *ext) +#endif +{ + const X509V3_EXT_METHOD *method = NULL; + void *ext_str = NULL; + const unsigned char *p; + int len; + + if (ext == NULL) { + verror_put_string("my_aia_get: ext is NULL"); + return(NULL); + } + + method = X509V3_EXT_get(ext); + if (method == NULL) { + myproxy_debug("my_aia_get: cannot get method"); + return(NULL); + } + + p = ASN1_STRING_get0_data(X509_EXTENSION_get_data(ext)); + len = ASN1_STRING_length(X509_EXTENSION_get_data(ext)); + if (method->it) { + ext_str = ASN1_item_d2i(NULL, &p, len, ASN1_ITEM_ptr(method->it)); + } else { + ext_str = method->d2i(NULL, &p, len); + } + if (ext_str == NULL) { + myproxy_debug("my_aia_get: null ext_str!"); + return(NULL); + } + + return((AUTHORITY_INFO_ACCESS*)ext_str); } +#if OPENSSL_VERSION_NUMBER < 0x40000000L static void -my_aia_free(X509_EXTENSION *ext, AUTHORITY_INFO_ACCESS* aia) { - const X509V3_EXT_METHOD *method = NULL; - - if (ext == NULL) { - verror_put_string("my_aia_free: ext is NULL"); - return; - } - - method = X509V3_EXT_get(ext); - if (method == NULL) return; - - if (method->it) { - ASN1_item_free((void*)aia, ASN1_ITEM_ptr(method->it)); - } else { - method->ext_free(aia); - } +my_aia_free(X509_EXTENSION *ext, AUTHORITY_INFO_ACCESS* aia) +#else +static void +my_aia_free(const X509_EXTENSION *ext, AUTHORITY_INFO_ACCESS* aia) +#endif +{ + const X509V3_EXT_METHOD *method = NULL; + + if (ext == NULL) { + verror_put_string("my_aia_free: ext is NULL"); + return; + } + + method = X509V3_EXT_get(ext); + if (method == NULL) return; + + if (method->it) { + ASN1_item_free((void*)aia, ASN1_ITEM_ptr(method->it)); + } else { + method->ext_free(aia); + } } char * myproxy_get_aia_ocsp_uri(X509 *cert) { - int loc = -1; + int loc = -1; char *uri = NULL; - if (cert == NULL) return(0); + if (cert == NULL) return(0); - for (loc = X509_get_ext_by_NID(cert, NID_info_access, loc); + for (loc = X509_get_ext_by_NID(cert, NID_info_access, loc); loc >= 0; loc = X509_get_ext_by_NID(cert, NID_info_access, loc)) { - X509_EXTENSION *xe; - AUTHORITY_INFO_ACCESS *aia; +#if OPENSSL_VERSION_NUMBER < 0x40000000L + X509_EXTENSION *xe; +#else + const X509_EXTENSION *xe; +#endif + AUTHORITY_INFO_ACCESS *aia; int k; - xe = X509_get_ext(cert, loc); - if (xe == NULL) { - myproxy_debug("get_aia_ocsp_uri: cannot get x509 extension"); - continue; - } + xe = X509_get_ext(cert, loc); + if (xe == NULL) { + myproxy_debug("get_aia_ocsp_uri: cannot get x509 extension"); + continue; + } aia = my_aia_get(xe); if (aia == NULL) continue; @@ -123,14 +139,14 @@ myproxy_get_aia_ocsp_uri(X509 *cert) if (gn->type != GEN_URI) continue; asn1_uri = gn->d.uniformResourceIdentifier; - uri = strdup((const char*)asn1_uri->data); + uri = strdup((const char*)ASN1_STRING_get0_data(asn1_uri)); break; } my_aia_free(xe, aia); - if (uri) break; - } + if (uri) break; + } return uri; } diff --git a/myproxy/source/myproxy_store.c b/myproxy/source/myproxy_store.c index 19d02e2f56..1efd8ce7ce 100644 --- a/myproxy/source/myproxy_store.c +++ b/myproxy/source/myproxy_store.c @@ -4,7 +4,7 @@ * Client program to store a end-entity credential to a myproxy-server */ -#include "myproxy_common.h" /* all needed headers included here */ +#include "myproxy_common.h" /* all needed headers included here */ /* Location of default proxy */ #define MYPROXY_DEFAULT_USERCERT "usercert.pem" @@ -85,27 +85,27 @@ static char version[] = "myproxy-store version " MYPROXY_VERSION " (" MYPROXY_VERSION_DATE ") " "\n"; -static char *certfile = NULL; /* certificate file name */ -static char *keyfile = NULL; /* key file name */ +static char *certfile = NULL; /* certificate file name */ +static char *keyfile = NULL; /* key file name */ static int dn_as_username = 0; static int verbose = 0; /* Function declarations */ -int +int init_arguments( int argc, - char *argv[], - myproxy_socket_attrs_t *attrs, + char *argv[], + myproxy_socket_attrs_t *attrs, myproxy_request_t *request); -int +int makecertfile( const char certfile[], - const char keyfile[], + const char keyfile[], char **credbuf); -#define SECONDS_PER_HOUR (60 * 60) +#define SECONDS_PER_HOUR (60 * 60) -int -main(int argc, +int +main(int argc, char *argv[]) { char *pshost = NULL; @@ -120,10 +120,10 @@ main(int argc, /* check library version */ if (myproxy_check_version()) { - fprintf(stderr, "MyProxy library version mismatch.\n" - "Expecting %s. Found %s.\n", - MYPROXY_VERSION_DATE, myproxy_version(0,0,0)); - exit(1); + fprintf(stderr, "MyProxy library version mismatch.\n" + "Expecting %s. Found %s.\n", + MYPROXY_VERSION_DATE, myproxy_version(0,0,0)); + exit(1); } myproxy_log_use_stream(stderr); @@ -145,18 +145,18 @@ main(int argc, pshost = getenv("MYPROXY_SERVER"); if (pshost != NULL) { - socket_attrs->pshost = strdup(pshost); + socket_attrs->pshost = strdup(pshost); } if (getenv("MYPROXY_SERVER_PORT")) { - socket_attrs->psport = atoi(getenv("MYPROXY_SERVER_PORT")); + socket_attrs->psport = atoi(getenv("MYPROXY_SERVER_PORT")); } else { - socket_attrs->psport = MYPROXY_SERVER_PORT; + socket_attrs->psport = MYPROXY_SERVER_PORT; } globus_module_activate(GLOBUS_GSI_SYSCONFIG_MODULE); GLOBUS_GSI_SYSCONFIG_GET_USER_CERT_FILENAME( &certfile, - &keyfile ); + &keyfile ); client_request->proxy_lifetime = SECONDS_PER_HOUR * MYPROXY_DEFAULT_DELEG_HOURS; @@ -168,17 +168,17 @@ main(int argc, } if (!certfile && !keyfile) { - fprintf(stderr, "Credentials not found in default location.\n" - "Use --certfile and --keyfile options.\n"); - goto cleanup; + fprintf(stderr, "Credentials not found in default location.\n" + "Use --certfile and --keyfile options.\n"); + goto cleanup; } else if (!certfile) { - fprintf(stderr, "Certificate not found in default location.\n" - "Use --certfile option.\n"); - goto cleanup; + fprintf(stderr, "Certificate not found in default location.\n" + "Use --certfile option.\n"); + goto cleanup; } else if (!keyfile) { - fprintf(stderr, "Private key not found in default location.\n" - "Use --keyfile option.\n"); - goto cleanup; + fprintf(stderr, "Private key not found in default location.\n" + "Use --keyfile option.\n"); + goto cleanup; } /* @@ -192,7 +192,7 @@ main(int argc, /* Set up client socket attributes */ if (myproxy_init_client(socket_attrs) < 0) { - verror_print_error(stderr); + verror_print_error(stderr); goto cleanup; } @@ -217,7 +217,7 @@ main(int argc, /* Authenticate client to server */ if (myproxy_authenticate_init(socket_attrs, NULL) < 0) { - verror_print_error(stderr); + verror_print_error(stderr); goto cleanup; } @@ -239,14 +239,14 @@ main(int argc, /* Continue unless the response is not OK */ if (myproxy_recv_response_ex(socket_attrs, - server_response, client_request) != 0) { + server_response, client_request) != 0) { verror_print_error(stderr); goto cleanup; } /* Send end-entity credentials to server. */ if (myproxy_init_credentials(socket_attrs, - credkeybuf) < 0) { + credkeybuf) < 0) { verror_print_error(stderr); goto cleanup; } @@ -273,93 +273,93 @@ main(int argc, int init_arguments(int argc, - char *argv[], - myproxy_socket_attrs_t *attrs, + char *argv[], + myproxy_socket_attrs_t *attrs, myproxy_request_t * request) { extern char *optarg; - int expr_type = MATCH_CN_ONLY; /*default */ + int expr_type = MATCH_CN_ONLY; /*default */ int arg; while ((arg = getopt_long(argc, - argv, - short_options, - long_options, NULL)) != EOF) { - switch (arg) { - case 's': /* pshost name */ - attrs->pshost = strdup(optarg); - break; - - case 'p': /* psport */ - attrs->psport = atoi(optarg); - break; - - case 'c': /* credential file name */ - if (certfile) free(certfile); - certfile = strdup(optarg); - break; - - case 'y': /* key file name */ - if (keyfile) free(keyfile); - keyfile = strdup(optarg); - break; - - case 'u': /* print help and exit */ - printf("%s", usage); - exit(0); - break; - - case 't': /* Specify proxy lifetime in hours */ - request->proxy_lifetime = SECONDS_PER_HOUR * atoi(optarg); + argv, + short_options, + long_options, NULL)) != EOF) { + switch (arg) { + case 's': /* pshost name */ + attrs->pshost = strdup(optarg); + break; + + case 'p': /* psport */ + attrs->psport = atoi(optarg); + break; + + case 'c': /* credential file name */ + if (certfile) free(certfile); + certfile = strdup(optarg); + break; + + case 'y': /* key file name */ + if (keyfile) free(keyfile); + keyfile = strdup(optarg); + break; + + case 'u': /* print help and exit */ + printf("%s", usage); + exit(0); + break; + + case 't': /* Specify proxy lifetime in hours */ + request->proxy_lifetime = SECONDS_PER_HOUR * atoi(optarg); if (request->proxy_lifetime < 0) { fprintf(stderr, "Requested lifetime (-t option) out of bounds.\n"); exit(1); } - break; + break; + + case 'h': /* print help and exit */ + printf("%s", usage); + exit(0); + break; - case 'h': /* print help and exit */ - printf("%s", usage); - exit(0); - break; + case 'l': /* username */ + request->username = strdup(optarg); + break; - case 'l': /* username */ - request->username = strdup(optarg); - break; + case 'v': /* verbose */ + myproxy_debug_set_level(1); + verbose = 1; + break; - case 'v': /* verbose */ - myproxy_debug_set_level(1); - verbose = 1; - break; + case 'V': /* print version and exit */ + printf("%s", version); + exit(0); + break; - case 'V': /* print version and exit */ - printf("%s", version); - exit(0); - break; + case 'r': /* retrievers list */ + if (request->retrievers) { + fprintf(stderr, + "Only one -a or -r option may be specified.\n"); + exit(1); + } - case 'r': /* retrievers list */ - if (request->retrievers) { - fprintf(stderr, - "Only one -a or -r option may be specified.\n"); - exit(1); - } + if (expr_type == REGULAR_EXP) { - if (expr_type == REGULAR_EXP) { - /* Copy as is */ - request->retrievers = strdup(optarg); - } else { - request->retrievers = - (char *) malloc(strlen(optarg) + 6); - strcpy(request->retrievers, "*/CN="); - myproxy_debug("authorized retriever %s", - request->retrievers); - request->retrievers = - strcat(request->retrievers, optarg); - } - break; - - case 'R': /* renewers list */ + request->retrievers = strdup(optarg); + } else { + request->retrievers = + (char *) malloc(strlen(optarg) + 6); + strcpy(request->retrievers, "*/CN="); + myproxy_debug("authorized retriever %s", + request->retrievers); + request->retrievers = + strcat(request->retrievers, optarg); + } + break; + + case 'R': /* renewers list */ /* ** This needs to be readdressed. Right now, the private key is ** being stored encrypted. This is a problem if the user calls @@ -368,127 +368,127 @@ init_arguments(int argc, ** So, do we want to add code to unencrypt the private key if ** this option is used? */ - if (request->renewers) { - fprintf(stderr, - "Only one -A or -R option may be specified.\n"); - exit(1); - } - - if (expr_type == REGULAR_EXP) { - /* Copy as is */ - request->renewers = strdup(optarg); - } else { - request->renewers = - (char *) malloc(strlen(optarg) + 6); - strcpy(request->renewers, "*/CN="); - myproxy_debug("authorized renewer %s", request->renewers); - request->renewers = strcat(request->renewers, optarg); - } - break; - - case 'Z': /* retrievers list */ - if (request->trusted_retrievers) { - fprintf(stderr, - "Only one -Z option may be specified.\n"); - exit(1); - } - - if (expr_type == REGULAR_EXP) { - + if (request->renewers) { + fprintf(stderr, + "Only one -A or -R option may be specified.\n"); + exit(1); + } + + if (expr_type == REGULAR_EXP) { /* Copy as is */ - request->trusted_retrievers = strdup(optarg); - } else { - request->trusted_retrievers = - (char *) malloc(strlen(optarg) + 6); - strcpy(request->trusted_retrievers, "*/CN="); - myproxy_debug("trusted retriever %s", - request->trusted_retrievers); - request->trusted_retrievers = - strcat(request->trusted_retrievers, optarg); - } - break; - - case 'E' : /* key retriever list */ - if (expr_type == REGULAR_EXP) { - /* Copy as is */ - request->keyretrieve = strdup(optarg); - } else { - request->keyretrieve = - (char *) malloc(strlen(optarg) + 6); - strcpy(request->keyretrieve, "*/CN="); - myproxy_debug("authorized key retriever %s", - request->keyretrieve); - request->keyretrieve = - strcat(request->keyretrieve, optarg); - } - break; - - case 'd': /* - ** use the certificate subject (DN) as the - ** default username instead of LOGNAME - */ - dn_as_username = 1; - break; - - case 'x': /*set expression type to regex */ - expr_type = REGULAR_EXP; - myproxy_debug("expr-type = regex"); - break; - - case 'X': /*set expression type to common name */ - expr_type = MATCH_CN_ONLY; - myproxy_debug("expr-type = CN"); - break; - - case 'a': /*allow anonymous retrievers */ - if (request->retrievers) { - fprintf(stderr, - "Only one -a or -r option may be specified.\n"); - exit(1); - } - - request->retrievers = strdup("*"); - myproxy_debug("anonymous retrievers allowed"); - break; - - case 'A': /*allow anonymous renewers */ - if (request->renewers) { - fprintf(stderr, - "Only one -A or -R option may be specified.\n"); - exit(1); - } - - request->renewers = strdup("*"); - myproxy_debug("anonymous renewers allowed"); - break; - - case 'k': /*credential name */ - request->credname = strdup(optarg); - break; - - case 'K': /*credential description */ - request->creddesc = strdup(optarg); - break; - - default: /* print usage and exit */ - fprintf(stderr, "%s", usage); - exit(1); - break; - } + request->renewers = strdup(optarg); + } else { + request->renewers = + (char *) malloc(strlen(optarg) + 6); + strcpy(request->renewers, "*/CN="); + myproxy_debug("authorized renewer %s", request->renewers); + request->renewers = strcat(request->renewers, optarg); + } + break; + + case 'Z': /* retrievers list */ + if (request->trusted_retrievers) { + fprintf(stderr, + "Only one -Z option may be specified.\n"); + exit(1); + } + + if (expr_type == REGULAR_EXP) { + + /* Copy as is */ + request->trusted_retrievers = strdup(optarg); + } else { + request->trusted_retrievers = + (char *) malloc(strlen(optarg) + 6); + strcpy(request->trusted_retrievers, "*/CN="); + myproxy_debug("trusted retriever %s", + request->trusted_retrievers); + request->trusted_retrievers = + strcat(request->trusted_retrievers, optarg); + } + break; + + case 'E' : /* key retriever list */ + if (expr_type == REGULAR_EXP) { + /* Copy as is */ + request->keyretrieve = strdup(optarg); + } else { + request->keyretrieve = + (char *) malloc(strlen(optarg) + 6); + strcpy(request->keyretrieve, "*/CN="); + myproxy_debug("authorized key retriever %s", + request->keyretrieve); + request->keyretrieve = + strcat(request->keyretrieve, optarg); + } + break; + + case 'd': /* + ** use the certificate subject (DN) as the + ** default username instead of LOGNAME + */ + dn_as_username = 1; + break; + + case 'x': /*set expression type to regex */ + expr_type = REGULAR_EXP; + myproxy_debug("expr-type = regex"); + break; + + case 'X': /*set expression type to common name */ + expr_type = MATCH_CN_ONLY; + myproxy_debug("expr-type = CN"); + break; + + case 'a': /*allow anonymous retrievers */ + if (request->retrievers) { + fprintf(stderr, + "Only one -a or -r option may be specified.\n"); + exit(1); + } + + request->retrievers = strdup("*"); + myproxy_debug("anonymous retrievers allowed"); + break; + + case 'A': /*allow anonymous renewers */ + if (request->renewers) { + fprintf(stderr, + "Only one -A or -R option may be specified.\n"); + exit(1); + } + + request->renewers = strdup("*"); + myproxy_debug("anonymous renewers allowed"); + break; + + case 'k': /*credential name */ + request->credname = strdup(optarg); + break; + + case 'K': /*credential description */ + request->creddesc = strdup(optarg); + break; + + default: /* print usage and exit */ + fprintf(stderr, "%s", usage); + exit(1); + break; + } } /* Check to see if myproxy-server specified */ if (attrs->pshost == NULL) { fprintf(stderr, "%s", usage); - fprintf(stderr, - "Unspecified myproxy-server! Either set the MYPROXY_SERVER environment variable or explicitly set the myproxy-server via the -s flag\n"); - return -1; + fprintf(stderr, + "Unspecified myproxy-server! Either set the MYPROXY_SERVER environment variable or explicitly set the myproxy-server via the -s flag\n"); + return -1; } return 0; } -int +int makecertfile(const char certfile[], const char keyfile[], char **credbuf) @@ -506,11 +506,11 @@ makecertfile(const char certfile[], static char ENDKEY1[] = "-----END RSA PRIVATE KEY-----"; static char ENDKEY2[] = "-----END PRIVATE KEY-----"; static char ENDKEY3[] = "-----END ENCRYPTED PRIVATE KEY-----"; - char *certstart; - char *certend; + const char *certstart; + const char *certend; int size; - char *keystart; - char *keyend; + const char *keystart; + const char *keyend; /* Figure out how much memory we are going to need */ @@ -530,8 +530,8 @@ makecertfile(const char certfile[], /* Read the certificate(s) into a buffer. */ if (buffer_from_file(certfile, &certbuf, NULL) < 0) { - fprintf(stderr, "Failed to read %s\n", certfile); - goto cleanup; + fprintf(stderr, "Failed to read %s\n", certfile); + goto cleanup; } /* Read the key into a buffer. */ @@ -554,29 +554,29 @@ makecertfile(const char certfile[], certend += strlen(ENDCERT); size = certend-certstart; - strncat( *credbuf, certstart, size ); + strncat( *credbuf, certstart, size ); strcat( *credbuf, "\n" ); certstart += size; /* Write the key. */ if ((keystart = strstr((const char *)keybuf, BEGINKEY1)) == NULL - && (keystart = strstr((const char *)keybuf, BEGINKEY2)) == NULL - && (keystart = strstr((const char *)keybuf, BEGINKEY3)) == NULL) { - fprintf(stderr, "%s doesn't contain '%s' nor '%s' nor %s.\n", keyfile, - BEGINKEY1, BEGINKEY2, BEGINKEY3); - goto cleanup; + && (keystart = strstr((const char *)keybuf, BEGINKEY2)) == NULL + && (keystart = strstr((const char *)keybuf, BEGINKEY3)) == NULL) { + fprintf(stderr, "%s doesn't contain '%s' nor '%s' nor %s.\n", keyfile, + BEGINKEY1, BEGINKEY2, BEGINKEY3); + goto cleanup; } if ((keyend = strstr(keystart, ENDKEY1)) != NULL) - keyend += strlen(ENDKEY1); + keyend += strlen(ENDKEY1); else if ((keyend = strstr(keystart, ENDKEY2)) != NULL) - keyend += strlen(ENDKEY2); + keyend += strlen(ENDKEY2); else if ((keyend = strstr(keystart, ENDKEY3)) != NULL) - keyend += strlen(ENDKEY3); + keyend += strlen(ENDKEY3); else { - fprintf(stderr, "%s doesn't contain '%s' nor '%s' nor %s.\n", keyfile, ENDKEY1, - ENDKEY2, ENDKEY3); - goto cleanup; + fprintf(stderr, "%s doesn't contain '%s' nor '%s' nor %s.\n", keyfile, ENDKEY1, + ENDKEY2, ENDKEY3); + goto cleanup; } size = keyend-keystart; @@ -595,8 +595,8 @@ makecertfile(const char certfile[], certend += strlen(ENDCERT); size = certend-certstart; - strncat( *credbuf, certstart, size ); - strcat( *credbuf, "\n" ); + strncat( *credbuf, certstart, size ); + strcat( *credbuf, "\n" ); certstart += size; } diff --git a/myproxy/source/plugin_common.c b/myproxy/source/plugin_common.c index d744c0d46d..8c0f96976d 100644 --- a/myproxy/source/plugin_common.c +++ b/myproxy/source/plugin_common.c @@ -731,7 +731,7 @@ int _plug_parseuser(const sasl_utils_t *utils, return SASL_BADPARAM; } - r = strchr(input, '@'); + r = (char *) strchr(input, '@'); if (!r) { /* hmmm, the user didn't specify a realm */ if(user_realm && user_realm[0]) { diff --git a/myproxy/source/ssl_utils.c b/myproxy/source/ssl_utils.c index e36134e2cf..c838487842 100644 --- a/myproxy/source/ssl_utils.c +++ b/myproxy/source/ssl_utils.c @@ -79,18 +79,27 @@ void ssl_error_to_verror() { unsigned long error; +#if OPENSSL_VERSION_NUMBER < 0x30000000L ERR_STATE *error_state; - const char *error_data; int error_number; +#else + int flags; +#endif + const char *error_data; while ((error = ERR_peek_error()) != 0) { +#if OPENSSL_VERSION_NUMBER < 0x30000000L /* Find data for last error */ error_state = ERR_get_state(); error_number = (error_state->bottom + 1) % ERR_NUM_ERRORS; error_data = error_state->err_data[error_number]; +#else + ERR_peek_error_data(&error_data, &flags); + if (!(flags & ERR_TXT_STRING)) error_data = NULL; +#endif /* Now add to verror state */ verror_put_string("%s", ERR_error_string(error, NULL)); diff --git a/myproxy/source/vomsclient.c b/myproxy/source/vomsclient.c index b441f9880d..7f41e4174f 100644 --- a/myproxy/source/vomsclient.c +++ b/myproxy/source/vomsclient.c @@ -14,7 +14,7 @@ int voms_init_delegation(myproxy_socket_attrs_t *attrs, char *voname, char *vomses, char *voms_userconf); -int voms_contact(SSL_CREDENTIALS *creds, int lifetime, +int voms_contact(SSL_CREDENTIALS *creds, int lifetime, char *voname, char *vomses, char *voms_userconf, unsigned char **aclist, int *aclist_length); @@ -35,7 +35,7 @@ voms_put_error_message(struct vomsdata *vd, int err) * get the user info for specified vo */ static int -voms_get_user_info(struct vomsdata *vd, +voms_get_user_info(struct vomsdata *vd, voms_command_t *command, char *vomses_path) { @@ -60,7 +60,7 @@ voms_get_user_info(struct vomsdata *vd, info->contact, command->command, vd, - &err); + &err); if (result) { /* if contact succeded jumps to other VOs */ return_code = 0; @@ -164,7 +164,7 @@ vomses_write_to_temporary(char *vomses, char *template) done: - return return_status; + return return_status; } static int @@ -198,8 +198,8 @@ static char * voms_get_role_command(const char *str) { char *buf = NULL; - char *p_role = NULL; - size_t buf_len, role_len;; + const char *p_role = NULL; + size_t buf_len, role_len;; int i = 0; if ((str == NULL) || (str[0] == '\0')) { @@ -232,7 +232,7 @@ static char * voms_get_mapping_command(const char *str) { char *buf = NULL; - char *p_role = NULL; + const char *p_role = NULL; size_t buf_len = 0, group_len = 0, role_len = 0; int i = 0; @@ -280,7 +280,7 @@ static char * voms_get_group_command(const char *str) { char *buf = NULL; - size_t buf_len = 0, str_len = 0; + size_t buf_len = 0, str_len = 0; int i = 0; if ((str == NULL) || (str[0] == '\0')) { @@ -315,7 +315,7 @@ voms_get_group_command(const char *str) static char * voms_convert_command(const char *str) { - char *p = NULL; + const char *p = NULL; char *result = NULL; if (str == NULL) { @@ -341,11 +341,11 @@ voms_convert_command(const char *str) return result; } -static int +static int voms_parse_command(const char *voms, char **vo, char **command) { int result = 1; - char *p_colon = NULL; + const char *p_colon = NULL; p_colon = strchr(voms, ':'); if (p_colon == NULL) { *vo = strdup(voms); @@ -448,12 +448,12 @@ voms_command_list_add(voms_command_t **headRef, const char *vo, const char *cmd) result = 0; } } else { - node = voms_command_list_find(current, vo); + node = voms_command_list_find(current, vo); if (node != NULL) { /* Append command to the node */ my_append(&(node->command), ",", cmd, NULL); result = 0; - } else { + } else { /* Create and Add a new node to last */ node = voms_command_new(vo, cmd); if (node != NULL) { @@ -575,13 +575,13 @@ get_AC_SEQ(struct vomsdata *vd, unsigned char **aclist, int *aclist_length) /* * Get VOMS User info - * + * * @param aclist DER-encoded AC-sequence * @param aclist_length length of aclist * Returns 0 on success or 1 on error. */ -int -voms_contact(SSL_CREDENTIALS *creds, int lifetime, +int +voms_contact(SSL_CREDENTIALS *creds, int lifetime, char *voname, char *vomses, char *voms_userconf, unsigned char **aclist, int *aclist_length) @@ -589,7 +589,7 @@ voms_contact(SSL_CREDENTIALS *creds, int lifetime, int return_code = 1; int verify_ac = 0; - struct vomsdata *vd = NULL; + struct vomsdata *vd = NULL; int err; int result = 1; int is_write_temp_vomses = 0; @@ -642,7 +642,7 @@ voms_contact(SSL_CREDENTIALS *creds, int lifetime, } is_write_temp_vomses = 1; } else { - if (voms_userconf == NULL) { + if (voms_userconf == NULL) { verror_put_string("No VOMS Server Information"); goto error; } @@ -661,8 +661,8 @@ voms_contact(SSL_CREDENTIALS *creds, int lifetime, /* Set X509_USER_CERT, X509_USER_KEY */ old_ucert = getenv("X509_USER_CERT"); old_ukey = getenv("X509_USER_KEY"); - /* - Save credential (cert & private key) to cred_path + /* + Save credential (cert & private key) to cred_path cred_path is modified on success. */ if ( credential_write_to_temporary(creds, cred_path) != SSL_SUCCESS ) { @@ -755,7 +755,7 @@ void get_voms_proxy(myproxy_socket_attrs_t *attrs, lifetime, request->passphrase, request->voname, - request->vomses, + request->vomses, config->voms_userconf) < 0) { response->response_type = MYPROXY_ERROR_RESPONSE; response->error_string = strdup( verror_get_string() ); @@ -779,13 +779,11 @@ voms_create_AC_SEQ_X509_EXTENSION(unsigned char *acseq, int acseq_length) goto error; } - ac_DER_string->data = (unsigned char*)malloc(acseq_length); - if (ac_DER_string->data == NULL) { + if (ASN1_OCTET_STRING_set(ac_DER_string, acseq, acseq_length) == 0) { verror_put_string("Couldn't allocate ASN1_OCTET"); goto error; } - memcpy(ac_DER_string->data, acseq, acseq_length); - ac_DER_string->length = acseq_length; + ext = X509_EXTENSION_create_by_NID(NULL, OBJ_txt2nid("acseq"), 0, ac_DER_string); if (ext == NULL) { @@ -803,11 +801,11 @@ voms_create_AC_SEQ_X509_EXTENSION(unsigned char *acseq, int acseq_length) static int voms_contact_ext(const char *source_credentials, const int lifetime, - char *passphrase, + char *passphrase, char *voname, char *vomses, char *voms_userconf) -{ +{ int result = 1; - SSL_CREDENTIALS *creds = NULL; + SSL_CREDENTIALS *creds = NULL; unsigned char *acseq= NULL; int acseq_length = 0; X509_EXTENSION *ext = NULL; @@ -817,7 +815,7 @@ voms_contact_ext(const char *source_credentials, const int lifetime, if (creds == NULL) { goto done; } - if (ssl_proxy_load_from_file(creds, source_credentials, + if (ssl_proxy_load_from_file(creds, source_credentials, passphrase) == SSL_ERROR) { goto done; } @@ -862,7 +860,7 @@ voms_init_delegation(myproxy_socket_attrs_t *attrs, const char *delegfile, const int lifetime, char *passphrase, - char *voname, char *vomses, + char *voname, char *vomses, char *voms_userconf) { @@ -874,7 +872,7 @@ voms_init_delegation(myproxy_socket_attrs_t *attrs, return -1; - if (voms_contact_ext(delegfile, lifetime, passphrase, + if (voms_contact_ext(delegfile, lifetime, passphrase, voname, vomses, voms_userconf)) { verror_put_string("Couldn't get VOMS User Information."); diff --git a/packaging/debian/globus-callout/debian/changelog.in b/packaging/debian/globus-callout/debian/changelog.in index de9d07310b..3bf9d4cacb 100644 --- a/packaging/debian/globus-callout/debian/changelog.in +++ b/packaging/debian/globus-callout/debian/changelog.in @@ -1,3 +1,9 @@ +globus-callout (4.4-1+gct.@distro@) @distro@; urgency=medium + + * Fix compiler warnings + + -- Mattias Ellert Tue, 19 May 2026 13:45:16 +0200 + globus-callout (4.3-1+gct.@distro@) @distro@; urgency=medium * Make makefiles exit sooner on errors diff --git a/packaging/debian/globus-common/debian/changelog.in b/packaging/debian/globus-common/debian/changelog.in index 8bdb6e17e9..01acb16277 100644 --- a/packaging/debian/globus-common/debian/changelog.in +++ b/packaging/debian/globus-common/debian/changelog.in @@ -1,3 +1,9 @@ +globus-common (18.16-1+gct.@distro@) @distro@; urgency=medium + + * Fix compiler and doxygen warnings + + -- Mattias Ellert Tue, 19 May 2026 11:07:18 +0200 + globus-common (18.15-1+gct.@distro@) @distro@; urgency=medium * Compatibility with autoconf 2.72 diff --git a/packaging/debian/globus-ftp-client/debian/changelog.in b/packaging/debian/globus-ftp-client/debian/changelog.in index f9bd3a1f70..7a89bc2759 100644 --- a/packaging/debian/globus-ftp-client/debian/changelog.in +++ b/packaging/debian/globus-ftp-client/debian/changelog.in @@ -1,3 +1,9 @@ +globus-ftp-client (9.10-1+gct.@distro@) @distro@; urgency=medium + + * Fix compiler and doxygen warnings + + -- Mattias Ellert Tue, 19 May 2026 17:56:39 +0200 + globus-ftp-client (9.9-1+gct.@distro@) @distro@; urgency=medium * Fix format warnings on 32 bit systems diff --git a/packaging/debian/globus-ftp-control/debian/changelog.in b/packaging/debian/globus-ftp-control/debian/changelog.in index 4376646d5c..57f5478302 100644 --- a/packaging/debian/globus-ftp-control/debian/changelog.in +++ b/packaging/debian/globus-ftp-control/debian/changelog.in @@ -1,3 +1,9 @@ +globus-ftp-control (9.11-1+gct.@distro@) @distro@; urgency=medium + + * Fix compiler warnings + + -- Mattias Ellert Tue, 19 May 2026 16:52:14 +0200 + globus-ftp-control (9.10-1+gct.@distro@) @distro@; urgency=medium * Fix cut-and-paste error in Makefile diff --git a/packaging/debian/globus-gass-cache/debian/changelog.in b/packaging/debian/globus-gass-cache/debian/changelog.in index f5b1578cbb..a0bd12c320 100644 --- a/packaging/debian/globus-gass-cache/debian/changelog.in +++ b/packaging/debian/globus-gass-cache/debian/changelog.in @@ -1,3 +1,9 @@ +globus-gass-cache (10.4-1+gct.@distro@) @distro@; urgency=medium + + * Fix compiler warnings + + -- Mattias Ellert Tue, 19 May 2026 18:57:52 +0200 + globus-gass-cache (10.3-1+gct.@distro@) @distro@; urgency=medium * Typo fixes diff --git a/packaging/debian/globus-gass-copy/debian/changelog.in b/packaging/debian/globus-gass-copy/debian/changelog.in index 490c5c8ba2..23a465d6bd 100644 --- a/packaging/debian/globus-gass-copy/debian/changelog.in +++ b/packaging/debian/globus-gass-copy/debian/changelog.in @@ -1,3 +1,10 @@ +globus-gass-copy (10.14-1+gct.@distro@) @distro@; urgency=medium + + * Compile with OpenSSL 4 + * Fix compiler and doxygen warnings + + -- Mattias Ellert Tue, 19 May 2026 18:03:13 +0200 + globus-gass-copy (10.13-1+gct.@distro@) @distro@; urgency=medium * Detect checksum calculation errors due to file read errors diff --git a/packaging/debian/globus-gass-transfer/debian/changelog.in b/packaging/debian/globus-gass-transfer/debian/changelog.in index d12fad55c8..b989d8d92f 100644 --- a/packaging/debian/globus-gass-transfer/debian/changelog.in +++ b/packaging/debian/globus-gass-transfer/debian/changelog.in @@ -1,3 +1,9 @@ +globus-gass-transfer (9.6-1+gct.@distro@) @distro@; urgency=medium + + * Fix compiler and doxygen warnings + + -- Mattias Ellert Tue, 19 May 2026 16:56:46 +0200 + globus-gass-transfer (9.5-1+gct.@distro@) @distro@; urgency=medium * Fix format warnings on 32 bit systems diff --git a/packaging/debian/globus-gatekeeper/debian/changelog.in b/packaging/debian/globus-gatekeeper/debian/changelog.in index 2995f87794..1d13ad2679 100644 --- a/packaging/debian/globus-gatekeeper/debian/changelog.in +++ b/packaging/debian/globus-gatekeeper/debian/changelog.in @@ -1,3 +1,9 @@ +globus-gatekeeper (11.5-1+gct.@distro@) @distro@; urgency=medium + + * Fix compiler warnings + + -- Mattias Ellert Tue, 19 May 2026 19:04:14 +0200 + globus-gatekeeper (11.4-1+gct.@distro@) @distro@; urgency=medium * Fix some compiler warnings diff --git a/packaging/debian/globus-gfork/debian/changelog.in b/packaging/debian/globus-gfork/debian/changelog.in index 825ec23658..1e76cff522 100644 --- a/packaging/debian/globus-gfork/debian/changelog.in +++ b/packaging/debian/globus-gfork/debian/changelog.in @@ -1,3 +1,9 @@ +globus-gfork (5.1-1+gct.@distro@) @distro@; urgency=medium + + * Fix compiler warnings + + -- Mattias Ellert Tue, 19 May 2026 17:04:21 +0200 + globus-gfork (5.0-1+gct.@distro@) @distro@; urgency=medium * First Grid Community Toolkit release diff --git a/packaging/debian/globus-gram-client/debian/changelog.in b/packaging/debian/globus-gram-client/debian/changelog.in index fd3967330c..353d147519 100644 --- a/packaging/debian/globus-gram-client/debian/changelog.in +++ b/packaging/debian/globus-gram-client/debian/changelog.in @@ -1,3 +1,9 @@ +globus-gram-client (14.8-1+gct.@distro@) @distro@; urgency=medium + + * Fix compiler warnings + + -- Mattias Ellert Tue, 19 May 2026 18:49:48 +0200 + globus-gram-client (14.7-1+gct.@distro@) @distro@; urgency=medium * Correct spelling error found by lintian diff --git a/packaging/debian/globus-gram-job-manager-lsf/debian/changelog.in b/packaging/debian/globus-gram-job-manager-lsf/debian/changelog.in index 7c2af416dd..1f5479ed90 100644 --- a/packaging/debian/globus-gram-job-manager-lsf/debian/changelog.in +++ b/packaging/debian/globus-gram-job-manager-lsf/debian/changelog.in @@ -1,3 +1,9 @@ +globus-gram-job-manager-lsf (3.2-1+gct.@distro@) @distro@; urgency=medium + + * Fix compiler warnings + + -- Mattias Ellert Tue, 19 May 2026 19:13:43 +0200 + globus-gram-job-manager-lsf (3.1-1+gct.@distro@) @distro@; urgency=medium * Handle 64 bit time_t on 32 bit systems diff --git a/packaging/debian/globus-gram-job-manager-sge/debian/changelog.in b/packaging/debian/globus-gram-job-manager-sge/debian/changelog.in index fe37fa22b2..b1fa41a4b7 100644 --- a/packaging/debian/globus-gram-job-manager-sge/debian/changelog.in +++ b/packaging/debian/globus-gram-job-manager-sge/debian/changelog.in @@ -1,3 +1,9 @@ +globus-gram-job-manager-sge (3.4-1+gct.@distro@) @distro@; urgency=medium + + * Fix compiler warnings + + -- Mattias Ellert Tue, 19 May 2026 19:12:15 +0200 + globus-gram-job-manager-sge (3.3-1+gct.@distro@) @distro@; urgency=medium * Fix some compiler warnings diff --git a/packaging/debian/globus-gram-job-manager/debian/changelog.in b/packaging/debian/globus-gram-job-manager/debian/changelog.in index 2e6a855307..d96634eb2c 100644 --- a/packaging/debian/globus-gram-job-manager/debian/changelog.in +++ b/packaging/debian/globus-gram-job-manager/debian/changelog.in @@ -1,3 +1,9 @@ +globus-gram-job-manager (15.11-1+gct.@distro@) @distro@; urgency=medium + + * Fix compiler warnings + + -- Mattias Ellert Tue, 19 May 2026 19:08:49 +0200 + globus-gram-job-manager (15.10-1+gct.@distro@) @distro@; urgency=medium * Only check write permission for stdout/stderr if path is absolute diff --git a/packaging/debian/globus-gram-protocol/debian/changelog.in b/packaging/debian/globus-gram-protocol/debian/changelog.in index 1b135d4aff..72bffcb6b4 100644 --- a/packaging/debian/globus-gram-protocol/debian/changelog.in +++ b/packaging/debian/globus-gram-protocol/debian/changelog.in @@ -1,3 +1,9 @@ +globus-gram-protocol (13.7-1+gct.@distro@) @distro@; urgency=medium + + * Fix compiler and doxygen warnings + + -- Mattias Ellert Tue, 19 May 2026 18:22:13 +0200 + globus-gram-protocol (13.6-1+gct.@distro@) @distro@; urgency=medium * Use sha256 hash when generating test certificates diff --git a/packaging/debian/globus-gridftp-server-control/debian/changelog.in b/packaging/debian/globus-gridftp-server-control/debian/changelog.in index a1bdfea3e9..5100f7faab 100644 --- a/packaging/debian/globus-gridftp-server-control/debian/changelog.in +++ b/packaging/debian/globus-gridftp-server-control/debian/changelog.in @@ -1,3 +1,9 @@ +globus-gridftp-server-control (9.6-1+gct.@distro@) @distro@; urgency=medium + + * Fix compiler warnings + + -- Mattias Ellert Tue, 19 May 2026 17:07:47 +0200 + globus-gridftp-server-control (9.5-1+gct.@distro@) @distro@; urgency=medium * Passing argument from incompatible pointer type diff --git a/packaging/debian/globus-gridftp-server/debian/changelog.in b/packaging/debian/globus-gridftp-server/debian/changelog.in index 0da5221d43..a0e4098d7b 100644 --- a/packaging/debian/globus-gridftp-server/debian/changelog.in +++ b/packaging/debian/globus-gridftp-server/debian/changelog.in @@ -1,3 +1,9 @@ +globus-gridftp-server (13.29-1+gct.@distro@) @distro@; urgency=medium + + * Fix compiler warnings + + -- Mattias Ellert Tue, 19 May 2026 17:18:24 +0200 + globus-gridftp-server (13.28-1+gct.@distro@) @distro@; urgency=medium * Fix incompatible pointer errors (gcc 15) diff --git a/packaging/debian/globus-gridmap-eppn-callout/debian/changelog.in b/packaging/debian/globus-gridmap-eppn-callout/debian/changelog.in index d932234013..f7ee3dcf05 100644 --- a/packaging/debian/globus-gridmap-eppn-callout/debian/changelog.in +++ b/packaging/debian/globus-gridmap-eppn-callout/debian/changelog.in @@ -1,3 +1,9 @@ +globus-gridmap-eppn-callout (2.3-1+gct.@distro@) @distro@; urgency=medium + + * Compile with OpenSSL 4 + + -- Mattias Ellert Tue, 19 May 2026 19:23:57 +0200 + globus-gridmap-eppn-callout (2.2-1+gct.@distro@) @distro@; urgency=medium * Add environment variable GLOBUS_EPPN_FORCE_GRIDMAP to return mapped diff --git a/packaging/debian/globus-gsi-callback/debian/changelog.in b/packaging/debian/globus-gsi-callback/debian/changelog.in index bcd7d5c9db..fbfab0c6bd 100644 --- a/packaging/debian/globus-gsi-callback/debian/changelog.in +++ b/packaging/debian/globus-gsi-callback/debian/changelog.in @@ -1,3 +1,10 @@ +globus-gsi-callback (6.3-1+gct.@distro@) @distro@; urgency=medium + + * Compile with OpenSSL 4 + * Fix compiler warnings + + -- Mattias Ellert Tue, 19 May 2026 13:14:31 +0200 + globus-gsi-callback (6.2-1+gct.@distro@) @distro@; urgency=medium * Make makefiles exit sooner on errors diff --git a/packaging/debian/globus-gsi-cert-utils/debian/changelog.in b/packaging/debian/globus-gsi-cert-utils/debian/changelog.in index ed14cdf2ad..c42a160047 100644 --- a/packaging/debian/globus-gsi-cert-utils/debian/changelog.in +++ b/packaging/debian/globus-gsi-cert-utils/debian/changelog.in @@ -1,3 +1,9 @@ +globus-gsi-cert-utils (10.12-1+gct.@distro@) @distro@; urgency=medium + + * Compile with OpenSSL 4 + + -- Mattias Ellert Tue, 19 May 2026 11:41:35 +0200 + globus-gsi-cert-utils (10.11-1+gct.@distro@) @distro@; urgency=medium * Fix parsing of ASN1 timestamps diff --git a/packaging/debian/globus-gsi-credential/debian/changelog.in b/packaging/debian/globus-gsi-credential/debian/changelog.in index ab7d5c13c4..8f20d25b5b 100644 --- a/packaging/debian/globus-gsi-credential/debian/changelog.in +++ b/packaging/debian/globus-gsi-credential/debian/changelog.in @@ -1,3 +1,9 @@ +globus-gsi-credential (8.6-1+gct.@distro@) @distro@; urgency=medium + + * Compile with OpenSSL 4 + + -- Mattias Ellert Tue, 19 May 2026 13:24:49 +0200 + globus-gsi-credential (8.5-1+gct.@distro@) @distro@; urgency=medium * Fix incompatible pointer errors (gcc 15) diff --git a/packaging/debian/globus-gsi-proxy-core/debian/changelog.in b/packaging/debian/globus-gsi-proxy-core/debian/changelog.in index 01f88c2a08..826468c881 100644 --- a/packaging/debian/globus-gsi-proxy-core/debian/changelog.in +++ b/packaging/debian/globus-gsi-proxy-core/debian/changelog.in @@ -1,3 +1,9 @@ +globus-gsi-proxy-core (9.10-1+gct.@distro@) @distro@; urgency=medium + + * Compile with OpenSSL 4 + + -- Mattias Ellert Tue, 19 May 2026 13:35:03 +0200 + globus-gsi-proxy-core (9.9-1+gct.@distro@) @distro@; urgency=medium * Fix linking error with gcc 16 diff --git a/packaging/debian/globus-gsi-proxy-ssl/debian/changelog.in b/packaging/debian/globus-gsi-proxy-ssl/debian/changelog.in index a1639d858d..1cea4764cf 100644 --- a/packaging/debian/globus-gsi-proxy-ssl/debian/changelog.in +++ b/packaging/debian/globus-gsi-proxy-ssl/debian/changelog.in @@ -1,3 +1,9 @@ +globus-gsi-proxy-ssl (6.7-1+gct.@distro@) @distro@; urgency=medium + + * Compile with OpenSSL 4 + + -- Mattias Ellert Tue, 19 May 2026 11:17:38 +0200 + globus-gsi-proxy-ssl (6.6-1+gct.@distro@) @distro@; urgency=medium * Fix incompatible pointer errors (gcc 15) diff --git a/packaging/debian/globus-gsi-sysconfig/debian/changelog.in b/packaging/debian/globus-gsi-sysconfig/debian/changelog.in index a9b7a03566..fe8b0b9c1a 100644 --- a/packaging/debian/globus-gsi-sysconfig/debian/changelog.in +++ b/packaging/debian/globus-gsi-sysconfig/debian/changelog.in @@ -1,3 +1,9 @@ +globus-gsi-sysconfig (9.7-1+gct.@distro@) @distro@; urgency=medium + + * Compile with OpenSSL 4 + + -- Mattias Ellert Tue, 19 May 2026 11:47:45 +0200 + globus-gsi-sysconfig (9.6-1+gct.@distro@) @distro@; urgency=medium * Remove extra comma diff --git a/packaging/debian/globus-gss-assist/debian/changelog.in b/packaging/debian/globus-gss-assist/debian/changelog.in index fabfcc8dac..cd49a16cee 100644 --- a/packaging/debian/globus-gss-assist/debian/changelog.in +++ b/packaging/debian/globus-gss-assist/debian/changelog.in @@ -1,3 +1,9 @@ +globus-gss-assist (12.8-1+gct.@distro@) @distro@; urgency=medium + + * Fix compiler and doxygen warnings + + -- Mattias Ellert Tue, 19 May 2026 16:04:59 +0200 + globus-gss-assist (12.7-1+gct.@distro@) @distro@; urgency=medium * Use sha256 hash when generating test certificates diff --git a/packaging/debian/globus-gssapi-gsi/debian/changelog.in b/packaging/debian/globus-gssapi-gsi/debian/changelog.in index 105522a25e..c25fa4609e 100644 --- a/packaging/debian/globus-gssapi-gsi/debian/changelog.in +++ b/packaging/debian/globus-gssapi-gsi/debian/changelog.in @@ -1,3 +1,10 @@ +globus-gssapi-gsi (14.21-1+gct.@distro@) @distro@; urgency=medium + + * Compile with OpenSSL 4 + * Fix compiler warnings + + -- Mattias Ellert Tue, 19 May 2026 15:59:55 +0200 + globus-gssapi-gsi (14.20-1+gct.@distro@) @distro@; urgency=medium * Disable sending session tickets after the TLS 1.3 handshake diff --git a/packaging/debian/globus-io/debian/changelog.in b/packaging/debian/globus-io/debian/changelog.in index 4f7b187c42..476ed92ba0 100644 --- a/packaging/debian/globus-io/debian/changelog.in +++ b/packaging/debian/globus-io/debian/changelog.in @@ -1,3 +1,9 @@ +globus-io (12.5-1+gct.@distro@) @distro@; urgency=medium + + * Fix compiler warnings + + -- Mattias Ellert Tue, 19 May 2026 16:48:24 +0200 + globus-io (12.4-1+gct.@distro@) @distro@; urgency=medium * Use sha256 hash when generating test certificates diff --git a/packaging/debian/globus-openssl-module/debian/changelog.in b/packaging/debian/globus-openssl-module/debian/changelog.in index db6e8512b4..98c9cb80e9 100644 --- a/packaging/debian/globus-openssl-module/debian/changelog.in +++ b/packaging/debian/globus-openssl-module/debian/changelog.in @@ -1,3 +1,9 @@ +globus-openssl-module (5.3-1+gct.@distro@) @distro@; urgency=medium + + * Fix compiler warnings + + -- Mattias Ellert Tue, 19 May 2026 11:31:43 +0200 + globus-openssl-module (5.2-1+gct.@distro@) @distro@; urgency=medium * Make makefiles exit sooner on errors diff --git a/packaging/debian/globus-proxy-utils/debian/changelog.in b/packaging/debian/globus-proxy-utils/debian/changelog.in index bf643c2541..13b8973649 100644 --- a/packaging/debian/globus-proxy-utils/debian/changelog.in +++ b/packaging/debian/globus-proxy-utils/debian/changelog.in @@ -1,3 +1,10 @@ +globus-proxy-utils (7.5-1+gct.@distro@) @distro@; urgency=medium + + * Compile with OpenSSL 4 + * Fix compiler warnings + + -- Mattias Ellert Tue, 19 May 2026 16:10:19 +0200 + globus-proxy-utils (7.4-1+gct.@distro@) @distro@; urgency=medium * Fix incompatible pointer errors (gcc 15) diff --git a/packaging/debian/globus-rsl/debian/changelog.in b/packaging/debian/globus-rsl/debian/changelog.in index 7d5e53b60f..bf73074f03 100644 --- a/packaging/debian/globus-rsl/debian/changelog.in +++ b/packaging/debian/globus-rsl/debian/changelog.in @@ -1,3 +1,9 @@ +globus-rsl (11.5-1+gct.@distro@) @distro@; urgency=medium + + * Fix doxygen warnings + + -- Mattias Ellert Tue, 19 May 2026 18:17:40 +0200 + globus-rsl (11.4-1+gct.@distro@) @distro@; urgency=medium * Make library linking survive -Wl,--as-needed diff --git a/packaging/debian/globus-scheduler-event-generator/debian/changelog.in b/packaging/debian/globus-scheduler-event-generator/debian/changelog.in index 1dc15e9c68..f7535c7ebf 100644 --- a/packaging/debian/globus-scheduler-event-generator/debian/changelog.in +++ b/packaging/debian/globus-scheduler-event-generator/debian/changelog.in @@ -1,3 +1,9 @@ +globus-scheduler-event-generator (6.7-1+gct.@distro@) @distro@; urgency=medium + + * Fix doxygen warnings + + -- Mattias Ellert Tue, 19 May 2026 19:01:42 +0200 + globus-scheduler-event-generator (6.6-1+gct.@distro@) @distro@; urgency=medium * Handle 64 bit time_t on 32 bit systems diff --git a/packaging/debian/globus-xio-gridftp-driver/debian/changelog.in b/packaging/debian/globus-xio-gridftp-driver/debian/changelog.in index 76b83f06d7..58d8d2839a 100644 --- a/packaging/debian/globus-xio-gridftp-driver/debian/changelog.in +++ b/packaging/debian/globus-xio-gridftp-driver/debian/changelog.in @@ -1,3 +1,9 @@ +globus-xio-gridftp-driver (3.7-1+gct.@distro@) @distro@; urgency=medium + + * Fix compiler and doxygen warnings + + -- Mattias Ellert Tue, 19 May 2026 19:19:49 +0200 + globus-xio-gridftp-driver (3.6-1+gct.@distro@) @distro@; urgency=medium * Fix some compiler warnings diff --git a/packaging/debian/globus-xio-gridftp-multicast/debian/changelog.in b/packaging/debian/globus-xio-gridftp-multicast/debian/changelog.in index 5f450b768e..0f8c4faa77 100644 --- a/packaging/debian/globus-xio-gridftp-multicast/debian/changelog.in +++ b/packaging/debian/globus-xio-gridftp-multicast/debian/changelog.in @@ -1,3 +1,9 @@ +globus-xio-gridftp-multicast (2.3-1+gct.@distro@) @distro@; urgency=medium + + * Fix compiler warnings + + -- Mattias Ellert Tue, 19 May 2026 19:27:07 +0200 + globus-xio-gridftp-multicast (2.2-1+gct.@distro@) @distro@; urgency=medium * Fix some compiler warnings diff --git a/packaging/debian/globus-xio-pipe-driver/debian/changelog.in b/packaging/debian/globus-xio-pipe-driver/debian/changelog.in index ecad8a4458..3b1d279e6c 100644 --- a/packaging/debian/globus-xio-pipe-driver/debian/changelog.in +++ b/packaging/debian/globus-xio-pipe-driver/debian/changelog.in @@ -1,3 +1,9 @@ +globus-xio-pipe-driver (4.2-1+gct.@distro@) @distro@; urgency=medium + + * Fix compiler warnings + + -- Mattias Ellert Tue, 19 May 2026 16:35:06 +0200 + globus-xio-pipe-driver (4.1-1+gct.@distro@) @distro@; urgency=medium * Add AC_CONFIG_MACRO_DIR and ACLOCAL_AMFLAGS diff --git a/packaging/debian/globus-xio/debian/changelog.in b/packaging/debian/globus-xio/debian/changelog.in index beaaa707f7..fc2da68173 100644 --- a/packaging/debian/globus-xio/debian/changelog.in +++ b/packaging/debian/globus-xio/debian/changelog.in @@ -1,3 +1,9 @@ +globus-xio (6.7-1+gct.@distro@) @distro@; urgency=medium + + * Fix compiler and doxygen warnings + + -- Mattias Ellert Tue, 19 May 2026 16:19:26 +0200 + globus-xio (6.6-1+gct.@distro@) @distro@; urgency=medium * Fix some compiler and doxygen warnings diff --git a/packaging/debian/globus-xioperf/debian/changelog.in b/packaging/debian/globus-xioperf/debian/changelog.in index 14ade1c37a..fd04011353 100644 --- a/packaging/debian/globus-xioperf/debian/changelog.in +++ b/packaging/debian/globus-xioperf/debian/changelog.in @@ -1,3 +1,9 @@ +globus-xioperf (5.2-1+gct.@distro@) @distro@; urgency=medium + + * Fix compiler warnings + + -- Mattias Ellert Tue, 19 May 2026 23:22:44 +0200 + globus-xioperf (5.1-1+gct.@distro@) @distro@; urgency=medium * Add AC_CONFIG_MACRO_DIR and ACLOCAL_AMFLAGS diff --git a/packaging/debian/myproxy/debian/changelog.in b/packaging/debian/myproxy/debian/changelog.in index 72eb7277d0..f8687345c5 100644 --- a/packaging/debian/myproxy/debian/changelog.in +++ b/packaging/debian/myproxy/debian/changelog.in @@ -1,3 +1,10 @@ +myproxy (6.2.21-1+gct.@distro@) @distro@; urgency=medium + + * Compile with OpenSSL 4 + * Fix compiler warnings + + -- Mattias Ellert Tue, 19 May 2026 19:33:03 +0200 + myproxy (6.2.20-1+gct.@distro@) @distro@; urgency=medium * Fix incompatible pointer errors (gcc 15) diff --git a/packaging/fedora/globus-callout.spec b/packaging/fedora/globus-callout.spec index 11b0903f29..82ef6694fe 100644 --- a/packaging/fedora/globus-callout.spec +++ b/packaging/fedora/globus-callout.spec @@ -3,7 +3,7 @@ Name: globus-callout %global soname 0 %global _name %(echo %{name} | tr - _) -Version: 4.3 +Version: 4.4 Release: 1%{?dist} Summary: Grid Community Toolkit - Globus Callout Library @@ -137,6 +137,9 @@ make %{?_smp_mflags} check VERBOSE=1 %doc %{_pkgdocdir}/GLOBUS_LICENSE %changelog +* Tue May 19 2026 Mattias Ellert - 4.4-1 +- Fix compiler warnings + * Tue Mar 10 2020 Mattias Ellert - 4.3-1 - Make makefiles exit sooner on errors diff --git a/packaging/fedora/globus-common.spec b/packaging/fedora/globus-common.spec index 516704e8e6..d6267aa075 100644 --- a/packaging/fedora/globus-common.spec +++ b/packaging/fedora/globus-common.spec @@ -3,7 +3,7 @@ Name: globus-common %global soname 0 %global _name %(echo %{name} | tr - _) -Version: 18.15 +Version: 18.16 Release: 1%{?dist} Summary: Grid Community Toolkit - Common Library @@ -239,6 +239,9 @@ make %{?_smp_mflags} check VERBOSE=1 NO_EXTERNAL_NET=1 %doc %{_pkgdocdir}/GLOBUS_LICENSE %changelog +* Tue May 19 2026 Mattias Ellert - 18.16-1 +- Fix compiler and doxygen warnings + * Wed Oct 30 2024 Mattias Ellert - 18.15-1 - Compatibility with autoconf 2.72 diff --git a/packaging/fedora/globus-ftp-client.spec b/packaging/fedora/globus-ftp-client.spec index b56a93c6dc..ed303c46d8 100644 --- a/packaging/fedora/globus-ftp-client.spec +++ b/packaging/fedora/globus-ftp-client.spec @@ -3,7 +3,7 @@ Name: globus-ftp-client %global soname 2 %global _name %(echo %{name} | tr - _) -Version: 9.9 +Version: 9.10 Release: 1%{?dist} Summary: Grid Community Toolkit - GridFTP Client Library @@ -169,6 +169,9 @@ GLOBUS_HOSTNAME=localhost make %{?_smp_mflags} check VERBOSE=1 %doc %{_pkgdocdir}/GLOBUS_LICENSE %changelog +* Tue May 19 2026 Mattias Ellert - 9.10-1 +- Fix compiler and doxygen warnings + * Fri Mar 01 2024 Mattias Ellert - 9.9-1 - Fix format warnings on 32 bit systems - Handle 64 bit time_t on 32 bit systems diff --git a/packaging/fedora/globus-ftp-control.spec b/packaging/fedora/globus-ftp-control.spec index c9051c012d..0bce52ab3d 100644 --- a/packaging/fedora/globus-ftp-control.spec +++ b/packaging/fedora/globus-ftp-control.spec @@ -3,7 +3,7 @@ Name: globus-ftp-control %global soname 1 %global _name %(echo %{name} | tr - _) -Version: 9.10 +Version: 9.11 Release: 1%{?dist} Summary: Grid Community Toolkit - GridFTP Control Library @@ -144,6 +144,9 @@ GLOBUS_HOSTNAME=localhost make %{?_smp_mflags} check VERBOSE=1 %doc %{_pkgdocdir}/GLOBUS_LICENSE %changelog +* Tue May 19 2026 Mattias Ellert - 9.11-1 +- Fix compiler warnings + * Thu Apr 21 2022 Mattias Ellert - 9.10-1 - Fix cut-and-paste error in Makefile diff --git a/packaging/fedora/globus-gass-cache.spec b/packaging/fedora/globus-gass-cache.spec index 6f27a1da7e..11acc4d2e3 100644 --- a/packaging/fedora/globus-gass-cache.spec +++ b/packaging/fedora/globus-gass-cache.spec @@ -3,7 +3,7 @@ Name: globus-gass-cache %global soname 5 %global _name %(echo %{name} | tr - _) -Version: 10.3 +Version: 10.4 Release: 1%{?dist} Summary: Grid Community Toolkit - Globus Gass Cache @@ -133,6 +133,9 @@ rm $RPM_BUILD_ROOT%{_libdir}/*.la %doc %{_pkgdocdir}/GLOBUS_LICENSE %changelog +* Tue May 19 2026 Mattias Ellert - 10.4-1 +- Fix compiler warnings + * Fri Aug 20 2021 Mattias Ellert - 10.3-1 - Typo fixes diff --git a/packaging/fedora/globus-gass-copy.spec b/packaging/fedora/globus-gass-copy.spec index f4129b44c5..de469fa2e9 100644 --- a/packaging/fedora/globus-gass-copy.spec +++ b/packaging/fedora/globus-gass-copy.spec @@ -3,7 +3,7 @@ Name: globus-gass-copy %global soname 2 %global _name %(echo %{name} | tr - _) -Version: 10.13 +Version: 10.14 Release: 1%{?dist} Summary: Grid Community Toolkit - Globus Gass Copy @@ -183,6 +183,10 @@ GLOBUS_HOSTNAME=localhost make %{?_smp_mflags} check VERBOSE=1 %doc %{_pkgdocdir}/GLOBUS_LICENSE %changelog +* Tue May 19 2026 Mattias Ellert - 10.14-1 +- Compile with OpenSSL 4 +- Fix compiler and doxygen warnings + * Thu Oct 26 2023 Mattias Ellert - 10.13-1 - Detect checksum calculation errors due to file read errors diff --git a/packaging/fedora/globus-gass-transfer.spec b/packaging/fedora/globus-gass-transfer.spec index 054c69b3c8..2f6c221a0f 100644 --- a/packaging/fedora/globus-gass-transfer.spec +++ b/packaging/fedora/globus-gass-transfer.spec @@ -3,7 +3,7 @@ Name: globus-gass-transfer %global soname 2 %global _name %(echo %{name} | tr - _) -Version: 9.5 +Version: 9.6 Release: 1%{?dist} Summary: Grid Community Toolkit - Globus Gass Transfer @@ -131,6 +131,9 @@ rm $RPM_BUILD_ROOT%{_libdir}/*.la %doc %{_pkgdocdir}/GLOBUS_LICENSE %changelog +* Tue May 19 2026 Mattias Ellert - 9.6-1 +- Fix compiler and doxygen warnings + * Fri Mar 01 2024 Mattias Ellert - 9.5-1 - Fix format warnings on 32 bit systems diff --git a/packaging/fedora/globus-gatekeeper.spec b/packaging/fedora/globus-gatekeeper.spec index e2613a8046..288f90ba0a 100644 --- a/packaging/fedora/globus-gatekeeper.spec +++ b/packaging/fedora/globus-gatekeeper.spec @@ -2,7 +2,7 @@ Name: globus-gatekeeper %global _name %(echo %{name} | tr - _) -Version: 11.4 +Version: 11.5 Release: 1%{?dist} Summary: Grid Community Toolkit - Globus Gatekeeper @@ -129,6 +129,9 @@ fi %doc %{_pkgdocdir}/GLOBUS_LICENSE %changelog +* Tue May 19 2026 Mattias Ellert - 11.5-1 +- Fix compiler warnings + * Thu Mar 10 2022 Mattias Ellert - 11.4-1 - Fix some compiler warnings diff --git a/packaging/fedora/globus-gfork.spec b/packaging/fedora/globus-gfork.spec index 7540e08214..169c2f3fe1 100644 --- a/packaging/fedora/globus-gfork.spec +++ b/packaging/fedora/globus-gfork.spec @@ -3,7 +3,7 @@ Name: globus-gfork %global soname 0 %global _name %(echo %{name} | tr - _) -Version: 5.0 +Version: 5.1 Release: 1%{?dist} Summary: Grid Community Toolkit - GFork @@ -132,6 +132,9 @@ echo "# This is the default gfork configuration file" > \ %{_libdir}/pkgconfig/%{name}.pc %changelog +* Tue May 19 2026 Mattias Ellert - 5.1-1 +- Fix compiler warnings + * Sat Mar 31 2018 Mattias Ellert - 5.0-1 - First Grid Community Toolkit release diff --git a/packaging/fedora/globus-gram-client.spec b/packaging/fedora/globus-gram-client.spec index 56764f6f76..801227dba1 100644 --- a/packaging/fedora/globus-gram-client.spec +++ b/packaging/fedora/globus-gram-client.spec @@ -3,7 +3,7 @@ Name: globus-gram-client %global soname 3 %global _name %(echo %{name} | tr - _) -Version: 14.7 +Version: 14.8 Release: 1%{?dist} Summary: Grid Community Toolkit - GRAM Client Library @@ -137,6 +137,9 @@ GLOBUS_HOSTNAME=localhost make %{?_smp_mflags} check VERBOSE=1 %doc %{_pkgdocdir}/GLOBUS_LICENSE %changelog +* Tue May 19 2026 Mattias Ellert - 14.8-1 +- Fix compiler warnings + * Fri Mar 08 2024 Mattias Ellert - 14.7-1 - Correct spelling error found by lintian diff --git a/packaging/fedora/globus-gram-job-manager-lsf.spec b/packaging/fedora/globus-gram-job-manager-lsf.spec index d60a6ec2c3..60abc0a81a 100644 --- a/packaging/fedora/globus-gram-job-manager-lsf.spec +++ b/packaging/fedora/globus-gram-job-manager-lsf.spec @@ -2,7 +2,7 @@ Name: globus-gram-job-manager-lsf %global _name %(echo %{name} | tr - _) -Version: 3.1 +Version: 3.2 Release: 1%{?dist} Summary: Grid Community Toolkit - LSF Job Manager Support @@ -170,6 +170,9 @@ fi %config(noreplace) %{_sysconfdir}/globus/scheduler-event-generator/available/lsf %changelog +* Tue May 19 2026 Mattias Ellert - 3.2-1 +- Fix compiler warnings + * Sun Mar 10 2024 Mattias Ellert - 3.1-1 - Handle 64 bit time_t on 32 bit systems diff --git a/packaging/fedora/globus-gram-job-manager-sge.spec b/packaging/fedora/globus-gram-job-manager-sge.spec index 9cc1b373ae..b4fb2ee012 100644 --- a/packaging/fedora/globus-gram-job-manager-sge.spec +++ b/packaging/fedora/globus-gram-job-manager-sge.spec @@ -2,7 +2,7 @@ Name: globus-gram-job-manager-sge %global _name %(echo %{name} | tr - _) -Version: 3.3 +Version: 3.4 Release: 1%{?dist} Summary: Grid Community Toolkit - Grid Engine Job Manager Support @@ -177,6 +177,9 @@ fi %config(noreplace) %{_sysconfdir}/globus/scheduler-event-generator/available/sge %changelog +* Tue May 19 2026 Mattias Ellert - 3.4-1 +- Fix compiler warnings + * Fri Mar 11 2022 Mattias Ellert - 3.3-1 - Fix some compiler warnings diff --git a/packaging/fedora/globus-gram-job-manager.spec b/packaging/fedora/globus-gram-job-manager.spec index 8560ab60d0..4875e6f370 100644 --- a/packaging/fedora/globus-gram-job-manager.spec +++ b/packaging/fedora/globus-gram-job-manager.spec @@ -2,7 +2,7 @@ Name: globus-gram-job-manager %global _name %(echo %{name} | tr - _) -Version: 15.10 +Version: 15.11 Release: 1%{?dist} Summary: Grid Community Toolkit - GRAM Jobmanager @@ -169,6 +169,9 @@ GLOBUS_HOSTNAME=localhost make %{?_smp_mflags} check VERBOSE=1 %{_libdir}/libglobus_seg_job_manager.so %changelog +* Tue May 19 2026 Mattias Ellert - 15.11-1 +- Fix compiler warnings + * Sat Apr 26 2025 Mattias Ellert - 15.10-1 - Only check write permission for stdout/stderr if path is absolute diff --git a/packaging/fedora/globus-gram-protocol.spec b/packaging/fedora/globus-gram-protocol.spec index 55d182e53e..f63c8b7321 100644 --- a/packaging/fedora/globus-gram-protocol.spec +++ b/packaging/fedora/globus-gram-protocol.spec @@ -3,7 +3,7 @@ Name: globus-gram-protocol %global soname 3 %global _name %(echo %{name} | tr - _) -Version: 13.6 +Version: 13.7 Release: 1%{?dist} Summary: Grid Community Toolkit - GRAM Protocol Library @@ -158,6 +158,9 @@ GLOBUS_HOSTNAME=localhost make %{?_smp_mflags} check VERBOSE=1 %doc %{_pkgdocdir}/GLOBUS_LICENSE %changelog +* Tue May 19 2026 Mattias Ellert - 13.7-1 +- Fix compiler and doxygen warnings + * Sun Mar 06 2022 Mattias Ellert - 13.6-1 - Use sha256 hash when generating test certificates diff --git a/packaging/fedora/globus-gridftp-server-control.spec b/packaging/fedora/globus-gridftp-server-control.spec index e4e732554e..46d6f880b8 100644 --- a/packaging/fedora/globus-gridftp-server-control.spec +++ b/packaging/fedora/globus-gridftp-server-control.spec @@ -3,7 +3,7 @@ Name: globus-gridftp-server-control %global soname 0 %global _name %(echo %{name} | tr - _) -Version: 9.5 +Version: 9.6 Release: 1%{?dist} Summary: Grid Community Toolkit - Globus GridFTP Server Library @@ -112,6 +112,9 @@ rm $RPM_BUILD_ROOT%{_libdir}/*.la %{_libdir}/pkgconfig/%{name}.pc %changelog +* Tue May 19 2026 Mattias Ellert - 9.6-1 +- Fix compiler warnings + * Thu Jul 11 2024 Mattias Ellert - 9.5-1 - Passing argument from incompatible pointer type diff --git a/packaging/fedora/globus-gridftp-server.spec b/packaging/fedora/globus-gridftp-server.spec index d569ad40a4..69b0dc4fba 100644 --- a/packaging/fedora/globus-gridftp-server.spec +++ b/packaging/fedora/globus-gridftp-server.spec @@ -3,7 +3,7 @@ Name: globus-gridftp-server %global soname 6 %global _name %(echo %{name} | tr - _) -Version: 13.28 +Version: 13.29 Release: 1%{?dist} Summary: Grid Community Toolkit - Globus GridFTP Server @@ -223,6 +223,9 @@ fi %{_libdir}/pkgconfig/%{name}.pc %changelog +* Tue May 19 2026 Mattias Ellert - 13.29-1 +- Fix compiler warnings + * Fri Jan 17 2025 Mattias Ellert - 13.28-1 - Fix incompatible pointer errors (gcc 15) diff --git a/packaging/fedora/globus-gridmap-eppn-callout.spec b/packaging/fedora/globus-gridmap-eppn-callout.spec index 19f685dbbb..3526d2669f 100644 --- a/packaging/fedora/globus-gridmap-eppn-callout.spec +++ b/packaging/fedora/globus-gridmap-eppn-callout.spec @@ -2,7 +2,7 @@ Name: globus-gridmap-eppn-callout %global _name %(echo %{name} | tr - _) -Version: 2.2 +Version: 2.3 Release: 1%{?dist} Summary: Grid Community Toolkit - Globus gridmap ePPN callout @@ -95,6 +95,9 @@ rm $RPM_BUILD_ROOT%{_libdir}/*.la %doc %{_pkgdocdir}/GLOBUS_LICENSE %changelog +* Tue May 19 2026 Mattias Ellert - 2.3-1 +- Compile with OpenSSL 4 + * Wed Aug 21 2019 Mattias Ellert - 2.2-1 - Add environment variable GLOBUS_EPPN_FORCE_GRIDMAP to return mapped identity from gridmap lookup based on the ePPN diff --git a/packaging/fedora/globus-gsi-callback.spec b/packaging/fedora/globus-gsi-callback.spec index 3eee496012..adb9adc3de 100644 --- a/packaging/fedora/globus-gsi-callback.spec +++ b/packaging/fedora/globus-gsi-callback.spec @@ -3,7 +3,7 @@ Name: globus-gsi-callback %global soname 0 %global _name %(echo %{name} | tr - _) -Version: 6.2 +Version: 6.3 Release: 1%{?dist} Summary: Grid Community Toolkit - Globus GSI Callback Library @@ -139,6 +139,10 @@ rm $RPM_BUILD_ROOT%{_libdir}/*.la %doc %{_pkgdocdir}/GLOBUS_LICENSE %changelog +* Tue May 19 2026 Mattias Ellert - 6.3-1 +- Compile with OpenSSL 4 +- Fix compiler warnings + * Tue Mar 10 2020 Mattias Ellert - 6.2-1 - Make makefiles exit sooner on errors diff --git a/packaging/fedora/globus-gsi-cert-utils.spec b/packaging/fedora/globus-gsi-cert-utils.spec index 8fdc573683..e6e4b6cf4d 100644 --- a/packaging/fedora/globus-gsi-cert-utils.spec +++ b/packaging/fedora/globus-gsi-cert-utils.spec @@ -3,7 +3,7 @@ Name: globus-gsi-cert-utils %global soname 0 %global _name %(echo %{name} | tr - _) -Version: 10.11 +Version: 10.12 Release: 1%{?dist} Summary: Grid Community Toolkit - Globus GSI Cert Utils Library @@ -180,6 +180,9 @@ make %{?_smp_mflags} check VERBOSE=1 %doc %{_pkgdocdir}/GLOBUS_LICENSE %changelog +* Tue May 19 2026 Mattias Ellert - 10.12-1 +- Compile with OpenSSL 4 + * Thu Jan 19 2023 Mischa Salle - 10.11-1 - Fix parsing of ASN1 timestamps diff --git a/packaging/fedora/globus-gsi-credential.spec b/packaging/fedora/globus-gsi-credential.spec index 2b9b3c9169..966c2da08a 100644 --- a/packaging/fedora/globus-gsi-credential.spec +++ b/packaging/fedora/globus-gsi-credential.spec @@ -3,7 +3,7 @@ Name: globus-gsi-credential %global soname 1 %global _name %(echo %{name} | tr - _) -Version: 8.5 +Version: 8.6 Release: 1%{?dist} Summary: Grid Community Toolkit - Globus GSI Credential Library @@ -137,6 +137,9 @@ rm $RPM_BUILD_ROOT%{_libdir}/*.la %doc %{_pkgdocdir}/GLOBUS_LICENSE %changelog +* Tue May 19 2026 Mattias Ellert - 8.6-1 +- Compile with OpenSSL 4 + * Fri Jan 17 2025 Mattias Ellert - 8.5-1 - Fix incompatible pointer errors (gcc 15) diff --git a/packaging/fedora/globus-gsi-proxy-core.spec b/packaging/fedora/globus-gsi-proxy-core.spec index d6ed217397..6a88445924 100644 --- a/packaging/fedora/globus-gsi-proxy-core.spec +++ b/packaging/fedora/globus-gsi-proxy-core.spec @@ -3,7 +3,7 @@ Name: globus-gsi-proxy-core %global soname 0 %global _name %(echo %{name} | tr - _) -Version: 9.9 +Version: 9.10 Release: 1%{?dist} Summary: Grid Community Toolkit - Globus GSI Proxy Core Library @@ -143,6 +143,9 @@ make %{?_smp_mflags} check VERBOSE=1 %doc %{_pkgdocdir}/GLOBUS_LICENSE %changelog +* Tue May 19 2026 Mattias Ellert - 9.10-1 +- Compile with OpenSSL 4 + * Thu Jan 08 2026 Mattias Ellert - 9.9-1 - Fix linking error with gcc 16 diff --git a/packaging/fedora/globus-gsi-proxy-ssl.spec b/packaging/fedora/globus-gsi-proxy-ssl.spec index 9af66e1936..4ba5f88b3d 100644 --- a/packaging/fedora/globus-gsi-proxy-ssl.spec +++ b/packaging/fedora/globus-gsi-proxy-ssl.spec @@ -3,7 +3,7 @@ Name: globus-gsi-proxy-ssl %global soname 1 %global _name %(echo %{name} | tr - _) -Version: 6.6 +Version: 6.7 Release: 1%{?dist} Summary: Grid Community Toolkit - Globus GSI Proxy SSL Library @@ -142,6 +142,9 @@ make %{?_smp_mflags} check VERBOSE=1 %doc %{_pkgdocdir}/GLOBUS_LICENSE %changelog +* Tue May 19 2026 Mattias Ellert - 6.7-1 +- Compile with OpenSSL 4 + * Fri Jan 17 2025 Mattias Ellert - 6.6-1 - Fix incompatible pointer errors (gcc 15) diff --git a/packaging/fedora/globus-gsi-sysconfig.spec b/packaging/fedora/globus-gsi-sysconfig.spec index 17fd1d7493..51a2e364f9 100644 --- a/packaging/fedora/globus-gsi-sysconfig.spec +++ b/packaging/fedora/globus-gsi-sysconfig.spec @@ -3,7 +3,7 @@ Name: globus-gsi-sysconfig %global soname 1 %global _name %(echo %{name} | tr - _) -Version: 9.6 +Version: 9.7 Release: 1%{?dist} Summary: Grid Community Toolkit - Globus GSI System Config Library @@ -150,6 +150,9 @@ make %{?_smp_mflags} check VERBOSE=1 %doc %{_pkgdocdir}/GLOBUS_LICENSE %changelog +* Tue May 19 2026 Mattias Ellert - 9.7-1 +- Compile with OpenSSL 4 + * Fri Nov 10 2023 Mattias Ellert - 9.6-1 - Remove extra comma diff --git a/packaging/fedora/globus-gss-assist.spec b/packaging/fedora/globus-gss-assist.spec index de31ec26aa..4473dd403f 100644 --- a/packaging/fedora/globus-gss-assist.spec +++ b/packaging/fedora/globus-gss-assist.spec @@ -3,7 +3,7 @@ Name: globus-gss-assist %global soname 3 %global _name %(echo %{name} | tr - _) -Version: 12.7 +Version: 12.8 Release: 1%{?dist} Summary: Grid Community Toolkit - GSSAPI Assist library @@ -185,6 +185,9 @@ make %{?_smp_mflags} check VERBOSE=1 %doc %{_pkgdocdir}/GLOBUS_LICENSE %changelog +* Tue May 19 2026 Mattias Ellert - 12.8-1 +- Fix compiler and doxygen warnings + * Sun Mar 06 2022 Mattias Ellert - 12.7-1 - Use sha256 hash when generating test certificates diff --git a/packaging/fedora/globus-gssapi-gsi.spec b/packaging/fedora/globus-gssapi-gsi.spec index a26b1e8b99..ca17c03213 100644 --- a/packaging/fedora/globus-gssapi-gsi.spec +++ b/packaging/fedora/globus-gssapi-gsi.spec @@ -3,7 +3,7 @@ Name: globus-gssapi-gsi %global soname 4 %global _name %(echo %{name} | tr - _) -Version: 14.20 +Version: 14.21 Release: 1%{?dist} Summary: Grid Community Toolkit - GSSAPI library @@ -158,6 +158,10 @@ make %{?_smp_mflags} check VERBOSE=1 %doc %{_pkgdocdir}/GLOBUS_LICENSE %changelog +* Tue May 19 2026 Mattias Ellert - 14.21-1 +- Compile with OpenSSL 4 +- Fix compiler warnings + * Fri May 20 2022 Mattias Ellert - 14.20-1 - Disable sending session tickets after the TLS 1.3 handshake diff --git a/packaging/fedora/globus-io.spec b/packaging/fedora/globus-io.spec index 7aae98d1ec..fc7ee01e89 100644 --- a/packaging/fedora/globus-io.spec +++ b/packaging/fedora/globus-io.spec @@ -3,7 +3,7 @@ Name: globus-io %global soname 3 %global _name %(echo %{name} | tr - _) -Version: 12.4 +Version: 12.5 Release: 1%{?dist} Summary: Grid Community Toolkit - uniform I/O interface @@ -121,6 +121,9 @@ GLOBUS_HOSTNAME=localhost make %{?_smp_mflags} check VERBOSE=1 %{_libdir}/pkgconfig/%{name}.pc %changelog +* Tue May 19 2026 Mattias Ellert - 12.5-1 +- Fix compiler warnings + * Sun Mar 06 2022 Mattias Ellert - 12.4-1 - Use sha256 hash when generating test certificates diff --git a/packaging/fedora/globus-openssl-module.spec b/packaging/fedora/globus-openssl-module.spec index 7b3570d56c..2d28182ad6 100644 --- a/packaging/fedora/globus-openssl-module.spec +++ b/packaging/fedora/globus-openssl-module.spec @@ -3,7 +3,7 @@ Name: globus-openssl-module %global soname 0 %global _name %(echo %{name} | tr - _) -Version: 5.2 +Version: 5.3 Release: 1%{?dist} Summary: Grid Community Toolkit - Globus OpenSSL Module Wrapper @@ -135,6 +135,9 @@ rm $RPM_BUILD_ROOT%{_libdir}/*.la %doc %{_pkgdocdir}/GLOBUS_LICENSE %changelog +* Tue May 19 2026 Mattias Ellert - 5.3-1 +- Fix compiler warnings + * Tue Mar 10 2020 Mattias Ellert - 5.2-1 - Make makefiles exit sooner on errors diff --git a/packaging/fedora/globus-proxy-utils.spec b/packaging/fedora/globus-proxy-utils.spec index 891b3fdbf3..0ce5ff2c26 100644 --- a/packaging/fedora/globus-proxy-utils.spec +++ b/packaging/fedora/globus-proxy-utils.spec @@ -2,7 +2,7 @@ Name: globus-proxy-utils %global _name %(echo %{name} | tr - _) -Version: 7.4 +Version: 7.5 Release: 1%{?dist} Summary: Grid Community Toolkit - Globus GSI Proxy Utility Programs @@ -77,6 +77,10 @@ make %{?_smp_mflags} check VERBOSE=1 %doc %{_pkgdocdir}/GLOBUS_LICENSE %changelog +* Tue May 19 2026 Mattias Ellert - 7.5-1 +- Compile with OpenSSL 4 +- Fix compiler warnings + * Fri Jan 17 2025 Mattias Ellert - 7.4-1 - Fix incompatible pointer errors (gcc 15) diff --git a/packaging/fedora/globus-rsl.spec b/packaging/fedora/globus-rsl.spec index ab7493f0ed..f9dd104de4 100644 --- a/packaging/fedora/globus-rsl.spec +++ b/packaging/fedora/globus-rsl.spec @@ -3,7 +3,7 @@ Name: globus-rsl %global soname 2 %global _name %(echo %{name} | tr - _) -Version: 11.4 +Version: 11.5 Release: 1%{?dist} Summary: Grid Community Toolkit - Resource Specification Language Library @@ -142,6 +142,9 @@ make %{?_smp_mflags} check VERBOSE=1 %doc %{_pkgdocdir}/GLOBUS_LICENSE %changelog +* Tue May 19 2026 Mattias Ellert - 11.5-1 +- Fix doxygen warnings + * Tue Aug 29 2023 Mattias Ellert - 11.4-1 - Make library linking survive -Wl,--as-needed diff --git a/packaging/fedora/globus-scheduler-event-generator.spec b/packaging/fedora/globus-scheduler-event-generator.spec index e71a331500..178ce25eda 100644 --- a/packaging/fedora/globus-scheduler-event-generator.spec +++ b/packaging/fedora/globus-scheduler-event-generator.spec @@ -3,7 +3,7 @@ Name: globus-scheduler-event-generator %global soname 0 %global _name %(echo %{name} | tr - _) -Version: 6.6 +Version: 6.7 Release: 1%{?dist} Summary: Grid Community Toolkit - Scheduler Event Generator @@ -239,6 +239,9 @@ fi %doc %{_pkgdocdir}/GLOBUS_LICENSE %changelog +* Tue May 19 2026 Mattias Ellert - 6.7-1 +- Fix doxygen warnings + * Fri Mar 01 2024 Mattias Ellert - 6.6-1 - Handle 64 bit time_t on 32 bit systems diff --git a/packaging/fedora/globus-xio-gridftp-driver.spec b/packaging/fedora/globus-xio-gridftp-driver.spec index 34c3b32111..838a11b861 100644 --- a/packaging/fedora/globus-xio-gridftp-driver.spec +++ b/packaging/fedora/globus-xio-gridftp-driver.spec @@ -2,7 +2,7 @@ Name: globus-xio-gridftp-driver %global _name %(echo %{name} | tr - _) -Version: 3.6 +Version: 3.7 Release: 1%{?dist} Summary: Grid Community Toolkit - Globus XIO GridFTP Driver @@ -152,6 +152,9 @@ GLOBUS_HOSTNAME=localhost make %{?_smp_mflags} check VERBOSE=1 %doc %{_pkgdocdir}/GLOBUS_LICENSE %changelog +* Tue May 19 2026 Mattias Ellert - 3.7-1 +- Fix compiler and doxygen warnings + * Fri Mar 11 2022 Mattias Ellert - 3.6-1 - Fix some compiler warnings diff --git a/packaging/fedora/globus-xio-gridftp-multicast.spec b/packaging/fedora/globus-xio-gridftp-multicast.spec index 4a33d498d1..be323ae5f2 100644 --- a/packaging/fedora/globus-xio-gridftp-multicast.spec +++ b/packaging/fedora/globus-xio-gridftp-multicast.spec @@ -2,7 +2,7 @@ Name: globus-xio-gridftp-multicast %global _name %(echo %{name} | tr - _) -Version: 2.2 +Version: 2.3 Release: 1%{?dist} Summary: Grid Community Toolkit - Globus XIO GridFTP Multicast Driver @@ -103,6 +103,9 @@ rm $RPM_BUILD_ROOT%{_libdir}/*.la %{_libdir}/pkgconfig/%{name}.pc %changelog +* Tue May 19 2026 Mattias Ellert - 2.3-1 +- Fix compiler warnings + * Fri Mar 11 2022 Mattias Ellert - 2.2-1 - Fix some compiler warnings diff --git a/packaging/fedora/globus-xio-pipe-driver.spec b/packaging/fedora/globus-xio-pipe-driver.spec index 6822b12fd1..c8a1f753cf 100644 --- a/packaging/fedora/globus-xio-pipe-driver.spec +++ b/packaging/fedora/globus-xio-pipe-driver.spec @@ -2,7 +2,7 @@ Name: globus-xio-pipe-driver %global _name %(echo %{name} | tr - _) -Version: 4.1 +Version: 4.2 Release: 1%{?dist} Summary: Grid Community Toolkit - Globus Pipe Driver @@ -102,6 +102,9 @@ rm $RPM_BUILD_ROOT%{_libdir}/*.la %{_libdir}/pkgconfig/%{name}.pc %changelog +* Tue May 19 2026 Mattias Ellert - 4.2-1 +- Fix compiler warnings + * Thu Jul 18 2019 Mattias Ellert - 4.1-1 - Add AC_CONFIG_MACRO_DIR and ACLOCAL_AMFLAGS diff --git a/packaging/fedora/globus-xio.spec b/packaging/fedora/globus-xio.spec index ea5eda902e..8591875e45 100644 --- a/packaging/fedora/globus-xio.spec +++ b/packaging/fedora/globus-xio.spec @@ -3,7 +3,7 @@ Name: globus-xio %global soname 0 %global _name %(echo %{name} | tr - _) -Version: 6.6 +Version: 6.7 Release: 1%{?dist} Summary: Grid Community Toolkit - Globus XIO Framework @@ -140,6 +140,9 @@ GLOBUS_HOSTNAME=localhost make %{?_smp_mflags} check VERBOSE=1 %doc %{_pkgdocdir}/GLOBUS_LICENSE %changelog +* Tue May 19 2026 Mattias Ellert - 6.7-1 +- Fix compiler and doxygen warnings + * Fri Mar 11 2022 Mattias Ellert - 6.6-1 - Fix some compiler and doxygen warnings diff --git a/packaging/fedora/globus-xioperf.spec b/packaging/fedora/globus-xioperf.spec index a907654d12..24555591ad 100644 --- a/packaging/fedora/globus-xioperf.spec +++ b/packaging/fedora/globus-xioperf.spec @@ -2,7 +2,7 @@ Name: globus-xioperf %global _name %(echo %{name} | tr - _) -Version: 5.1 +Version: 5.2 Release: 1%{?dist} Summary: Grid Community Toolkit - XIO Performance Tool @@ -47,6 +47,9 @@ make install DESTDIR=$RPM_BUILD_ROOT %doc %{_pkgdocdir}/GLOBUS_LICENSE %changelog +* Tue May 19 2026 Mattias Ellert - 5.2-1 +- Fix compiler warnings + * Thu Jul 18 2019 Mattias Ellert - 5.1-1 - Add AC_CONFIG_MACRO_DIR and ACLOCAL_AMFLAGS diff --git a/packaging/fedora/myproxy.spec b/packaging/fedora/myproxy.spec index 852aa9e483..8eaa83ebd7 100644 --- a/packaging/fedora/myproxy.spec +++ b/packaging/fedora/myproxy.spec @@ -2,7 +2,7 @@ Name: myproxy %global soname 6 -Version: 6.2.20 +Version: 6.2.21 Release: 1%{?dist} Summary: Manage X.509 Public Key Infrastructure (PKI) security credentials @@ -391,6 +391,10 @@ fi %doc %{_pkgdocdir}/LICENSE* %changelog +* Tue May 19 2026 Mattias Ellert - 6.2.21-1 +- Compile with OpenSSL 4 +- Fix compiler warnings + * Fri Jan 17 2025 Mattias Ellert - 6.2.20-1 - Fix incompatible pointer errors (gcc 15) diff --git a/xio/drivers/pipe/source/configure.ac b/xio/drivers/pipe/source/configure.ac index 69d036f9cd..c004ec7ec8 100644 --- a/xio/drivers/pipe/source/configure.ac +++ b/xio/drivers/pipe/source/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ([2.60]) -AC_INIT([globus_xio_pipe_driver], [4.1],[https://github.com/gridcf/gct/issues]) +AC_INIT([globus_xio_pipe_driver], [4.2],[https://github.com/gridcf/gct/issues]) AC_CONFIG_MACRO_DIR([m4]) AC_SUBST([MAJOR_VERSION], [${PACKAGE_VERSION%%.*}]) AC_SUBST([MINOR_VERSION], [${PACKAGE_VERSION##*.}]) diff --git a/xio/drivers/pipe/source/globus_xio_pipe_driver.c b/xio/drivers/pipe/source/globus_xio_pipe_driver.c index 8f476a4f08..b0f8c71b1c 100644 --- a/xio/drivers/pipe/source/globus_xio_pipe_driver.c +++ b/xio/drivers/pipe/source/globus_xio_pipe_driver.c @@ -28,7 +28,7 @@ GlobusDebugDefine(GLOBUS_XIO_PIPE); GlobusXIOPipeDebugPrintf( \ GLOBUS_L_XIO_PIPE_DEBUG_TRACE, \ (_XIOSL("[%s] Entering\n"), _xio_name)) - + #define GlobusXIOPipeDebugExit() \ GlobusXIOPipeDebugPrintf( \ GLOBUS_L_XIO_PIPE_DEBUG_TRACE, \ @@ -70,7 +70,7 @@ typedef struct xio_l_pipe_attr_s { globus_bool_t use_blocking_io; globus_xio_system_file_t infd; - globus_xio_system_file_t outfd; + globus_xio_system_file_t outfd; } xio_l_pipe_attr_t; /* default attr */ @@ -194,7 +194,7 @@ globus_l_xio_pipe_attr_cntl( case GLOBUS_XIO_PIPE_SET_OUT_HANDLE: attr->outfd = va_arg(ap, globus_xio_system_file_t); break; - + default: break; } @@ -208,13 +208,10 @@ globus_result_t globus_l_xio_pipe_attr_destroy( void * driver_attr) { - xio_l_pipe_attr_t * attr; GlobusXIOName(globus_l_xio_pipe_attr_destroy); GlobusXIOPipeDebugEnter(); - attr = (xio_l_pipe_attr_t *) driver_attr; - globus_free(driver_attr); GlobusXIOPipeDebugExit(); @@ -232,9 +229,9 @@ globus_l_xio_pipe_handle_init( { globus_result_t result; GlobusXIOName(globus_l_xio_pipe_handle_init); - + GlobusXIOPipeDebugEnter(); - + *handle = (xio_l_pipe_handle_t *) globus_calloc(1, sizeof(xio_l_pipe_handle_t)); if(!*handle) @@ -242,7 +239,7 @@ globus_l_xio_pipe_handle_init( result = GlobusXIOErrorMemory("handle"); goto error_handle; } - + globus_mutex_init(&(*handle)->lock, NULL); (*handle)->use_blocking_io = attr->use_blocking_io; (*handle)->infd = attr->infd; @@ -253,7 +250,7 @@ globus_l_xio_pipe_handle_init( error_handle: GlobusXIOPipeDebugExitWithError(); - return result; + return result; } static @@ -262,12 +259,12 @@ globus_l_xio_pipe_handle_destroy( xio_l_pipe_handle_t * handle) { GlobusXIOName(globus_l_xio_pipe_handle_destroy); - + GlobusXIOPipeDebugEnter(); - + globus_mutex_destroy(&handle->lock); globus_free(handle); - + GlobusXIOPipeDebugExit(); } @@ -287,9 +284,9 @@ globus_l_xio_pipe_open( xio_l_pipe_attr_t * attr; globus_result_t result; GlobusXIOName(globus_l_xio_pipe_open); - + GlobusXIOPipeDebugEnter(); - + attr = (xio_l_pipe_attr_t *) (driver_attr ? driver_attr : &xio_l_pipe_attr_default); result = globus_l_xio_pipe_handle_init(&handle, attr); @@ -314,9 +311,9 @@ globus_l_xio_pipe_open( "globus_xio_system_file_init", result); goto error_init; } - + globus_xio_driver_finished_open(handle, op, GLOBUS_SUCCESS); - + GlobusXIOPipeDebugExit(); return GLOBUS_SUCCESS; @@ -341,18 +338,18 @@ globus_l_xio_pipe_close( GlobusXIOName(globus_l_xio_pipe_close); GlobusXIOPipeDebugEnter(); - + handle = (xio_l_pipe_handle_t *) driver_specific_handle; - + globus_xio_system_file_destroy(handle->in_system); globus_xio_system_file_destroy(handle->out_system); - + globus_xio_system_file_close(handle->infd); globus_xio_system_file_close(handle->outfd); - + globus_xio_driver_finished_close(op, GLOBUS_SUCCESS); globus_l_xio_pipe_handle_destroy(handle); - + GlobusXIOPipeDebugExit(); return GLOBUS_SUCCESS; } @@ -366,13 +363,13 @@ globus_l_xio_pipe_system_read_cb( { globus_xio_operation_t op; GlobusXIOName(globus_l_xio_pipe_system_read_cb); - + GlobusXIOPipeDebugEnter(); - + op = (globus_xio_operation_t) user_arg; - + globus_xio_driver_finished_read(op, result, nbytes); - + GlobusXIOPipeDebugExit(); } @@ -393,9 +390,9 @@ globus_l_xio_pipe_read( GlobusXIOName(globus_l_xio_pipe_read); GlobusXIOPipeDebugEnter(); - + handle = (xio_l_pipe_handle_t *) driver_specific_handle; - + /* if buflen and waitfor are both 0, we behave like register select */ if((globus_xio_operation_get_wait_for(op) == 0 && (iovec_count > 1 || iovec[0].iov_len > 0)) || @@ -409,7 +406,7 @@ globus_l_xio_pipe_read( iovec_count, globus_xio_operation_get_wait_for(op), &nbytes); - + globus_xio_driver_finished_read(op, result, nbytes); result = GLOBUS_SUCCESS; } @@ -425,7 +422,7 @@ globus_l_xio_pipe_read( globus_l_xio_pipe_system_read_cb, op); } - + GlobusXIOPipeDebugExit(); return result; } @@ -439,13 +436,13 @@ globus_l_xio_pipe_system_write_cb( { globus_xio_operation_t op; GlobusXIOName(globus_l_xio_pipe_system_write_cb); - + GlobusXIOPipeDebugEnter(); - + op = (globus_xio_operation_t) user_arg; - + globus_xio_driver_finished_write(op, result, nbytes); - + GlobusXIOPipeDebugExit(); } @@ -464,11 +461,11 @@ globus_l_xio_pipe_write( globus_size_t nbytes; globus_result_t result; GlobusXIOName(globus_l_xio_pipe_write); - + GlobusXIOPipeDebugEnter(); - + handle = (xio_l_pipe_handle_t *) driver_specific_handle; - + /* if buflen and waitfor are both 0, we behave like register select */ if((globus_xio_operation_get_wait_for(op) == 0 && (iovec_count > 1 || iovec[0].iov_len > 0)) || @@ -482,7 +479,7 @@ globus_l_xio_pipe_write( iovec_count, globus_xio_operation_get_wait_for(op), &nbytes); - + globus_xio_driver_finished_write(op, result, nbytes); result = GLOBUS_SUCCESS; } @@ -498,7 +495,7 @@ globus_l_xio_pipe_write( globus_l_xio_pipe_system_write_cb, op); } - + GlobusXIOPipeDebugExit(); return result; } @@ -520,11 +517,11 @@ globus_l_xio_pipe_init( globus_xio_driver_t driver; globus_result_t result; GlobusXIOName(globus_l_xio_pipe_init); - + GlobusXIOPipeDebugEnter(); - + /* I dont support any driver options, so I'll ignore the ap */ - + result = globus_xio_driver_init(&driver, "file", GLOBUS_NULL); if(result != GLOBUS_SUCCESS) { @@ -553,7 +550,7 @@ globus_l_xio_pipe_init( pipe_l_string_opts_table); *out_driver = driver; - + GlobusXIOPipeDebugExit(); return GLOBUS_SUCCESS; @@ -568,11 +565,11 @@ globus_l_xio_pipe_destroy( globus_xio_driver_t driver) { GlobusXIOName(globus_l_xio_pipe_destroy); - + GlobusXIOPipeDebugEnter(); - + globus_xio_driver_destroy(driver); - + GlobusXIOPipeDebugExit(); } @@ -586,13 +583,13 @@ int globus_l_xio_pipe_activate(void) { int rc; - + GlobusXIOName(globus_l_xio_pipe_activate); - + GlobusDebugInit(GLOBUS_XIO_PIPE, TRACE INFO); - + GlobusXIOPipeDebugEnter(); - + rc = globus_module_activate(GLOBUS_XIO_SYSTEM_MODULE); if(rc != GLOBUS_SUCCESS) { @@ -602,9 +599,9 @@ globus_l_xio_pipe_activate(void) xio_l_pipe_attr_default.infd = GetStdHandle(STD_INPUT_HANDLE); xio_l_pipe_attr_default.outfd = GetStdHandle(STD_OUTPUT_HANDLE); # endif - + GlobusXIORegisterDriver(pipe); - + GlobusXIOPipeDebugExit(); return GLOBUS_SUCCESS; @@ -619,14 +616,14 @@ int globus_l_xio_pipe_deactivate(void) { GlobusXIOName(globus_l_xio_pipe_deactivate); - + GlobusXIOPipeDebugEnter(); - + GlobusXIOUnRegisterDriver(pipe); globus_module_deactivate(GLOBUS_XIO_SYSTEM_MODULE); - + GlobusXIOPipeDebugExit(); GlobusDebugDestroy(GLOBUS_XIO_PIPE); - + return GLOBUS_SUCCESS; } diff --git a/xio/src/builtins/http/globus_i_xio_http.h b/xio/src/builtins/http/globus_i_xio_http.h index b4e3968190..c8b93f28b6 100644 --- a/xio/src/builtins/http/globus_i_xio_http.h +++ b/xio/src/builtins/http/globus_i_xio_http.h @@ -102,7 +102,7 @@ typedef struct /** * buffer to hold the chunk size line */ - globus_byte_t chunk_size_buffer[64]; + globus_byte_t chunk_size_buffer[64]; } globus_i_xio_http_operation_info_t; @@ -335,12 +335,12 @@ typedef struct globus_i_xio_http_handle_s * contain unparsed data */ globus_size_t read_buffer_valid; - + /** * Operation used for closing, when an error occurs at open time. */ globus_xio_operation_t close_operation; - + /** * Remaining-to-be-read chunk. */ @@ -372,7 +372,7 @@ typedef struct globus_i_xio_http_handle_s */ globus_xio_operation_t response_read_operation; - + globus_i_xio_http_operation_info_t read_operation; globus_i_xio_http_operation_info_t write_operation; @@ -402,7 +402,7 @@ typedef struct globus_i_xio_http_handle_s * drops us */ globus_bool_t reopen_in_progress; - + /* error from internal response read, usually with a broken persistent * connection */ @@ -437,7 +437,7 @@ globus_i_xio_http_copy_blob( extern char * globus_i_xio_http_find_eol( - const char * blob, + char * blob, globus_size_t blob_length); extern @@ -662,7 +662,7 @@ globus_result_t globus_i_xio_http_server_read_next_request( globus_i_xio_http_handle_t * http_handle); -/* globus_xio_http_target.c */ +/* globus_xio_http_target.c */ extern globus_result_t globus_i_xio_http_target_init( @@ -711,7 +711,7 @@ globus_result_t globus_l_xio_http_client_parse_response( globus_i_xio_http_handle_t * http_handle, globus_bool_t * done); - + void globus_l_xio_http_client_read_response_callback( globus_xio_operation_t op, @@ -748,7 +748,7 @@ globus_i_xio_http_close( void * attr, globus_xio_operation_t op); -extern +extern globus_result_t globus_i_xio_http_close_internal( globus_i_xio_http_handle_t * http_handle); diff --git a/xio/src/builtins/http/globus_xio_http.c b/xio/src/builtins/http/globus_xio_http.c index 1b7d71a240..14841c526d 100644 --- a/xio/src/builtins/http/globus_xio_http.c +++ b/xio/src/builtins/http/globus_xio_http.c @@ -71,7 +71,7 @@ globus_l_xio_http_init( globus_i_xio_http_read, globus_i_xio_http_write, globus_i_xio_http_handle_cntl, - NULL); + NULL); globus_xio_driver_set_server( driver, @@ -171,6 +171,8 @@ globus_i_xio_http_copy_blob( } /* globus_l_xio_http_copy_blob() */ +#ifndef GLOBUS_DONT_DOCUMENT_INTERNAL + /** * Determine whether an HTTP method should contain an entity. * @ingroup globus_i_xio_http_util @@ -274,13 +276,13 @@ globus_i_xio_http_guess_version( */ char * globus_i_xio_http_find_eol( - const char * blob, + char * blob, globus_size_t blob_length) { char * result; globus_size_t skip = 0; - while (((skip + 1) < blob_length) && + while (((skip + 1) < blob_length) && (result = memchr(blob + skip, '\r', blob_length-skip)) != NULL) { if (result+1 == (blob + skip + blob_length)) @@ -291,7 +293,7 @@ globus_i_xio_http_find_eol( { return result; } - else + else { skip += (result - blob + 1); } @@ -368,7 +370,7 @@ globus_i_xio_http_clean_read_buffer( + http_handle->read_buffer_offset + http_handle->read_buffer_valid; - http_handle->read_iovec.iov_len = + http_handle->read_iovec.iov_len = http_handle->read_buffer.iov_len - http_handle->read_buffer_offset - http_handle->read_buffer_valid; @@ -379,6 +381,8 @@ globus_i_xio_http_clean_read_buffer( } /* globus_i_xio_http_cleanup_read_buffer() */ +#endif /* GLOBUS_DONT_DOCUMENT_INTERNAL */ + GlobusXIODefineDriver( http, globus_l_xio_http_init, @@ -409,9 +413,9 @@ globus_l_xio_http_deactivate(void) { globus_i_xio_http_handle_t * http_handle; globus_result_t result; - + GlobusXIOUnRegisterDriver(http); - + globus_mutex_lock(&globus_i_xio_http_cached_handle_mutex); while (!globus_list_empty(globus_i_xio_http_cached_handles)) { diff --git a/xio/src/builtins/http/globus_xio_http_attr.c b/xio/src/builtins/http/globus_xio_http_attr.c index e58a8db750..94de4ee2db 100644 --- a/xio/src/builtins/http/globus_xio_http_attr.c +++ b/xio/src/builtins/http/globus_xio_http_attr.c @@ -23,6 +23,8 @@ */ #endif +#ifndef GLOBUS_DONT_DOCUMENT_INTERNAL + /** * Allocate and initialize an HTTP attribute * @ingroup globus_i_xio_http_attr @@ -31,7 +33,7 @@ * driver via globus_xio_attr_init(). * * @param out_attr - * Pointer value will be set to point to a + * Pointer value will be set to point to a * newly allocated and initilized #globus_i_xio_http_attr_t * structure. * @@ -355,3 +357,5 @@ globus_i_xio_http_attr_destroy( return GLOBUS_SUCCESS; } /* globus_i_xio_http_attr_destroy() */ + +#endif /* GLOBUS_DONT_DOCUMENT_INTERNAL */ diff --git a/xio/src/builtins/http/globus_xio_http_client.c b/xio/src/builtins/http/globus_xio_http_client.c index da6fa218b6..225083a20f 100644 --- a/xio/src/builtins/http/globus_xio_http_client.c +++ b/xio/src/builtins/http/globus_xio_http_client.c @@ -36,6 +36,8 @@ globus_result_t globus_l_xio_http_cleanup_cancel( globus_i_xio_http_handle_t * http_handle); +#ifndef GLOBUS_DONT_DOCUMENT_INTERNAL + /** * Client-side connection open callback * @ingroup globus_i_xio_http_client @@ -47,15 +49,13 @@ globus_l_xio_http_cleanup_cancel( * If this function succeeds, the open will remain unfinished until that * write completes. If an error happens, this function will close the handle * internally and call globus_xio_driver_finished_open() before returning. - * + * * @param op * operation associated with the open call. * @param result * Lower-level protocol result from open. * @param user_arg - * A void pointer pointing to a #globus_i_xio_http_driver_t - * - * @return void + * A void pointer pointing to a #globus_i_xio_http_driver_t */ void globus_i_xio_http_client_open_callback( @@ -291,7 +291,7 @@ globus_i_xio_http_client_write_request( strlen(http_handle->target_info.host), free_iovecs_exit); - if (http_handle->target_info.port != 0 && + if (http_handle->target_info.port != 0 && http_handle->target_info.port != 80) { char port_buffer[7]; @@ -316,7 +316,7 @@ globus_i_xio_http_client_write_request( &http_handle->request_info.headers)) { if ((http_handle->request_info.http_version == - GLOBUS_XIO_HTTP_VERSION_1_0) || + GLOBUS_XIO_HTTP_VERSION_1_0) || ((http_handle->request_info.headers.transfer_encoding == GLOBUS_XIO_HTTP_TRANSFER_ENCODING_IDENTITY) && GLOBUS_I_XIO_HTTP_HEADER_IS_CONTENT_LENGTH_SET( @@ -339,7 +339,7 @@ globus_i_xio_http_client_write_request( size_buffer = globus_common_create_string( "%"GLOBUS_OFF_T_FORMAT"\r\n", http_handle->request_info.headers.content_length); - + if (size_buffer == NULL) { result = GlobusXIOErrorMemory("iovec.iov_base"); @@ -457,7 +457,7 @@ globus_i_xio_http_client_write_request( /* globus_i_xio_http_client_write_request() */ /** - * Request Written Callback + * Request Written Callback * @ingroup globus_i_xio_http_write_request_callback * * Called when the response has been completely written by the transport. @@ -476,8 +476,6 @@ globus_i_xio_http_client_write_request( * Number of bytes in the message that were written. * @param user_arg * Void pointer containing the #globus_i_xio_http_handle_t. - * - * @return void */ static void @@ -660,10 +658,7 @@ globus_l_xio_http_client_write_request_callback( * @param user_arg * Void * pointing to the #globus_i_xio_http_handle_t associated * with this response. - * - * @return void */ - void globus_l_xio_http_client_read_response_callback( globus_xio_operation_t op, @@ -694,7 +689,7 @@ globus_l_xio_http_client_read_response_callback( response_error = globus_error_get(result); http_handle->response_info.status_code = 500; - http_handle->response_info.reason_phrase = + http_handle->response_info.reason_phrase = globus_error_print_friendly(response_error); if (http_handle->write_operation.operation != NULL) @@ -716,7 +711,7 @@ globus_l_xio_http_client_read_response_callback( http_handle->pending_error = globus_object_copy(response_error); http_handle->parse_state = GLOBUS_XIO_HTTP_EOF; http_handle->send_state = GLOBUS_XIO_HTTP_EOF; - + /* Set metadata on this read to contain the response info */ descriptor = globus_xio_operation_get_data_descriptor(op, GLOBUS_TRUE); if (descriptor != NULL) @@ -726,7 +721,7 @@ globus_l_xio_http_client_read_response_callback( &descriptor->response, &http_handle->response_info); } - + /* don't go to error exit yet because we may need to clean up * the cancel info */ @@ -823,13 +818,13 @@ globus_l_xio_http_client_read_response_callback( } } - if(http_handle->response_info.status_code > 199 || + if(http_handle->response_info.status_code > 199 || http_handle->response_info.status_code < 100) { globus_xio_driver_operation_destroy(http_handle->response_read_operation); http_handle->response_read_operation = NULL; } - + globus_mutex_unlock(&http_handle->mutex); if (finish_read) @@ -938,7 +933,7 @@ globus_l_xio_http_client_read_response_callback( * @ingroup globus_i_xio_http_client * * Parses the response line and then uses globus_i_xio_http_header_parse() to - * parse the header block. If the entire response header section is read, + * parse the header block. If the entire response header section is read, * the boolean pointed to by @a done will be modified to be GLOBUS_TRUE. * * Called with mutex locked. @@ -951,7 +946,7 @@ globus_l_xio_http_client_read_response_callback( * globus_i_xio_http_header_parse(). * @retval GLOBUS_SUCCESS * No parsing errors occurred while parsing the status line or headers. - * Parsing may still be incomplete, depending on the final value of + * Parsing may still be incomplete, depending on the final value of * @a done. * @retval ::GLOBUS_XIO_HTTP_ERROR_PARSE * Parse error reading the HTTP Status line @@ -1005,7 +1000,7 @@ globus_l_xio_http_client_parse_response( goto error_exit; } - http_handle->response_info.http_version = + http_handle->response_info.http_version = globus_i_xio_http_guess_version(http_major, http_minor); current_offset += parsed; @@ -1023,7 +1018,7 @@ globus_l_xio_http_client_parse_response( goto error_exit; } - + current_offset += parsed; /* Reason Phrase */ @@ -1054,7 +1049,7 @@ globus_l_xio_http_client_parse_response( { http_handle->parse_state = GLOBUS_XIO_HTTP_STATUS_LINE; } - + return result; error_exit: @@ -1120,7 +1115,7 @@ globus_l_xio_http_cleanup_cancel( else { /* Cancel callback occurred in another thread. That thread will - * try to cancel this operation. We are obliged to free the + * try to cancel this operation. We are obliged to free the * cancel info. */ @@ -1133,3 +1128,5 @@ globus_l_xio_http_cleanup_cancel( return result; } + +#endif /* GLOBUS_DONT_DOCUMENT_INTERNAL */ diff --git a/xio/src/builtins/http/globus_xio_http_handle.c b/xio/src/builtins/http/globus_xio_http_handle.c index 1111ad278f..6261e5c829 100644 --- a/xio/src/builtins/http/globus_xio_http_handle.c +++ b/xio/src/builtins/http/globus_xio_http_handle.c @@ -31,6 +31,8 @@ globus_l_xio_http_write_eof_callback( globus_size_t nbytes, void * user_arg); +#ifndef GLOBUS_DONT_DOCUMENT_INTERNAL + /** * Allocate and initialize an HTTP handle * @ingroup globus_i_xio_http_handle @@ -227,8 +229,6 @@ globus_i_xio_http_handle_reinit( * * @param http_handle * Handle to be destroyed. - * - * @return void */ void globus_i_xio_http_handle_destroy( @@ -282,7 +282,7 @@ globus_i_xio_http_handle_destroy( * @retval GLOBUS_XIO_ERROR_MEMORY * The command failed due to memory constraints. * @retval GLOBUS_XIO_ERROR_PARAMETER - * Invalid @a cmd parameter or invlaid value of cmd-specific parameters + * Invalid @a cmd parameter or invlaid value of cmd-specific parameters * in @a ap */ globus_result_t @@ -438,6 +438,8 @@ globus_i_xio_http_handle_cntl( } /* globus_i_xio_http_handle_cntl() */ +#endif /* GLOBUS_DONT_DOCUMENT_INTERNAL */ + /** * Called with mutex locked */ @@ -446,9 +448,8 @@ globus_i_xio_http_set_end_of_entity( globus_i_xio_http_handle_t * http_handle) { globus_result_t result = GLOBUS_SUCCESS; - globus_i_xio_http_header_info_t * headers; static globus_xio_iovec_t end_of_body_iovec = { - .iov_base = "0\r\n\r\n", + .iov_base = "0\r\n\r\n", .iov_len = 5 }; GlobusXIOName(globus_i_xio_http_set_end_of_entity); @@ -459,15 +460,7 @@ globus_i_xio_http_set_end_of_entity( goto error_exit; } - else if (http_handle->target_info.is_client) - { - headers = &http_handle->request_info.headers; - } - else - { - headers = &http_handle->response_info.headers; - } - + if (http_handle->send_state == GLOBUS_XIO_HTTP_STATUS_LINE) { /* To send an empty response from server */ diff --git a/xio/src/builtins/http/globus_xio_http_header.c b/xio/src/builtins/http/globus_xio_http_header.c index f5819e7839..5b53e2725d 100644 --- a/xio/src/builtins/http/globus_xio_http_header.c +++ b/xio/src/builtins/http/globus_xio_http_header.c @@ -23,6 +23,8 @@ */ #endif +#ifndef GLOBUS_DONT_DOCUMENT_INTERNAL + /** * Destroy an HTTP Header * @ingroup globus_i_xio_http_header @@ -33,8 +35,6 @@ * * @param header * A void * pointing to the header to be freed. - * - * @return void */ extern void @@ -76,8 +76,6 @@ globus_i_xio_http_header_destroy( * @param src_datum * A void * pointing to the HTTP header structure in the * original hashtable to copy. - * - * @return void */ extern void @@ -264,7 +262,7 @@ globus_i_xio_http_header_parse( { http_handle->parse_state = GLOBUS_XIO_HTTP_CHUNK_LINE; } - else if ((http_handle->target_info.is_client && + else if ((http_handle->target_info.is_client && http_handle->response_info.http_version == GLOBUS_XIO_HTTP_VERSION_1_0) || GLOBUS_I_XIO_HTTP_HEADER_IS_CONTENT_LENGTH_SET(headers)) @@ -295,3 +293,5 @@ globus_i_xio_http_header_parse( return result; } /* globus_i_xio_http_header_parse() */ + +#endif /* GLOBUS_DONT_DOCUMENT_INTERNAL */ diff --git a/xio/src/builtins/http/globus_xio_http_header_info.c b/xio/src/builtins/http/globus_xio_http_header_info.c index 64ca01e973..af1189260e 100644 --- a/xio/src/builtins/http/globus_xio_http_header_info.c +++ b/xio/src/builtins/http/globus_xio_http_header_info.c @@ -23,6 +23,8 @@ */ #endif +#ifndef GLOBUS_DONT_DOCUMENT_INTERNAL + /** * Initialize an HTTP header info structure * @ingroup globus_i_xio_http_header_info @@ -71,8 +73,6 @@ globus_i_xio_http_header_info_init( * * @param header_info * Header information structure to destroy. - * - * @return void */ void globus_i_xio_http_header_info_destroy( @@ -142,7 +142,7 @@ globus_i_xio_http_header_info_copy( * Adds a new header to a header info structure, or updates the value of an * existing header. Copies of the name and value will be stored in a * #globus_xio_http_header_t in a hashtable in the header info structure. - * + * * @param headers * Pointer to the header info structure. * @param header_name @@ -229,7 +229,7 @@ globus_i_xio_http_header_info_set_header( { store = GLOBUS_TRUE; } - + if(store) { /* @@ -308,3 +308,5 @@ globus_i_xio_http_header_info_set_header( return result; } /* globus_l_xio_http_header_info_set_header() */ + +#endif /* GLOBUS_DONT_DOCUMENT_INTERNAL */ diff --git a/xio/src/builtins/http/globus_xio_http_request.c b/xio/src/builtins/http/globus_xio_http_request.c index 067875940b..d4a1e8f235 100644 --- a/xio/src/builtins/http/globus_xio_http_request.c +++ b/xio/src/builtins/http/globus_xio_http_request.c @@ -23,6 +23,8 @@ */ #endif +#ifndef GLOBUS_DONT_DOCUMENT_INTERNAL + /** * Initialize an HTTP request * @ingroup globus_i_xio_http_request @@ -57,8 +59,6 @@ globus_i_xio_http_request_init( * * @param request * Request structure to destroy. - * - * @return void */ void globus_i_xio_http_request_destroy( @@ -168,3 +168,5 @@ globus_i_xio_http_request_copy( return res; } /* globus_i_xio_http_request_copy() */ + +#endif /* GLOBUS_DONT_DOCUMENT_INTERNAL */ diff --git a/xio/src/builtins/http/globus_xio_http_response.c b/xio/src/builtins/http/globus_xio_http_response.c index ec477477ad..0951ae16af 100644 --- a/xio/src/builtins/http/globus_xio_http_response.c +++ b/xio/src/builtins/http/globus_xio_http_response.c @@ -23,6 +23,8 @@ */ #endif +#ifndef GLOBUS_DONT_DOCUMENT_INTERNAL + /** * Initialize an HTTP response * @ingroup globus_i_xio_http_response @@ -65,8 +67,6 @@ globus_i_xio_http_response_init( * * @param response * Response structure to destroy. - * - * @return void */ void globus_i_xio_http_response_destroy( @@ -153,3 +153,5 @@ globus_i_xio_http_response_copy( return res; } /* globus_i_xio_http_response_copy() */ + +#endif /* GLOBUS_DONT_DOCUMENT_INTERNAL */ diff --git a/xio/src/builtins/http/globus_xio_http_server.c b/xio/src/builtins/http/globus_xio_http_server.c index 99736b3b50..41db9f877a 100644 --- a/xio/src/builtins/http/globus_xio_http_server.c +++ b/xio/src/builtins/http/globus_xio_http_server.c @@ -44,11 +44,13 @@ globus_l_xio_http_server_write_response_callback( globus_size_t nbytes, void * user_arg); +#ifndef GLOBUS_DONT_DOCUMENT_INTERNAL + /** * Accept an HTTP request * @ingroup globus_i_xio_http_server * - * Passes the request to the transport driver. In the callback, + * Passes the request to the transport driver. In the callback, * the request target information will be generated. * * @param driver_server @@ -87,8 +89,6 @@ globus_i_xio_http_accept( * @param user_arg * Not used. * - * @return void - * * @todo When implemented in the XIO driver framework, parse the request * header before returning from this, so the target is populated with * meaningful information for the user. This will help enable persistent @@ -103,7 +103,7 @@ globus_l_xio_http_accept_callback( { globus_i_xio_http_target_t * target_info = NULL; GlobusXIOName(globus_l_xio_http_accept_callback); - + if (result == GLOBUS_SUCCESS) { target_info = globus_i_xio_http_target_new(); @@ -134,8 +134,6 @@ globus_l_xio_http_accept_callback( * @param user_arg * Void * pointing to a #globus_i_xio_http_handle_t associated with * this open. - * - * @return void */ void globus_i_xio_http_server_open_callback( @@ -194,7 +192,7 @@ globus_i_xio_http_server_open_callback( * * @retval GLOBUS_SUCCESS * Response was passed to the transport for writing. If this was generated - * by a user writing data, then the write will occur after the + * by a user writing data, then the write will occur after the * globus_l_xio_http_server_write_response_callback() has been called. * @retval GLOBUS_XIO_ERROR_MEMORY * Unable to compose the response due to memory constraints. @@ -299,7 +297,7 @@ globus_i_xio_http_server_write_response( GLOBUS_I_XIO_HTTP_HEADER_IS_CONTENT_LENGTH_SET( &http_handle->response_info.headers))) { - http_handle->response_info.headers.flags |= + http_handle->response_info.headers.flags |= GLOBUS_I_XIO_HTTP_HEADER_CONNECTION_CLOSE; GLOBUS_XIO_HTTP_COPY_BLOB(&iovecs, @@ -498,8 +496,6 @@ globus_i_xio_http_server_write_response( * finished. If the response was triggered by the * GLOBUS_XIO_HTTP_HANDLE_SET_END_OF_ENTITY control, then the operation * is simply destroyed. - * - * @return void */ static void @@ -683,7 +679,7 @@ globus_l_xio_http_server_parse_request( globus_assert(rc == 1); current_offset += parsed; - + rc = sscanf(current_offset, "%*s %n", &parsed); if (rc < 0) { @@ -740,6 +736,8 @@ globus_l_xio_http_server_parse_request( } /* globus_l_xio_http_server_parse_request() */ +#endif /* GLOBUS_DONT_DOCUMENT_INTERNAL */ + void globus_i_xio_http_server_read_request_callback( globus_xio_operation_t op, @@ -809,7 +807,7 @@ globus_i_xio_http_server_read_request_callback( if (descriptor == NULL) { result = GlobusXIOErrorMemory("descriptor"); - + goto error_exit; } globus_i_xio_http_request_destroy(&descriptor->request); @@ -848,7 +846,7 @@ globus_i_xio_http_server_read_request_callback( http_handle->read_operation.nbytes = 0; globus_mutex_unlock(&http_handle->mutex); - + globus_xio_driver_finished_read(op, result, nbytes); return; diff --git a/xio/src/builtins/http/globus_xio_http_target.c b/xio/src/builtins/http/globus_xio_http_target.c index 58732ae780..c87486efd9 100644 --- a/xio/src/builtins/http/globus_xio_http_target.c +++ b/xio/src/builtins/http/globus_xio_http_target.c @@ -23,6 +23,8 @@ */ #endif +#ifndef GLOBUS_DONT_DOCUMENT_INTERNAL + /** * Allocate a new target * @ingroup globus_i_xio_http_target @@ -108,7 +110,7 @@ globus_i_xio_http_target_init( else { res = GlobusXIOErrorParameter("port"); - + goto free_target_exit; } } @@ -219,6 +221,8 @@ globus_i_xio_http_target_destroy( } /* globus_i_xio_http_target_destroy() */ +#endif /* GLOBUS_DONT_DOCUMENT_INTERNAL */ + extern void globus_i_xio_http_target_destroy_internal( diff --git a/xio/src/builtins/http/globus_xio_http_transform.c b/xio/src/builtins/http/globus_xio_http_transform.c index 6a31a3e903..cc1162e777 100644 --- a/xio/src/builtins/http/globus_xio_http_transform.c +++ b/xio/src/builtins/http/globus_xio_http_transform.c @@ -94,9 +94,11 @@ void globus_l_xio_http_read_timeout_callback( void * user_arg); +#ifndef GLOBUS_DONT_DOCUMENT_INTERNAL + /** * Open an HTTP URI - * @ingroup globus_i_xio_http_transform + * @ingroup globus_i_xio_http_transform * * Opens a new connection to handle an HTTP request. Allocates a handle * and then passes the open on to the transport. In the callback called @@ -131,7 +133,7 @@ globus_i_xio_http_open( globus_i_xio_http_target_t * target = NULL; globus_i_xio_http_handle_t * http_handle; GlobusXIOName(globus_i_xio_http_open); - + if(link) { target = (globus_i_xio_http_target_t *) link; @@ -144,7 +146,7 @@ globus_i_xio_http_open( goto error; } } - + http_handle = globus_l_xio_http_find_cached_handle(target, attr); if (http_handle != NULL) @@ -155,7 +157,7 @@ globus_i_xio_http_open( { result = globus_l_xio_http_open(contact_info, target, attr, op); } - + if(!link && target) { globus_i_xio_http_target_destroy(target); @@ -279,11 +281,11 @@ globus_l_xio_http_open( open_callback = globus_i_xio_http_server_open_callback; http_handle->send_state = GLOBUS_XIO_HTTP_STATUS_LINE; } - + memcpy(&new_contact_info, contact_info, sizeof(new_contact_info)); snprintf(port_buf, sizeof(port_buf), "%hu", http_handle->target_info.port); new_contact_info.port = port_buf; - + http_handle->handle = globus_xio_operation_get_driver_handle(op); result = globus_xio_driver_pass_open( @@ -377,7 +379,7 @@ globus_l_xio_http_find_cached_handle( * Operation associated with the read. * * @return - * This function returns GLOBUS_SUCCESS, + * This function returns GLOBUS_SUCCESS, * GLOBUS_XIO_ERROR_ALREADY_REGISTERED, and GLOBUS_XIO_ERROR_EOF * errors directly. * @@ -425,7 +427,7 @@ globus_i_xio_http_read( globus_object_copy(http_handle->pending_error)); goto error_exit; } - + if (http_handle->read_operation.operation != NULL) { /* Only one read in progress per handle, sorry */ @@ -447,7 +449,7 @@ globus_i_xio_http_read( for (i = 0; i < iovec_count; i++) { - http_handle->read_operation.iov[i].iov_base = + http_handle->read_operation.iov[i].iov_base = iovec[i].iov_base; http_handle->read_operation.iov[i].iov_len = iovec[i].iov_len; @@ -475,7 +477,7 @@ globus_i_xio_http_read( } http_handle->cancellation->user_read_op = op; - http_handle->cancellation->internal_op = + http_handle->cancellation->internal_op = http_handle->response_read_operation; http_handle->cancellation->http_handle = http_handle; http_handle->cancellation->driver_handle = @@ -523,7 +525,7 @@ globus_i_xio_http_read( if (http_handle->read_buffer.iov_base == NULL) { result = GlobusXIOErrorMemory("read_buffer"); - + goto error_exit; } } @@ -537,7 +539,7 @@ globus_i_xio_http_read( } http_handle->parse_state = GLOBUS_XIO_HTTP_REQUEST_LINE; } - + result = globus_xio_driver_pass_read( op, &http_handle->read_buffer, @@ -578,7 +580,7 @@ globus_i_xio_http_read( } /* * Either we've read enough, hit end of chunk, no entity was present, - * or pass to transport failed. Call finished_read + * or pass to transport failed. Call finished_read */ op = http_handle->read_operation.operation; @@ -645,8 +647,6 @@ globus_i_xio_http_read( * @param registered_again * Set to GLOBUS_TRUE by this function if the read operation was passed * down again as a result of a partial read of data. - * - * @return void */ globus_result_t globus_i_xio_http_parse_residue( @@ -672,10 +672,10 @@ globus_i_xio_http_parse_residue( headers = &http_handle->request_info.headers; } - if (http_handle->read_operation.iovcnt == 0 || + if (http_handle->read_operation.iovcnt == 0 || http_handle->parse_state == GLOBUS_XIO_HTTP_EOF) { - http_handle->read_operation.wait_for = 0; + http_handle->read_operation.wait_for = 0; goto finish; } @@ -779,7 +779,7 @@ globus_i_xio_http_parse_residue( { nbytes = http_handle->read_operation.wait_for; } - + result = globus_xio_driver_pass_read( http_handle->read_operation.operation, http_handle->read_operation.iov, @@ -790,8 +790,8 @@ globus_i_xio_http_parse_residue( if (result == GLOBUS_SUCCESS) { *registered_again = GLOBUS_TRUE; - } - + } + } break; case GLOBUS_XIO_HTTP_STATUS_LINE: @@ -808,7 +808,7 @@ globus_i_xio_http_parse_residue( { goto finish; } - + result = globus_xio_driver_pass_read( http_handle->response_read_operation, &http_handle->read_iovec, @@ -816,7 +816,7 @@ globus_i_xio_http_parse_residue( 1, globus_l_xio_http_client_read_response_callback, http_handle); - + if (result != GLOBUS_SUCCESS) { goto finish; @@ -969,8 +969,6 @@ globus_l_xio_http_copy_residue( * Number of bytes read by the transport. * @param user_arg * Void pointer pointing to an HTTP handle. - * - * @return void */ static void @@ -1057,8 +1055,6 @@ globus_l_xio_http_read_callback( * Number of bytes read by the transport. * @param user_arg * Void pointer pointing to an HTTP handle. - * - * @return void */ static void @@ -1111,7 +1107,7 @@ globus_l_xio_http_read_chunk_header_callback( } /* * Either we've read enough, hit end of chunk, no entity was present, - * or pass to transport failed. Call finished_read + * or pass to transport failed. Call finished_read */ op = http_handle->read_operation.operation; @@ -1138,7 +1134,7 @@ globus_l_xio_http_read_chunk_header_callback( * @ingroup globus_i_xio_http_transform * * Parse the chunk size, end-of-chunk CRLF, or chunk footers, out of the - * handle's read buffer, depending on the current parse state. + * handle's read buffer, depending on the current parse state. * * @param http_handle * Handle associated with this parsing. @@ -1211,7 +1207,7 @@ globus_l_xio_http_parse_chunk_header( break; } - + /* FALLSTHROUGH */ case GLOBUS_XIO_HTTP_CHUNK_LINE: *eol = '\0'; @@ -1367,7 +1363,7 @@ globus_l_xio_http_parse_chunk_header( * Operation associated with the write. * * @return - * This function returns GLOBUS_SUCCESS, + * This function returns GLOBUS_SUCCESS, * GLOBUS_XIO_ERROR_ALREADY_REGISTERED, and GLOBUS_XIO_ERROR_EOF * errors directly. Other errors may be returned from * globus_i_xio_http_server_write_response(), @@ -1393,18 +1389,8 @@ globus_i_xio_http_write( { globus_i_xio_http_handle_t * http_handle = handle; globus_result_t result = GLOBUS_SUCCESS; - globus_i_xio_http_header_info_t * headers; GlobusXIOName(globus_i_xio_http_write); - if (http_handle->target_info.is_client) - { - headers = &http_handle->request_info.headers; - } - else - { - headers = &http_handle->response_info.headers; - } - globus_mutex_lock(&http_handle->mutex); if (http_handle->pending_error) @@ -1414,7 +1400,7 @@ globus_i_xio_http_write( } else { - + switch (http_handle->send_state) { case GLOBUS_XIO_HTTP_STATUS_LINE: @@ -1428,7 +1414,7 @@ globus_i_xio_http_write( case GLOBUS_XIO_HTTP_CLOSE: result = GlobusXIOHttpErrorNoEntity(); break; - + case GLOBUS_XIO_HTTP_CHUNK_BODY: if (http_handle->write_operation.operation != NULL) { @@ -1455,13 +1441,13 @@ globus_i_xio_http_write( globus_i_xio_http_write_callback, http_handle); break; - + case GLOBUS_XIO_HTTP_PRE_REQUEST_LINE: if(http_handle->delay_write_header) { http_handle->first_write_iovec = iovec; http_handle->first_write_iovec_count = iovec_count; - + result = globus_i_xio_http_client_write_request( op, http_handle); @@ -1552,7 +1538,7 @@ globus_i_xio_http_write_chunk( } http_handle->write_operation.operation = op; http_handle->write_operation.driver_handle = globus_xio_operation_get_driver_handle(op); - http_handle->write_operation.iov = globus_libc_malloc((iovec_count + 2) * + http_handle->write_operation.iov = globus_libc_malloc((iovec_count + 2) * sizeof(globus_xio_iovec_t)); if (http_handle->write_operation.iov == NULL) @@ -1615,7 +1601,7 @@ globus_i_xio_http_write_chunk( * In chunked mode, we will adjust the nbytes to remove the size of the * chunk framing, otherwise we will finish the write with the value passed * to this callback. - * + * * @param op * Operation associated with the write. * @param result @@ -1624,8 +1610,6 @@ globus_i_xio_http_write_chunk( * Number of bytes written by the transport. * @param user_arg * Void pointer to a globus_i_xio_http_handle_t. - * - * @return void */ void globus_i_xio_http_write_callback( @@ -1692,10 +1676,10 @@ globus_i_xio_http_write_callback( globus_object_t * err; err = globus_error_get(result); - + if(http_handle->reopen_in_progress) { - http_handle->pending_error = + http_handle->pending_error = GlobusXIOHTTPErrorObjPersistentConnectionDropped(err); } else @@ -1851,19 +1835,9 @@ globus_result_t globus_i_xio_http_close_internal( globus_i_xio_http_handle_t * http_handle) { - globus_i_xio_http_header_info_t * headers; globus_result_t result; globus_reltime_t delay; - if (http_handle->target_info.is_client) - { - headers = &http_handle->request_info.headers; - } - else - { - headers = &http_handle->response_info.headers; - } - http_handle->send_state = GLOBUS_XIO_HTTP_CLOSE; if (http_handle->target_info.is_client && @@ -1900,6 +1874,8 @@ globus_i_xio_http_close_internal( } /* globus_i_xio_http_close_internal() */ +#endif /* GLOBUS_DONT_DOCUMENT_INTERNAL */ + void globus_i_xio_http_close_callback( globus_xio_operation_t op, diff --git a/xio/src/builtins/mode_e/globus_xio_mode_e_driver.c b/xio/src/builtins/mode_e/globus_xio_mode_e_driver.c index 7f4baa419e..a8ce5994f5 100644 --- a/xio/src/builtins/mode_e/globus_xio_mode_e_driver.c +++ b/xio/src/builtins/mode_e/globus_xio_mode_e_driver.c @@ -78,7 +78,7 @@ typedef struct globus_xio_stack_t stack; int max_connection_count; int eod_count; - globus_xio_attr_t xio_attr; + globus_xio_attr_t xio_attr; globus_bool_t send_eod; globus_bool_t manual_eodc; globus_off_t offset; @@ -89,7 +89,7 @@ static globus_l_xio_mode_e_attr_t globus_l_xio_mode_e_attr_default = { GLOBUS_NULL, 1, - 0, + 0, GLOBUS_NULL, GLOBUS_FALSE, GLOBUS_FALSE, @@ -109,7 +109,7 @@ typedef struct globus_xio_server_t server; globus_xio_handle_t accepted_handle; globus_l_xio_mode_e_attr_t * attr; - globus_i_xio_mode_e_state_t state; + globus_i_xio_mode_e_state_t state; globus_memory_t requestor_memory; globus_memory_t header_memory; char * cs; @@ -137,7 +137,7 @@ typedef struct globus_object_t * error; } globus_l_xio_mode_e_handle_t; -typedef struct +typedef struct { globus_xio_operation_t op; globus_xio_iovec_t * iovec; @@ -154,11 +154,11 @@ typedef struct globus_i_xio_mode_e_requestor_t * requestor; int iovec_index; globus_size_t iovec_index_len; - globus_off_t outstanding_data_len; - globus_off_t outstanding_data_offset; + globus_off_t outstanding_data_len; + globus_off_t outstanding_data_offset; globus_bool_t eod; globus_bool_t close; -} globus_l_xio_mode_e_connection_handle_t; +} globus_l_xio_mode_e_connection_handle_t; static int @@ -302,18 +302,18 @@ globus_l_xio_mode_e_activate(void) static int globus_l_xio_mode_e_deactivate(void) -{ +{ int rc; GlobusXIOName(globus_l_xio_mode_e_deactivate); - + GlobusXIOModeEDebugEnter(); GlobusXIOUnRegisterDriver(mode_e); rc = globus_module_deactivate(GLOBUS_XIO_MODULE); if (rc != GLOBUS_SUCCESS) - { + { goto error_deactivate; } - + GlobusXIOModeEDebugExit(); GlobusDebugDestroy(GLOBUS_XIO_MODE_E); return GLOBUS_SUCCESS; @@ -336,7 +336,7 @@ globus_l_xio_mode_e_hashtable_offset_hash( int i; globus_size_t size; GlobusXIOName(globus_l_xio_mode_e_hashtable_offset_hash); - + GlobusXIOModeEDebugEnter(); key = (char *) offsetp; size = sizeof(globus_off_t); @@ -347,8 +347,8 @@ globus_l_xio_mode_e_hashtable_offset_hash( { h ^= g >> 24; h ^= g; - } - } + } + } GlobusXIOModeEDebugExit(); return h % limit; } @@ -438,7 +438,7 @@ globus_i_xio_mode_e_header_encode( GlobusXIOModeEDebugEnter(); offset_size = sizeof(globus_off_t); /* - * buf[0] contains most significant byte and buf[7] contains the + * buf[0] contains most significant byte and buf[7] contains the * least significant byte */ globus_assert(GLOBUS_XIO_MODE_E_MAX_OFFSET_SIZE >= offset_size); @@ -470,12 +470,12 @@ globus_i_xio_mode_e_header_decode( GlobusXIOModeEDebugEnter(); offset_size = sizeof(globus_off_t); for (i = GLOBUS_XIO_MODE_E_MAX_OFFSET_SIZE; i > offset_size; i--) - { - /* + { + /* * if offset_size < MAX_OFFSET_SIZE; then the most significant * (MAX_OFFSET_SIZE - offset_size) number of bytes should be zero; * otherwise there is an overflow - */ + */ if (buf[GLOBUS_XIO_MODE_E_MAX_OFFSET_SIZE - i] != 0) { result = GlobusXIOModeEHeaderError("offset overflow"); @@ -485,7 +485,7 @@ globus_i_xio_mode_e_header_decode( if (offset_size > GLOBUS_XIO_MODE_E_MAX_OFFSET_SIZE) { offset_size = GLOBUS_XIO_MODE_E_MAX_OFFSET_SIZE; - } + } for (i = 0; i < offset_size; i++) { x += ((globus_off_t) buf[i]) << (offset_size - i - 1) * 8; @@ -503,7 +503,7 @@ globus_i_xio_mode_e_header_decode( /* * allocate the memory for and initialize an internal handle */ -static +static globus_result_t globus_l_xio_mode_e_handle_create( globus_l_xio_mode_e_handle_t ** out_handle, @@ -526,7 +526,7 @@ globus_l_xio_mode_e_handle_create( memset(handle, 0, sizeof(globus_l_xio_mode_e_handle_t)); if (!attr) { - result = globus_l_xio_mode_e_attr_init((void**)(void*)&handle->attr); + result = globus_l_xio_mode_e_attr_init((void**)(void*)&handle->attr); if (result != GLOBUS_SUCCESS) { result = GlobusXIOErrorWrapFailed( @@ -577,23 +577,23 @@ globus_l_xio_mode_e_handle_create( if (result != GLOBUS_SUCCESS) { goto error_eod_q_init; - } + } result = globus_fifo_init(&handle->io_q); if (result != GLOBUS_SUCCESS) { goto error_io_q_init; } - node_size = sizeof(globus_i_xio_mode_e_requestor_t); - node_count = GLOBUS_XIO_MODE_E_IO_Q_SIZE; + node_size = sizeof(globus_i_xio_mode_e_requestor_t); + node_count = GLOBUS_XIO_MODE_E_IO_Q_SIZE; globus_memory_init(&handle->requestor_memory, node_size, node_count); node_size = sizeof(globus_l_xio_mode_e_header_t); - node_count = GLOBUS_XIO_MODE_E_HEADER_COUNT; + node_count = GLOBUS_XIO_MODE_E_HEADER_COUNT; globus_memory_init(&handle->header_memory, node_size, node_count); globus_mutex_init(&handle->mutex, NULL); - /* + /* * As I did memset(handle, 0) in the beginning, here i initialize only the * fields that has to initialized with a non-zero value - */ + */ handle->eod_count = -1; handle->ref_count = 1; *out_handle = handle; @@ -608,7 +608,7 @@ globus_l_xio_mode_e_handle_create( error_push_driver: if (!handle->attr->stack) { - globus_xio_stack_destroy(handle->stack); + globus_xio_stack_destroy(handle->stack); } error_stack_init: if (!handle->attr->stack) @@ -635,7 +635,7 @@ globus_l_xio_mode_e_server_init( globus_l_xio_mode_e_handle_t * handle; globus_l_xio_mode_e_attr_t * attr; globus_xio_contact_t my_contact_info; - char * cs; + char * cs; globus_result_t result; GlobusXIOName(globus_l_xio_mode_e_server_init); @@ -645,7 +645,7 @@ globus_l_xio_mode_e_server_init( if (result != GLOBUS_SUCCESS) { goto error_handle_create; - } + } if (!attr) { attr = handle->attr; @@ -657,19 +657,19 @@ globus_l_xio_mode_e_server_init( { goto error_attr_init; } - } + } result = globus_xio_server_create( &handle->server, attr->xio_attr, handle->stack); if (result != GLOBUS_SUCCESS) { goto error_server_create; - } + } result = globus_xio_server_get_contact_string(handle->server, &cs); if (result != GLOBUS_SUCCESS) { goto error_get_cs; } - result = globus_xio_contact_parse(&my_contact_info, cs); + result = globus_xio_contact_parse(&my_contact_info, cs); if (result != GLOBUS_SUCCESS) { goto error_parse_cs; @@ -692,7 +692,7 @@ globus_l_xio_mode_e_server_init( globus_l_xio_mode_e_handle_destroy(handle); error_handle_create: GlobusXIOModeEDebugExitWithError(); - return result; + return result; } @@ -703,12 +703,12 @@ globus_l_xio_mode_e_save_error( globus_result_t result) { GlobusXIOName(globus_l_xio_mode_e_save_error); - + GlobusXIOModeEDebugEnter(); handle->state = GLOBUS_XIO_MODE_E_ERROR; if (handle->error == GLOBUS_NULL) { - handle->error = globus_object_copy(globus_error_peek(result)); + handle->error = globus_object_copy(globus_error_peek(result)); } GlobusXIOModeEDebugExit(); } @@ -722,14 +722,14 @@ globus_l_xio_mode_e_server_accept_cb( globus_result_t result, void * user_arg) { - globus_l_xio_mode_e_handle_t * handle; + globus_l_xio_mode_e_handle_t * handle; globus_xio_operation_t op; GlobusXIOName(globus_l_xio_mode_e_server_accept_cb); GlobusXIOModeEDebugEnter(); handle = (globus_l_xio_mode_e_handle_t *)user_arg; globus_xio_operation_disable_cancel(handle->outstanding_op); - globus_mutex_lock(&handle->mutex); + globus_mutex_lock(&handle->mutex); op = handle->outstanding_op; if (result == GLOBUS_SUCCESS) { @@ -740,13 +740,13 @@ globus_l_xio_mode_e_server_accept_cb( { goto error_accept; } - globus_mutex_unlock(&handle->mutex); + globus_mutex_unlock(&handle->mutex); globus_xio_driver_finished_accept(op, handle, result); GlobusXIOModeEDebugExit(); return; error_accept: - globus_mutex_unlock(&handle->mutex); + globus_mutex_unlock(&handle->mutex); globus_xio_driver_finished_accept(op, handle, result); GlobusXIOModeEDebugExitWithError(); return; @@ -754,9 +754,9 @@ globus_l_xio_mode_e_server_accept_cb( /* - * At any instance, there would be a globus_xio_server_register_accept + * At any instance, there would be a globus_xio_server_register_accept * outstanding to accept any new incoming connection. For the very first - * register accept (done in globus_l_xio_mode_e_server_accept), + * register accept (done in globus_l_xio_mode_e_server_accept), * globus_l_xio_mode_e_server_accept_cb is used. For the subsequent * register accpets, this function is used */ @@ -768,39 +768,39 @@ globus_i_xio_mode_e_server_accept_cb( globus_result_t result, void * user_arg) { - globus_l_xio_mode_e_handle_t * handle; + globus_l_xio_mode_e_handle_t * handle; globus_result_t res; GlobusXIOName(globus_i_xio_mode_e_server_accept_cb); GlobusXIOModeEDebugEnter(); handle = (globus_l_xio_mode_e_handle_t *)user_arg; - globus_mutex_lock(&handle->mutex); + globus_mutex_lock(&handle->mutex); if (result != GLOBUS_SUCCESS) - { + { res = result; goto error_accept; - } + } switch (handle->state) { case GLOBUS_XIO_MODE_E_OPEN: { res = globus_xio_register_open( - xio_handle, - NULL, + xio_handle, + NULL, handle->attr->xio_attr, globus_i_xio_mode_e_server_open_cb, handle); if (res != GLOBUS_SUCCESS) { globus_xio_register_close( - xio_handle, - NULL, + xio_handle, + NULL, NULL, NULL); goto error_register_open; } res = globus_xio_server_register_accept( - server, + server, globus_i_xio_mode_e_server_accept_cb, handle); if (res != GLOBUS_SUCCESS) @@ -812,8 +812,8 @@ globus_i_xio_mode_e_server_accept_cb( default: res = GlobusXIOErrorInvalidState(handle->state); goto error_invalid_state; - } - globus_mutex_unlock(&handle->mutex); + } + globus_mutex_unlock(&handle->mutex); GlobusXIOModeEDebugExit(); return; @@ -822,7 +822,7 @@ globus_i_xio_mode_e_server_accept_cb( error_invalid_state: error_accept: globus_l_xio_mode_e_save_error(handle, res); - globus_mutex_unlock(&handle->mutex); + globus_mutex_unlock(&handle->mutex); GlobusXIOModeEDebugExitWithError(); return; } @@ -840,8 +840,8 @@ globus_i_xio_mode_e_cancel_operations( GlobusXIOName(globus_i_xio_mode_e_cancel_operations); GlobusXIOModeEDebugEnter(); - /* - * If user cancels close on the client side, both register_write (eods) + /* + * If user cancels close on the client side, both register_write (eods) * and register_close can be outstanding */ mask = GLOBUS_XIO_CANCEL_WRITE; @@ -851,9 +851,9 @@ globus_i_xio_mode_e_cancel_operations( globus_list_remove(&handle->eod_list, handle->eod_list); result = globus_xio_handle_cancel_operations(xio_handle, mask); if (result != GLOBUS_SUCCESS) - { + { goto error; - } + } } mask = GLOBUS_XIO_CANCEL_CLOSE; while (!globus_list_empty(handle->close_list)) @@ -862,9 +862,9 @@ globus_i_xio_mode_e_cancel_operations( globus_list_remove(&handle->close_list, handle->close_list); result = globus_xio_handle_cancel_operations(xio_handle, mask); if (result != GLOBUS_SUCCESS) - { + { goto error; - } + } } GlobusXIOModeEDebugExit(); return GLOBUS_SUCCESS; @@ -924,11 +924,11 @@ globus_l_xio_mode_e_cancel_cb( if (globus_fifo_empty(&handle->io_q) || !globus_fifo_remove(&handle->io_q, requestor)) { - /* - * requestor->xio_handle would be NULL if cancel was called - * after enable_cancel is called in read/write and before the - * lock is required in read/write. In that case an xio - * operation would not have been initiated. So I don't do + /* + * requestor->xio_handle would be NULL if cancel was called + * after enable_cancel is called in read/write and before the + * lock is required in read/write. In that case an xio + * operation would not have been initiated. So I don't do * anything here. */ if (requestor->xio_handle) @@ -969,7 +969,7 @@ globus_l_xio_mode_e_cancel_cb( default: result = GlobusXIOErrorInvalidState(handle->state); goto error; - + } globus_mutex_unlock(&handle->mutex); if (finish) @@ -1025,13 +1025,13 @@ globus_l_xio_mode_e_server_accept( goto error_operation_canceled; } result = globus_xio_server_register_accept( - handle->server, + handle->server, globus_l_xio_mode_e_server_accept_cb, handle); if (result != GLOBUS_SUCCESS) { goto error_register_accept; - } + } globus_mutex_unlock(&handle->mutex); GlobusXIOModeEDebugExit(); return GLOBUS_SUCCESS; @@ -1054,19 +1054,19 @@ globus_l_xio_mode_e_server_destroy( { globus_l_xio_mode_e_handle_t * handle; GlobusXIOName(globus_l_xio_mode_e_server_destroy); - + GlobusXIOModeEDebugEnter(); handle = (globus_l_xio_mode_e_handle_t *)driver_server; - globus_mutex_lock(&handle->mutex); + globus_mutex_lock(&handle->mutex); --handle->ref_count; if (handle->ref_count == 0) { - globus_mutex_unlock(&handle->mutex); + globus_mutex_unlock(&handle->mutex); globus_l_xio_mode_e_handle_destroy(handle); } else { - globus_mutex_unlock(&handle->mutex); + globus_mutex_unlock(&handle->mutex); } GlobusXIOModeEDebugExit(); return GLOBUS_SUCCESS; @@ -1114,7 +1114,7 @@ globus_l_xio_mode_e_link_destroy( --handle->ref_count; if (handle->ref_count == 0) { - globus_mutex_unlock(&handle->mutex); + globus_mutex_unlock(&handle->mutex); globus_l_xio_mode_e_handle_destroy(handle); } else @@ -1148,7 +1148,7 @@ static globus_result_t globus_l_xio_mode_e_process_header( globus_l_xio_mode_e_header_t * header, - globus_l_xio_mode_e_connection_handle_t * + globus_l_xio_mode_e_connection_handle_t * connection_handle) { globus_result_t result; @@ -1161,7 +1161,7 @@ globus_l_xio_mode_e_process_header( } if (header->descriptor & GLOBUS_XIO_MODE_E_DATA_DESCRIPTOR_CLOSE) { - /* sending CLOSE before EOD is a protocol violation */ + /* sending CLOSE before EOD is a protocol violation */ globus_assert(connection_handle->eod); connection_handle->close = GLOBUS_TRUE; } @@ -1216,15 +1216,15 @@ globus_l_xio_mode_e_process_outstanding_data( if (!globus_fifo_empty(&handle->io_q)) { requestor = (globus_i_xio_mode_e_requestor_t *) - globus_fifo_dequeue(&handle->io_q); + globus_fifo_dequeue(&handle->io_q); if (handle->attr->offset_reads) { /* wait_for of this requestor should be zero */ - requestor->dd->offset = + requestor->dd->offset = connection_handle->outstanding_data_offset; globus_hashtable_insert( - &handle->offset_ht, - (void *) &connection_handle->outstanding_data_offset, + &handle->offset_ht, + (void *) &connection_handle->outstanding_data_offset, (void *) connection_handle); } else @@ -1265,7 +1265,7 @@ globus_l_xio_mode_e_process_eod( NULL, globus_l_xio_mode_e_close_cb, handle); - globus_list_remove(&handle->connection_list, + globus_list_remove(&handle->connection_list, globus_list_search(handle->connection_list, connection_handle)); globus_free(connection_handle); } @@ -1320,7 +1320,7 @@ globus_l_xio_mode_e_read_header_cb( offset = connection_handle->outstanding_data_offset; globus_mutex_lock(&handle->mutex); if (result == GLOBUS_SUCCESS) - { + { header = (globus_l_xio_mode_e_header_t *) buffer; result = globus_l_xio_mode_e_process_header(header, connection_handle); if (result != GLOBUS_SUCCESS) @@ -1337,16 +1337,16 @@ globus_l_xio_mode_e_read_header_cb( * If EOF is set in header, data len will be zero. If EOD alone is * set, there can be data present. If EOD is set on header and also * there is data present, i process EOD in read_cb. If I process it - * here and if it so happens that eods_received == eod_count, + * here and if it so happens that eods_received == eod_count, * process_eod will return true (eof) and the state would be set to * GLOBUS_XIO_MODE_E_EOF_RECEIVED or DELIVERED and there would be no - * way for the user to read the data that had EOD set on the header. + * way for the user to read the data that had EOD set on the header. */ else if (connection_handle->eod) { eof = globus_l_xio_mode_e_process_eod( connection_handle, &requestor_q); - if (eof) + if (eof) { if (globus_fifo_empty(&requestor_q)) { @@ -1357,12 +1357,12 @@ globus_l_xio_mode_e_read_header_cb( } else { - requestor = (globus_i_xio_mode_e_requestor_t *) + requestor = (globus_i_xio_mode_e_requestor_t *) globus_fifo_peek(&requestor_q); globus_xio_driver_set_eof_received(requestor->op); /* * If this part of the code is executed, finished_read - * happen only in if (finish) {} block below. The + * happen only in if (finish) {} block below. The * finished_read in if (requestor) {} block below should * happen only if process_outstanding_data called above * returns a non NULL requestor value. Thats why requestor @@ -1388,13 +1388,13 @@ globus_l_xio_mode_e_read_header_cb( } } else if(globus_error_match( - globus_error_peek(result), - GLOBUS_XIO_MODULE, + globus_error_peek(result), + GLOBUS_XIO_MODULE, GLOBUS_XIO_ERROR_CANCELED)) { - /* - * if there are outstanding header reads and user calls close, the - * header reads are canceled in close + /* + * if there are outstanding header reads and user calls close, the + * header reads are canceled in close */ if (!handle->close_canceled) { @@ -1445,12 +1445,12 @@ globus_l_xio_mode_e_read_header_cb( op = requestor->op; /* * Earlier I had this push_node inside process_eod but then i moved - * here to avoid a race. process_eod is called with lock held and + * here to avoid a race. process_eod is called with lock held and * when lock is released above, sometimes cancel_cb gets called and * it tries to access the requestor which is no more. To get rid * of that, I moved the push_node to here after disable_cancel. - * Since requestor is removed from the handle->io_q and put in - * requestor_q by process_eod function, cancel_cb will not do + * Since requestor is removed from the handle->io_q and put in + * requestor_q by process_eod function, cancel_cb will not do * finished_read on requestor->op. Similar thing is done in read_cb * too */ @@ -1460,7 +1460,7 @@ globus_l_xio_mode_e_read_header_cb( NULL, GLOBUS_XIO_DD_SET_OFFSET, offset); - res = GlobusXIOErrorEOF(); + res = GlobusXIOErrorEOF(); globus_xio_driver_finished_read(op, res, 0); } } @@ -1531,7 +1531,7 @@ globus_l_xio_mode_e_open_cb( globus_mutex_unlock(&handle->mutex); globus_xio_driver_finished_open(handle, op, res); GlobusXIOModeEDebugExit(); - return; + return; error_connection_handle: globus_xio_register_close(xio_handle, NULL, NULL, NULL); @@ -1540,7 +1540,7 @@ globus_l_xio_mode_e_open_cb( globus_xio_attr_destroy(handle->attr->xio_attr); if (--handle->ref_count == 0) { - globus_mutex_unlock(&handle->mutex); + globus_mutex_unlock(&handle->mutex); globus_l_xio_mode_e_handle_destroy(handle); } else @@ -1550,7 +1550,7 @@ globus_l_xio_mode_e_open_cb( } globus_xio_driver_finished_open(handle, op, res); GlobusXIOModeEDebugExitWithError(); - return; + return; } @@ -1573,12 +1573,12 @@ globus_i_xio_mode_e_open_cb( handle = (globus_l_xio_mode_e_handle_t *)user_arg; globus_mutex_lock(&handle->mutex); if (result == GLOBUS_SUCCESS) - { + { globus_size_t connection_handle_size; - connection_handle_size = + connection_handle_size = sizeof(globus_l_xio_mode_e_connection_handle_t); connection_handle = (globus_l_xio_mode_e_connection_handle_t *) - globus_malloc(connection_handle_size); + globus_malloc(connection_handle_size); if (!connection_handle) { res = GlobusXIOErrorMemory("connection_handle"); @@ -1614,7 +1614,7 @@ globus_i_xio_mode_e_open_cb( } globus_mutex_unlock(&handle->mutex); GlobusXIOModeEDebugExit(); - return; + return; error_register_write: error_connection_handle: @@ -1634,7 +1634,7 @@ globus_i_xio_mode_e_open_cb( globus_xio_driver_finished_write(write_op, res, 0); } GlobusXIOModeEDebugExitWithError(); - return; + return; } @@ -1717,7 +1717,7 @@ globus_l_xio_mode_e_server_open_cb( error: if (--handle->ref_count == 0) { - globus_mutex_unlock(&handle->mutex); + globus_mutex_unlock(&handle->mutex); globus_l_xio_mode_e_handle_destroy(handle); } else @@ -1733,15 +1733,15 @@ globus_l_xio_mode_e_server_open_cb( /* called locked (if handle->state == GLOBUS_XIO_MODE_E_OPEN) */ static -globus_result_t +globus_result_t globus_l_xio_mode_e_open_new_stream( globus_l_xio_mode_e_handle_t * handle, globus_xio_callback_t open_cb) { - globus_xio_handle_t xio_handle; + globus_xio_handle_t xio_handle; globus_l_xio_mode_e_attr_t * attr; - globus_i_xio_mode_e_requestor_t * requestor; - globus_xio_operation_t op; + globus_i_xio_mode_e_requestor_t * requestor = GLOBUS_NULL; + globus_xio_operation_t op = GLOBUS_XIO_OPERATION_TYPE_NONE; globus_result_t result; GlobusXIOName(globus_l_xio_mode_e_open_new_stream); @@ -1781,8 +1781,8 @@ globus_l_xio_mode_e_open_new_stream( } } result = globus_xio_register_open( - xio_handle, - handle->cs, + xio_handle, + handle->cs, handle->attr->xio_attr, open_cb, handle); @@ -1833,10 +1833,10 @@ globus_l_xio_mode_e_server_open( GlobusXIOModeEDebugEnter(); globus_mutex_lock(&handle->mutex); handle->outstanding_op = op; - if (handle->attr->offset_reads) + if (handle->attr->offset_reads) { result = globus_hashtable_init( - &handle->offset_ht, + &handle->offset_ht, GLOBUS_XIO_MODE_E_OFFSET_HT_SIZE, globus_l_xio_mode_e_hashtable_offset_hash, globus_l_xio_mode_e_hashtable_offset_keyeq); @@ -1953,7 +1953,7 @@ globus_l_xio_mode_e_open( if (result != GLOBUS_SUCCESS) { globus_l_xio_mode_e_save_error(handle, result); - goto error_server_open; + goto error_server_open; } } GlobusXIOModeEDebugExit(); @@ -1961,7 +1961,7 @@ globus_l_xio_mode_e_open( error_open_new_stream: error_contact_info_to_string: - globus_l_xio_mode_e_handle_destroy(handle); + globus_l_xio_mode_e_handle_destroy(handle); error_handle_create: error_server_open: GlobusXIOModeEDebugExitWithError(); @@ -2011,7 +2011,7 @@ globus_l_xio_mode_e_read_cb( void * user_arg) { globus_result_t res = result; - globus_l_xio_mode_e_connection_handle_t * + globus_l_xio_mode_e_connection_handle_t * connection_handle; globus_l_xio_mode_e_handle_t * handle; globus_bool_t eof; @@ -2025,20 +2025,20 @@ globus_l_xio_mode_e_read_cb( connection_handle = (globus_l_xio_mode_e_connection_handle_t *) user_arg; op = connection_handle->requestor->op; globus_xio_operation_disable_cancel(op); - handle = connection_handle->mode_e_handle; + handle = connection_handle->mode_e_handle; globus_fifo_init(&requestor_q); offset = connection_handle->outstanding_data_offset; if (connection_handle->iovec_index != -1) { - iovec[connection_handle->iovec_index].iov_len = + iovec[connection_handle->iovec_index].iov_len = connection_handle->iovec_index_len; connection_handle->iovec_index = -1; } - globus_mutex_lock(&handle->mutex); + globus_mutex_lock(&handle->mutex); globus_memory_push_node( &handle->requestor_memory, (void*)connection_handle->requestor); if (result == GLOBUS_SUCCESS) - { + { connection_handle->outstanding_data_len -= nbytes; if (connection_handle->outstanding_data_len > 0) { @@ -2046,7 +2046,7 @@ globus_l_xio_mode_e_read_cb( requestor = globus_l_xio_mode_e_process_outstanding_data( connection_handle); } - else if (connection_handle->eod) + else if (connection_handle->eod) { eof = globus_l_xio_mode_e_process_eod( connection_handle, &requestor_q); @@ -2080,7 +2080,7 @@ globus_l_xio_mode_e_read_cb( } goto error; } - globus_mutex_unlock(&handle->mutex); + globus_mutex_unlock(&handle->mutex); globus_xio_driver_data_descriptor_cntl( op, NULL, @@ -2109,7 +2109,7 @@ globus_l_xio_mode_e_read_cb( error: globus_l_xio_mode_e_save_error(handle, result); - globus_mutex_unlock(&handle->mutex); + globus_mutex_unlock(&handle->mutex); while (!globus_fifo_empty(&requestor_q)) { requestor = (globus_i_xio_mode_e_requestor_t*) @@ -2131,7 +2131,7 @@ globus_i_xio_mode_e_register_read( globus_l_xio_mode_e_connection_handle_t * connection_handle) { - globus_size_t iovec_len; + globus_size_t iovec_len; globus_result_t result; globus_xio_iovec_t * iovec; int iovec_count; @@ -2141,14 +2141,14 @@ globus_i_xio_mode_e_register_read( iovec = connection_handle->requestor->iovec; iovec_count = connection_handle->requestor->iovec_count; GlobusXIOUtilIovTotalLength(iovec_len, iovec, iovec_count); - /* - * Upto iovec_len amount of data would be read from the channel. If + /* + * Upto iovec_len amount of data would be read from the channel. If * iovec_len > outstanding_data_len, this read might possibly get the next * header that has arrived on this channel. So I modify iovec (and later * restore in the read_cb) such that the amount of data read would be * min(outstanding_data_len, iovec_len) */ - if (connection_handle->outstanding_data_len < iovec_len) + if (connection_handle->outstanding_data_len < iovec_len) { globus_size_t size = 0; int i; @@ -2168,7 +2168,7 @@ globus_i_xio_mode_e_register_read( } result = globus_xio_register_readv( connection_handle->xio_handle, - (globus_xio_iovec_t*)iovec, + (globus_xio_iovec_t*)iovec, iovec_count, iovec_len, NULL, @@ -2176,7 +2176,7 @@ globus_i_xio_mode_e_register_read( connection_handle); GlobusXIOModeEDebugExit(); return result; -} +} /* called locked */ @@ -2187,7 +2187,7 @@ globus_l_xio_mode_e_reset_connections( { globus_l_xio_mode_e_connection_handle_t * connection_handle; - globus_result_t result; + globus_result_t result; GlobusXIOName(globus_l_xio_mode_e_reset_connections); GlobusXIOModeEDebugEnter(); handle->eod_count = -1; @@ -2278,17 +2278,17 @@ globus_l_xio_mode_e_read( case GLOBUS_XIO_MODE_E_EOF_RECEIVED: globus_xio_driver_set_eof_received(op); handle->state = GLOBUS_XIO_MODE_E_EOF_DELIVERED; - globus_memory_push_node( - &handle->requestor_memory, (void*)requestor); + globus_memory_push_node( + &handle->requestor_memory, (void*)requestor); result = GlobusXIOErrorEOF(); finish = GLOBUS_TRUE; break; case GLOBUS_XIO_MODE_E_EOF_DELIVERED: - if (globus_xio_driver_eof_received(op) || + if (globus_xio_driver_eof_received(op) || handle->connection_count == 0) { - globus_memory_push_node( - &handle->requestor_memory, (void*)requestor); + globus_memory_push_node( + &handle->requestor_memory, (void*)requestor); result = GlobusXIOErrorEOF(); finish = GLOBUS_TRUE; break; @@ -2296,7 +2296,7 @@ globus_l_xio_mode_e_read( else { globus_l_xio_mode_e_reset_connections(handle); - /* + /* * connection_q will be empty at this point. I let this * fall through to enqueue the request in the io_q */ @@ -2309,29 +2309,29 @@ globus_l_xio_mode_e_read( } else { - globus_l_xio_mode_e_connection_handle_t * + globus_l_xio_mode_e_connection_handle_t * connection_handle; if (wait_for == 0) { globus_memory_push_node( &handle->requestor_memory, (void*)requestor); - connection_handle = - (globus_l_xio_mode_e_connection_handle_t*) + connection_handle = + (globus_l_xio_mode_e_connection_handle_t*) globus_fifo_dequeue(&handle->connection_q); globus_hashtable_insert( - &handle->offset_ht, - (void *)&connection_handle->outstanding_data_offset, + &handle->offset_ht, + (void *)&connection_handle->outstanding_data_offset, (void *)connection_handle); dd->offset = connection_handle->outstanding_data_offset; result = GLOBUS_SUCCESS; finish = GLOBUS_TRUE; } - else + else { if (handle->attr->offset_reads) { - connection_handle = - (globus_l_xio_mode_e_connection_handle_t*) + connection_handle = + (globus_l_xio_mode_e_connection_handle_t*) globus_hashtable_remove( &handle->offset_ht, &dd->offset); if (!connection_handle) @@ -2342,8 +2342,8 @@ globus_l_xio_mode_e_read( } else { - connection_handle = - (globus_l_xio_mode_e_connection_handle_t*) + connection_handle = + (globus_l_xio_mode_e_connection_handle_t*) globus_fifo_dequeue(&handle->connection_q); } connection_handle->requestor = requestor; @@ -2428,8 +2428,8 @@ globus_l_xio_mode_e_write_cb( requestor_result = globus_i_xio_mode_e_register_write( connection_handle); if (requestor_result != GLOBUS_SUCCESS) - { - requestor_op = requestor->op; + { + requestor_op = requestor->op; requestor_offset = connection_handle->outstanding_data_offset; finish_next = GLOBUS_TRUE; globus_memory_push_node( @@ -2442,10 +2442,10 @@ globus_l_xio_mode_e_write_cb( if (handle->state == GLOBUS_XIO_MODE_E_SENDING_EOD) { globus_byte_t descriptor; - /* + /* * I'll get this cb with eod_sent == TRUE for one connection alone * and I send EOF (if need be) on this connection alone. If I don't - * need to send EOF and eods_sent == connection_count, I need to + * need to send EOF and eods_sent == connection_count, I need to * finish the write (that had SEND_EOD set on dd) */ if (!connection_handle->eod) @@ -2458,7 +2458,7 @@ globus_l_xio_mode_e_write_cb( goto error_register_eod; } } - else + else { connection_handle->eod = GLOBUS_FALSE; if (handle->eod_count > -1) @@ -2558,13 +2558,13 @@ globus_l_xio_mode_e_write_header_cb( globus_mutex_lock(&handle->mutex); if (result == GLOBUS_SUCCESS) { - /* + /* * if handle->eod_count != -1, then register_eod will be called (either - * in here or in write_cb) to send EOF and eods_sent will be + * in here or in write_cb) to send EOF and eods_sent will be * incremented in eod_cb */ if (header->descriptor & GLOBUS_XIO_MODE_E_DATA_DESCRIPTOR_EOD && - handle->eod_count == -1) + handle->eod_count == -1) { ++handle->eods_sent; } @@ -2590,7 +2590,7 @@ globus_l_xio_mode_e_write_header_cb( else if (handle->eod_count > -1) { globus_byte_t descriptor; - /* + /* * handle->iovec can be NULL only when the user sets SEND_EOD * on the dd. So I just wrote EOD on this channel and now i check * to see if i need to send EOF @@ -2603,13 +2603,13 @@ globus_l_xio_mode_e_write_header_cb( goto error; } } - else + else { globus_fifo_enqueue(&handle->connection_q, connection_handle); if (handle->eods_sent == handle->connection_count) { - /* - * user is allowed to do a write with buffer = NULL and + /* + * user is allowed to do a write with buffer = NULL and * SEND_EOD set on dd */ handle->state = GLOBUS_XIO_MODE_E_OPEN; @@ -2617,17 +2617,17 @@ globus_l_xio_mode_e_write_header_cb( handle->attr->eod_count = -1; handle->offset = 0; finish = GLOBUS_TRUE; - /* + /* * handle->eod_offset also has same value. if i have to finish * in eod_cb, connection_handle->outstanding_data_offset cant - * be used coz i don't know which connection_handle is + * be used coz i don't know which connection_handle is * associated with the user_write (that had SEND_EOD set). */ offset = connection_handle->outstanding_data_offset; /* the op is stored in handle->outstanding_op too */ op = connection_handle->requestor->op; globus_memory_push_node( - &handle->requestor_memory, + &handle->requestor_memory, (void*)connection_handle->requestor); } } @@ -2668,7 +2668,7 @@ globus_l_xio_mode_e_write_header_cb( static globus_result_t globus_i_xio_mode_e_register_write( - globus_l_xio_mode_e_connection_handle_t * + globus_l_xio_mode_e_connection_handle_t * connection_handle) { globus_l_xio_mode_e_handle_t * handle; @@ -2686,8 +2686,8 @@ globus_i_xio_mode_e_register_write( header_size = sizeof(globus_l_xio_mode_e_header_t); memset(header, 0, header_size); GlobusXIOUtilIovTotalLength( - size, - connection_handle->requestor->iovec, + size, + connection_handle->requestor->iovec, connection_handle->requestor->iovec_count); globus_i_xio_mode_e_header_encode(header->count, size); result = globus_xio_driver_data_descriptor_cntl( @@ -2699,7 +2699,7 @@ globus_i_xio_mode_e_register_write( { offset = handle->offset; } - if (handle->state == GLOBUS_XIO_MODE_E_SENDING_EOD && + if (handle->state == GLOBUS_XIO_MODE_E_SENDING_EOD && globus_fifo_empty(&handle->io_q)) { header->descriptor = GLOBUS_XIO_MODE_E_DATA_DESCRIPTOR_EOD; @@ -2713,8 +2713,8 @@ globus_i_xio_mode_e_register_write( handle->offset = offset; } result = globus_xio_register_write( - connection_handle->xio_handle, - (globus_byte_t*)header, + connection_handle->xio_handle, + (globus_byte_t*)header, header_size, header_size, GLOBUS_NULL, @@ -2723,7 +2723,7 @@ globus_i_xio_mode_e_register_write( if (result != GLOBUS_SUCCESS) { goto error; - } + } if (header->descriptor & GLOBUS_XIO_MODE_E_DATA_DESCRIPTOR_EOD) { connection_handle->eod = GLOBUS_TRUE; @@ -2753,10 +2753,10 @@ globus_l_xio_mode_e_write( GlobusXIOModeEDebugEnter(); handle = (globus_l_xio_mode_e_handle_t *) driver_specific_handle; - /* + /* * Mode E is unidirectional. Server can only read and client can only write */ - globus_assert(handle->server == GLOBUS_NULL); + globus_assert(handle->server == GLOBUS_NULL); dd = (globus_l_xio_mode_e_attr_t *) globus_xio_operation_get_data_descriptor(op, GLOBUS_FALSE); requestor = (globus_i_xio_mode_e_requestor_t *) @@ -2782,9 +2782,9 @@ globus_l_xio_mode_e_write( switch (handle->state) { case GLOBUS_XIO_MODE_E_OPEN: - /* + /* * I reset eods_sent here (and not right after i send all the eods) - * coz i use 'eods_sent == connection_count' in close to check if + * coz i use 'eods_sent == connection_count' in close to check if * eods have been sent or not */ if (handle->eods_sent == handle->connection_count) @@ -2811,7 +2811,7 @@ globus_l_xio_mode_e_write( if (!globus_fifo_empty(&handle->connection_q)) { globus_l_xio_mode_e_connection_handle_t * - connection_handle; + connection_handle; connection_handle = (globus_l_xio_mode_e_connection_handle_t *) globus_fifo_dequeue(&handle->connection_q); connection_handle->requestor = requestor; @@ -2827,7 +2827,7 @@ globus_l_xio_mode_e_write( descriptor = GLOBUS_XIO_MODE_E_DATA_DESCRIPTOR_EOD; while (!globus_fifo_empty(&handle->connection_q)) { - connection_handle = + connection_handle = (globus_l_xio_mode_e_connection_handle_t *) globus_fifo_dequeue(&handle->connection_q); globus_l_xio_mode_e_register_eod( @@ -2837,7 +2837,7 @@ globus_l_xio_mode_e_write( } else { - if (handle->connection_count < + if (handle->connection_count < handle->attr->max_connection_count) { result = globus_l_xio_mode_e_open_new_stream( @@ -2897,8 +2897,8 @@ globus_l_xio_mode_e_close_cb( goto error; } if(globus_error_match( - globus_error_peek(result), - GLOBUS_XIO_MODULE, + globus_error_peek(result), + GLOBUS_XIO_MODULE, GLOBUS_XIO_ERROR_CANCELED)) { ++handle->close_count; @@ -2914,7 +2914,7 @@ globus_l_xio_mode_e_close_cb( if (!globus_list_empty(handle->close_list)) { globus_list_remove( - &handle->close_list, + &handle->close_list, globus_list_search(handle->close_list, xio_handle)); } } @@ -2973,7 +2973,7 @@ globus_l_xio_mode_e_write_eod_cb( globus_l_xio_mode_e_connection_handle_t * connection_handle; globus_l_xio_mode_e_handle_t * handle; - globus_l_xio_mode_e_header_t * header; + globus_l_xio_mode_e_header_t * header; globus_xio_operation_t op; globus_off_t offset; globus_bool_t finish = GLOBUS_FALSE; @@ -2991,18 +2991,18 @@ globus_l_xio_mode_e_write_eod_cb( res = result; goto error; } - ++handle->eods_sent; - /* - * If CLOSE is set on header, then it implies that user has called - * close and I allow users to cancel close until all the channels are + ++handle->eods_sent; + /* + * If CLOSE is set on header, then it implies that user has called + * close and I allow users to cancel close until all the channels are * closed */ if (header->descriptor & GLOBUS_XIO_MODE_E_DATA_DESCRIPTOR_CLOSE) { /* I don't register_close, if user has canceled the close already */ if (!globus_error_match( - globus_error_peek(result), - GLOBUS_XIO_MODULE, + globus_error_peek(result), + GLOBUS_XIO_MODULE, GLOBUS_XIO_ERROR_CANCELED)) { res = globus_xio_register_close( @@ -3016,13 +3016,13 @@ globus_l_xio_mode_e_write_eod_cb( } globus_list_insert( &handle->close_list, connection_handle->xio_handle); - /* + /* * If it was canceled, then the xio_handle would have been removed * from the eod_list before the canceling the write eod. So I do - * not have to this removal in the else below. + * not have to this removal in the else below. */ globus_list_remove( - &handle->eod_list, + &handle->eod_list, globus_list_search( handle->eod_list, connection_handle->xio_handle)); } @@ -3039,10 +3039,10 @@ globus_l_xio_mode_e_write_eod_cb( } else { - /* + /* * getting here implies that register_eod (associated with this cb) is * called in response to the dd 'SEND_EOD' on write - */ + */ if (header->descriptor & GLOBUS_XIO_MODE_E_DATA_DESCRIPTOR_EOF) { handle->eof_sent = GLOBUS_TRUE; @@ -3059,17 +3059,17 @@ globus_l_xio_mode_e_write_eod_cb( finish = GLOBUS_TRUE; } if (!globus_error_match( - globus_error_peek(result), - GLOBUS_XIO_MODULE, + globus_error_peek(result), + GLOBUS_XIO_MODULE, GLOBUS_XIO_ERROR_CANCELED)) { globus_list_remove( - &handle->eod_list, + &handle->eod_list, globus_list_search( handle->eod_list, connection_handle->xio_handle)); } - - } + + } globus_memory_push_node(&handle->header_memory, (void*)header); globus_mutex_unlock(&handle->mutex); if (finish) @@ -3143,7 +3143,7 @@ globus_l_xio_mode_e_register_eod( return GLOBUS_SUCCESS; error: - globus_memory_push_node(&handle->header_memory, (void*)header); + globus_memory_push_node(&handle->header_memory, (void*)header); GlobusXIOModeEDebugExitWithError(); return result; } @@ -3161,7 +3161,7 @@ globus_l_xio_mode_e_close_connections( GlobusXIOName(globus_l_xio_mode_e_close_connections); GlobusXIOModeEDebugEnter(); - /* + /* * handle->connection_list contains all the connections whereas the q's * (connection_q, eod_q contain only those connections that are free (idle) */ @@ -3173,17 +3173,17 @@ globus_l_xio_mode_e_close_connections( globus_fifo_remove(&handle->connection_q, connection_handle); if (!idle_connection_handle) { - idle_connection_handle = + idle_connection_handle = (globus_l_xio_mode_e_connection_handle_t *) globus_fifo_remove(&handle->eod_q, connection_handle); - + } if (idle_connection_handle) { /* connection_handle and idle_connection_handle are same here */ globus_xio_register_close( - connection_handle->xio_handle, - NULL, + connection_handle->xio_handle, + NULL, globus_l_xio_mode_e_close_cb, connection_handle->mode_e_handle); globus_list_insert( @@ -3219,7 +3219,7 @@ globus_l_xio_mode_e_close( GlobusXIOModeEDebugEnter(); handle = (globus_l_xio_mode_e_handle_t *) driver_specific_handle; - attr = (globus_l_xio_mode_e_attr_t *) + attr = (globus_l_xio_mode_e_attr_t *) driver_attr ? driver_attr : handle->attr; requestor = (globus_i_xio_mode_e_requestor_t *) globus_memory_pop_node(&handle->requestor_memory); @@ -3244,7 +3244,7 @@ globus_l_xio_mode_e_close( descriptor = GLOBUS_XIO_MODE_E_DATA_DESCRIPTOR_CLOSE; handle->state = GLOBUS_XIO_MODE_E_CLOSING; - /* this implies eods are not sent yet */ + /* this implies eods are not sent yet */ if (handle->eods_sent != handle->connection_count) { descriptor |= GLOBUS_XIO_MODE_E_DATA_DESCRIPTOR_EOD; @@ -3308,7 +3308,7 @@ globus_l_xio_mode_e_close( globus_xio_driver_finished_close(op, GLOBUS_SUCCESS); } GlobusXIOModeEDebugExit(); - return GLOBUS_SUCCESS; + return GLOBUS_SUCCESS; error_register_eod: error_operation_canceled: @@ -3317,7 +3317,7 @@ globus_l_xio_mode_e_close( error_cancel_enable: globus_memory_push_node(&handle->requestor_memory, (void*)requestor); GlobusXIOModeEDebugExitWithError(); - return result; + return result; } @@ -3359,8 +3359,8 @@ globus_l_xio_mode_e_cntl( goto error; default: result = GlobusXIOErrorInvalidCommand(cmd); - goto error; - } + goto error; + } GlobusXIOModeEDebugExit(); return GLOBUS_SUCCESS; @@ -3383,14 +3383,14 @@ globus_l_xio_mode_e_attr_init( /* * create a mode_e attr structure and intialize its values */ - attr = (globus_l_xio_mode_e_attr_t *) + attr = (globus_l_xio_mode_e_attr_t *) globus_malloc(sizeof(globus_l_xio_mode_e_attr_t)); if(!attr) { result = GlobusXIOErrorMemory("attr"); goto error_attr; } - memcpy(attr, &globus_l_xio_mode_e_attr_default, + memcpy(attr, &globus_l_xio_mode_e_attr_default, sizeof(globus_l_xio_mode_e_attr_t)); *out_attr = attr; GlobusXIOModeEDebugExit(); @@ -3451,7 +3451,7 @@ globus_l_xio_mode_e_attr_cntl( } case GLOBUS_XIO_MODE_E_SET_MANUAL_EODC: attr->manual_eodc = va_arg(ap, globus_bool_t); - break; + break; case GLOBUS_XIO_MODE_E_GET_MANUAL_EODC: { globus_bool_t * manual_eodc_out = va_arg(ap, globus_bool_t*); @@ -3496,11 +3496,11 @@ globus_l_xio_mode_e_attr_cntl( default: result = GlobusXIOErrorInvalidCommand(cmd); goto error; - } + } GlobusXIOModeEDebugExit(); return GLOBUS_SUCCESS; -error: +error: GlobusXIOModeEDebugExitWithError(); return result; } @@ -3518,7 +3518,7 @@ globus_l_xio_mode_e_attr_copy( GlobusXIOName(globus_l_xio_mode_e_attr_copy); GlobusXIOModeEDebugEnter(); - dst_attr = (globus_l_xio_mode_e_attr_t *) + dst_attr = (globus_l_xio_mode_e_attr_t *) globus_malloc(sizeof(globus_l_xio_mode_e_attr_t)); if(!dst_attr) { @@ -3526,7 +3526,7 @@ globus_l_xio_mode_e_attr_copy( goto error_dst_attr; } src_attr = (globus_l_xio_mode_e_attr_t *) src; - memcpy(dst_attr, src_attr, sizeof(globus_l_xio_mode_e_attr_t)); + memcpy(dst_attr, src_attr, sizeof(globus_l_xio_mode_e_attr_t)); if(src_attr->stack != NULL) { globus_xio_stack_copy(&dst_attr->stack, src_attr->stack); diff --git a/xio/src/configure.ac b/xio/src/configure.ac index 9b24677843..f6bdb3bdb6 100644 --- a/xio/src/configure.ac +++ b/xio/src/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ([2.60]) -AC_INIT([globus_xio], [6.6], [https://github.com/gridcf/gct/issues]) +AC_INIT([globus_xio], [6.7], [https://github.com/gridcf/gct/issues]) AC_CONFIG_MACRO_DIR([m4]) AC_SUBST(MAJOR_VERSION, [${PACKAGE_VERSION%%.*}]) AC_SUBST(MINOR_VERSION, [${PACKAGE_VERSION##*.}]) diff --git a/xio/src/globus_xio_driver.c b/xio/src/globus_xio_driver.c index a267b0806e..3504792de9 100644 --- a/xio/src/globus_xio_driver.c +++ b/xio/src/globus_xio_driver.c @@ -64,7 +64,7 @@ globus_l_xio_op_restarted( { globus_i_xio_handle_destroy(handle); } - + GlobusXIODebugInternalExit(); } @@ -152,7 +152,7 @@ globus_i_xio_repass_read( return res; } -void +void globus_i_xio_pass_failed( globus_i_xio_op_t * op, globus_i_xio_context_entry_t * my_context, @@ -244,7 +244,7 @@ globus_i_xio_handle_destroy( GlobusXIODebugInternalExit(); } -/* +/* * called in the context lock */ void @@ -260,7 +260,7 @@ globus_i_xio_handle_dec( *destroy_handle = GLOBUS_FALSE; - handle->ref--; + handle->ref--; GlobusXIODebugPrintf( GLOBUS_XIO_DEBUG_INFO_VERBOSE, (_XIOSL("[globus_i_xio_handle_dec] :: handle ref at %d.\n"), handle->ref)); @@ -291,8 +291,8 @@ globus_i_xio_handle_dec( GlobusXIODebugInternalExit(); } -/* - * called locked +/* + * called locked */ void globus_i_xio_op_destroy( @@ -333,7 +333,7 @@ globus_i_xio_op_destroy( op->entry[ctr].close_attr = NULL; } } - + if(op->user_open_sbj) { globus_free(op->user_open_sbj); @@ -381,7 +381,7 @@ globus_i_xio_driver_resume_op( case GLOBUS_XIO_OPERATION_TYPE_WRITE: globus_l_xio_driver_op_write_kickout(op); break; - + case GLOBUS_XIO_OPERATION_TYPE_CLOSE: globus_l_xio_driver_op_close_kickout(op); break; @@ -456,7 +456,7 @@ globus_i_xio_will_block_cb( { GlobusXIOOpInc(op); deliver_type = *op->entry[ndx].deliver_type; - *op->entry[ndx].deliver_type = + *op->entry[ndx].deliver_type = GLOBUS_XIO_OPERATION_TYPE_FINISHED; op->entry[ndx].deliver_type = NULL; } @@ -535,7 +535,7 @@ globus_l_xio_driver_op_write_kickout( GlobusIXIOClearCancel(op); /* - * before releasing the op back to the user we can safely set this + * before releasing the op back to the user we can safely set this * outside of a mutex. Once the users callbcak is called the value * on the local stack may be changed, theus the magic. */ @@ -554,20 +554,20 @@ globus_l_xio_driver_op_write_kickout( my_op->_op_ent_data_cb(op, GlobusXIOObjToResult(op->cached_obj), my_op->_op_ent_nbytes, my_op->user_arg); - + globus_thread_blocking_callback_pop(&wb_ndx); } else { if(my_op->_op_ent_data_cb == NULL) { - globus_xio_driver_finished_write(op, - GlobusXIOObjToResult(op->cached_obj), + globus_xio_driver_finished_write(op, + GlobusXIOObjToResult(op->cached_obj), my_op->_op_ent_nbytes); } else { - my_op->_op_ent_data_cb(op, + my_op->_op_ent_data_cb(op, GlobusXIOObjToResult(op->cached_obj), my_op->_op_ent_nbytes, my_op->user_arg); } @@ -576,8 +576,8 @@ globus_l_xio_driver_op_write_kickout( globus_xio_driver_write_delivered(op, ndx, &deliver_type); GlobusXIODebugInternalExit(); -} - +} + void globus_l_xio_driver_op_read_kickout( void * user_arg) @@ -600,9 +600,9 @@ globus_l_xio_driver_op_read_kickout( handle = op->_op_handle; GlobusIXIOClearCancel(op); - + /* - * before releasing the op back to the user we can safely set this + * before releasing the op back to the user we can safely set this * outside of a mutex. Once the users callbcak is called the value * on the local stack may be changed, theus the magic. */ @@ -621,20 +621,20 @@ globus_l_xio_driver_op_read_kickout( my_op->_op_ent_data_cb(op, GlobusXIOObjToResult(op->cached_obj), my_op->_op_ent_nbytes, my_op->user_arg); - + globus_thread_blocking_callback_pop(&wb_ndx); } else { if(my_op->_op_ent_data_cb == NULL) { - globus_xio_driver_finished_read(op, - GlobusXIOObjToResult(op->cached_obj), + globus_xio_driver_finished_read(op, + GlobusXIOObjToResult(op->cached_obj), my_op->_op_ent_nbytes); } else { - my_op->_op_ent_data_cb(op, + my_op->_op_ent_data_cb(op, GlobusXIOObjToResult(op->cached_obj), my_op->_op_ent_nbytes, my_op->user_arg); } @@ -643,8 +643,8 @@ globus_l_xio_driver_op_read_kickout( globus_xio_driver_read_delivered(op, ndx, &deliver_type); GlobusXIODebugInternalExit(); -} - +} + void globus_l_xio_driver_purge_read_eof( globus_i_xio_context_entry_t * my_context) @@ -655,7 +655,7 @@ globus_l_xio_driver_purge_read_eof( GlobusXIODebugInternalEnter(); while(!globus_list_empty(my_context->eof_op_list)) { - /* we can only get here if a eof has been received */ + /* we can only get here if a eof has been received */ globus_assert(my_context->state == GLOBUS_XIO_CONTEXT_STATE_EOF_RECEIVED || my_context->state == @@ -728,7 +728,7 @@ globus_i_xio_driver_start_close( globus_xio_driver_finished_close(op, res); my_op->in_register = GLOBUS_FALSE; } - + if((res == GLOBUS_SUCCESS || !can_fail) && my_op->prev_ndx == 0) { while(op->finished_delayed) @@ -746,7 +746,7 @@ globus_i_xio_driver_start_close( { globus_i_xio_op_destroy(op, &destroy_handle); } - + context->ref--; if(context->ref == 0) { @@ -761,7 +761,7 @@ globus_i_xio_driver_start_close( } if(destroy_context) { - /* the only way we'll be destroying the context is if this was a + /* the only way we'll be destroying the context is if this was a * driver op and the handle no longer exists */ globus_assert(!destroy_handle); @@ -820,19 +820,19 @@ globus_l_xio_driver_op_accept_kickout( globus_i_xio_op_t * op; globus_i_xio_op_entry_t * my_op; GlobusXIOName(globus_l_xio_driver_op_accept_kickout); - + GlobusXIODebugInternalEnter(); op = (globus_i_xio_op_t *) user_arg; - + my_op = &op->entry[op->ndx - 1]; op->ndx = my_op->prev_ndx; - + /* driver's can't cancel accept ops yet, dont need this * this call only works for regular ops, anyway - * + * GlobusIXIOClearCancel(op); */ - + if(my_op->cb != NULL) { my_op->cb( @@ -860,7 +860,7 @@ globus_l_xio_driver_open_op_kickout( globus_i_xio_op_t * op; globus_xio_operation_type_t deliver_type; GlobusXIOName(globus_l_xio_driver_open_op_kickout); - + GlobusXIODebugInternalEnter(); op = (globus_i_xio_op_t *) user_arg; @@ -891,12 +891,12 @@ globus_l_xio_driver_open_op_kickout( { if(my_op->cb == NULL) { - globus_xio_driver_finished_open(NULL, op, + globus_xio_driver_finished_open(NULL, op, GlobusXIOObjToResult(op->cached_obj)); } else { - my_op->cb(op, + my_op->cb(op, GlobusXIOObjToResult(op->cached_obj), my_op->user_arg); } } @@ -922,15 +922,15 @@ globus_i_xio_context_destroy( globus_assert(xio_context->ref == 0); GlobusXIODebugPrintf( - GLOBUS_XIO_DEBUG_INFO_VERBOSE, - (_XIOSL(" context @ 0x%x: ref=%d size=%d\n"), + GLOBUS_XIO_DEBUG_INFO_VERBOSE, + (_XIOSL(" context @ 0x%x: ref=%d size=%d\n"), xio_context, xio_context->ref, xio_context->stack_size)); - + for(ctr = 0; ctr < xio_context->stack_size; ctr++) { globus_fifo_destroy(&xio_context->entry[ctr].pending_read_queue); } - + globus_mutex_destroy(&xio_context->mutex); globus_mutex_destroy(&xio_context->cancel_mutex); globus_memory_destroy(&xio_context->op_memory); @@ -1000,7 +1000,7 @@ globus_i_xio_attr_get_ds( /* * read ahead stuff */ -void +void globus_xio_driver_operation_destroy( globus_xio_operation_t operation) { @@ -1060,16 +1060,16 @@ globus_xio_driver_operation_create( index++) { } - + if(index == context->stack_size) { res = GlobusXIOErrorParameter("driver_handle"); goto err; } - + /* driver_handles are to the drivers below the current one */ index--; - + GlobusXIOOperationCreate(op, context); if(op == NULL) { @@ -1090,7 +1090,7 @@ globus_xio_driver_operation_create( my_op->_op_ent_wait_for = 0; my_op->prev_ndx = -1; my_op->type = GLOBUS_XIO_OPERATION_TYPE_DRIVER; - + globus_mutex_lock(&context->mutex); context->ref++; globus_mutex_unlock(&context->mutex); @@ -1147,12 +1147,12 @@ globus_i_xio_driver_attr_cntl( attr->ndx++; } - /* if the driver is capable of parsing the strings + /* if the driver is capable of parsing the strings and this is the string parser command, if there is no table defined the SET_STRING command will be passed to the driver. this is fine. they may want to parse it in their own way */ - if(driver->string_table != NULL && + if(driver->string_table != NULL && cmd == GLOBUS_XIO_SET_STRING_OPTIONS) { char * opt_str; @@ -1174,7 +1174,7 @@ globus_i_xio_driver_attr_cntl( { res = driver->attr_cntl_func(ds, cmd, ap); } - + if(res != GLOBUS_SUCCESS) { goto err; @@ -1295,7 +1295,7 @@ globus_i_xio_driver_attr_cntl( tmp_str = va_arg(ap, char *); attr->user_open_pw = globus_libc_strdup(tmp_str); break; - + default: res = GlobusXIOErrorInvalidCommand(general_cmd); goto err; @@ -1339,7 +1339,7 @@ globus_i_xio_driver_dd_cntl( { if(op->entry[ctr].open_attr == NULL) { - res = + res = op->_op_server->entry[ctr].driver->attr_init_func( &op->entry[ctr].open_attr); } @@ -1355,7 +1355,7 @@ globus_i_xio_driver_dd_cntl( case GLOBUS_XIO_OPERATION_TYPE_OPEN: if(op->entry[ctr].open_attr == NULL) { - res = + res = op->_op_context->entry[ctr].driver->attr_init_func( &op->entry[ctr].open_attr); } @@ -1365,7 +1365,7 @@ globus_i_xio_driver_dd_cntl( case GLOBUS_XIO_OPERATION_TYPE_CLOSE: if(op->entry[ctr].close_attr == NULL) { - res = + res = op->_op_context->entry[ctr].driver->attr_init_func( &op->entry[ctr].close_attr); } @@ -1375,7 +1375,7 @@ globus_i_xio_driver_dd_cntl( default: if(op->entry[ctr].dd == NULL) { - res = + res = op->_op_context->entry[ctr].driver->attr_init_func( &op->entry[ctr].dd); } @@ -1408,16 +1408,16 @@ globus_i_xio_driver_dd_cntl( if (attr_cntl_func) { - /* if the driver is capable of parsing the strings + /* if the driver is capable of parsing the strings and this is the string parser command, if there is no table defined the SET_STRING command will be passed to the driver. this is fine. they may want to parse it in their own way */ - if(driver->string_table != NULL && + if(driver->string_table != NULL && cmd == GLOBUS_XIO_SET_STRING_OPTIONS) { char * opt_str; - + opt_str = va_arg(ap, char *); res = globus_i_xio_string_cntl_parser( opt_str, @@ -1453,7 +1453,7 @@ globus_i_xio_driver_dd_cntl( else { globus_off_t * out_offt; - + /* could end up here with non-dd attr cntls... none supported at driver * level yet, so no biggie */ @@ -1462,12 +1462,12 @@ globus_i_xio_driver_dd_cntl( case GLOBUS_XIO_DD_SET_OFFSET: op->_op_ent_offset = va_arg(ap, globus_off_t); break; - + case GLOBUS_XIO_DD_GET_OFFSET: out_offt = va_arg(ap, globus_off_t *); *out_offt = op->_op_ent_offset; break; - + default: res = GlobusXIOErrorInvalidCommand(cmd); goto err; @@ -1593,7 +1593,7 @@ globus_i_xio_driver_handle_cntl( for(ctr = start_ndx; ctr < context->stack_size; ctr++) { called = GLOBUS_FALSE; - + if(driver == context->entry[ctr].driver || driver == GLOBUS_XIO_QUERY) { @@ -1609,7 +1609,7 @@ globus_i_xio_driver_handle_cntl( ap); called = GLOBUS_TRUE; } - else if(context->entry[ctr].state != + else if(context->entry[ctr].state != GLOBUS_XIO_CONTEXT_STATE_NONE && context->entry[ctr].driver->handle_cntl_func) { @@ -1619,12 +1619,12 @@ globus_i_xio_driver_handle_cntl( ap); called = GLOBUS_TRUE; } - + if(called && res == GLOBUS_SUCCESS) { break; } - + if(driver == GLOBUS_XIO_QUERY) { if(called && res != GLOBUS_SUCCESS && @@ -1639,7 +1639,7 @@ globus_i_xio_driver_handle_cntl( res = GlobusXIOErrorInvalidDriver( _XIOSL("handle_cntl not supported")); } - + if(res != GLOBUS_SUCCESS) { goto err; @@ -1723,7 +1723,7 @@ globus_xio_driver_merge_handle( goto err; } dst_context->entry[ctr].whos_my_daddy = dst_context; - dst_context->entry[ctr].driver_handle = + dst_context->entry[ctr].driver_handle = src_context->entry[ctr].driver_handle; GlobusXIOContextStateChange(&dst_context->entry[ctr], @@ -1774,7 +1774,7 @@ globus_xio_driver_handle_cntl( { } } - + res = globus_i_xio_driver_handle_cntl(context, start_ndx, driver, cmd, ap); va_end(ap); if(res != GLOBUS_SUCCESS) @@ -1818,22 +1818,22 @@ globus_xio_driver_operation_cancel( source_ndx++) { } - + if(source_ndx == context->stack_size) { res = GlobusXIOErrorParameter("driver_handle"); goto err; } - + /* driver_handles are to the drivers below the current one */ source_ndx--; - + globus_mutex_lock(&context->cancel_mutex); { res = globus_i_xio_operation_cancel(op, source_ndx); } globus_mutex_unlock(&context->cancel_mutex); - + GlobusXIODebugExit(); return GLOBUS_SUCCESS; @@ -1853,10 +1853,10 @@ globus_xio_driver_set_eof_received( GlobusXIOName(globus_xio_driver_set_eof_received); GlobusXIODebugEnter(); - + context = op->_op_context; my_context = &context->entry[op->entry[op->ndx - 1].prev_ndx]; - + globus_mutex_lock(&context->mutex); { globus_assert( @@ -1865,9 +1865,9 @@ globus_xio_driver_set_eof_received( globus_assert( my_context->state == GLOBUS_XIO_CONTEXT_STATE_OPEN || my_context->state == GLOBUS_XIO_CONTEXT_STATE_EOF_RECEIVED || - my_context->state == + my_context->state == GLOBUS_XIO_CONTEXT_STATE_EOF_RECEIVED_AND_CLOSING); - + if(my_context->state == GLOBUS_XIO_CONTEXT_STATE_OPEN) { GlobusXIOContextStateChange(my_context, @@ -1875,7 +1875,7 @@ globus_xio_driver_set_eof_received( } } globus_mutex_unlock(&context->mutex); - + GlobusXIODebugExit(); } @@ -1889,10 +1889,10 @@ globus_xio_driver_eof_received( GlobusXIOName(globus_xio_driver_eof_received); GlobusXIODebugEnter(); - + context = op->_op_context; my_context = &context->entry[op->entry[op->ndx - 1].prev_ndx]; - + globus_mutex_lock(&context->mutex); { globus_assert( @@ -1901,20 +1901,20 @@ globus_xio_driver_eof_received( globus_assert( my_context->state == GLOBUS_XIO_CONTEXT_STATE_OPEN || my_context->state == GLOBUS_XIO_CONTEXT_STATE_EOF_RECEIVED || - my_context->state == + my_context->state == GLOBUS_XIO_CONTEXT_STATE_EOF_RECEIVED_AND_CLOSING); - + if(my_context->state == GLOBUS_XIO_CONTEXT_STATE_EOF_RECEIVED || - my_context->state == + my_context->state == GLOBUS_XIO_CONTEXT_STATE_EOF_RECEIVED_AND_CLOSING) { received = GLOBUS_TRUE; } } globus_mutex_unlock(&context->mutex); - + GlobusXIODebugExit(); - + return received; } @@ -1942,7 +1942,7 @@ globus_xio_driver_init( goto err; } memset(driver, '\0', sizeof(globus_i_xio_driver_t)); - + driver->name = globus_libc_strdup(driver_name); if(!driver->name) { @@ -1950,7 +1950,7 @@ globus_xio_driver_init( res = GlobusXIOErrorMemory("driver->name"); goto err; } - + driver->user_data = user_data; *out_driver = driver; @@ -2089,7 +2089,7 @@ globus_xio_driver_set_server( * @details * This function adds a callback to a driver that will be called before * a server handle is created by XIO. This function has the same signature - * as the server_init_func in the driver, but is always called with a + * as the server_init_func in the driver, but is always called with a * NULL contact string. There is no support for calling a pass() or finished() * function for this interface. It may inspect and modify its attributes * and operation, but can not directly return any data or set a driver-specific @@ -2269,7 +2269,7 @@ globus_xio_operation_enable_cancel( { mutex = &op->_op_context->cancel_mutex; } - + globus_mutex_lock(mutex); { already_canceled = op->canceled != 0; @@ -2280,7 +2280,7 @@ globus_xio_operation_enable_cancel( } } globus_mutex_unlock(mutex); - + return already_canceled; } @@ -2298,7 +2298,7 @@ globus_xio_operation_disable_cancel( { mutex = &op->_op_context->cancel_mutex; } - + globus_mutex_lock(mutex); { op->cancel_cb = NULL; @@ -2347,7 +2347,7 @@ globus_xio_operation_get_user_driver( /** * @brief Get the XIO transport driver associated with an op - * @ingroup globus_xio_driver_programming + * @ingroup string_globus_xio_driver_programming */ globus_xio_driver_t globus_xio_operation_get_transport_user_driver( @@ -2400,7 +2400,7 @@ globus_xio_operation_attr_cntl( gss_cred_id_t * out_cred; va_list ap; GlobusXIOName(globus_xio_operation_attr_cntl); - + if(op == NULL) { result = GlobusXIOErrorParameter("op"); @@ -2465,7 +2465,7 @@ globus_xio_operation_get_data_descriptor( op->entry[op->ndx - 1].dd = NULL; } } - + return op->entry[op->ndx - 1].dd; } @@ -2488,14 +2488,14 @@ globus_xio_operation_copy_stack( { goto error_init; } - + istack = *stack; - + switch(op->type) { case GLOBUS_XIO_OPERATION_TYPE_SERVER_INIT: server = op->_op_server; - + for(ndx = op->stack_size - 1; ndx > op->ndx; ndx--) { istack->size++; @@ -2503,10 +2503,10 @@ globus_xio_operation_copy_stack( &istack->driver_stack, server->entry[ndx].driver); } break; - + case GLOBUS_XIO_OPERATION_TYPE_ACCEPT: server = op->_op_server; - + for(ndx = op->stack_size - 1; ndx >= op->ndx; ndx--) { istack->size++; @@ -2514,10 +2514,10 @@ globus_xio_operation_copy_stack( &istack->driver_stack, server->entry[ndx].driver); } break; - + default: context = op->_op_context; - + for(ndx = op->stack_size - 1; ndx >= op->ndx; ndx--) { istack->size++; @@ -2526,10 +2526,10 @@ globus_xio_operation_copy_stack( } break; } - + GlobusXIODebugExit(); return GLOBUS_SUCCESS; - + error_init: GlobusXIODebugExitWithError(); return result; diff --git a/xio/src/globus_xio_system_select.c b/xio/src/globus_xio_system_select.c index dd1d5eff04..f5059535f5 100644 --- a/xio/src/globus_xio_system_select.c +++ b/xio/src/globus_xio_system_select.c @@ -157,7 +157,7 @@ globus_l_xio_system_wakeup_handler( GlobusXIOName(globus_l_xio_system_wakeup_handler); GlobusXIOSystemDebugEnter(); - + if(!globus_l_xio_system_shutdown_called) { byte = 0; @@ -167,7 +167,7 @@ globus_l_xio_system_wakeup_handler( globus_l_xio_system_wakeup_pipe[1], &byte, sizeof(byte)); } while(rc < 0 && errno == EINTR); } - + GlobusXIOSystemDebugExit(); } @@ -180,12 +180,12 @@ globus_l_xio_system_activate(void) globus_result_t result; globus_reltime_t period; GlobusXIOName(globus_l_xio_system_activate); - + if(globus_i_xio_system_common_activate() != GLOBUS_SUCCESS) { goto error_activate; } - + GlobusXIOSystemDebugEnter(); globus_cond_init(&globus_l_xio_system_cond, GLOBUS_NULL); @@ -245,7 +245,7 @@ globus_l_xio_system_activate(void) } fcntl(globus_l_xio_system_wakeup_pipe[0], F_SETFD, FD_CLOEXEC); fcntl(globus_l_xio_system_wakeup_pipe[1], F_SETFD, FD_CLOEXEC); - + globus_l_xio_system_highest_fd = globus_l_xio_system_wakeup_pipe[0]; FD_SET(globus_l_xio_system_wakeup_pipe[0], globus_l_xio_system_read_fds); @@ -262,7 +262,7 @@ globus_l_xio_system_activate(void) "globus_callback_register_periodic", result); goto error_register; } - + globus_callback_add_wakeup_handler( globus_l_xio_system_wakeup_handler, GLOBUS_NULL); @@ -283,7 +283,7 @@ globus_l_xio_system_activate(void) globus_mutex_destroy(&globus_l_xio_system_cancel_mutex); globus_mutex_destroy(&globus_l_xio_system_fdset_mutex); globus_cond_destroy(&globus_l_xio_system_cond); - + GlobusXIOSystemDebugExitWithError(); globus_i_xio_system_common_deactivate(); error_activate: @@ -297,9 +297,9 @@ globus_l_xio_system_unregister_periodic_cb( { globus_bool_t * signaled; GlobusXIOName(globus_l_xio_system_unregister_periodic_cb); - + GlobusXIOSystemDebugEnter(); - + signaled = (globus_bool_t *) user_args; globus_mutex_lock(&globus_l_xio_system_fdset_mutex); { @@ -322,7 +322,7 @@ globus_l_xio_system_deactivate(void) globus_mutex_lock(&globus_l_xio_system_fdset_mutex); { globus_bool_t signaled; - + globus_l_xio_system_shutdown_called = GLOBUS_TRUE; signaled = GLOBUS_FALSE; globus_callback_unregister( @@ -354,7 +354,7 @@ globus_l_xio_system_deactivate(void) globus_cond_destroy(&globus_l_xio_system_cond); GlobusXIOSystemDebugExit(); - + globus_i_xio_system_common_deactivate(); return GLOBUS_SUCCESS; @@ -381,25 +381,25 @@ globus_l_xio_system_handle_init( result = GlobusXIOErrorMemory("handle"); goto error_alloc; } - + handle->type = type; handle->fd = fd; - + handle->file_position = globus_xio_system_file_get_position(fd); - + rc = globus_l_xio_system_add_nonblocking(handle); if(rc < 0) { result = GlobusXIOErrorSystemError("fcntl", errno); goto error_fcntl; } - + globus_mutex_init(&handle->lock, NULL); - + *u_handle = handle; GlobusXIOSystemDebugExitFD(fd); return GLOBUS_SUCCESS; - + error_fcntl: globus_free(handle); error_alloc: @@ -439,7 +439,7 @@ globus_l_xio_system_handle_destroy( globus_l_xio_system_remove_nonblocking(handle); globus_free(handle); - + GlobusXIOSystemDebugExitFD(fd); } @@ -473,21 +473,21 @@ globus_l_xio_system_cancel_cb( globus_mutex_lock(&globus_l_xio_system_cancel_mutex); { - if(op_info->state != GLOBUS_I_XIO_SYSTEM_OP_COMPLETE && + if(op_info->state != GLOBUS_I_XIO_SYSTEM_OP_COMPLETE && op_info->state != GLOBUS_I_XIO_SYSTEM_OP_CANCELED) { op_info->error = reason == GLOBUS_XIO_ERROR_TIMEOUT ? GlobusXIOErrorObjTimeout() : GlobusXIOErrorObjCanceled(); - + globus_mutex_lock(&globus_l_xio_system_fdset_mutex); { globus_bool_t pend; - + if(op_info->state == GLOBUS_I_XIO_SYSTEM_OP_NEW) { op_info->state = GLOBUS_I_XIO_SYSTEM_OP_CANCELED; - + GlobusXIOSystemDebugPrintf( GLOBUS_I_XIO_SYSTEM_DEBUG_INFO, (_XIOSL("[%s] fd=%d, Canceling NEW\n"), @@ -498,12 +498,12 @@ globus_l_xio_system_cancel_cb( if(globus_l_xio_system_select_active) { op_info->state = GLOBUS_I_XIO_SYSTEM_OP_CANCELED; - + GlobusXIOSystemDebugPrintf( GLOBUS_I_XIO_SYSTEM_DEBUG_INFO, (_XIOSL("[%s] fd=%d, Canceling Active\n"), _xio_name, op_info->handle->fd)); - + /* pend the cancel for after select wakes up */ if(!globus_l_xio_system_wakeup_pending) { @@ -518,12 +518,12 @@ globus_l_xio_system_cancel_cb( globus_result_t result; op_info->state = GLOBUS_I_XIO_SYSTEM_OP_COMPLETE; - + GlobusXIOSystemDebugPrintf( GLOBUS_I_XIO_SYSTEM_DEBUG_INFO, (_XIOSL("[%s] fd=%d, Canceling Pending\n"), _xio_name, op_info->handle->fd)); - + /* unregister and kickout now */ result = globus_callback_register_oneshot( GLOBUS_NULL, @@ -621,7 +621,7 @@ globus_l_xio_system_register_read_fd( result = GlobusXIOErrorNotActivated(); goto error_deactivated; } - + if(fd >= globus_l_xio_system_max_fds) { result = GlobusXIOErrorSystemResource(_XIOSL("too many fds")); @@ -661,7 +661,7 @@ globus_l_xio_system_register_read_fd( */ globus_l_xio_system_select_wakeup(); } - + GlobusXIOSystemDebugExitFD(fd); return GLOBUS_SUCCESS; @@ -706,13 +706,13 @@ globus_l_xio_system_register_write_fd( result = globus_error_put(write_info->error); goto error_canceled; } - + if(globus_l_xio_system_shutdown_called) { result = GlobusXIOErrorNotActivated(); goto error_deactivated; } - + if(fd >= globus_l_xio_system_max_fds) { result = GlobusXIOErrorSystemResource(_XIOSL("too many fds")); @@ -743,7 +743,7 @@ globus_l_xio_system_register_write_fd( write_info->state = GLOBUS_I_XIO_SYSTEM_OP_PENDING; } globus_mutex_unlock(&globus_l_xio_system_fdset_mutex); - + if(do_wakeup) { /* I do this outside the lock because the select thread is likely @@ -752,7 +752,7 @@ globus_l_xio_system_register_write_fd( */ globus_l_xio_system_select_wakeup(); } - + GlobusXIOSystemDebugExitFD(fd); return GLOBUS_SUCCESS; @@ -885,7 +885,7 @@ globus_l_xio_system_kickout( op_info->sop.data.start_iov); break; } - + GlobusXIOSystemDebugExitFD(fd); GlobusIXIOSystemFreeOperation(op_info); } @@ -899,7 +899,7 @@ globus_l_xio_system_select_wakeup(void) GlobusXIOName(globus_l_xio_system_select_wakeup); GlobusXIOSystemDebugEnter(); - + byte = 0; do @@ -985,15 +985,14 @@ globus_l_xio_system_handle_read( } else { - int rc; globus_l_xio_system_t tmp_handle; *read_info->sop.non_data.out_fd = new_fd; tmp_handle.fd = new_fd; tmp_handle.type = GLOBUS_XIO_SYSTEM_TCP; - rc = globus_l_xio_system_remove_nonblocking(&tmp_handle); - + globus_l_xio_system_remove_nonblocking(&tmp_handle); + read_info->nbytes++; GlobusXIOSystemDebugPrintf( GLOBUS_I_XIO_SYSTEM_DEBUG_INFO, @@ -1026,12 +1025,12 @@ globus_l_xio_system_handle_read( return GLOBUS_FALSE; break; } - + if(result != GLOBUS_SUCCESS) { read_info->error = globus_error_get(result); } - + /* always true for accept operations */ if(read_info->nbytes >= read_info->waitforbytes || result != GLOBUS_SUCCESS) @@ -1133,12 +1132,12 @@ globus_l_xio_system_handle_write( return GLOBUS_FALSE; break; } - + if(result != GLOBUS_SUCCESS) { write_info->error = globus_error_get(result); } - + /* always true for connect operations */ if(write_info->nbytes >= write_info->waitforbytes || result != GLOBUS_SUCCESS) @@ -1186,7 +1185,7 @@ globus_l_xio_system_bad_apple(void) GlobusXIOName(globus_l_xio_system_bad_apple); GlobusXIOSystemDebugEnter(); - + globus_mutex_lock(&globus_l_xio_system_fdset_mutex); { for(fd = 0; fd <= globus_l_xio_system_highest_fd; fd++) @@ -1199,9 +1198,9 @@ globus_l_xio_system_bad_apple(void) { GlobusXIOSystemDebugPrintf( GLOBUS_I_XIO_SYSTEM_DEBUG_INFO, - (_XIOSL("[%s] fd=%d, Canceling read bad apple\n"), + (_XIOSL("[%s] fd=%d, Canceling read bad apple\n"), _xio_name, fd)); - + op_info = globus_l_xio_system_read_operations[fd]; if(op_info->state == GLOBUS_I_XIO_SYSTEM_OP_PENDING) { @@ -1213,7 +1212,7 @@ globus_l_xio_system_bad_apple(void) } } } - + if(FD_ISSET(fd, globus_l_xio_system_write_fds)) { rc = fstat(fd, &stat_buf); @@ -1224,7 +1223,7 @@ globus_l_xio_system_bad_apple(void) GLOBUS_I_XIO_SYSTEM_DEBUG_INFO, (_XIOSL("[%s] fd=%d, Canceling write bad apple\n"), _xio_name, fd)); - + op_info = globus_l_xio_system_write_operations[fd]; if(op_info->state == GLOBUS_I_XIO_SYSTEM_OP_PENDING) { @@ -1239,7 +1238,7 @@ globus_l_xio_system_bad_apple(void) } } globus_mutex_unlock(&globus_l_xio_system_fdset_mutex); - + GlobusXIOSystemDebugExit(); } @@ -1264,7 +1263,7 @@ globus_l_xio_system_poll( int nready; int fd; int save_errno; - + time_left_is_zero = GLOBUS_FALSE; time_left_is_infinity = GLOBUS_FALSE; @@ -1294,11 +1293,11 @@ globus_l_xio_system_poll( globus_l_xio_system_select_active = GLOBUS_TRUE; } globus_mutex_unlock(&globus_l_xio_system_fdset_mutex); - + GlobusXIOSystemDebugPrintf( GLOBUS_I_XIO_SYSTEM_DEBUG_INFO, (_XIOSL("[%s] Before select\n"), _xio_name)); - + nready = select( num, globus_l_xio_system_ready_reads, @@ -1308,7 +1307,7 @@ globus_l_xio_system_poll( GlobusXIOSystemUpdateErrno(); save_errno = errno; - + GlobusXIOSystemDebugPrintf( GLOBUS_I_XIO_SYSTEM_DEBUG_INFO, (_XIOSL("[%s] After select\n"), _xio_name)); @@ -1339,7 +1338,7 @@ globus_l_xio_system_poll( { globus_l_xio_system_bad_apple(); } - + /* * can't really do anything about other errors * so, set ready fds to known state in case there are things @@ -1361,11 +1360,11 @@ globus_l_xio_system_poll( fd = (int) (intptr_t) globus_list_remove( &globus_l_xio_system_canceled_reads, globus_l_xio_system_canceled_reads); - + GlobusXIOSystemDebugPrintf( GLOBUS_I_XIO_SYSTEM_DEBUG_INFO, (_XIOSL("[%s] fd=%d, Setting canceled read\n"), _xio_name, fd)); - + if(!FD_ISSET(fd, globus_l_xio_system_ready_reads)) { FD_SET(fd, globus_l_xio_system_ready_reads); @@ -1378,11 +1377,11 @@ globus_l_xio_system_poll( fd = (int) (intptr_t) globus_list_remove( &globus_l_xio_system_canceled_writes, globus_l_xio_system_canceled_writes); - + GlobusXIOSystemDebugPrintf( GLOBUS_I_XIO_SYSTEM_DEBUG_INFO, (_XIOSL("[%s] fd=%d, Setting canceled read\n"), _xio_name, fd)); - + if(!FD_ISSET(fd, globus_l_xio_system_ready_writes)) { FD_SET(fd, globus_l_xio_system_ready_writes); @@ -1486,7 +1485,7 @@ globus_xio_system_socket_register_connect( goto error_register; } - + /* handle could be destroyed by time we get here - no touch! */ GlobusXIOSystemDebugExitFD(fd); return GLOBUS_SUCCESS; @@ -1514,7 +1513,7 @@ globus_xio_system_socket_register_accept( GlobusXIOName(globus_xio_system_socket_register_accept); GlobusXIOSystemDebugEnterFD(fd); - + GlobusIXIOSystemAllocOperation(op_info); if(!op_info) { @@ -1539,7 +1538,7 @@ globus_xio_system_socket_register_accept( _XIOSL("globus_l_xio_system_register_read_fd"), result); goto error_register; } - + /* handle could be destroyed by time we get here - no touch! */ GlobusXIOSystemDebugExitFD(fd); return GLOBUS_SUCCESS; @@ -1576,23 +1575,23 @@ globus_l_xio_system_register_read( GlobusXIOSystemDebugPrintf( GLOBUS_I_XIO_SYSTEM_DEBUG_DATA, (_XIOSL("[%s] Waiting for %u bytes\n"), _xio_name, (unsigned) waitforbytes)); - + GlobusIXIOSystemAllocOperation(op_info); if(!op_info) { result = GlobusXIOErrorMemory("op_info"); goto error_op_info; } - + GlobusIXIOSystemAllocIovec(u_iovc, iov); if(!iov) { result = GlobusXIOErrorMemory("iov"); goto error_iovec; } - + GlobusIXIOUtilTransferIovec(iov, u_iov, u_iovc); - + op_info->type = GLOBUS_I_XIO_SYSTEM_OP_READ; op_info->sop.data.start_iov = iov; op_info->sop.data.start_iovc = u_iovc; @@ -1600,7 +1599,7 @@ globus_l_xio_system_register_read( op_info->sop.data.iovc = u_iovc; op_info->sop.data.addr = from; op_info->sop.data.flags = flags; - + op_info->state = GLOBUS_I_XIO_SYSTEM_OP_NEW; op_info->op = op; op_info->handle = handle; @@ -1608,7 +1607,7 @@ globus_l_xio_system_register_read( op_info->sop.data.callback = callback; op_info->waitforbytes = waitforbytes; op_info->offset = offset; - + result = globus_l_xio_system_register_read_fd(fd, op_info); if(result != GLOBUS_SUCCESS) { @@ -1616,7 +1615,7 @@ globus_l_xio_system_register_read( "globus_l_xio_system_register_read_fd", result); goto error_register; } - + /* handle could be destroyed by time we get here - no touch! */ GlobusXIOSystemDebugExitFD(fd); return GLOBUS_SUCCESS; @@ -1705,14 +1704,14 @@ globus_l_xio_system_register_write( GlobusXIOSystemDebugPrintf( GLOBUS_I_XIO_SYSTEM_DEBUG_DATA, (_XIOSL("[%s] Waiting for %u bytes\n"), _xio_name, (unsigned) waitforbytes)); - + GlobusIXIOSystemAllocOperation(op_info); if(!op_info) { result = GlobusXIOErrorMemory("op_info"); goto error_op_info; } - + GlobusIXIOSystemAllocIovec(u_iovc, iov); if(!iov) { @@ -1721,7 +1720,7 @@ globus_l_xio_system_register_write( } GlobusIXIOUtilTransferIovec(iov, u_iov, u_iovc); - + op_info->type = GLOBUS_I_XIO_SYSTEM_OP_WRITE; op_info->sop.data.start_iov = iov; op_info->sop.data.start_iovc = u_iovc; @@ -1729,7 +1728,7 @@ globus_l_xio_system_register_write( op_info->sop.data.iovc = u_iovc; op_info->sop.data.addr = to; op_info->sop.data.flags = flags; - + op_info->state = GLOBUS_I_XIO_SYSTEM_OP_NEW; op_info->op = op; op_info->handle = handle; @@ -1737,7 +1736,7 @@ globus_l_xio_system_register_write( op_info->sop.data.callback = callback; op_info->waitforbytes = waitforbytes; op_info->offset = offset; - + result = globus_l_xio_system_register_write_fd(fd, op_info); if(result != GLOBUS_SUCCESS) { @@ -1745,7 +1744,7 @@ globus_l_xio_system_register_write( "globus_l_xio_system_register_write_fd", result); goto error_register; } - + /* handle could be destroyed by time we get here - no touch! */ GlobusXIOSystemDebugExitFD(fd); return GLOBUS_SUCCESS; @@ -1824,7 +1823,7 @@ globus_l_xio_system_try_read( if(handle->type == GLOBUS_XIO_SYSTEM_FILE) { globus_result_t result; - + globus_mutex_lock(&handle->lock); { if(handle->file_position != offset && @@ -1835,19 +1834,19 @@ globus_l_xio_system_try_read( ("[globus_l_xio_system_try_read] fd=%d, " "Changing file position to %" GLOBUS_OFF_T_FORMAT "\n", handle->fd, offset)); - + /* assume success as possible failures are ignorable */ lseek(handle->fd, offset, SEEK_SET); handle->file_position = offset; } - + result = globus_i_xio_system_file_try_read( handle->fd, iov, iovc, nbytes); - + handle->file_position += *nbytes; } globus_mutex_unlock(&handle->lock); - + return result; } else @@ -1870,28 +1869,27 @@ globus_l_xio_system_read( globus_size_t * u_nbytes) { globus_result_t result; - int rc; GlobusXIOName(globus_l_xio_system_read); GlobusXIOSystemDebugEnter(); result = globus_l_xio_system_try_read( handle, offset, u_iov, u_iovc, flags, from, u_nbytes); - + if(result == GLOBUS_SUCCESS && *u_nbytes < waitforbytes) { struct iovec * iov; int iovc; globus_size_t nbytes = *u_nbytes; globus_size_t total = nbytes; - + /* * XXX this is not thread safe... both reads and writes are mucking * with blocking status. * worst case, we read 0 bytes in the loop below, return, and xio * calls us again to finish up. */ - rc = globus_l_xio_system_remove_nonblocking(handle); + globus_l_xio_system_remove_nonblocking(handle); GlobusIXIOSystemAllocIovec(u_iovc, iov); if(!iov) { @@ -1902,7 +1900,7 @@ globus_l_xio_system_read( GlobusIXIOUtilTransferIovec(iov, u_iov, u_iovc); u_iov = iov; iovc = u_iovc; - + do { if(total > 0) @@ -1910,25 +1908,25 @@ globus_l_xio_system_read( /* only capture source first time around */ from = GLOBUS_NULL; } - + offset += nbytes; GlobusIXIOUtilAdjustIovec(iov, iovc, nbytes); result = globus_l_xio_system_try_read( handle, offset, iov, iovc, flags, from, &nbytes); total += nbytes; } while(result == GLOBUS_SUCCESS && nbytes && total < waitforbytes); - + *u_nbytes = total; - + GlobusIXIOSystemFreeIovec(u_iovc, (globus_xio_iovec_t *) u_iov); - rc = globus_l_xio_system_add_nonblocking(handle); + globus_l_xio_system_add_nonblocking(handle); } GlobusXIOSystemDebugExit(); return result; error_iovec: - rc = globus_l_xio_system_add_nonblocking(handle); + globus_l_xio_system_add_nonblocking(handle); GlobusXIOSystemDebugExitWithError(); return result; } @@ -1974,7 +1972,7 @@ globus_l_xio_system_try_write( if(handle->type == GLOBUS_XIO_SYSTEM_FILE) { globus_result_t result; - + globus_mutex_lock(&handle->lock); { if(handle->file_position != offset && @@ -1985,19 +1983,19 @@ globus_l_xio_system_try_write( ("[globus_l_xio_system_try_write] fd=%d, " "Changing file position to %" GLOBUS_OFF_T_FORMAT "\n", handle->fd, offset)); - + /* assume success as possible failures are ignorable */ lseek(handle->fd, offset, SEEK_SET); handle->file_position = offset; } - + result = globus_i_xio_system_file_try_write( handle->fd, iov, iovc, nbytes); - + handle->file_position += *nbytes; } globus_mutex_unlock(&handle->lock); - + return result; } else @@ -2020,26 +2018,25 @@ globus_l_xio_system_write( globus_size_t * u_nbytes) { globus_result_t result; - int rc; GlobusXIOName(globus_l_xio_system_write); GlobusXIOSystemDebugEnter(); result = globus_l_xio_system_try_write( handle, offset, u_iov, u_iovc, flags, to, u_nbytes); - + if(result == GLOBUS_SUCCESS && *u_nbytes < waitforbytes) { struct iovec * iov; int iovc; globus_size_t nbytes = *u_nbytes; globus_size_t total = nbytes; - + /* * XXX this is not thread safe... both reads and writes are mucking * with blocking status */ - rc = globus_l_xio_system_remove_nonblocking(handle); + globus_l_xio_system_remove_nonblocking(handle); GlobusIXIOSystemAllocIovec(u_iovc, iov); if(!iov) { @@ -2050,7 +2047,7 @@ globus_l_xio_system_write( GlobusIXIOUtilTransferIovec(iov, u_iov, u_iovc); u_iov = iov; iovc = u_iovc; - + do { offset += nbytes; @@ -2059,18 +2056,18 @@ globus_l_xio_system_write( handle, offset, iov, iovc, flags, to, &nbytes); total += nbytes; } while(result == GLOBUS_SUCCESS && nbytes && total < waitforbytes); - + *u_nbytes = total; - + GlobusIXIOSystemFreeIovec(u_iovc, (globus_xio_iovec_t *) u_iov); - rc = globus_l_xio_system_add_nonblocking(handle); + globus_l_xio_system_add_nonblocking(handle); } GlobusXIOSystemDebugExit(); return result; error_iovec: - rc = globus_l_xio_system_add_nonblocking(handle); + globus_l_xio_system_add_nonblocking(handle); GlobusXIOSystemDebugExitWithError(); return result; } @@ -2112,19 +2109,19 @@ globus_l_xio_system_close( GlobusXIOName(globus_l_xio_system_close); GlobusXIOSystemDebugEnterFD(fd); - + do { rc = close(fd); GlobusXIOSystemUpdateErrno(); } while(rc < 0 && errno == EINTR); - + if(rc < 0) { result = GlobusXIOErrorSystemError("close", errno); goto error_close; } - + GlobusXIOSystemDebugExitFD(fd); return GLOBUS_SUCCESS; @@ -2139,18 +2136,18 @@ globus_xio_system_file_get_position( { globus_off_t offset; GlobusXIOName(globus_xio_system_file_get_position); - + GlobusXIOSystemDebugEnterFD(fd); - + /* ignore errors, may be a pipe or other unseekable */ offset = lseek(fd, 0, SEEK_CUR); if(offset == -1) { offset = 0; } - + GlobusXIOSystemDebugExitFD(fd); - + return offset; } @@ -2161,16 +2158,16 @@ globus_xio_system_file_get_size( globus_off_t size = -1; struct stat buf; GlobusXIOName(globus_xio_system_file_get_size); - + GlobusXIOSystemDebugEnterFD(fd); - + if(fstat(fd, &buf) == 0) { size = buf.st_size; } - + GlobusXIOSystemDebugExitFD(fd); - + return size; } @@ -2190,7 +2187,7 @@ globus_xio_system_convert_stdio( { return fileno(stderr); } - + return GLOBUS_XIO_SYSTEM_INVALID_FILE; } @@ -2202,9 +2199,9 @@ globus_xio_system_file_truncate( globus_result_t result; int rc; GlobusXIOName(globus_xio_system_file_truncate); - + GlobusXIOSystemDebugEnterFD(fd); - + #ifdef TARGET_ARCH_ARM setErrno(EINVAL); @@ -2217,7 +2214,7 @@ globus_xio_system_file_truncate( result = GlobusXIOErrorSystemError("ftruncate", errno); goto error_truncate; } - + GlobusXIOSystemDebugExitFD(fd); return GLOBUS_SUCCESS; @@ -2236,10 +2233,10 @@ globus_xio_system_file_open( { globus_result_t result; GlobusXIOName(globus_xio_system_file_open); - + *fd = -1; GlobusXIOSystemDebugEnterFD(*fd); - + do { *fd = open(filename, flags, mode); @@ -2251,10 +2248,10 @@ globus_xio_system_file_open( result = GlobusXIOErrorSystemError("open", errno); goto error_open; } - + /* all handles created by me are closed on exec */ fcntl(*fd, F_SETFD, FD_CLOEXEC); - + GlobusXIOSystemDebugPrintf( GLOBUS_I_XIO_SYSTEM_DEBUG_INFO, ("[%s] Opened file, %s fd=%d\n", _xio_name, filename, *fd)); @@ -2283,10 +2280,10 @@ globus_xio_system_socket_create( { globus_result_t result; GlobusXIOName(globus_xio_system_socket_create); - + *fd = -1; GlobusXIOSystemDebugEnterFD(*fd); - + *fd = socket(domain, type, protocol); GlobusXIOSystemUpdateErrno(); if(*fd == -1) @@ -2294,7 +2291,7 @@ globus_xio_system_socket_create( result = GlobusXIOErrorSystemError("socket", errno); goto error_socket; } - + /* all handles created by me are closed on exec */ fcntl(*fd, F_SETFD, FD_CLOEXEC); @@ -2316,16 +2313,16 @@ globus_xio_system_socket_setsockopt( { globus_result_t result; GlobusXIOName(globus_xio_system_socket_setsockopt); - + GlobusXIOSystemDebugEnterFD(socket); - + if(setsockopt(socket, level, optname, (void *) optval, optlen) < 0) { GlobusXIOSystemUpdateErrno(); result = GlobusXIOErrorSystemError("setsockopt", errno); goto error_setsockopt; } - + GlobusXIOSystemDebugExitFD(socket); return GLOBUS_SUCCESS; @@ -2344,16 +2341,16 @@ globus_xio_system_socket_getsockopt( { globus_result_t result; GlobusXIOName(globus_xio_system_socket_getsockopt); - + GlobusXIOSystemDebugEnterFD(socket); - + if(getsockopt(socket, level, optname, optval, optlen) < 0) { GlobusXIOSystemUpdateErrno(); result = GlobusXIOErrorSystemError("getsockopt", errno); goto error_getsockopt; } - + GlobusXIOSystemDebugExitFD(socket); return GLOBUS_SUCCESS; @@ -2370,16 +2367,16 @@ globus_xio_system_socket_getsockname( { globus_result_t result; GlobusXIOName(globus_xio_system_socket_getsockname); - + GlobusXIOSystemDebugEnterFD(socket); - + if(getsockname(socket, name, namelen) < 0) { GlobusXIOSystemUpdateErrno(); result = GlobusXIOErrorSystemError("getsockname", errno); goto error_getsockname; } - + GlobusXIOSystemDebugExitFD(socket); return GLOBUS_SUCCESS; @@ -2396,16 +2393,16 @@ globus_xio_system_socket_getpeername( { globus_result_t result; GlobusXIOName(globus_xio_system_socket_getpeername); - + GlobusXIOSystemDebugEnterFD(socket); - + if(getpeername(socket, name, namelen) < 0) { GlobusXIOSystemUpdateErrno(); result = GlobusXIOErrorSystemError("getpeername", errno); goto error_getpeername; } - + GlobusXIOSystemDebugExitFD(socket); return GLOBUS_SUCCESS; @@ -2422,16 +2419,16 @@ globus_xio_system_socket_bind( { globus_result_t result; GlobusXIOName(globus_xio_system_socket_bind); - + GlobusXIOSystemDebugEnterFD(socket); - + if(bind(socket, addr, addrlen) < 0) { GlobusXIOSystemUpdateErrno(); result = GlobusXIOErrorSystemError("bind", errno); goto error_bind; } - + GlobusXIOSystemDebugExitFD(socket); return GLOBUS_SUCCESS; @@ -2447,16 +2444,16 @@ globus_xio_system_socket_listen( { globus_result_t result; GlobusXIOName(globus_xio_system_socket_listen); - + GlobusXIOSystemDebugEnterFD(socket); - + if(listen(socket, backlog) < 0) { GlobusXIOSystemUpdateErrno(); result = GlobusXIOErrorSystemError("listen", errno); goto error_listen; } - + GlobusXIOSystemDebugExitFD(socket); return GLOBUS_SUCCESS; @@ -2474,21 +2471,21 @@ globus_xio_system_socket_connect( globus_result_t result; int rc; GlobusXIOName(globus_xio_system_socket_connect); - + GlobusXIOSystemDebugEnterFD(socket); - + do { rc = connect(socket, addr, addrlen); GlobusXIOSystemUpdateErrno(); } while(rc < 0 && errno == EINTR); - + if(rc < 0) { result = GlobusXIOErrorSystemError("connect", errno); goto error_connect; } - + GlobusXIOSystemDebugExitFD(socket); return GLOBUS_SUCCESS; diff --git a/xio/src/test/drivers/globus_xio_smtp.c b/xio/src/test/drivers/globus_xio_smtp.c index 08569c0562..72851c858d 100644 --- a/xio/src/test/drivers/globus_xio_smtp.c +++ b/xio/src/test/drivers/globus_xio_smtp.c @@ -123,7 +123,7 @@ globus_l_xio_smtp_attr_cntl( if(cmd == 1) { to_addr = (char *) va_arg(ap, char *); - sprintf(info->to_address, "%s", to_addr); + sprintf(info->to_address, "%s", to_addr); } return GLOBUS_SUCCESS; @@ -224,7 +224,7 @@ globus_l_xio_smtp_read_header_cb( { /* if we have not recieved the entire message repost */ info->read_offset += nbytes; - if(info->read_offset < 2 || + if(info->read_offset < 2 || info->message[info->read_offset - 2] != '\r' || info->message[info->read_offset - 1] != '\n') { @@ -274,7 +274,6 @@ globus_l_xio_smtp_write_header_cb( globus_size_t nbytes, void * user_arg) { - globus_result_t res; l_smtp_info_t * info; info = (l_smtp_info_t *) user_arg; @@ -291,7 +290,7 @@ globus_l_xio_smtp_write_header_cb( */ else { - res = globus_xio_driver_pass_read(op, &info->iovec, 1, + globus_xio_driver_pass_read(op, &info->iovec, 1, 1, globus_l_xio_smtp_read_header_cb, (void *) info); } } @@ -318,7 +317,7 @@ globus_l_xio_smtp_open_cb( { next_state(info, op); } -} +} static globus_result_t @@ -352,9 +351,9 @@ globus_l_xio_smtp_close_cb( globus_xio_operation_t op, globus_result_t result, void * user_arg) -{ +{ globus_xio_driver_finished_close(op, result); -} +} void globus_l_xio_smtp_write_close_cb( @@ -363,9 +362,7 @@ globus_l_xio_smtp_write_close_cb( globus_size_t nbytes, void * user_arg) { - globus_result_t res; - - res = globus_xio_driver_pass_close( + globus_xio_driver_pass_close( op, globus_l_xio_smtp_close_cb, user_arg); } @@ -515,7 +512,7 @@ globus_l_xio_smtp_activate(void) globus_l_return_address = globus_common_create_string("%s@%s", username, globus_l_hostname); - + if(rc == GLOBUS_SUCCESS) { GlobusXIORegisterDriver(smtp); diff --git a/xio/src/test/globus_utp_main.c b/xio/src/test/globus_utp_main.c index 698e4b318d..43f59d4671 100644 --- a/xio/src/test/globus_utp_main.c +++ b/xio/src/test/globus_utp_main.c @@ -45,7 +45,7 @@ Public functions for the Unnamed Timing Package (UTP). #include "globus_utp_private.h" /****************************************************************************** - Module activation structure + Module activation structure ******************************************************************************/ static int globus_l_utp_activate(void); @@ -54,7 +54,7 @@ static int globus_l_utp_deactivate(void); -globus_module_descriptor_t globus_i_utp_module = +globus_module_descriptor_t globus_i_utp_module = { "globus_utp", globus_l_utp_activate, @@ -64,7 +64,7 @@ globus_module_descriptor_t globus_i_utp_module = /****************************************************************************** - globus_utp module activation functions + globus_utp module activation functions ******************************************************************************/ static int @@ -72,14 +72,14 @@ globus_l_utp_activate(void) { if (globus_module_activate(GLOBUS_COMMON_MODULE) != GLOBUS_SUCCESS) { - return GLOBUS_FAILURE; + return GLOBUS_FAILURE; } /* Initialize some global variables */ globus_utp_attributes = GLOBUS_NULL; globus_utp_numTimers = 0; globus_utp_timers = GLOBUS_NULL; - + return GLOBUS_SUCCESS; } @@ -93,7 +93,7 @@ globus_l_utp_deactivate(void) globus_utp_Attribute_t *tmpAttr; rc = GLOBUS_SUCCESS; - + /* * Free up any storage */ @@ -101,18 +101,18 @@ globus_l_utp_deactivate(void) while (curAttr) { - tmpAttr = curAttr; - curAttr = curAttr->next; - globus_free(tmpAttr); + tmpAttr = curAttr; + curAttr = curAttr->next; + globus_free(tmpAttr); } globus_utp_attributes = GLOBUS_NULL; for (i = 0; i < globus_utp_numTimers; i++) { - if (globus_utp_timers[i].name) - { - globus_free(globus_utp_timers[i].name); - } + if (globus_utp_timers[i].name) + { + globus_free(globus_utp_timers[i].name); + } } globus_free(globus_utp_timers); globus_utp_numTimers = 0; @@ -123,11 +123,11 @@ globus_l_utp_deactivate(void) */ if (globus_module_deactivate(GLOBUS_COMMON_MODULE) != GLOBUS_SUCCESS) { - rc = GLOBUS_FAILURE; + rc = GLOBUS_FAILURE; } return rc; - + } @@ -137,53 +137,53 @@ Public UTP functions. int globus_utp_init(unsigned numTimers, int mode) { - unsigned i; - int sharingMode = mode & GLOBUS_UTP_MODE_SHARING_FIELD; - char hostnameBuff[MAXHOSTNAMELEN]; - time_t theTime; + unsigned i; + int sharingMode = mode & GLOBUS_UTP_MODE_SHARING_FIELD; + char hostnameBuff[MAXHOSTNAMELEN]; + time_t theTime; const char *username; - char theTimeStr[27]; - - if (sharingMode == GLOBUS_UTP_MODE_PRIVATE) - { - globus_utp_warn("globus_utp_init: mode GLOBUS_UTP_MODE_PRIVATE not yet " - "implemented"); - return 1; - } else if (sharingMode != GLOBUS_UTP_MODE_SHARED) - { - globus_utp_warn("globus_utp_init: invalid sharing mode %#X specified", - sharingMode); - return 1; - } - - if (!(globus_utp_timers = globus_malloc(numTimers * sizeof(globus_utp_Timer_t)))) - { - globus_utp_warn("globus_utp_init: globus_malloc() failed for timers"); - globus_utp_numTimers = 0; - return 1; - } - - globus_utp_numTimers = numTimers; - - /* This loop not only initializes every - field; by "touching" everything, it also - makes sure it is paged in. */ - for (i = 0; i < numTimers; i++) { - globus_utp_timers[i].state = GLOBUS_UTP_TIMER_STOPPED; - globus_utp_timeZero(&globus_utp_timers[i].startTime); - globus_utp_timeZero(&globus_utp_timers[i].accumulatedTime); - globus_utp_timers[i].numEvents = 0; - /* If name is still NULL when - globus_utp_write_file() is called, - globus_utp_DEFAULT_TIMER_NAME is printed. */ - globus_utp_timers[i].name = NULL; - } - - /* Make key/value linked list empty. */ - globus_utp_attributes = NULL; - - /* Set attributes for "user", "hostname", - and "timestamp". */ + char theTimeStr[27]; + + if (sharingMode == GLOBUS_UTP_MODE_PRIVATE) + { + globus_utp_warn("globus_utp_init: mode GLOBUS_UTP_MODE_PRIVATE not yet " + "implemented"); + return 1; + } else if (sharingMode != GLOBUS_UTP_MODE_SHARED) + { + globus_utp_warn("globus_utp_init: invalid sharing mode %#X specified", + sharingMode); + return 1; + } + + if (!(globus_utp_timers = globus_malloc(numTimers * sizeof(globus_utp_Timer_t)))) + { + globus_utp_warn("globus_utp_init: globus_malloc() failed for timers"); + globus_utp_numTimers = 0; + return 1; + } + + globus_utp_numTimers = numTimers; + + /* This loop not only initializes every + field; by "touching" everything, it also + makes sure it is paged in. */ + for (i = 0; i < numTimers; i++) { + globus_utp_timers[i].state = GLOBUS_UTP_TIMER_STOPPED; + globus_utp_timeZero(&globus_utp_timers[i].startTime); + globus_utp_timeZero(&globus_utp_timers[i].accumulatedTime); + globus_utp_timers[i].numEvents = 0; + /* If name is still NULL when + globus_utp_write_file() is called, + globus_utp_DEFAULT_TIMER_NAME is printed. */ + globus_utp_timers[i].name = NULL; + } + + /* Make key/value linked list empty. */ + globus_utp_attributes = NULL; + + /* Set attributes for "user", "hostname", + and "timestamp". */ # ifdef _WIN32 { @@ -198,31 +198,31 @@ int globus_utp_init(unsigned numTimers, int mode) struct passwd *passwdEntry; passwdEntry = getpwuid(getuid()); if (!passwdEntry) { - return 1; + return 1; } username = passwdEntry->pw_name; } - globus_utp_set_attribute("%s", "user", username); + globus_utp_set_attribute("%s", "user", username); #endif - if (globus_libc_gethostname(hostnameBuff, MAXHOSTNAMELEN)) { - /* globus_utp_warn("globus_utp_init: gethostname() failed; system error is " - "\"%s\"", sys_errlist[errno]); */ - return 1; - } - globus_utp_set_attribute("%s", "hostname", hostnameBuff); - - if ((theTime = time(NULL)) == (time_t) -1) { - /* globus_utp_warn("globus_utp_init: time(3) failed; system error is " - "\"%s\"", sys_errlist[errno]); */ - return 1; - } - strcpy(theTimeStr, ctime(&theTime)); - /* Remove trailing '\n'. */ - theTimeStr[strlen(theTimeStr) - 1] = 0; - globus_utp_set_attribute("%s", "timestamp", theTimeStr); - - return 0; + if (globus_libc_gethostname(hostnameBuff, MAXHOSTNAMELEN)) { + /* globus_utp_warn("globus_utp_init: gethostname() failed; system error is " + "\"%s\"", sys_errlist[errno]); */ + return 1; + } + globus_utp_set_attribute("%s", "hostname", hostnameBuff); + + if ((theTime = time(NULL)) == (time_t) -1) { + /* globus_utp_warn("globus_utp_init: time(3) failed; system error is " + "\"%s\"", sys_errlist[errno]); */ + return 1; + } + strcpy(theTimeStr, ctime(&theTime)); + /* Remove trailing '\n'. */ + theTimeStr[strlen(theTimeStr) - 1] = 0; + globus_utp_set_attribute("%s", "timestamp", theTimeStr); + + return 0; } void @@ -235,306 +235,306 @@ globus_utp_write_file(const char *outFilename) if (!(outFile = fopen(outFilename, "w"))) { - /* globus_utp_warn("globus_utp_write_file: fopen() on file \"%s\" failed", - outFilename); - globus_utp_warn("globus_utp_write_file: system error message is \"%s\"", - sys_errlist[errno]); */ - return; + /* globus_utp_warn("globus_utp_write_file: fopen() on file \"%s\" failed", + outFilename); + globus_utp_warn("globus_utp_write_file: system error message is \"%s\"", + sys_errlist[errno]); */ + return; } curAttr = globus_utp_attributes; while (curAttr) { - globus_utp_Attribute_t *tmp = curAttr; - fprintf(outFile, "attribute\t\"%s\"\t\"%s\"\n", - curAttr->key, curAttr->value); - curAttr = curAttr->next; - globus_free(tmp->key); - globus_free(tmp->value); - globus_free(tmp); + globus_utp_Attribute_t *tmp = curAttr; + fprintf(outFile, "attribute\t\"%s\"\t\"%s\"\n", + curAttr->key, curAttr->value); + curAttr = curAttr->next; + globus_free(tmp->key); + globus_free(tmp->value); + globus_free(tmp); } globus_utp_attributes = NULL; for (i = 0; i < globus_utp_numTimers; i++) { - const char *name = globus_utp_timers[i].name; - - if (globus_utp_timers[i].state == GLOBUS_UTP_TIMER_RUNNING) - { - globus_utp_warn("globus_utp_write_file: timer %d still running", - i); - globus_utp_stop_timer(i); - } - - globus_utp_timeToString(buff, - &globus_utp_timers[i].accumulatedTime); - - fprintf(outFile, "timer\t%u\t%s\t%lu\t\"%s\"\n", - (unsigned) i, - buff, - globus_utp_timers[i].numEvents, - name ? name : GLOBUS_UTP_DEFAULT_TIMER_NAME); + const char *name = globus_utp_timers[i].name; + + if (globus_utp_timers[i].state == GLOBUS_UTP_TIMER_RUNNING) + { + globus_utp_warn("globus_utp_write_file: timer %d still running", + i); + globus_utp_stop_timer(i); + } + + globus_utp_timeToString(buff, + &globus_utp_timers[i].accumulatedTime); + + fprintf(outFile, "timer\t%u\t%s\t%lu\t\"%s\"\n", + (unsigned) i, + buff, + globus_utp_timers[i].numEvents, + name ? name : GLOBUS_UTP_DEFAULT_TIMER_NAME); } if (fclose(outFile)) { - /* globus_utp_warn("globus_utp_write_file: fclose() on file \"%s\" failed", - outFilename); - globus_utp_warn("globus_utp_write_file: system error message is \"%s\"", - sys_errlist[errno]); */ - return; + /* globus_utp_warn("globus_utp_write_file: fclose() on file \"%s\" failed", + outFilename); + globus_utp_warn("globus_utp_write_file: system error message is \"%s\"", + sys_errlist[errno]); */ + return; } } void globus_utp_set_attribute(const char *keyStr, const char *keyArg, - const char *valueStr, ...) + const char *valueStr, ...) { - globus_utp_Attribute_t *newAttr; /* New key/value pair. */ - globus_utp_Attribute_t **lastNext; /* Final "next" pointer in list. */ - char *newKey = globus_malloc(sizeof(char) * GLOBUS_UTP_MAX_NAME_LENGTH); - char *newValue = globus_malloc(sizeof(char) * GLOBUS_UTP_MAX_NAME_LENGTH); - va_list ap; - - if (!newKey || !newValue) { - globus_utp_warn("globus_utp_set_attribute: globus_malloc() failed"); - return; - } - sprintf(newKey, keyStr, keyArg); /* Compute new key. */ - va_start(ap, valueStr); /* Compute new value. */ - vsprintf(newValue, valueStr, ap); - - newAttr = globus_utp_attributes; - lastNext = &globus_utp_attributes; - /* Search for same key in list. */ - while (newAttr && strcmp(newAttr->key, newKey) != 0) { - lastNext = &newAttr->next; - newAttr = newAttr->next; - } - - if (newAttr) { /* Key already exists in list. */ - /* Just replace the old value. */ - strcpy(newAttr->value, newValue); - globus_free(newKey); - globus_free(newValue); - return; - } - - /* Add new key/value pair to list. */ - *lastNext = newAttr = globus_malloc(sizeof(globus_utp_Attribute_t)); - if (!newAttr) { - globus_utp_warn("globus_utp_set_attribute: globus_malloc() failed"); - return; - } - newAttr->key = newKey; - newAttr->value = newValue; - newAttr->next = NULL; + globus_utp_Attribute_t *newAttr; /* New key/value pair. */ + globus_utp_Attribute_t **lastNext; /* Final "next" pointer in list. */ + char *newKey = globus_malloc(sizeof(char) * GLOBUS_UTP_MAX_NAME_LENGTH); + char *newValue = globus_malloc(sizeof(char) * GLOBUS_UTP_MAX_NAME_LENGTH); + va_list ap; + + if (!newKey || !newValue) { + globus_utp_warn("globus_utp_set_attribute: globus_malloc() failed"); + return; + } + sprintf(newKey, keyStr, keyArg); /* Compute new key. */ + va_start(ap, valueStr); /* Compute new value. */ + vsprintf(newValue, valueStr, ap); + + newAttr = globus_utp_attributes; + lastNext = &globus_utp_attributes; + /* Search for same key in list. */ + while (newAttr && strcmp(newAttr->key, newKey) != 0) { + lastNext = &newAttr->next; + newAttr = newAttr->next; + } + + if (newAttr) { /* Key already exists in list. */ + /* Just replace the old value. */ + strcpy(newAttr->value, newValue); + globus_free(newKey); + globus_free(newValue); + return; + } + + /* Add new key/value pair to list. */ + *lastNext = newAttr = globus_malloc(sizeof(globus_utp_Attribute_t)); + if (!newAttr) { + globus_utp_warn("globus_utp_set_attribute: globus_malloc() failed"); + return; + } + newAttr->key = newKey; + newAttr->value = newValue; + newAttr->next = NULL; } /********************************************************************** -Timer state transition diagram. If timer is in "Current State", and +Timer state transition diagram. If timer is in "Current State", and "State Change Function" is called, result is either the indicated new state or "Invalid" (in which case globus_utp_warn() is called). - State Change Function + State Change Function Current -State start() stop() reset() disable() enable() -------- ------- ------ ------- --------- --------- -STOPPED RUNNING Invalid STOPPED DISABLED STOPPED +State start() stop() reset() disable() enable() +------- ------- ------ ------- --------- --------- +STOPPED RUNNING Invalid STOPPED DISABLED STOPPED -RUNNING Invalid STOPPED STOPPED Invalid RUNNING +RUNNING Invalid STOPPED STOPPED Invalid RUNNING -DISABLED DISABLED DISABLED DISABLED DISABLED STOPPED +DISABLED DISABLED DISABLED DISABLED DISABLED STOPPED **********************************************************************/ void globus_utp_start_timer(unsigned timerNumber) { - globus_utp_Timer_t *theTimer; + globus_utp_Timer_t *theTimer; - /* Don't compile run-time checks into fully-optimized - version of the library. */ + /* Don't compile run-time checks into fully-optimized + version of the library. */ #ifndef NDEBUG - if (timerNumber >= globus_utp_numTimers) { - globus_utp_warn("globus_utp_start_timer: illegal timer %d", - (int) timerNumber); - return; - } + if (timerNumber >= globus_utp_numTimers) { + globus_utp_warn("globus_utp_start_timer: illegal timer %d", + (int) timerNumber); + return; + } #endif /* #ifndef NDEBUG */ - theTimer = &globus_utp_timers[timerNumber]; - if (theTimer->state == GLOBUS_UTP_TIMER_DISABLED) - return; + theTimer = &globus_utp_timers[timerNumber]; + if (theTimer->state == GLOBUS_UTP_TIMER_DISABLED) + return; #ifndef NDEBUG - if (theTimer->state == GLOBUS_UTP_TIMER_RUNNING) { - globus_utp_warn("globus_utp_start_timer: timer %d already running", - (int) timerNumber); - return; - } + if (theTimer->state == GLOBUS_UTP_TIMER_RUNNING) { + globus_utp_warn("globus_utp_start_timer: timer %d already running", + (int) timerNumber); + return; + } #endif /* #ifndef NDEBUG */ - theTimer->state = GLOBUS_UTP_TIMER_RUNNING; - globus_utp_readTime(&theTimer->startTime); + theTimer->state = GLOBUS_UTP_TIMER_RUNNING; + globus_utp_readTime(&theTimer->startTime); } void globus_utp_stop_timer(unsigned timerNumber) { - globus_utp_Timer_t *theTimer; - globus_utp_TimeValue_t stopTime, elapsedTime; + globus_utp_Timer_t *theTimer; + globus_utp_TimeValue_t stopTime, elapsedTime; #ifndef NDEBUG - if (timerNumber >= globus_utp_numTimers) { - globus_utp_warn("globus_utp_stop_timer: illegal timer %d", - (int) timerNumber); - return; - } + if (timerNumber >= globus_utp_numTimers) { + globus_utp_warn("globus_utp_stop_timer: illegal timer %d", + (int) timerNumber); + return; + } #endif /* #ifndef NDEBUG */ - theTimer = &globus_utp_timers[timerNumber]; - if (theTimer->state == GLOBUS_UTP_TIMER_DISABLED) - return; + theTimer = &globus_utp_timers[timerNumber]; + if (theTimer->state == GLOBUS_UTP_TIMER_DISABLED) + return; #ifndef NDEBUG - if (theTimer->state == GLOBUS_UTP_TIMER_STOPPED) { - globus_utp_warn("globus_utp_stop_timer: timer %d not running", - (int) timerNumber); - return; - } + if (theTimer->state == GLOBUS_UTP_TIMER_STOPPED) { + globus_utp_warn("globus_utp_stop_timer: timer %d not running", + (int) timerNumber); + return; + } #endif /* #ifndef NDEBUG */ - theTimer->state = GLOBUS_UTP_TIMER_STOPPED; - globus_utp_readTime(&stopTime); - globus_utp_timeDifference(&elapsedTime, &theTimer->startTime, &stopTime); - globus_utp_timeAdd(&theTimer->accumulatedTime, &elapsedTime); - theTimer->numEvents++; + theTimer->state = GLOBUS_UTP_TIMER_STOPPED; + globus_utp_readTime(&stopTime); + globus_utp_timeDifference(&elapsedTime, &theTimer->startTime, &stopTime); + globus_utp_timeAdd(&theTimer->accumulatedTime, &elapsedTime); + theTimer->numEvents++; } void globus_utp_reset_timer(unsigned timerNumber) { - globus_utp_Timer_t *theTimer; + globus_utp_Timer_t *theTimer; #ifndef NDEBUG - if (timerNumber >= globus_utp_numTimers) { - globus_utp_warn("globus_utp_reset_timer: illegal timer %d", - (int) timerNumber); - return; - } + if (timerNumber >= globus_utp_numTimers) { + globus_utp_warn("globus_utp_reset_timer: illegal timer %d", + (int) timerNumber); + return; + } #endif /* #ifndef NDEBUG */ - theTimer = &globus_utp_timers[timerNumber]; - if (theTimer->state == GLOBUS_UTP_TIMER_DISABLED) - return; + theTimer = &globus_utp_timers[timerNumber]; + if (theTimer->state == GLOBUS_UTP_TIMER_DISABLED) + return; - theTimer->state = GLOBUS_UTP_TIMER_STOPPED; - globus_utp_timeZero(&theTimer->startTime); - globus_utp_timeZero(&theTimer->accumulatedTime); - theTimer->numEvents = 0; + theTimer->state = GLOBUS_UTP_TIMER_STOPPED; + globus_utp_timeZero(&theTimer->startTime); + globus_utp_timeZero(&theTimer->accumulatedTime); + theTimer->numEvents = 0; } void globus_utp_disable_timer(unsigned timerNumber) { - globus_utp_Timer_t *theTimer; + globus_utp_Timer_t *theTimer; #ifndef NDEBUG - if (timerNumber >= globus_utp_numTimers) { - globus_utp_warn("globus_utp_disable_timer: illegal timer %d", - (int) timerNumber); - return; - } + if (timerNumber >= globus_utp_numTimers) { + globus_utp_warn("globus_utp_disable_timer: illegal timer %d", + (int) timerNumber); + return; + } #endif /* #ifndef NDEBUG */ - theTimer = &globus_utp_timers[timerNumber]; + theTimer = &globus_utp_timers[timerNumber]; #ifndef NDEBUG - if (theTimer->state == GLOBUS_UTP_TIMER_RUNNING) { - globus_utp_warn("globus_utp_disable_timer: timer %d is running", - (int) timerNumber); - return; - } + if (theTimer->state == GLOBUS_UTP_TIMER_RUNNING) { + globus_utp_warn("globus_utp_disable_timer: timer %d is running", + (int) timerNumber); + return; + } #endif /* #ifndef NDEBUG */ - theTimer->state = GLOBUS_UTP_TIMER_DISABLED; + theTimer->state = GLOBUS_UTP_TIMER_DISABLED; } void globus_utp_enable_timer(unsigned timerNumber) { - globus_utp_Timer_t *theTimer; + globus_utp_Timer_t *theTimer; #ifndef NDEBUG - if (timerNumber >= globus_utp_numTimers) { - globus_utp_warn("globus_utp_disable_timer: illegal timer %d", - (int) timerNumber); - return; - } + if (timerNumber >= globus_utp_numTimers) { + globus_utp_warn("globus_utp_disable_timer: illegal timer %d", + (int) timerNumber); + return; + } #endif /* #ifndef NDEBUG */ - theTimer = &globus_utp_timers[timerNumber]; + theTimer = &globus_utp_timers[timerNumber]; - /* If STOPPED or RUNNING, already enabled. - Otherwise, can only get to DISABLED from - STOPPED, so go there. */ - if (theTimer->state == GLOBUS_UTP_TIMER_DISABLED) - theTimer->state = GLOBUS_UTP_TIMER_STOPPED; + /* If STOPPED or RUNNING, already enabled. + Otherwise, can only get to DISABLED from + STOPPED, so go there. */ + if (theTimer->state == GLOBUS_UTP_TIMER_DISABLED) + theTimer->state = GLOBUS_UTP_TIMER_STOPPED; } void globus_utp_disable_all_timers(void) { - unsigned i; + unsigned i; - for (i = 0; i < globus_utp_numTimers; i++) - globus_utp_disable_timer(i); + for (i = 0; i < globus_utp_numTimers; i++) + globus_utp_disable_timer(i); } void globus_utp_enable_all_timers(void) { - unsigned i; + unsigned i; - for (i = 0; i < globus_utp_numTimers; i++) - globus_utp_enable_timer(i); + for (i = 0; i < globus_utp_numTimers; i++) + globus_utp_enable_timer(i); } const char * globus_utp_name_timer(unsigned timerNumber, const char *nameStr, ...) { - char *name; - va_list ap; + char *name; + va_list ap; #ifndef NDEBUG - if (timerNumber >= globus_utp_numTimers) { - globus_utp_warn("globus_utp_name_timer: illegal timer %d", - (int) timerNumber); - return NULL; - } + if (timerNumber >= globus_utp_numTimers) { + globus_utp_warn("globus_utp_name_timer: illegal timer %d", + (int) timerNumber); + return NULL; + } #endif /* #ifndef NDEBUG */ - if (!(name = globus_malloc(sizeof(char) * GLOBUS_UTP_MAX_NAME_LENGTH))) { - globus_utp_warn("globus_utp_name_timer: globus_malloc() failed"); - return NULL; - } + if (!(name = globus_malloc(sizeof(char) * GLOBUS_UTP_MAX_NAME_LENGTH))) { + globus_utp_warn("globus_utp_name_timer: globus_malloc() failed"); + return NULL; + } - va_start(ap, nameStr); - vsprintf(name, nameStr, ap); - globus_utp_timers[timerNumber].name = name; + va_start(ap, nameStr); + vsprintf(name, nameStr, ap); + globus_utp_timers[timerNumber].name = name; - return name; + return name; } void globus_utp_get_accum_time(unsigned timerNumber, double *time, int *precision) { - globus_utp_Timer_t *theTimer; + globus_utp_Timer_t *theTimer; #ifndef NDEBUG - if (timerNumber >= globus_utp_numTimers) { - globus_utp_warn("globus_utp_get_accum_time: illegal timer %d", - (int) timerNumber); - return; - } + if (timerNumber >= globus_utp_numTimers) { + globus_utp_warn("globus_utp_get_accum_time: illegal timer %d", + (int) timerNumber); + return; + } #endif /* #ifndef NDEBUG */ - theTimer = &globus_utp_timers[timerNumber]; + theTimer = &globus_utp_timers[timerNumber]; - globus_utp_timeToDouble(time, precision, &theTimer->accumulatedTime); + globus_utp_timeToDouble(time, precision, &theTimer->accumulatedTime); } @@ -542,30 +542,32 @@ globus_utp_get_accum_time(unsigned timerNumber, double *time, int *precision) Private UTP functions. **********************************************************************/ - /* Use external assembler routine for RS6000 by - default, unless RS6000_GETTIMER is defined. */ + /* Use external assembler routine for RS6000 by + default, unless RS6000_GETTIMER is defined. */ #if !defined(RS6000) || (defined(RS6000) && defined(RS6000_GETTIMER)) void globus_utp_readTime(globus_utp_TimeValue_t *tv) { #ifdef UNIX - int flag; +#ifdef DEBUG + int flag; - flag = gettimeofday(tv, NULL); + flag = gettimeofday(tv, NULL); -#ifdef DEBUG - if (flag) { - globus_utp_warn("globus_utp_readTime: gettimeofday() failed"); - globus_utp_warn("globus_utp_readTime: system error message is \"%s\"", - sys_errlist[errno]); - } + if (flag) { + globus_utp_warn("globus_utp_readTime: gettimeofday() failed"); + globus_utp_warn("globus_utp_readTime: system error message is \"%s\"", + sys_errlist[errno]); + } +#else + gettimeofday(tv, NULL); #endif /* #ifdef DEBUG */ #endif /* #ifdef UNIX */ #ifdef SOLHR - *tv = gethrtime(); + *tv = gethrtime(); #endif #ifdef RS6000 @@ -577,95 +579,97 @@ on p. 59 of the "Optimizing and Tuning Guide for FORTRAN, C, and C++", and seems to work just fine. */ - int flag; +#ifdef DEBUG + int flag; - flag = gettimer(TIMEOFDAY, tv); + flag = gettimer(TIMEOFDAY, tv); -#ifdef DEBUG - if (flag) { - globus_utp_warn("globus_utp_readTime: gettimer() failed"); - globus_utp_warn("globus_utp_readTime: system error message is \"%s\"", - sys_errlist[errno]); - } + if (flag) { + globus_utp_warn("globus_utp_readTime: gettimer() failed"); + globus_utp_warn("globus_utp_readTime: system error message is \"%s\"", + sys_errlist[errno]); + } +#else + gettimer(TIMEOFDAY, tv); #endif /* #ifdef DEBUG */ #endif /* #ifdef RS6000 */ #ifdef PARAGON - *tv = dclock(); -#endif /* #ifdef PARAGON */ + *tv = dclock(); +#endif /* #ifdef PARAGON */ } -#endif /* #if !defined(RS6000) || .... */ +#endif /* #if !defined(RS6000) || .... */ void globus_utp_timeDifference(globus_utp_TimeValue_t *diff, const globus_utp_TimeValue_t *start, - const globus_utp_TimeValue_t *end) + const globus_utp_TimeValue_t *end) { #ifdef UNIX - diff->tv_sec = end->tv_sec - start->tv_sec; + diff->tv_sec = end->tv_sec - start->tv_sec; - if (end->tv_usec < start->tv_usec) { - diff->tv_sec--; /* "Borrow" from seconds. */ - diff->tv_usec = 1000000 + end->tv_usec - start->tv_usec; - } else - diff->tv_usec = end->tv_usec - start->tv_usec; + if (end->tv_usec < start->tv_usec) { + diff->tv_sec--; /* "Borrow" from seconds. */ + diff->tv_usec = 1000000 + end->tv_usec - start->tv_usec; + } else + diff->tv_usec = end->tv_usec - start->tv_usec; #endif /* #ifdef UNIX */ #ifdef RS6000 - diff->tv_sec = end->tv_sec - start->tv_sec; + diff->tv_sec = end->tv_sec - start->tv_sec; - if (end->tv_nsec < start->tv_nsec) { - diff->tv_sec--; /* "Borrow" from seconds. */ - diff->tv_nsec = 1000000000 + end->tv_nsec - start->tv_nsec; - } else - diff->tv_nsec = end->tv_nsec - start->tv_nsec; + if (end->tv_nsec < start->tv_nsec) { + diff->tv_sec--; /* "Borrow" from seconds. */ + diff->tv_nsec = 1000000000 + end->tv_nsec - start->tv_nsec; + } else + diff->tv_nsec = end->tv_nsec - start->tv_nsec; #endif /* #ifdef RS6000 */ #ifdef SOLHR - *diff = *end - *start; + *diff = *end - *start; #endif #ifdef PARAGON - *diff = *end - *start; -#endif /* #ifdef PARAGON */ + *diff = *end - *start; +#endif /* #ifdef PARAGON */ } void globus_utp_timeAdd(globus_utp_TimeValue_t *oldElapsed, - const globus_utp_TimeValue_t *newElapsed) + const globus_utp_TimeValue_t *newElapsed) { #ifdef UNIX - oldElapsed->tv_usec += newElapsed->tv_usec; + oldElapsed->tv_usec += newElapsed->tv_usec; - if (oldElapsed->tv_usec >= 1000000) { - oldElapsed->tv_sec++; /* "Carry" into seconds. */ - oldElapsed->tv_usec -= 1000000; - } + if (oldElapsed->tv_usec >= 1000000) { + oldElapsed->tv_sec++; /* "Carry" into seconds. */ + oldElapsed->tv_usec -= 1000000; + } - oldElapsed->tv_sec += newElapsed->tv_sec; + oldElapsed->tv_sec += newElapsed->tv_sec; #endif /* #ifdef UNIX */ #ifdef RS6000 - oldElapsed->tv_nsec += newElapsed->tv_nsec; + oldElapsed->tv_nsec += newElapsed->tv_nsec; - if (oldElapsed->tv_nsec >= 1000000000) { - oldElapsed->tv_sec++; /* "Carry" into seconds. */ - oldElapsed->tv_nsec -= 1000000000; - } + if (oldElapsed->tv_nsec >= 1000000000) { + oldElapsed->tv_sec++; /* "Carry" into seconds. */ + oldElapsed->tv_nsec -= 1000000000; + } - oldElapsed->tv_sec += newElapsed->tv_sec; + oldElapsed->tv_sec += newElapsed->tv_sec; #endif /* #ifdef RS6000 */ #ifdef SOLHR - *oldElapsed += *newElapsed; + *oldElapsed += *newElapsed; #endif #ifdef PARAGON - *oldElapsed += *newElapsed; -#endif /* #ifdef PARAGON */ + *oldElapsed += *newElapsed; +#endif /* #ifdef PARAGON */ } @@ -673,22 +677,22 @@ void globus_utp_timeZero(globus_utp_TimeValue_t *tv) { #ifdef UNIX - tv->tv_sec = 0; - tv->tv_usec = 0; + tv->tv_sec = 0; + tv->tv_usec = 0; #endif /* #ifdef UNIX */ #ifdef RS6000 - tv->tv_sec = 0; - tv->tv_nsec = 0; + tv->tv_sec = 0; + tv->tv_nsec = 0; #endif /* #ifdef RS6000 */ #ifdef SOLHR - *tv = 0; + *tv = 0; #endif #ifdef PARAGON - *tv = 0.0; -#endif /* #ifdef PARAGON */ + *tv = 0.0; +#endif /* #ifdef PARAGON */ } @@ -696,37 +700,37 @@ void globus_utp_timeToDouble(double *time, int *precision, const globus_utp_TimeValue_t *tv) { #ifdef UNIX - *time = (double) tv->tv_sec + ((double) tv->tv_usec) / 1000000.0; - *precision = 6; + *time = (double) tv->tv_sec + ((double) tv->tv_usec) / 1000000.0; + *precision = 6; #endif /* #ifdef UNIX */ #ifdef RS6000 - *time = (double) tv->tv_sec + ((double) tv->tv_nsec) / - 1000000000.0; - *precision = 7; + *time = (double) tv->tv_sec + ((double) tv->tv_nsec) / + 1000000000.0; + *precision = 7; #endif /* #ifdef RS6000 */ #ifdef SOLHR - *time = ((double)*tv) / 1000000000.0; - *precision = 6; + *time = ((double)*tv) / 1000000000.0; + *precision = 6; #endif #ifdef PARAGON - *time = *tv; - *precision = 7; -#endif /* #ifdef PARAGON */ + *time = *tv; + *precision = 7; +#endif /* #ifdef PARAGON */ } void globus_utp_timeToString(char timeString[], const globus_utp_TimeValue_t *tv) { - double tvAsDouble; - int precision; + double tvAsDouble; + int precision; - globus_utp_timeToDouble(&tvAsDouble, &precision, tv); + globus_utp_timeToDouble(&tvAsDouble, &precision, tv); - sprintf(timeString, "%.*f", precision, tvAsDouble); + sprintf(timeString, "%.*f", precision, tvAsDouble); } @@ -735,13 +739,13 @@ globus_utp_warn(const char *messageStr, ...) { # if defined(DEBUG) { - va_list ap; + va_list ap; - va_start(ap, messageStr); + va_start(ap, messageStr); - vfprintf(stderr, messageStr, ap); - fprintf(stderr, "\n"); - fflush(stderr); /* Just to be safe. */ + vfprintf(stderr, messageStr, ap); + fprintf(stderr, "\n"); + fflush(stderr); /* Just to be safe. */ } # endif } diff --git a/xio/src/test/http_timeout_test.c b/xio/src/test/http_timeout_test.c index a1a4ed635f..d5335a7b09 100644 --- a/xio/src/test/http_timeout_test.c +++ b/xio/src/test/http_timeout_test.c @@ -108,7 +108,6 @@ main( { 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; @@ -314,12 +313,12 @@ main( server_timeout_info.handle = NULL; server_timeout_info.result = GLOBUS_SUCCESS; server_timeout_info.contact = NULL; - result = globus_xio_server_create( + globus_xio_server_create( &server_timeout_info.server, server_timeout_info.attr, globus_l_http_stack); - result = globus_xio_server_get_contact_string( + globus_xio_server_get_contact_string( server_timeout_info.server, &contact); @@ -333,19 +332,19 @@ main( client_timeout_info.result = GLOBUS_SUCCESS; client_timeout_info.server = NULL; - result = globus_xio_handle_create( + globus_xio_handle_create( &client_timeout_info.handle, globus_l_http_stack); /* oneshot to start server state machine */ - result = globus_callback_register_oneshot( + 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( + globus_callback_register_oneshot( NULL, &globus_i_reltime_zero, state_machine, @@ -534,7 +533,6 @@ state_machine( void * user_arg) { globus_reltime_t delay; - globus_result_t result; globus_l_timeout_info_t * info = user_arg; /* If the timeout is to be caused by this side of the transfer, then check @@ -568,14 +566,14 @@ state_machine( { case GLOBUS_XIO_OPERATION_TYPE_ACCEPT: globus_assert(info->server); - result = globus_xio_server_register_accept( + globus_xio_server_register_accept( info->server, accept_callback, info); break; case GLOBUS_XIO_OPERATION_TYPE_OPEN: - result = globus_xio_register_open( + globus_xio_register_open( info->handle, info->contact, info->attr, @@ -584,7 +582,7 @@ state_machine( break; case GLOBUS_XIO_OPERATION_TYPE_READ: - result = globus_xio_register_read( + globus_xio_register_read( info->handle, info->buffer, sizeof(info->buffer), @@ -597,7 +595,7 @@ state_machine( case GLOBUS_XIO_OPERATION_TYPE_WRITE: strcpy((char *) info->buffer, "ok\n"); - result = globus_xio_register_write( + globus_xio_register_write( info->handle, info->buffer, strlen((char *) info->buffer), @@ -608,7 +606,7 @@ state_machine( break; case GLOBUS_XIO_OPERATION_TYPE_CLOSE: - result = globus_xio_register_close( + globus_xio_register_close( info->handle, NULL, open_close_callback, diff --git a/xio/xioperf/source/configure.ac b/xio/xioperf/source/configure.ac index 249f5a42f9..b4f9191378 100644 --- a/xio/xioperf/source/configure.ac +++ b/xio/xioperf/source/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ([2.60]) -AC_INIT([globus_xioperf], [5.1],[https://github.com/gridcf/gct/issues]) +AC_INIT([globus_xioperf], [5.2],[https://github.com/gridcf/gct/issues]) AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_AUX_DIR([build-aux]) AM_INIT_AUTOMAKE([1.11 foreign parallel-tests tar-pax]) diff --git a/xio/xioperf/source/globus_i_xioperf_opts.c b/xio/xioperf/source/globus_i_xioperf_opts.c index 616e28e701..1fd9eb1ca6 100644 --- a/xio/xioperf/source/globus_i_xioperf_opts.c +++ b/xio/xioperf/source/globus_i_xioperf_opts.c @@ -300,9 +300,6 @@ xioperf_l_opts_bandwidth( int * out_parms_used) { GlobusXIOPerfFuncName(xioperf_l_opts_bandwidth); - globus_i_xioperf_info_t * info; - - info = (globus_i_xioperf_info_t *) arg; *out_parms_used = 0; return GlobusXIOPerfError( @@ -539,39 +536,39 @@ globus_options_entry_t globus_i_xioperf_opts_table[] = "format to report: Kbits, Mbits, Gbits, KBytes, MBytes, GBytes", 1, xioperf_l_opts_format}, {"interval", "i", NULL, "#", - "seconds between periodic bandwidth reports", + "seconds between periodic bandwidth reports", 1, xio_perf_l_opts_interval}, {"quiet", "q", NULL, NULL, - "only output |