int globus_fifo_enqueue( globus_fifo_t * fifo, void * datum) { int err; struct globus_fifo_s * s_fifo; if (fifo==GLOBUS_NULL) return -1; s_fifo = *fifo; if(s_fifo==GLOBUS_NULL) return -1; if(s_fifo->tail==GLOBUS_NULL) { err = globus_list_insert ( (globus_list_t **) &(s_fifo->tail), datum); s_fifo->head = s_fifo->tail; } else { err = globus_list_insert (globus_list_rest_ref (s_fifo->tail), datum); s_fifo->tail = globus_list_rest (s_fifo->tail); } if(!err) { s_fifo->size++; } return err; }
static int globus_l_usage_stats_split_targets( const char * targets_string, globus_list_t ** targets) { char * tmpstr; char * target; char * ptr; if(targets_string == NULL) { return -1; } tmpstr = globus_libc_strdup(targets_string); target = tmpstr; while((ptr = strchr(target, ',')) != NULL || (ptr = strchr(target, ' ')) != NULL) { *ptr = '\0'; globus_list_insert(targets, globus_libc_strdup(target)); target = ptr + 1; } if(ptr == NULL) { globus_list_insert(targets, globus_libc_strdup(target)); } globus_free(tmpstr); return 0; }
globus_result_t globus_xio_attr_init( globus_xio_attr_t * attr) { globus_result_t res; globus_i_xio_attr_t * xio_attr; GlobusXIOName(globus_xio_attr_init); GlobusXIODebugEnter(); if(attr == NULL) { res = GlobusXIOErrorParameter("attr"); goto err; } /* allocate the attr */ xio_attr = (globus_i_xio_attr_t *) globus_calloc(sizeof(globus_i_xio_attr_t), 1); if(xio_attr == NULL) { res = GlobusXIOErrorMemory("attr"); goto err; } xio_attr->entry = (globus_i_xio_attr_ent_t *) globus_calloc(sizeof(globus_i_xio_attr_ent_t) * GLOBUS_XIO_ATTR_ARRAY_BASE_SIZE, 1); if(xio_attr->entry == NULL) { *attr = GLOBUS_NULL; globus_free(xio_attr); res = GlobusXIOErrorMemory("attr->entry"); goto err; } /* zero it out */ xio_attr->max = GLOBUS_XIO_ATTR_ARRAY_BASE_SIZE; xio_attr->space = GLOBUS_CALLBACK_GLOBAL_SPACE; globus_mutex_lock(&globus_i_xio_mutex); { globus_list_insert(&globus_i_xio_outstanding_attrs_list, xio_attr); } globus_mutex_unlock(&globus_i_xio_mutex); *attr = xio_attr; GlobusXIODebugExit(); return GLOBUS_SUCCESS; err: GlobusXIODebugExitWithError(); return res; }
void globus_i_gass_transfer_keyvalue_insert( globus_list_t ** list, char * key, char * value) { globus_gass_transfer_keyvalue_t * kv; kv = globus_malloc(sizeof(globus_gass_transfer_keyvalue_t)); kv->key = key; kv->value = value; globus_list_insert(list, kv); }
/** * Add default values to RSL and verify required parameters * * Inserts default values to RSL when an RSL parameter is not defined * in it. After this is complete, it checks that all RSL parameters * with the "required_when" flag set are present in the RSL tree. * * @param request * Request which contains the RSL tree to validate. * @param when * Which RSL validation time scope we will use to decide * whether to use the default values or not. */ static int globus_l_gram_job_manager_insert_default_rsl( globus_gram_jobmanager_request_t * request, globus_rsl_t * rsl, globus_gram_job_manager_validation_when_t when) { globus_rvf_record_t * record; globus_list_t ** attributes; globus_rsl_t * new_relation; char * new_relation_str; globus_list_t * validation_records; int rc = GLOBUS_SUCCESS; attributes = globus_rsl_boolean_get_operand_list_ref(rsl); validation_records = request->manager->validation_records; while(!globus_list_empty(validation_records)) { record = globus_list_first(validation_records); validation_records = globus_list_rest(validation_records); if(record->default_value && (record->default_when&when)) { if(!globus_l_gram_job_manager_attribute_exists( *attributes, record->attribute)) { new_relation_str = globus_common_create_string( "%s = %s", record->attribute, record->default_value); globus_gram_job_manager_request_log( request, GLOBUS_GRAM_JOB_MANAGER_LOG_TRACE, "event=gram.validate_rsl.info " "level=TRACE " "msg=\"Inserting default RSL for attribute\" " "attribute=%s " "default=\"%s\" " "\n", record->attribute, record->default_value); new_relation = globus_rsl_parse(new_relation_str); globus_list_insert(attributes, new_relation); free(new_relation_str); } } if(record->required_when & when) { if(!globus_l_gram_job_manager_attribute_exists( *attributes, record->attribute)) { rc = globus_l_gram_job_manager_missing_value_error( record->attribute); globus_gram_job_manager_request_log( request, GLOBUS_GRAM_JOB_MANAGER_LOG_ERROR, "event=gram.validate_rsl.end " "level=ERROR " "msg=\"RSL missing required attribute\" " "attribute=%s " "\n", record->attribute); return rc; } } } return rc; }
globus_result_t globus_net_manager_context_init( globus_net_manager_context_t * context, const globus_net_manager_attr_t * attrs) { globus_i_net_manager_context_t * ctx; globus_net_manager_attr_t * attr; globus_result_t result; int i; int j; int max_attr_count; int attrnum; char * current_scope = NULL; globus_i_net_manager_context_entry_t * ent = NULL; GlobusNetManagerName(globus_net_manager_context_init); if(context == NULL || attrs == NULL || attrs[0].scope == NULL) { result = GlobusNetManagerErrorParameter("No parameter may be NULL."); goto error_no_attr; } ctx = globus_calloc(1, sizeof(globus_i_net_manager_context_t)); if(ctx == NULL) { result = GlobusNetManagerErrorMemory("context"); goto error_ctx_mem; } for(max_attr_count = 0; attrs[max_attr_count].scope != NULL; max_attr_count++); for(i = 0; attrs[i].scope != NULL; i++) { /* start of a new manager entry */ if(strcmp(attrs[i].scope, "net_manager") == 0 && strcmp(attrs[i].name, "manager") == 0) { ent = NULL; attrnum = 0; current_scope = attrs[i].value; result = globus_l_net_manager_context_load_entry( attrs[i].value, &ent); if(result) { goto error_load; } ent->attrs = calloc( max_attr_count, sizeof(globus_net_manager_attr_t)); for(j = 0; attrs[j].scope != NULL; j++) { if(strcmp(attrs[j].scope, "global") == 0) { result = globus_net_manager_attr_init( &ent->attrs[attrnum++], attrs[j].scope, attrs[j].name, attrs[j].value); if(result) { goto error_attr; } } } ent->attrs[attrnum] = globus_net_manager_null_attr; globus_list_insert(&ctx->managers, ent); } /* attrs for the current manager entry */ else if(current_scope && strcmp(attrs[i].scope, current_scope) == 0) { result = globus_net_manager_attr_init( &ent->attrs[attrnum++], attrs[i].scope, attrs[i].name, attrs[i].value); if(result) { goto error_attr; } ent->attrs[attrnum] = globus_net_manager_null_attr; } /* unrelated scope */ else { ent = NULL; attrnum = 0; current_scope = attrs[i].value; } } *context = ctx; return GLOBUS_SUCCESS; error_attr: error_load: free(ctx); error_ctx_mem: error_no_attr: if (context) { *context = NULL; } return result; }
static int globus_l_gram_job_manager_staging_add_pair( globus_gram_jobmanager_request_t * request, globus_rsl_value_t * from, globus_rsl_value_t * to, const char * type) { int rc; globus_gram_job_manager_staging_info_t * info; info = calloc( 1, sizeof(globus_gram_job_manager_staging_info_t)); if(!info) { rc = GLOBUS_GRAM_PROTOCOL_ERROR_MALLOC_FAILED; goto info_calloc_failed; } info->from = globus_rsl_value_copy_recursive(from); info->to = globus_rsl_value_copy_recursive(to); if(strcmp(type, GLOBUS_GRAM_PROTOCOL_FILE_STAGE_IN_PARAM) == 0) { info->type = GLOBUS_GRAM_JOB_MANAGER_STAGE_IN; } else if(strcmp(type, GLOBUS_GRAM_PROTOCOL_FILE_STAGE_IN_SHARED_PARAM)== 0) { info->type = GLOBUS_GRAM_JOB_MANAGER_STAGE_IN_SHARED; } else if(strcmp(type, GLOBUS_GRAM_PROTOCOL_FILE_STAGE_OUT_PARAM) == 0) { info->type = GLOBUS_GRAM_JOB_MANAGER_STAGE_OUT; } else if (strcmp(type, "filestreamout") == 0) { info->type = GLOBUS_GRAM_JOB_MANAGER_STAGE_STREAMS; } rc = globus_gram_job_manager_rsl_evaluate_value( &request->symbol_table, info->from, &info->evaled_from); if(!info->evaled_from) { if(rc == GLOBUS_SUCCESS) { /* Not a literal after a successful eval */ switch(info->type) { case GLOBUS_GRAM_JOB_MANAGER_STAGE_IN: rc = GLOBUS_GRAM_PROTOCOL_ERROR_RSL_FILE_STAGE_IN; break; case GLOBUS_GRAM_JOB_MANAGER_STAGE_IN_SHARED: rc = GLOBUS_GRAM_PROTOCOL_ERROR_RSL_FILE_STAGE_IN_SHARED; break; case GLOBUS_GRAM_JOB_MANAGER_STAGE_OUT: rc = GLOBUS_GRAM_PROTOCOL_ERROR_RSL_FILE_STAGE_OUT; break; case GLOBUS_GRAM_JOB_MANAGER_STAGE_STREAMS: rc = GLOBUS_GRAM_PROTOCOL_ERROR_RSL_STDOUT; break; } } goto eval_from_failed; } rc = globus_gram_job_manager_rsl_evaluate_value( &request->symbol_table, info->to, &info->evaled_to); if(!info->evaled_to) { if(rc == GLOBUS_SUCCESS) { /* Not a literal after a successful eval */ switch(info->type) { case GLOBUS_GRAM_JOB_MANAGER_STAGE_IN: rc = GLOBUS_GRAM_PROTOCOL_ERROR_RSL_FILE_STAGE_IN; break; case GLOBUS_GRAM_JOB_MANAGER_STAGE_IN_SHARED: rc = GLOBUS_GRAM_PROTOCOL_ERROR_RSL_FILE_STAGE_IN_SHARED; break; case GLOBUS_GRAM_JOB_MANAGER_STAGE_OUT: rc = GLOBUS_GRAM_PROTOCOL_ERROR_RSL_FILE_STAGE_OUT; break; case GLOBUS_GRAM_JOB_MANAGER_STAGE_STREAMS: rc = GLOBUS_GRAM_PROTOCOL_ERROR_RSL_STDOUT; break; } } goto eval_to_failed; } switch(info->type) { case GLOBUS_GRAM_JOB_MANAGER_STAGE_IN: globus_list_insert(&request->stage_in_todo, info); break; case GLOBUS_GRAM_JOB_MANAGER_STAGE_IN_SHARED: globus_list_insert(&request->stage_in_shared_todo, info); break; case GLOBUS_GRAM_JOB_MANAGER_STAGE_OUT: globus_list_insert(&request->stage_out_todo, info); break; case GLOBUS_GRAM_JOB_MANAGER_STAGE_STREAMS: if (strcmp(info->evaled_to, "/dev/null") == 0) { globus_rsl_value_free_recursive(info->from); globus_rsl_value_free_recursive(info->to); free(info->evaled_from); free(info->evaled_to); free(info); } else { globus_list_insert(&request->stage_stream_todo, info); } break; } return GLOBUS_SUCCESS; eval_to_failed: free(info->evaled_from); eval_from_failed: free(info); info_calloc_failed: return rc; }
/** * Read a list of staging pairs from the state file * * @param request * Job request associated with the state file (used for * RSL evaluation) * @param fp * State file opened for reading * @param buffer * Buffer containing the state file data * @param staging_type * Type of staging list to read * @param staging_list * List to insert the staging work into. * * @retval GLOBUS_SUCCESS * Success * @retval GLOBUS_GRAM_PROTOCOL_ERROR_READING_STATE_FILE * Error reading state file * @retval GLOBUS_GRAM_PROTOCOL_ERROR_MALLOC_FAILED * Out of memory */ static int globus_l_gram_staging_list_read_state( globus_gram_jobmanager_request_t * request, FILE * fp, char * buffer, globus_gram_job_manager_staging_type_t staging_type, globus_list_t ** staging_list) { int rc = GLOBUS_SUCCESS; int i, tmp_list_size; globus_gram_job_manager_staging_info_t * info; if (fscanf(fp, "%[^\n]%*c", buffer) < 1) { rc = GLOBUS_GRAM_PROTOCOL_ERROR_READING_STATE_FILE; goto out; } tmp_list_size = atoi(buffer); for(i = 0; i < tmp_list_size; i++) { info = calloc( 1, sizeof(globus_gram_job_manager_staging_info_t)); if (info == NULL) { rc = GLOBUS_GRAM_PROTOCOL_ERROR_MALLOC_FAILED; goto out; } info->type = staging_type; if(fscanf(fp, "%[^\n]%*c", buffer) < 1) { rc = GLOBUS_GRAM_PROTOCOL_ERROR_READING_STATE_FILE; goto free_info_out; } rc = globus_gram_job_manager_rsl_parse_value( buffer, &info->from); if (rc != GLOBUS_SUCCESS) { goto free_info_out; } if(fscanf(fp, "%[^\n]%*c", buffer) < 1) { rc = GLOBUS_GRAM_PROTOCOL_ERROR_READING_STATE_FILE; goto free_info_from_out; } rc = globus_gram_job_manager_rsl_parse_value( buffer, &info->to); if (rc != GLOBUS_SUCCESS) { goto free_info_from_out; } rc = globus_gram_job_manager_rsl_evaluate_value( &request->symbol_table, info->from, &info->evaled_from); if (rc != GLOBUS_SUCCESS) { goto free_info_to_out; } rc = globus_gram_job_manager_rsl_evaluate_value( &request->symbol_table, info->to, &info->evaled_to); if (rc != GLOBUS_SUCCESS) { goto free_info_evaled_from_out; } globus_list_insert(staging_list, info); } if (rc != GLOBUS_SUCCESS) { free_info_evaled_from_out: free(info->evaled_from); free_info_to_out: free(info->to); free_info_from_out: free(info->from); free_info_out: free(info); } out: return rc; }
globus_result_t globus_usage_stats_handle_init( globus_usage_stats_handle_t * handle, uint16_t code, uint16_t version, const char * targets) { globus_result_t result = GLOBUS_SUCCESS; #ifndef TARGET_ARCH_ARM globus_i_usage_stats_handle_t * new_handle; char * targets_env; globus_list_t * targets_list; char * contact; globus_sockaddr_t addr; int host[16]; int count; char hostname[255]; int rc = 0; int i; new_handle = globus_calloc(1, sizeof(globus_i_usage_stats_handle_t)); if(!new_handle) { return globus_error_put( globus_error_construct_error( GLOBUS_USAGE_MODULE, NULL, GLOBUS_USAGE_STATS_ERROR_TYPE_OOM, __FILE__, _globus_func_name, __LINE__, "Out of memory")); } new_handle->optout = getenv("GLOBUS_USAGE_OPTOUT"); if(new_handle->optout) { *handle = new_handle; return GLOBUS_SUCCESS; } globus_mutex_init(&new_handle->mutex, NULL); new_handle->inuse = GLOBUS_FALSE; new_handle->code = htons(code); new_handle->version = htons(version); memset(new_handle->data, 0, PACKET_SIZE); memcpy(new_handle->data + new_handle->data_length, (void *)&new_handle->code, 2); new_handle->data_length += 2; memcpy(new_handle->data + new_handle->data_length, (void *)&new_handle->version, 2); new_handle->data_length += 2; rc = globus_libc_gethostaddr(&addr); if(rc != 0) { return globus_error_put( globus_error_construct_error( GLOBUS_USAGE_MODULE, NULL, GLOBUS_USAGE_STATS_ERROR_TYPE_UNKNOWN_HOSTNAME, __FILE__, _globus_func_name, __LINE__, "Unable to get hostaddr.")); } result = globus_libc_addr_to_contact_string( &addr, GLOBUS_LIBC_ADDR_NUMERIC, &contact); if(result != GLOBUS_SUCCESS) { return result; } result = globus_libc_contact_string_to_ints( contact, host, &count, NULL); if(result != GLOBUS_SUCCESS) { return result; } globus_libc_free(contact); if(count == 4) { memset(new_handle->data + new_handle->data_length, 0, 12); new_handle->data_length += 12; } for (i = 0; i < count; i++) { new_handle->data[new_handle->data_length++] = (unsigned char) host[i]; } /* timestamp will go here */ new_handle->data_length += 4; if(globus_libc_gethostname(hostname, 255) == 0) { new_handle->data_length += sprintf((char *) new_handle->data + new_handle->data_length, "HOSTNAME=%s", hostname); } new_handle->header_length = new_handle->data_length; if(targets) { globus_l_usage_stats_split_targets(targets, &new_handle->targets); } else if((targets_env = getenv("GLOBUS_USAGE_TARGETS")) != NULL) { globus_l_usage_stats_split_targets( targets_env, &new_handle->targets); } else { globus_l_usage_stats_split_targets( GLOBUS_L_USAGE_STATS_DEFAULT_TARGETS, &new_handle->targets); } result = globus_xio_handle_create( &new_handle->xio_handle, globus_l_usage_stats_stack); if(result != GLOBUS_SUCCESS) { return result; } result = globus_xio_open( new_handle->xio_handle, NULL, NULL); if(result != GLOBUS_SUCCESS) { return result; } targets_list = new_handle->targets; while(targets_list) { globus_xio_data_descriptor_t * dd; dd = (globus_xio_data_descriptor_t *) globus_malloc( sizeof(globus_xio_data_descriptor_t)); result = globus_xio_data_descriptor_init( dd, new_handle->xio_handle); if(result != GLOBUS_SUCCESS) { return result; } result = globus_xio_data_descriptor_cntl( *dd, globus_l_usage_stats_udp_driver, GLOBUS_XIO_UDP_SET_CONTACT, (char *)globus_list_first(targets_list)); if(result != GLOBUS_SUCCESS) { goto exit; } globus_list_insert(&new_handle->xio_desc_list, dd); targets_list = globus_list_rest(targets_list); } *handle = new_handle; return GLOBUS_SUCCESS; exit: #endif return result; }
/* * globus_l_module_increment() */ static globus_bool_t globus_l_module_increment( 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; entry = 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; } } 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; } }
globus_result_t globus_xio_stack_push_driver( globus_xio_stack_t stack, globus_xio_driver_t driver) { globus_xio_driver_t p_d; globus_i_xio_stack_t * xio_stack; globus_result_t res = GLOBUS_SUCCESS; GlobusXIOName(globus_xio_stack_push_driver); GlobusXIODebugEnter(); if(stack == NULL) { res = GlobusXIOErrorParameter("stack"); goto err; } if(driver == NULL) { res = GlobusXIOErrorParameter("driver"); goto err; } xio_stack = (globus_i_xio_stack_t *) stack; /* if in the transport position and has a push stack */ if(driver->push_driver_func != NULL && xio_stack->pushing_driver != driver) { p_d = xio_stack->pushing_driver; xio_stack->pushing_driver = driver; res = driver->push_driver_func(driver, xio_stack); xio_stack->pushing_driver = p_d; if(res != GLOBUS_SUCCESS) { goto err; } } /* if a transport driver position */ else if(xio_stack->size == 0) { if(driver->transport_open_func == NULL) { res = GlobusXIOErrorInvalidDriver( _XIOSL("open function not defined")); goto err; } else { xio_stack->size++; globus_list_insert(&xio_stack->driver_stack, driver); } } else if(driver->transport_open_func != NULL) { res = GlobusXIOErrorInvalidDriver( _XIOSL("transport can only be at bottom of stack")); goto err; } else { xio_stack->size++; globus_list_insert(&xio_stack->driver_stack, driver); } GlobusXIODebugExit(); return GLOBUS_SUCCESS; err: GlobusXIODebugExitWithError(); return res; }
globus_result_t globus_xio_data_descriptor_init( globus_xio_data_descriptor_t * data_desc, globus_xio_handle_t handle) { globus_result_t res = GLOBUS_SUCCESS; globus_i_xio_op_t * op; globus_i_xio_context_t * context; GlobusXIOName(globus_xio_data_descriptor_init); GlobusXIODebugEnter(); if(data_desc == NULL) { res = GlobusXIOErrorParameter("data_desc"); goto err_parm; } if(handle == NULL) { res = GlobusXIOErrorParameter("handle"); goto err; } context = handle->context; globus_mutex_lock(&context->mutex); { GlobusXIOOperationCreate(op, context); if(op != NULL) { op->type = GLOBUS_XIO_OPERATION_TYPE_DD; handle->ref++; GlobusXIODebugPrintf( GLOBUS_XIO_DEBUG_INFO_VERBOSE, (_XIOSL("[globus_xio_data_descriptor_init] :: handle ref at %d.\n"), handle->ref)); op->_op_handle = handle; op->ref = 1; op->is_user_dd = GLOBUS_TRUE; } else { res = GlobusXIOErrorMemory("xio_dd"); } } globus_mutex_unlock(&context->mutex); if(res != GLOBUS_SUCCESS) { goto err; } *data_desc = op; globus_mutex_lock(&globus_i_xio_mutex); { globus_list_insert(&globus_i_xio_outstanding_dds_list, op); } globus_mutex_unlock(&globus_i_xio_mutex); GlobusXIODebugExit(); return GLOBUS_SUCCESS; err: *data_desc = NULL; err_parm: GlobusXIODebugExitWithError(); return res; }
globus_result_t globus_xio_attr_copy( globus_xio_attr_t * dst, globus_xio_attr_t src) { globus_i_xio_attr_t * xio_attr_src; globus_i_xio_attr_t * xio_attr_dst; globus_result_t res; int ctr; int ctr2; GlobusXIOName(globus_xio_attr_copy); GlobusXIODebugEnter(); if(dst == NULL) { res = GlobusXIOErrorParameter("dst"); goto err; } if(src == NULL) { res = GlobusXIOErrorParameter("src"); goto err; } xio_attr_src = src; xio_attr_dst = (globus_i_xio_attr_t *) globus_malloc(sizeof(globus_i_xio_attr_t)); /* check for memory alloc failure */ if(xio_attr_dst == NULL) { res = GlobusXIOErrorMemory("xio_attr_dst"); goto err; } memset(xio_attr_dst, 0, sizeof(globus_i_xio_attr_t)); xio_attr_dst->entry = (globus_i_xio_attr_ent_t *) globus_malloc(sizeof(globus_i_xio_attr_ent_t) * GLOBUS_XIO_ATTR_ARRAY_BASE_SIZE); if(xio_attr_dst->entry == NULL) { globus_free(xio_attr_dst); res = GlobusXIOErrorMemory("xio_attr_dst->entry"); goto err; } memset(xio_attr_dst->entry, 0, sizeof(globus_i_xio_attr_ent_t) * GLOBUS_XIO_ATTR_ARRAY_BASE_SIZE); /* copy all general attrs */ xio_attr_dst->max = xio_attr_src->max; xio_attr_dst->ndx = xio_attr_src->ndx; xio_attr_dst->space = xio_attr_src->space; globus_callback_space_reference(xio_attr_dst->space); xio_attr_dst->open_timeout_cb = xio_attr_src->open_timeout_cb; xio_attr_dst->open_timeout_period = xio_attr_src->open_timeout_period; xio_attr_dst->read_timeout_cb = xio_attr_src->read_timeout_cb; xio_attr_dst->read_timeout_period = xio_attr_src->read_timeout_period; xio_attr_dst->write_timeout_cb = xio_attr_src->write_timeout_cb; xio_attr_dst->write_timeout_period = xio_attr_src->write_timeout_period; xio_attr_dst->close_timeout_cb = xio_attr_src->close_timeout_cb; xio_attr_dst->close_timeout_period = xio_attr_src->close_timeout_period; xio_attr_dst->accept_timeout_cb = xio_attr_src->accept_timeout_cb; xio_attr_dst->accept_timeout_period = xio_attr_src->accept_timeout_period; xio_attr_dst->cancel_open = xio_attr_src->cancel_open; xio_attr_dst->cancel_close = xio_attr_src->cancel_close; xio_attr_dst->cancel_read = xio_attr_src->cancel_read; xio_attr_dst->cancel_write = xio_attr_src->cancel_write; xio_attr_dst->no_cancel = xio_attr_src->no_cancel; xio_attr_dst->timeout_arg = xio_attr_src->timeout_arg; for(ctr = 0; ctr < xio_attr_dst->ndx; ctr++) { xio_attr_dst->entry[ctr].driver = xio_attr_src->entry[ctr].driver; res = xio_attr_dst->entry[ctr].driver->attr_copy_func( &xio_attr_dst->entry[ctr].driver_data, xio_attr_src->entry[ctr].driver_data); if(res != GLOBUS_SUCCESS) { for(ctr2 = 0; ctr2 < ctr; ctr2++) { /* ignore result here */ xio_attr_dst->entry[ctr].driver->attr_destroy_func( xio_attr_dst->entry[ctr].driver_data); } globus_free(xio_attr_dst->entry); globus_free(xio_attr_dst); goto err; } } globus_mutex_lock(&globus_i_xio_mutex); { globus_list_insert(&globus_i_xio_outstanding_attrs_list, xio_attr_dst); } globus_mutex_unlock(&globus_i_xio_mutex); *dst = xio_attr_dst; GlobusXIODebugExit(); return GLOBUS_SUCCESS; err: GlobusXIODebugExitWithError(); return res; }
/* driver list stuff */ globus_result_t globus_xio_driver_list_from_string( char * driver_string, globus_list_t ** driver_list, globus_hashtable_t * safe_table) { globus_result_t result; globus_bool_t done = GLOBUS_FALSE; globus_bool_t loaded; char * opts; char * ptr; char * driver_str; char * driver_name; char * tmp_str; globus_xio_driver_t driver; globus_list_t * list = NULL; globus_xio_driver_list_ent_t * list_ent; GlobusXIOName(globus_xio_driver_list_from_string); *driver_list = NULL; if(driver_string == NULL) { result = GlobusXIOErrorParameter("driver_string"); goto error_param; } driver_str = globus_libc_strdup(driver_string); tmp_str = driver_str; while(!done) { loaded = GLOBUS_FALSE; driver_name = tmp_str; ptr = strchr(driver_name, ','); if(ptr != NULL) { *ptr = '\0'; tmp_str = ptr+1; } else { done = GLOBUS_TRUE; } opts = strchr(driver_name, ':'); if(opts != NULL) { *opts = '\0'; opts++; /* decode the string */ globus_url_string_hex_decode(opts); } /* check against the safe list */ if(safe_table != NULL) { char * err_str; list_ent = (globus_xio_driver_list_ent_t *) globus_hashtable_lookup(safe_table, driver_name); if(list_ent == NULL) { err_str = globus_common_create_string( "%s driver not whitelisted", driver_name); result = GlobusXIOErrorParameter(err_str); globus_free(err_str); goto error_load; } driver = list_ent->driver; } else { result = globus_xio_driver_load(driver_name, &driver); if(result != GLOBUS_SUCCESS) { goto error_load; } loaded = GLOBUS_TRUE; } list_ent = (globus_xio_driver_list_ent_t *) globus_calloc(1, sizeof(globus_xio_driver_list_ent_t)); list_ent->opts = globus_libc_strdup(opts); list_ent->driver = driver; list_ent->driver_name = globus_libc_strdup(driver_name); list_ent->loaded = loaded; globus_list_insert(&list, list_ent); } globus_free(driver_str); /* reverse list */ while(!globus_list_empty(list)) { globus_list_insert(driver_list, globus_list_first(list)); globus_list_remove(&list, list); } return GLOBUS_SUCCESS; error_load: globus_free(driver_str); while(!globus_list_empty(list)) { list_ent = (globus_xio_driver_list_ent_t *) globus_list_remove(&list, list); if(list_ent->loaded) { globus_xio_driver_unload(list_ent->driver); } globus_free(list_ent->driver_name); if(list_ent->opts != NULL) { globus_free(list_ent->opts); } globus_free(list_ent); } error_param: return result; }
/** * Initialize a gass_transfer request handle. * * This function creates a #globus_gass_transfer_request_struct_t and * associates it with a #gass_transfer_request_t handle. The structure * is initialized with the information passed as the arguments to the * function. * * @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 value pointed to by this will be initialized to the new * 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, * they are copied into the request structure. * @param url * An URL string containing the location of the file to access. A * copy of this is stored in the request handle. * @param type * The type of file transfer that this request will be used for. * @param callback * The callback function to be called once the request is in the * ready state. * @param user_arg * User-supplied argument to the callback function. * * @retval void */ void globus_i_gass_transfer_request_init( globus_gass_transfer_request_t * request, globus_gass_transfer_requestattr_t * attr, char * url, globus_gass_transfer_request_type_t type, globus_gass_transfer_callback_t callback, void * user_arg) { globus_gass_transfer_request_struct_t * req; req = globus_malloc(sizeof(globus_gass_transfer_request_struct_t)); if(req == GLOBUS_NULL) { goto error_exit; } if(url) { req->url = globus_libc_strdup(url); if(req->url == GLOBUS_NULL) { 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; 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; } } else { req->attr = GLOBUS_NULL; } *request = globus_handle_table_insert(&globus_i_gass_transfer_request_handles, (void *) req, 2); globus_list_insert(&globus_i_gass_transfer_requests, (void *) (intptr_t) (*request)); return; free_fifo: globus_fifo_destroy(&req->pending_data); globus_free(req->url); free_req: globus_free(req); error_exit: *request = GLOBUS_NULL_HANDLE; return; }
static globus_result_t globus_l_xio_net_manager_attr_set_string_options( globus_l_xio_net_manager_attr_t *attr, const char *options_string) { globus_result_t result = GLOBUS_SUCCESS; globus_list_t *options = NULL; globus_list_t *rev_options; int num_options; globus_net_manager_attr_t *new_attrs; globus_net_manager_context_t new_context = NULL; char *scope = NULL; char *new_task_id = NULL; size_t attrnum = 0; rev_options = globus_list_from_string(options_string, ';', NULL); /* dislike that this func produces a reversed list */ while (!globus_list_empty(rev_options)) { globus_list_insert( &options, globus_list_remove(&rev_options, rev_options)); } num_options = globus_list_size(options); if (num_options == 0) { goto no_options; } new_attrs = calloc(num_options+1, sizeof(globus_net_manager_attr_t)); if (!new_attrs) { result = GlobusNetManagerErrorMemory("attr_array"); goto new_attrs_calloc_fail; } while (!globus_list_empty(options)) { char *opt, *val; opt = globus_list_remove(&options, options); if (*opt == '\0') { free(opt); continue; } val = strchr(opt, '='); if (!val) { result = GlobusNetManagerErrorParameter("Invalid option string."); free(opt); goto no_equals; } *val++ = '\0'; if (strcmp(opt, "manager") == 0) { result = globus_net_manager_attr_init( &new_attrs[attrnum++], "net_manager", opt, val); if (result) { free(opt); new_attrs[attrnum-1] = globus_net_manager_null_attr; goto new_attr_init_fail; } free(scope); scope = strdup(val); if (!scope) { result = GlobusNetManagerErrorMemory("scope"); free(opt); new_attrs[attrnum++] = globus_net_manager_null_attr; goto strdup_scope_fail; } } else if (strcmp(opt, "task-id") == 0) { free(new_task_id); new_task_id = strdup(val); if (!new_task_id) { result = GlobusNetManagerErrorMemory("task-id"); free(opt); new_attrs[attrnum++] = globus_net_manager_null_attr; goto strdup_task_id_fail; } } else { result = globus_net_manager_attr_init( &new_attrs[attrnum++], scope ? scope : "global", opt, val); if (result) { free(opt); new_attrs[attrnum-1] = globus_net_manager_null_attr; goto new_attr_init_fail; } } free(opt); } new_attrs[attrnum++] = globus_net_manager_null_attr; if (new_attrs) { result = globus_net_manager_context_init( &new_context, new_attrs); if (result) { goto new_context_fail; } globus_net_manager_context_destroy(attr->context); attr->context = new_context; } if (new_task_id) { free(attr->task_id); attr->task_id = new_task_id; new_task_id = NULL; } if (new_attrs) { globus_net_manager_attr_array_delete(attr->attr_array); attr->attr_array = new_attrs; new_attrs = NULL; } new_context_fail: new_attr_init_fail: strdup_task_id_fail: strdup_scope_fail: no_equals: free(new_task_id); free(scope); globus_net_manager_attr_array_delete(new_attrs); new_attrs_calloc_fail: globus_list_destroy_all(options, free); no_options: return result; }
/* * globus_module_activate() */ int globus_module_activate_proxy( 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 * packages if the system has been configured to use threads. */ if (globus_i_module_initialized == GLOBUS_FALSE) { 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); /* * Once the recursive mutex has been acquired, increment the reference * counter for this module, and call it's activation function if it is not * currently active. */ 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(); if(ret_val != GLOBUS_SUCCESS) { globus_l_module_decrement( module_descriptor, parent_key_save); } else { /* * Set up the exit handler */ # if defined(HAVE_ATEXIT) || defined(HAVE_ONEXIT) { if(module_descriptor->atexit_func != GLOBUS_NULL) { /* only call the atexit function once */ if(!globus_list_search( globus_l_module_atexit_funcs, (void *) module_descriptor->atexit_func)) { globus_list_insert( &globus_l_module_atexit_funcs, (void *) module_descriptor->atexit_func); atexit(module_descriptor->atexit_func); } } } # endif } globus_thread_setspecific( globus_l_activate_parent_key, parent_key_save); } } } globus_l_module_mutex_unlock(&globus_l_module_mutex); return ret_val; }
static void globus_l_gss_read_test_cases(char * filename) { int fd; int rc; struct stat st; char * buffer; char * line; compare_name_test_case_t * test_case; globus_list_t * rline_list = NULL; static char name_type1[32], name_type2[32]; static char name_token1[128], name_token2[128]; static char expectation[16]; rc = stat(filename, &st); if (rc != 0) { perror("stat"); exit(1); } buffer = malloc(st.st_size + 1); if (buffer == NULL) { perror("malloc"); exit(1); } fd = open(filename, O_RDONLY, 0); if (fd < 0) { perror("open"); exit(1); } rc = read(fd, buffer, st.st_size); if (rc != st.st_size) { perror("read"); exit(1); } buffer[st.st_size] = '\0'; /* reversed order list */ rline_list = globus_list_from_string(buffer, '\n', " \t\r\n"); while (! globus_list_empty(rline_list)) { line = globus_list_remove(&rline_list, rline_list); if (strlen(line) != 0) { test_case = calloc(1, sizeof(compare_name_test_case_t)); sscanf(line, "%[^,], %[^,], %[^,], %[^,], %[^,]", name_type1, name_token1, name_type2, name_token2, expectation); test_case->test_name = strdup(line); compare_l_parse_name_type( name_type1, name_token1, &test_case->name_type1, &test_case->name_token1); compare_l_parse_name_type( name_type2, name_token2, &test_case->name_type2, &test_case->name_token2); if (strcmp(expectation, "GLOBUS_TRUE") == 0) { test_case->expectation = GLOBUS_TRUE; } else if (strcmp(expectation, "GLOBUS_FALSE") == 0) { test_case->expectation = GLOBUS_FALSE; } else { globus_assert((strcmp(expectation, "GLOBUS_FALSE") == 0) || (strcmp(expectation, "GLOBUS_FALSE") == 0)); } globus_list_insert(&test_cases, test_case); } free(line); } free(buffer); }
/** * Initialize configuration based on command-line arguments * * @param config * LRMA-specific configuration state * @param argc * Count of command-line arguments to the job manager. * @param argv * Array of command-line arguments to the job manager. * * @retval GLOBUS_SUCCESS * Success * @retval GLOBUS_GRAM_PROTOCOL_ERROR_GATEKEEPER_MISCONFIGURED * Command-line includes -help */ int globus_gram_job_manager_config_init( globus_gram_job_manager_config_t * config, int argc, char ** argv) { int i; int rc = 0; char * tmp; char hostname[MAXHOSTNAMELEN]; struct utsname utsname; char * conf_path = NULL; char * dot; char * gatekeeper_contact; memset(config, 0, sizeof(globus_gram_job_manager_config_t)); /* if -conf is passed then get the arguments from the file * specified */ if (argc > 2 && !strcmp(argv[1],"-conf")) { char ** newargv; char * newbuf; int newargc = 52; int length; FILE *fp; newargv = (char**) malloc(newargc * sizeof(char *)); /* not freed */ newargv[0] = argv[0]; /* get file length via fseek & ftell */ if ((fp = fopen(argv[2], "r")) == NULL) { globus_gram_job_manager_log( NULL, GLOBUS_GRAM_JOB_MANAGER_LOG_FATAL, "event=gram.config.end level=FATAL path=\"%s\" " "status=-1 msg=\"%s\" errno=%d reason=\"%s\"\n", argv[2], "Error opening configuration file", errno, strerror(errno)); exit(1); } conf_path = argv[2]; fseek(fp, 0, SEEK_END); length = ftell(fp); if (length <=0) { globus_gram_job_manager_log( NULL, GLOBUS_GRAM_JOB_MANAGER_LOG_FATAL, "event=gram.config.end level=FATAL path=\"%s\" " "status=-1 msg=\"%s\" errno=%d reason=\"%s\"\n", conf_path, "Error determining config file length", errno, strerror(errno)); exit(1); } rewind(fp); newbuf = (char *) malloc(length+1); /* dont free */ i = fread(newbuf, 1, length, fp); if (i < 0) { globus_gram_job_manager_log( NULL, GLOBUS_GRAM_JOB_MANAGER_LOG_FATAL, "event=gram.config.end level=FATAL path=\"%s\" " "status=-1 msg=\"%s\" errno=%d reason=\"%s\"\n", conf_path, "Error reading configuration file", errno, strerror(errno)); exit(1); } newbuf[i] = '\0'; fclose(fp); newargv[0] = argv[0]; newargc--; globus_l_gram_tokenize(newbuf, &newargv[1], &newargc); for (i=3; i<argc; i++) newargv[++newargc] = strdup(argv[i]); argv = newargv; argc = newargc + 1; } /* Default log level if nothing specified on command-line or config file */ config->log_levels = -1; /* Default to using GLOBUS_USAGE_TARGETS environment variable. * If not set, use the Globus usage stats service * Eitehr can be overridden by using -disable-usagestats or setting * -usagestats-targets in the configuration file */ if ((tmp = getenv("GLOBUS_USAGE_TARGETS")) != NULL) { config->usage_targets = strdup(tmp); } else { config->usage_targets = strdup("usage-stats.globus.org:4810"); } /* * Parse the command line arguments */ for (i = 1; i < argc; i++) { if (strcmp(argv[i], "-k") == 0) { config->kerberos = GLOBUS_TRUE; } else if ((strcmp(argv[i], "-home") == 0) && (i + 1 < argc)) { config->globus_location = strdup(argv[++i]); } else if ((strcmp(argv[i], "-target-globus-location") == 0) && (i + 1 < argc)) { config->target_globus_location = strdup(argv[++i]); } else if ((strcmp(argv[i], "-type") == 0) && (i + 1 < argc)) { config->jobmanager_type = strdup(argv[++i]); } else if((strcmp(argv[i], "-history") == 0) && (i + 1 < argc)) { config->job_history_dir = strdup(argv[++i]); } else if (strcmp(argv[i], "-cache-location") == 0) { config->cache_location = strdup(argv[++i]); } else if (strcmp(argv[i], "-scratch-dir-base") == 0) { config->scratch_dir_base = strdup(argv[++i]); } else if ((strcmp(argv[i], "-condor-arch") == 0) && (i + 1 < argc)) { config->condor_arch = strdup(argv[++i]); } else if ((strcmp(argv[i], "-condor-os") == 0) && (i + 1 < argc)) { config->condor_os = strdup(argv[++i]); } else if ((strcmp(argv[i], "-globus-gatekeeper-host") == 0) && (i + 1 < argc)) { config->globus_gatekeeper_host = strdup(argv[++i]); } else if ((strcmp(argv[i], "-globus-gatekeeper-port") == 0) && (i + 1 < argc)) { config->globus_gatekeeper_port = strdup(argv[++i]); } else if ((strcmp(argv[i], "-globus-gatekeeper-subject") == 0) && (i + 1 < argc)) { config->globus_gatekeeper_subject = strdup(argv[++i]); } else if ((strcmp(argv[i], "-globus-host-manufacturer") == 0) && (i + 1 < argc)) { config->globus_host_manufacturer = strdup(argv[++i]); } else if ((strcmp(argv[i], "-globus-host-cputype") == 0) && (i + 1 < argc)) { config->globus_host_cputype = strdup(argv[++i]); } else if ((strcmp(argv[i], "-globus-host-osname") == 0) && (i + 1 < argc)) { config->globus_host_osname = strdup(argv[++i]); } else if ((strcmp(argv[i], "-globus-host-osversion") == 0) && (i + 1 < argc)) { config->globus_host_osversion = strdup(argv[++i]); } else if ((strcmp(argv[i], "-globus-tcp-port-range") == 0) && (i + 1 < argc)) { config->tcp_port_range = strdup(argv[++i]); } else if ((strcmp(argv[i], "-globus-tcp-source-range") == 0) && (i + 1 < argc)) { config->tcp_source_range = strdup(argv[++i]); } else if ((strcmp(argv[i], "-state-file-dir") == 0) && (i + 1 < argc)) { config->job_state_file_dir = strdup(argv[++i]); } else if ((strcmp(argv[i], "-x509-cert-dir") == 0) && (i + 1 < argc)) { config->x509_cert_dir = strdup(argv[++i]); } else if ((strcmp(argv[i], "-extra-envvars") == 0) && (i + 1 < argc)) { char * extra_envvars = strdup(argv[++i]); char *p, *q; p = extra_envvars; while (p && *p) { q = strchr(p, ','); if (q) { *q = 0; } globus_list_insert( &config->extra_envvars, strdup(p)); if (q) { p = q+1; } else { p = q; } } free(extra_envvars); } else if ((strcasecmp(argv[i], "-seg-module" ) == 0) && (i + 1 < argc)) { config->seg_module = strdup(argv[++i]); } else if ((strcmp(argv[i], "-audit-directory") == 0) && (i+1 < argc)) { globus_eval_path(argv[++i], &config->auditing_dir); } else if ((strcmp(argv[i], "-globus-toolkit-version") == 0) && (i+1 < argc)) { config->globus_version = strdup(argv[++i]); } else if (strcmp(argv[i], "-disable-streaming") == 0) { /* Ignore this request, as we don't do streaming any more */ config->streaming_disabled = GLOBUS_FALSE; } else if (strcmp(argv[i], "-service-tag") == 0 && (i+1 < argc)) { config->service_tag = strdup(argv[++i]); } else if (strcmp(argv[i], "-enable-syslog") == 0) { config->syslog_enabled = GLOBUS_TRUE; } else if (strcmp(argv[i], "-stdio-log") == 0 && (i+1 < argc)) { /* Backward-compatible definition of -stdio-log based on * -log-pattern implementation */ config->log_pattern = globus_common_create_string( "%s/gram_$(DATE).log", argv[++i]); } else if (strcmp(argv[i], "-log-pattern") == 0 && (i+1 < argc)) { config->log_pattern = strdup(argv[++i]); } else if ((strcmp(argv[i], "-globus-job-dir") == 0) && (i + 1 < argc)) { config->job_dir_home = globus_common_create_string( "%s/%s", argv[++i], strdup(getenv("USER"))); if (config->job_dir_home == NULL) { rc = GLOBUS_GRAM_PROTOCOL_ERROR_MALLOC_FAILED; goto out; } globus_gram_job_manager_log( NULL, GLOBUS_GRAM_JOB_MANAGER_LOG_TRACE, "event=gram.config.info " "level=TRACE " "option=\"-globus-job-dir\" " "path=\"%s\" " "\n", config->job_dir_home); } else if (strcmp(argv[i], "-log-levels") == 0 && (i+1 < argc)) { rc = globus_i_gram_parse_log_levels( argv[++i], &config->log_levels, NULL); } else if (strcmp(argv[i], "-disable-usagestats") == 0) { config->usage_disabled = GLOBUS_TRUE; } else if (strcmp(argv[i], "-usagestats-targets") == 0 && (i+1 < argc)) { if (config->usage_targets) { free(config->usage_targets); config->usage_targets = NULL; } config->usage_targets = strdup(argv[++i]); } else if (strcmp(argv[i], "-enable-callout") == 0) { config->enable_callout = GLOBUS_TRUE; } else if ((strcasecmp(argv[i], "-help" ) == 0) || (strcasecmp(argv[i], "--help") == 0)) { fprintf(stderr, "Usage: globus-gram-jobmanager\n" "\n" "Required Arguments:\n" "\t-type jobmanager type, i.e. fork, lsf ...\n" "\t-globus-host-manufacturer manufacturer\n" "\t-globus-host-cputype cputype\n" "\t-globus-host-osname osname\n" "\t-globus-host-osversion osversion\n" "\t-globus-gatekeeper-host host\n" "\t-globus-gatekeeper-port port\n" "\t-globus-gatekeeper-subject subject\n" "\n" "Options:\n" "\t-home globus_location\n" "\t-target-globus-location globus_location\n" "\t-condor-arch arch, i.e. SUN4x\n" "\t-condor-os os, i.e. SOLARIS26\n" "\t-history job-history-directory\n" "\t-scratch-dir-base scratch-directory\n" "\t-enable-syslog\n" "\t-stdio-log DIRECTORY\n" "\t-log-levels TRACE|INFO|DEBUG|WARN|ERROR|FATAL\n" "\t-state-file-dir state-directory\n" "\t-globus-tcp-port-range <min port #>,<max port #>\n" "\t-globus-tcp-source-range <min port #>,<max port #>\n" "\t-x509-cert-dir DIRECTORY\n" "\t-cache-location PATH\n" "\t-k\n" "\t-extra-envvars VAR1,VAR2,...\n" "\t-seg-module SEG-MODULE\n" "\t-audit-directory DIRECTORY\n" "\t-globus-toolkit-version VERSION\n" "\t-usagestats-targets <host:port>[!<default | all>],...\n" "\t-enable-callout\n" "\t-globus-job-dir DIRECTORY\n" "\n" "Note: if type=condor then\n" " -condor-os & -condor-arch are required.\n" "\n"); rc = GLOBUS_GRAM_PROTOCOL_ERROR_GATEKEEPER_MISCONFIGURED; goto out; } else { globus_gram_job_manager_log( NULL, GLOBUS_GRAM_JOB_MANAGER_LOG_ERROR, "event=gram.config level=ERROR path=\"%s\" " "argument=%s reason=\"Invalid command-line option\"\n", conf_path ? conf_path : "ARGV", argv[i] ? argv[i] : ""); } } /* If log levels were not specified on the command-line or configuration, set the * service default */ if (config->log_levels == -1) { config->log_levels = 0; } /* Always have these at a minimum */ config->log_levels |= GLOBUS_GRAM_JOB_MANAGER_LOG_FATAL | GLOBUS_GRAM_JOB_MANAGER_LOG_ERROR; /* Verify that required values are present */ if(config->jobmanager_type == NULL) { globus_gram_job_manager_log( NULL, GLOBUS_GRAM_JOB_MANAGER_LOG_ERROR, "event=gram.config level=ERROR path=\"%s\" argument=\"-type\" reason=\"Missing -type command-line option\"\n", conf_path ? conf_path : "ARGV"); rc = GLOBUS_GRAM_PROTOCOL_ERROR_GATEKEEPER_MISCONFIGURED; goto out; } if(config->home == NULL) { config->home = strdup(getenv("HOME")); if (config->home == NULL) { rc = GLOBUS_GRAM_PROTOCOL_ERROR_MALLOC_FAILED; goto out; } } if (config->service_tag == NULL) { config->service_tag = strdup("untagged"); } if (config->tcp_port_range == NULL) { char * ev = getenv("GLOBUS_TCP_PORT_RANGE"); if (ev != NULL) { config->tcp_port_range = strdup(ev); } } if (config->tcp_source_range == NULL) { char * ev = getenv("GLOBUS_TCP_SOURCE_RANGE"); if (ev != NULL) { config->tcp_source_range = strdup(ev); } } if (! globus_list_search_pred( config->extra_envvars, globus_l_env_present, "PATH")) { char * path = strdup("PATH"); if (!path) { rc = GLOBUS_GRAM_PROTOCOL_ERROR_MALLOC_FAILED; goto out; } globus_list_insert(&config->extra_envvars, path); } /* Now initialize values from our environment */ config->logname = strdup(getenv("LOGNAME")); if (config->logname == NULL) { rc = GLOBUS_GRAM_PROTOCOL_ERROR_MALLOC_FAILED; goto out; } if (config->globus_location == NULL) { rc = globus_location(&config->globus_location); if (rc != GLOBUS_SUCCESS) { rc = GLOBUS_GRAM_PROTOCOL_ERROR_MALLOC_FAILED; goto out; } } if (config->target_globus_location == NULL) { config->target_globus_location = strdup(config->globus_location); if (config->target_globus_location == NULL) { rc = GLOBUS_GRAM_PROTOCOL_ERROR_MALLOC_FAILED; goto out; } } if (config->job_state_file_dir == NULL) { rc = globus_eval_path("${localstatedir}/lib/globus/gram_job_state", &config->job_state_file_dir); if (rc != 0 || config->job_state_file_dir == NULL) { rc = GLOBUS_GRAM_PROTOCOL_ERROR_MALLOC_FAILED; goto out; } } if (config->job_dir_home == NULL) { config->job_dir_home = globus_common_create_string("%s/%s", config->job_state_file_dir, config->logname); if (config->job_dir_home == NULL) { rc = GLOBUS_GRAM_PROTOCOL_ERROR_MALLOC_FAILED; goto out; } } if (config->scratch_dir_base == NULL) { config->scratch_dir_base = strdup( config->home); if (config->scratch_dir_base == NULL) { rc = GLOBUS_GRAM_PROTOCOL_ERROR_MALLOC_FAILED; goto out; } } rc = globus_libc_gethostname(hostname, sizeof(hostname)); if (rc != GLOBUS_SUCCESS) { rc = GLOBUS_GRAM_PROTOCOL_ERROR_MALLOC_FAILED; goto out; } config->hostname = strdup(hostname); if (config->hostname == GLOBUS_NULL) { rc = GLOBUS_GRAM_PROTOCOL_ERROR_MALLOC_FAILED; goto out; } config->short_hostname = strdup(hostname); dot = strchr(config->short_hostname, '.'); if (dot != NULL) { *dot = 0; } rc = uname(&utsname); if (rc >= 0) { if (config->globus_host_osname == NULL) { config->globus_host_osname = strdup(utsname.sysname); } if (config->globus_host_osversion == NULL) { if (strcmp(utsname.sysname, "AIX") == 0) { config->globus_host_osversion = globus_common_create_string( "%s.%s", utsname.version, utsname.release); } else { config->globus_host_osversion = globus_common_create_string( "%s", utsname.release); } } } gatekeeper_contact = getenv("GLOBUS_GATEKEEPER_CONTACT_STRING"); if (gatekeeper_contact) { char *colon; char *save = strdup(gatekeeper_contact); gatekeeper_contact = save; if (gatekeeper_contact) { colon = strchr(gatekeeper_contact, ':'); if (colon) { if (!config->globus_gatekeeper_host) { *colon = '\0'; config->globus_gatekeeper_host = strdup(gatekeeper_contact); } gatekeeper_contact = colon + 1; colon = strchr(gatekeeper_contact, ':'); if (colon) { if (!config->globus_gatekeeper_port) { *colon = '\0'; config->globus_gatekeeper_port = strdup(gatekeeper_contact); } gatekeeper_contact = colon + 1; if (!config->globus_gatekeeper_subject) { config->globus_gatekeeper_subject = strdup(gatekeeper_contact); } } } } free(save); } rc = globus_module_activate(GLOBUS_GSI_GSSAPI_MODULE); if (rc != GLOBUS_SUCCESS) { goto out; } rc = globus_gram_job_manager_gsi_get_subject(&config->subject); if (rc != GLOBUS_SUCCESS) { goto out; } config->proxy_timeout = 10*60; out: return rc; }
/** @brief Globus List Test Cases*/ int list_test(void) { globus_list_t *list = GLOBUS_NULL; int rc; void *ptr; int x1 = 1; int x2 = 2; int x3 = 3; int x4 = 4; int search_item; globus_list_t *sub_list; int size; printf("1..25\n"); globus_module_activate(GLOBUS_COMMON_MODULE); /** * @test * Call globus_list_size() with an empty list */ size = globus_list_size(list); ok(size == 0, "size_of_empty_list"); /** * @test * Insert a datum into a globus_list_t with globus_list_insert() */ rc = globus_list_insert(&list, &x1); ok(rc == 0, "insert_item_into_empty_list"); /** * @test * Add a datum to a globus_list_t with globus_list_cons() */ list = globus_list_cons(&x2, list); ok(list != NULL, "globus_list_cons"); /** * @test * Verify that globus_list_size() returns 2 after adding two data * items to a list. */ size = globus_list_size(list); ok(size == 2, "size_of_list_after_insert_and_cons"); /** * @test * Insert x3 into a list with globus_list_insert() */ ok(globus_list_insert(&list, &x3) == 0, "insert_x3"); /** * @test * Insert x4 into a list with globus_list_insert() */ ok(globus_list_insert(&list, &x4) == 0, "insert_x4"); /** * @test * Verify that the size of the list is now 4 with globus_list_size() */ ok(globus_list_size(list) == 4, "check_new_size"); /** * @test * Search for the first item in a list with globus_list_search() */ sub_list = globus_list_search(list, &x1); ok(sub_list != NULL, "search_first"); /** * @test * Use globus_list_first() to return the datum from the returned list node. * Verify that the search result matches the value searched for. */ ptr = globus_list_first(sub_list); ok(*((int *)ptr) == x1, "search_first_value"); /** * @test * Search for the third item in a list with globus_list_search() */ sub_list = globus_list_search(list, &x3); ok(sub_list != NULL, "search_third"); /** * @test * Use globus_list_first() to return the datum from the returned list node. * Verify that the search result matches the value searched for. */ ptr = globus_list_first(sub_list); ok(*((int *)ptr) == x3, "search_third_value"); /** * @test * Search for the fourth item in a list with globus_list_search() */ sub_list = globus_list_search(list, &x4); ok(sub_list != NULL, "search_last"); /** * @test * Use globus_list_first() to return the datum from the returned list node. * Verify that the search result matches the value searched for. */ ptr = globus_list_first(sub_list); ok(*((int *)ptr) == x4, "search_last_value"); /** * @test * Search for the second item in a list with globus_list_search() */ sub_list = globus_list_search(list, &x2); ok(sub_list != NULL, "search_second"); /** * @test * Use globus_list_first() to return the datum from the returned list node. * Verify that the search result matches the value searched for. */ ptr = globus_list_first(sub_list); ok(*((int *)ptr) == x2, "search_second_value"); /** * @test * Search for the fourth item in a list with globus_list_search_pred() */ search_item = 4; sub_list = globus_list_search_pred(list, matches, &search_item); ok(sub_list != NULL, "search_pred_4"); /** * @test * Search for the second item in a list with globus_list_search_pred() */ search_item = 2; sub_list = globus_list_search_pred(list, matches, &search_item); ok(sub_list != NULL, "search_pred_2"); /** * @test * Search for the third item in a list with globus_list_search_pred() */ search_item = 3; sub_list = globus_list_search_pred(list, matches, &search_item); ok(sub_list != NULL, "search_pred_3"); /** * @test * Search for the first item in a list with globus_list_search_pred() */ search_item = 1; sub_list = globus_list_search_pred(list, matches, &search_item); ok(sub_list != NULL, "search_pred_1"); /** * @test * Search for the second item in the list with globus_list_search() */ sub_list = globus_list_search(list, &x2); ok(sub_list != NULL, "search_2"); /** * @test * Remove the second item in the list with globus_list_remove() */ ok(globus_list_remove(&list, sub_list) == &x2, "remove_2"); /** * @test * Remove the first item in the list with globus_list_remove() */ ok(globus_list_remove(&list, list) == &x4, "remove_first"); /** * @test * Remove the first item in the list with globus_list_remove() */ ok(globus_list_remove(&list, list) == &x3, "remove_first_again"); /** * @test * Remove the first item in the list with globus_list_remove() */ ok(globus_list_remove(&list, list) == &x1, "remove_first_again"); /** * @test * Verify that the list is empty with globus_list_empty() */ ok(globus_list_empty(list), "empty_list"); globus_list_free(list); globus_module_deactivate(GLOBUS_COMMON_MODULE); return TEST_EXIT_CODE; }