Esempio n. 1
0
static NTSTATUS do_smb_load_module(const char *subsystem,
				   const char *module_name, bool is_probe)
{
	void *handle;
	init_module_fn init;
	NTSTATUS status;

	char *full_path = NULL;
	TALLOC_CTX *ctx = talloc_stackframe();

	/* Check for absolute path */

	DEBUG(5, ("%s module '%s'\n", is_probe ? "Probing" : "Loading", module_name));

	if (subsystem && module_name[0] != '/') {
		full_path = talloc_asprintf(ctx,
					    "%s/%s.%s",
					    modules_path(ctx, subsystem),
					    module_name,
					    shlib_ext());
		if (!full_path) {
			TALLOC_FREE(ctx);
			return NT_STATUS_NO_MEMORY;
		}

		DEBUG(5, ("%s module '%s': Trying to load from %s\n",
			  is_probe ? "Probing": "Loading", module_name, full_path));
		init = load_module(full_path, is_probe, &handle);
	} else {
		init = load_module(module_name, is_probe, &handle);
	}

	if (!init) {
		return NT_STATUS_UNSUCCESSFUL;
	}

	DEBUG(2, ("Module '%s' loaded\n", module_name));

	status = init();
	if (!NT_STATUS_IS_OK(status)) {
		DEBUG(0, ("Module '%s' initialization failed: %s\n",
			  module_name, get_friendly_nt_error_msg(status)));
		dlclose(handle);
	}

	return status;
}
Esempio n. 2
0
NTSTATUS smb_probe_module(const char *subsystem, const char *module)
{
	char *full_path = NULL;
	TALLOC_CTX *ctx = talloc_stackframe();
	NTSTATUS status;

	/* Check for absolute path */

	/* if we make any 'samba multibyte string'
	   calls here, we break
	   for loading string modules */

	DEBUG(5, ("Probing module '%s'\n", module));

	if (module[0] == '/') {
		status = do_smb_load_module(module, True);
		TALLOC_FREE(ctx);
		return status;
	}

	full_path = talloc_asprintf(ctx,
			"%s/%s.%s",
			modules_path(subsystem),
			module,
			shlib_ext());
	if (!full_path) {
		TALLOC_FREE(ctx);
		return NT_STATUS_NO_MEMORY;
	}

	DEBUG(5, ("Probing module '%s': Trying to load from %s\n",
		module, full_path));

	status = do_smb_load_module(full_path, True);

	TALLOC_FREE(ctx);
	return status;
}