bytes_read;i++)
{
cc_handle->read_buffer[i-last]=
cc_handle->read_buffer[i];
}
cc_handle->bytes_read -= last;
}
else
{
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(
GLOBUS_FTP_CONTROL_MODULE,
GLOBUS_NULL,
_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);
cc_handle->read_buffer_size += GLOBUS_I_FTP_CONTROL_BUF_INCR;
globus_libc_free(cc_handle->read_buffer);
cc_handle->read_buffer=new_buf;
}
}
globus_mutex_lock(&(cc_handle->mutex));
{
if(cc_handle->cb_count == 1 &&
cc_handle->cc_state == GLOBUS_FTP_CONTROL_CLOSING)
{
cc_handle->cb_count--;
call_close_cb = GLOBUS_TRUE;
}
else if(code == GLOBUS_FTP_CONTROL_COMMAND_QUIT)
{
cc_handle->cb_count--;
}
}
globus_mutex_unlock(&(cc_handle->mutex));
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->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;
}
}
globus_mutex_unlock(&(cc_handle->mutex));
if(call_close_cb == GLOBUS_TRUE)
{
globus_i_ftp_control_call_close_cb(c_handle);
}
return;
}
/**
* @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
* to respond to the clients request.
*
* @param handle
* The control connection to send the response across.
* @param respspec
* A formatted string representing the users response.
* @param callback
* The user callback that will be called when the response has
* been sent.
* @param callback_arg
* The user argument passed to the callback.
*/
globus_result_t
globus_ftp_control_send_response(
globus_ftp_control_handle_t * handle,
const char * respspec,
globus_ftp_control_callback_t callback,
void * callback_arg,
...)
{
globus_ftp_control_rw_queue_element_t * element;
globus_bool_t queue_empty;
globus_result_t rc;
globus_result_t result;
globus_byte_t * buf;
globus_byte_t * encoded_buf;
globus_bool_t call_close_cb = GLOBUS_FALSE;
va_list ap;
int arglength;
if(handle == GLOBUS_NULL)
{
return globus_error_put(
globus_error_construct_string(
GLOBUS_FTP_CONTROL_MODULE,
GLOBUS_NULL,
_FCSL("globus_ftp_control_send_response: handle argument is NULL"))
);
}
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(
globus_error_construct_string(
GLOBUS_FTP_CONTROL_MODULE,
GLOBUS_NULL,
_FCSL("globus_ftp_control_send_response: Unable to determine total length of response string"))
);
goto return_error;
}
buf=(globus_byte_t *) globus_libc_malloc(sizeof(globus_byte_t)*
(arglength+1));
if(buf == GLOBUS_NULL)
{
result=globus_error_put(
globus_error_construct_string(
GLOBUS_FTP_CONTROL_MODULE,
GLOBUS_NULL,
_FCSL("globus_ftp_control_send_response: malloc failed"))
);
goto return_error;
}
va_start(ap, callback_arg);
if(globus_libc_vsprintf((char *) buf, respspec,ap) < arglength)
{
globus_libc_free(buf);
result=globus_error_put(
globus_error_construct_string(
GLOBUS_FTP_CONTROL_MODULE,
GLOBUS_NULL,
_FCSL("globus_ftp_control_send_response: Response string construction failed"))
);
va_end(ap);
goto return_error;
}
va_end(ap);
if(handle->cc_handle.auth_info.authenticated == GLOBUS_TRUE)
{
rc=globus_i_ftp_control_encode_reply((char *) buf,(char **) (void *) &encoded_buf,
&(handle->cc_handle.auth_info));
globus_libc_free(buf);
if(rc != GLOBUS_SUCCESS)
{
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(
globus_error_construct_string(
GLOBUS_FTP_CONTROL_MODULE,
GLOBUS_NULL,
_FCSL("globus_ftp_control_send_response: malloc failed"))
);
globus_libc_free(buf);
goto return_error;
}
element->callback = GLOBUS_NULL;
element->send_response_cb = callback;
element->arg = callback_arg;
element->write_flags = 0;
element->write_buf = buf;
element->write_callback = globus_l_ftp_control_send_response_cb;
globus_mutex_lock(&(handle->cc_handle.mutex));
{
if(handle->cc_handle.cc_state == GLOBUS_FTP_CONTROL_CONNECTED &&
handle->cc_handle.auth_cb == GLOBUS_NULL)
{
queue_empty=globus_fifo_empty(&handle->cc_handle.writers);
globus_fifo_enqueue(&handle->cc_handle.writers,
element);
handle->cc_handle.cb_count++;
}
else
{
globus_mutex_unlock(&(handle->cc_handle.mutex));
globus_libc_free(buf);
globus_libc_free(element);
result = globus_error_put(
globus_error_construct_string(
GLOBUS_FTP_CONTROL_MODULE,
GLOBUS_NULL,
_FCSL("globus_ftp_control_send_response: handle is not connected/authenticated"))
);
goto return_error;
}
}
globus_mutex_unlock(&(handle->cc_handle.mutex));
if(queue_empty == GLOBUS_TRUE)
{
rc = globus_io_register_write(&(handle->cc_handle.io_handle),
buf,
(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));
{
globus_fifo_dequeue(&handle->cc_handle.writers);
handle->cc_handle.cb_count--;
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;
}
}
globus_mutex_unlock(&(handle->cc_handle.mutex));
if(call_close_cb == GLOBUS_TRUE)
{
globus_i_ftp_control_call_close_cb(handle);
}
globus_libc_free(buf);
globus_libc_free(element);
if(queue_empty == GLOBUS_FALSE)
{
globus_i_ftp_control_write_next(handle);
}
result=rc;
goto return_error;
}
}
return GLOBUS_SUCCESS;
return_error:
return result;
}
#ifdef GLOBUS_INTERNAL_DOC
/**
* 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
* calls the user callback
*
* @param arg
* The callback argument, which in this case is the control
* handle.
* @param handle
* 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
*
* @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.
*/
#endif
static void
globus_l_ftp_control_send_response_cb(
void * arg,
globus_io_handle_t * handle,
globus_result_t result,
globus_byte_t * buf,
globus_size_t nbytes)
{
globus_ftp_cc_handle_t * cc_handle;
globus_ftp_control_handle_t * c_handle;
globus_object_t * error;
globus_ftp_control_rw_queue_element_t * element;
globus_bool_t queue_empty;
globus_bool_t call_close_cb = GLOBUS_FALSE;
c_handle = (globus_ftp_control_handle_t *) arg;
cc_handle = &(c_handle->cc_handle);
globus_libc_free(buf);
globus_mutex_lock(&(cc_handle->mutex));
{
element = (globus_ftp_control_rw_queue_element_t *)
globus_fifo_dequeue(&cc_handle->writers);
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);
goto return_error;
}
(element->send_response_cb)((element->arg),
c_handle,
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;
}
}
globus_mutex_unlock(&(cc_handle->mutex));
if(call_close_cb == GLOBUS_TRUE)
{
globus_i_ftp_control_call_close_cb(c_handle);
}
return;
return_error:
(element->send_response_cb)((element->arg),
c_handle,
error);
globus_libc_free(element);
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;
}
}
globus_mutex_unlock(&(cc_handle->mutex));
if(call_close_cb == GLOBUS_TRUE)
{
globus_i_ftp_control_call_close_cb(c_handle);
}
return;
}
#ifdef GLOBUS_INTERNAL_DOC
/**
* 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
*
* @param cmd
* A string representing the command to decode.
* @param encoded_cmd
* Used to return the decoded command. Memory for the encoded
* command is allocated in this function.
* @param auth_info
* The auth_info structure to use for gss unwrapping the command
*
* @return
* - error object
* - GLOBUS_SUCCESS
*
*/
#endif
globus_result_t
globus_i_ftp_control_decode_command(
char * cmd,
char ** decoded_cmd,
globus_ftp_control_auth_info_t * auth_info)
{
int length;
int i;
char * tmp;
globus_result_t rc;
gss_buffer_desc wrapped_token;
gss_buffer_desc unwrapped_token;
OM_uint32 maj_stat;
OM_uint32 min_stat;
int conf_state;
gss_qop_t qop_state;
if(cmd == GLOBUS_NULL)
{
return globus_error_put(
globus_error_construct_string(
GLOBUS_FTP_CONTROL_MODULE,
GLOBUS_NULL,
_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(
globus_error_construct_string(
GLOBUS_FTP_CONTROL_MODULE,
GLOBUS_NULL,
_FCSL("globus_ftp_control_decode_command: malloc failed"))
);
}
if(sscanf(cmd,"%4s",tmp) < 1)
{
rc = globus_error_put(
globus_error_construct_string(
GLOBUS_FTP_CONTROL_MODULE,
GLOBUS_NULL,
_FCSL("globus_ftp_control_decode_command: parse error"))
);
goto decode_error;
}
i=0;
while(tmp[i] != '\0')
{
tmp[i]=toupper(tmp[i]);
i++;
}
if(strcmp(tmp,"MIC") &&
strcmp(tmp,"ENC"))
{
rc = globus_error_put(
globus_error_construct_string(
GLOBUS_FTP_CONTROL_MODULE,
GLOBUS_NULL,
_FCSL("globus_ftp_control_decode_command: parse error"))
);
goto decode_error;
}
if((!strcmp(tmp,"ENC")) && auth_info->encrypt == GLOBUS_FALSE)
{
/* 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,
GLOBUS_NULL,
_FCSL("globus_ftp_control_decode_command: encryption not supported"))
);
goto decode_error;
}
if(sscanf(cmd,"%*s %s",tmp) < 1)
{
rc = globus_error_put(
globus_error_construct_string(
GLOBUS_FTP_CONTROL_MODULE,
GLOBUS_NULL,
_FCSL("globus_ftp_control_decode_command: parse error"))
);
goto decode_error;
}
*decoded_cmd = (char *) globus_libc_malloc((length+3) * 6/8);
if(*decoded_cmd == GLOBUS_NULL)
{
rc = globus_error_put(
globus_error_construct_string(
GLOBUS_FTP_CONTROL_MODULE,
GLOBUS_NULL,
_FCSL("globus_ftp_control_decode_command: malloc failed"))
);
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,
auth_info->auth_gssapi_context,
&wrapped_token,
&unwrapped_token,
&conf_state,
&qop_state);
if(maj_stat != GSS_S_COMPLETE)
{
rc = globus_error_put(
globus_error_construct_string(
GLOBUS_FTP_CONTROL_MODULE,
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;
decode_error:
*decoded_cmd=GLOBUS_NULL;
globus_libc_free(tmp);
return rc;
}
#ifdef GLOBUS_INTERNAL_DOC
/**
* 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
*
* @param reply
* A string representing the response to encode.
* @param encoded_reply
* Used to return the encoded reply. Memory for the encoded
* reply is allocated in this function.
* @param auth_info
* The auth_info structure to use for gss wrapping the reply.
*
* @return
* - error object
* - GLOBUS_SUCCESS
*
*/
#endif
globus_result_t
globus_i_ftp_control_encode_reply(
char * reply,
char ** encoded_reply,
globus_ftp_control_auth_info_t * auth_info)
{
gss_buffer_desc in_buf;
gss_buffer_desc out_buf;
OM_uint32 maj_stat;
OM_uint32 min_stat;
int conf_state;
int length;
if(auth_info == GLOBUS_NULL ||
reply == GLOBUS_NULL ||
encoded_reply == GLOBUS_NULL)
{
return globus_error_put(
globus_error_construct_string(
GLOBUS_FTP_CONTROL_MODULE,
GLOBUS_NULL,
_FCSL("globus_i_ftp_control_encode_reply: NULL argument detected"))
);
}
in_buf.value = reply;
in_buf.length = strlen(reply)+1;
maj_stat = gss_wrap(&min_stat,
auth_info->auth_gssapi_context,
0,
GSS_C_QOP_DEFAULT,
&in_buf,
&conf_state,
&out_buf);
if(maj_stat != GSS_S_COMPLETE)
{
return globus_error_put(
globus_error_construct_string(
GLOBUS_FTP_CONTROL_MODULE,
GLOBUS_NULL,
_FCSL("globus_i_ftp_control_encode_reply: gss_wrap failed"))
);
}
*encoded_reply = (char *) globus_libc_malloc(
(out_buf.length + 3) * 8 / 6 + 9);
if(*encoded_reply == GLOBUS_NULL)
{
gss_release_buffer(&min_stat, &out_buf);
return globus_error_put(
globus_error_construct_string(
GLOBUS_FTP_CONTROL_MODULE,
GLOBUS_NULL,
_FCSL("globus_i_ftp_control_encode_reply: malloc failed"))
);
}
(*encoded_reply)[0]='\0';
if(auth_info->encrypt == GLOBUS_TRUE)
{
strcat(*encoded_reply,"632 ");
}
else
{
strcat(*encoded_reply,"631 ");
}
length = out_buf.length;
globus_i_ftp_control_radix_encode(
out_buf.value,
(globus_byte_t *) &((*encoded_reply)[4]),
&length);
(*encoded_reply)[length+4]='\r';
(*encoded_reply)[length+5]='\n';
(*encoded_reply)[length+6]='\0';
gss_release_buffer(&min_stat, &out_buf);
return GLOBUS_SUCCESS;
}
#ifdef GLOBUS_INTERNAL_DOC
/**
* 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
* - GLOBUS_SUCCESS
*
*/
#endif
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);
globus_hashtable_init(&globus_l_ftp_control_parse_table,
64,
globus_hashtable_string_hash,
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));
entries[0].code = GLOBUS_FTP_CONTROL_COMMAND_SBUF;
entries[0].parse_func = globus_l_ftp_control_parse_sbuf_cmd;
globus_hashtable_insert(&globus_l_ftp_control_parse_table,
"SBUF",
&entries[0]);
entries[1].code = GLOBUS_FTP_CONTROL_COMMAND_SIZE;
entries[1].parse_func = globus_l_ftp_control_parse_string_arg;
globus_hashtable_insert(&globus_l_ftp_control_parse_table,
"SIZE",
&entries[1]);
entries[2].code = GLOBUS_FTP_CONTROL_COMMAND_STOR;
entries[2].parse_func = globus_l_ftp_control_parse_string_arg;
globus_hashtable_insert(&globus_l_ftp_control_parse_table,
"STOR",
&entries[2]);
entries[3].code = GLOBUS_FTP_CONTROL_COMMAND_ADAT;
entries[3].parse_func = globus_l_ftp_control_parse_string_arg;
globus_hashtable_insert(&globus_l_ftp_control_parse_table,
"ADAT",
&entries[3]);
entries[4].code = GLOBUS_FTP_CONTROL_COMMAND_RETR;
entries[4].parse_func = globus_l_ftp_control_parse_string_arg;
globus_hashtable_insert(&globus_l_ftp_control_parse_table,
"RETR",
&entries[4]);
entries[5].code = GLOBUS_FTP_CONTROL_COMMAND_ERET;
entries[5].parse_func = globus_l_ftp_control_parse_string_arg;
globus_hashtable_insert(&globus_l_ftp_control_parse_table,
"ERET",
&entries[5]);
entries[6].code = GLOBUS_FTP_CONTROL_COMMAND_ESTO;
entries[6].parse_func = globus_l_ftp_control_parse_string_arg;
globus_hashtable_insert(&globus_l_ftp_control_parse_table,
"ESTO",
&entries[6]);
entries[7].code = GLOBUS_FTP_CONTROL_COMMAND_USER;
entries[7].parse_func = globus_l_ftp_control_parse_string_arg;
globus_hashtable_insert(&globus_l_ftp_control_parse_table,
"USER",
&entries[7]);
entries[8].code = GLOBUS_FTP_CONTROL_COMMAND_STOU;
entries[8].parse_func = globus_l_ftp_control_parse_string_arg;
globus_hashtable_insert(&globus_l_ftp_control_parse_table,
"STOU",
&entries[8]);
entries[9].code = GLOBUS_FTP_CONTROL_COMMAND_DELE;
entries[9].parse_func = globus_l_ftp_control_parse_string_arg;
globus_hashtable_insert(&globus_l_ftp_control_parse_table,
"DELE",
&entries[9]);
entries[10].code = GLOBUS_FTP_CONTROL_COMMAND_ACCT;
entries[10].parse_func = globus_l_ftp_control_parse_string_arg;
globus_hashtable_insert(&globus_l_ftp_control_parse_table,
"ACCT",
&entries[10]);
entries[11].code = GLOBUS_FTP_CONTROL_COMMAND_SITE;
entries[11].parse_func = globus_l_ftp_control_parse_string_arg;
globus_hashtable_insert(&globus_l_ftp_control_parse_table,
"SITE",
&entries[11]);
entries[12].code = GLOBUS_FTP_CONTROL_COMMAND_RNFR;
entries[12].parse_func = globus_l_ftp_control_parse_string_arg;
globus_hashtable_insert(&globus_l_ftp_control_parse_table,
"RNFR",
&entries[12]);
entries[13].code = GLOBUS_FTP_CONTROL_COMMAND_RNTO;
entries[13].parse_func = globus_l_ftp_control_parse_string_arg;
globus_hashtable_insert(&globus_l_ftp_control_parse_table,
"RNTO",
&entries[13]);
entries[14].code = GLOBUS_FTP_CONTROL_COMMAND_APPE;
entries[14].parse_func = globus_l_ftp_control_parse_string_arg;
globus_hashtable_insert(&globus_l_ftp_control_parse_table,
"APPE",
&entries[14]);
entries[15].code = GLOBUS_FTP_CONTROL_COMMAND_REST;
entries[15].parse_func = globus_l_ftp_control_parse_string_arg;
globus_hashtable_insert(&globus_l_ftp_control_parse_table,
"REST",
&entries[15]);
entries[16].code = GLOBUS_FTP_CONTROL_COMMAND_ALLO;
entries[16].parse_func = globus_l_ftp_control_parse_allo_cmd;
globus_hashtable_insert(&globus_l_ftp_control_parse_table,
"ALLO",
&entries[16]);
entries[17].code = GLOBUS_FTP_CONTROL_COMMAND_SMNT;
entries[17].parse_func = globus_l_ftp_control_parse_string_arg;
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,
"OPTS",
&entries[18]);
entries[19].code = GLOBUS_FTP_CONTROL_COMMAND_PORT;
entries[19].parse_func = globus_l_ftp_control_parse_port_cmd;
globus_hashtable_insert(&globus_l_ftp_control_parse_table,
"PORT",
&entries[19]);
entries[20].code = GLOBUS_FTP_CONTROL_COMMAND_SPOR;
entries[20].parse_func = globus_l_ftp_control_parse_spor_cmd;
globus_hashtable_insert(&globus_l_ftp_control_parse_table,
"SPOR",
&entries[20]);
entries[21].code = GLOBUS_FTP_CONTROL_COMMAND_TYPE;
entries[21].parse_func = globus_l_ftp_control_parse_type_cmd;
globus_hashtable_insert(&globus_l_ftp_control_parse_table,
"TYPE",
&entries[21]);
entries[22].code = GLOBUS_FTP_CONTROL_COMMAND_STRU;
entries[22].parse_func = globus_l_ftp_control_parse_stru_cmd;
globus_hashtable_insert(&globus_l_ftp_control_parse_table,
"STRU",
&entries[22]);
entries[23].code = GLOBUS_FTP_CONTROL_COMMAND_AUTH;
entries[23].parse_func = globus_l_ftp_control_parse_auth_cmd;
globus_hashtable_insert(&globus_l_ftp_control_parse_table,
"AUTH",
&entries[23]);
entries[24].code = GLOBUS_FTP_CONTROL_COMMAND_MODE;
entries[24].parse_func = globus_l_ftp_control_parse_mode_cmd;
globus_hashtable_insert(&globus_l_ftp_control_parse_table,
"MODE",
&entries[24]);
entries[25].code = GLOBUS_FTP_CONTROL_COMMAND_CWD;
entries[25].parse_func = globus_l_ftp_control_parse_string_arg;
globus_hashtable_insert(&globus_l_ftp_control_parse_table,
"CWD",
&entries[25]);
entries[26].code = GLOBUS_FTP_CONTROL_COMMAND_PASS;
entries[26].parse_func = globus_l_ftp_control_parse_string_arg;
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,
"RMD",
&entries[27]);
entries[28].code = GLOBUS_FTP_CONTROL_COMMAND_MKD;
entries[28].parse_func = globus_l_ftp_control_parse_string_arg;
globus_hashtable_insert(&globus_l_ftp_control_parse_table,
"MKD",
&entries[28]);
entries[29].code = GLOBUS_FTP_CONTROL_COMMAND_CDUP;
entries[29].parse_func = globus_l_ftp_control_parse_no_arg;
globus_hashtable_insert(&globus_l_ftp_control_parse_table,
"CDUP",
&entries[29]);
entries[30].code = GLOBUS_FTP_CONTROL_COMMAND_QUIT;
entries[30].parse_func = globus_l_ftp_control_parse_no_arg;
globus_hashtable_insert(&globus_l_ftp_control_parse_table,
"QUIT",
&entries[30]);
entries[31].code = GLOBUS_FTP_CONTROL_COMMAND_REIN;
entries[31].parse_func = globus_l_ftp_control_parse_no_arg;
globus_hashtable_insert(&globus_l_ftp_control_parse_table,
"REIN",
&entries[31]);
entries[32].code = GLOBUS_FTP_CONTROL_COMMAND_PASV;
entries[32].parse_func = globus_l_ftp_control_parse_no_arg;
globus_hashtable_insert(&globus_l_ftp_control_parse_table,
"PASV",
&entries[32]);
entries[33].code = GLOBUS_FTP_CONTROL_COMMAND_SPAS;
entries[33].parse_func = globus_l_ftp_control_parse_no_arg;
globus_hashtable_insert(&globus_l_ftp_control_parse_table,
"SPAS",
&entries[33]);
entries[34].code = GLOBUS_FTP_CONTROL_COMMAND_ABOR;
entries[34].parse_func = globus_l_ftp_control_parse_no_arg;
globus_hashtable_insert(&globus_l_ftp_control_parse_table,
"ABOR",
&entries[34]);
entries[35].code = GLOBUS_FTP_CONTROL_COMMAND_SYST;
entries[35].parse_func = globus_l_ftp_control_parse_no_arg;
globus_hashtable_insert(&globus_l_ftp_control_parse_table,
"SYST",
&entries[35]);
entries[36].code = GLOBUS_FTP_CONTROL_COMMAND_NOOP;
entries[36].parse_func = globus_l_ftp_control_parse_no_arg;
globus_hashtable_insert(&globus_l_ftp_control_parse_table,
"NOOP",
&entries[36]);
entries[37].code = GLOBUS_FTP_CONTROL_COMMAND_FEAT;
entries[37].parse_func = globus_l_ftp_control_parse_no_arg;
globus_hashtable_insert(&globus_l_ftp_control_parse_table,
"FEAT",
&entries[37]);
entries[38].code = GLOBUS_FTP_CONTROL_COMMAND_PWD;
entries[38].parse_func = globus_l_ftp_control_parse_no_arg;
globus_hashtable_insert(&globus_l_ftp_control_parse_table,
"PWD",
&entries[38]);
entries[39].code = GLOBUS_FTP_CONTROL_COMMAND_LIST;
entries[39].parse_func = globus_l_ftp_control_parse_string_arg;
globus_hashtable_insert(&globus_l_ftp_control_parse_table,
"LIST",
&entries[39]);
entries[40].code = GLOBUS_FTP_CONTROL_COMMAND_NLST;
entries[40].parse_func = globus_l_ftp_control_parse_string_arg;
globus_hashtable_insert(&globus_l_ftp_control_parse_table,
"NLST",
&entries[40]);
entries[41].code = GLOBUS_FTP_CONTROL_COMMAND_STAT;
entries[41].parse_func = globus_l_ftp_control_parse_string_arg;
globus_hashtable_insert(&globus_l_ftp_control_parse_table,
"STAT",
&entries[41]);
entries[42].code = GLOBUS_FTP_CONTROL_COMMAND_HELP;
entries[42].parse_func = globus_l_ftp_control_parse_string_arg;
globus_hashtable_insert(&globus_l_ftp_control_parse_table,
"HELP",
&entries[42]);
entries[43].code = GLOBUS_FTP_CONTROL_COMMAND_LANG;
entries[43].parse_func = globus_l_ftp_control_parse_string_arg;
globus_hashtable_insert(&globus_l_ftp_control_parse_table,
"LANG",
&entries[43]);
return GLOBUS_SUCCESS;
}
#ifdef GLOBUS_INTERNAL_DOC
/**
*
* Internal helper function which deactivates any server handles
*
* Internal helper function which goes through a list of server
* handles and closes any open connections associated with the
* handles.
*
* @return
* - GLOBUS_SUCCESS
*
*/
#endif
globus_result_t
globus_i_ftp_control_server_deactivate(void)
{
globus_ftp_control_server_t * server_handle;
globus_result_t rc;
globus_mutex_lock(&globus_l_ftp_server_handle_list_mutex);
{
while(!globus_list_empty(globus_l_ftp_server_handle_list))
{
server_handle=(globus_ftp_control_server_t *)
globus_list_first(globus_l_ftp_server_handle_list);
globus_mutex_lock(&(server_handle->mutex));
{
if(server_handle->state ==
GLOBUS_FTP_CONTROL_SERVER_LISTENING)
{
rc=globus_io_close(&(server_handle->io_handle));
globus_assert(rc == GLOBUS_SUCCESS);
server_handle->state = GLOBUS_FTP_CONTROL_SERVER_DEAF;
}
}
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);
}
}
globus_mutex_unlock(&globus_l_ftp_server_handle_list_mutex);
globus_mutex_destroy(&globus_l_ftp_server_handle_list_mutex);
/* 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)
{
if(sscanf(command->noop.raw_command,
"%*s %d", &command->sbuf.buffer_size) < 1)
{
command->code=GLOBUS_FTP_CONTROL_COMMAND_UNKNOWN;
}
return GLOBUS_SUCCESS;
}
globus_result_t globus_l_ftp_control_parse_string_arg(
globus_ftp_control_command_t * command)
{
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(
globus_error_construct_string(
GLOBUS_FTP_CONTROL_MODULE,
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++;
}
while(isspace(command->noop.raw_command[length-1]))
{
length--;
}
command->noop.raw_command[length]='\0';
strcpy(command->eret.string_arg,
&command->noop.raw_command[arg_start]);
return GLOBUS_SUCCESS;
}
globus_result_t globus_l_ftp_control_parse_no_arg(
globus_ftp_control_command_t * command)
{
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)
{
command->allo.record_size = 0;
if(sscanf(command->noop.raw_command,"%*s %d R %d",
&(command->allo.size),
&(command->allo.record_size))<1)
{
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)
{
int length;
length = strlen(command->noop.raw_command);
command->opts.cmd_name =
(char *) globus_libc_malloc(length);
if(command->opts.cmd_name == GLOBUS_NULL)
{
return globus_error_put(
globus_error_construct_string(
GLOBUS_FTP_CONTROL_MODULE,
GLOBUS_NULL,
_FCSL("globus_ftp_control_command_init: malloc failed")));
}
command->opts.cmd_opts =
(char *) globus_libc_malloc(length);
if(command->opts.cmd_opts == GLOBUS_NULL)
{
globus_libc_free(command->opts.cmd_name);
return globus_error_put(
globus_error_construct_string(
GLOBUS_FTP_CONTROL_MODULE,
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)
{
globus_libc_free(command->opts.cmd_name);
globus_libc_free(command->opts.cmd_opts);
command->opts.cmd_name=GLOBUS_NULL;
command->opts.cmd_opts=GLOBUS_NULL;
}
return GLOBUS_SUCCESS;
}
globus_result_t globus_l_ftp_control_parse_port_cmd(
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]),
&(command->port.host_port.host[1]),
&(command->port.host_port.host[2]),
&(command->port.host_port.host[3]),
&port[0],
&port[1]) < 6)
{
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 ||
(command->port.host_port.host)[3] > 255 ||
port[0] > 255 ||
port[1] > 255)
{
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)
{
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]))
{
i++;
while(command->noop.raw_command[i] &&
isspace(command->noop.raw_command[i]))
{
i++;
}
if(command->noop.raw_command[i])
{
j++;
}
}
else
{
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(
globus_error_construct_string(
GLOBUS_FTP_CONTROL_MODULE,
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]))
{
if(sscanf(&(command->noop.raw_command[i]),
"%u,%u,%u,%u,%u,%u",
&(command->spor.host_port[j].host[0]),
&(command->spor.host_port[j].host[1]),
&(command->spor.host_port[j].host[2]),
&(command->spor.host_port[j].host[3]),
&port[0],
&port[1]) < 6)
{
globus_libc_free(command->spor.host_port);
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 ||
(command->spor.host_port[j].host)[3] > 255 ||
port[0] > 255 ||
port[1] > 255)
{
globus_libc_free(command->spor.host_port);
command->code=GLOBUS_FTP_CONTROL_COMMAND_UNKNOWN;
return GLOBUS_SUCCESS;
}
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++;
}
}
else
{
i++;
}
}
return GLOBUS_SUCCESS;
}
globus_result_t globus_l_ftp_control_parse_type_cmd(
globus_ftp_control_command_t * command)
{
char tmp;
command->type.option=GLOBUS_FTP_CONTROL_TYPE_NO_OPTION;
command->type.bytesize=0;
if(sscanf(command->noop.raw_command,"%*s %c",&tmp) < 1)
{
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)
{
switch(tmp)
{
case 'N':
command->type.option=GLOBUS_FTP_CONTROL_TYPE_OPTION_N;
return GLOBUS_SUCCESS;
case 'T':
command->type.option=GLOBUS_FTP_CONTROL_TYPE_OPTION_T;
return GLOBUS_SUCCESS;
case 'C':
command->type.option=GLOBUS_FTP_CONTROL_TYPE_OPTION_C;
return GLOBUS_SUCCESS;
default:
command->type.type=GLOBUS_FTP_CONTROL_TYPE_NONE;
command->type.option=GLOBUS_FTP_CONTROL_TYPE_NO_OPTION;
return GLOBUS_SUCCESS;
}
}
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)
{
switch(tmp)
{
case 'N':
command->type.option=GLOBUS_FTP_CONTROL_TYPE_OPTION_N;
return GLOBUS_SUCCESS;
case 'T':
command->type.option=GLOBUS_FTP_CONTROL_TYPE_OPTION_T;
return GLOBUS_SUCCESS;
case 'C':
command->type.option=GLOBUS_FTP_CONTROL_TYPE_OPTION_C;
return GLOBUS_SUCCESS;
default:
command->type.type=GLOBUS_FTP_CONTROL_TYPE_NONE;
command->type.option=GLOBUS_FTP_CONTROL_TYPE_NO_OPTION;
return GLOBUS_SUCCESS;
}
}
return GLOBUS_SUCCESS;
case 'I':
case 'i':
command->type.type=GLOBUS_FTP_CONTROL_TYPE_IMAGE;
return GLOBUS_SUCCESS;
case 'L':
case 'l':
command->type.type=GLOBUS_FTP_CONTROL_TYPE_LOCAL;
if(sscanf(command->noop.raw_command,"%*s %*c %u",
&command->type.bytesize) < 1)
{
command->type.type=GLOBUS_FTP_CONTROL_TYPE_NONE;
command->type.option=GLOBUS_FTP_CONTROL_TYPE_NO_OPTION;
return GLOBUS_SUCCESS;
}
return GLOBUS_SUCCESS;
default:
command->type.type=GLOBUS_FTP_CONTROL_TYPE_NONE;
return GLOBUS_SUCCESS;
}
}
globus_result_t globus_l_ftp_control_parse_stru_cmd(
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':
case 'f':
command->stru.structure=
GLOBUS_FTP_CONTROL_STRUCTURE_FILE;
return GLOBUS_SUCCESS;
case 'R':
case 'r':
command->stru.structure=
GLOBUS_FTP_CONTROL_STRUCTURE_RECORD;
return GLOBUS_SUCCESS;
case 'P':
case 'p':
command->stru.structure=
GLOBUS_FTP_CONTROL_STRUCTURE_PAGE;
return GLOBUS_SUCCESS;
default:
return GLOBUS_SUCCESS;
}
}
globus_result_t globus_l_ftp_control_parse_auth_cmd(
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)
{
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':
case 's':
command->mode.mode=GLOBUS_FTP_CONTROL_MODE_STREAM;
return GLOBUS_SUCCESS;
case 'B':
case 'b':
command->mode.mode=GLOBUS_FTP_CONTROL_MODE_BLOCK;
return GLOBUS_SUCCESS;
case 'C':
case 'c':
command->mode.mode=GLOBUS_FTP_CONTROL_MODE_COMPRESSED;
return GLOBUS_SUCCESS;
case 'E':
case 'e':
command->mode.mode=GLOBUS_FTP_CONTROL_MODE_EXTENDED_BLOCK;
return GLOBUS_SUCCESS;
default:
command->mode.mode=GLOBUS_FTP_CONTROL_MODE_NONE;
return GLOBUS_SUCCESS;
}
}
globus_ftp_control-9.10/PaxHeaders.24857/globus_i_ftp_control.h 0000644 0000000 0000000 00000000132 14243161125 022741 x ustar 00 0000000 0000000 30 mtime=1653400149.412969574
30 atime=1653401521.844239676
30 ctime=1653404005.195900049
globus_ftp_control-9.10/globus_i_ftp_control.h 0000664 0001750 0001750 00000016161 14243161125 023100 0 ustar 00johndoe johndoe 0000000 0000000 /*
* Copyright 1999-2006 University of Chicago
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef GLOBUS_INCLUDE_FTP_I_CONTROL_H
#define GLOBUS_INCLUDE_FTP_I_CONTROL_H 1
#define GLOBUS_I_FTP_CONTROL_BUF_SIZE 200
#define GLOBUS_I_FTP_CONTROL_BUF_INCR 100
#define GLOBUS_I_TELNET_IP "\xFF\xF4"
#define GLOBUS_I_TELNET_SYNCH "\xFF\xF2"
#define GLOBUS_I_TELNET_IAC '\xFF'
#include "globus_config.h"
extern
FILE * globus_i_ftp_control_devnull;
typedef enum
{
GLOBUS_I_FTP_AUTH,
GLOBUS_I_FTP_ACCT,
GLOBUS_I_FTP_ADAT,
GLOBUS_I_FTP_QUIT,
GLOBUS_I_FTP_USER,
GLOBUS_I_FTP_PASS,
GLOBUS_I_FTP_NOOP
}
globus_i_ftp_cmd_t;
typedef struct globus_i_ftp_passthru_cb_arg_s
{
globus_ftp_control_response_callback_t user_cb;
void * user_cb_arg;
globus_i_ftp_cmd_t cmd;
globus_ftp_control_handle_t * handle;
} globus_i_ftp_passthru_cb_arg_t;
typedef struct globus_i_ftp_server_passthru_cb_arg_s
{
globus_ftp_control_server_callback_t callback;
void * callback_arg;
globus_ftp_control_server_t * server_handle;
} globus_i_ftp_server_passthru_cb_arg_t;
void
globus_i_ftp_control_call_close_cb(
globus_ftp_control_handle_t * handle);
void
globus_i_ftp_control_write_next(
globus_ftp_control_handle_t * handle);
globus_result_t
globus_i_ftp_control_radix_encode(
unsigned char * inbuf,
unsigned char * outbuf,
int * length);
globus_result_t
globus_i_ftp_control_radix_decode(
unsigned char * inbuf,
unsigned char * outbuf,
int * length);
globus_result_t
globus_i_ftp_control_decode_command(
char * cmd,
char ** decoded_cmd,
globus_ftp_control_auth_info_t * auth_info);
globus_result_t
globus_i_ftp_control_encode_command(
globus_ftp_cc_handle_t * cc_handle,
char * cmd,
char ** encoded_cmd);
globus_result_t
globus_i_ftp_control_encode_reply(
char * reply,
char ** encoded_reply,
globus_ftp_control_auth_info_t * auth_info);
globus_result_t
globus_i_ftp_control_data_set_netlogger(
globus_ftp_control_handle_t * handle,
globus_netlogger_handle_t * nl_handle,
globus_bool_t nl_ftp_control,
globus_bool_t nl_globus_io);
globus_result_t
globus_i_ftp_control_client_set_netlogger(
globus_ftp_control_handle_t * handle,
globus_netlogger_handle_t * nl_handle);
globus_result_t
globus_i_ftp_control_data_activate(void);
globus_result_t
globus_i_ftp_control_data_deactivate(void);
globus_result_t
globus_i_ftp_control_client_activate(void);
globus_result_t
globus_i_ftp_control_client_deactivate(void);
globus_result_t
globus_i_ftp_control_server_activate(void);
globus_result_t
globus_i_ftp_control_server_deactivate(void);
globus_result_t
globus_i_ftp_control_data_cc_destroy(
globus_ftp_control_handle_t * control_handle);
globus_result_t
globus_i_ftp_control_data_cc_blocking_destroy(
globus_ftp_control_handle_t * control_handle);
globus_result_t
globus_i_ftp_control_data_abort(
globus_ftp_control_handle_t * control_handle,
globus_object_t * error);
globus_result_t
globus_i_ftp_control_auth_info_init(
globus_ftp_control_auth_info_t * dest,
globus_ftp_control_auth_info_t * src);
globus_result_t
globus_i_ftp_control_auth_info_destroy(
globus_ftp_control_auth_info_t * auth_info);
globus_result_t
globus_i_ftp_control_get_connection_info(
globus_ftp_control_handle_t * handle,
int * local_host,
unsigned short * local_port,
int * remote_host,
unsigned short * remote_port);
/*
* internal function definitions
*/
globus_result_t
globus_i_ftp_parallelism_copy(
globus_ftp_control_parallelism_t * dest_parallelism,
globus_ftp_control_parallelism_t * src_parallelism);
int
globus_i_ftp_parallelism_get_size(
globus_ftp_control_parallelism_t * parallelism);
int
globus_i_ftp_parallelism_get_min_size(
globus_ftp_control_parallelism_t * parallelism);
int
globus_i_ftp_parallelism_get_max_size(
globus_ftp_control_parallelism_t * parallelism);
void
globus_ftp_control_host_port_init(
globus_ftp_control_host_port_t * host_port,
char * host,
unsigned short port);
void
globus_ftp_control_host_port_destroy(
globus_ftp_control_host_port_t * host_port);
void
globus_ftp_control_host_port_get_host(
globus_ftp_control_host_port_t * host_port,
char * host);
unsigned short
globus_ftp_control_host_port_get_port(
globus_ftp_control_host_port_t * host_port);
void
globus_ftp_control_host_port_copy(
globus_ftp_control_host_port_t * dest,
globus_ftp_control_host_port_t * src);
globus_result_t
globus_i_ftp_control_client_get_connection_info(
globus_ftp_control_handle_t * handle,
int localhost[4],
unsigned short * localport,
int remotehost[4],
unsigned short * remoteport);
extern const char * globus_i_ftp_server_welcome;
extern const char * globus_i_ftp_server_user_reply;
extern const char * globus_i_ftp_server_pass_reply;
extern int globus_i_ftp_control_debug_level;
#ifdef BUILD_DEBUG
#define globus_i_ftp_control_debug(Level) \
(globus_i_ftp_control_debug_level >= (Level))
#define globus_i_ftp_control_debug_printf(level, message) \
do { \
if (globus_i_ftp_control_debug(level)) \
{ \
globus_libc_fprintf message; \
} \
} while (0)
#else
#define globus_i_ftp_control_debug_printf(level, message)
#endif
#endif
globus_ftp_control-9.10/PaxHeaders.24857/globus_gridftp_protocol_extensions.dox 0000644 0000000 0000000 00000000131 14243161125 026301 x ustar 00 0000000 0000000 30 mtime=1653400149.411969584
30 atime=1653401522.023237862
29 ctime=1653404005.19790003
globus_ftp_control-9.10/globus_gridftp_protocol_extensions.dox 0000664 0001750 0001750 00000061713 14243161125 026444 0 ustar 00johndoe johndoe 0000000 0000000 /**
@anchor page_extensions
@page globus_ftp_extensions
@brief GridFTP: Protocol Extensions to FTP for the Grid
@section extensions_intro Introduction
This section defines extensions to the FTP specification STD 9, RFC
959, @ref rfc959 "FILE TRANSFER PROTOCOL (FTP)" (October 1985)
These extensions provide striped data transfer, parallel data
transfer, extended data transfer, data buffer size configuration, and
data channel authentication.
The following new commands are introduced in this specification
- @ref sec_SPAS "Striped Passive (SPAS)"
- @ref sec_SPOR "Striped Data Port (SPOR)"
- @ref sec_ERET "Extended Retrieve (ERET)"
- @ref sec_ESTO "Extended Store (ESTO)"
- @ref sec_SBUF "Set Data Buffer Size (SBUF)"
- @ref sec_DCAU "Data Channel Authentication Mode (DCAU)"
A new transfer mode (@ref mode_e "extended-block mode") is
introduced for parallel and striped data transfers. Also, a set of
extension @ref sec_OPTS "options to RETR" are added to control
striped data layout and parallelism.
The following new feature names are to be included in the FTP server's
response to FEAT if it implements the following sets of functionality
@par PARALLEL
The server supports the SPOR, SPAS, the RETR options mentioned above,
and extended block mode.
@par ESTO
The server implements the ESTO command as described in this document.
@par ERET
The server implements the ERET command as described in this document.
@par SBUF
The server implements the SBUF command as described in this document.
@par DCAU
The server implements the DCAU command as described in this document,
including the requirement that data channels are authenticated by
default, if @ref rfc2228 "RFC 2228" authentication is used to establish
the control channel.
@section term Terminology
@par Parallel transfer
From a single data server, splitting file data for transfer over multiple
data connections.
@par Striped transfer
Distributing a file's data over multiple independent
data nodes, and transerring over multiple data connections.
@par Data Node
In a striped data transfer, a data node is one of the stripe
destinations returned in the SPAS command, or one of the stripe
destinations sent in the SPOR command.
@par DTP
The data transfer process establishes and manages the data connection.
The DTP can be passive or active.
@par PI
The protocol interpreter. The user and server sides of the protocol
have distinct roles implemented in a user-PI and a server-PI.
@section Existing FTP Standards Used
- RFC 959, @ref rfc959 "FILE TRANSFER PROTOCOL (FTP)", J. Postel,
R. Reynolds (October 1985)
- Commands used by GridFTP
- USER
- PASS
- ACCT
- CWD
- CDUP
- QUIT
- REIN
- PORT
- PASV
- TYPE
- MODE
- RETR
- STOR
- STOU
- APPE
- ALLO
- REST
- RNFR
- RNTO
- ABOR
- DELE
- RMD
- MKD
- PWD
- LIST
- NLST
- SITE
- SYST
- STAT
- HELP
- NOOP
- Features used by GridFTP
- ASCII and Image types
- Stream mode
- File structure
- RFC 2228, @ref rfc2228 "FTP Security Extensions", Horowitz, M. and
S. Lunt (October 1997)
- Commands used by GridFTP
- AUTH
- ADAT
- MIC
- CONF
- ENC
- Features used by GridFTP
- GSSAPI authentication
- RFC 2389, @ref rfc2389 "Feature negotiation mechanism for the File Transfer Protocol", P. Hethmon , R. Elz (August 1998)
- Commands used by GridFTP
- FEAT
- OPTS
- Features used by GridFTP
- @ref ietfftpext "FTP Extensions", R. Elz, P. Hethmon (September 2000)
- Commands used by GridFTP
- SIZE
- Features used by GridFTP
- Restart of a stream mode transfer
@anchor sec_SPAS
@section SPAS Striped Passive (SPAS)
This extension is used to establish a vector of data socket listeners for for a
server with one or more stripes. This command MUST be used in conjunction with
the extended block mode. The response to this command includes a list of
host and port addresses the server is listening on.
Due to the nature of the extended block mode protocol, SPAS must be used in
conjunction with data transfer commands which receive data (such as
STOR, ESTO, or APPE) and can not be used with commands which send data
on the data channels.
@par Syntax
The syntax of the SPAS command is:
@code
spas = "SPAS"
@endcode
@par Responses
The server-PI will respond to the SPAS command with a 229 reply
giving the list of host-port strings for the remote server-DTP or
user-DTP to connect to.
@code
spas-response = "229-Entering Striped Passive Mode" CRLF
1*( host-port CRLF)
229 End
@endcode
Where the command is correctly parsed, but the server-DTP cannot
process the SPAS request, it must return the same error responses as
the PASV command.
@par OPTS for SPAS
There are no options in this SPAS specification, and hence there is no
OPTS command defined.
@anchor sec_SPOR
@section SPOR Striped Data Port (SPOR)
This extension is to be used as a complement to the SPAS command to
implement striped third-party transfers. This command MUST always be used in
conjunction with the extended block mode. The argument to SPOR is a vector of
host/TCP listener port pairs to which the server is to connect. This
Due to the nature of the extended block mode protocol, SPOR must be used in
conjunction with data transfer commands which send data (such as
RETR, ERET, LIST, or NLST) and can not be used with commands which receive data
on the data channels.
@par Syntax
The syntax of the SPOR command is:
@code
SPOR 1*( )
@endcode
The host-port sequence in the command structure MUST match the
host-port replies to a SPAS command.
@par Responses
The server-PI will respond to the SPOR command with the same response
set as the PORT command described in the @ref rfc959 "ftp specification".
@par OPTS for SPOR
There are no options in this SPOR specification, and hence there is no
OPTS command defined.
@anchor sec_ERET
@section ERET Extended Retrieve (ERET)
The extended retrieve extension is used to request that a retrieve be
done with some additional processing on the server. This command an
extensible way of providing server-side data reduction or other
modifications to the RETR command. This command is used in place of
OPTS to the RETR command to allow server side processing to be done
with a single round trip (one command sent to the server instead of
two) for latency-critical applications.
ERET may be used with either the data transports defined in RFC 959, or using
extended block mode as defined in this document. Using an ERET creates a new
virtual file which will be sent, with it's own size and byte range starting
at zero. Restart markers generated while processing an ERET
are relative to the beginning of this view of the file.
@par Syntax
The syntax of the ERET command is
@code
ERET
retrieve-mode ::= P
offset ::= 64 bit integer
size ::= 64 bit integer
@endcode
The @b retrieve-mode defines behavior of the extended-retrieve
mode. There is one mode defined by this specification, but other general
purpose or application-specific ones may be added later.
@par modes_ERET Extended Retrieve Modes
@par Partial Retrieve Mode (P)
A section of the file will be retrieved from the data server. The
section is defined by the starting @b offset and extent @b size
parameters. When used with extended block mode, the extended block
headers sent along with data will send the data with offset of 0 meaning
the beginning of the section of the file which was requested.
@anchor sec_ESTO
@section ESTO Extended Store (ESTO)
The extended store extension is used to request that a store be done with some
additional processing on the server. Arbitrary data processing algorithms may
be added by defining additional ESTO store-modes. Similar to the ERET, the
ESTO command expects data sent to satisfy the request to be sent as if
it were a new file with data block offset 0 being beginning the beginning
of the new file.
The format of the ESTO command is
@code
ESTO
store-mode ::= A
@endcode
The store-mode defines the behavior of the extended store. There is
one mode defined by this specification, but others may be added later.
@par Extended Store Modes
@par Adjusted store (A)
The data in the file is to stored with @b offset added to the file pointer
before storing the blocks of the file. In extended block mode, this value is
added to the offset in the extended block header by the server when writing to
disk. Extended block headers should therefore send the beginning of the byte
range on the data channel with offset of zero. In stream mode, the offset is
added to the implicit offset of 0 for the beginning of the data before
writing. If a stream mode restart marker is used in conjunction with this ESTO
mode, the restart marker's offset is added to the offset passed as the
parameter to the adjusted store.
@anchor sec_SBUF
@section SBUF Set Buffer Size (SBUF)
This extension adds the capability of a client to set the TCP buffer
size for subsequent data connections to a value. This replaces the
server-specific commands SITE RBUFSIZE, SITE RETRBUFSIZE, SITE RBUFSZ,
SITE SBUFSIZE, SITE SBUFSZ, and SITE BUFSIZE. Clients may wish to consider
supporting these other commands to ensure wider compatibility.
@par Syntax
The syntax of the SBUF command is
@code
sbuf = SBUF
buffer-size ::=
@endcode
The @b buffer-size value is the TCP buffer size in bytes. The TCP
window size should be set accordingly by the server.
@par Response Codes
If the server-PI is able to set the buffer size state to the requested
buffer-size, then it will return a 200 reply.
@note Even if the SBUF is accepted by the server, an error may occur
later when the data connections are actually created, depending on how
the server or client operating systems' TCP implementations.
@anchor sec_DCAU
@section DCAU Data Channel Authentication (DCAU)
This extension provides a method for specifying the type of
authentication to be performed on FTP data channels. This extension
may only be used when the control connection was authenticated using
RFC 2228 Security extensions.
The format of the DCAU command is
@code
DCAU
authentication-mode ::=
|
|
no-authentication ::= N
authenticate-with-self ::= A
authenticate-with-subject ::= S
subject-name ::= string
@endcode
@par Authentication Modes
- No authentication (N)
No authentication handshake will be done upon data connection
establishment.
- Self authentication (A)
A security-protocol specific authentication will be used on the data
channel. The identity of the remote data connection will be the same
as the identity of the user which authenticated to the control
connection.
- Subject-name authentication (S)
A security-protocol specific authentication will be used on the data
channel. The identity of the remote data connection MUST match the
supplied @b subject-name string.
The default data channel authentication mode is @b A for FTP sessions which
are RFC 2228 authenticated---the client must explicitly send a DCAU N message
to disable it if it does not implement data channel authentication.
If the security handshake fails, the server should return the error
response 432 (Data channel authentication failed).
@section mode_e Extended Block Mode
The striped and parallel data transfer methods described above require
an extended transfer mode to support out-of-sequence data delivery,
and partial data transmission per data connection. The extended block
mode described here extends the block mode header to provide support
for these as well as large blocks, and end-of-data synchronization.
Clients indicate that they want to use extended block mode by sending
the command
@code
MODE E
@endcode
on the control channel before a transfer command is sent.
The structure of the extended block header is
@code
Extended Block Header
+----------------+-------/-----------+------/------------+
| Descriptor | Byte Count | Offset Count |
| 8 bits | 64 bits | 64 bits |
+----------------+-------/-----------+------/------------+
@endcode
The descriptor codes are indicated by bit flags in the
descriptor byte. Six codes have been assigned, where each
code number is the decimal value of the corresponding bit in
the byte.
@code
Code Meaning
128 End of data block is EOR (Legacy)
64 End of data block is EOF
32 Suspected errors in data block
16 Data block is a restart marker
8 End of data block is EOD for a parallel/striped transfer
4 Sender will close the data connection
@endcode
With this encoding, more than one descriptor coded condition
may exist for a particular block. As many bits as necessary
may be flagged.
Some additional protocol is added to the extended block mode data
channels, to properly handle end-of-file detection in the presence of
an unknown number of data streams.
- When no more data is to be sent on the data channel, then the sender
will mark the last block, or send a zero-length block after the last
block with the EOD bit (8) set in the extended block header.
- After receiving an EOD the data connection can be cached for use in a
subsequent transfer. To signifiy that the data connection will be closed
the sender sets the close bit (4) in the header on the last message sent.
- The sender communicates end of file by sending an EOF message to all
servers receiving data. The EOF message format follows.
Extended Block EOF Header
@code
+----------------+-------/--------+------/---------------+
| Descriptor | unused | EOD count expected |
| 8 bits | 64 bits | 64 bits |
+----------------+-------/--------+------/---------------+
@endcode
EOF Descriptor.
The EOF header descriptor has the same definition as the regular data
message header described above.
EOD Count Expected.
This 64 bit field represents the total number of data connections that
will be established with the server receiving the file. This number is
used by the receiver to determine it has received all of the data. When
the number of EOD messages received equals the number represented by the
"EOD Count Expected" field the receiver has hit end of file.
Simply waiting for EOD on all open data connections is not sufficient.
It is possible that the receiver reads an EOD message on all of its open
data connects while an additional data connection is in flight. If the
receiver were to assume it reached end of file it would fail to receive
the data on the in flight connection.
To handle EOF in the multi-striped server case a 126 response has been
introduced. When receiving data from a striped server a client makes a
control connection to a single host, but several host may create several
data connections back to the client. Each host can independently decide
how many data connections it will use, but only a single EOF message may
be sent to back to the client, therefore it must be possible to aggregate
the total number of data connections used in the transfer across the
stripes. The 126 response serves this purpose.
The 126 is an intermediate response to RETR command. It has the following
format.
@code
126 1*(count of data connections)
@endcode
Several "Count of data connections" can be in a single reply. They
correspond to the stripes returned in the response to the SPAS command.
Discussion of protocol change to enable bidirectional data channels
brought up the following problem if doing bidirectional data channels
If the client is pasv, and sending to a multi-stripe server, then the
server creates data connections connections; since the client didn't
do SPAS, it cannot associate HOST/PORT pairs on the data connections
with stripes on the server (it doesn't even know how many there
are). it cannot reliably determine which nodes to send data
to. (Becomes even more complex in the third-party transfer case,
because the sender may have multiple stripes of data.) The basic
problem is that we need to know logical stripe numbers to know where
to send the data.
@par EOF Handling in Extended Block Mode
If you are in either striped or parallel mode, you will get exactly
one EOF on each SPAS-specified ports (stripes). Hosts in extended
block mode must be prepared to accept an arbitrary number of
connections on each SPOR port before the EOF block is sent.
@par Restarting
In general, opaque restart markers passed via the block header should
not be used in extended block mode. Instead, the destination server
should send extended data marker responses over the control
connection, in the following form:
@code
extended-mark-response = "111" "Range Marker"
byte-ranges-list = [ *("," ) ]
byte-range = "-"
start-offset ::=
end-offset ::=
@endcode
The byte ranges in the marker are an incremental set of byte ranges
which have been stored to disk by the data server. The complete
restart marker is a concatenation of all byte ranges received by the
client in 111 responses.
The client MAY combine adjacent ranges received over several range
responses into any number of ranges when sending the REST command to
the server to restart a transfer.
For example, the client, on receiving the responses:
@code
111 Range Marker 0-29
111 Range Marker 30-89
@endcode
may send, equivalently,
@code
REST 0-29,30-89
REST 0-89
REST 30-59,0-29,60-89
@endcode
to restart the transfer after those 90 bytes have been received.
The server MAY indicate that a given range of data has been received
in multiple subsequent range markers. The client MUST be able to
handle this. For example:
@code
111 Range Marker 30-59
111 Range Marker 0-89
@endcode
is equivalent to
@code
111 Range Marker 30-59
111 Range Marker 0-29,60-89
@endcode
Similarly, the client, if it is doing no processing of the restart
markers, MAY send redundant information in a restart.
Should these be allowed as restart markers for stream mode?
@par Performance Monitoring
In order to monitor the performance of extended block mode transfer,
an additional preliminary reply MAY be transmitted over the control
channel. This reply is of the form:
@code
extended-perf-response = "112-Perf Marker" CRLF
"Timestamp:" CRLF
"Stripe Index:" CRLF
"Stripe Bytes Transferred:" CRLF
"Total Stripe Count:" CRLF
"112 End" CRLF
timestamp = [ "." ]
@endcode
<timestamp> is seconds since the epoch
The performance marker can contain these or any other perf-line facts
which provide useful information about the current performance.
All perf-line facts represent an instantaneous state of the transfer
at the given timestamp. The meaning of the facts are
- Timestamp - The time at which the server computed the performance
information. This is in seconds since the epoch (00:00:00 UTC, January 1,
1970).
- Stripe Index - the index (0-number of stripes on the STOR side of the
transfer) which this marker pertains to.
- Stripe Bytes Transferred - The number of bytes which have been received
on this stripe.
A transfer start time can be specified by a perf marker with
'Stripe Bytes Transferred' set to zero. Only the first marker per stripe
can be used to specify the start time of that stripe. Any subsequent
markers with 'Stripe Bytes Transferred' set to zero simply indicates no data
transfer over the interval.
A server should send a 'start' marker for each stripe. A server should also
send a final perf marker for each stripe. This is a marker with
'Stripe Bytes Transferred' set to the total transfer size for that stripe.
@anchor sec_OPTS
@section opts Options to RETR
The options described in this section provide a means to convey
striping and transfer parallelism information to the server-DTP. For
the RETR command, the Client-FTP may specify a parallelism and
striping mode it wishes the server-DTP to use. These options are only
used by the server-DTP if the retrieve operation is done in extended
block mode. These options are implemented as @ref rfc2389 "RFC 2389"
extensions.
The format of the RETR OPTS is specified by:
@code
retr-opts = "OPTS" "RETR" [ option-list] CRLF
option-list = [ layout-opts ";" ] [ parallel-opts ";" ]
layout-opts = "StripeLayout=Partitioned"
| "StripeLayout=Blocked;BlockSize="
parallel-opts = "Parallelism=" ","
","
block-size ::=
starting-parallelism ::=
minimum-parallelism ::=
maximum-parallelism ::=
@endcode
@par Layout Options
The layout option is used by the source data node to send
sections of the data file to the appropriate destination stripe.
The various StripeLayout parameters are to be implemented as follows:
@par Partitioned
A partitioned data layout is one where the data is distributed evenly
on the destination data nodes. Only one contiguous section of data
is stored on each data node. A data node is defined here a single
host-port mentioned in the SPOR command
@par Blocked
A blocked data layout is one where the data is distributed in
round-robin fashion over the destination data nodes. The data
distribution is ordered by the order of the host-port specifications
in the SPOR command. The @b block-size defines the size of blocks to
be distributed.
@par PLVL Parallelism Options
The parallelism option is used by the source data node to control how
many parallel data connections may be established to each destination
data node. This extension option provides for both a fixed level of
parallelism, and for adapting the parallelism to the host/network
connection, within a range. If the @b starting-parallelism option is
set, then the server-DTP will make @b starting-parallelism connections
to each destination data node. If the @b minimum-parallelism option is
set, then the server may reduce the number of parallel
connections per destination data node to this value. If the
@b maximum-parallelism option is set, then the server may
increase the number of parallel connections to per destination data
node to at most this value.
@section refs References
@anchor rfc959 [1]
Postel, J. and Reynolds, J., "
FILE TRANSFER PROTOCOL (FTP)", STD 9, RFC 959, October 1985.
@anchor rfc2389 [2]
Hethmon, P. and Elz, R., "
Feature negotiation mechanism for the File Transfer Protocol",
RFC 2389, August 1998.
@anchor rfc2228 [3]
Horowitz, M. and Lunt, S., "
FTP Security Extensions", RFC 2228, October 1997.
@anchor ietfftpext [4]
Elz, R. and Hethom, P., "
FTP Extensions", IETF Draft, May 2001.
@section appendix_i Appendix I: Implementation under GSI
There are several security components in this document which are extensions
to the behavior of RFC 2228. These appendix attempts to clarify the protocol
how these extensions map to the OpenSSL-based implementation of the GSSAPI
known as GSI (Grid Security Infrastructure).
A client implementation which communicates with a server which supports the
DCAU extension should delegate a limited credential set (using
the GSS_C_DELEG_FLAG and GSS_C_GLOBUS_LIMITED_DELEG_PROXY_FLAG flags to
gss_init_sec_context()). If delegation is not performed, the client MUST
request that DCAU be disable by requesting DCAU N, or the server will be
unable to perform the default of DCAU A as described by this document.
When DCAU mode "A" or "S" is used, a separate security context is established
on each data channel. The context is established by performing the GSSAPI
handshake with the active-DTP calling gss_init_sec_context() and the
passive-DTP calling gss_accept_sec_context(). No delegation need be done
on these data channels.
Data channel protection via the PROT command MUST always be used in conjunction
with the DCAU A or DCAU S commands. If a PROT level is set, then messages will
be wrapped according to RFC 2228 Appendix I using the contexts established on
each data channel. Tokens transferred over the data channels when either PROT
or DCAU is used are not framed in any way when using GSI. (When implementing
this specification with other GSSAPI mechanisms, a 4 byte, big endian, binary
token length should proceed all tokens).
If the DCAU mode or the PROT mode is changed between file transfers when
caching data channels in extended block mode, all open data channels must be
closed. This is because the GSI implementation does not support changing levels
of protection on an existing connection.
*/
globus_ftp_control-9.10/PaxHeaders.24857/GLOBUS_LICENSE 0000644 0000000 0000000 00000000131 14243161125 020433 x ustar 00 0000000 0000000 30 mtime=1653400149.407969625
30 atime=1653401902.242459247
29 ctime=1653404005.19890002
globus_ftp_control-9.10/GLOBUS_LICENSE 0000664 0001750 0001750 00000023676 14243161125 020604 0 ustar 00johndoe johndoe 0000000 0000000
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
globus_ftp_control-9.10/PaxHeaders.24857/test 0000644 0000000 0000000 00000000132 14243170545 017264 x ustar 00 0000000 0000000 30 mtime=1653404005.279899248
30 atime=1653404005.292899124
30 ctime=1653404005.279899248
globus_ftp_control-9.10/test/ 0000775 0001750 0001750 00000000000 14243170545 017473 5 ustar 00johndoe johndoe 0000000 0000000 globus_ftp_control-9.10/test/PaxHeaders.24857/Makefile.in 0000644 0000000 0000000 00000000132 14243161725 021406 x ustar 00 0000000 0000000 30 mtime=1653400533.150081207
30 atime=1653401125.355166033
30 ctime=1653404005.247899553
globus_ftp_control-9.10/test/Makefile.in 0000664 0001750 0001750 00000124273 14243161725 021551 0 ustar 00johndoe johndoe 0000000 0000000 # Makefile.in generated by automake 1.13.4 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
check_PROGRAMS = connect_test$(EXEEXT) data_test$(EXEEXT) \
get_lingering_close$(EXEEXT) globus_ftp_control_test$(EXEEXT) \
pipe_test$(EXEEXT) test_server$(EXEEXT)
@ENABLE_TESTS_TRUE@TESTS = connect_test$(EXEEXT) data_test$(EXEEXT) \
@ENABLE_TESTS_TRUE@ pipe_test$(EXEEXT) $(check_SCRIPTS)
subdir = test
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
$(srcdir)/testcred.cnf.in $(top_srcdir)/build-aux/depcomp \
$(top_srcdir)/build-aux/test-driver
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
$(top_srcdir)/dirt.sh $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
CONFIG_CLEAN_FILES = testcred.cnf
CONFIG_CLEAN_VPATH_FILES =
am__DEPENDENCIES_1 =
libtest_common_la_DEPENDENCIES = ../libglobus_ftp_control.la \
$(am__DEPENDENCIES_1)
am_libtest_common_la_OBJECTS = connect_disconnect_test.lo \
test_common.lo
libtest_common_la_OBJECTS = $(am_libtest_common_la_OBJECTS)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
am__v_lt_1 =
connect_test_SOURCES = connect_test.c
connect_test_OBJECTS = connect_test.$(OBJEXT)
am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) libtest_common.la \
../libglobus_ftp_control.la $(am__DEPENDENCIES_1)
connect_test_DEPENDENCIES = $(am__DEPENDENCIES_2)
connect_test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(connect_test_LDFLAGS) $(LDFLAGS) -o $@
am_data_test_OBJECTS = data_test.$(OBJEXT)
data_test_OBJECTS = $(am_data_test_OBJECTS)
data_test_DEPENDENCIES = $(am__DEPENDENCIES_2)
data_test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(data_test_LDFLAGS) $(LDFLAGS) -o $@
get_lingering_close_SOURCES = get_lingering_close.c
get_lingering_close_OBJECTS = get_lingering_close.$(OBJEXT)
get_lingering_close_DEPENDENCIES = $(am__DEPENDENCIES_2)
get_lingering_close_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
$(AM_CFLAGS) $(CFLAGS) $(get_lingering_close_LDFLAGS) \
$(LDFLAGS) -o $@
am_globus_ftp_control_test_OBJECTS = abort_test.$(OBJEXT) \
async_control_test.$(OBJEXT) globus_ftp_control_test.$(OBJEXT) \
eb_simple_data_test.$(OBJEXT) outstanding_io_test.$(OBJEXT) \
simple_control_test.$(OBJEXT) simple_data_test.$(OBJEXT) \
simple_dir_test.$(OBJEXT)
globus_ftp_control_test_OBJECTS = \
$(am_globus_ftp_control_test_OBJECTS)
globus_ftp_control_test_DEPENDENCIES = $(am__DEPENDENCIES_2)
globus_ftp_control_test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
$(AM_CFLAGS) $(CFLAGS) $(globus_ftp_control_test_LDFLAGS) \
$(LDFLAGS) -o $@
pipe_test_SOURCES = pipe_test.c
pipe_test_OBJECTS = pipe_test.$(OBJEXT)
pipe_test_DEPENDENCIES = $(am__DEPENDENCIES_2)
pipe_test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(pipe_test_LDFLAGS) $(LDFLAGS) -o $@
test_server_SOURCES = test_server.c
test_server_OBJECTS = test_server.$(OBJEXT)
test_server_DEPENDENCIES = $(am__DEPENDENCIES_2)
test_server_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(test_server_LDFLAGS) $(LDFLAGS) -o $@
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
DEFAULT_INCLUDES = -I.@am__isrc@
depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CFLAGS) $(CFLAGS)
AM_V_CC = $(am__v_CC_@AM_V@)
am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
am__v_CC_0 = @echo " CC " $@;
am__v_CC_1 =
CCLD = $(CC)
LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
SOURCES = $(libtest_common_la_SOURCES) connect_test.c \
$(data_test_SOURCES) get_lingering_close.c \
$(globus_ftp_control_test_SOURCES) pipe_test.c test_server.c
DIST_SOURCES = $(libtest_common_la_SOURCES) connect_test.c \
$(data_test_SOURCES) get_lingering_close.c \
$(globus_ftp_control_test_SOURCES) pipe_test.c test_server.c
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
BEGIN { nonempty = 0; } \
{ items[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique. This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
list='$(am__tagged_files)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
am__tty_colors_dummy = \
mgn= red= grn= lgn= blu= brg= std=; \
am__color_tests=no
am__tty_colors = { \
$(am__tty_colors_dummy); \
if test "X$(AM_COLOR_TESTS)" = Xno; then \
am__color_tests=no; \
elif test "X$(AM_COLOR_TESTS)" = Xalways; then \
am__color_tests=yes; \
elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \
am__color_tests=yes; \
fi; \
if test $$am__color_tests = yes; then \
red='[0;31m'; \
grn='[0;32m'; \
lgn='[1;32m'; \
blu='[1;34m'; \
mgn='[0;35m'; \
brg='[1m'; \
std='[m'; \
fi; \
}
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
*) f=$$p;; \
esac;
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
am__install_max = 40
am__nobase_strip_setup = \
srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
am__nobase_strip = \
for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
am__nobase_list = $(am__nobase_strip_setup); \
for p in $$list; do echo "$$p $$p"; done | \
sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
$(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
if (++n[$$2] == $(am__install_max)) \
{ print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
END { for (dir in files) print dir, files[dir] }'
am__base_list = \
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
am__uninstall_files_from_dir = { \
test -z "$$files" \
|| { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
$(am__cd) "$$dir" && rm -f $$files; }; \
}
am__recheck_rx = ^[ ]*:recheck:[ ]*
am__global_test_result_rx = ^[ ]*:global-test-result:[ ]*
am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]*
# A command that, given a newline-separated list of test names on the
# standard input, print the name of the tests that are to be re-run
# upon "make recheck".
am__list_recheck_tests = $(AWK) '{ \
recheck = 1; \
while ((rc = (getline line < ($$0 ".trs"))) != 0) \
{ \
if (rc < 0) \
{ \
if ((getline line2 < ($$0 ".log")) < 0) \
recheck = 0; \
break; \
} \
else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \
{ \
recheck = 0; \
break; \
} \
else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \
{ \
break; \
} \
}; \
if (recheck) \
print $$0; \
close ($$0 ".trs"); \
close ($$0 ".log"); \
}'
# A command that, given a newline-separated list of test names on the
# standard input, create the global log from their .trs and .log files.
am__create_global_log = $(AWK) ' \
function fatal(msg) \
{ \
print "fatal: making $@: " msg | "cat >&2"; \
exit 1; \
} \
function rst_section(header) \
{ \
print header; \
len = length(header); \
for (i = 1; i <= len; i = i + 1) \
printf "="; \
printf "\n\n"; \
} \
{ \
copy_in_global_log = 1; \
global_test_result = "RUN"; \
while ((rc = (getline line < ($$0 ".trs"))) != 0) \
{ \
if (rc < 0) \
fatal("failed to read from " $$0 ".trs"); \
if (line ~ /$(am__global_test_result_rx)/) \
{ \
sub("$(am__global_test_result_rx)", "", line); \
sub("[ ]*$$", "", line); \
global_test_result = line; \
} \
else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \
copy_in_global_log = 0; \
}; \
if (copy_in_global_log) \
{ \
rst_section(global_test_result ": " $$0); \
while ((rc = (getline line < ($$0 ".log"))) != 0) \
{ \
if (rc < 0) \
fatal("failed to read from " $$0 ".log"); \
print line; \
}; \
printf "\n"; \
}; \
close ($$0 ".trs"); \
close ($$0 ".log"); \
}'
# Restructured Text title.
am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; }
# Solaris 10 'make', and several other traditional 'make' implementations,
# pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it
# by disabling -e (using the XSI extension "set +e") if it's set.
am__sh_e_setup = case $$- in *e*) set +e;; esac
# Default flags passed to test drivers.
am__common_driver_flags = \
--color-tests "$$am__color_tests" \
--enable-hard-errors "$$am__enable_hard_errors" \
--expect-failure "$$am__expect_failure"
# To be inserted before the command running the test. Creates the
# directory for the log if needed. Stores in $dir the directory
# containing $f, in $tst the test, in $log the log. Executes the
# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and
# passes TESTS_ENVIRONMENT. Set up options for the wrapper that
# will run the test scripts (or their associated LOG_COMPILER, if
# thy have one).
am__check_pre = \
$(am__sh_e_setup); \
$(am__vpath_adj_setup) $(am__vpath_adj) \
$(am__tty_colors); \
srcdir=$(srcdir); export srcdir; \
case "$@" in \
*/*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \
*) am__odir=.;; \
esac; \
test "x$$am__odir" = x"." || test -d "$$am__odir" \
|| $(MKDIR_P) "$$am__odir" || exit $$?; \
if test -f "./$$f"; then dir=./; \
elif test -f "$$f"; then dir=; \
else dir="$(srcdir)/"; fi; \
tst=$$dir$$f; log='$@'; \
if test -n '$(DISABLE_HARD_ERRORS)'; then \
am__enable_hard_errors=no; \
else \
am__enable_hard_errors=yes; \
fi; \
case " $(XFAIL_TESTS) " in \
*[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \
am__expect_failure=yes;; \
*) \
am__expect_failure=no;; \
esac; \
$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT)
# A shell command to get the names of the tests scripts with any registered
# extension removed (i.e., equivalently, the names of the test logs, with
# the '.log' extension removed). The result is saved in the shell variable
# '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly,
# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)",
# since that might cause problem with VPATH rewrites for suffix-less tests.
# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'.
am__set_TESTS_bases = \
bases='$(TEST_LOGS)'; \
bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \
bases=`echo $$bases`
RECHECK_LOGS = $(TEST_LOGS)
AM_RECURSIVE_TARGETS = check recheck
TEST_SUITE_LOG = test-suite.log
TEST_EXTENSIONS = @EXEEXT@ .test
LOG_DRIVER = $(SHELL) $(top_srcdir)/build-aux/test-driver
LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS)
am__set_b = \
case '$@' in \
*/*) \
case '$*' in \
*/*) b='$*';; \
*) b=`echo '$@' | sed 's/\.log$$//'`; \
esac;; \
*) \
b='$*';; \
esac
am__test_logs1 = $(TESTS:=.log)
am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log)
TEST_LOGS = $(am__test_logs2:.test.log=.log)
TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/build-aux/test-driver
TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \
$(TEST_LOG_FLAGS)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AGE_VERSION = @AGE_VERSION@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
AS = @AS@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DIRT_BRANCH_ID = @DIRT_BRANCH_ID@
DIRT_TIMESTAMP = @DIRT_TIMESTAMP@
DLLTOOL = @DLLTOOL@
DOXYGEN = @DOXYGEN@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
GSI_DRIVER_CFLAGS = @GSI_DRIVER_CFLAGS@
GSI_DRIVER_DLOPEN = @GSI_DRIVER_DLOPEN@
GSI_DRIVER_DLPREOPEN = @GSI_DRIVER_DLPREOPEN@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAJOR_VERSION = @MAJOR_VERSION@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MINOR_VERSION = @MINOR_VERSION@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OPENSSL = @OPENSSL@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_DEPS = @PACKAGE_DEPS@
PACKAGE_DEP_CFLAGS = @PACKAGE_DEP_CFLAGS@
PACKAGE_DEP_LIBS = @PACKAGE_DEP_LIBS@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PKG_CONFIG = @PKG_CONFIG@
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
check_SCRIPTS = get_lingering_close.sh
check_DATA = \
testcred.key \
testcred.cert \
testcred.cakey \
testcred.cacert \
testcred.link \
testcred.signing_policy \
testcred.srl \
testcred.gridmap
AM_CPPFLAGS = -I$(top_srcdir) $(PACKAGE_DEP_CFLAGS)
test_ldadd = $(GSI_DRIVER_DLPREOPEN) libtest_common.la ../libglobus_ftp_control.la $(PACKAGE_DEP_LIBS) -lltdl
test_ldflags = -dlpreopen force
check_LTLIBRARIES = libtest_common.la
libtest_common_la_SOURCES = connect_disconnect_test.c test_common.c test_common.h
libtest_common_la_LIBADD = ../libglobus_ftp_control.la $(PACKAGE_DEP_LIBS)
data_test_SOURCES = data_test.c
data_test_LDADD = $(test_ldadd)
data_test_LDFLAGS = $(test_ldflags)
globus_ftp_control_test_SOURCES = \
abort_test.c \
async_control_test.c \
globus_ftp_control_test.c \
globus_ftp_control_test.h \
eb_simple_data_test.c \
outstanding_io_test.c \
simple_control_test.c \
simple_data_test.c \
simple_dir_test.c
connect_test_LDADD = $(test_ldadd)
connect_test_LDFLAGS = $(test_ldflags)
get_lingering_close_LDADD = $(test_ldadd)
get_lingering_close_LDFLAGS = $(test_ldflags)
globus_ftp_control_test_LDADD = $(test_ldadd)
globus_ftp_control_test_LDFLAGS = $(test_ldflags)
pipe_test_LDADD = $(test_ldadd)
pipe_test_LDFLAGS = $(test_ldflags)
test_server_LDADD = $(test_ldadd)
test_server_LDFLAGS = $(test_ldflags)
@CYGPATH_W_DEFINED_FALSE@@ENABLE_TESTS_TRUE@X509_CERT_DIR = $(abs_builddir)
@CYGPATH_W_DEFINED_TRUE@@ENABLE_TESTS_TRUE@X509_CERT_DIR = $$($(CYGPATH_W) $(abs_builddir))
@CYGPATH_W_DEFINED_FALSE@@ENABLE_TESTS_TRUE@GRIDMAP = $(abs_builddir)/testcred.gridmap
@CYGPATH_W_DEFINED_TRUE@@ENABLE_TESTS_TRUE@GRIDMAP = $$($(CYGPATH_W) $(abs_builddir)/testcred.gridmap)
@ENABLE_TESTS_TRUE@TESTS_ENVIRONMENT = export \
@ENABLE_TESTS_TRUE@ X509_USER_CERT=testcred.cert \
@ENABLE_TESTS_TRUE@ X509_USER_KEY=testcred.key \
@ENABLE_TESTS_TRUE@ X509_CERT_DIR=$(X509_CERT_DIR) \
@ENABLE_TESTS_TRUE@ GRIDMAP=$(GRIDMAP) \
@ENABLE_TESTS_TRUE@ PATH=$${PATH}:$(abs_builddir):$(abs_srcdir);
@ENABLE_TESTS_TRUE@LOG_COMPILER = $(LIBTOOL) --mode=execute $(GSI_DRIVER_DLOPEN)
@ENABLE_TESTS_TRUE@CLEANFILES = testcred.key testcred.cert testcred.req \
@ENABLE_TESTS_TRUE@ testcred.cacert testcred.srl \
@ENABLE_TESTS_TRUE@ testcred.cakey testcred.gridmap \
@ENABLE_TESTS_TRUE@ get_lingering_close.sh.port
@ENABLE_TESTS_TRUE@SUFFIXES = .key .req .cert
EXTRA_DIST = $(check_SCRIPTS)
all: all-am
.SUFFIXES:
.SUFFIXES: .key .req .cert .c .cacert .cakey .cnf .gridmap .link .lo .log .o .obj .signing_policy .srl .test .test$(EXEEXT) .trs
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign test/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --foreign test/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
testcred.cnf: $(top_builddir)/config.status $(srcdir)/testcred.cnf.in
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
clean-checkLTLIBRARIES:
-test -z "$(check_LTLIBRARIES)" || rm -f $(check_LTLIBRARIES)
@list='$(check_LTLIBRARIES)'; \
locs=`for p in $$list; do echo $$p; done | \
sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
sort -u`; \
test -z "$$locs" || { \
echo rm -f $${locs}; \
rm -f $${locs}; \
}
libtest_common.la: $(libtest_common_la_OBJECTS) $(libtest_common_la_DEPENDENCIES) $(EXTRA_libtest_common_la_DEPENDENCIES)
$(AM_V_CCLD)$(LINK) $(libtest_common_la_OBJECTS) $(libtest_common_la_LIBADD) $(LIBS)
clean-checkPROGRAMS:
@list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \
echo " rm -f" $$list; \
rm -f $$list || exit $$?; \
test -n "$(EXEEXT)" || exit 0; \
list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
echo " rm -f" $$list; \
rm -f $$list
connect_test$(EXEEXT): $(connect_test_OBJECTS) $(connect_test_DEPENDENCIES) $(EXTRA_connect_test_DEPENDENCIES)
@rm -f connect_test$(EXEEXT)
$(AM_V_CCLD)$(connect_test_LINK) $(connect_test_OBJECTS) $(connect_test_LDADD) $(LIBS)
data_test$(EXEEXT): $(data_test_OBJECTS) $(data_test_DEPENDENCIES) $(EXTRA_data_test_DEPENDENCIES)
@rm -f data_test$(EXEEXT)
$(AM_V_CCLD)$(data_test_LINK) $(data_test_OBJECTS) $(data_test_LDADD) $(LIBS)
get_lingering_close$(EXEEXT): $(get_lingering_close_OBJECTS) $(get_lingering_close_DEPENDENCIES) $(EXTRA_get_lingering_close_DEPENDENCIES)
@rm -f get_lingering_close$(EXEEXT)
$(AM_V_CCLD)$(get_lingering_close_LINK) $(get_lingering_close_OBJECTS) $(get_lingering_close_LDADD) $(LIBS)
globus_ftp_control_test$(EXEEXT): $(globus_ftp_control_test_OBJECTS) $(globus_ftp_control_test_DEPENDENCIES) $(EXTRA_globus_ftp_control_test_DEPENDENCIES)
@rm -f globus_ftp_control_test$(EXEEXT)
$(AM_V_CCLD)$(globus_ftp_control_test_LINK) $(globus_ftp_control_test_OBJECTS) $(globus_ftp_control_test_LDADD) $(LIBS)
pipe_test$(EXEEXT): $(pipe_test_OBJECTS) $(pipe_test_DEPENDENCIES) $(EXTRA_pipe_test_DEPENDENCIES)
@rm -f pipe_test$(EXEEXT)
$(AM_V_CCLD)$(pipe_test_LINK) $(pipe_test_OBJECTS) $(pipe_test_LDADD) $(LIBS)
test_server$(EXEEXT): $(test_server_OBJECTS) $(test_server_DEPENDENCIES) $(EXTRA_test_server_DEPENDENCIES)
@rm -f test_server$(EXEEXT)
$(AM_V_CCLD)$(test_server_LINK) $(test_server_OBJECTS) $(test_server_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/abort_test.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/async_control_test.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/connect_disconnect_test.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/connect_test.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/data_test.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eb_simple_data_test.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/get_lingering_close.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/globus_ftp_control_test.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/outstanding_io_test.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pipe_test.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/simple_control_test.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/simple_data_test.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/simple_dir_test.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_common.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_server.Po@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c $<
.c.obj:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'`
.c.lo:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
ID: $(am__tagged_files)
$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-am
TAGS: tags
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
set x; \
here=`pwd`; \
$(am__define_uniq_tagged_files); \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: ctags-am
CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
$(am__define_uniq_tagged_files); \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
cscopelist: cscopelist-am
cscopelist-am: $(am__tagged_files)
list='$(am__tagged_files)'; \
case "$(srcdir)" in \
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
*) sdir=$(subdir)/$(srcdir) ;; \
esac; \
for i in $$list; do \
if test -f "$$i"; then \
echo "$(subdir)/$$i"; \
else \
echo "$$sdir/$$i"; \
fi; \
done >> $(top_builddir)/cscope.files
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
# Recover from deleted '.trs' file; this should ensure that
# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create
# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells
# to avoid problems with "make -n".
.log.trs:
rm -f $< $@
$(MAKE) $(AM_MAKEFLAGS) $<
# Leading 'am--fnord' is there to ensure the list of targets does not
# expand to empty, as could happen e.g. with make check TESTS=''.
am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck)
am--force-recheck:
@:
$(TEST_SUITE_LOG): $(TEST_LOGS)
@$(am__set_TESTS_bases); \
am__f_ok () { test -f "$$1" && test -r "$$1"; }; \
redo_bases=`for i in $$bases; do \
am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \
done`; \
if test -n "$$redo_bases"; then \
redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \
redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \
if $(am__make_dryrun); then :; else \
rm -f $$redo_logs && rm -f $$redo_results || exit 1; \
fi; \
fi; \
if test -n "$$am__remaking_logs"; then \
echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \
"recursion detected" >&2; \
else \
am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \
fi; \
if $(am__make_dryrun); then :; else \
st=0; \
errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \
for i in $$redo_bases; do \
test -f $$i.trs && test -r $$i.trs \
|| { echo "$$errmsg $$i.trs" >&2; st=1; }; \
test -f $$i.log && test -r $$i.log \
|| { echo "$$errmsg $$i.log" >&2; st=1; }; \
done; \
test $$st -eq 0 || exit 1; \
fi
@$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \
ws='[ ]'; \
results=`for b in $$bases; do echo $$b.trs; done`; \
test -n "$$results" || results=/dev/null; \
all=` grep "^$$ws*:test-result:" $$results | wc -l`; \
pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \
fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \
skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \
xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \
xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \
error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \
if test `expr $$fail + $$xpass + $$error` -eq 0; then \
success=true; \
else \
success=false; \
fi; \
br='==================='; br=$$br$$br$$br$$br; \
result_count () \
{ \
if test x"$$1" = x"--maybe-color"; then \
maybe_colorize=yes; \
elif test x"$$1" = x"--no-color"; then \
maybe_colorize=no; \
else \
echo "$@: invalid 'result_count' usage" >&2; exit 4; \
fi; \
shift; \
desc=$$1 count=$$2; \
if test $$maybe_colorize = yes && test $$count -gt 0; then \
color_start=$$3 color_end=$$std; \
else \
color_start= color_end=; \
fi; \
echo "$${color_start}# $$desc $$count$${color_end}"; \
}; \
create_testsuite_report () \
{ \
result_count $$1 "TOTAL:" $$all "$$brg"; \
result_count $$1 "PASS: " $$pass "$$grn"; \
result_count $$1 "SKIP: " $$skip "$$blu"; \
result_count $$1 "XFAIL:" $$xfail "$$lgn"; \
result_count $$1 "FAIL: " $$fail "$$red"; \
result_count $$1 "XPASS:" $$xpass "$$red"; \
result_count $$1 "ERROR:" $$error "$$mgn"; \
}; \
{ \
echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \
$(am__rst_title); \
create_testsuite_report --no-color; \
echo; \
echo ".. contents:: :depth: 2"; \
echo; \
for b in $$bases; do echo $$b; done \
| $(am__create_global_log); \
} >$(TEST_SUITE_LOG).tmp || exit 1; \
mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \
if $$success; then \
col="$$grn"; \
else \
col="$$red"; \
test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \
fi; \
echo "$${col}$$br$${std}"; \
echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \
echo "$${col}$$br$${std}"; \
create_testsuite_report --maybe-color; \
echo "$$col$$br$$std"; \
if $$success; then :; else \
echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \
if test -n "$(PACKAGE_BUGREPORT)"; then \
echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \
fi; \
echo "$$col$$br$$std"; \
fi; \
$$success || exit 1
check-TESTS:
@list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list
@list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list
@test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
@set +e; $(am__set_TESTS_bases); \
log_list=`for i in $$bases; do echo $$i.log; done`; \
trs_list=`for i in $$bases; do echo $$i.trs; done`; \
log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \
$(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \
exit $$?;
recheck: all $(check_LTLIBRARIES) $(check_PROGRAMS) $(check_SCRIPTS) $(check_DATA)
@test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
@set +e; $(am__set_TESTS_bases); \
bases=`for i in $$bases; do echo $$i; done \
| $(am__list_recheck_tests)` || exit 1; \
log_list=`for i in $$bases; do echo $$i.log; done`; \
log_list=`echo $$log_list`; \
$(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \
am__force_recheck=am--force-recheck \
TEST_LOGS="$$log_list"; \
exit $$?
connect_test.log: connect_test$(EXEEXT)
@p='connect_test$(EXEEXT)'; \
b='connect_test'; \
$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
data_test.log: data_test$(EXEEXT)
@p='data_test$(EXEEXT)'; \
b='data_test'; \
$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
pipe_test.log: pipe_test$(EXEEXT)
@p='pipe_test$(EXEEXT)'; \
b='pipe_test'; \
$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
get_lingering_close.sh.log: get_lingering_close.sh
@p='get_lingering_close.sh'; \
b='get_lingering_close.sh'; \
$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
.test.log:
@p='$<'; \
$(am__set_b); \
$(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
@am__EXEEXT_TRUE@.test$(EXEEXT).log:
@am__EXEEXT_TRUE@ @p='$<'; \
@am__EXEEXT_TRUE@ $(am__set_b); \
@am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \
@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \
@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \
@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT)
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
check-am: all-am
$(MAKE) $(AM_MAKEFLAGS) $(check_LTLIBRARIES) $(check_PROGRAMS) \
$(check_SCRIPTS) $(check_DATA)
$(MAKE) $(AM_MAKEFLAGS) check-TESTS
check: check-am
all-am: Makefile
installdirs:
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
-test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS)
-test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs)
-test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
clean-generic:
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
@ENABLE_TESTS_FALSE@clean-local:
clean: clean-am
clean-am: clean-checkLTLIBRARIES clean-checkPROGRAMS clean-generic \
clean-libtool clean-local mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
html-am:
info: info-am
info-am:
install-data-am:
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am:
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am:
.MAKE: check-am install-am install-strip
.PHONY: CTAGS GTAGS TAGS all all-am check check-TESTS check-am clean \
clean-checkLTLIBRARIES clean-checkPROGRAMS clean-generic \
clean-libtool clean-local cscopelist-am ctags ctags-am \
distclean distclean-compile distclean-generic \
distclean-libtool distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-data \
install-data-am install-dvi install-dvi-am install-exec \
install-exec-am install-html install-html-am install-info \
install-info-am install-man install-pdf install-pdf-am \
install-ps install-ps-am install-strip installcheck \
installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
recheck tags tags-am uninstall uninstall-am
# Test CA
@ENABLE_TESTS_TRUE@.cnf.cacert:
@ENABLE_TESTS_TRUE@ umask 077; $(OPENSSL) req -passout pass:globus -subj "/CN=ca" -new -x509 -extensions v3_ca -keyout $*.cakey -out $@ -config $<
@ENABLE_TESTS_TRUE@.cacert.cakey:
@ENABLE_TESTS_TRUE@ :
@ENABLE_TESTS_TRUE@.cacert.link:
@ENABLE_TESTS_TRUE@ linkname="`$(OPENSSL) x509 -hash -noout -in $<`.0"; \
@ENABLE_TESTS_TRUE@ rm -f "$$linkname"; \
@ENABLE_TESTS_TRUE@ cp $< "$$linkname"; \
@ENABLE_TESTS_TRUE@ echo "$$linkname" > $@
@ENABLE_TESTS_TRUE@.link.signing_policy:
@ENABLE_TESTS_TRUE@ linkname=`cat $<`; \
@ENABLE_TESTS_TRUE@ policyfile=$${linkname%.0}.signing_policy; \
@ENABLE_TESTS_TRUE@ echo "access_id_CA X509 '/CN=ca'" > $${policyfile}; \
@ENABLE_TESTS_TRUE@ echo "pos_rights globus CA:sign" >> $${policyfile}; \
@ENABLE_TESTS_TRUE@ echo "cond_subjects globus '\"/*\"'" >> $${policyfile}; \
@ENABLE_TESTS_TRUE@ echo $${policyfile} >> $@
@ENABLE_TESTS_TRUE@.signing_policy.srl:
@ENABLE_TESTS_TRUE@ echo 01 > $@
# Test Cert/Key
@ENABLE_TESTS_TRUE@.srl.key:
@ENABLE_TESTS_TRUE@ umask 077; $(OPENSSL) genrsa -out $@ 2048
@ENABLE_TESTS_TRUE@.key.req:
@ENABLE_TESTS_TRUE@ $(OPENSSL) req -subj "/CN=test" -new -key $< -out $@ -config $*.cnf
@ENABLE_TESTS_TRUE@.req.cert:
@ENABLE_TESTS_TRUE@ umask 022; $(OPENSSL) x509 -passin pass:globus -req -days 365 -in testcred.req -CA $*.cacert -CAkey $*.cakey -out $@
@ENABLE_TESTS_TRUE@.cert.gridmap:
@ENABLE_TESTS_TRUE@ subject=`$(OPENSSL) x509 -subject -noout -in $< -nameopt sep_multiline | sed -e '/^subject=/d' -e 's!^\s*!/!' | tr -d '\n'`; \
@ENABLE_TESTS_TRUE@ echo "\"$$subject\" `id -un`" > $@
@ENABLE_TESTS_TRUE@clean-local:
@ENABLE_TESTS_TRUE@ if [ -f testcred.link ]; then \
@ENABLE_TESTS_TRUE@ rm -f $$(cat testcred.link) testcred.link; \
@ENABLE_TESTS_TRUE@ fi
@ENABLE_TESTS_TRUE@ if test -f testcred.signing_policy; then \
@ENABLE_TESTS_TRUE@ rm -f $$(cat testcred.signing_policy) testcred.signing_policy; \
@ENABLE_TESTS_TRUE@ fi
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
globus_ftp_control-9.10/test/PaxHeaders.24857/Makefile.am 0000644 0000000 0000000 00000000132 14243161125 021367 x ustar 00 0000000 0000000 30 mtime=1653400149.412969574
30 atime=1653400533.074081977
30 ctime=1653404005.249899534
globus_ftp_control-9.10/test/Makefile.am 0000664 0001750 0001750 00000007236 14243161125 021531 0 ustar 00johndoe johndoe 0000000 0000000 check_PROGRAMS = \
connect_test \
data_test \
get_lingering_close \
globus_ftp_control_test \
pipe_test \
test_server
check_SCRIPTS = get_lingering_close.sh
check_DATA = \
testcred.key \
testcred.cert \
testcred.cakey \
testcred.cacert \
testcred.link \
testcred.signing_policy \
testcred.srl \
testcred.gridmap
AM_CPPFLAGS = -I$(top_srcdir) $(PACKAGE_DEP_CFLAGS)
test_ldadd = $(GSI_DRIVER_DLPREOPEN) libtest_common.la ../libglobus_ftp_control.la $(PACKAGE_DEP_LIBS) -lltdl
test_ldflags = -dlpreopen force
check_LTLIBRARIES = libtest_common.la
libtest_common_la_SOURCES = connect_disconnect_test.c test_common.c test_common.h
libtest_common_la_LIBADD = ../libglobus_ftp_control.la $(PACKAGE_DEP_LIBS)
data_test_SOURCES = data_test.c
data_test_LDADD = $(test_ldadd)
data_test_LDFLAGS = $(test_ldflags)
globus_ftp_control_test_SOURCES = \
abort_test.c \
async_control_test.c \
globus_ftp_control_test.c \
globus_ftp_control_test.h \
eb_simple_data_test.c \
outstanding_io_test.c \
simple_control_test.c \
simple_data_test.c \
simple_dir_test.c
connect_test_LDADD = $(test_ldadd)
connect_test_LDFLAGS = $(test_ldflags)
get_lingering_close_LDADD = $(test_ldadd)
get_lingering_close_LDFLAGS = $(test_ldflags)
globus_ftp_control_test_LDADD = $(test_ldadd)
globus_ftp_control_test_LDFLAGS = $(test_ldflags)
pipe_test_LDADD = $(test_ldadd)
pipe_test_LDFLAGS = $(test_ldflags)
test_server_LDADD = $(test_ldadd)
test_server_LDFLAGS = $(test_ldflags)
if ENABLE_TESTS
TESTS = \
connect_test \
data_test \
pipe_test \
$(check_SCRIPTS)
if CYGPATH_W_DEFINED
X509_CERT_DIR = $$($(CYGPATH_W) $(abs_builddir))
GRIDMAP = $$($(CYGPATH_W) $(abs_builddir)/testcred.gridmap)
else
X509_CERT_DIR = $(abs_builddir)
GRIDMAP = $(abs_builddir)/testcred.gridmap
endif
TESTS_ENVIRONMENT = export \
X509_USER_CERT=testcred.cert \
X509_USER_KEY=testcred.key \
X509_CERT_DIR=$(X509_CERT_DIR) \
GRIDMAP=$(GRIDMAP) \
PATH=$${PATH}:$(abs_builddir):$(abs_srcdir);
LOG_COMPILER = $(LIBTOOL) --mode=execute $(GSI_DRIVER_DLOPEN)
# Test CA
.cnf.cacert:
umask 077; $(OPENSSL) req -passout pass:globus -subj "/CN=ca" -new -x509 -extensions v3_ca -keyout $*.cakey -out $@ -config $<
.cacert.cakey:
:
.cacert.link:
linkname="`$(OPENSSL) x509 -hash -noout -in $<`.0"; \
rm -f "$$linkname"; \
cp $< "$$linkname"; \
echo "$$linkname" > $@
.link.signing_policy:
linkname=`cat $<`; \
policyfile=$${linkname%.0}.signing_policy; \
echo "access_id_CA X509 '/CN=ca'" > $${policyfile}; \
echo "pos_rights globus CA:sign" >> $${policyfile}; \
echo "cond_subjects globus '\"/*\"'" >> $${policyfile}; \
echo $${policyfile} >> $@
.signing_policy.srl:
echo 01 > $@
# Test Cert/Key
.srl.key:
umask 077; $(OPENSSL) genrsa -out $@ 2048
.key.req:
$(OPENSSL) req -subj "/CN=test" -new -key $< -out $@ -config $*.cnf
.req.cert:
umask 022; $(OPENSSL) x509 -passin pass:globus -req -days 365 -in testcred.req -CA $*.cacert -CAkey $*.cakey -out $@
.cert.gridmap:
subject=`$(OPENSSL) x509 -subject -noout -in $< -nameopt sep_multiline | sed -e '/^subject=/d' -e 's!^\s*!/!' | tr -d '\n'`; \
echo "\"$$subject\" `id -un`" > $@
CLEANFILES = testcred.key testcred.cert testcred.req \
testcred.cacert testcred.srl \
testcred.cakey testcred.gridmap \
get_lingering_close.sh.port
clean-local:
if [ -f testcred.link ]; then \
rm -f $$(cat testcred.link) testcred.link; \
fi
if test -f testcred.signing_policy; then \
rm -f $$(cat testcred.signing_policy) testcred.signing_policy; \
fi
SUFFIXES = .key .req .cert
endif
EXTRA_DIST = $(check_SCRIPTS)
globus_ftp_control-9.10/test/PaxHeaders.24857/testcred.cnf.in 0000644 0000000 0000000 00000000132 14243161125 022245 x ustar 00 0000000 0000000 30 mtime=1653400149.414969554
30 atime=1653401125.378165805
30 ctime=1653404005.250899524
globus_ftp_control-9.10/test/testcred.cnf.in 0000664 0001750 0001750 00000004502 14243161125 022400 0 ustar 00johndoe johndoe 0000000 0000000 HOME = .
RANDFILE = $ENV::HOME/.rnd
[ ca ]
default_ca = CA_default # The default ca section
[ CA_default ]
dir = . # Where everything is kept
certs = $dir/certs # Where the issued certs are kept
crl_dir = $dir/crl # Where the issued crl are kept
database = $dir/index.txt # database index file.
new_certs_dir = $dir/newcerts # default place for new certs.
certificate = $dir/cacert.pem # The CA certificate
serial = $dir/serial # The current serial number
crlnumber = $dir/crlnumber # the current crl number
# must be commented out to leave a V1 CRL
crl = $dir/crl.pem # The current CRL
private_key = $dir/private/cakey.pem# The private key
RANDFILE = $dir/private/.rand # private random number file
x509_extensions = usr_cert # The extentions to add to the cert
name_opt = ca_default # Subject Name options
cert_opt = ca_default # Certificate field options
default_days = 365 # how long to certify for
default_crl_days= 30 # how long before next CRL
default_md = default # use public key default MD
preserve = no # keep passed DN ordering
policy = policy_match
# For the CA policy
[ policy_match ]
commonName = supplied
# For the 'anything' policy
# At this point in time, you must list all acceptable 'object'
# types.
[ policy_anything ]
commonName = supplied
####################################################################
[ req ]
default_bits = 2048
default_md = sha256
default_keyfile = privkey.pem
distinguished_name = req_distinguished_name
attributes = req_attributes
x509_extensions = v3_ca
string_mask = utf8only
[ req_distinguished_name ]
commonName = Common Name (eg, your name or your server\'s hostname)
commonName_max = 64
[ req_attributes ]
challengePassword = A challenge password
challengePassword_min = 4
challengePassword_max = 20
unstructuredName = An optional company name
[ usr_cert ]
# PKIX recommendations harmless if included in all certificates.
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid,issuer
[ v3_req ]
# Extensions to add to a certificate request
basicConstraints = CA:FALSE
keyUsage = nonRepudiation, digitalSignature, keyEncipherment
[ v3_ca ]
# PKIX recommendation.
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid:always,issuer
basicConstraints = critical,CA:true
[ crl_ext ]
# CRL extensions.
authorityKeyIdentifier=keyid:always
globus_ftp_control-9.10/test/PaxHeaders.24857/connect_disconnect_test.c 0000644 0000000 0000000 00000000132 14243161125 024400 x ustar 00 0000000 0000000 30 mtime=1653400149.412969574
30 atime=1653401814.374286756
30 ctime=1653404005.253899496
globus_ftp_control-9.10/test/connect_disconnect_test.c 0000664 0001750 0001750 00000017751 14243161125 024545 0 ustar 00johndoe johndoe 0000000 0000000 /*
* Copyright 1999-2006 University of Chicago
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "globus_ftp_control_test.h"
#include "globus_common.h"
#include "gssapi.h"
static globus_ftp_control_test_monitor_t connect_monitor;
static globus_ftp_control_auth_info_t auth;
static gss_cred_id_t g_cred;
static char * g_user_name;
static char * g_password;
static char * g_base_dir;
static char * g_host;
static gss_name_t g_name;
static char * g_subject;
static unsigned short g_port;
void
connect_response_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_ftp_control_response_t * ftp_response)
{
globus_result_t result;
if(ftp_response == GLOBUS_NULL)
{
globus_mutex_lock(&connect_monitor.mutex);
{
connect_monitor.rc = GLOBUS_FALSE;
connect_monitor.done = GLOBUS_TRUE;
verbose_printf(2, "signal condition error:%s\n",
globus_object_printable_to_string(error));
globus_cond_signal(&connect_monitor.cond);
}
globus_mutex_unlock(&connect_monitor.mutex);
return;
}
verbose_printf(2, "connect_response_callback() : start: %s\n",
ftp_response->response_buffer);
if(ftp_response->code == 530)
{
verbose_printf(1, "not logged in: %s\n", ftp_response->response_buffer);
globus_mutex_lock(&connect_monitor.mutex);
{
connect_monitor.rc = GLOBUS_FALSE;
connect_monitor.done = GLOBUS_TRUE;
verbose_printf(2, "signal condition\n");
globus_cond_signal(&connect_monitor.cond);
}
globus_mutex_unlock(&connect_monitor.mutex);
}
else if(ftp_response->code == 220)
{
memset(&auth, '\0', sizeof(auth));
{
OM_uint32 maj, min;
gss_buffer_desc buffer;
maj = gss_acquire_cred(
&min,
GSS_C_NO_NAME,
0,
GSS_C_NO_OID_SET,
GSS_C_BOTH,
&g_cred,
NULL,
NULL);
gss_inquire_cred(&min,
g_cred,
&g_name,
NULL,
NULL,
NULL);
gss_display_name(
&min,
g_name,
&buffer,
NULL);
g_subject = buffer.value;
}
result = globus_ftp_control_auth_info_init(
&auth,
g_cred,
GLOBUS_FALSE,
g_user_name,
g_password,
NULL,
g_subject);
assert(result==GLOBUS_SUCCESS);
result = globus_ftp_control_authenticate(
handle,
&auth,
g_cred != GSS_C_NO_CREDENTIAL,
connect_response_callback,
NULL);
if(result != GLOBUS_SUCCESS)
{
printf("#####-> %s\n", globus_object_printable_to_string(globus_error_get(result)));
}
assert(result==GLOBUS_SUCCESS);
}
else if(ftp_response->code == 230)
{
result = globus_ftp_control_send_command(
handle,
"CWD %s\r\n",
connect_response_callback,
NULL,
g_base_dir);
if(result != GLOBUS_SUCCESS)
{
verbose_printf(1, "failed to send cd\n");
exit(1);
}
}
else if(ftp_response->code == 250)
{
globus_mutex_lock(&connect_monitor.mutex);
{
connect_monitor.rc = GLOBUS_TRUE;
connect_monitor.done = GLOBUS_TRUE;
globus_cond_signal(&connect_monitor.cond);
}
globus_mutex_unlock(&connect_monitor.mutex);
}
else if(ftp_response->code == 221)
{
globus_mutex_lock(&connect_monitor.mutex);
{
connect_monitor.rc = GLOBUS_TRUE;
connect_monitor.done = GLOBUS_TRUE;
globus_cond_signal(&connect_monitor.cond);
}
globus_mutex_unlock(&connect_monitor.mutex);
}
else if(ftp_response->code >= 500)
{
globus_mutex_lock(&connect_monitor.mutex);
{
connect_monitor.rc = GLOBUS_FALSE;
connect_monitor.done = GLOBUS_FALSE;
globus_cond_signal(&connect_monitor.cond);
}
globus_mutex_unlock(&connect_monitor.mutex);
}
}
globus_bool_t
connect_control_handle(
globus_ftp_control_handle_t * control_handle,
char * user_name,
char * password,
char * base_dir,
char * hostname,
unsigned short port)
{
globus_result_t result;
if (user_name && user_name[0] != 0)
{
g_user_name = user_name;
}
if (password && password[0] != 0)
{
g_password = password;
}
if (base_dir && base_dir[0] != 0)
{
g_base_dir = base_dir;
}
g_host = hostname;
g_port = port;
globus_mutex_init(&connect_monitor.mutex, GLOBUS_NULL);
globus_cond_init(&connect_monitor.cond, GLOBUS_NULL);
connect_monitor.done = GLOBUS_FALSE;
connect_monitor.rc = GLOBUS_TRUE;
result = globus_ftp_control_connect(
control_handle,
g_host,
g_port,
connect_response_callback,
GLOBUS_NULL);
if(result != GLOBUS_SUCCESS)
{
verbose_printf(1, "error: could not connect\n");
return GLOBUS_FALSE;
}
globus_mutex_lock(&connect_monitor.mutex);
{
verbose_printf(2, "waiting for signal\n");
while(!connect_monitor.done)
{
globus_cond_wait(&connect_monitor.cond, &connect_monitor.mutex);
}
}
globus_mutex_unlock(&connect_monitor.mutex);
verbose_printf(2, "connect_control_handle() : test %d\n",
connect_monitor.rc);
return connect_monitor.rc;
}
globus_bool_t
disconnect_control_handle(
globus_ftp_control_handle_t * control_handle)
{
globus_result_t result;
connect_monitor.done = GLOBUS_FALSE;
connect_monitor.rc = GLOBUS_TRUE;
result = globus_ftp_control_quit(
control_handle,
connect_response_callback,
GLOBUS_NULL);
if(result != GLOBUS_SUCCESS)
{
verbose_printf(1, "globus_ftp_control_quit() failed\n");
return GLOBUS_FALSE;
}
globus_mutex_lock(&connect_monitor.mutex);
{
while(!connect_monitor.done)
{
globus_cond_wait(&connect_monitor.cond, &connect_monitor.mutex);
}
}
globus_mutex_unlock(&connect_monitor.mutex);
globus_mutex_destroy(&connect_monitor.mutex);
globus_cond_destroy(&connect_monitor.cond);
connect_monitor.done = GLOBUS_FALSE;
return connect_monitor.rc;
}
globus_ftp_control-9.10/test/PaxHeaders.24857/test_common.c 0000644 0000000 0000000 00000000132 14243161125 022026 x ustar 00 0000000 0000000 30 mtime=1653400149.414969554
30 atime=1653401814.545285145
30 ctime=1653404005.254899486
globus_ftp_control-9.10/test/test_common.c 0000664 0001750 0001750 00000015535 14243161125 022171 0 ustar 00johndoe johndoe 0000000 0000000 /*
* Copyright 1999-2006 University of Chicago
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include
#include "globus_ftp_control_test.h"
#include "globus_common.h"
#include
#include "test_common.h"
int verbose_print_level;
void
ftp_test_monitor_reset(
ftp_test_monitor_t * monitor)
{
monitor->count = 0;
monitor->done = GLOBUS_FALSE;
monitor->result = GLOBUS_SUCCESS;
}
void
ftp_test_monitor_init(
ftp_test_monitor_t * monitor)
{
globus_mutex_init(&monitor->mutex, GLOBUS_NULL);
globus_cond_init(&monitor->cond, GLOBUS_NULL);
ftp_test_monitor_reset(monitor);
}
void
ftp_test_monitor_done_wait(
ftp_test_monitor_t * monitor)
{
globus_mutex_lock(&monitor->mutex);
{
while(!monitor->done)
{
globus_cond_wait(&monitor->cond, &monitor->mutex);
}
}
globus_mutex_unlock(&monitor->mutex);
}
void
ftp_test_monitor_count_wait(
ftp_test_monitor_t * monitor,
int count)
{
globus_mutex_lock(&monitor->mutex);
{
while(monitor->count < count)
{
globus_cond_wait(&monitor->cond, &monitor->mutex);
}
}
globus_mutex_unlock(&monitor->mutex);
}
void
ftp_test_monitor_signal(
ftp_test_monitor_t * monitor)
{
globus_mutex_lock(&monitor->mutex);
{
monitor->done = GLOBUS_TRUE;
monitor->count++;
globus_cond_signal(&monitor->cond);
}
globus_mutex_unlock(&monitor->mutex);
}
void
ftp_test_monitor_destroy(
ftp_test_monitor_t * monitor)
{
globus_mutex_destroy(&monitor->mutex);
globus_cond_destroy(&monitor->cond);
}
void
help_print()
{
printf("globus_ftp_control_test arguments:\n");
printf("--verbose [level]\n");
printf(" level 0 -- print overall success [default level]\n");
printf(" level 1 -- print individual test success\n");
printf(" level 2 -- print intermediate test messages\n");
printf(" level 3 -- print in loop test messages\n");
printf("--help\n");
}
void
fake_file_init(
globus_ftp_control_fake_file_t * fake_file,
int file_size,
int chunk_size)
{
int offset;
int len;
char * buf =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
fake_file->chunk_size = chunk_size;
fake_file->buffer = globus_malloc(chunk_size);
fake_file->file_size = file_size;
fake_file->offset = 0;
offset = 0;
while(offset < chunk_size)
{
len = chunk_size - offset;
if(len > strlen(buf))
{
len = strlen(buf);
}
memcpy(&fake_file->buffer[offset], buf, len);
offset += len;
}
}
void
fake_file_destroy(
globus_ftp_control_fake_file_t * fake_file)
{
globus_free(fake_file->buffer);
}
globus_byte_t *
fake_file_get_chunk(
globus_ftp_control_fake_file_t * fake_file,
int * size)
{
int offset;
offset = fake_file->offset % fake_file->chunk_size;
*size = fake_file->chunk_size - offset;
if(*size + fake_file->offset > fake_file->file_size)
{
*size = fake_file->file_size - fake_file->offset;
}
fake_file->offset += *size;
return fake_file->buffer;
}
globus_bool_t
fake_file_is_eof(
globus_ftp_control_fake_file_t * fake_file)
{
if(fake_file->offset >= fake_file->file_size)
{
return GLOBUS_TRUE;
}
else
{
return GLOBUS_FALSE;
}
}
globus_bool_t
fake_file_seek(
globus_ftp_control_fake_file_t * fake_file,
int offset)
{
if(fake_file->file_size > offset)
{
return GLOBUS_FALSE;
}
fake_file->offset = offset;
return GLOBUS_TRUE;
}
globus_bool_t
fake_file_cmp(
globus_ftp_control_fake_file_t * fake_file,
globus_byte_t * buffer,
int offset,
int length)
{
int start;
int ndx = 0;
int len = 0;
start = offset % fake_file->chunk_size;
while(ndx < length)
{
if(length + start - ndx < fake_file->chunk_size)
{
len = length - ndx;
}
else
{
len = fake_file->chunk_size - ndx - start;
}
if(memcmp(&buffer[ndx], &fake_file->buffer[start], len) != 0)
{
return GLOBUS_FALSE;
}
start = 0;
ndx += len;
}
return GLOBUS_TRUE;
}
void
verbose_printf(
int level,
char * s,
...)
{
va_list ap;
if(level > verbose_print_level)
{
return;
}
va_start(ap, s);
vprintf(s, ap);
va_end(ap);
fflush(stdout);
}
globus_bool_t
pasv_to_host_port(
char * astr,
globus_ftp_control_host_port_t * addr)
{
char * hostname;
char * port_str;
char * tmp_ptr;
unsigned short port;
int hi;
int low;
int ctr;
hostname = strchr(astr, '(') + 1;
tmp_ptr = strchr(hostname, ',');
for(ctr = 0; ctr < 3; ctr++)
{
if(tmp_ptr == GLOBUS_NULL)
{
return GLOBUS_FALSE;
}
tmp_ptr[0] = '.';
tmp_ptr++;
tmp_ptr = strchr(tmp_ptr, ',');
}
tmp_ptr[0] = '\0';
port_str = tmp_ptr + 1;
sscanf(port_str, "%d,%d", &hi, &low);
port = hi * 256;
port = port | low;
globus_ftp_control_host_port_init(
addr,
hostname,
port);
return GLOBUS_TRUE;
}
globus_ftp_control-9.10/test/PaxHeaders.24857/test_common.h 0000644 0000000 0000000 00000000131 14243161125 022032 x ustar 00 0000000 0000000 30 mtime=1653400149.414969554
29 atime=1653401814.34628702
30 ctime=1653404005.255899477
globus_ftp_control-9.10/test/test_common.h 0000664 0001750 0001750 00000007176 14243161125 022200 0 ustar 00johndoe johndoe 0000000 0000000 /*
* Copyright 1999-2006 University of Chicago
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#if !defined(TEST_COMMON_H)
#define TEST_COMMON_H 1
extern int verbose_print_level;
typedef struct ftp_test_monitor_s
{
globus_mutex_t mutex;
globus_cond_t cond;
globus_bool_t done;
int count;
globus_result_t result;
void * user_arg;
} ftp_test_monitor_t;
typedef struct globus_ftp_control_fake_file_t
{
globus_byte_t * buffer;
int chunk_size;
int file_size;
int offset;
} globus_ftp_control_fake_file_t;
void
ftp_test_monitor_init(
ftp_test_monitor_t * monitor);
void
ftp_test_monitor_reset(
ftp_test_monitor_t * monitor);
void
ftp_test_monitor_done_wait(
ftp_test_monitor_t * monitor);
void
ftp_test_monitor_count_wait(
ftp_test_monitor_t * monitor,
int count);
void
ftp_test_monitor_signal(
ftp_test_monitor_t * monitor);
void
help_print();
void
fake_file_init(
globus_ftp_control_fake_file_t * fake_file,
int file_size,
int chunk_size);
void
fake_file_destroy(
globus_ftp_control_fake_file_t * fake_file);
globus_byte_t *
fake_file_get_chunk(
globus_ftp_control_fake_file_t * fake_file,
int * size);
globus_bool_t
fake_file_is_eof(
globus_ftp_control_fake_file_t * fake_file);
globus_bool_t
fake_file_seek(
globus_ftp_control_fake_file_t * fake_file,
int offset);
globus_bool_t
fake_file_cmp(
globus_ftp_control_fake_file_t * fake_file,
globus_byte_t * buffer,
int offset,
int length);
void
verbose_printf(
int level,
char * s,
...);
globus_bool_t
pasv_to_host_port(
char * astr,
globus_ftp_control_host_port_t * addr);
globus_bool_t
disconnect_control_handle(
globus_ftp_control_handle_t * control_handle);
globus_bool_t
connect_control_handle(
globus_ftp_control_handle_t * control_handle,
char * user_name,
char * password,
char * base_dir,
char * hostname,
unsigned short port);
void
ftp_test_monitor_destroy(
ftp_test_monitor_t * monitor);
#endif
globus_ftp_control-9.10/test/PaxHeaders.24857/connect_test.c 0000644 0000000 0000000 00000000132 14243161125 022167 x ustar 00 0000000 0000000 30 mtime=1653400149.412969574
30 atime=1653401814.385286652
30 ctime=1653404005.257899458
globus_ftp_control-9.10/test/connect_test.c 0000664 0001750 0001750 00000102537 14243161125 022331 0 ustar 00johndoe johndoe 0000000 0000000 /*
* Copyright 1999-2017 University of Chicago
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "globus_common.h"
#include
#include "globus_preload.h"
#include "globus_ftp_control.h"
#include "gssapi.h"
#define TEST_USER "tester"
#define TEST_PASSWORD "password"
typedef struct
{
globus_ftp_control_server_t server;
unsigned short port;
globus_list_t *sessions;
globus_ftp_control_auth_requirements_t
auth_requirements;
globus_object_t *error;
globus_mutex_t mutex;
globus_cond_t cond;
}
auth_test_server_t;
typedef struct
{
auth_test_server_t *server;
globus_ftp_control_handle_t handle;
enum
{
SERVER_ACCEPT,
SERVER_AUTH,
SERVER_CMDS,
SERVER_QUIT,
SERVER_DONE,
}
server_state;
}
auth_test_server_session_t;
typedef struct
{
globus_ftp_control_handle_t handle;
bool expect_success;
globus_ftp_control_auth_info_t auth_info;
bool use_auth;
enum
{
CMD_CONNECT,
CMD_AUTHENTICATE,
CMD_QUIT,
CMD_DONE,
}
command;
globus_cond_t cond;
globus_mutex_t mutex;
globus_object_t *error;
}
auth_test_client_t;
static auth_test_server_t cleartext_server;
static auth_test_server_t tls_server;
static auth_test_server_t gssapi_server;
static
void
globus_l_server_close_callback(
void * callback_arg,
globus_ftp_control_handle_t *handle,
globus_object_t *error,
globus_ftp_control_response_t *ftp_response);
static
void
globus_l_server_response_callback(
void *callback_arg,
globus_ftp_control_handle_t *handle,
globus_object_t *error);
static
void
globus_l_client_callback(
void * callback_arg,
globus_ftp_control_handle_t *handle,
globus_object_t *error,
globus_ftp_control_response_t *ftp_response)
{
globus_result_t result = GLOBUS_SUCCESS;
auth_test_client_t *client = callback_arg;
globus_mutex_lock(&client->mutex);
if (error != NULL)
{
client->error = globus_object_copy(error);
result = globus_ftp_control_force_close(
handle,
globus_l_client_callback,
client);
client->command = CMD_QUIT;
if (result != GLOBUS_SUCCESS)
{
client->command = CMD_DONE;
globus_cond_signal(&client->cond);
}
}
else
{
switch (client->command)
{
case CMD_CONNECT:
result = globus_ftp_control_authenticate_ex(
handle,
&client->auth_info,
client->use_auth,
globus_l_client_callback,
client);
client->command = CMD_AUTHENTICATE;
break;
case CMD_AUTHENTICATE:
result = globus_ftp_control_quit(
handle,
globus_l_client_callback,
client);
client->command = CMD_QUIT;
if (result == GLOBUS_SUCCESS
&& ftp_response->code > 399)
{
client->error = globus_error_construct_string(
NULL,
NULL,
"Authentication failed: %.*s\n",
(int) ftp_response->response_length,
ftp_response->response_buffer);
}
break;
case CMD_QUIT:
client->command = CMD_DONE;
case CMD_DONE:
globus_cond_signal(&client->cond);
break;
}
if (result != GLOBUS_SUCCESS)
{
client->error = globus_error_get(result);
client->command = CMD_DONE;
globus_cond_signal(&client->cond);
}
}
globus_mutex_unlock(&client->mutex);
}
globus_result_t
authenticate_clear(
auth_test_server_t *server)
{
auth_test_client_t test_client =
{
.command = CMD_CONNECT,
};
globus_xio_attr_t attr = NULL;
globus_reltime_t timeout = {0};
globus_result_t result = GLOBUS_SUCCESS;
GlobusTimeReltimeSet(timeout, 5, 0);
globus_mutex_init(&test_client.mutex, NULL);
globus_cond_init(&test_client.cond, NULL);
result = globus_ftp_control_handle_init(
&test_client.handle);
if (result != GLOBUS_SUCCESS)
{
goto control_handle_init_fail;
}
result = globus_io_attr_get_xio_attr(
&test_client.handle.cc_handle.io_attr,
&attr);
if (result != GLOBUS_SUCCESS)
{
goto xio_attr_get_fail;
}
result = globus_xio_attr_cntl(
attr,
NULL,
GLOBUS_XIO_ATTR_SET_TIMEOUT_ALL,
NULL,
&timeout,
NULL);
if (result != GLOBUS_SUCCESS)
{
goto xio_attr_cntl_fail;
}
result = globus_ftp_control_auth_info_init(
&test_client.auth_info,
NULL,
false,
TEST_USER,
TEST_PASSWORD,
NULL,
NULL);
if (result != GLOBUS_SUCCESS)
{
goto auth_info_init_fail;
}
result = globus_ftp_control_connect(
&test_client.handle,
"localhost",
server->port,
globus_l_client_callback,
&test_client);
if (result != GLOBUS_SUCCESS)
{
goto connect_fail;
}
globus_mutex_lock(&test_client.mutex);
while (test_client.command != CMD_DONE)
{
globus_cond_wait(&test_client.cond, &test_client.mutex);
}
globus_mutex_unlock(&test_client.mutex);
connect_fail:
auth_info_init_fail:
xio_attr_cntl_fail:
xio_attr_get_fail:
globus_ftp_control_handle_destroy(&test_client.handle);
if (result != GLOBUS_SUCCESS)
{
control_handle_init_fail:
test_client.error = globus_error_get(result);
}
globus_cond_destroy(&test_client.cond);
globus_mutex_destroy(&test_client.mutex);
return (test_client.error == NULL) ? GLOBUS_SUCCESS : globus_error_put(test_client.error);
}
globus_result_t
authenticate_gssapi(
auth_test_server_t *server,
OM_uint32 req_flags)
{
auth_test_client_t test_client =
{
.command = CMD_CONNECT,
};
globus_xio_attr_t attr = NULL;
globus_reltime_t timeout = {0};
globus_result_t result = GLOBUS_SUCCESS;
GlobusTimeReltimeSet(timeout, 5, 0);
globus_mutex_init(&test_client.mutex, NULL);
globus_cond_init(&test_client.cond, NULL);
result = globus_ftp_control_handle_init(
&test_client.handle);
if (result != GLOBUS_SUCCESS)
{
goto control_handle_init_fail;
}
result = globus_io_attr_get_xio_attr(
&test_client.handle.cc_handle.io_attr,
&attr);
if (result != GLOBUS_SUCCESS)
{
goto xio_attr_get_fail;
}
result = globus_xio_attr_cntl(
attr,
NULL,
GLOBUS_XIO_ATTR_SET_TIMEOUT_ALL,
NULL,
&timeout,
NULL);
if (result != GLOBUS_SUCCESS)
{
goto xio_attr_cntl_fail;
}
result = globus_ftp_control_auth_info_init(
&test_client.auth_info,
GSS_C_NO_CREDENTIAL,
true,
TEST_USER,
TEST_PASSWORD,
NULL,
"/CN=test");
if (result != GLOBUS_SUCCESS)
{
goto auth_info_init_fail;
}
test_client.auth_info.req_flags = req_flags;
test_client.use_auth = true;
result = globus_ftp_control_connect(
&test_client.handle,
"localhost",
server->port,
globus_l_client_callback,
&test_client);
if (result != GLOBUS_SUCCESS)
{
goto connect_fail;
}
globus_mutex_lock(&test_client.mutex);
while (test_client.command != CMD_DONE)
{
globus_cond_wait(&test_client.cond, &test_client.mutex);
}
globus_mutex_unlock(&test_client.mutex);
connect_fail:
auth_info_init_fail:
xio_attr_cntl_fail:
xio_attr_get_fail:
globus_ftp_control_handle_destroy(&test_client.handle);
if (result != GLOBUS_SUCCESS)
{
control_handle_init_fail:
test_client.error = globus_error_get(result);
}
globus_cond_destroy(&test_client.cond);
globus_mutex_destroy(&test_client.mutex);
return (test_client.error == NULL) ? GLOBUS_SUCCESS : globus_error_put(test_client.error);
}
globus_result_t
authenticate_tls(
auth_test_server_t *server,
OM_uint32 req_flags)
{
auth_test_client_t test_client =
{
.command = CMD_CONNECT,
};
globus_xio_attr_t attr = NULL;
globus_reltime_t timeout = {0};
globus_result_t result = GLOBUS_SUCCESS;
GlobusTimeReltimeSet(timeout, 5, 0);
globus_mutex_init(&test_client.mutex, NULL);
globus_cond_init(&test_client.cond, NULL);
result = globus_ftp_control_handle_init(
&test_client.handle);
if (result != GLOBUS_SUCCESS)
{
goto control_handle_init_fail;
}
result = globus_io_attr_get_xio_attr(
&test_client.handle.cc_handle.io_attr,
&attr);
if (result != GLOBUS_SUCCESS)
{
goto xio_attr_get_fail;
}
result = globus_xio_attr_cntl(
attr,
NULL,
GLOBUS_XIO_ATTR_SET_TIMEOUT_ALL,
NULL,
&timeout,
NULL);
if (result != GLOBUS_SUCCESS)
{
goto xio_attr_cntl_fail;
}
result = globus_ftp_control_auth_info_init(
&test_client.auth_info,
GSS_C_NO_CREDENTIAL,
false,
TEST_USER,
TEST_PASSWORD,
NULL,
"/CN=test");
if (result != GLOBUS_SUCCESS)
{
goto auth_info_init_fail;
}
test_client.auth_info.req_flags = req_flags;
test_client.use_auth = false;
result = globus_ftp_control_use_tls(
&test_client.handle,
&test_client.auth_info);
if (result != GLOBUS_SUCCESS)
{
goto use_tls_fail;
}
result = globus_ftp_control_connect(
&test_client.handle,
"localhost",
server->port,
globus_l_client_callback,
&test_client);
if (result != GLOBUS_SUCCESS)
{
goto connect_fail;
}
globus_mutex_lock(&test_client.mutex);
while (test_client.command != CMD_DONE)
{
globus_cond_wait(&test_client.cond, &test_client.mutex);
}
globus_mutex_unlock(&test_client.mutex);
connect_fail:
use_tls_fail:
auth_info_init_fail:
xio_attr_cntl_fail:
xio_attr_get_fail:
globus_ftp_control_handle_destroy(&test_client.handle);
if (result != GLOBUS_SUCCESS)
{
control_handle_init_fail:
test_client.error = globus_error_get(result);
}
globus_cond_destroy(&test_client.cond);
globus_mutex_destroy(&test_client.mutex);
return (test_client.error == NULL) ? GLOBUS_SUCCESS : globus_error_put(test_client.error);
}
bool
authenticate_clear_test(void)
{
globus_result_t result = GLOBUS_SUCCESS;
result = authenticate_clear(&cleartext_server);
if (result != GLOBUS_SUCCESS)
{
char *msg = globus_error_print_friendly(globus_error_peek(result));
fprintf(
stderr,
"Error authenticating to cleartext server%s%s\n",
msg != NULL ? ": " : "",
msg != NULL ? msg : "");
free(msg);
}
return result == GLOBUS_SUCCESS;
}
static
bool
authenticate_clear_to_tls(void)
{
globus_result_t result = GLOBUS_SUCCESS;
result = authenticate_clear(&tls_server);
if (result != GLOBUS_SUCCESS)
{
char *msg = globus_error_print_friendly(globus_error_peek(result));
fprintf(
stderr,
"Error authenticating to tls server (this is expected)%s%s\n",
msg != NULL ? ": " : "",
msg != NULL ? msg : "");
free(msg);
}
return result != GLOBUS_SUCCESS;
}
static
bool
authenticate_clear_to_gssapi(void)
{
globus_result_t result = GLOBUS_SUCCESS;
result = authenticate_clear(&gssapi_server);
if (result != GLOBUS_SUCCESS)
{
char *msg = globus_error_print_friendly(globus_error_peek(result));
fprintf(
stderr,
"Error authenticating to gssapi server (this is expected)%s%s\n",
msg != NULL ? ": " : "",
msg != NULL ? msg : "");
free(msg);
}
return result != GLOBUS_SUCCESS;
}
static
bool
authenticate_gssapi_anonymous_to_clear(void)
{
globus_result_t result = GLOBUS_SUCCESS;
result = authenticate_gssapi(&cleartext_server, GSS_C_ANON_FLAG);
if (result != GLOBUS_SUCCESS)
{
char *msg = globus_error_print_friendly(globus_error_peek(result));
fprintf(
stderr,
"Error authenticating to cleartext server (this is expected)%s%s\n",
msg != NULL ? ": " : "",
msg != NULL ? msg : "");
free(msg);
}
return result != GLOBUS_SUCCESS;
}
static
bool
authenticate_gssapi_anonymous_to_tls(void)
{
globus_result_t result = GLOBUS_SUCCESS;
result = authenticate_gssapi(&tls_server, GSS_C_ANON_FLAG);
if (result != GLOBUS_SUCCESS)
{
char *msg = globus_error_print_friendly(globus_error_peek(result));
fprintf(
stderr,
"Error authenticating to tls server (this is expected)%s%s\n",
msg != NULL ? ": " : "",
msg != NULL ? msg : "");
free(msg);
}
return result != GLOBUS_SUCCESS;
}
static
bool
authenticate_gssapi_anonymous_to_gssapi(void)
{
globus_result_t result = GLOBUS_SUCCESS;
result = authenticate_gssapi(&gssapi_server, GSS_C_ANON_FLAG);
if (result != GLOBUS_SUCCESS)
{
char *msg = globus_error_print_friendly(globus_error_peek(result));
fprintf(
stderr,
"Error authenticating to gssapi server%s%s\n",
msg != NULL ? ": " : "",
msg != NULL ? msg : "");
free(msg);
}
return result == GLOBUS_SUCCESS;
}
static
bool
authenticate_tls_anonymous_to_clear(void)
{
globus_result_t result = GLOBUS_SUCCESS;
result = authenticate_tls(&cleartext_server, GSS_C_ANON_FLAG|GSS_C_CONF_FLAG);
if (result != GLOBUS_SUCCESS)
{
char *msg = globus_error_print_friendly(globus_error_peek(result));
fprintf(
stderr,
"Error authenticating to cleartext server (this is expected)%s%s\n",
msg != NULL ? ": " : "",
msg != NULL ? msg : "");
free(msg);
}
return result != GLOBUS_SUCCESS;
}
static
bool
authenticate_tls_anonymous_to_tls(void)
{
globus_result_t result = GLOBUS_SUCCESS;
result = authenticate_tls(&tls_server, GSS_C_ANON_FLAG|GSS_C_CONF_FLAG);
if (result != GLOBUS_SUCCESS)
{
char *msg = globus_error_print_friendly(globus_error_peek(result));
fprintf(
stderr,
"Error authenticating to tls server%s%s\n",
msg != NULL ? ": " : "",
msg != NULL ? msg : "");
free(msg);
}
return result == GLOBUS_SUCCESS;
}
static
bool
authenticate_tls_anonymous_to_gssapi(void)
{
globus_result_t result = GLOBUS_SUCCESS;
result = authenticate_tls(&gssapi_server, GSS_C_ANON_FLAG|GSS_C_CONF_FLAG);
if (result != GLOBUS_SUCCESS)
{
char *msg = globus_error_print_friendly(globus_error_peek(result));
fprintf(
stderr,
"Error authenticating to gssapi server (this is expected)%s%s\n",
msg != NULL ? ": " : "",
msg != NULL ? msg : "");
free(msg);
}
return result != GLOBUS_SUCCESS;
}
static
bool
authenticate_gssapi_to_clear(void)
{
globus_result_t result = GLOBUS_SUCCESS;
result = authenticate_gssapi(&cleartext_server, GSS_C_MUTUAL_FLAG);
if (result != GLOBUS_SUCCESS)
{
char *msg = globus_error_print_friendly(globus_error_peek(result));
fprintf(
stderr,
"Error authenticating to cleartext server (this is expected)%s%s\n",
msg != NULL ? ": " : "",
msg != NULL ? msg : "");
free(msg);
}
return result != GLOBUS_SUCCESS;
}
static
bool
authenticate_gssapi_to_tls(void)
{
globus_result_t result = GLOBUS_SUCCESS;
result = authenticate_gssapi(&tls_server, GSS_C_MUTUAL_FLAG);
if (result != GLOBUS_SUCCESS)
{
char *msg = globus_error_print_friendly(globus_error_peek(result));
fprintf(
stderr,
"Error authenticating to tls server (this is expected)%s%s\n",
msg != NULL ? ": " : "",
msg != NULL ? msg : "");
free(msg);
}
return result != GLOBUS_SUCCESS;
}
static
bool
authenticate_gssapi_to_gssapi(void)
{
globus_result_t result = GLOBUS_SUCCESS;
result = authenticate_gssapi(&gssapi_server, GSS_C_MUTUAL_FLAG);
if (result != GLOBUS_SUCCESS)
{
char *msg = globus_error_print_friendly(globus_error_peek(result));
fprintf(
stderr,
"Error authenticating to gssapi server%s%s\n",
msg != NULL ? ": " : "",
msg != NULL ? msg : "");
free(msg);
}
return result == GLOBUS_SUCCESS;
}
static
bool
authenticate_tls_to_clear(void)
{
globus_result_t result = GLOBUS_SUCCESS;
result = authenticate_tls(&cleartext_server, GSS_C_MUTUAL_FLAG|GSS_C_CONF_FLAG);
if (result != GLOBUS_SUCCESS)
{
char *msg = globus_error_print_friendly(globus_error_peek(result));
fprintf(
stderr,
"Error authenticating to cleartext server (this is expected)%s%s\n",
msg != NULL ? ": " : "",
msg != NULL ? msg : "");
free(msg);
}
return result != GLOBUS_SUCCESS;
}
static
bool
authenticate_tls_to_tls(void)
{
globus_result_t result = GLOBUS_SUCCESS;
result = authenticate_tls(&tls_server, GSS_C_MUTUAL_FLAG|GSS_C_CONF_FLAG);
if (result != GLOBUS_SUCCESS)
{
char *msg = globus_error_print_friendly(globus_error_peek(result));
fprintf(
stderr,
"Error authenticating to tls server%s%s\n",
msg != NULL ? ": " : "",
msg != NULL ? msg : "");
free(msg);
}
return result == GLOBUS_SUCCESS;
}
static
bool
authenticate_tls_to_gssapi(void)
{
globus_result_t result = GLOBUS_SUCCESS;
result = authenticate_tls(&gssapi_server, GSS_C_MUTUAL_FLAG|GSS_C_CONF_FLAG);
if (result != GLOBUS_SUCCESS)
{
char *msg = globus_error_print_friendly(globus_error_peek(result));
fprintf(
stderr,
"Error authenticating to gssapi server (this is expected)%s%s\n",
msg != NULL ? ": " : "",
msg != NULL ? msg : "");
free(msg);
}
return result != GLOBUS_SUCCESS;
}
static
void
globus_l_command_callback(
void *callback_arg,
globus_ftp_control_handle_t *handle,
globus_object_t *error,
union globus_ftp_control_command_u *command)
{
auth_test_server_session_t *session = callback_arg;
if (command != NULL)
{
switch (command->code)
{
case GLOBUS_FTP_CONTROL_COMMAND_QUIT:
session->server_state = SERVER_QUIT;
globus_ftp_control_send_response(
handle,
"221 Service closing control connection.",
globus_l_server_response_callback,
callback_arg);
break;
default:
globus_ftp_control_send_response(
handle,
"502 Command not implemented.",
globus_l_server_response_callback,
callback_arg);
break;
}
}
}
static
void
globus_l_server_auth_callback(
void *callback_arg,
globus_ftp_control_handle_t *handle,
globus_object_t *error,
globus_ftp_control_auth_info_t *auth_result)
{
auth_test_server_session_t *session = callback_arg;
globus_result_t res;
char * username;
globus_bool_t accepted;
if (error)
{
session->server_state = SERVER_DONE;
res = globus_ftp_control_force_close(
handle,
globus_l_server_close_callback,
callback_arg);
return;
}
accepted = GLOBUS_FALSE;
if(strcmp(auth_result->user, TEST_USER) == 0
&& strcmp(auth_result->password, TEST_PASSWORD) == 0)
{
username = auth_result->user;
accepted = true;
}
if(accepted)
{
res = globus_ftp_control_send_response(
handle,
"230 User %s logged on.\r\n",
globus_l_server_response_callback,
callback_arg,
username);
}
else
{
res = globus_ftp_control_send_response(
handle,
"530 No local mapping for Globus ID.\r\n",
globus_l_server_response_callback,
callback_arg);
}
if (res != GLOBUS_SUCCESS)
{
abort();
}
}
static
void
globus_l_server_close_callback(
void * callback_arg,
globus_ftp_control_handle_t *handle,
globus_object_t *error,
globus_ftp_control_response_t *ftp_response)
{
globus_l_server_response_callback(callback_arg, handle, error);
}
static
void
globus_l_server_response_callback(
void *callback_arg,
globus_ftp_control_handle_t *handle,
globus_object_t *error)
{
auth_test_server_session_t *session = callback_arg;
globus_result_t res = GLOBUS_SUCCESS;
globus_ftp_control_auth_requirements_t
auth_req;
if (error)
{
return;
}
switch (session->server_state)
{
case SERVER_ACCEPT:
session->server_state = SERVER_AUTH;
auth_req = session->server->auth_requirements;
res = globus_ftp_control_server_authenticate(
handle,
auth_req,
globus_l_server_auth_callback,
callback_arg);
break;
case SERVER_AUTH:
session->server_state = SERVER_CMDS;
res = globus_ftp_control_read_commands(
handle,
globus_l_command_callback,
callback_arg);
break;
case SERVER_CMDS:
break;
case SERVER_QUIT:
session->server_state = SERVER_DONE;
res = globus_ftp_control_force_close(
handle,
globus_l_server_close_callback,
callback_arg);
break;
case SERVER_DONE:
{
globus_list_t *entry = NULL;
globus_mutex_lock(&session->server->mutex);
entry = globus_list_search(session->server->sessions, session);
globus_list_remove(&session->server->sessions, entry);
globus_ftp_control_handle_destroy(handle);
globus_mutex_unlock(&session->server->mutex);
free(session);
}
}
if (res != GLOBUS_SUCCESS)
{
abort();
}
}
static
void
globus_l_server_accept_callback(
void * callback_arg,
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(
handle,
globus_l_server_close_callback,
callback_arg);
}
res = globus_ftp_control_send_response(
handle,
"220 Globus GridFTP Test Server\r\n",
globus_l_server_response_callback,
callback_arg);
}
static
void
globus_l_server_listen_callback(
void * callback_arg,
globus_ftp_control_server_t * server_handle,
globus_object_t * error)
{
auth_test_server_t *server = callback_arg;
auth_test_server_session_t *session = NULL;
globus_result_t res = GLOBUS_SUCCESS;
if (error)
{
return;
}
session = malloc(sizeof(auth_test_server_session_t));
if (session == NULL)
{
abort();
}
*session = (auth_test_server_session_t)
{
.server = server,
.server_state = SERVER_ACCEPT,
};
res = globus_ftp_control_handle_init(&session->handle);
if (res != GLOBUS_SUCCESS)
{
abort();
}
globus_mutex_lock(&server->mutex);
globus_list_insert(&server->sessions, session);
globus_mutex_unlock(&server->mutex);
res = globus_ftp_control_server_accept(
server_handle,
&session->handle,
globus_l_server_accept_callback,
session);
if (res != GLOBUS_SUCCESS)
{
abort();
}
}
static
globus_result_t
initialize_servers(void)
{
globus_result_t result = GLOBUS_SUCCESS;
globus_io_attr_t tls_server_attr = NULL;
result = globus_ftp_control_server_handle_init(&cleartext_server.server);
if (result != GLOBUS_SUCCESS)
{
goto failed_init_cleartext;
}
result = globus_ftp_control_server_listen(
&cleartext_server.server,
&cleartext_server.port,
globus_l_server_listen_callback,
&cleartext_server);
if (result != GLOBUS_SUCCESS)
{
goto failed_listen_cleartext;
}
globus_mutex_init(&cleartext_server.mutex, NULL);
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)
{
goto failed_init_tls;
}
result = globus_io_tcpattr_init(
&tls_server_attr);
if (result != GLOBUS_SUCCESS)
{
goto failed_init_tls_attr;
}
result = globus_io_attr_set_secure_authentication_mode(
&tls_server_attr,
GLOBUS_IO_SECURE_AUTHENTICATION_MODE_GSSAPI,
GSS_C_NO_CREDENTIAL);
if (result != GLOBUS_SUCCESS)
{
goto failed_set_tls_attr;
}
result = globus_io_attr_set_secure_channel_mode(
&tls_server_attr,
GLOBUS_IO_SECURE_CHANNEL_MODE_SSL_WRAP);
if (result != GLOBUS_SUCCESS)
{
goto failed_set_tls_attr;
}
result = globus_ftp_control_server_listen_ex(
&tls_server.server,
&tls_server_attr,
&tls_server.port,
globus_l_server_listen_callback,
&tls_server);
if (result != GLOBUS_SUCCESS)
{
goto failed_listen_tls;
}
globus_mutex_init(&tls_server.mutex, NULL);
tls_server.auth_requirements =
GLOBUS_FTP_CONTROL_AUTH_REQ_USER
| GLOBUS_FTP_CONTROL_AUTH_REQ_PASS
| GLOBUS_FTP_CONTROL_AUTH_REQ_TLS;
result = globus_ftp_control_server_handle_init(
&gssapi_server.server);
if (result != GLOBUS_SUCCESS)
{
goto failed_init_gssapi;
}
result = globus_ftp_control_server_listen(
&gssapi_server.server,
&gssapi_server.port,
globus_l_server_listen_callback,
&gssapi_server);
globus_mutex_init(&gssapi_server.mutex, NULL);
globus_cond_init(&gssapi_server.cond, NULL);
gssapi_server.auth_requirements =
GLOBUS_FTP_CONTROL_AUTH_REQ_USER
| GLOBUS_FTP_CONTROL_AUTH_REQ_PASS
| GLOBUS_FTP_CONTROL_AUTH_REQ_GSSAPI;
if (result != GLOBUS_SUCCESS)
{
globus_ftp_control_server_handle_destroy(&gssapi_server.server);
failed_init_gssapi:
failed_listen_tls:
failed_init_tls_attr:
failed_set_tls_attr:
globus_ftp_control_server_handle_destroy(&tls_server.server);
failed_init_tls:
failed_listen_cleartext:
globus_ftp_control_server_handle_destroy(&cleartext_server.server);
}
if (tls_server_attr != NULL)
{
globus_io_tcpattr_destroy(&tls_server_attr);
}
failed_init_cleartext:
return result;
}
/* initialize_servers() */
static
void
globus_l_server_stop_callback(
void * callback_arg,
globus_ftp_control_server_t *server_handle,
globus_object_t *error)
{
auth_test_server_t *server = callback_arg;
globus_mutex_lock(&server->mutex);
server->port = 0;
globus_cond_signal(&server->cond);
globus_mutex_unlock(&server->mutex);
}
#define TEST_CASE(x) { x, #x }
typedef struct
{
bool (*test)(void);
const char *name;
}
test_case_t;
int main(int argc, char *argv[])
{
globus_result_t result = GLOBUS_SUCCESS;
test_case_t tests[] =
{
TEST_CASE(authenticate_clear_test),
TEST_CASE(authenticate_clear_to_tls),
TEST_CASE(authenticate_clear_to_gssapi),
TEST_CASE(authenticate_gssapi_anonymous_to_clear),
TEST_CASE(authenticate_gssapi_anonymous_to_tls),
TEST_CASE(authenticate_gssapi_anonymous_to_gssapi),
TEST_CASE(authenticate_tls_anonymous_to_clear),
TEST_CASE(authenticate_tls_anonymous_to_tls),
TEST_CASE(authenticate_tls_anonymous_to_gssapi),
TEST_CASE(authenticate_gssapi_to_clear),
TEST_CASE(authenticate_gssapi_to_tls),
TEST_CASE(authenticate_gssapi_to_gssapi),
TEST_CASE(authenticate_tls_to_clear),
TEST_CASE(authenticate_tls_to_tls),
TEST_CASE(authenticate_tls_to_gssapi),
};
size_t num_tests
= sizeof(tests) / sizeof(tests[0]);
size_t failed = 0;
printf("1..%zu\n", num_tests);
LTDL_SET_PRELOADED_SYMBOLS();
globus_module_activate(GLOBUS_FTP_CONTROL_MODULE);
result = initialize_servers();
if (result != GLOBUS_SUCCESS)
{
char *msg = NULL;
msg = globus_error_print_friendly(globus_error_peek(result));
fprintf(
stderr,
"Error initializing servers%s%s\n",
msg != NULL ? ": " : "",
msg != NULL ? msg : "");
failed = 99;
free(msg);
goto exit;
}
for (size_t i = 0; i < num_tests; i++)
{
bool ok = false;
ok = tests[i].test();
printf("%s %zu - %s\n", ok ? "ok" : "not ok", i + 1, tests[i].name);
failed += !ok;
}
globus_mutex_lock(&gssapi_server.mutex);
globus_ftp_control_server_stop(
&gssapi_server.server,
globus_l_server_stop_callback,
&gssapi_server);
while (gssapi_server.port != 0)
{
globus_cond_wait(&gssapi_server.cond, &gssapi_server.mutex);
}
globus_mutex_unlock(&gssapi_server.mutex);
globus_mutex_lock(&tls_server.mutex);
globus_ftp_control_server_stop(
&tls_server.server,
globus_l_server_stop_callback,
&tls_server);
while (tls_server.port != 0)
{
globus_cond_wait(&tls_server.cond, &tls_server.mutex);
}
globus_mutex_unlock(&tls_server.mutex);
globus_mutex_lock(&cleartext_server.mutex);
globus_ftp_control_server_stop(
&cleartext_server.server,
globus_l_server_stop_callback,
&cleartext_server);
while (cleartext_server.port != 0)
{
globus_cond_wait(&cleartext_server.cond, &cleartext_server.mutex);
}
globus_mutex_unlock(&cleartext_server.mutex);
exit:
globus_module_deactivate(GLOBUS_FTP_CONTROL_MODULE);
return failed;
}
globus_ftp_control-9.10/test/PaxHeaders.24857/data_test.c 0000644 0000000 0000000 00000000132 14243161125 021447 x ustar 00 0000000 0000000 30 mtime=1653400149.413969564
30 atime=1653401814.408286436
30 ctime=1653404005.258899448
globus_ftp_control-9.10/test/data_test.c 0000664 0001750 0001750 00000163120 14243161125 021604 0 ustar 00johndoe johndoe 0000000 0000000 /*
* Copyright 1999-2006 University of Chicago
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* This program tests the globus_ftp_control_data library
*/
#include "globus_ftp_control.h"
#include "globus_common.h"
#include
#include "test_common.h"
#include "globus_preload.h"
#define MAX_PLEVEL 10
#define TEST_ITERATIONS 4
#define WRITE_CHUNK_COUNT 32
static globus_bool_t g_send_eof = GLOBUS_TRUE;
typedef void (*set_handle_mode_cb_t)(
globus_ftp_control_handle_t * handle,
int plevel);
typedef struct data_test_info_s
{
char fname[L_tmpnam];
FILE * fin;
FILE * fout;
ftp_test_monitor_t * monitor;
int bb_len;
} data_test_info_t;
static int g_test_count = 0;
static char g_test_file[L_tmpnam] = {0};
static char g_tmp_file[TEST_ITERATIONS][L_tmpnam] = {0};
globus_result_t
cache_test(
set_handle_mode_cb_t mode_cb,
int plevel);
globus_result_t
reuse_handles_test(
set_handle_mode_cb_t mode_cb,
int plevel);
void
test_result(
globus_result_t result,
char * msg,
int line_num);
globus_result_t
transfer_test(
set_handle_mode_cb_t mode_cb,
int plevel);
globus_result_t
big_buffer_test(
set_handle_mode_cb_t mode_cb,
int plevel);
void
failure_end(
char * msg);
void
connect_read_callback(
void * callback_arg,
struct globus_ftp_control_handle_s * handle,
unsigned int stripe_ndx,
globus_bool_t resuse,
globus_object_t * error);
void
connect_write_zero_eof_callback(
void * callback_arg,
struct globus_ftp_control_handle_s * handle,
unsigned int stripe_ndx,
globus_bool_t resuse,
globus_object_t * error);
void
connect_write_callback(
void * callback_arg,
struct globus_ftp_control_handle_s * handle,
unsigned int stripe_ndx,
globus_bool_t resuse,
globus_object_t * error);
void
data_read_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_byte_t * buffer,
globus_size_t length,
globus_off_t offset,
globus_bool_t eof);
void
data_read_big_buffer_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_byte_t * buffer,
globus_size_t length_read,
globus_off_t offset,
globus_bool_t eof);
void
data_write_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_byte_t * buffer,
globus_size_t length,
globus_off_t offset,
globus_bool_t eof);
void
connect_write_big_buffer_callback(
void * callback_arg,
struct globus_ftp_control_handle_s * handle,
unsigned int stripe_ndx,
globus_bool_t resuse,
globus_object_t * error);
void
connect_read_big_buffer_callback(
void * callback_arg,
struct globus_ftp_control_handle_s * handle,
unsigned int stripe_ndx,
globus_bool_t resuse,
globus_object_t * error);
void
binary_eb_mode(
globus_ftp_control_handle_t * handle,
int plevel);
void
binary_stream_mode(
globus_ftp_control_handle_t * handle,
int plevel);
globus_result_t
cache_multiparallel_test(
set_handle_mode_cb_t mode_cb);
int
copy_file(
const char * source,
const char * dest);
int
diff(
const char * source,
const char * dest);
void
force_close_cb(
void * user_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error)
{
ftp_test_monitor_t * monitor;
monitor = (ftp_test_monitor_t *) user_arg;
globus_mutex_lock(&monitor->mutex);
{
monitor->done = GLOBUS_TRUE;
globus_cond_signal(&monitor->cond);
}
globus_mutex_unlock(&monitor->mutex);
}
int
main(
int argc,
char * argv[])
{
globus_result_t res;
int ctr;
int rc;
int i;
int plevel;
LTDL_SET_PRELOADED_SYMBOLS();
setbuf(stdout, NULL);
setbuf(stderr, NULL);
printf("1..11\n");
for(ctr = 0; ctr < argc; ctr++)
{
if(strcmp(argv[ctr], "--verbose") == 0)
{
if(ctr + 1 >= argc)
{
verbose_print_level = 1;
}
else
{
verbose_print_level = atoi(argv[ctr+1]);
ctr++;
}
}
}
{
FILE *f;
int i, r;
tmpnam(g_test_file);
f = fopen(g_test_file, "w");
for (i = 0; i < 10000; i++)
{
r = rand();
fwrite(&r, sizeof(int), 1, f);
}
fclose(f);
}
for (i = 0; i < TEST_ITERATIONS; i++)
{
tmpnam(g_tmp_file[i]);
}
/*
* activate
*/
rc = globus_module_activate(GLOBUS_FTP_CONTROL_MODULE);
if(rc) res = globus_error_put(GLOBUS_ERROR_NO_INFO);
else res = GLOBUS_SUCCESS;
test_result(res, "globus_module_activate failed", __LINE__);
g_test_count++;
verbose_printf(1, "------------------------------------\n");
verbose_printf(1, "running transfer test in stream mode\n");
transfer_test(binary_stream_mode, 1);
printf("ok - transfer_test(binary_stream_mode, 1)\n");
verbose_printf(1, "transfer test in stream mode passed\n");
verbose_printf(1, "------------------------------------\n");
g_test_count++;
verbose_printf(1, "------------------------------------\n");
verbose_printf(1, "running reuse handles test in stream mode.\n");
reuse_handles_test(binary_stream_mode, 1);
printf("ok - reuse_handles_test(binary_stream_mode, 1)\n");
verbose_printf(1, "reuse handles test in stream mode passed.\n");
verbose_printf(1, "------------------------------------\n");
g_test_count++;
verbose_printf(1, "------------------------------------\n");
verbose_printf(1, "running big buffer test in stream mode\n");
big_buffer_test(binary_stream_mode, 1);
verbose_printf(1, "big buffer in stream mode passed\n");
printf("ok - big_buffer_test(binary_stream_mode, 1)\n");
verbose_printf(1, "------------------------------------\n");
g_test_count++;
verbose_printf(1, "------------------------------------\n");
verbose_printf(1, "running transfer test in eb mode\n");
for(plevel = 1; plevel <= MAX_PLEVEL; plevel++)
{
verbose_printf(2, "parallel level %d\n", plevel);
transfer_test(binary_eb_mode, plevel);
}
verbose_printf(1, "transfer test in eb mode passed\n");
printf("ok - transfer_test(binary_eb_mode, plevel)\n");
verbose_printf(1, "------------------------------------\n");
g_test_count++;
verbose_printf(1, "------------------------------------\n");
verbose_printf(1, "running reuse handles test in eb mode.\n");
for(plevel = 1; plevel <= MAX_PLEVEL; plevel++)
{
verbose_printf(2, "parallel level %d\n", plevel);
reuse_handles_test(binary_eb_mode, plevel);
}
verbose_printf(1, "reuse handles test in eb mode passed.\n");
printf("ok - reuse_handles_test(binary_eb_mode, plevel)\n");
verbose_printf(1, "------------------------------------\n");
g_test_count++;
g_send_eof = GLOBUS_FALSE;
verbose_printf(1, "------------------------------------\n");
verbose_printf(1, "send eof running transfer test in eb mode\n");
for(plevel = 1; plevel <= MAX_PLEVEL; plevel++)
{
verbose_printf(2, "parallel level %d\n", plevel);
transfer_test(binary_eb_mode, plevel);
}
g_send_eof = GLOBUS_TRUE;
verbose_printf(1, "send eof transfer test in eb mode passed\n");
printf("ok - transfer_test(binary_eb_mode, plevel)\n");
verbose_printf(1, "------------------------------------\n");
g_test_count++;
g_send_eof = GLOBUS_FALSE;
verbose_printf(1, "------------------------------------\n");
verbose_printf(1, "send eof running reuse handle test in eb mode\n");
for(plevel = 1; plevel <= MAX_PLEVEL; plevel++)
{
verbose_printf(2, "parallel level %d\n", plevel);
reuse_handles_test(binary_eb_mode, plevel);
}
g_send_eof = GLOBUS_TRUE;
verbose_printf(1, "send eof reuse handle test in eb mode passed\n");
printf("ok - reuse_handles_test(binary_eb_mode, plevel)\n");
verbose_printf(1, "------------------------------------\n");
g_test_count++;
verbose_printf(1, "------------------------------------\n");
verbose_printf(1, "running big buffer test in eb mode\n");
for(plevel = 1; plevel <= MAX_PLEVEL; plevel++)
{
verbose_printf(2, "parallel level %d\n", 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");
verbose_printf(1, "------------------------------------\n");
g_test_count++;
verbose_printf(1, "------------------------------------\n");
verbose_printf(1, "running cache test in eb mode\n");
for(plevel = 1; plevel <= MAX_PLEVEL; plevel++)
{
verbose_printf(2, "parallel level %d\n", plevel);
cache_test(binary_eb_mode, plevel);
}
verbose_printf(1, "cache in eb mode passed\n");
printf("ok - cache_test(binary_eb_mode, plevel)\n");
verbose_printf(1, "------------------------------------\n");
g_test_count++;
g_send_eof = GLOBUS_FALSE;
verbose_printf(1, "--------------------------------------\n");
verbose_printf(1, "send_eof running cache test in eb mode\n");
for(plevel = 1; plevel <= MAX_PLEVEL; plevel++)
{
verbose_printf(2, "parallel level %d\n", plevel);
cache_test(binary_eb_mode, plevel);
}
g_send_eof = GLOBUS_TRUE;
verbose_printf(1, "send_eof cache in eb mode passed\n");
printf("ok - cache_test(binary_eb_mode, plevel)\n");
verbose_printf(1, "-------------------------------------\n");
verbose_printf(1, "--------------------------------------\n");
verbose_printf(1, "cache_multiparallel_test in eb mode\n");
cache_multiparallel_test(binary_eb_mode);
verbose_printf(1, "cache_multiparallel_test passed\n");
printf("ok - cache_multiparallel_test(binary_eb_mode)\n");
verbose_printf(1, "-------------------------------------\n");
rc = globus_module_deactivate(GLOBUS_FTP_CONTROL_MODULE);
if(rc) res = globus_error_put(GLOBUS_ERROR_NO_INFO);
else res = GLOBUS_SUCCESS;
test_result(res, "deactivate", __LINE__);
verbose_printf(1, "%d tests passed.\n", g_test_count);
return 0;
}
void
data_send_eof_cb(
void * callback_arg,
struct globus_ftp_control_handle_s * handle,
globus_object_t * error)
{
ftp_test_monitor_t * done_monitor;
done_monitor = (ftp_test_monitor_t *)callback_arg;
globus_mutex_lock(&done_monitor->mutex);
{
done_monitor->done = GLOBUS_TRUE;
globus_cond_signal(&done_monitor->cond);
}
globus_mutex_unlock(&done_monitor->mutex);
}
globus_result_t
test_send_eof(
globus_ftp_control_handle_t * port_handle)
{
ftp_test_monitor_t done_monitor;
globus_result_t res;
int x = 0;
ftp_test_monitor_init(&done_monitor);
res = globus_ftp_control_data_send_eof(
port_handle,
&x,
1,
GLOBUS_TRUE,
data_send_eof_cb,
(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);
}
}
globus_mutex_unlock(&done_monitor.mutex);
return GLOBUS_SUCCESS;
}
/*
* test several read using the big buffer test
*/
globus_result_t
big_buffer_test(
set_handle_mode_cb_t mode_cb,
int plevel)
{
int ctr;
globus_result_t res;
globus_ftp_control_host_port_t host_port;
globus_ftp_control_handle_t port_handle;
globus_ftp_control_handle_t pasv_handle;
ftp_test_monitor_t done_monitor;
data_test_info_t * test_info;
ftp_test_monitor_init(&done_monitor);
done_monitor.result = GLOBUS_SUCCESS;
test_info = (data_test_info_t *)
globus_malloc(sizeof(data_test_info_t));
test_info->monitor = &done_monitor;
strcpy(test_info->fname, g_tmp_file[0]);
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__);
for(ctr = 0; ctr < TEST_ITERATIONS; ctr++)
{
done_monitor.done = GLOBUS_FALSE;
done_monitor.count = 0;
globus_ftp_control_host_port_init(&host_port, "localhost", 0);
res = globus_ftp_control_local_pasv(&pasv_handle, &host_port);
test_result(res, "local pasv", __LINE__);
res = globus_ftp_control_local_port(&port_handle, &host_port);
test_result(res, "local port", __LINE__);
mode_cb(&pasv_handle, plevel);
mode_cb(&port_handle, plevel);
/*
* calling connect read/write() will get the ball rolling
*/
res = globus_ftp_control_data_connect_read(
&pasv_handle,
connect_read_big_buffer_callback,
(void *)test_info);
test_result(res, "connect_read", __LINE__);
res = globus_ftp_control_data_connect_write(
&port_handle,
connect_write_big_buffer_callback,
(void *)test_info);
test_result(res, "connect_write", __LINE__);
verbose_printf(3, "waiting for transfer.\n");
globus_mutex_lock(&done_monitor.mutex);
{
while(done_monitor.count < 2 &&
!done_monitor.done)
{
globus_cond_wait(&done_monitor.cond, &done_monitor.mutex);
}
}
globus_mutex_unlock(&done_monitor.mutex);
}
done_monitor.done = GLOBUS_FALSE;
res = globus_ftp_control_data_force_close(
&pasv_handle,
force_close_cb,
(void *)&done_monitor);
if(res == GLOBUS_SUCCESS)
{
globus_mutex_lock(&done_monitor.mutex);
{
while(!done_monitor.done)
{
globus_cond_wait(&done_monitor.cond, &done_monitor.mutex);
}
}
globus_mutex_unlock(&done_monitor.mutex);
}
res = globus_i_ftp_control_data_cc_destroy(&pasv_handle);
test_result(res, "destroy", __LINE__);
done_monitor.done = GLOBUS_FALSE;
res = globus_ftp_control_data_force_close(
&port_handle,
force_close_cb,
(void *)&done_monitor);
if(res == GLOBUS_SUCCESS)
{
globus_mutex_lock(&done_monitor.mutex);
{
while(!done_monitor.done)
{
globus_cond_wait(&done_monitor.cond, &done_monitor.mutex);
}
}
globus_mutex_unlock(&done_monitor.mutex);
}
res = globus_i_ftp_control_data_cc_destroy(&port_handle);
test_result(res, "destroy", __LINE__);
globus_free(test_info);
return GLOBUS_SUCCESS;
}
globus_result_t
reuse_handles_test(
set_handle_mode_cb_t mode_cb,
int plevel)
{
int ctr;
globus_result_t res;
globus_ftp_control_host_port_t host_port;
globus_ftp_control_handle_t port_handle;
globus_ftp_control_handle_t pasv_handle;
ftp_test_monitor_t done_monitor;
data_test_info_t * test_info;
unsigned int port_connections;
unsigned int pasv_connections;
globus_ftp_control_data_connect_callback_t connect_cb;
ftp_test_monitor_init(&done_monitor);
done_monitor.result = GLOBUS_SUCCESS;
test_info = (data_test_info_t *)
globus_malloc(sizeof(data_test_info_t));
test_info->monitor = &done_monitor;
strcpy(test_info->fname, g_tmp_file[0]);
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__);
if(!g_send_eof)
{
res = globus_ftp_control_local_send_eof(
&port_handle,
GLOBUS_FALSE);
test_result(res, "local_send_eof()", __LINE__);
}
connect_cb = connect_write_callback;
for(ctr = 0; ctr < TEST_ITERATIONS * 2; ctr++)
{
done_monitor.done = GLOBUS_FALSE;
done_monitor.count = 0;
globus_ftp_control_host_port_init(&host_port, "localhost", 0);
res = globus_ftp_control_local_pasv(&pasv_handle, &host_port);
test_result(res, "local pasv", __LINE__);
res = globus_ftp_control_local_port(&port_handle, &host_port);
test_result(res, "local port", __LINE__);
mode_cb(&pasv_handle, plevel);
mode_cb(&port_handle, plevel);
/*
* calling connect read/write() will get the ball rolling
*/
res = globus_ftp_control_data_connect_read(
&pasv_handle,
connect_read_callback,
(void *)test_info);
test_result(res, "connect_read", __LINE__);
res = globus_ftp_control_data_connect_write(
&port_handle,
connect_cb,
(void *)test_info);
test_result(res, "connect_write", __LINE__);
verbose_printf(3, "waiting for transfer.\n");
res = globus_ftp_control_data_get_total_data_channels(
&pasv_handle,
&pasv_connections,
0);
res = globus_ftp_control_data_get_total_data_channels(
&port_handle,
&port_connections,
0);
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 &&
!done_monitor.done)
{
globus_cond_wait(&done_monitor.cond, &done_monitor.mutex);
}
}
globus_mutex_unlock(&done_monitor.mutex);
if(ctr == TEST_ITERATIONS)
{
verbose_printf(2,
"starting zero eof callback\n");
connect_cb = connect_write_zero_eof_callback;
}
}
done_monitor.done = GLOBUS_FALSE;
res = globus_ftp_control_data_force_close(
&pasv_handle,
force_close_cb,
(void *)&done_monitor);
if(res == GLOBUS_SUCCESS)
{
globus_mutex_lock(&done_monitor.mutex);
{
while(!done_monitor.done)
{
globus_cond_wait(&done_monitor.cond, &done_monitor.mutex);
}
}
globus_mutex_unlock(&done_monitor.mutex);
}
globus_free(test_info);
res = globus_i_ftp_control_data_cc_destroy(&pasv_handle);
test_result(res, "destroy handle", __LINE__);
done_monitor.done = GLOBUS_FALSE;
res = globus_ftp_control_data_force_close(
&port_handle,
force_close_cb,
(void *)&done_monitor);
if(res == GLOBUS_SUCCESS)
{
globus_mutex_lock(&done_monitor.mutex);
{
while(!done_monitor.done)
{
globus_cond_wait(&done_monitor.cond, &done_monitor.mutex);
}
}
globus_mutex_unlock(&done_monitor.mutex);
}
res = globus_i_ftp_control_data_cc_destroy(&port_handle);
test_result(res, "destroy", __LINE__);
return GLOBUS_SUCCESS;
}
void
binary_eb_mode(
globus_ftp_control_handle_t * handle,
int plevel)
{
globus_result_t res;
globus_ftp_control_parallelism_t parallelism;
parallelism.mode = GLOBUS_FTP_CONTROL_PARALLELISM_FIXED;
parallelism.fixed.size = plevel;
res = globus_ftp_control_local_type(
handle,
GLOBUS_FTP_CONTROL_TYPE_IMAGE,
0);
test_result(res, "local_type", __LINE__);
res = globus_ftp_control_local_mode(
handle,
GLOBUS_FTP_CONTROL_MODE_EXTENDED_BLOCK);
test_result(res, "local_mode", __LINE__);
res = globus_ftp_control_local_parallelism(
handle,
¶llelism);
test_result(res, "local_mode", __LINE__);
}
void
binary_stream_mode(
globus_ftp_control_handle_t * handle,
int plevel)
{
globus_result_t res;
res = globus_ftp_control_local_type(
handle,
GLOBUS_FTP_CONTROL_TYPE_IMAGE,
0);
test_result(res, "local_type", __LINE__);
res = globus_ftp_control_local_mode(
handle,
GLOBUS_FTP_CONTROL_MODE_STREAM);
test_result(res, "local_mode", __LINE__);
}
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;
globus_ftp_control_handle_t port_handle;
globus_ftp_control_handle_t pasv_handle;
ftp_test_monitor_t done_monitor;
data_test_info_t * test_info;
int nsock_a[] =
{4, 16, 8, 32, 2, 4, 0};
ftp_test_monitor_init(&done_monitor);
done_monitor.result = GLOBUS_SUCCESS;
test_info = (data_test_info_t *)
globus_malloc(sizeof(data_test_info_t));
test_info->monitor = &done_monitor;
strcpy(test_info->fname, g_tmp_file[0]);
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__);
globus_ftp_control_host_port_init(&host_port, "localhost", 0);
res = globus_ftp_control_local_pasv(&pasv_handle, &host_port);
test_result(res, "local pasv", __LINE__);
res = globus_ftp_control_local_port(&port_handle, &host_port);
test_result(res, "local port", __LINE__);
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]);
done_monitor.done = GLOBUS_FALSE;
done_monitor.count = 0;
/*
* calling connect read/write() will get the ball rolling
*/
res = globus_ftp_control_data_connect_read(
&pasv_handle,
connect_read_callback,
(void *)test_info);
test_result(res, "connect_read", __LINE__);
res = globus_ftp_control_data_connect_write(
&port_handle,
connect_write_callback,
(void *)test_info);
test_result(res, "connect_write", __LINE__);
verbose_printf(3, "waiting for transfer.\n");
globus_mutex_lock(&done_monitor.mutex);
{
while(done_monitor.count < 2 &&
!done_monitor.done)
{
globus_cond_wait(&done_monitor.cond, &done_monitor.mutex);
}
}
globus_mutex_unlock(&done_monitor.mutex);
}
}
done_monitor.done = GLOBUS_FALSE;
res = globus_ftp_control_data_force_close(
&pasv_handle,
force_close_cb,
(void *)&done_monitor);
if(res == GLOBUS_SUCCESS)
{
globus_mutex_lock(&done_monitor.mutex);
{
while(!done_monitor.done)
{
globus_cond_wait(&done_monitor.cond, &done_monitor.mutex);
}
}
globus_mutex_unlock(&done_monitor.mutex);
}
globus_free(test_info);
res = globus_i_ftp_control_data_cc_destroy(&pasv_handle);
test_result(res, "destroy handle", __LINE__);
done_monitor.done = GLOBUS_FALSE;
res = globus_ftp_control_data_force_close(
&port_handle,
force_close_cb,
(void *)&done_monitor);
if(res == GLOBUS_SUCCESS)
{
globus_mutex_lock(&done_monitor.mutex);
{
while(!done_monitor.done)
{
globus_cond_wait(&done_monitor.cond, &done_monitor.mutex);
}
}
globus_mutex_unlock(&done_monitor.mutex);
}
res = globus_i_ftp_control_data_cc_destroy(&port_handle);
test_result(res, "destroy", __LINE__);
return GLOBUS_SUCCESS;
}
globus_result_t
cache_test(
set_handle_mode_cb_t mode_cb,
int plevel)
{
int ctr;
globus_result_t res;
globus_ftp_control_host_port_t host_port;
globus_ftp_control_handle_t port_handle;
globus_ftp_control_handle_t pasv_handle;
ftp_test_monitor_t done_monitor;
data_test_info_t * test_info;
ftp_test_monitor_init(&done_monitor);
done_monitor.result = GLOBUS_SUCCESS;
test_info = (data_test_info_t *)
globus_malloc(sizeof(data_test_info_t));
test_info->monitor = &done_monitor;
strcpy(test_info->fname, g_tmp_file[0]);
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__);
globus_ftp_control_host_port_init(&host_port, "localhost", 0);
res = globus_ftp_control_local_pasv(&pasv_handle, &host_port);
test_result(res, "local pasv", __LINE__);
res = globus_ftp_control_local_port(&port_handle, &host_port);
test_result(res, "local port", __LINE__);
mode_cb(&pasv_handle, plevel);
mode_cb(&port_handle, plevel);
if(!g_send_eof)
{
res = globus_ftp_control_local_send_eof(
&port_handle,
GLOBUS_FALSE);
test_result(res, "local_send_eof()", __LINE__);
}
for(ctr = 0; ctr < TEST_ITERATIONS; ctr++)
{
done_monitor.done = GLOBUS_FALSE;
done_monitor.count = 0;
/*
* calling connect read/write() will get the ball rolling
*/
res = globus_ftp_control_data_connect_read(
&pasv_handle,
connect_read_callback,
(void *)test_info);
test_result(res, "connect_read", __LINE__);
res = globus_ftp_control_data_connect_write(
&port_handle,
connect_write_callback,
(void *)test_info);
test_result(res, "connect_write", __LINE__);
verbose_printf(3, "waiting for transfer.\n");
globus_mutex_lock(&done_monitor.mutex);
{
while(done_monitor.count < 2 &&
!done_monitor.done)
{
globus_cond_wait(&done_monitor.cond, &done_monitor.mutex);
}
}
globus_mutex_unlock(&done_monitor.mutex);
}
done_monitor.done = GLOBUS_FALSE;
res = globus_ftp_control_data_force_close(
&pasv_handle,
force_close_cb,
(void *)&done_monitor);
if(res == GLOBUS_SUCCESS)
{
globus_mutex_lock(&done_monitor.mutex);
{
while(!done_monitor.done)
{
globus_cond_wait(&done_monitor.cond, &done_monitor.mutex);
}
}
globus_mutex_unlock(&done_monitor.mutex);
}
globus_free(test_info);
res = globus_i_ftp_control_data_cc_destroy(&pasv_handle);
test_result(res, "destroy handle", __LINE__);
done_monitor.done = GLOBUS_FALSE;
res = globus_ftp_control_data_force_close(
&port_handle,
force_close_cb,
(void *)&done_monitor);
if(res == GLOBUS_SUCCESS)
{
globus_mutex_lock(&done_monitor.mutex);
{
while(!done_monitor.done)
{
globus_cond_wait(&done_monitor.cond, &done_monitor.mutex);
}
}
globus_mutex_unlock(&done_monitor.mutex);
}
res = globus_i_ftp_control_data_cc_destroy(&port_handle);
test_result(res, "destroy", __LINE__);
return GLOBUS_SUCCESS;
}
/*
* transfer test
* -------------
* This test local creates several pasv and port handles and connects them.
* 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()
* are called. The other half leave the clean up up to deactivate.
*/
globus_result_t
transfer_test(
set_handle_mode_cb_t mode_cb,
int plevel)
{
int ctr;
globus_result_t res;
globus_ftp_control_host_port_t host_port;
globus_ftp_control_handle_t * port_handle;
globus_ftp_control_handle_t * pasv_handle;
ftp_test_monitor_t done_monitor;
data_test_info_t * test_info;
data_test_info_t test_info_array[TEST_ITERATIONS];
globus_ftp_control_handle_t port_handle_array[TEST_ITERATIONS];
globus_ftp_control_handle_t pasv_handle_array[TEST_ITERATIONS];
ftp_test_monitor_init(&done_monitor);
done_monitor.result = GLOBUS_SUCCESS;
for(ctr = 0; ctr < TEST_ITERATIONS; ctr++)
{
/*
* initialize test info structure
*/
test_info = &test_info_array[ctr];
test_info->monitor = &done_monitor;
strcpy(test_info->fname, g_tmp_file[ctr]);
/*
* these will be freed in the final callback
*/
port_handle = &port_handle_array[ctr];
pasv_handle = &pasv_handle_array[ctr];
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__);
/*
* local_port/pasv()
*/
globus_ftp_control_host_port_init(&host_port, "localhost", 0);
res = globus_ftp_control_local_pasv(pasv_handle, &host_port);
test_result(res, "local pasv", __LINE__);
res = globus_ftp_control_local_port(port_handle, &host_port);
test_result(res, "local port", __LINE__);
mode_cb(pasv_handle, plevel);
mode_cb(port_handle, plevel);
if(!g_send_eof)
{
res = globus_ftp_control_local_send_eof(
port_handle,
GLOBUS_FALSE);
test_result(res, "local_send_eof()", __LINE__);
}
/*
* calling connect read/write() will get the ball rolling
*/
res = globus_ftp_control_data_connect_read(
pasv_handle,
connect_read_callback,
(void *)test_info);
test_result(res, "connect_read", __LINE__);
res = globus_ftp_control_data_connect_write(
port_handle,
connect_write_callback,
(void *)test_info);
test_result(res, "connect_write", __LINE__);
}
/*
* wait for end
*/
verbose_printf(3, "waiting for end\n");
globus_mutex_lock(&done_monitor.mutex);
{
while(done_monitor.count < (TEST_ITERATIONS*2) && !done_monitor.done)
{
globus_cond_wait(&done_monitor.cond, &done_monitor.mutex);
}
}
globus_mutex_unlock(&done_monitor.mutex);
/*
* clean up
*/
for(ctr = 0; ctr < TEST_ITERATIONS; ctr++)
{
done_monitor.done = GLOBUS_FALSE;
res = globus_ftp_control_data_force_close(
&pasv_handle_array[ctr],
force_close_cb,
(void *)&done_monitor);
if(res == GLOBUS_SUCCESS)
{
globus_mutex_lock(&done_monitor.mutex);
{
while(!done_monitor.done)
{
globus_cond_wait(&done_monitor.cond, &done_monitor.mutex);
}
}
globus_mutex_unlock(&done_monitor.mutex);
}
res = globus_i_ftp_control_data_cc_destroy(&pasv_handle_array[ctr]);
test_result(res, "destroy", __LINE__);
done_monitor.done = GLOBUS_FALSE;
res = globus_ftp_control_data_force_close(
&port_handle_array[ctr],
force_close_cb,
(void *)&done_monitor);
if(res == GLOBUS_SUCCESS)
{
globus_mutex_lock(&done_monitor.mutex);
{
while(!done_monitor.done)
{
globus_cond_wait(&done_monitor.cond, &done_monitor.mutex);
}
}
globus_mutex_unlock(&done_monitor.mutex);
}
res = globus_i_ftp_control_data_cc_destroy(&port_handle_array[ctr]);
test_result(res, "destroy", __LINE__);
}
verbose_printf(3, "ending\n");
return GLOBUS_SUCCESS;
}
/*
* want to test smaller than the write block, and bigger than the write
* block
*/
void
connect_read_big_buffer_callback(
void * callback_arg,
struct globus_ftp_control_handle_s * handle,
unsigned int stripe_ndx,
globus_bool_t resuse,
globus_object_t * error)
{
data_test_info_t * test_info;
struct stat stat_info;
int file_size;
globus_byte_t * buf;
globus_result_t res;
test_info = (data_test_info_t *)callback_arg;
verbose_printf(3,
"connect_read_big_buffer_callback() : start\n");
if(error != GLOBUS_NULL)
{
test_result(globus_error_put(error),
"connect_read_big_buffer_callback error", __LINE__);
}
globus_mutex_lock(&test_info->monitor->mutex);
{
copy_file(g_test_file, test_info->fname);
test_info->fout = fopen(test_info->fname, "rb+");
if(test_info->fout == GLOBUS_NULL)
{
failure_end("fopen failed\n");
}
if(stat(g_test_file, &stat_info) < 0)
{
failure_end("stat failed\n");
}
file_size = stat_info.st_size;
test_info->bb_len = file_size;
buf = (globus_byte_t *)malloc(file_size);
res = globus_ftp_control_data_read_all(
handle,
buf,
file_size,
data_read_big_buffer_callback,
(void *)test_info);
test_result(res, "data_read_all", __LINE__);
}
globus_mutex_unlock(&test_info->monitor->mutex);
}
/*
* want to test smaller than the write block, and bigger than the write
* block
*/
void
connect_read_callback(
void * callback_arg,
struct globus_ftp_control_handle_s * handle,
unsigned int stripe_ndx,
globus_bool_t resuse,
globus_object_t * error)
{
data_test_info_t * test_info;
struct stat stat_info;
int write_blk_size;
int blk_size;
globus_byte_t * buf;
globus_result_t res;
test_info = (data_test_info_t *)callback_arg;
verbose_printf(3, "connect_read_callback() : start\n");
if(error != GLOBUS_NULL)
{
test_result(globus_error_put(error), "connect_read_callback error"
, __LINE__);
}
globus_mutex_lock(&test_info->monitor->mutex);
{
test_info->fout = fopen(test_info->fname, "wb");
if(test_info->fout == GLOBUS_NULL)
{
failure_end("fopen failed\n");
}
if(stat(g_test_file, &stat_info) < 0)
{
failure_end("stat failed\n");
}
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);
res = globus_ftp_control_data_read(
handle,
buf,
blk_size,
data_read_callback,
(void *)test_info);
test_result(res, "data_read", __LINE__);
}
globus_mutex_unlock(&test_info->monitor->mutex);
}
void
data_read_big_buffer_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_byte_t * buffer,
globus_size_t length_read,
globus_off_t offset_read,
globus_bool_t eof)
{
data_test_info_t * test_info;
verbose_printf(4,
"data_read_big_buffer_callback():start %d %d %d\n",
length_read, offset_read, eof);
if(error != GLOBUS_NULL)
{
test_result(globus_error_put(error), "big_buffer_callback", __LINE__);
}
test_info = (data_test_info_t *)callback_arg;
globus_mutex_lock(&test_info->monitor->mutex);
{
if(!eof)
{
verbose_printf(4, "intermediate big buffer callback\n");
}
else
{
verbose_printf(3, "eof big buffer callback\n");
/* write out the entire buffer */
if(fwrite(buffer, 1, test_info->bb_len, test_info->fout)
!= test_info->bb_len)
{
failure_end("fwrite failed\n");
}
verbose_printf(3, "closing the out stream\n");
fflush(test_info->fout);
fclose(test_info->fout);
if (diff(test_info->fname, g_test_file) != 0)
{
verbose_printf(1, "files are not the same: %d\n", __LINE__);
test_info->monitor->done = GLOBUS_TRUE;
test_info->monitor->result =
globus_error_put(GLOBUS_ERROR_NO_INFO);
globus_cond_signal(&test_info->monitor->cond);
}
else
{
verbose_printf(3, "files are the same\n");
test_info->monitor->count++;
globus_cond_signal(&test_info->monitor->cond);
}
globus_free(buffer);
}
}
globus_mutex_unlock(&test_info->monitor->mutex);
}
void
connect_write_big_buffer_callback(
void * callback_arg,
struct globus_ftp_control_handle_s * handle,
unsigned int stripe_ndx,
globus_bool_t resuse,
globus_object_t * error)
{
data_test_info_t * test_info;
struct stat stat_info;
int blk_size;
int offset = 0;
int nbyte;
globus_byte_t * buf;
globus_bool_t eof = GLOBUS_FALSE;
globus_result_t res;
int ctr;
test_info = (data_test_info_t *)callback_arg;
verbose_printf(3, "connect_write_callback() : start\n");
if(error != GLOBUS_NULL)
{
verbose_printf(1, "error:%s\n",
globus_object_printable_to_string(error));
failure_end("connect_write_callback error\n");
}
globus_mutex_lock(&test_info->monitor->mutex);
{
test_info->fin = fopen(g_test_file, "rb");
if(test_info->fin == GLOBUS_NULL)
{
failure_end("fopen failed\n");
}
if(stat(g_test_file, &stat_info) < 0)
{
failure_end("stat failed\n");
}
offset = 0;
fseek(test_info->fin, offset, SEEK_SET);
blk_size = stat_info.st_size / WRITE_CHUNK_COUNT + 1;
for(ctr = 0; ctr < WRITE_CHUNK_COUNT; ctr++)
{
buf = globus_malloc(blk_size);
/*
* read a chunk
*/
nbyte = fread(buf, 1, blk_size, test_info->fin);
if(nbyte < blk_size)
{
if(feof(test_info->fin))
{
verbose_printf(3, "registering eof\n");
fclose(test_info->fin);
eof = GLOBUS_TRUE;
}
else
{
failure_end("fread failed\n");
}
}
/*
* write a chunk
*/
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(
handle,
buf,
nbyte,
offset,
eof,
data_write_callback,
(void *)test_info);
test_result(res, "data_write", __LINE__);
offset += nbyte;
}
}
globus_mutex_unlock(&test_info->monitor->mutex);
}
void
data_read_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_byte_t * buffer,
globus_size_t length,
globus_off_t offset,
globus_bool_t eof)
{
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");
if(error != GLOBUS_NULL)
{
failure_end("data_read_callback error\n");
}
test_info = (data_test_info_t *)callback_arg;
globus_mutex_lock(&test_info->monitor->mutex);
{
verbose_printf(4, "seeking to %d\n", offset);
if(fseek(test_info->fout, offset, SEEK_SET) != 0)
{
verbose_printf(1, "errno %d %d %d\n", errno, EBADF, EINVAL);
failure_end("seek failed\n");
}
if(fwrite(buffer, 1, length, test_info->fout) != length)
{
failure_end("fwrite failed\n");
}
if(eof)
{
verbose_printf(3, "closing the out stream\n");
fclose(test_info->fout);
if (diff(test_info->fname, g_test_file) != 0)
{
verbose_printf(1, "files are not the same: %d\n", __LINE__);
test_info->monitor->done = GLOBUS_TRUE;
test_info->monitor->result =
globus_error_put(GLOBUS_ERROR_NO_INFO);
globus_cond_signal(&test_info->monitor->cond);
}
else
{
verbose_printf(3, "files are the same\n");
test_info->monitor->count++;
globus_cond_signal(&test_info->monitor->cond);
}
}
else
{
/* add some stuff to the length */
blk_size = length + (rand() % length);
buf = globus_malloc(blk_size);
res = globus_ftp_control_data_read(
handle,
buf,
blk_size,
data_read_callback,
(void *)test_info);
test_result(res, "data_read", __LINE__);
}
}
globus_mutex_unlock(&test_info->monitor->mutex);
if(!eof && length > 0)
{
globus_free(buffer);
}
}
void
connect_write_callback(
void * callback_arg,
struct globus_ftp_control_handle_s * handle,
unsigned int stripe_ndx,
globus_bool_t resuse,
globus_object_t * error)
{
data_test_info_t * test_info;
struct stat stat_info;
int blk_size;
int offset = 0;
int nbyte;
globus_byte_t * buf;
globus_bool_t eof = GLOBUS_FALSE;
globus_result_t res;
int ctr;
test_info = (data_test_info_t *)callback_arg;
verbose_printf(4, "connect_write_callback() : start\n");
if(error != GLOBUS_NULL)
{
verbose_printf(1, "error:%s\n",
globus_object_printable_to_string(error));
failure_end("connect_write_callback error\n");
}
globus_mutex_lock(&test_info->monitor->mutex);
{
test_info->fin = fopen(g_test_file, "rb");
if(test_info->fin == GLOBUS_NULL)
{
failure_end("fopen failed\n");
}
if(stat(g_test_file, &stat_info) < 0)
{
failure_end("stat failed\n");
}
blk_size = stat_info.st_size / WRITE_CHUNK_COUNT + 1;
for(ctr = 0; ctr < WRITE_CHUNK_COUNT; ctr++)
{
buf = globus_malloc(blk_size);
/*
* read a chunk
*/
nbyte = fread(buf, 1, blk_size, test_info->fin);
if(nbyte < blk_size)
{
if(feof(test_info->fin))
{
verbose_printf(3, "registering eof\n");
fclose(test_info->fin);
eof = GLOBUS_TRUE;
}
else
{
failure_end("fread failed\n");
}
}
/*
* write a chunk
*/
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(
handle,
buf,
nbyte,
offset,
eof,
data_write_callback,
(void *)test_info);
test_result(res, "data_write", __LINE__);
offset += nbyte;
}
}
globus_mutex_unlock(&test_info->monitor->mutex);
}
void
connect_write_zero_eof_callback(
void * callback_arg,
struct globus_ftp_control_handle_s * handle,
unsigned int stripe_ndx,
globus_bool_t resuse,
globus_object_t * error)
{
data_test_info_t * test_info;
struct stat stat_info;
int blk_size;
int offset = 0;
int nbyte;
globus_byte_t * buf;
globus_bool_t eof = GLOBUS_FALSE;
globus_result_t res;
test_info = (data_test_info_t *)callback_arg;
verbose_printf(4, "connect_write_callback() : start\n");
if(error != GLOBUS_NULL)
{
verbose_printf(1, "error:%s\n",
globus_object_printable_to_string(error));
failure_end("connect_write_callback error\n");
}
globus_mutex_lock(&test_info->monitor->mutex);
{
test_info->fin = fopen(g_test_file, "rb");
if(test_info->fin == GLOBUS_NULL)
{
failure_end("fopen failed\n");
}
if(stat(g_test_file, &stat_info) < 0)
{
failure_end("stat failed\n");
}
blk_size = stat_info.st_size;
buf = globus_malloc(blk_size);
/*
* read a chunk
*/
nbyte = 0;
while(nbyte < blk_size)
{
nbyte += fread(&buf[nbyte], 1, blk_size-nbyte, test_info->fin);
}
fclose(test_info->fin);
/*
* write a chunk
*/
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(
handle,
buf,
nbyte,
offset,
GLOBUS_FALSE,
data_write_callback,
(void *)test_info);
test_result(res, "data_write", __LINE__);
offset += nbyte;
res = globus_ftp_control_data_write(
handle,
buf,
0,
offset,
GLOBUS_TRUE,
data_write_callback,
(void *)test_info);
test_result(res, "data_write", __LINE__);
}
globus_mutex_unlock(&test_info->monitor->mutex);
}
void
data_write_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_byte_t * buffer,
globus_size_t length,
globus_off_t offset,
globus_bool_t eof)
{
data_test_info_t * test_info;
globus_result_t res;
test_info = (data_test_info_t *)callback_arg;
verbose_printf(4, "data_write_callback() : start\n");
if(error != GLOBUS_NULL)
{
verbose_printf(1, "error:%s\n",
globus_object_printable_to_string(error));
failure_end("data_write_callback error\n");
}
if(eof)
{
verbose_printf(3, "data_write_callback() : eof has been reached\n");
if(!g_send_eof)
{
res = test_send_eof(handle);
test_result(res, "send_eof()", __LINE__);
}
globus_mutex_lock(&test_info->monitor->mutex);
{
test_info->monitor->count++;
globus_cond_signal(&test_info->monitor->cond);
}
globus_mutex_unlock(&test_info->monitor->mutex);
}
if(length > 0 &&!eof)
{
globus_free(buffer);
}
}
void
failure_end(
char * msg)
{
verbose_printf(1, "%s\n", msg);
verbose_printf(1, "test #%d failed\n", g_test_count);
exit(EXIT_FAILURE);
}
void
test_result(
globus_result_t res,
char * msg,
int line_num)
{
if(res != GLOBUS_SUCCESS)
{
verbose_printf(1, "Line# %d [error]:%s\n", line_num,
globus_object_printable_to_string(globus_error_get(res)));
failure_end(msg);
}
}
int
copy_file(
const char * source,
const char * dest)
{
FILE *sfp, *dfp;
unsigned char buf[BUFSIZ];
int rc = 0;
sfp = fopen(source, "rb");
if (sfp == NULL)
{
rc = errno;
goto failed_fopen_source;
}
dfp = fopen(dest, "wb");
if (dfp == NULL)
{
rc = errno;
goto failed_fopen_dest;
}
while (!(feof(sfp) || ferror(sfp) || ferror(dfp)))
{
size_t a, b;
a = fread(buf, 1, sizeof(buf), sfp);
if (a > 0)
{
b = 0;
do
{
b = fwrite(buf + b, 1, a-b, dfp);
}
while (b > 0 && b < a && (!ferror(dfp)));
}
}
if (ferror(sfp) || ferror(dfp))
{
rc = errno;
if (rc == 0)
{
rc = -1;
}
}
fclose(dfp);
failed_fopen_dest:
fclose(sfp);
failed_fopen_source:
return rc;
}
int
diff(
const char * source,
const char * dest)
{
FILE *sfp, *dfp;
unsigned char sbuf[BUFSIZ], dbuf[BUFSIZ];
int rc = 0;
size_t pos = 0;
sfp = fopen(source, "rb");
if (sfp == NULL)
{
rc = errno;
goto failed_fopen_source;
}
dfp = fopen(dest, "rb");
if (dfp == NULL)
{
rc = errno;
goto failed_fopen_dest;
}
while (!(feof(sfp) || ferror(sfp) || ferror(dfp)))
{
size_t a, b = 0;
a = fread(sbuf, 1, sizeof(sbuf), sfp);
if (a > 0)
{
do
{
b += fread(dbuf + b, 1, a-b, dfp);
}
while (b > 0 && b < a && (!feof(dfp)) && (!ferror(dfp)));
if (a == b)
{
size_t i;
for (i = 0; i < a; i++)
{
if (sbuf[i] != dbuf[i])
{
fprintf(stderr, "# Files differ at position %zd (%02x != %02x)\n",
pos + i, (int) sbuf[i], (int) dbuf[i]);
rc = 1;
goto diff_failed;
}
}
pos += a;
}
}
}
if (ferror(sfp) || ferror(dfp))
{
rc = errno;
if (rc == 0)
{
rc = -1;
}
}
diff_failed:
fclose(dfp);
failed_fopen_dest:
fclose(sfp);
failed_fopen_source:
return rc;
}
globus_ftp_control-9.10/test/PaxHeaders.24857/get_lingering_close.c 0000644 0000000 0000000 00000000132 14243161125 023501 x ustar 00 0000000 0000000 30 mtime=1653400149.413969564
30 atime=1653401814.443286106
30 ctime=1653404005.260899429
globus_ftp_control-9.10/test/get_lingering_close.c 0000664 0001750 0001750 00000010530 14243161125 023632 0 ustar 00johndoe johndoe 0000000 0000000 /*
* Copyright 1999-2006 University of Chicago
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "globus_ftp_control.h"
#include "gssapi.h"
#include "globus_preload.h"
globus_mutex_t the_lock;
globus_cond_t the_cond;
globus_bool_t done = GLOBUS_FALSE;
void
response_cb(
void * closure,
globus_ftp_control_handle_t * handle,
globus_object_t * err,
globus_ftp_control_response_t * response)
{
globus_ftp_control_auth_info_t auth_info;
if (err)
{
int i;
char *msg = globus_error_print_friendly(err);
putchar('#');
for (i = 0; msg[i] != '\0'; i++)
{
putchar(msg[i]);
if (msg[i] == '\n' && msg[i+1] != '\0')
{
putchar('#');
}
}
if (msg[i-1] != '\n')
{
putchar('\n');
}
globus_mutex_lock(&the_lock);
done = -1;
globus_cond_signal(&the_cond);
globus_mutex_unlock(&the_lock);
}
if (response)
{
if(response->code == 220)
{
OM_uint32 maj, min;
gss_buffer_desc buffer;
gss_cred_id_t g_cred;
gss_name_t g_name;
char * g_subject;
maj = gss_acquire_cred(
&min,
GSS_C_NO_NAME,
0,
GSS_C_NO_OID_SET,
GSS_C_BOTH,
&g_cred,
NULL,
NULL);
gss_inquire_cred(&min,
g_cred,
&g_name,
NULL,
NULL,
NULL);
gss_display_name(
&min,
g_name,
&buffer,
NULL);
g_subject = buffer.value;
globus_ftp_control_auth_info_init(
&auth_info,
g_cred,
GLOBUS_FALSE,
"anonymous",
"globus@",
0,
g_subject);
globus_ftp_control_authenticate(handle,
&auth_info,
GLOBUS_TRUE,
response_cb,
0);
}
else
{
globus_ftp_control_quit(
handle,
response_cb,
0);
globus_mutex_lock(&the_lock);
done = 1;
globus_cond_signal(&the_cond);
globus_mutex_unlock(&the_lock);
}
}
}
int main(int argc,
char ** argv)
{
globus_ftp_control_handle_t handle;
char * g_host = NULL;
unsigned short g_port = 0;
int i;
int rc;
LTDL_SET_PRELOADED_SYMBOLS();
for (i = 1; i < argc; i++)
{
if ((strcmp(argv[i], "--host")==0) && ((i+2) < argc))
{
g_host = argv[++i];
g_port = atoi(argv[++i]);
}
}
if (g_host == NULL || g_port == 0)
{
fprintf(stderr, "Usage: %s --host HOST PORT\n", argv[0]);
exit(99);
}
printf("1..1\n");
globus_module_activate(GLOBUS_FTP_CONTROL_MODULE);
globus_mutex_init(&the_lock, 0);
globus_cond_init(&the_cond, 0);
globus_ftp_control_handle_init(&handle);
globus_ftp_control_connect(&handle,
g_host,
g_port,
response_cb,
0);
globus_mutex_lock(&the_lock);
while(!done)
{
globus_cond_wait(&the_cond, &the_lock);
}
globus_mutex_unlock(&the_lock);
rc = globus_module_deactivate_all();
printf("%s - get_linger_close\n", (done==1&&rc==0)?"ok":"not ok");
return (done !=1 || rc != 0);
}
globus_ftp_control-9.10/test/PaxHeaders.24857/abort_test.c 0000644 0000000 0000000 00000000131 14243161125 021644 x ustar 00 0000000 0000000 30 mtime=1653400149.412969574
30 atime=1653401814.324287227
29 ctime=1653404005.26289941
globus_ftp_control-9.10/test/abort_test.c 0000664 0001750 0001750 00000041261 14243161125 022003 0 ustar 00johndoe johndoe 0000000 0000000 /*
* Copyright 1999-2006 University of Chicago
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "globus_ftp_control_test.h"
#include "test_common.h"
#define TEST_ITERATIONS 8
#define NAME1 "globus_ftp_control_test_file_name1"
#define NAME2 "globus_ftp_control_test_file_name2"
#define CHUNK_SIZE 2048
#define CHUNK_COUNT 1000
#define ABORT_COUNT 5
void
test_result(
globus_result_t res,
char * msg);
static void
abort_response_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_ftp_control_response_t * ftp_response);
static void
write_data_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_byte_t * buffer,
globus_size_t length,
globus_off_t offset,
globus_bool_t eof);
static void
read_data_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_byte_t * buffer,
globus_size_t length,
globus_off_t offset,
globus_bool_t eof);
static globus_byte_t * g_buffer = GLOBUS_NULL;
static ftp_test_monitor_t g_monitor;
static globus_bool_t g_abort_size;
/*
* make pasv blocking
*/
void
pasv_response_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_ftp_control_response_t * ftp_response)
{
globus_result_t res;
ftp_test_monitor_t * l_mon;
globus_ftp_control_host_port_t addr;
l_mon = (ftp_test_monitor_t *)callback_arg;
if(error != GLOBUS_NULL)
{
test_result(globus_error_put(error),
"response callback()");
}
if(ftp_response->code == 227)
{
verbose_printf(2, "pasv buffer :%s:\n", ftp_response->response_buffer);
pasv_to_host_port((char *)ftp_response->response_buffer, &addr);
verbose_printf(2, "pasv port %d.%d.%d.%d:%d\n",
addr.host[0],
addr.host[1],
addr.host[2],
addr.host[3],
addr.port);
res = globus_ftp_control_local_port(handle, &addr);
test_result(res, "globus_ftp_control_local_port()");
}
else
{
verbose_printf(1, "error, pasv reply was :%s:\n", ftp_response->response_buffer);
}
globus_mutex_lock(&l_mon->mutex);
{
l_mon->done = GLOBUS_TRUE;
globus_cond_signal(&l_mon->cond);
}
globus_mutex_unlock(&l_mon->mutex);
return;
}
static void
send_pasv_blocking(
globus_ftp_control_handle_t * handle)
{
globus_result_t res;
ftp_test_monitor_t l_mon;
ftp_test_monitor_init(&l_mon);
res = globus_ftp_control_send_command(
handle,
"PASV\r\n",
pasv_response_callback,
(void *)&l_mon);
test_result(res, "globus_ftp_control_send_command()");
globus_mutex_lock(&l_mon.mutex);
{
while(!l_mon.done)
{
globus_cond_wait(&l_mon.cond, &l_mon.mutex);
}
}
globus_mutex_unlock(&l_mon.mutex);
}
/*
* make type blocking
*/
void
type_response_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_ftp_control_response_t * ftp_response)
{
ftp_test_monitor_t * l_mon;
l_mon = (ftp_test_monitor_t *)callback_arg;
if(error != GLOBUS_NULL)
{
test_result(globus_error_put(error),
"response callback()");
}
globus_mutex_lock(&l_mon->mutex);
{
l_mon->done = GLOBUS_TRUE;
globus_cond_signal(&l_mon->cond);
}
globus_mutex_unlock(&l_mon->mutex);
return;
}
static void
send_type_blocking(
globus_ftp_control_handle_t * handle)
{
globus_result_t res;
ftp_test_monitor_t l_mon;
ftp_test_monitor_init(&l_mon);
res = globus_ftp_control_send_command(
handle,
"TYPE I\r\n",
type_response_callback,
(void *)&l_mon);
test_result(res, "globus_ftp_control_send_command()");
globus_mutex_lock(&l_mon.mutex);
{
while(!l_mon.done)
{
globus_cond_wait(&l_mon.cond, &l_mon.mutex);
}
}
globus_mutex_unlock(&l_mon.mutex);
res = globus_ftp_control_local_type(
handle,
GLOBUS_FTP_CONTROL_TYPE_IMAGE,
0);
test_result(res, "local_type");
}
static void
send_dele_blocking(
globus_ftp_control_handle_t * handle,
char * fname)
{
globus_result_t res;
ftp_test_monitor_t l_mon;
ftp_test_monitor_init(&l_mon);
res = globus_ftp_control_send_command(
handle,
"DELE %s\r\n",
type_response_callback,
(void *)&l_mon,
fname);
test_result(res, "globus_ftp_control_send_command()");
globus_mutex_lock(&l_mon.mutex);
{
while(!l_mon.done)
{
globus_cond_wait(&l_mon.cond, &l_mon.mutex);
}
}
globus_mutex_unlock(&l_mon.mutex);
}
/*
* this is called with a connected handle
*/
globus_bool_t
abort_test(
globus_ftp_control_handle_t * handle)
{
globus_result_t res;
ftp_test_monitor_t l_mon;
int ctr;
ftp_test_monitor_init(&l_mon);
ftp_test_monitor_init(&g_monitor);
g_buffer = globus_malloc(CHUNK_SIZE);
memset(g_buffer, 0xff, CHUNK_SIZE);
verbose_printf(2, "set to type i\n");
send_type_blocking(handle);
for(ctr = 0; ctr < TEST_ITERATIONS; ctr++)
{
/*
* put a file on the server
*/
verbose_printf(2, "sending\n");
g_abort_size = -1;
verbose_printf(2, "put in pasv mode\n");
send_pasv_blocking(handle);
ftp_test_monitor_reset(&l_mon);
ftp_test_monitor_reset(&g_monitor);
res = globus_ftp_control_send_command(
handle,
"STOR %s\r\n",
abort_response_callback,
(void *)&l_mon,
NAME1);
test_result(res, "send command");
res = globus_ftp_control_data_connect_write(
handle,
GLOBUS_NULL,
GLOBUS_NULL);
test_result(res, "connect_write()");
ftp_test_monitor_done_wait(&l_mon);
ftp_test_monitor_reset(&l_mon);
res = globus_ftp_control_data_write(
handle,
g_buffer,
CHUNK_SIZE,
0,
GLOBUS_FALSE,
write_data_callback,
(void *) &l_mon);
test_result(res, "globus_ftp_control_data_write()");
ftp_test_monitor_count_wait(&l_mon, 2);
/*
* send and abort
*/
verbose_printf(2, "sending and aborting\n");
ftp_test_monitor_reset(&g_monitor);
ftp_test_monitor_reset(&l_mon);
g_abort_size = ABORT_COUNT;
verbose_printf(2, "setting abort size to %d\n", g_abort_size);
verbose_printf(2, "put in pasv mode\n");
send_pasv_blocking(handle);
res = globus_ftp_control_send_command(
handle,
"STOR %s\r\n",
abort_response_callback,
(void *)&l_mon,
NAME2);
test_result(res, "send command");
res = globus_ftp_control_data_connect_write(
handle,
GLOBUS_NULL,
GLOBUS_NULL);
test_result(res, "connect_write()");
ftp_test_monitor_done_wait(&l_mon);
ftp_test_monitor_reset(&l_mon);
res = globus_ftp_control_data_write(
handle,
g_buffer,
CHUNK_SIZE,
0,
GLOBUS_FALSE,
write_data_callback,
(void *) &l_mon);
test_result(res, "globus_ftp_control_data_write()");
ftp_test_monitor_count_wait(&l_mon, 3);
/*
* receive and abort
*/
verbose_printf(2, "recieving and aborting\n");
ftp_test_monitor_reset(&g_monitor);
ftp_test_monitor_reset(&l_mon);
g_abort_size = ABORT_COUNT;
verbose_printf(2, "put in pasv mode\n");
send_pasv_blocking(handle);
verbose_printf(2, "sending RETR\n");
res = globus_ftp_control_send_command(
handle,
"RETR %s\r\n",
abort_response_callback,
(void *)&l_mon,
NAME1);
test_result(res, "send command");
verbose_printf(2, "calling connect read\n");
res = globus_ftp_control_data_connect_read(
handle,
GLOBUS_NULL,
GLOBUS_NULL);
test_result(res, "connect_read()");
ftp_test_monitor_done_wait(&l_mon);
ftp_test_monitor_reset(&l_mon);
verbose_printf(2, "calling data_read\n");
res = globus_ftp_control_data_read(
handle,
g_buffer,
CHUNK_SIZE,
read_data_callback,
(void *)&l_mon);
test_result(res, "globus_ftp_control_data_write()");
ftp_test_monitor_count_wait(&l_mon, 3);
/*
* receive the file
*/
verbose_printf(2, "recieving\n");
ftp_test_monitor_reset(&g_monitor);
ftp_test_monitor_reset(&l_mon);
g_abort_size = -1;
verbose_printf(2, "put in pasv mode\n");
send_pasv_blocking(handle);
res = globus_ftp_control_send_command(
handle,
"RETR %s\r\n",
abort_response_callback,
(void *)&l_mon,
NAME1);
test_result(res, "send command");
res = globus_ftp_control_data_connect_read(
handle,
GLOBUS_NULL,
GLOBUS_NULL);
test_result(res, "connect_read()");
ftp_test_monitor_done_wait(&l_mon);
ftp_test_monitor_reset(&l_mon);
res = globus_ftp_control_data_read(
handle,
g_buffer,
CHUNK_SIZE,
read_data_callback,
(void *)&l_mon);
test_result(res, "globus_ftp_control_data_write()");
ftp_test_monitor_count_wait(&l_mon, 2);
/*
* remove the file
*/
send_dele_blocking(handle, NAME1);
}
return GLOBUS_TRUE;
}
void
abort_response_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_ftp_control_response_t * ftp_response)
{
ftp_test_monitor_t * l_mon;
l_mon = (ftp_test_monitor_t *)callback_arg;
verbose_printf(2, "abort_response_callback() : %d %s\n",
ftp_response->code,
ftp_response->response_buffer);
if(error != GLOBUS_NULL)
{
test_result(globus_error_put(error), "abort_response_callback error");
}
if(ftp_response->code == 226)
{
ftp_test_monitor_signal(l_mon);
}
if(ftp_response->code == 225)
{
ftp_test_monitor_signal(l_mon);
}
else if(ftp_response->code == 426)
{
ftp_test_monitor_signal(l_mon);
}
else if(ftp_response->code == 150)
{
ftp_test_monitor_signal(l_mon);
}
}
void
write_data_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_byte_t * buffer,
globus_size_t length,
globus_off_t offset,
globus_bool_t eof)
{
globus_bool_t send_eof = GLOBUS_FALSE;
ftp_test_monitor_t * l_mon;
globus_result_t res;
l_mon = (ftp_test_monitor_t *)callback_arg;
verbose_printf(3, "write_data_callback():start\n");
globus_mutex_lock(&g_monitor.mutex);
{
g_monitor.count++;
if(g_monitor.count == CHUNK_COUNT)
{
verbose_printf(2, "sending eof\n");
send_eof = GLOBUS_TRUE;
}
if(g_abort_size == g_monitor.count)
{
verbose_printf(2, "sending abort message");
res = globus_ftp_control_abort(
handle,
abort_response_callback,
(void *)l_mon);
test_result(res, "globus_ftp_control_abort()");
}
if(eof)
{
verbose_printf(2, "signaling eof\n");
ftp_test_monitor_signal(l_mon);
}
else
{
res = globus_ftp_control_data_write(
handle,
g_buffer,
CHUNK_SIZE,
offset+length,
send_eof,
write_data_callback,
(void *) callback_arg);
test_result(res, "globus_ftp_control_data_write()");
}
}
globus_mutex_unlock(&g_monitor.mutex);
}
void
read_data_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_byte_t * buffer,
globus_size_t length,
globus_off_t offset,
globus_bool_t eof)
{
globus_result_t res;
ftp_test_monitor_t * l_mon;
verbose_printf(3, "read_data_callback() : start\n");
l_mon = (ftp_test_monitor_t *)callback_arg;
if(error != GLOBUS_NULL)
{
verbose_printf(1, "read_data_callback():error in callback\n");
}
globus_mutex_lock(&g_monitor.mutex);
{
g_monitor.count++;
if(g_abort_size == g_monitor.count)
{
verbose_printf(2, "@@@@@@ sending read abort message");
res = globus_ftp_control_abort(
handle,
abort_response_callback,
(void *)l_mon);
test_result(res, "globus_ftp_control_abort()");
}
if(!eof)
{
verbose_printf(3, "registering next read\n");
res = globus_ftp_control_data_read(
handle,
g_buffer,
CHUNK_SIZE,
read_data_callback,
callback_arg);
test_result(res, "globus_ftp_control_data_write()");
}
else
{
verbose_printf(2, "read_data_callback() : eof received\n");
l_mon = (ftp_test_monitor_t *)callback_arg;
globus_mutex_lock(&l_mon->mutex);
{
l_mon->count++;
globus_cond_signal(&l_mon->cond);
}
globus_mutex_unlock(&l_mon->mutex);
}
}
globus_mutex_unlock(&g_monitor.mutex);
}
void
test_result(
globus_result_t res,
char * msg)
{
if(res != GLOBUS_SUCCESS)
{
verbose_printf(1, "error:%s\n",
globus_object_printable_to_string(globus_error_get(res)));
verbose_printf(1, "%s\n", msg);
assert(GLOBUS_FALSE);
}
}
globus_ftp_control-9.10/test/PaxHeaders.24857/async_control_test.c 0000644 0000000 0000000 00000000130 14243161125 023411 x ustar 00 0000000 0000000 30 mtime=1653400149.412969574
30 atime=1653401814.360286888
28 ctime=1653404005.2638994
globus_ftp_control-9.10/test/async_control_test.c 0000664 0001750 0001750 00000013502 14243161125 023546 0 ustar 00johndoe johndoe 0000000 0000000 /*
* Copyright 1999-2006 University of Chicago
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "globus_ftp_control_test.h"
#include
#include
#include
#ifndef _WIN32
#include
#include
#endif
void
connect_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_ftp_control_response_t * ftp_response);
void
authenticate_callback(
void *callback_arg,
globus_ftp_control_handle_t *handle,
globus_object_t *error,
globus_ftp_control_response_t *ftp_response);
void
send_command_callback(
void *callback_arg,
globus_ftp_control_handle_t *handle,
globus_object_t *error,
globus_ftp_control_response_t *ftp_response);
void
quit_callback(
void *callback_arg,
globus_ftp_control_handle_t *handle,
globus_object_t *error,
globus_ftp_control_response_t *ftp_response);
globus_mutex_t end_mutex;
globus_cond_t end_cond;
globus_bool_t end_done;
globus_mutex_t data_mutex;
globus_cond_t data_cond;
globus_bool_t data_done;
globus_ftp_control_auth_info_t auth;
globus_bool_t
async_control_test(
globus_ftp_control_handle_t * handle)
{
globus_ftp_control_handle_t control_handle;
globus_result_t result;
globus_mutex_init(&end_mutex, GLOBUS_NULL);
globus_cond_init(&end_cond, GLOBUS_NULL);
end_done = GLOBUS_FALSE;
result = globus_ftp_control_handle_init(&control_handle);
if (result != GLOBUS_SUCCESS)
{
printf("error: could not initialize\n");
exit(1);
}
result = globus_ftp_control_connect(
&control_handle,
login_info.hostname,
login_info.port,
connect_callback,
GLOBUS_NULL);
if (result != GLOBUS_SUCCESS)
{
printf("error: could not connect\n");
return GLOBUS_FALSE;
}
globus_mutex_lock(&end_mutex);
{
while(!end_done)
{
globus_cond_wait(&end_cond, &end_mutex);
}
}
globus_mutex_unlock(&end_mutex);
globus_ftp_control_handle_destroy(&control_handle);
return GLOBUS_TRUE;
}
void
connect_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_ftp_control_response_t * ftp_response)
{
globus_result_t result;
if (ftp_response->code == 220 || ftp_response->code == 530) {
verbose_printf(2, "%s\n", ftp_response->response_buffer);
auth.auth_gssapi_subject = GLOBUS_NULL;
auth.auth_gssapi_context = GLOBUS_NULL;
auth.user = login_info.login;
auth.password = login_info.password;
result= globus_ftp_control_authenticate(
handle,
&auth,
GLOBUS_TRUE,
authenticate_callback,
GLOBUS_NULL);
if (result != GLOBUS_SUCCESS) {
printf("authentication failed\n");
exit(1);
}
} else {
printf("Error : %s\n", ftp_response->response_buffer);
exit(1);
}
}
void
authenticate_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_ftp_control_response_t * ftp_response)
{
globus_result_t result;
if(error != GLOBUS_NULL)
{
verbose_printf(1, "Error : %s\n",
globus_object_printable_to_string(error));
exit(1);
}
if (ftp_response->code == 230)
{
verbose_printf(2, "%s\n", ftp_response->response_buffer);
result = globus_ftp_control_send_command(
handle,
"PWD\r\n",
send_command_callback,
GLOBUS_NULL);
if (result != GLOBUS_SUCCESS)
{
verbose_printf(1, "send_command PWD failed\n");
exit(1);
}
}
else
{
verbose_printf(1, "Error : %s\n", ftp_response->response_buffer);
exit(1);
}
}
void
send_command_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_ftp_control_response_t * ftp_response)
{
globus_result_t result;
if (ftp_response->code == 257)
{
verbose_printf(2, "%s\n", ftp_response->response_buffer);
result = globus_ftp_control_quit(
handle,
quit_callback,
GLOBUS_NULL);
if (result != GLOBUS_SUCCESS)
{
verbose_printf(1, "quit failed\n");
exit(1);
}
}
else
{
verbose_printf(1, "Error : %s\n", ftp_response->response_buffer);
exit(1);
}
}
void
quit_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_ftp_control_response_t * ftp_response)
{
if (ftp_response->code == 221)
{
verbose_printf(2, "%s\n", ftp_response->response_buffer);
globus_mutex_lock(&end_mutex);
{
end_done = GLOBUS_TRUE;
globus_cond_signal(&end_cond);
}
globus_mutex_unlock(&end_mutex);
}
else
{
verbose_printf(1,"Error : %s\n", ftp_response->response_buffer);
exit(1);
}
}
globus_ftp_control-9.10/test/PaxHeaders.24857/globus_ftp_control_test.c 0000644 0000000 0000000 00000000132 14243161125 024442 x ustar 00 0000000 0000000 30 mtime=1653400149.413969564
30 atime=1653401814.453286012
30 ctime=1653404005.265899381
globus_ftp_control-9.10/test/globus_ftp_control_test.c 0000664 0001750 0001750 00000030512 14243161125 024575 0 ustar 00johndoe johndoe 0000000 0000000 /*
* Copyright 1999-2006 University of Chicago
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "globus_ftp_control_test.h"
#include "globus_common.h"
#include
globus_bool_t
connect_wrapper(
globus_ftp_control_handle_t * control_handle);
globus_bool_t
disconnect_wrapper(
globus_ftp_control_handle_t * control_handle);
globus_bool_t
simple_control_test_wrapper(
globus_ftp_control_handle_t * control_handle);
globus_bool_t
simple_data_test_wrapper(
globus_ftp_control_handle_t * control_handle);
globus_bool_t
eb_simple_data_test_wrapper(
globus_ftp_control_handle_t * control_handle);
globus_bool_t
outstanding_io_test_wrapper(
globus_ftp_control_handle_t * control_handle);
globus_bool_t
simple_dir_test_wrapper(
globus_ftp_control_handle_t * control_handle);
globus_bool_t
abort_test_wrapper(
globus_ftp_control_handle_t * control_handle);
/*****************************************************************
* test function desriptors
*
* when adding a test add its function descriptor and
* a string describing it to the "test_array" table, and
* increase the TEST_COUNT by one.
****************************************************************/
typedef
globus_bool_t
(*globus_ftp_control_test_func_t)(
globus_ftp_control_handle_t * control_handle);
typedef struct test_entry_s
{
globus_ftp_control_test_func_t test_func;
char * name;
} test_entry_t;
test_entry_t test_array[] =
{
{connect_wrapper, "connect handle test"},
{disconnect_wrapper, "disconnect handle test"},
{simple_dir_test_wrapper, "simple directory test"},
{simple_data_test_wrapper, "simple data 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"},
{GLOBUS_NULL, GLOBUS_NULL}
};
#define TEST_COUNT 1
test_entry_t eb_test_array[] =
{
{eb_simple_data_test_wrapper, "eb simple data test"},
{GLOBUS_NULL, GLOBUS_NULL}
};
#define EB_TEST_COUNT 1
login_t login_info = {
":globus-mapping:",
"",
"",
"",
0
};
extern int verbose_print_level;
int
main(
int argc,
char * argv[])
{
int ctr;
globus_ftp_control_handle_t control_handle;
globus_result_t result;
int tests_run = 0;
int tests_passed = 0;
int tests_failed = 0;
globus_bool_t rc;
globus_ftp_control_handle_t handles[TEST_COUNT];
verbose_print_level = 1;
/*
* get the verbose print level
*/
for(ctr = 0; ctr < argc; ctr++)
{
if(strcmp(argv[ctr], "--verbose") == 0)
{
if(ctr + 1 >= argc)
{
verbose_print_level = 1;
}
else
{
verbose_print_level = atoi(argv[ctr+1]);
ctr++;
}
}
else if(strcmp(argv[ctr], "--host") == 0)
{
if(argc < ctr+2)
{
help_print();
exit(1);
}
strcpy(login_info.hostname, argv[ctr+1]);
login_info.port = atoi(argv[ctr+2]);
}
else if(strcmp(argv[ctr], "--help") == 0)
{
help_print();
}
else if(strcmp(argv[ctr], "--login") == 0)
{
if(argc < ctr+3)
{
help_print();
exit(1);
}
strcpy(login_info.login, argv[ctr+1]);
strcpy(login_info.password, argv[ctr+2]);
strcpy(login_info.dir, argv[ctr+3]);
ctr += 3;
}
}
if (login_info.dir[0] == 0)
{
getcwd(login_info.dir, sizeof(login_info.dir));
}
/*
* first test
*/
rc = globus_module_activate(GLOBUS_FTP_CONTROL_MODULE);
tests_run++;
result = globus_ftp_control_handle_init(&handles[0]);
connect_control_handle(
&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);
tests_passed++;
verbose_printf(1, "test #%d) activate/connect/deactivate passed\n", tests_run);
/*
* second test
*/
rc = globus_module_activate(GLOBUS_FTP_CONTROL_MODULE);
tests_run++;
for(ctr = 0; ctr < TEST_COUNT; ctr++)
{
result = globus_ftp_control_handle_init(&handles[ctr]);
if(result != GLOBUS_SUCCESS)
{
tests_failed++;
verbose_printf(1,
"activate/deactivate test # %d failed\n",
tests_run);
exit(1);
}
if(ctr % 2)
{
result = globus_ftp_control_handle_destroy(&handles[ctr]);
if(result != GLOBUS_SUCCESS)
{
tests_failed++;
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)
{
tests_failed++;
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)
{
globus_libc_printf("unable to activate common module\n");
exit(1);
}
/*
* run stream mode tests
*/
rc = globus_module_activate(GLOBUS_FTP_CONTROL_MODULE);
if(result != GLOBUS_SUCCESS)
{
globus_libc_printf("unable to activate gsiftp module\n");
exit(1);
}
globus_ftp_control_handle_init(&control_handle);
for(ctr = 0; ctr < EB_TEST_COUNT; ctr++)
{
tests_run++;
if(eb_test_array[ctr].test_func(&control_handle))
{
tests_passed++;
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",
tests_run, eb_test_array[ctr].name);
exit(1);
}
}
globus_ftp_control_handle_destroy(&control_handle);
globus_ftp_control_handle_init(&control_handle);
for(ctr = 0; ctr < TEST_COUNT; ctr++)
{
tests_run++;
if(test_array[ctr].test_func(&control_handle))
{
tests_passed++;
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",
tests_run, test_array[ctr].name);
exit(1);
}
}
globus_ftp_control_handle_destroy(&control_handle);
rc = globus_module_deactivate(GLOBUS_FTP_CONTROL_MODULE);
if(result != GLOBUS_SUCCESS)
{
globus_libc_printf("unable to activate gsiftp module\n");
exit(1);
}
verbose_printf(1, "%d tests run. %d passed. %d failed\n",
tests_run, tests_passed, tests_failed);
verbose_printf(0, "Success\n");
return 0;
}
globus_bool_t
simple_control_test_wrapper(
globus_ftp_control_handle_t * control_handle)
{
globus_bool_t rc;
rc = connect_control_handle(control_handle,
login_info.login,
login_info.password,
login_info.dir,
login_info.hostname,
login_info.port);
if(rc)
{
rc = simple_control_test(control_handle);
}
if(rc)
{
rc = disconnect_control_handle(control_handle);
}
return rc;
}
globus_bool_t
connect_wrapper(
globus_ftp_control_handle_t * control_handle)
{
return connect_control_handle(
control_handle,
login_info.login,
login_info.password,
login_info.dir,
login_info.hostname,
login_info.port);
}
globus_bool_t
disconnect_wrapper(
globus_ftp_control_handle_t * control_handle)
{
globus_bool_t rc;
rc = disconnect_control_handle(control_handle);
return rc;
}
globus_bool_t
simple_data_test_wrapper(
globus_ftp_control_handle_t * control_handle)
{
globus_bool_t rc;
rc = connect_control_handle(control_handle,
login_info.login,
login_info.password,
login_info.dir,
login_info.hostname,
login_info.port);
if(rc)
{
rc = simple_data_test(control_handle);
}
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)
{
globus_bool_t rc;
rc = connect_control_handle(control_handle,
login_info.login,
login_info.password,
login_info.dir,
login_info.hostname,
login_info.port);
if(rc)
{
rc = eb_data_test(control_handle);
}
if(rc)
{
rc = disconnect_control_handle(control_handle);
}
return rc;
}
globus_bool_t
outstanding_io_test_wrapper(
globus_ftp_control_handle_t * control_handle)
{
globus_bool_t rc;
rc = connect_control_handle(control_handle,
login_info.login,
login_info.password,
login_info.dir,
login_info.hostname,
login_info.port);
if(rc)
{
rc = outstanding_io_test(control_handle);
}
if(rc)
{
rc = disconnect_control_handle(control_handle);
}
return rc;
}
globus_bool_t
simple_dir_test_wrapper(
globus_ftp_control_handle_t * control_handle)
{
globus_bool_t rc;
rc = connect_control_handle(control_handle,
login_info.login,
login_info.password,
login_info.dir,
login_info.hostname,
login_info.port);
if(rc)
{
rc = simple_dir_test(control_handle);
}
if(rc)
{
rc = disconnect_control_handle(control_handle);
}
return rc;
}
globus_bool_t
abort_test_wrapper(
globus_ftp_control_handle_t * control_handle)
{
globus_bool_t rc;
rc = connect_control_handle(control_handle,
login_info.login,
login_info.password,
login_info.dir,
login_info.hostname,
login_info.port);
if(rc)
{
rc = abort_test(control_handle);
}
if(rc)
{
rc = disconnect_control_handle(control_handle);
}
return rc;
}
globus_ftp_control-9.10/test/PaxHeaders.24857/globus_ftp_control_test.h 0000644 0000000 0000000 00000000132 14243161125 024447 x ustar 00 0000000 0000000 30 mtime=1653400149.413969564
30 atime=1653401814.336287114
30 ctime=1653404005.266899372
globus_ftp_control-9.10/test/globus_ftp_control_test.h 0000664 0001750 0001750 00000014707 14243161125 024612 0 ustar 00johndoe johndoe 0000000 0000000 /*
* Copyright 1999-2006 University of Chicago
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#if !defined(GLOBUS_FTP_CONTROL_TEST_H)
#define GLOBUS_FTP_CONTROL_TEST_H
#include "globus_ftp_control.h"
#include "test_common.h"
/**********************************************************************
* TESTS
*
* for ascii and binary
*
* a call to globus_module_activate should precede each test
* and they should be followed by a corresponding call to _deactivate
*
* control_connect_test
* test connecting the control channel
*
* control_disconnect_test
* disconnect the control channel
*
* async_control_test
* send commands via the callbacks of other commands
*
* simple_control_test
* send several non data requesting commands and wait for
* appropriate responses
*
* simple_data_test
* put bytes / get bytes / compare bytes
* only 1 read or write request is outstanding a time
*
* simple_dir_test
* requests a list from the server. Tests the data channel.
*
* outstanding_io_test
* same as simple_data_test only several read/write can be registered
* at one time
*
* simple_fail_test
* a variety of functions called that due to the current state
* should fail with useful error codes
*
* abort_restart_test
* same as the abort_test only restart the transfer after the
* abort is successful
*
* data_commands_connect_test
* Test if a control handle hasn't been established prior to calling
* globus_ftp_data commands.
*
* data_commands_pasvorport_test
* Test if globus_ftp_data_local_pasv()/port() has been called prior to
* calling globus_ftp_data commands.
*
* pending_test
* Test for pending commands that have been sent but the reply is not yet
* been received. In this case a call to send_command() returns FAILURE.
*
**********************************************************************/
typedef struct login_s
{
char login[512];
char password[512];
char dir[512];
char hostname[512];
int port;
} login_t;
typedef struct globus_ftp_control_test_monitor_s
{
globus_mutex_t mutex;
globus_cond_t cond;
globus_bool_t done;
globus_bool_t rc;
int count;
void * user_arg;
} globus_ftp_control_test_monitor_t;
void
fake_file_init(
globus_ftp_control_fake_file_t * fake_file,
int file_size,
int chunk_size);
globus_byte_t *
fake_file_get_chunk(
globus_ftp_control_fake_file_t * fake_file,
int * chunk_size);
globus_bool_t
fake_file_seek(
globus_ftp_control_fake_file_t * fake_file,
int offset);
globus_bool_t
fake_file_is_eof(
globus_ftp_control_fake_file_t * fake_file);
globus_bool_t
fake_file_cmp(
globus_ftp_control_fake_file_t * fake_file,
globus_byte_t * buffer,
int offset,
int length);
void
fake_file_destroy(
globus_ftp_control_fake_file_t * fake_file);
void
verbose_printf(
int level,
char * s,
...);
void
help_print();
globus_bool_t
connect_control_handle(
globus_ftp_control_handle_t * control_handle,
char * user_name,
char * password,
char * base_dir,
char * hostname,
unsigned short port);
globus_bool_t
disconnect_control_handle(
globus_ftp_control_handle_t * control_handle);
globus_bool_t
simple_control_test(
globus_ftp_control_handle_t * handle);
globus_bool_t
simple_data_test(
globus_ftp_control_handle_t * handle);
globus_bool_t
eb_data_test(
globus_ftp_control_handle_t * handle);
globus_bool_t
eb_simple_data_test(
globus_ftp_control_handle_t * handle);
globus_bool_t
outstanding_io_test(
globus_ftp_control_handle_t * handle);
globus_bool_t
async_control_test(
globus_ftp_control_handle_t * handle);
globus_bool_t
simple_dir_test(
globus_ftp_control_handle_t * handle);
globus_bool_t
pending_response_test(
globus_ftp_control_handle_t * handle);
globus_bool_t
data_commands_connect_test(
globus_ftp_control_handle_t * handle);
globus_bool_t
data_commands_pasvorport_test(
globus_ftp_control_handle_t * handle);
globus_bool_t
abort_test(
globus_ftp_control_handle_t * handle);
globus_bool_t
pasv_to_host_port(
char * parse_str,
globus_ftp_control_host_port_t * addr);
extern int verbose_print_level;
void
verbose_printf(
int level,
char * s,
...);
void
help_print();
globus_bool_t
simple_control_test(
globus_ftp_control_handle_t * handle);
globus_bool_t
simple_data_test(
globus_ftp_control_handle_t * handle);
globus_bool_t
pasv_to_host_port(
char * parse_str,
globus_ftp_control_host_port_t * addr);
extern int verbose_print_level;
extern login_t login_info;
#endif
globus_ftp_control-9.10/test/PaxHeaders.24857/eb_simple_data_test.c 0000644 0000000 0000000 00000000132 14243161125 023466 x ustar 00 0000000 0000000 30 mtime=1653400149.413969564
30 atime=1653401814.430286229
30 ctime=1653404005.268899353
globus_ftp_control-9.10/test/eb_simple_data_test.c 0000664 0001750 0001750 00000046232 14243161125 023627 0 ustar 00johndoe johndoe 0000000 0000000 /*
* Copyright 1999-2006 University of Chicago
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "globus_ftp_control_test.h"
#define TEST_ITERATIONS 8
#define NAME "globus_ftp_control_test_file_name"
#define DIRECTION_GET 0
#define DIRECTION_PUT 1
#define CHUNK_SIZE 256
#define CHUNK_COUNT 10
typedef struct get_put_info_s
{
int direction;
int buffer_size;
globus_byte_t * buffer;
globus_bool_t result;
globus_ftp_control_fake_file_t * fake_file;
} get_put_info_t;
static void
eb_data_response_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_ftp_control_response_t * ftp_response);
void
eb_port_response_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_ftp_control_response_t * ftp_response);
static void
eb_write_data_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_byte_t * buffer,
globus_size_t length,
globus_off_t offset,
globus_bool_t eof);
static void
read_data_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_byte_t * buffer,
globus_size_t length,
globus_off_t offset,
globus_bool_t eof);
static void
signal_exit();
static globus_ftp_control_test_monitor_t monitor;
/*
* this is called with a connected handle
*/
globus_bool_t
eb_data_test(
globus_ftp_control_handle_t * handle)
{
globus_result_t result;
get_put_info_t get_put_info;
globus_ftp_control_fake_file_t fake_file;
globus_ftp_control_host_port_t host_port;
int ctr;
int hi;
int low;
globus_mutex_init(&monitor.mutex, GLOBUS_NULL);
globus_cond_init(&monitor.cond, GLOBUS_NULL);
/* once in default, once in image */
for(ctr = 0; ctr < 10; ctr++)
{
/* send type */
if(ctr == 0)
{
verbose_printf(2, "sending type command\n");
monitor.done = GLOBUS_FALSE;
monitor.count = 0;
monitor.rc = GLOBUS_TRUE;
result = globus_ftp_control_send_command(
handle,
"TYPE I\r\n",
eb_data_response_callback,
GLOBUS_NULL);
if(result != GLOBUS_SUCCESS)
{
verbose_printf(1, "send_command TYPE failed\n");
return GLOBUS_FALSE;
}
/* wait to get pasv back */
globus_mutex_lock(&monitor.mutex);
{
while(!monitor.done)
{
globus_cond_wait(&monitor.cond, &monitor.mutex);
}
}
globus_mutex_unlock(&monitor.mutex);
if(!monitor.rc)
{
verbose_printf(1, "TYPE failed\n");
return GLOBUS_FALSE;
}
verbose_printf(2, "sending MODE E command\n");
monitor.done = GLOBUS_FALSE;
monitor.count = 0;
monitor.rc = GLOBUS_TRUE;
result = globus_ftp_control_send_command(
handle,
"MODE E\r\n",
eb_data_response_callback,
GLOBUS_NULL);
if(result != GLOBUS_SUCCESS)
{
verbose_printf(1, "send_command MODE failed\n");
return GLOBUS_FALSE;
}
globus_mutex_lock(&monitor.mutex);
{
while(!monitor.done)
{
globus_cond_wait(&monitor.cond, &monitor.mutex);
}
}
globus_mutex_unlock(&monitor.mutex);
if(!monitor.rc)
{
verbose_printf(1, "MODE failed\n");
return GLOBUS_FALSE;
}
globus_ftp_control_local_mode(
handle,
GLOBUS_FTP_CONTROL_MODE_EXTENDED_BLOCK);
}
/* send pasv */
verbose_printf(2, "sending pasv command\n");
monitor.done = GLOBUS_FALSE;
result = globus_ftp_control_send_command(
handle,
"PASV\r\n",
eb_data_response_callback,
GLOBUS_NULL);
if(result != GLOBUS_SUCCESS)
{
verbose_printf(1, "send_command PASV failed\n");
return GLOBUS_FALSE;
}
/* wait to get pasv back */
globus_mutex_lock(&monitor.mutex);
{
while(!monitor.done)
{
globus_cond_wait(&monitor.cond, &monitor.mutex);
}
}
globus_mutex_unlock(&monitor.mutex);
if(!monitor.rc)
{
verbose_printf(1, "pasv command failed\n");
return GLOBUS_FALSE;
}
/* start writting */
verbose_printf(2, "sending stor command\n");
get_put_info.direction = DIRECTION_PUT;
monitor.rc = GLOBUS_TRUE;
fake_file_init(&fake_file, CHUNK_SIZE * CHUNK_COUNT + 12, CHUNK_SIZE);
get_put_info.fake_file = &fake_file;
monitor.done = GLOBUS_FALSE;
monitor.count = 0;
result = globus_ftp_control_send_command(
handle,
"STOR %s\r\n",
eb_data_response_callback,
&get_put_info,
NAME);
if(result != GLOBUS_SUCCESS)
{
verbose_printf(1, "send_command STOR failed\n");
return GLOBUS_FALSE;
}
result = globus_ftp_control_data_connect_write(
handle, GLOBUS_NULL, GLOBUS_NULL);
if(result != GLOBUS_SUCCESS)
{
verbose_printf(1, "connect_write failed\n");
return GLOBUS_FALSE;
}
/* wait to get put back */
globus_mutex_lock(&monitor.mutex);
{
while(monitor.count < 2)
{
globus_cond_wait(&monitor.cond, &monitor.mutex);
}
}
globus_mutex_unlock(&monitor.mutex);
if(!monitor.rc)
{
verbose_printf(1, "STOR failed\n");
return GLOBUS_FALSE;
}
verbose_printf(2, "data has been sent\n");
/* new pasv */
host_port.port = 0;
globus_ftp_control_local_pasv(
handle,
&host_port);
hi = host_port.port / 256;
low = host_port.port % 256;
verbose_printf(2, "sending port command %d,%d,%d,%d,%d,%d\n",
host_port.host[0],
host_port.host[1],
host_port.host[2],
host_port.host[3],
hi,
low);
monitor.done = GLOBUS_FALSE;
monitor.rc = GLOBUS_TRUE;
result = globus_ftp_control_send_command(
handle,
"PORT %d,%d,%d,%d,%d,%d\r\n",
eb_port_response_callback,
GLOBUS_NULL,
host_port.host[0],
host_port.host[1],
host_port.host[2],
host_port.host[3],
hi,
low);
if(result != GLOBUS_SUCCESS)
{
verbose_printf(1, "send_command PASV failed\n");
return GLOBUS_FALSE;
}
globus_mutex_lock(&monitor.mutex);
{
while(!monitor.done)
{
globus_cond_wait(&monitor.cond, &monitor.mutex);
}
}
globus_mutex_unlock(&monitor.mutex);
if(!monitor.rc)
{
verbose_printf(1, "PASV failed\n");
return GLOBUS_FALSE;
}
fake_file_seek(get_put_info.fake_file, 0);
verbose_printf(2, "sending retr command\n");
get_put_info.direction = DIRECTION_GET;
monitor.rc = GLOBUS_TRUE;
get_put_info.fake_file = &fake_file;
monitor.done = GLOBUS_FALSE;
monitor.count = 0;
result = globus_ftp_control_send_command(
handle,
"RETR %s\r\n",
eb_data_response_callback,
&get_put_info,
NAME);
if(result != GLOBUS_SUCCESS)
{
verbose_printf(1, "send_command PASV failed\n");
return GLOBUS_FALSE;
}
result = globus_ftp_control_data_connect_read(
handle, GLOBUS_NULL, GLOBUS_NULL);
if(result != GLOBUS_SUCCESS)
{
verbose_printf(1, "connect_read failed\n");
return GLOBUS_FALSE;
}
globus_mutex_lock(&monitor.mutex);
{
while(monitor.count < 2)
{
globus_cond_wait(&monitor.cond, &monitor.mutex);
}
}
globus_mutex_unlock(&monitor.mutex);
if(!monitor.rc)
{
verbose_printf(1, "RETR failed\n");
return GLOBUS_FALSE;
}
verbose_printf(2, "data has been received\n");
/* delete existing file */
verbose_printf(2, "sending dele command\n");
monitor.done = GLOBUS_FALSE;
monitor.rc = GLOBUS_TRUE;
result = globus_ftp_control_send_command(
handle,
"DELE %s\r\n",
eb_data_response_callback,
GLOBUS_NULL,
NAME);
if(result != GLOBUS_SUCCESS)
{
verbose_printf(1, "send_command DELE failed\n");
return GLOBUS_FALSE;
}
/* wait to get pasv back */
globus_mutex_lock(&monitor.mutex);
{
while(!monitor.done)
{
globus_cond_wait(&monitor.cond, &monitor.mutex);
}
}
globus_mutex_unlock(&monitor.mutex);
if(!monitor.rc)
{
verbose_printf(1, "DELE failed\n");
return GLOBUS_FALSE;
}
fake_file_destroy(&fake_file);
}
return GLOBUS_TRUE;
}
void
eb_port_response_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_ftp_control_response_t * ftp_response)
{
verbose_printf(2, "eb_port_response_callback() : start %d\n",
ftp_response->code);
{
if(error != GLOBUS_NULL)
{
verbose_printf(1,
"eb_port_response_callback() : result failuer\n");
monitor.rc = GLOBUS_FALSE;
}
else
{
verbose_printf(2,
"eb_port_response_callback() : port successful\n");
monitor.rc = GLOBUS_TRUE;
}
signal_exit();
return;
}
}
void
eb_data_response_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_ftp_control_response_t * ftp_response)
{
get_put_info_t * get_put_info;
globus_result_t result;
globus_ftp_control_host_port_t addr;
if(error != GLOBUS_NULL)
{
monitor.rc = GLOBUS_FALSE;
signal_exit();
return;
}
if(ftp_response->code == 227)
{
pasv_to_host_port((char *)ftp_response->response_buffer, &addr);
result = globus_ftp_control_local_port(handle, &addr);
if(result != GLOBUS_SUCCESS)
{
monitor.rc = GLOBUS_FALSE;
}
else
{
monitor.rc = GLOBUS_TRUE;
}
signal_exit();
return;
}
else if(ftp_response->code == 226)
{
get_put_info = (get_put_info_t *)callback_arg;
if(get_put_info->direction == DIRECTION_PUT)
{
monitor.rc = GLOBUS_TRUE;
}
signal_exit();
}
else if(ftp_response->code == 150)
{
globus_byte_t * buf;
int buf_size;
get_put_info = (get_put_info_t *)callback_arg;
if(get_put_info->direction == DIRECTION_PUT)
{
buf = fake_file_get_chunk(get_put_info->fake_file, &buf_size);
result = globus_ftp_control_data_write(
handle,
buf,
buf_size,
0,
fake_file_is_eof(get_put_info->fake_file),
eb_write_data_callback,
(void *) get_put_info);
if(result != GLOBUS_SUCCESS)
{
verbose_printf(1, "intial write register failed\n");
monitor.rc = GLOBUS_FALSE;
signal_exit();
return;
}
}
else if(get_put_info->direction == DIRECTION_GET)
{
buf = globus_malloc(CHUNK_SIZE);
result = globus_ftp_control_data_read(
handle,
buf,
CHUNK_SIZE,
read_data_callback,
(void *) get_put_info);
if(result != GLOBUS_SUCCESS)
{
verbose_printf(1, "intial read register failed\n");
monitor.rc = GLOBUS_FALSE;
signal_exit();
return;
}
}
}
else if(ftp_response->code == 200)
{
result = globus_ftp_control_local_type(
handle,
GLOBUS_FTP_CONTROL_TYPE_IMAGE,
0);
if(result == GLOBUS_SUCCESS)
{
monitor.rc = GLOBUS_TRUE;
}
else
{
verbose_printf(1, "local_type failed\n");
monitor.rc = GLOBUS_FALSE;
}
signal_exit();
}
else if(ftp_response->code == 250)
{
verbose_printf(2, "delete succeded\n");
signal_exit();
}
else if(ftp_response->code >= 500)
{
verbose_printf(1, "error %s\n", ftp_response->response_buffer);
signal_exit();
}
else
{
verbose_printf(1, "error %d %s\n", ftp_response->code, ftp_response->response_buffer);
signal_exit();
}
}
void
signal_exit()
{
verbose_printf(2, "signal_exit() : start\n");
globus_mutex_lock(&monitor.mutex);
{
monitor.done = GLOBUS_TRUE;
monitor.count++;
globus_cond_signal(&monitor.cond);
}
globus_mutex_unlock(&monitor.mutex);
}
static
void
eb_write_data_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_byte_t * buffer,
globus_size_t length,
globus_off_t offset,
globus_bool_t eof)
{
get_put_info_t * get_put_info;
globus_byte_t * buf;
int buf_size;
globus_result_t result;
get_put_info = (get_put_info_t *)callback_arg;
if(error != GLOBUS_NULL)
{
monitor.rc = GLOBUS_FALSE;
signal_exit();
signal_exit();
return;
}
if(!eof)
{
buf = fake_file_get_chunk(get_put_info->fake_file, &buf_size);
result = globus_ftp_control_data_write(
handle,
buf,
buf_size,
offset + length,
fake_file_is_eof(get_put_info->fake_file),
eb_write_data_callback,
(void *) get_put_info);
if(result != GLOBUS_SUCCESS)
{
monitor.rc = GLOBUS_FALSE;
signal_exit();
signal_exit();
return;
}
}
else
{
signal_exit();
}
}
void
read_data_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_byte_t * buffer,
globus_size_t length,
globus_off_t offset,
globus_bool_t eof)
{
get_put_info_t * get_put_info;
globus_result_t result;
get_put_info = (get_put_info_t *)callback_arg;
if(error != GLOBUS_NULL)
{
monitor.rc = GLOBUS_FALSE;
signal_exit();
signal_exit();
return;
}
if(!fake_file_cmp(get_put_info->fake_file, buffer, offset, length))
{
monitor.rc = GLOBUS_FALSE;
verbose_printf(1, "file compare failed\n");
signal_exit();
signal_exit();
return;
}
if(eof)
{
verbose_printf(2, "read eof hit\n");
signal_exit();
globus_free(buffer);
}
else
{
verbose_printf(2, "register next read\n");
get_put_info = (get_put_info_t *)callback_arg;
result = globus_ftp_control_data_read(
handle,
buffer,
CHUNK_SIZE,
read_data_callback,
(void *) get_put_info);
if(result != GLOBUS_SUCCESS)
{
verbose_printf(1, "intial read register failed\n");
monitor.rc = GLOBUS_FALSE;
signal_exit();
return;
}
}
}
globus_ftp_control-9.10/test/PaxHeaders.24857/outstanding_io_test.c 0000644 0000000 0000000 00000000132 14243161125 023564 x ustar 00 0000000 0000000 30 mtime=1653400149.413969564
30 atime=1653401814.479285767
30 ctime=1653404005.270899334
globus_ftp_control-9.10/test/outstanding_io_test.c 0000664 0001750 0001750 00000044442 14243161125 023726 0 ustar 00johndoe johndoe 0000000 0000000 /*
* Copyright 1999-2006 University of Chicago
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "globus_ftp_control_test.h"
#define NAME "globus_ftp_control_test_file_name"
#define DIRECTION_GET 0
#define DIRECTION_PUT 1
#define CHUNK_SIZE 256
#define CHUNK_COUNT 40
#define OPERATIONS_REGISTERED 4
globus_bool_t global_eof;
typedef struct get_put_info_s
{
int direction;
int buffer_size;
globus_byte_t * buffer;
globus_bool_t result;
globus_bool_t done;
globus_ftp_control_fake_file_t * fake_file;
} get_put_info_t;
static void
outstanding_io_response_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_ftp_control_response_t * ftp_response);
static void
write_data_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_byte_t * buffer,
globus_size_t length,
globus_off_t offset,
globus_bool_t eof);
static void
read_data_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_byte_t * buffer,
globus_size_t length,
globus_off_t offset,
globus_bool_t eof);
static void
signal_exit();
static globus_ftp_control_test_monitor_t monitor;
static int global_bs_i = 0;
/*
* this is called with a connected handle
*/
globus_bool_t
outstanding_io_test(
globus_ftp_control_handle_t * handle)
{
globus_result_t result;
get_put_info_t get_put_info;
globus_ftp_control_fake_file_t fake_file;
int ctr;
globus_mutex_init(&monitor.mutex, GLOBUS_NULL);
globus_cond_init(&monitor.cond, GLOBUS_NULL);
/* once in default, once in image */
for(ctr = 0; ctr < 1; ctr++)
{
global_eof = GLOBUS_FALSE;
/* send pasv */
verbose_printf(2, "sendind pasv command\n");
monitor.done = GLOBUS_FALSE;
result = globus_ftp_control_send_command(
handle,
"PASV\r\n",
outstanding_io_response_callback,
GLOBUS_NULL);
if(result != GLOBUS_SUCCESS)
{
verbose_printf(1, "send_command PASV failed\n");
return GLOBUS_FALSE;
}
/* wait to get pasv back */
globus_mutex_lock(&monitor.mutex);
{
while(!monitor.done)
{
globus_cond_wait(&monitor.cond, &monitor.mutex);
}
}
globus_mutex_unlock(&monitor.mutex);
if(!monitor.rc)
{
verbose_printf(1, "pasv command failed\n");
return GLOBUS_FALSE;
}
/* start writting */
verbose_printf(2, "sendind stor command\n");
get_put_info.direction = DIRECTION_PUT;
get_put_info.done = GLOBUS_FALSE;
monitor.rc = GLOBUS_TRUE;
fake_file_init(&fake_file, CHUNK_SIZE * CHUNK_COUNT + 12, CHUNK_SIZE);
get_put_info.fake_file = &fake_file;
monitor.done = GLOBUS_FALSE;
monitor.count = 0;
result = globus_ftp_control_send_command(
handle,
"STOR %s\r\n",
outstanding_io_response_callback,
&get_put_info,
NAME);
if(result != GLOBUS_SUCCESS)
{
verbose_printf(1, "send_command PASV 2failed\n");
return GLOBUS_FALSE;
}
result = globus_ftp_control_data_connect_write(
handle, GLOBUS_NULL, GLOBUS_NULL);
if(result != GLOBUS_SUCCESS)
{
verbose_printf(1, "connect_write failed\n");
return GLOBUS_FALSE;
}
/* wait to get put back */
globus_mutex_lock(&monitor.mutex);
{
while(monitor.count < 2)
{
globus_cond_wait(&monitor.cond, &monitor.mutex);
}
}
globus_mutex_unlock(&monitor.mutex);
if(!monitor.rc)
{
verbose_printf(1, "STOR failed\n");
return GLOBUS_FALSE;
}
verbose_printf(2, "data has been sent\n");
/* new pasv */
verbose_printf(2, "sendind new pasv command\n");
monitor.done = GLOBUS_FALSE;
monitor.rc = GLOBUS_TRUE;
result = globus_ftp_control_send_command(
handle,
"PASV\r\n",
outstanding_io_response_callback,
GLOBUS_NULL);
if(result != GLOBUS_SUCCESS)
{
verbose_printf(1, "send_command PASV failed\n");
return GLOBUS_FALSE;
}
/* wait to get pasv back */
globus_mutex_lock(&monitor.mutex);
{
while(!monitor.done)
{
globus_cond_wait(&monitor.cond, &monitor.mutex);
}
}
globus_mutex_unlock(&monitor.mutex);
if(!monitor.rc)
{
verbose_printf(1, "PASV failed\n");
return GLOBUS_FALSE;
}
/* start reading */
fake_file_seek(get_put_info.fake_file, 0);
verbose_printf(2, "sending retr command\n");
get_put_info.direction = DIRECTION_GET;
get_put_info.done = GLOBUS_FALSE;
monitor.rc = GLOBUS_TRUE;
get_put_info.fake_file = &fake_file;
monitor.done = GLOBUS_FALSE;
monitor.count = 0;
global_eof = GLOBUS_FALSE;
result = globus_ftp_control_send_command(
handle,
"RETR %s\r\n",
outstanding_io_response_callback,
&get_put_info,
NAME);
if(result != GLOBUS_SUCCESS)
{
verbose_printf(1, "send_command PASV failed\n");
return GLOBUS_FALSE;
}
result = globus_ftp_control_data_connect_read(
handle, GLOBUS_NULL, GLOBUS_NULL);
if(result != GLOBUS_SUCCESS)
{
verbose_printf(1, "connect_write failed\n");
return GLOBUS_FALSE;
}
/* wait to get put back */
globus_mutex_lock(&monitor.mutex);
{
while(monitor.count < 2)
{
globus_cond_wait(&monitor.cond, &monitor.mutex);
}
}
globus_mutex_unlock(&monitor.mutex);
if(!monitor.rc)
{
verbose_printf(1, "RETR failed\n");
return GLOBUS_FALSE;
}
verbose_printf(2, "data has been received\n");
/* delete existing file */
verbose_printf(2, "sending dele command\n");
monitor.done = GLOBUS_FALSE;
monitor.rc = GLOBUS_TRUE;
result = globus_ftp_control_send_command(
handle,
"DELE %s\r\n",
outstanding_io_response_callback,
GLOBUS_NULL,
NAME);
if(result != GLOBUS_SUCCESS)
{
verbose_printf(1, "send_command DELE failed\n");
return GLOBUS_FALSE;
}
/* wait to get pasv back */
globus_mutex_lock(&monitor.mutex);
{
while(!monitor.done)
{
globus_cond_wait(&monitor.cond, &monitor.mutex);
}
}
globus_mutex_unlock(&monitor.mutex);
if(!monitor.rc)
{
verbose_printf(1, "DELE failed\n");
return GLOBUS_FALSE;
}
/* send type */
if(ctr == 0)
{
verbose_printf(2, "sending type command\n");
monitor.done = GLOBUS_FALSE;
monitor.count = 0;
monitor.rc = GLOBUS_TRUE;
result = globus_ftp_control_send_command(
handle,
"TYPE I\r\n",
outstanding_io_response_callback,
GLOBUS_NULL);
if(result != GLOBUS_SUCCESS)
{
verbose_printf(1, "send_command TYPE failed\n");
return GLOBUS_FALSE;
}
/* wait to get pasv back */
globus_mutex_lock(&monitor.mutex);
{
while(!monitor.done)
{
globus_cond_wait(&monitor.cond, &monitor.mutex);
}
}
globus_mutex_unlock(&monitor.mutex);
if(!monitor.rc)
{
verbose_printf(1, "TYPE failed\n");
return GLOBUS_FALSE;
}
}
fake_file_destroy(&fake_file);
}
return GLOBUS_TRUE;
}
void
outstanding_io_response_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_ftp_control_response_t * ftp_response)
{
get_put_info_t * get_put_info;
globus_result_t result;
globus_ftp_control_host_port_t addr;
int ctr;
globus_off_t offset;
if(error != GLOBUS_NULL)
{
verbose_printf(1, "outstanding_io_response_callback() got error\n");
monitor.rc = GLOBUS_FALSE;
signal_exit();
return;
}
if(ftp_response->code == 227)
{
pasv_to_host_port((char *)ftp_response->response_buffer, &addr);
result = globus_ftp_control_local_port(handle, &addr);
if(result != GLOBUS_SUCCESS)
{
monitor.rc = GLOBUS_FALSE;
}
else
{
monitor.rc = GLOBUS_TRUE;
}
signal_exit();
return;
}
else if(ftp_response->code == 226)
{
get_put_info = (get_put_info_t *)callback_arg;
if(get_put_info->direction == DIRECTION_PUT)
{
monitor.rc = GLOBUS_TRUE;
}
signal_exit();
}
else if(ftp_response->code == 150)
{
globus_byte_t * buf;
int buf_size;
get_put_info = (get_put_info_t *)callback_arg;
if(get_put_info->direction == DIRECTION_PUT)
{
offset = 0;
for(ctr = 0;
ctr < OPERATIONS_REGISTERED &&
!fake_file_is_eof(get_put_info->fake_file);
ctr++)
{
buf = fake_file_get_chunk(get_put_info->fake_file, &buf_size);
global_bs_i++;
result = globus_ftp_control_data_write(
handle,
buf,
buf_size,
offset,
fake_file_is_eof(get_put_info->fake_file),
write_data_callback,
(void *) get_put_info);
if(result != GLOBUS_SUCCESS)
{
verbose_printf(1, "write register %d failed\n", ctr);
monitor.rc = GLOBUS_FALSE;
signal_exit();
return;
}
offset += buf_size;
}
}
else if(get_put_info->direction == DIRECTION_GET)
{
for(ctr = 0;
ctr < OPERATIONS_REGISTERED;
ctr++)
{
buf = globus_malloc(CHUNK_SIZE);
result = globus_ftp_control_data_read(
handle,
buf,
CHUNK_SIZE,
read_data_callback,
(void *) get_put_info);
if(result != GLOBUS_SUCCESS)
{
verbose_printf(1, "intial read register failed\n");
monitor.rc = GLOBUS_FALSE;
signal_exit();
return;
}
}
}
}
else if(ftp_response->code == 200)
{
result = globus_ftp_control_local_type(
handle,
GLOBUS_FTP_CONTROL_TYPE_IMAGE,
0);
if(result == GLOBUS_SUCCESS)
{
monitor.rc = GLOBUS_TRUE;
}
else
{
verbose_printf(1, "local_type failed\n");
monitor.rc = GLOBUS_FALSE;
}
signal_exit();
}
else if(ftp_response->code == 250)
{
verbose_printf(2, "delete succeded\n");
signal_exit();
}
}
void
signal_exit()
{
verbose_printf(2, "signal_exit() : start\n");
globus_mutex_lock(&monitor.mutex);
{
monitor.done = GLOBUS_TRUE;
monitor.count++;
globus_cond_signal(&monitor.cond);
}
globus_mutex_unlock(&monitor.mutex);
}
void
write_data_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_byte_t * buffer,
globus_size_t length,
globus_off_t offset,
globus_bool_t eof)
{
get_put_info_t * get_put_info;
globus_byte_t * buf;
int buf_size;
globus_result_t result;
static int cb_count = 0;
int ctr;
verbose_printf(2, "write_data_callback() : start\n");
cb_count++;
get_put_info = (get_put_info_t *)callback_arg;
if(error != GLOBUS_NULL)
{
verbose_printf(1, "error received in write callback\n");
monitor.rc = GLOBUS_FALSE;
return;
}
if(!eof && !fake_file_is_eof(get_put_info->fake_file))
{
for(ctr = 0;
ctr < OPERATIONS_REGISTERED &&
!fake_file_is_eof(get_put_info->fake_file);
ctr++)
{
global_bs_i++;
buf = fake_file_get_chunk(get_put_info->fake_file, &buf_size);
result = globus_ftp_control_data_write(
handle,
buf,
buf_size,
offset + length,
fake_file_is_eof(get_put_info->fake_file),
write_data_callback,
(void *) get_put_info);
if(result != GLOBUS_SUCCESS)
{
monitor.rc = GLOBUS_FALSE;
signal_exit();
signal_exit();
return;
}
}
}
else if(eof)
{
verbose_printf(2, "registered %d callbacks\n",
global_bs_i);
verbose_printf(2, "sent all %d bytes and received %d callbacks\n",
offset + length, cb_count);
if(!global_eof)
{
signal_exit();
global_eof = GLOBUS_FALSE;
}
}
}
void
read_data_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_byte_t * buffer,
globus_size_t length,
globus_off_t offset,
globus_bool_t eof)
{
get_put_info_t * get_put_info;
globus_result_t result;
get_put_info = (get_put_info_t *)callback_arg;
verbose_printf(2, "read_data_callback() : start\n");
if(error != GLOBUS_NULL)
{
verbose_printf(1, "error received in read callback\n");
monitor.rc = GLOBUS_FALSE;
return;
}
if(!fake_file_cmp(get_put_info->fake_file, buffer, offset, length))
{
monitor.rc = GLOBUS_FALSE;
verbose_printf(1, "file compare failed\n");
signal_exit();
signal_exit();
return;
}
else
{
verbose_printf(2, "file compare at %d for %d bytes passed\n",
offset, length);
}
if(eof)
{
verbose_printf(2, "read eof hit\n");
if(!global_eof)
{
verbose_printf(2, "same size sent and received %d\n",
offset+length);
monitor.rc = GLOBUS_TRUE;
signal_exit();
}
global_eof = eof;
globus_free(buffer);
}
else
{
verbose_printf(2, "register next read\n");
get_put_info = (get_put_info_t *)callback_arg;
result = globus_ftp_control_data_read(
handle,
buffer,
CHUNK_SIZE,
read_data_callback,
(void *) get_put_info);
if(result != GLOBUS_SUCCESS)
{
verbose_printf(2, "read re-register failed\n");
}
}
}
globus_ftp_control-9.10/test/PaxHeaders.24857/simple_control_test.c 0000644 0000000 0000000 00000000132 14243161125 023567 x ustar 00 0000000 0000000 30 mtime=1653400149.414969554
30 atime=1653401814.510285475
30 ctime=1653404005.271899324
globus_ftp_control-9.10/test/simple_control_test.c 0000664 0001750 0001750 00000005545 14243161125 023732 0 ustar 00johndoe johndoe 0000000 0000000 /*
* Copyright 1999-2006 University of Chicago
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "globus_ftp_control_test.h"
#define TEST_ITERATIONS 8
void
simple_control_response_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_ftp_control_response_t * ftp_response);
void
block_response_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_ftp_control_response_t * ftp_response);
static globus_ftp_control_test_monitor_t monitor;
globus_bool_t
simple_control_test(
globus_ftp_control_handle_t * handle)
{
int ctr;
globus_result_t result;
globus_mutex_init(&monitor.mutex, GLOBUS_NULL);
globus_cond_init(&monitor.cond, GLOBUS_NULL);
monitor.done = GLOBUS_FALSE;
monitor.rc = GLOBUS_FALSE;
for(ctr = 0; ctr < TEST_ITERATIONS; ctr++)
{
/* try to send a command and wait for a response */
monitor.done = GLOBUS_FALSE;
result = globus_ftp_control_send_command(
handle,
"PWD\r\n",
simple_control_response_callback,
GLOBUS_NULL);
if(result != GLOBUS_SUCCESS)
{
return GLOBUS_FALSE;
}
globus_mutex_lock(&monitor.mutex);
{
while(!monitor.done)
{
globus_cond_wait(&monitor.cond, &monitor.mutex);
}
}
globus_mutex_unlock(&monitor.mutex);
}
return monitor.rc;
}
void
simple_control_response_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_ftp_control_response_t * ftp_response)
{
if(ftp_response->code == 257)
{
globus_mutex_lock(&monitor.mutex);
{
monitor.done = GLOBUS_TRUE;
monitor.rc = GLOBUS_TRUE;
globus_cond_signal(&monitor.cond);
}
globus_mutex_unlock(&monitor.mutex);
}
}
globus_ftp_control-9.10/test/PaxHeaders.24857/simple_data_test.c 0000644 0000000 0000000 00000000131 14243161125 023017 x ustar 00 0000000 0000000 30 mtime=1653400149.414969554
29 atime=1653401814.51928539
30 ctime=1653404005.273899305
globus_ftp_control-9.10/test/simple_data_test.c 0000664 0001750 0001750 00000040560 14243161125 023157 0 ustar 00johndoe johndoe 0000000 0000000 /*
* Copyright 1999-2006 University of Chicago
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "globus_ftp_control_test.h"
#define TEST_ITERATIONS 8
#define NAME "globus_ftp_control_test_file_name"
#define DIRECTION_GET 0
#define DIRECTION_PUT 1
#define CHUNK_SIZE 256
#define CHUNK_COUNT 10
typedef struct get_put_info_s
{
int direction;
int buffer_size;
globus_byte_t * buffer;
globus_bool_t result;
globus_ftp_control_fake_file_t * fake_file;
} get_put_info_t;
static void
simple_data_response_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_ftp_control_response_t * ftp_response);
static void
write_data_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_byte_t * buffer,
globus_size_t length,
globus_off_t offset,
globus_bool_t eof);
static void
read_data_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_byte_t * buffer,
globus_size_t length,
globus_off_t offset,
globus_bool_t eof);
static void
signal_exit();
static globus_ftp_control_test_monitor_t monitor;
/*
* this is called with a connected handle
*/
globus_bool_t
simple_data_test(
globus_ftp_control_handle_t * handle)
{
globus_result_t result;
get_put_info_t get_put_info;
globus_ftp_control_fake_file_t fake_file;
int ctr;
globus_mutex_init(&monitor.mutex, GLOBUS_NULL);
globus_cond_init(&monitor.cond, GLOBUS_NULL);
/* once in default, once in image */
for(ctr = 0; ctr < 2; ctr++)
{
/* send pasv */
verbose_printf(2, "sendind pasv command\n");
monitor.done = GLOBUS_FALSE;
result = globus_ftp_control_send_command(
handle,
"PASV\r\n",
simple_data_response_callback,
GLOBUS_NULL);
if(result != GLOBUS_SUCCESS)
{
verbose_printf(1, "send_command PASV failed\n");
return GLOBUS_FALSE;
}
/* wait to get pasv back */
globus_mutex_lock(&monitor.mutex);
{
while(!monitor.done)
{
globus_cond_wait(&monitor.cond, &monitor.mutex);
}
}
globus_mutex_unlock(&monitor.mutex);
if(!monitor.rc)
{
verbose_printf(1, "pasv command failed\n");
return GLOBUS_FALSE;
}
/* start writting */
verbose_printf(2, "sendind stor command\n");
get_put_info.direction = DIRECTION_PUT;
monitor.rc = GLOBUS_TRUE;
fake_file_init(&fake_file, CHUNK_SIZE * CHUNK_COUNT + 12, CHUNK_SIZE);
get_put_info.fake_file = &fake_file;
monitor.done = GLOBUS_FALSE;
monitor.count = 0;
result = globus_ftp_control_send_command(
handle,
"STOR %s\r\n",
simple_data_response_callback,
&get_put_info,
NAME);
if(result != GLOBUS_SUCCESS)
{
verbose_printf(1, "send_command PASV failed\n");
return GLOBUS_FALSE;
}
result = globus_ftp_control_data_connect_write(
handle, GLOBUS_NULL, GLOBUS_NULL);
if(result != GLOBUS_SUCCESS)
{
verbose_printf(1, "connect_write failed\n");
return GLOBUS_FALSE;
}
/* wait to get put back */
globus_mutex_lock(&monitor.mutex);
{
while(monitor.count < 2)
{
globus_cond_wait(&monitor.cond, &monitor.mutex);
}
}
globus_mutex_unlock(&monitor.mutex);
if(!monitor.rc)
{
verbose_printf(1, "STOR failed\n");
return GLOBUS_FALSE;
}
verbose_printf(2, "data has been sent\n");
/* new pasv */
verbose_printf(2, "sendind new pasv command\n");
monitor.done = GLOBUS_FALSE;
monitor.rc = GLOBUS_TRUE;
result = globus_ftp_control_send_command(
handle,
"PASV\r\n",
simple_data_response_callback,
GLOBUS_NULL);
if(result != GLOBUS_SUCCESS)
{
verbose_printf(1, "send_command PASV failed\n");
return GLOBUS_FALSE;
}
/* wait to get pasv back */
globus_mutex_lock(&monitor.mutex);
{
while(!monitor.done)
{
globus_cond_wait(&monitor.cond, &monitor.mutex);
}
}
globus_mutex_unlock(&monitor.mutex);
if(!monitor.rc)
{
verbose_printf(1, "PASV failed\n");
return GLOBUS_FALSE;
}
/* start reading */
fake_file_seek(get_put_info.fake_file, 0);
verbose_printf(2, "sending retr command\n");
get_put_info.direction = DIRECTION_GET;
monitor.rc = GLOBUS_TRUE;
get_put_info.fake_file = &fake_file;
monitor.done = GLOBUS_FALSE;
monitor.count = 0;
result = globus_ftp_control_send_command(
handle,
"RETR %s\r\n",
simple_data_response_callback,
&get_put_info,
NAME);
if(result != GLOBUS_SUCCESS)
{
verbose_printf(1, "send_command PASV failed\n");
return GLOBUS_FALSE;
}
result = globus_ftp_control_data_connect_read(
handle, GLOBUS_NULL, GLOBUS_NULL);
if(result != GLOBUS_SUCCESS)
{
verbose_printf(1, "connect_read failed\n");
return GLOBUS_FALSE;
}
/* wait to get put back */
globus_mutex_lock(&monitor.mutex);
{
while(monitor.count < 2)
{
globus_cond_wait(&monitor.cond, &monitor.mutex);
}
}
globus_mutex_unlock(&monitor.mutex);
if(!monitor.rc)
{
verbose_printf(1, "RETR failed\n");
return GLOBUS_FALSE;
}
verbose_printf(2, "data has been received\n");
/* delete existing file */
verbose_printf(2, "sending dele command\n");
monitor.done = GLOBUS_FALSE;
monitor.rc = GLOBUS_TRUE;
result = globus_ftp_control_send_command(
handle,
"DELE %s\r\n",
simple_data_response_callback,
GLOBUS_NULL,
NAME);
if(result != GLOBUS_SUCCESS)
{
verbose_printf(1, "send_command DELE failed\n");
return GLOBUS_FALSE;
}
/* wait to get pasv back */
globus_mutex_lock(&monitor.mutex);
{
while(!monitor.done)
{
globus_cond_wait(&monitor.cond, &monitor.mutex);
}
}
globus_mutex_unlock(&monitor.mutex);
if(!monitor.rc)
{
verbose_printf(1, "DELE failed\n");
return GLOBUS_FALSE;
}
fake_file_destroy(&fake_file);
/* send type */
if(ctr == 0)
{
verbose_printf(2, "sending type command\n");
monitor.done = GLOBUS_FALSE;
monitor.count = 0;
monitor.rc = GLOBUS_TRUE;
result = globus_ftp_control_send_command(
handle,
"TYPE I\r\n",
simple_data_response_callback,
GLOBUS_NULL);
if(result != GLOBUS_SUCCESS)
{
verbose_printf(1, "send_command TYPE failed\n");
return GLOBUS_FALSE;
}
/* wait to get pasv back */
globus_mutex_lock(&monitor.mutex);
{
while(!monitor.done)
{
globus_cond_wait(&monitor.cond, &monitor.mutex);
}
}
globus_mutex_unlock(&monitor.mutex);
if(!monitor.rc)
{
verbose_printf(1, "TYPE failed\n");
return GLOBUS_FALSE;
}
}
}
return GLOBUS_TRUE;
}
void
simple_data_response_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_ftp_control_response_t * ftp_response)
{
get_put_info_t * get_put_info;
globus_result_t result;
globus_ftp_control_host_port_t addr;
if(error != GLOBUS_NULL)
{
monitor.rc = GLOBUS_FALSE;
signal_exit();
return;
}
if(ftp_response->code == 227)
{
pasv_to_host_port((char *)ftp_response->response_buffer, &addr);
result = globus_ftp_control_local_port(handle, &addr);
if(result != GLOBUS_SUCCESS)
{
monitor.rc = GLOBUS_FALSE;
}
else
{
monitor.rc = GLOBUS_TRUE;
}
signal_exit();
return;
}
else if(ftp_response->code == 226)
{
get_put_info = (get_put_info_t *)callback_arg;
if(get_put_info->direction == DIRECTION_PUT)
{
monitor.rc = GLOBUS_TRUE;
}
signal_exit();
}
else if(ftp_response->code == 150)
{
globus_byte_t * buf;
int buf_size;
get_put_info = (get_put_info_t *)callback_arg;
if(get_put_info->direction == DIRECTION_PUT)
{
buf = fake_file_get_chunk(get_put_info->fake_file, &buf_size);
result = globus_ftp_control_data_write(
handle,
buf,
buf_size,
0,
fake_file_is_eof(get_put_info->fake_file),
write_data_callback,
(void *) get_put_info);
if(result != GLOBUS_SUCCESS)
{
verbose_printf(1, "intial write register failed\n");
monitor.rc = GLOBUS_FALSE;
signal_exit();
return;
}
}
else if(get_put_info->direction == DIRECTION_GET)
{
buf = globus_malloc(CHUNK_SIZE);
result = globus_ftp_control_data_read(
handle,
buf,
CHUNK_SIZE,
read_data_callback,
(void *) get_put_info);
if(result != GLOBUS_SUCCESS)
{
verbose_printf(1, "intial read register failed\n");
monitor.rc = GLOBUS_FALSE;
signal_exit();
return;
}
}
}
else if(ftp_response->code == 200)
{
result = globus_ftp_control_local_type(
handle,
GLOBUS_FTP_CONTROL_TYPE_IMAGE,
0);
if(result == GLOBUS_SUCCESS)
{
monitor.rc = GLOBUS_TRUE;
}
else
{
verbose_printf(1, "local_type failed\n");
monitor.rc = GLOBUS_FALSE;
}
signal_exit();
}
else if(ftp_response->code == 250)
{
verbose_printf(2, "delete succeded\n");
signal_exit();
}
else if(ftp_response->code >= 500)
{
verbose_printf(1, "error %s\n", ftp_response->response_buffer);
signal_exit();
}
else
{
verbose_printf(1, "error %d %s\n", ftp_response->code, ftp_response->response_buffer);
signal_exit();
}
}
void
signal_exit()
{
verbose_printf(2, "signal_exit() : start\n");
globus_mutex_lock(&monitor.mutex);
{
monitor.done = GLOBUS_TRUE;
monitor.count++;
globus_cond_signal(&monitor.cond);
}
globus_mutex_unlock(&monitor.mutex);
}
void
write_data_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_byte_t * buffer,
globus_size_t length,
globus_off_t offset,
globus_bool_t eof)
{
get_put_info_t * get_put_info;
globus_byte_t * buf;
int buf_size;
globus_result_t result;
get_put_info = (get_put_info_t *)callback_arg;
if(error != GLOBUS_NULL)
{
monitor.rc = GLOBUS_FALSE;
signal_exit();
signal_exit();
return;
}
if(!eof)
{
buf = fake_file_get_chunk(get_put_info->fake_file, &buf_size);
result = globus_ftp_control_data_write(
handle,
buf,
buf_size,
offset + length,
fake_file_is_eof(get_put_info->fake_file),
write_data_callback,
(void *) get_put_info);
if(result != GLOBUS_SUCCESS)
{
monitor.rc = GLOBUS_FALSE;
signal_exit();
signal_exit();
return;
}
}
else
{
signal_exit();
}
}
void
read_data_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_byte_t * buffer,
globus_size_t length,
globus_off_t offset,
globus_bool_t eof)
{
get_put_info_t * get_put_info;
globus_result_t result;
get_put_info = (get_put_info_t *)callback_arg;
if(error != GLOBUS_NULL)
{
monitor.rc = GLOBUS_FALSE;
signal_exit();
signal_exit();
return;
}
if(!fake_file_cmp(get_put_info->fake_file, buffer, offset, length))
{
monitor.rc = GLOBUS_FALSE;
verbose_printf(1, "file compare failed\n");
signal_exit();
signal_exit();
return;
}
if(eof)
{
verbose_printf(2, "read eof hit\n");
signal_exit();
globus_free(buffer);
}
else
{
verbose_printf(2, "register next read\n");
get_put_info = (get_put_info_t *)callback_arg;
result = globus_ftp_control_data_read(
handle,
buffer,
CHUNK_SIZE,
read_data_callback,
(void *) get_put_info);
if(result != GLOBUS_SUCCESS)
{
verbose_printf(1, "intial read register failed\n");
monitor.rc = GLOBUS_FALSE;
signal_exit();
return;
}
}
}
globus_ftp_control-9.10/test/PaxHeaders.24857/simple_dir_test.c 0000644 0000000 0000000 00000000132 14243161125 022665 x ustar 00 0000000 0000000 30 mtime=1653400149.414969554
30 atime=1653401814.533285259
30 ctime=1653404005.275899286
globus_ftp_control-9.10/test/simple_dir_test.c 0000664 0001750 0001750 00000017302 14243161125 023022 0 ustar 00johndoe johndoe 0000000 0000000 /*
* Copyright 1999-2006 University of Chicago
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "globus_ftp_control_test.h"
#include "globus_libc.h"
#ifndef _WIN32
#include
#include
#include
#endif
#define TEST_ITERATIONS 8
#define BUFFER_SIZE 2048
void
simple_dir_response_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_ftp_control_response_t * ftp_response);
void
simple_dir_command_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_ftp_control_response_t * ftp_response);
void
list_read_data_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_byte_t * buffer,
globus_size_t length,
globus_off_t offset,
globus_bool_t eof);
void
signal_exit();
static globus_ftp_control_test_monitor_t monitor;
static globus_ftp_control_test_monitor_t data_monitor;
typedef struct get_put_info_s
{
int buffer_size;
globus_byte_t * buffer;
} get_put_info_t;
globus_bool_t
simple_dir_test(
globus_ftp_control_handle_t * handle)
{
int ctr;
int hi;
int low;
globus_result_t result;
globus_ftp_control_host_port_t addr;
char portmsg[256];
globus_mutex_init(&monitor.mutex, GLOBUS_NULL);
globus_cond_init(&monitor.cond, GLOBUS_NULL);
monitor.done = GLOBUS_FALSE;
globus_mutex_init(&data_monitor.mutex, GLOBUS_NULL);
globus_cond_init(&data_monitor.cond, GLOBUS_NULL);
data_monitor.done = GLOBUS_FALSE;
for(ctr = 0; ctr < TEST_ITERATIONS; ctr++)
{
monitor.done = GLOBUS_FALSE;
monitor.rc = GLOBUS_TRUE;
data_monitor.done = GLOBUS_FALSE;
monitor.count = 0;
globus_ftp_control_host_port_init(&addr, "localhost", 0);
result = globus_ftp_control_local_pasv(handle, &addr);
if (result != GLOBUS_SUCCESS)
{
verbose_printf(1, "globus_ftp_control_host_port_init failed\n");
return GLOBUS_FALSE;
}
hi = addr.port / 256;
low = addr.port - (hi * 256);
sprintf(portmsg, "PORT %d,%d,%d,%d,%d,%d\r\n",
addr.host[0],
addr.host[1],
addr.host[2],
addr.host[3],
hi,
low);
verbose_printf(2, "@@@%s\n", portmsg);
result = globus_ftp_control_send_command(
handle,
portmsg,
simple_dir_response_callback,
GLOBUS_NULL);
if(result != GLOBUS_SUCCESS)
{
verbose_printf(1, "send_command PORT failed\n");
return GLOBUS_FALSE;
}
globus_mutex_lock(&monitor.mutex);
{
while(!monitor.done)
{
globus_cond_wait(&monitor.cond, &monitor.mutex);
}
}
globus_mutex_unlock(&monitor.mutex);
if (!monitor.rc)
{
return GLOBUS_FALSE;
}
}
return GLOBUS_TRUE;
}
void
signal_exit()
{
verbose_printf(2, "signal_exit() : start\n");
globus_mutex_lock(&monitor.mutex);
{
monitor.done = GLOBUS_TRUE;
monitor.count++;
globus_cond_signal(&monitor.cond);
}
globus_mutex_unlock(&monitor.mutex);
}
void
simple_dir_response_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_ftp_control_response_t * ftp_response)
{
get_put_info_t * get_put_info;
globus_result_t result;
if (ftp_response->code == 200)
{
verbose_printf(2, "%s\n", ftp_response->response_buffer);
get_put_info = (get_put_info_t *) globus_malloc(sizeof(get_put_info_t));
get_put_info->buffer_size = BUFFER_SIZE;
get_put_info->buffer = globus_malloc(BUFFER_SIZE);
result = globus_ftp_control_send_command(
handle,
"LIST\r\n",
simple_dir_response_callback,
(void *)get_put_info);
if (result != GLOBUS_SUCCESS)
{
verbose_printf(1, "LIST failed\n");
monitor.rc = GLOBUS_FALSE;
signal_exit();
}
result = globus_ftp_control_data_connect_read(
handle, GLOBUS_NULL, GLOBUS_NULL);
if (result != GLOBUS_SUCCESS)
{
verbose_printf(1, "ls failed\n");
monitor.rc = GLOBUS_FALSE;
signal_exit();
}
}
else if (ftp_response->code == 150)
{
verbose_printf(2, "%s\n", ftp_response->response_buffer);
get_put_info = (get_put_info_t *)callback_arg;
data_monitor.done = GLOBUS_FALSE;
globus_ftp_control_data_read(
handle,
get_put_info->buffer,
get_put_info->buffer_size,
list_read_data_callback,
(void *) get_put_info);
}
else if (ftp_response->code == 226)
{
globus_mutex_lock(&data_monitor.mutex);
{
while(!data_monitor.done)
{
globus_cond_wait(&data_monitor.cond, &data_monitor.mutex);
}
}
globus_mutex_unlock(&data_monitor.mutex);
verbose_printf(2, "%s\n", ftp_response->response_buffer);
monitor.rc = GLOBUS_TRUE;
signal_exit();
}
else
{
verbose_printf(1, "Error: %s\n", ftp_response->response_buffer);
monitor.rc = GLOBUS_FALSE;
signal_exit();
}
}
void
list_read_data_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_byte_t * buffer,
globus_size_t length,
globus_off_t offset,
globus_bool_t eof)
{
get_put_info_t * get_put_info;
get_put_info = (get_put_info_t *) callback_arg;
if(error != GLOBUS_NULL)
{
verbose_printf(1, "unable to list files\n");
monitor.rc = GLOBUS_FALSE;
signal_exit();
}
buffer[length] = '\0';
verbose_printf(3, "%s", buffer);
if (!eof)
{
globus_ftp_control_data_read(
handle,
get_put_info->buffer,
get_put_info->buffer_size,
list_read_data_callback,
(void *) get_put_info);
}
else
{
verbose_printf(2, "we have eof\n");
globus_mutex_lock(&data_monitor.mutex);
{
data_monitor.done = GLOBUS_TRUE;
globus_cond_signal(&data_monitor.cond);
}
globus_mutex_unlock(&data_monitor.mutex);
}
}
globus_ftp_control-9.10/test/PaxHeaders.24857/pipe_test.c 0000644 0000000 0000000 00000000132 14243161125 021473 x ustar 00 0000000 0000000 30 mtime=1653400149.413969564
30 atime=1653401814.492285645
30 ctime=1653404005.276899276
globus_ftp_control-9.10/test/pipe_test.c 0000664 0001750 0001750 00000031600 14243161125 021625 0 ustar 00johndoe johndoe 0000000 0000000 /*
* Copyright 1999-2006 University of Chicago
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* This program tests the globus_ftp_control_data library
*/
#include "globus_ftp_control.h"
#include "globus_common.h"
#include
#include "test_common.h"
#include "globus_preload.h"
#define TEST_ITERATIONS 10
void
test_result(
globus_result_t result,
char * msg);
globus_result_t
pipe_test(
int depth);
void
failure_end(
char * msg);
void
command_cb(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_ftp_control_response_t * ftp_response);
typedef struct send_cmd_cb_arg_s
{
ftp_test_monitor_t * monitor;
int cmd_nr;
}
send_cmd_cb_arg_t;
static unsigned short g_bs_port;
static ftp_test_monitor_t g_server_monitor;
static globus_list_t * g_server_handle_list = GLOBUS_NULL;
static globus_bool_t g_test_done = GLOBUS_FALSE;
void
server_stop_callback(
void * callback_arg,
struct globus_ftp_control_server_s * server_handle,
globus_object_t * error)
{
ftp_test_monitor_t * bs_monitor;
bs_monitor = (ftp_test_monitor_t *)callback_arg;
globus_mutex_lock(&bs_monitor->mutex);
{
bs_monitor->done = GLOBUS_TRUE;
globus_cond_signal(&bs_monitor->cond);
}
globus_mutex_unlock(&bs_monitor->mutex);
}
void
bs_connect_callback(
void * callback_arg,
struct globus_ftp_control_handle_s * handle,
globus_object_t * error,
globus_ftp_control_response_t * ftp_response)
{
ftp_test_monitor_t * bs_monitor;
if(error != GLOBUS_NULL)
{
verbose_printf(3, "bs_connect_callback() : %s\n",
globus_object_printable_to_string(error));
globus_assert(GLOBUS_FALSE);
}
bs_monitor = (ftp_test_monitor_t *)callback_arg;
verbose_printf(3, "bs_connect_callback() : start\n");
globus_mutex_lock(&bs_monitor->mutex);
{
bs_monitor->done = GLOBUS_TRUE;
globus_cond_signal(&bs_monitor->cond);
}
globus_mutex_unlock(&bs_monitor->mutex);
}
void
stop_server(
globus_ftp_control_server_t * server)
{
ftp_test_monitor_t bs_monitor;
globus_result_t res;
globus_mutex_lock(&g_server_monitor.mutex);
g_test_done = GLOBUS_TRUE;
globus_mutex_unlock(&g_server_monitor.mutex);
ftp_test_monitor_init(&bs_monitor);
res = globus_ftp_control_server_stop(
server,
server_stop_callback,
(void *)&bs_monitor);
assert(res == GLOBUS_SUCCESS);
globus_mutex_lock(&bs_monitor.mutex);
{
while(!bs_monitor.done)
{
globus_cond_wait(&bs_monitor.cond, &bs_monitor.mutex);
}
}
globus_mutex_unlock(&bs_monitor.mutex);
res = globus_ftp_control_server_handle_destroy(server);
assert(res == GLOBUS_SUCCESS);
}
void
connect_to_bs_server(
globus_ftp_control_handle_t * handle)
{
globus_result_t res;
ftp_test_monitor_t bs_monitor;
ftp_test_monitor_init(&bs_monitor);
verbose_printf(3, "connect_to_bs_server() : Connecting to port %d\n",
g_bs_port);
res = globus_ftp_control_connect(
handle,
"localhost",
g_bs_port,
bs_connect_callback,
(void *)&bs_monitor);
assert(res == GLOBUS_SUCCESS);
globus_mutex_lock(&bs_monitor.mutex);
{
while(!bs_monitor.done)
{
globus_cond_wait(&bs_monitor.cond, &bs_monitor.mutex);
}
}
globus_mutex_unlock(&bs_monitor.mutex);
}
void response_cb(
void * callback_arg,
struct globus_ftp_control_handle_s * handle,
globus_object_t * error)
{
verbose_printf(3, "sent response %s\n", (char *) callback_arg);
globus_libc_free(callback_arg);
return;
}
void
read_command_cb(
void * callback_arg,
struct globus_ftp_control_handle_s * handle,
globus_object_t * error,
union globus_ftp_control_command_u * command)
{
if(error != GLOBUS_NULL)
{
globus_mutex_lock(&g_server_monitor.mutex);
if (!g_test_done)
{
verbose_printf(3, "read_command_cb: Error %s\n",
globus_object_printable_to_string(error));
}
globus_mutex_unlock(&g_server_monitor.mutex);
return;
}
verbose_printf(3, "server got command %s\n",
command->noop.raw_command);
verbose_printf(3, "server sending response %s in read_command_cb\n",
command->noop.raw_command);
globus_ftp_control_send_response(handle,
"222 %s\r\n",
response_cb,
globus_libc_strdup(
command->noop.raw_command),
command->noop.raw_command);
}
void
bullshit_auth_callback(
void * callback_arg,
struct globus_ftp_control_handle_s * handle,
globus_object_t * error)
{
if(error != GLOBUS_NULL)
{
verbose_printf(3, "bullshit_auth_callback: Error %s\n",
globus_object_printable_to_string(error));
}
verbose_printf(3, "server sent accept response\n");
globus_ftp_control_read_commands(handle,
read_command_cb,
callback_arg);
}
void
bullshit_accept_callback(
void * callback_arg,
struct globus_ftp_control_handle_s * handle,
globus_object_t * error)
{
if(error != GLOBUS_NULL)
{
verbose_printf(3, "bullshit_auth_callback: Error %s\n",
globus_object_printable_to_string(error));
}
verbose_printf(3, "server connection accepted\n");
globus_ftp_control_send_response(handle,
"220 Service ready for new user.\r\n",
bullshit_auth_callback,
callback_arg);
}
void
bullshit_server(
void * callback_arg,
struct globus_ftp_control_server_s * server_handle,
globus_object_t * error)
{
globus_ftp_control_handle_t * handle;
if(error != GLOBUS_NULL)
{
globus_mutex_lock(&g_server_monitor.mutex);
if (!g_test_done)
{
verbose_printf(1, "server error\n");
}
globus_mutex_unlock(&g_server_monitor.mutex);
return;
}
handle = (globus_ftp_control_handle_t *)
globus_malloc(sizeof(globus_ftp_control_handle_t));
globus_ftp_control_handle_init(handle);
globus_mutex_lock(&g_server_monitor.mutex);
{
globus_list_insert(&g_server_handle_list, handle);
}
globus_mutex_unlock(&g_server_monitor.mutex);
verbose_printf(3, "server connection request\n");
globus_ftp_control_server_accept(
server_handle,
handle,
bullshit_accept_callback,
&g_server_monitor);
}
void
close_server_connection(
globus_ftp_control_handle_t * handle)
{
ftp_test_monitor_t bs_monitor;
globus_result_t res;
verbose_printf(3, "close_server_connection() : start\n");
bs_monitor.done = GLOBUS_FALSE;
ftp_test_monitor_init(&bs_monitor);
res = globus_ftp_control_force_close(
handle,
bs_connect_callback,
(void *)&bs_monitor);
test_result(res, "force_close");
globus_mutex_lock(&bs_monitor.mutex);
{
while(!bs_monitor.done)
{
globus_cond_wait(&bs_monitor.cond, &bs_monitor.mutex);
}
}
globus_mutex_unlock(&bs_monitor.mutex);
res = globus_ftp_control_handle_destroy(handle);
test_result(res, "handle_destroy");
verbose_printf(3, "close_server_connection() : end\n");
}
int
main(
int argc,
char * argv[])
{
globus_result_t res;
int ctr;
int rc;
globus_ftp_control_server_t server;
LTDL_SET_PRELOADED_SYMBOLS();
printf("1..1\n");
for(ctr = 0; ctr < argc; ctr++)
{
if(strcmp(argv[ctr], "--verbose") == 0)
{
if(ctr + 1 >= argc)
{
verbose_print_level = 1;
}
else
{
verbose_print_level = atoi(argv[ctr+1]);
ctr++;
}
}
}
/*
* activate
*/
rc = globus_module_activate(GLOBUS_FTP_CONTROL_MODULE);
if(rc) res = globus_error_put(GLOBUS_ERROR_NO_INFO);
else res = GLOBUS_SUCCESS;
test_result(res, "globus_module_activate failed");
/* create a bullshit server */
ftp_test_monitor_init(&g_server_monitor);
globus_ftp_control_server_handle_init(&server);
globus_ftp_control_server_listen(
&server,
&g_bs_port,
bullshit_server,
GLOBUS_NULL);
pipe_test(10);
stop_server(&server);
rc = globus_module_deactivate(GLOBUS_FTP_CONTROL_MODULE);
if(rc) res = globus_error_put(GLOBUS_ERROR_NO_INFO);
else res = GLOBUS_SUCCESS;
test_result(res, "deactivate");
printf("ok - pipe test with depth 10\n");
return 0;
}
/*
* test several read using the big buffer test
*/
globus_result_t
pipe_test(
int depth)
{
int ctr;
int i;
globus_result_t res;
globus_ftp_control_handle_t handle;
ftp_test_monitor_t done_monitor;
send_cmd_cb_arg_t * cb_arg;
cb_arg = malloc(sizeof(send_cmd_cb_arg_t)*depth);
ftp_test_monitor_init(&done_monitor);
done_monitor.result = GLOBUS_SUCCESS;
res = globus_ftp_control_handle_init(&handle);
test_result(res, "handle init");
connect_to_bs_server(&handle);
for(ctr = 0; ctr < TEST_ITERATIONS; ctr++)
{
done_monitor.done = GLOBUS_FALSE;
done_monitor.count = 0;
for(i=0;iresponse_buffer,
cb_arg->cmd_nr);
globus_mutex_lock(&cb_arg->monitor->mutex);
{
cb_arg->monitor->count++;
globus_cond_signal(&cb_arg->monitor->cond);
}
globus_mutex_unlock(&cb_arg->monitor->mutex);
return;
}
void
failure_end(
char * msg)
{
printf("not ok - %s", msg);
exit(1);
}
void
test_result(
globus_result_t res,
char * msg)
{
if(res != GLOBUS_SUCCESS)
{
verbose_printf(1, "error:%s\n",
globus_object_printable_to_string(globus_error_get(res)));
failure_end(msg);
}
}
globus_ftp_control-9.10/test/PaxHeaders.24857/test_server.c 0000644 0000000 0000000 00000000132 14243161125 022044 x ustar 00 0000000 0000000 30 mtime=1653400149.414969554
30 atime=1653401814.569284919
30 ctime=1653404005.278899257
globus_ftp_control-9.10/test/test_server.c 0000664 0001750 0001750 00000021510 14243161125 022175 0 ustar 00johndoe johndoe 0000000 0000000 /*
* Copyright 1999-2006 University of Chicago
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "globus_ftp_control.h"
#include
#include "globus_preload.h"
static globus_bool_t g_done;
void
error_msg(
globus_result_t res,
int line)
{
globus_object_t * error;
if(res != GLOBUS_SUCCESS)
{
error = globus_error_get(res);
printf("Error: %s\n", globus_object_printable_to_string(error));
printf("At Line: %d\n", line);
assert(0);
}
}
void
gpftpd_cmd_response_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error)
{
}
void gpftpd_command_callback(
void *callback_arg,
struct globus_ftp_control_handle_s *handle,
globus_object_t *error,
union globus_ftp_control_command_u *command)
{
if(command)
{
switch(command->code)
{
case GLOBUS_FTP_CONTROL_COMMAND_OPTS:
case GLOBUS_FTP_CONTROL_COMMAND_AUTH:
case GLOBUS_FTP_CONTROL_COMMAND_ADAT:
case GLOBUS_FTP_CONTROL_COMMAND_SPAS:
case GLOBUS_FTP_CONTROL_COMMAND_SPOR:
case GLOBUS_FTP_CONTROL_COMMAND_PORT:
case GLOBUS_FTP_CONTROL_COMMAND_PASV:
case GLOBUS_FTP_CONTROL_COMMAND_SITE:
case GLOBUS_FTP_CONTROL_COMMAND_TYPE:
case GLOBUS_FTP_CONTROL_COMMAND_DELE:
case GLOBUS_FTP_CONTROL_COMMAND_FEAT:
case GLOBUS_FTP_CONTROL_COMMAND_ERET:
case GLOBUS_FTP_CONTROL_COMMAND_ESTO:
case GLOBUS_FTP_CONTROL_COMMAND_RMD:
case GLOBUS_FTP_CONTROL_COMMAND_MKD:
case GLOBUS_FTP_CONTROL_COMMAND_PWD:
abort();
case GLOBUS_FTP_CONTROL_COMMAND_CWD:
chdir(command->cwd.string_arg);
globus_ftp_control_send_response(
handle,
"250 Requested file action okay, completed.",
gpftpd_cmd_response_callback,
callback_arg);
break;
case GLOBUS_FTP_CONTROL_COMMAND_CDUP:
abort();
case GLOBUS_FTP_CONTROL_COMMAND_NLST:
case GLOBUS_FTP_CONTROL_COMMAND_HELP:
case GLOBUS_FTP_CONTROL_COMMAND_STAT:
case GLOBUS_FTP_CONTROL_COMMAND_NOOP:
case GLOBUS_FTP_CONTROL_COMMAND_SYST:
case GLOBUS_FTP_CONTROL_COMMAND_STOU:
case GLOBUS_FTP_CONTROL_COMMAND_QUIT:
case GLOBUS_FTP_CONTROL_COMMAND_REIN:
case GLOBUS_FTP_CONTROL_COMMAND_ABOR:
case GLOBUS_FTP_CONTROL_COMMAND_ALLO:
case GLOBUS_FTP_CONTROL_COMMAND_MODE:
case GLOBUS_FTP_CONTROL_COMMAND_STRU:
case GLOBUS_FTP_CONTROL_COMMAND_ACCT:
case GLOBUS_FTP_CONTROL_COMMAND_PASS:
case GLOBUS_FTP_CONTROL_COMMAND_USER:
case GLOBUS_FTP_CONTROL_COMMAND_SMNT:
case GLOBUS_FTP_CONTROL_COMMAND_LIST:
case GLOBUS_FTP_CONTROL_COMMAND_RETR:
case GLOBUS_FTP_CONTROL_COMMAND_REST:
case GLOBUS_FTP_CONTROL_COMMAND_SBUF:
case GLOBUS_FTP_CONTROL_COMMAND_SIZE:
case GLOBUS_FTP_CONTROL_COMMAND_STOR:
case GLOBUS_FTP_CONTROL_COMMAND_APPE:
case GLOBUS_FTP_CONTROL_COMMAND_RNFR:
case GLOBUS_FTP_CONTROL_COMMAND_RNTO:
case GLOBUS_FTP_CONTROL_COMMAND_LANG:
case GLOBUS_FTP_CONTROL_COMMAND_UNKNOWN:
abort();
}
}
}
void
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(
handle,
gpftpd_command_callback,
callback_arg);
}
/*
*
*/
void
gpftpd_auth_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error,
globus_ftp_control_auth_info_t * auth_result)
{
globus_result_t res;
char * username;
globus_bool_t accepted;
if(error)
{
error_msg(globus_error_put(error), __LINE__);
}
accepted = GLOBUS_FALSE;
if(strcmp(auth_result->user, ":globus-mapping:") == 0 &&
globus_gss_assist_gridmap(
auth_result->auth_gssapi_subject, &username) == 0)
{
accepted = GLOBUS_TRUE;
}
else if(strcmp(auth_result->user, "ftp") == 0 ||
strcmp(auth_result->user, "anonymous") == 0)
{
accepted = GLOBUS_TRUE;
username = auth_result->user;
}
if(accepted)
{
res = globus_ftp_control_send_response(
handle,
"230 User %s logged on.\r\n",
gpftpd_ac_response_callback,
callback_arg,
username);
}
else
{
res = globus_ftp_control_send_response(
handle,
"530 No local mapping for Globus ID.\r\n",
gpftpd_ac_response_callback,
callback_arg);
}
error_msg(res, __LINE__);
}
void
gpftpd_response_callback(
void * callback_arg,
globus_ftp_control_handle_t * handle,
globus_object_t * error)
{
globus_result_t res;
globus_ftp_control_auth_requirements_t auth_req;
if(error)
{
error_msg(globus_error_put(error), __LINE__);
}
auth_req = GLOBUS_FTP_CONTROL_AUTH_REQ_GSSAPI |
GLOBUS_FTP_CONTROL_AUTH_REQ_USER |
GLOBUS_FTP_CONTROL_AUTH_REQ_PASS;
res = globus_ftp_control_server_authenticate(
handle,
auth_req,
gpftpd_auth_callback,
callback_arg);
error_msg(res, __LINE__);
}
void
gpftpd_accept_callback(
void * callback_arg,
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(
handle,
"220 Globus GridFTP Test Server\r\n",
gpftpd_response_callback,
callback_arg);
}
void
gpftpd_listen_callback(
void * callback_arg,
globus_ftp_control_server_t * server_handle,
globus_object_t * error)
{
globus_ftp_control_handle_t * new_handle;
globus_result_t res;
if(error)
{
error_msg(globus_error_put(error), __LINE__);
}
new_handle = (globus_ftp_control_handle_t *)
globus_malloc(sizeof(globus_ftp_control_handle_t));
res = globus_ftp_control_handle_init(new_handle);
error_msg(res, __LINE__);
res = globus_ftp_control_server_accept(
server_handle,
new_handle,
gpftpd_accept_callback,
callback_arg);
error_msg(res, __LINE__);
}
int
main(
int argc,
char * argv[])
{
unsigned short port = 0;
int rc;
globus_result_t res;
globus_ftp_control_server_t server_handle;
LTDL_SET_PRELOADED_SYMBOLS();
rc = globus_module_activate(GLOBUS_FTP_CONTROL_MODULE);
if (rc != GLOBUS_SUCCESS)
{
fprintf(stderr, "Error activating GLOBUS_FTP_CONTROL_MODULE: %s\n",
globus_error_print_friendly(globus_error_peek(rc)));
exit(EXIT_FAILURE);
}
res = globus_ftp_control_server_handle_init(&server_handle);
error_msg(res, __LINE__);
res = globus_ftp_control_server_listen(
&server_handle,
&port,
gpftpd_listen_callback,
NULL);
error_msg(res, __LINE__);
printf("%d\n", port);
fflush(stdout);
while(!g_done)
{
globus_poll();
}
return 0;
}
globus_ftp_control-9.10/test/PaxHeaders.24857/get_lingering_close.sh 0000644 0000000 0000000 00000000132 14243161125 023671 x ustar 00 0000000 0000000 30 mtime=1653400149.413969564
30 atime=1653400149.413969564
30 ctime=1653404005.285899191
globus_ftp_control-9.10/test/get_lingering_close.sh 0000775 0001750 0001750 00000000664 14243161125 024034 0 ustar 00johndoe johndoe 0000000 0000000 #! /bin/sh
portfile="$(basename $0).port"
rm -f "${portfile}"
./test_server > "${portfile}" &
serverpid=$!
i=0
while [ ! -s "${portfile}" ]; do
sleep 1;
i=$(($i + 1))
if [ $i -eq 10 ]; then
[ ${serverpid:-0} -gt 0 ] && kill -0 $serverpid && kill $serverpid
exit 1
fi
done
$(basename $0 .sh) --host localhost $(cat ${portfile})
([ ${serverpid:-0} -gt 0 ] && kill -0 $serverpid && kill $serverpid) || true