Esempio n. 1
0
WERROR dns_server_process_query(struct dns_server *dns,
				struct dns_request_state *state,
				TALLOC_CTX *mem_ctx,
				struct dns_name_packet *in,
				struct dns_res_rec **answers,    uint16_t *ancount,
				struct dns_res_rec **nsrecs,     uint16_t *nscount,
				struct dns_res_rec **additional, uint16_t *arcount)
{
	uint16_t num_answers=0, num_nsrecs=0, num_additional=0;
	struct dns_res_rec *ans=NULL, *ns=NULL, *adds=NULL;
	WERROR werror;

	if (in->qdcount != 1) {
		return DNS_ERR(FORMAT_ERROR);
	}

	/* Windows returns NOT_IMPLEMENTED on this as well */
	if (in->questions[0].question_class == DNS_QCLASS_NONE) {
		return DNS_ERR(NOT_IMPLEMENTED);
	}

	if (dns_authorative_for_zone(dns, in->questions[0].name)) {
		state->flags |= DNS_FLAG_AUTHORITATIVE;
		werror = handle_question(dns, mem_ctx, &in->questions[0],
					 &ans, &num_answers);
	} else {
		if (state->flags & DNS_FLAG_RECURSION_DESIRED &&
		    state->flags & DNS_FLAG_RECURSION_AVAIL) {
			DEBUG(2, ("Not authorative for '%s', forwarding\n",
				  in->questions[0].name));
			werror = ask_forwarder(dns, mem_ctx, &in->questions[0],
					       &ans, &num_answers,
					       &ns, &num_nsrecs,
					       &adds, &num_additional);
		} else {
			werror = DNS_ERR(NAME_ERROR);
		}
	}
	W_ERROR_NOT_OK_GOTO(werror, query_failed);

	*answers = ans;
	*ancount = num_answers;

	/*FIXME: Do something for these */
	*nsrecs  = ns;
	*nscount = num_nsrecs;

	*additional = adds;
	*arcount    = num_additional;

	return WERR_OK;

query_failed:
	/*FIXME: add our SOA record to nsrecs */
	return werror;
}
Esempio n. 2
0
WERROR dns_server_process_query(struct dns_server *dns,
				TALLOC_CTX *mem_ctx,
				struct dns_name_packet *in,
				struct dns_res_rec **answers,    uint16_t *ancount,
				struct dns_res_rec **nsrecs,     uint16_t *nscount,
				struct dns_res_rec **additional, uint16_t *arcount)
{
	uint16_t num_answers=0;
	struct dns_res_rec *ans=NULL;
	WERROR werror;

	if (in->qdcount != 1) {
		return DNS_ERR(FORMAT_ERROR);
	}

	/* Windows returns NOT_IMPLEMENTED on this as well */
	if (in->questions[0].question_class == DNS_QCLASS_NONE) {
		return DNS_ERR(NOT_IMPLEMENTED);
	}

	werror = handle_question(dns, mem_ctx, &in->questions[0], &ans, &num_answers);
	W_ERROR_NOT_OK_GOTO(werror, query_failed);

	*answers = ans;
	*ancount = num_answers;

	/*FIXME: Do something for these */
	*nsrecs  = NULL;
	*nscount = 0;

	*additional = NULL;
	*arcount    = 0;

	return WERR_OK;

query_failed:
	/*FIXME: add our SOA record to nsrecs */
	return werror;
}
Esempio n. 3
0
WERROR dsdb_set_schema_from_ldif(struct ldb_context *ldb,
				 const char *pf, const char *df,
				 const char *dn)
{
	struct ldb_ldif *ldif;
	struct ldb_message *msg;
	TALLOC_CTX *mem_ctx;
	WERROR status;
	int ret;
	struct dsdb_schema *schema;
	const struct ldb_val *prefix_val;
	const struct ldb_val *info_val;
	struct ldb_val info_val_default;


	mem_ctx = talloc_new(ldb);
	if (!mem_ctx) {
		goto nomem;
	}

	schema = dsdb_new_schema(mem_ctx);
	if (!schema) {
		goto nomem;
	}
	schema->base_dn = ldb_dn_new(schema, ldb, dn);
	if (!schema->base_dn) {
		goto nomem;
	}
	schema->fsmo.we_are_master = true;
	schema->fsmo.update_allowed = true;
	schema->fsmo.master_dn = ldb_dn_new(schema, ldb, "@PROVISION_SCHEMA_MASTER");
	if (!schema->fsmo.master_dn) {
		goto nomem;
	}

	/*
	 * load the prefixMap attribute from pf
	 */
	ldif = ldb_ldif_read_string(ldb, &pf);
	if (!ldif) {
		status = WERR_INVALID_PARAM;
		goto failed;
	}
	talloc_steal(mem_ctx, ldif);

	ret = ldb_msg_normalize(ldb, mem_ctx, ldif->msg, &msg);
	if (ret != LDB_SUCCESS) {
		goto nomem;
	}
	talloc_free(ldif);

	prefix_val = ldb_msg_find_ldb_val(msg, "prefixMap");
	if (!prefix_val) {
	    	status = WERR_INVALID_PARAM;
		goto failed;
	}

	info_val = ldb_msg_find_ldb_val(msg, "schemaInfo");
	if (!info_val) {
		status = dsdb_schema_info_blob_new(mem_ctx, &info_val_default);
		W_ERROR_NOT_OK_GOTO(status, failed);
		info_val = &info_val_default;
	}

	status = dsdb_load_oid_mappings_ldb(schema, prefix_val, info_val);
	if (!W_ERROR_IS_OK(status)) {
		DEBUG(0,("ERROR: dsdb_load_oid_mappings_ldb() failed with %s\n", win_errstr(status)));
		goto failed;
	}

	/* load the attribute and class definitions out of df */
	while ((ldif = ldb_ldif_read_string(ldb, &df))) {
		talloc_steal(mem_ctx, ldif);

		ret = ldb_msg_normalize(ldb, ldif, ldif->msg, &msg);
		if (ret != LDB_SUCCESS) {
			goto nomem;
		}

		status = dsdb_schema_set_el_from_ldb_msg(ldb, schema, msg);
		talloc_free(ldif);
		if (!W_ERROR_IS_OK(status)) {
			goto failed;
		}
	}

	ret = dsdb_set_schema(ldb, schema);
	if (ret != LDB_SUCCESS) {
		status = WERR_FOOBAR;
		goto failed;
	}

	ret = dsdb_schema_fill_extended_dn(ldb, schema);
	if (ret != LDB_SUCCESS) {
		status = WERR_FOOBAR;
		goto failed;
	}

	goto done;

nomem:
	status = WERR_NOMEM;
failed:
done:
	talloc_free(mem_ctx);
	return status;
}