int main(int argc, char * argv[])
{
    test_case                           tests[] =
    {
        TEST_CASE(unpack_test),
        TEST_CASE(unpack_test_with_extensions),
        TEST_CASE(unpack_null_param_test),
        TEST_CASE(unpack_bad_message_test)
    };
    int                                 i;
    int                                 rc;
    int                                 not_ok = 0;

    printf("1..%d\n", ARRAY_LEN(tests));

    globus_module_activate(GLOBUS_GRAM_PROTOCOL_MODULE);
    for (i = 0; i < ARRAY_LEN(tests); i++)
    {
        rc = tests[i].test_function();

        if (rc != 0)
        {
            not_ok++;
            printf("not ok # %s\n", tests[i].name);
        }
        else
        {
            printf("ok\n");
        }
    }
    globus_module_deactivate(GLOBUS_GRAM_PROTOCOL_MODULE);

    return not_ok;
}
/**
 * Module deactivation
 *
 */
static
int
globus_l_openssl_deactivate(void)
{
    int                                 i;

    OBJ_cleanup();

    ERR_clear_error();

    X509V3_EXT_cleanup();

    if (CRYPTO_get_id_callback() == globus_l_openssl_thread_id)
    {
        CRYPTO_set_id_callback(NULL);
    }
    if (CRYPTO_get_locking_callback() == globus_l_openssl_locking_cb)
    {
        CRYPTO_set_locking_callback(NULL);
    }

    for (i=0; i<CRYPTO_num_locks(); i++)
    {
        globus_mutex_destroy(&(mutex_pool[i]));
    }

    free(mutex_pool);

    globus_module_deactivate(GLOBUS_GSI_OPENSSL_ERROR_MODULE);
    globus_module_deactivate(GLOBUS_COMMON_MODULE);

    return GLOBUS_SUCCESS;
}
static
int
globus_l_seg_stdout_deactivate(void)
{
    globus_mutex_lock(&globus_l_seg_mutex);
    globus_l_seg_shutdown = 1;

    if (globus_l_seg_write_registered)
    {
        while (globus_l_seg_shutdown == 1)
        {
            globus_cond_wait(&globus_l_seg_mutex, &globus_l_seg_cond);
        }
    }
    globus_fifo_destroy(&globus_l_seg_buffers);
    globus_mutex_unlock(&globus_l_seg_mutex);

    globus_xio_close(globus_l_seg_output_handle, NULL);
    globus_xio_close(globus_l_seg_input_handle, NULL);

    globus_mutex_destroy(&globus_l_seg_mutex);
    globus_cond_destroy(&globus_l_seg_cond);

    globus_module_deactivate(GLOBUS_XIO_MODULE);
    globus_module_deactivate(GLOBUS_SCHEDULER_EVENT_GENERATOR_MODULE);
    globus_module_deactivate(GLOBUS_COMMON_MODULE);

    return 0;
}
static
int
globus_l_xio_net_manager_deactivate(void)
{
    GlobusXIOUnRegisterDriver(net_manager);
    globus_module_deactivate(GLOBUS_NET_MANAGER_MODULE);
    globus_module_deactivate(GLOBUS_XIO_MODULE);
    return 0;
}
Example #5
0
/**
 * Module deactivation
 *
 */
static
int
globus_l_gsi_gssapi_deactivate(void)
{
    GLOBUS_I_GSI_GSSAPI_DEBUG_ENTER;

    globus_module_deactivate(GLOBUS_GSI_CALLBACK_MODULE);
    globus_module_deactivate(GLOBUS_GSI_PROXY_MODULE);
    globus_module_deactivate(GLOBUS_OPENSSL_MODULE);
    globus_module_deactivate(GLOBUS_COMMON_MODULE);
    globus_i_gssapi_active = GLOBUS_FALSE;
    GLOBUS_I_GSI_GSSAPI_INTERNAL_DEBUG_EXIT;

    return GLOBUS_SUCCESS;
}
static int
globus_l_xio_telnet_deactivate(void)
{
    GlobusXIOName(globus_l_xio_telnet_deactivate);
    GlobusXIOUnRegisterDriver(telnet);
    return globus_module_deactivate(GLOBUS_XIO_MODULE);
}
Example #7
0
int
eDestroy(int fd)
{

	OM_uint32       maj_stat, min_stat;
	tunnel_ctx_t* tunnel_ctx = getGssContext(fd);
	if( tunnel_ctx == NULL ) {
		return -1;
	}

	maj_stat = gss_delete_sec_context(&min_stat,  &tunnel_ctx->context_hdl, GSS_C_NO_BUFFER);
	destroyGssContext(fd);

#if defined(GSIGSS) &&  defined(GLOBUS_BUG)
	/* work arount globus bug */
	(void) globus_module_deactivate(GLOBUS_GSI_GSSAPI_MODULE);
#endif /* GLOBUS_BUG */


	if( maj_stat != GSS_S_COMPLETE ) {
		gss_print_errors(maj_stat);
		return -1;
	}

	return 0;
}
static
int
globus_l_xio_net_manager_activate(void)
{
    int                                 rc;

    GlobusDebugInit(GLOBUS_XIO_NET_MANAGER, TRACE);

    rc = globus_module_activate(GLOBUS_XIO_MODULE);
    if(rc != GLOBUS_SUCCESS)
    {
        goto activate_xio_fail;
    }
    rc = globus_module_activate(GLOBUS_NET_MANAGER_MODULE);

    if(rc == GLOBUS_SUCCESS)
    {
        GlobusXIORegisterDriver(net_manager);
    }
    else
    {
        globus_module_deactivate(GLOBUS_XIO_MODULE);
    }

activate_xio_fail:
    return rc;
}
int main(int argc, char *argv[])
{
    globus_module_activate(GLOBUS_GRAM_CLIENT_MODULE);
    globus_module_deactivate(GLOBUS_GRAM_CLIENT_MODULE);

    return 0;
}
Example #10
0
static
int
globus_l_xio_null_deactivate(void)
{
    GlobusXIOUnRegisterDriver(null);
    return globus_module_deactivate(GLOBUS_XIO_MODULE);
}
Example #11
0
/**
 * Module deactivation
 * @ingroup globus_callout_activation
 */
static
int
globus_l_callout_deactivate(void)
{
    int                                 result = (int) GLOBUS_SUCCESS;
    static char *                       _function_name_ =
        "globus_l_callout_deactivate";

    GLOBUS_I_CALLOUT_DEBUG_ENTER;

    globus_module_deactivate(GLOBUS_COMMON_MODULE);

    GLOBUS_I_CALLOUT_DEBUG_EXIT;

    if(globus_i_callout_debug_fstream != stderr)
    {
        fclose(globus_i_callout_debug_fstream);
    }

#ifndef BUILD_STATIC_ONLY
    result = lt_dlexit();
#endif

    return result;
}
static
int
globus_l_ftp_control_deactivate(void)
{
    int                             rc;
    
    globus_i_ftp_control_debug_printf(1,
        (stderr, "globus_l_ftp_control_deactivate() entering\n"));
        
    rc = (int)globus_i_ftp_control_data_deactivate();
    if(rc != GLOBUS_SUCCESS)
    {
        goto exit;
    }
    rc = (int)globus_i_ftp_control_client_deactivate();
    if(rc != GLOBUS_SUCCESS)
    {
        goto exit;
    }
    rc = (int)globus_i_ftp_control_server_deactivate();
    if(rc != GLOBUS_SUCCESS)
    {
        goto exit;
    }
    rc = globus_module_deactivate(GLOBUS_IO_MODULE);
    if(rc != GLOBUS_SUCCESS)
    {
        goto exit;
    }
    rc = globus_module_deactivate(GLOBUS_GSI_GSSAPI_MODULE);
    if(rc != GLOBUS_SUCCESS)
    {
        goto exit;
    }
    rc = globus_module_deactivate(GLOBUS_THREAD_MODULE);
    if(rc != GLOBUS_SUCCESS)
    {
        goto exit;
    }
    rc = globus_module_deactivate(GLOBUS_COMMON_MODULE);

exit:    
    globus_i_ftp_control_debug_printf(1,
        (stderr, "globus_l_ftp_control_deactivate() exiting\n"));
    return rc;
}
static int
gfork_l_deactivate()
{
    gfork_l_globals_set = GLOBUS_FALSE;

    globus_module_deactivate(GLOBUS_XIO_MODULE);

    return 0;
}
Example #14
0
 int
 eval_rsl_fini(void)
 {
     if (g_globus_activated)
     {
         globus_module_deactivate(GLOBUS_RSL_MODULE);
     }
     return 0;
 }
/*
 * Function:	main
 *
 * Description:	
 *		
 * Parameters:	
 *
 * Returns:	
 */
int
main(int argc, char **argv)
{
    int					rc;
    
    globus_module_activate(GLOBUS_COMMON_MODULE);
    globus_module_activate(GLOBUS_IO_MODULE);
    

#if 1
    test1();				/* connect, read, write, read */
    test2();				/* connect, read, writev, read */
    test3();				/* failed connect */
#endif
    test4(atoi(argv[1]));		/* connect to secure server*/
    globus_module_deactivate(GLOBUS_IO_MODULE);
    globus_module_deactivate(GLOBUS_COMMON_MODULE);
}
/**
 * Module deactivation
 */
static
int
globus_l_gsi_gss_assist_deactivate(void)
{
    static char *                       _function_name_ =
        "globus_l_gsi_gss_assist_deactivate";
    
    GLOBUS_I_GSI_GSS_ASSIST_DEBUG_ENTER;
    
    globus_mutex_destroy(&globus_i_gsi_gss_assist_mutex);

    globus_module_deactivate(GLOBUS_GSI_GSSAPI_MODULE);
    globus_module_deactivate(GLOBUS_GSI_SYSCONFIG_MODULE);
    globus_module_deactivate(GLOBUS_CALLOUT_MODULE);
    globus_module_deactivate(GLOBUS_COMMON_MODULE);

    GLOBUS_I_GSI_GSS_ASSIST_DEBUG_EXIT;
    return GLOBUS_SUCCESS;
}
void
GSI_SOCKET_destroy(GSI_SOCKET *self)
{
    if (self == NULL)
    {
	return;
    }
    
    if (self->gss_context != GSS_C_NO_CONTEXT)
    {
	gss_buffer_desc output_token_desc  = GSS_C_EMPTY_BUFFER;

	gss_delete_sec_context(&self->minor_status,
			       &self->gss_context,
			       &output_token_desc);
	
	/* XXX Should deal with output_token_desc here */
	gss_release_buffer(&self->minor_status, &output_token_desc);
    }

    if (self->peer_name != NULL)
    {
	free(self->peer_name);
    }
    
    if (self->error_string)
    {
	free(self->error_string);
    }

    if (self->certreq)
    {
        free(self->certreq);
    }

    free(self);

#if 0 /* http://bugzilla.globus.org/bugzilla/show_bug.cgi?id=6909 */
    globus_module_deactivate(GLOBUS_GSI_GSS_ASSIST_MODULE);
    globus_module_deactivate(GLOBUS_GSI_SYSCONFIG_MODULE);
#endif
}
static
int
globus_l_net_manager_python_deactivate(void)
{
    globus_net_manager_unregister(&globus_l_net_manager_python);
    globus_hashtable_destroy_all(
            &globus_l_python_modules,
            globus_l_python_modules_destroy);
    Py_Finalize();
    return globus_module_deactivate(GLOBUS_NET_MANAGER_MODULE);
}
static
int
globus_l_net_manager_null_deactivate(void)
{
    int rc = globus_net_manager_unregister(&globus_l_net_manager_null);
    if (rc == 0)
    {
        rc = globus_module_deactivate(GLOBUS_NET_MANAGER_MODULE);
    }
    return rc;
}
Example #20
0
static int auth_globus_assert(struct link *link, time_t stoptime)
{
	int rc;
	gss_cred_id_t credential = GSS_C_NO_CREDENTIAL;
	gss_ctx_id_t context = GSS_C_NO_CONTEXT;
	OM_uint32 major, minor, flags = 0;
	int token;
	char *reason = NULL;

	globus_module_activate(GLOBUS_GSI_GSS_ASSIST_MODULE);

	if(use_delegated_credential && delegated_credential != GSS_C_NO_CREDENTIAL) {
		debug(D_AUTH, "globus: using delegated credential");
		credential = delegated_credential;
		major = GSS_S_COMPLETE;
	} else {
		debug(D_AUTH, "globus: loading my credentials");
		major = globus_gss_assist_acquire_cred(&minor, GSS_C_INITIATE, &credential);
	}

	if(major == GSS_S_COMPLETE) {
		debug(D_AUTH, "globus: waiting for server to get ready");
		if(auth_barrier(link, "yes\n", stoptime) == 0) {
			debug(D_AUTH, "globus: authenticating with server");
			major = globus_gss_assist_init_sec_context(&minor, credential, &context, "GSI-NO-TARGET", 0, &flags, &token, read_token, link, write_token, link);
			if(major == GSS_S_COMPLETE) {
				debug(D_AUTH, "globus: credentials accepted!");
				gss_delete_sec_context(&minor, &context, GSS_C_NO_BUFFER);
			} else {
				globus_gss_assist_display_status_str(&reason, "", major, minor, token);
				debug(D_AUTH, "globus: credentials rejected: %s", reason ? reason : "unknown reason");
				THROW_QUIET(EACCES);
			}
		} else {
			debug(D_AUTH, "globus: server couldn't load credentials");
			THROW_QUIET(EACCES);
		}
	} else {
		debug(D_AUTH, "globus: couldn't load my credentials; did you grid-proxy-init?");
		auth_barrier(link, "no\n", stoptime);
		THROW_QUIET(EACCES);
	}

	rc = 0;
	goto out;
out:
	if(!use_delegated_credential) {
		gss_release_cred(&major, &credential);
	}
	globus_module_deactivate(GLOBUS_GSI_GSS_ASSIST_MODULE);
	free(reason);
	return RCUNIX(rc);
}
int
main(
    int                                 argc, 
    char **                             argv)
{
    unsigned char                       buffer[LINE_LEN];
    globus_size_t                       nbytes;
    globus_result_t                     res;
    globus_xio_attr_t                   attr;
    char *                              opts = NULL;

    if(argc < 2)
    {
        fprintf(stderr, "usage: %s url\n", argv[0]);
        return -1;
    }
    if(argc > 2)
    {
        opts = argv[2];
    }
    globus_module_activate(GLOBUS_XIO_MODULE);

    globus_xio_attr_init(&attr);
    globus_xio_handle_t             myhandle;

    res = globus_xio_handle_create_from_url(
        &myhandle,
        argv[1],
        attr,
        opts);
    test_res(res, __LINE__);

    res = globus_xio_open(myhandle, argv[1], attr);
    test_res(res, __LINE__);
    while(res == GLOBUS_SUCCESS)
    {
        res = globus_xio_read(myhandle, buffer, LINE_LEN, 1, &nbytes, NULL);
        buffer[nbytes] = '\0';
        printf("%s", buffer);
    }
    if(!globus_xio_error_is_eof(res))
    {
        printf("Error before EOF\n");
        test_res(res, __LINE__);
    }
    globus_xio_close(myhandle, NULL);
    globus_xio_attr_destroy(attr);

    globus_module_deactivate(GLOBUS_XIO_MODULE);

    return 0;
}
static
int
gfork_l_activate()
{
    int                                 rc;
    globus_result_t                     res;

    rc = globus_module_activate(GLOBUS_XIO_MODULE);
    if(rc != 0)
    {
        goto error_activate;
    }

    if(!gfork_l_globals_set)
    {
        GlobusDebugInit(GLOBUS_GFORK,
                        ERROR WARNING TRACE INTERNAL_TRACE INFO STATE INFO_VERBOSE);


        gfork_i_state_init();

        res = globus_xio_stack_init(&gfork_i_file_stack, NULL);
        if(res != GLOBUS_SUCCESS)
        {
            goto error_file_stack;
        }
        res = globus_xio_driver_load("file", &gfork_i_file_driver);
        if(res != GLOBUS_SUCCESS)
        {
            goto error_file_driver;
        }
        res = globus_xio_stack_push_driver(
                  gfork_i_file_stack, gfork_i_file_driver);
        if(res != GLOBUS_SUCCESS)
        {
            goto error_file_push;
        }
        globus_xio_attr_init(&gfork_i_file_attr);

    }
    gfork_l_globals_set = GLOBUS_TRUE;

    return 0;
error_file_push:
    globus_xio_driver_unload(gfork_i_file_driver);
error_file_driver:
    globus_xio_stack_destroy(gfork_i_file_stack);
error_file_stack:
    globus_module_deactivate(GLOBUS_XIO_MODULE);
error_activate:
    return 1;
}
int
globus_i_xio_system_common_deactivate(void)
{
    GlobusXIOName(globus_i_xio_system_common_deactivate);

    GlobusXIOSystemDebugEnter();

    globus_module_deactivate(GLOBUS_XIO_MODULE);

    GlobusXIOSystemDebugExit();
    GlobusDebugDestroy(GLOBUS_XIO_SYSTEM);
    return GLOBUS_SUCCESS;
}
Example #24
0
static int auth_globus_accept(struct link *link, char **subject, time_t stoptime)
{
	gss_cred_id_t credential = GSS_C_NO_CREDENTIAL;
	gss_ctx_id_t context = GSS_C_NO_CONTEXT;
	OM_uint32 major, minor, flags = 0;
	int token;
	int success = 0;

	globus_module_activate(GLOBUS_GSI_GSS_ASSIST_MODULE);

	*subject = 0;

	debug(D_AUTH, "globus: loading my credentials");
	major = globus_gss_assist_acquire_cred(&minor, GSS_C_ACCEPT, &credential);
	if(major == GSS_S_COMPLETE) {

		debug(D_AUTH, "globus: waiting for client to get ready");
		if(auth_barrier(link, "yes\n", stoptime) == 0) {

			delegated_credential = GSS_C_NO_CREDENTIAL;
			debug(D_AUTH, "globus: authenticating client");
			major = globus_gss_assist_accept_sec_context(&minor, &context, credential, subject, &flags, 0, &token, &delegated_credential, read_token, link, write_token, link);
			if(major == GSS_S_COMPLETE) {
				debug(D_AUTH, "globus: accepted client %s", *subject);
				if(delegated_credential != GSS_C_NO_CREDENTIAL) {
					debug(D_AUTH, "globus: client delegated its credentials");
				}
				success = 1;
				gss_delete_sec_context(&minor, &context, GSS_C_NO_BUFFER);
			} else {
				char *reason;
				globus_gss_assist_display_status_str(&reason, "", major, minor, token);
				if(!reason)
					reason = xxstrdup("unknown reason");
				debug(D_AUTH, "globus: couldn't authenticate client: %s", reason);
				if(reason)
					free(reason);
			}
		} else {
			debug(D_AUTH, "globus: client couldn't load credentials");
		}
		gss_release_cred(&major, &credential);
	} else {
		debug(D_AUTH, "globus: couldn't load my credentials: did you run grid-proxy-init?");
		auth_barrier(link, "no\n", stoptime);
	}

	globus_module_deactivate(GLOBUS_GSI_GSS_ASSIST_MODULE);

	return success;
}
static
int
globus_l_net_manager_logging_deactivate(void)
{
    globus_hashtable_destroy_all(
            &globus_l_nm_logging_logfiles,
            globus_l_logging_logfiles_destroy);

    int rc = globus_net_manager_unregister(&globus_l_net_manager_logging);
    if (rc == 0)
    {
        rc = globus_module_deactivate(GLOBUS_NET_MANAGER_MODULE);
    }
    return rc;
}
Example #26
0
static
int
globus_l_usage_stats_deactivate()
{
#ifndef TARGET_ARCH_ARM
    if(globus_l_usage_stats_stack)
    {
        globus_xio_stack_destroy(globus_l_usage_stats_stack);
    }

    return globus_module_deactivate(GLOBUS_XIO_MODULE);
#else
    return 1;
#endif
}
static
int
globus_l_xio_pipe_deactivate(void)
{
    GlobusXIOName(globus_l_xio_pipe_deactivate);
    
    GlobusXIOPipeDebugEnter();
    
    GlobusXIOUnRegisterDriver(pipe);
    globus_module_deactivate(GLOBUS_XIO_SYSTEM_MODULE);
    
    GlobusXIOPipeDebugExit();
    GlobusDebugDestroy(GLOBUS_XIO_PIPE);
    
    return GLOBUS_SUCCESS;
}
Example #28
0
/*
 * globus_module_deactivate_all()
 */
int
globus_module_deactivate_all(void)
{
    /*
     * If module activation hasn't been initialized then return an error
     */
    if (!globus_i_module_initialized)
    {
	return GLOBUS_FAILURE;
    }
    
    globus_l_module_mutex_lock(&globus_l_module_mutex);
    {
	globus_bool_t			 deactivated_one;

	deactivated_one = GLOBUS_TRUE;

	while(deactivated_one)
	{
	    globus_list_t *		module_list;

	    module_list = globus_l_module_list;
	    deactivated_one = GLOBUS_FALSE;

	    while(!globus_list_empty(module_list))
	    {
		globus_l_module_entry_t *module_entry;

		module_entry = globus_list_first(module_list);
		module_list = globus_list_rest(module_list);
	    
		if(globus_list_empty(module_entry->clients) &&
		   module_entry->reference_count > 0)
		{
		    globus_l_module_mutex_unlock(&globus_l_module_mutex);
		    globus_module_deactivate(module_entry->descriptor);
		    globus_l_module_mutex_lock(&globus_l_module_mutex);
		    deactivated_one = GLOBUS_TRUE;
		}
	    }
	}
    }
    globus_l_module_mutex_unlock(&globus_l_module_mutex);

    return GLOBUS_SUCCESS;
}
static
int
globus_l_job_manager_module_deactivate(void)
{
    globus_mutex_lock(&globus_l_job_manager_mutex);
    shutdown_called = GLOBUS_TRUE;

    while (callback_count > 0)
    {
        globus_cond_wait(&globus_l_job_manager_cond, &globus_l_job_manager_mutex);
    }
    globus_mutex_unlock(&globus_l_job_manager_mutex);

    GlobusDebugDestroy(SEG_JOB_MANAGER);

    globus_module_deactivate(GLOBUS_COMMON_MODULE);

    return 0;
}
int
main(int argc, char *argv[])
{
    struct test_case                    tests[] =
    {
        TEST_CASE(null_param_test),
        TEST_CASE(bad_contact_test),
        TEST_CASE(job_status_with_info_test)
    };
    int                                 i;
    int                                 rc;
    int                                 not_ok = 0;

    if (argc != 2)
    {
        fprintf(stderr, "Usage: %s RM-CONTACT\n", argv[0]);
        return 1;
    }
    rm_contact = argv[1];

    printf("1..%d\n", ARRAY_LEN(tests));

    globus_module_activate(GLOBUS_GRAM_CLIENT_MODULE);
    for (i = 0; i < ARRAY_LEN(tests); i++)
    {
        rc = tests[i].test_function();

        if (rc != 0)
        {
            not_ok++;
            printf("not ok # %s\n", tests[i].name);
        }
        else
        {
            printf("ok\n");
        }
    }
    globus_module_deactivate(GLOBUS_GRAM_CLIENT_MODULE);

    return not_ok;
}