Пример #1
0
static bool test_do_global_parameter(struct torture_context *tctx)
{
	struct loadparm_context *lp_ctx = loadparm_init(tctx);
	torture_assert(tctx, lpcfg_do_global_parameter(lp_ctx, "workgroup", "werkgroep42"),
		       "lpcfg_set_cmdline failed");
	torture_assert_str_equal(tctx, lpcfg_workgroup(lp_ctx), "WERKGROEP42", "workgroup");
	return true;
}
Пример #2
0
static bool ntprinting_printer_latin1_check(struct torture_context *tctx)
{
	enum ndr_err_code ndr_err;
	struct ntprinting_printer r;
	DATA_BLOB blob;
	bool ok;

	ok = lpcfg_do_global_parameter(tctx->lp_ctx, "dos charset", "CP1252");
	if (!ok) {
		torture_comment(tctx, "Could not set 'dos charset' option.\n");
		return false;
	}
	reload_charcnv(tctx->lp_ctx);

	ZERO_STRUCT(r);
	r.info.string_flags = LIBNDR_FLAG_STR_ASCII;

	blob = data_blob_const(ntprinting_printer_data_latin1,
			       sizeof(ntprinting_printer_data_latin1));

	ndr_err = ndr_pull_struct_blob(&blob, tctx, &r,
		   (ndr_pull_flags_fn_t)ndr_pull_ntprinting_printer);

	torture_assert_ndr_success(tctx,
				   ndr_err,
				   "ndr_pull_ntprinting_printer");
#if 0
	ndr_print_debug((ndr_print_fn_t) ndr_print_ntprinting_printer,
			"ntprinter",
			&r);
#endif
	torture_assert_str_equal(tctx,
				 r.info.printername,
				 "S0BC",
				 "printername");
	/* latin1 encoding check */
	torture_assert_str_equal(tctx,
				 r.info.comment,
				 "\" SALA DA RECEPÇÃO DA CONSTRUÇÃO - RAND0 LOCATIO",
				 "comment");
	torture_assert_str_equal(tctx,
				 r.info.location,
				 "UTGCA ",
				 "location");

	return true;
}
Пример #3
0
/*
  called to initialise the driver
 */
_PUBLIC_ isc_result_t dlz_create(const char *dlzname,
				 unsigned int argc, char *argv[],
				 void **dbdata, ...)
{
	struct dlz_bind9_data *state;
	const char *helper_name;
	va_list ap;
	isc_result_t result;
	struct ldb_dn *dn;
	NTSTATUS nt_status;

	state = talloc_zero(NULL, struct dlz_bind9_data);
	if (state == NULL) {
		return ISC_R_NOMEMORY;
	}

	talloc_set_destructor(state, dlz_state_debug_unregister);

	/* fill in the helper functions */
	va_start(ap, dbdata);
	while ((helper_name = va_arg(ap, const char *)) != NULL) {
		b9_add_helper(state, helper_name, va_arg(ap, void*));
	}
	va_end(ap);

	/* Do not install samba signal handlers */
	fault_setup_disable();

	/* Start logging (to the bind9 logs) */
	debug_set_callback(state, b9_debug);

	state->ev_ctx = s4_event_context_init(state);
	if (state->ev_ctx == NULL) {
		result = ISC_R_NOMEMORY;
		goto failed;
	}

	result = parse_options(state, argc, argv, &state->options);
	if (result != ISC_R_SUCCESS) {
		goto failed;
	}

	state->lp = loadparm_init_global(true);
	if (state->lp == NULL) {
		result = ISC_R_NOMEMORY;
		goto failed;
	}

	if (state->options.debug) {
		lpcfg_do_global_parameter(state->lp, "log level", state->options.debug);
	} else {
		lpcfg_do_global_parameter(state->lp, "log level", "0");
	}

	if (smb_krb5_init_context(state, state->ev_ctx, state->lp, &state->smb_krb5_ctx) != 0) {
		result = ISC_R_NOMEMORY;
		goto failed;
	}

	nt_status = gensec_init();
	if (!NT_STATUS_IS_OK(nt_status)) {
		result = ISC_R_NOMEMORY;
		goto failed;
	}

	state->auth_context = talloc_zero(state, struct auth4_context);
	if (state->auth_context == NULL) {
		result = ISC_R_NOMEMORY;
		goto failed;
	}

	if (state->options.url == NULL) {
		state->options.url = lpcfg_private_path(state, state->lp, "dns/sam.ldb");
		if (state->options.url == NULL) {
			result = ISC_R_NOMEMORY;
			goto failed;
		}
	}

	state->samdb = samdb_connect_url(state, state->ev_ctx, state->lp,
					system_session(state->lp), 0, state->options.url);
	if (state->samdb == NULL) {
		state->log(ISC_LOG_ERROR, "samba_dlz: Failed to connect to %s",
			state->options.url);
		result = ISC_R_FAILURE;
		goto failed;
	}

	dn = ldb_get_default_basedn(state->samdb);
	if (dn == NULL) {
		state->log(ISC_LOG_ERROR, "samba_dlz: Unable to get basedn for %s - %s",
			   state->options.url, ldb_errstring(state->samdb));
		result = ISC_R_FAILURE;
		goto failed;
	}

	state->log(ISC_LOG_INFO, "samba_dlz: started for DN %s",
		   ldb_dn_get_linearized(dn));

	state->auth_context->event_ctx = state->ev_ctx;
	state->auth_context->lp_ctx = state->lp;
	state->auth_context->sam_ctx = state->samdb;
	state->auth_context->generate_session_info_pac = b9_generate_session_info_pac;

	*dbdata = state;

	return ISC_R_SUCCESS;

failed:
	talloc_free(state);
	return result;
}