]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
rpc:dnsserver: allow update replacing with similar record
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Fri, 28 May 2021 07:09:17 +0000 (19:09 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 29 Jun 2021 02:19:35 +0000 (02:19 +0000)
We have been refusing to handle the case where the replaced record
matches the replacement according to dns_record_match() (meaning the
wType and data are semantically identical). In Windows this is
explicitly used for changing TTL.

There are further changes we need to properly handle this case.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
selftest/knownfail.d/dns-aging
selftest/knownfail.d/dnscmd
source4/rpc_server/dnsserver/dnsdb.c

index f585449e1f9d2f7729247a3d32118c4adff5c7c8..bcea801187200bd17f6894891c8de504e29ecf98 100644 (file)
@@ -35,8 +35,6 @@ samba.tests.dns_aging.+test_add_update_dwReserved
 samba.tests.dns_aging.+test_add_update_dwSerial
 samba.tests.dns_aging.+test_add_update_dwSerial_2
 samba.tests.dns_aging.+test_add_update_many
-samba.tests.dns_aging.+test_add_update_timestamp
-samba.tests.dns_aging.+test_add_update_ttl
 samba.tests.dns_aging.+test_add_update_ttl_serial
 samba.tests.dns_aging.+test_dns_delete_simple_0_0_days_no_aging_touch
 samba.tests.dns_aging.+test_dns_delete_simple_0_113_days_no_aging_touch
@@ -53,7 +51,6 @@ samba.tests.dns_aging.+test_dns_delete_simple_2_13_days_no_aging_touch
 samba.tests.dns_aging.+test_dns_delete_simple_2_3_days_no_aging_touch
 samba.tests.dns_aging.+test_dynamic_record_static_update
 samba.tests.dns_aging.+test_multi_records_delete_aging
-samba.tests.dns_aging.+test_rpc_update_timestamps
 samba.tests.dns_aging.+test_static_record_dynamic_update
 samba.tests.dns_aging.+test_update_aging_disabled\b
 samba.tests.dns_aging.+test_update_aging_disabled_beyond_refresh_window
index 95860d2e9c2f5c6473c0de17f111904d615f7508..5385997ab50129e588dafdfbcc593b114983c264 100644 (file)
@@ -1,2 +1 @@
-samba.tests.samba_tool.dnscmd.+test_update_valid_type
 samba.tests.samba_tool.dnscmd.+test_update_invalid_type
index 33e73879248dc6a9e7421829a51a7a255662847e..3323000530fe22deecde6403cacfc24213933f6f 100644 (file)
@@ -570,12 +570,14 @@ WERROR dnsserver_db_update_record(TALLOC_CTX *mem_ctx,
 {
        const char * const attrs[] = { "dnsRecord", NULL };
        struct ldb_result *res;
+       struct dnsp_DnssrvRpcRecord rec2;
        struct dnsp_DnssrvRpcRecord *arec = NULL, *drec = NULL;
        struct ldb_message_element *el;
        enum ndr_err_code ndr_err;
        int ret, i;
        int serial;
        WERROR werr;
+       bool updating_ttl = false;
        char *encoded_name = ldb_binary_encode_string(mem_ctx, name);
 
        werr = dns_to_dnsp_convert(mem_ctx, add_record, &arec, true);
@@ -607,8 +609,6 @@ WERROR dnsserver_db_update_record(TALLOC_CTX *mem_ctx,
        }
 
        for (i=0; i<el->num_values; i++) {
-               struct dnsp_DnssrvRpcRecord rec2;
-
                ndr_err = ndr_pull_struct_blob(&el->values[i], mem_ctx, &rec2,
                                                (ndr_pull_flags_fn_t)ndr_pull_dnsp_DnssrvRpcRecord);
                if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
@@ -620,13 +620,22 @@ WERROR dnsserver_db_update_record(TALLOC_CTX *mem_ctx,
                }
        }
        if (i < el->num_values) {
-               return WERR_DNS_ERROR_RECORD_ALREADY_EXISTS;
+               /*
+                * The record already exists, which is an error UNLESS we are
+                * doing an in-place update.
+                *
+                * Therefore we need to see if drec also matches, in which
+                * case it's OK, though we can only update dwTtlSeconds and
+                * reset the timestamp to zero.
+                */
+               updating_ttl = dns_record_match(drec, &rec2);
+               if (! updating_ttl) {
+                       return WERR_DNS_ERROR_RECORD_ALREADY_EXISTS;
+               }
+               /* In this case the next loop is redundant */
        }
 
-
        for (i=0; i<el->num_values; i++) {
-               struct dnsp_DnssrvRpcRecord rec2;
-
                ndr_err = ndr_pull_struct_blob(&el->values[i], mem_ctx, &rec2,
                                                (ndr_pull_flags_fn_t)ndr_pull_dnsp_DnssrvRpcRecord);
                if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {