#include "dsdb/common/util.h"
#include "dns_server/dns_server.h"
+#undef DBGC_CLASS
+#define DBGC_CLASS DBGC_DNS
+
uint8_t werr_to_dns_err(WERROR werr)
{
if (W_ERROR_EQUAL(WERR_OK, werr)) {
return DNS_RCODE_NOTAUTH;
} else if (W_ERROR_EQUAL(DNS_ERR(NOTZONE), werr)) {
return DNS_RCODE_NOTZONE;
+ } else if (W_ERROR_EQUAL(DNS_ERR(BADKEY), werr)) {
+ return DNS_RCODE_BADKEY;
}
- DEBUG(5, ("No mapping exists for %%s\n"));
+ DEBUG(5, ("No mapping exists for %s\n", win_errstr(werr)));
return DNS_RCODE_SERVFAIL;
}
if (el == NULL) {
*records = NULL;
*rec_count = 0;
- return WERR_OK;
+ return DNS_ERR(NAME_ERROR);
}
recs = talloc_zero_array(mem_ctx, struct dnsp_DnssrvRpcRecord, el->num_values);
- W_ERROR_HAVE_NO_MEMORY(recs);
+ if (recs == NULL) {
+ return WERR_NOMEM;
+ }
for (ri = 0; ri < el->num_values; ri++) {
struct ldb_val *v = &el->values[ri];
enum ndr_err_code ndr_err;
if (needs_add) {
return WERR_OK;
}
- /* TODO: Delete object? */
+ /* No entries left, delete the dnsNode object */
+ ret = ldb_delete(dns->samdb, msg->dn);
+ if (ret != LDB_SUCCESS) {
+ DEBUG(0, ("Deleting record failed; %d\n", ret));
+ return DNS_ERR(SERVER_FAILURE);
+ }
+ return WERR_OK;
}
if (needs_add) {
*_dn = dn;
return WERR_OK;
}
+
+WERROR dns_generate_options(struct dns_server *dns,
+ TALLOC_CTX *mem_ctx,
+ struct dns_res_rec **options)
+{
+ struct dns_res_rec *o;
+
+ o = talloc_zero(mem_ctx, struct dns_res_rec);
+ if (o == NULL) {
+ return WERR_NOMEM;
+ }
+ o->name = '\0';
+ o->rr_type = DNS_QTYPE_OPT;
+ /* This is ugly, but RFC2671 wants the payload size in this field */
+ o->rr_class = (enum dns_qclass) dns->max_payload;
+ o->ttl = 0;
+ o->length = 0;
+
+ *options = o;
+ return WERR_OK;
+}