View | Details | Raw Unified | Return to bug 41190 | Differences between
and this patch

Collapse All | Expand All

(-)a/python/samba/samdb.py (-4 / +4 lines)
 Lines 935-954   accountExpires: %u Link Here 
935
        '''Return the NDR database structures from a dnsRecord element'''
935
        '''Return the NDR database structures from a dnsRecord element'''
936
        return dsdb_dns.extract(el)
936
        return dsdb_dns.extract(el)
937
937
938
    def dns_replace(self, dns_name, new_records):
938
    def dns_replace(self, dns_name, new_records, tombstone=False):
939
        '''Do a DNS modification on the database, sets the NDR database
939
        '''Do a DNS modification on the database, sets the NDR database
940
        structures on a DNS name
940
        structures on a DNS name
941
        '''
941
        '''
942
        return dsdb_dns.replace(self, dns_name, new_records)
942
        return dsdb_dns.replace(self, dns_name, new_records, tombstone)
943
943
944
    def dns_replace_by_dn(self, dn, new_records):
944
    def dns_replace_by_dn(self, dn, new_records, tombstone=False):
945
        '''Do a DNS modification on the database, sets the NDR database
945
        '''Do a DNS modification on the database, sets the NDR database
946
        structures on a LDB DN
946
        structures on a LDB DN
947
947
948
        This routine is important because if the last record on the DN
948
        This routine is important because if the last record on the DN
949
        is removed, this routine will put a tombstone in the record.
949
        is removed, this routine will put a tombstone in the record.
950
        '''
950
        '''
951
        return dsdb_dns.replace_by_dn(self, dn, new_records)
951
        return dsdb_dns.replace_by_dn(self, dn, new_records, tombstone)
952
952
953
    def garbage_collect_tombstones(self, dn, current_time,
953
    def garbage_collect_tombstones(self, dn, current_time,
954
                                   tombstone_lifetime=None):
954
                                   tombstone_lifetime=None):
(-)a/source4/dns_server/dlz_bind9.c (-3 / +5 lines)
 Lines 1637-1643   _PUBLIC_ isc_result_t dlz_addrdataset(const char *name, const char *rdatastr, vo Link Here 
1637
1637
1638
	/* modify the record */
1638
	/* modify the record */
1639
	werr = dns_common_replace(state->samdb, rec, dn,
1639
	werr = dns_common_replace(state->samdb, rec, dn,
1640
				  needs_add,
1640
				  needs_add, tombstoned,
1641
				  state->soa_serial,
1641
				  state->soa_serial,
1642
				  recs, num_recs);
1642
				  recs, num_recs);
1643
	b9_reset_session_info(state);
1643
	b9_reset_session_info(state);
 Lines 1720-1726   _PUBLIC_ isc_result_t dlz_subrdataset(const char *name, const char *rdatastr, vo Link Here 
1720
1720
1721
	/* modify the record */
1721
	/* modify the record */
1722
	werr = dns_common_replace(state->samdb, rec, dn,
1722
	werr = dns_common_replace(state->samdb, rec, dn,
1723
				  false,/* needs_add */
1723
				  false, /* needs_add */
1724
				  false, /* tombstoned */
1724
				  state->soa_serial,
1725
				  state->soa_serial,
1725
				  recs, num_recs);
1726
				  recs, num_recs);
1726
	b9_reset_session_info(state);
1727
	b9_reset_session_info(state);
 Lines 1804-1810   _PUBLIC_ isc_result_t dlz_delrdataset(const char *name, const char *type, void * Link Here 
1804
1805
1805
	/* modify the record */
1806
	/* modify the record */
1806
	werr = dns_common_replace(state->samdb, tmp_ctx, dn,
1807
	werr = dns_common_replace(state->samdb, tmp_ctx, dn,
1807
				  false,/* needs_add */
1808
				  false, /* needs_add */
1809
				  false, /* tombstoned */
1808
				  state->soa_serial,
1810
				  state->soa_serial,
1809
				  recs, num_recs);
1811
				  recs, num_recs);
1810
	b9_reset_session_info(state);
1812
	b9_reset_session_info(state);
(-)a/source4/dns_server/dns_server.h (+1 lines)
 Lines 97-102   WERROR dns_replace_records(struct dns_server *dns, Link Here 
97
			   TALLOC_CTX *mem_ctx,
97
			   TALLOC_CTX *mem_ctx,
98
			   struct ldb_dn *dn,
98
			   struct ldb_dn *dn,
99
			   bool needs_add,
99
			   bool needs_add,
100
			   bool tombstoned,
100
			   struct dnsp_DnssrvRpcRecord *records,
101
			   struct dnsp_DnssrvRpcRecord *records,
101
			   uint16_t rec_count);
102
			   uint16_t rec_count);
102
WERROR dns_name2dn(struct dns_server *dns,
103
WERROR dns_name2dn(struct dns_server *dns,
(-)a/source4/dns_server/dns_update.c (-6 / +12 lines)
 Lines 456-462   static WERROR handle_one_update(struct dns_server *dns, Link Here 
456
			rcount += 1;
456
			rcount += 1;
457
457
458
			werror = dns_replace_records(dns, mem_ctx, dn,
458
			werror = dns_replace_records(dns, mem_ctx, dn,
459
						     needs_add, recs, rcount);
459
						     needs_add, tombstoned,
460
						     recs, rcount);
460
			W_ERROR_NOT_OK_RETURN(werror);
461
			W_ERROR_NOT_OK_RETURN(werror);
461
462
462
			return WERR_OK;
463
			return WERR_OK;
 Lines 517-523   static WERROR handle_one_update(struct dns_server *dns, Link Here 
517
			}
518
			}
518
519
519
			werror = dns_replace_records(dns, mem_ctx, dn,
520
			werror = dns_replace_records(dns, mem_ctx, dn,
520
						     needs_add, recs, rcount);
521
						     needs_add, tombstoned,
522
						     recs, rcount);
521
			W_ERROR_NOT_OK_RETURN(werror);
523
			W_ERROR_NOT_OK_RETURN(werror);
522
524
523
			return WERR_OK;
525
			return WERR_OK;
 Lines 538-551   static WERROR handle_one_update(struct dns_server *dns, Link Here 
538
			recs[i] = recs[rcount];
540
			recs[i] = recs[rcount];
539
541
540
			werror = dns_replace_records(dns, mem_ctx, dn,
542
			werror = dns_replace_records(dns, mem_ctx, dn,
541
						     needs_add, recs, rcount);
543
						     needs_add, tombstoned,
544
						     recs, rcount);
542
			W_ERROR_NOT_OK_RETURN(werror);
545
			W_ERROR_NOT_OK_RETURN(werror);
543
546
544
			return WERR_OK;
547
			return WERR_OK;
545
		}
548
		}
546
549
547
		werror = dns_replace_records(dns, mem_ctx, dn,
550
		werror = dns_replace_records(dns, mem_ctx, dn,
548
					     needs_add, recs, rcount+1);
551
					     needs_add, tombstoned, recs,
552
					     rcount+1);
549
		W_ERROR_NOT_OK_RETURN(werror);
553
		W_ERROR_NOT_OK_RETURN(werror);
550
554
551
		return WERR_OK;
555
		return WERR_OK;
 Lines 594-600   static WERROR handle_one_update(struct dns_server *dns, Link Here 
594
		}
598
		}
595
599
596
		werror = dns_replace_records(dns, mem_ctx, dn,
600
		werror = dns_replace_records(dns, mem_ctx, dn,
597
					     needs_add, recs, rcount);
601
					     needs_add, tombstoned, recs,
602
					     rcount);
598
		W_ERROR_NOT_OK_RETURN(werror);
603
		W_ERROR_NOT_OK_RETURN(werror);
599
604
600
		return WERR_OK;
605
		return WERR_OK;
 Lines 640-646   static WERROR handle_one_update(struct dns_server *dns, Link Here 
640
		}
645
		}
641
646
642
		werror = dns_replace_records(dns, mem_ctx, dn,
647
		werror = dns_replace_records(dns, mem_ctx, dn,
643
					     needs_add, recs, rcount);
648
					     needs_add, tombstoned, recs,
649
					     rcount);
644
		W_ERROR_NOT_OK_RETURN(werror);
650
		W_ERROR_NOT_OK_RETURN(werror);
645
	}
651
	}
646
652
(-)a/source4/dns_server/dns_utils.c (-1 / +3 lines)
 Lines 121-133   WERROR dns_replace_records(struct dns_server *dns, Link Here 
121
			   TALLOC_CTX *mem_ctx,
121
			   TALLOC_CTX *mem_ctx,
122
			   struct ldb_dn *dn,
122
			   struct ldb_dn *dn,
123
			   bool needs_add,
123
			   bool needs_add,
124
			   bool tombstoned,
124
			   struct dnsp_DnssrvRpcRecord *records,
125
			   struct dnsp_DnssrvRpcRecord *records,
125
			   uint16_t rec_count)
126
			   uint16_t rec_count)
126
{
127
{
127
	/* TODO: Autogenerate this somehow */
128
	/* TODO: Autogenerate this somehow */
128
	uint32_t dwSerial = 110;
129
	uint32_t dwSerial = 110;
129
	return dns_common_replace(dns->samdb, mem_ctx, dn,
130
	return dns_common_replace(dns->samdb, mem_ctx, dn,
130
				  needs_add, dwSerial, records, rec_count);
131
				  needs_add, tombstoned, dwSerial, records,
132
				  rec_count);
131
}
133
}
132
134
133
bool dns_authoritative_for_zone(struct dns_server *dns,
135
bool dns_authoritative_for_zone(struct dns_server *dns,
(-)a/source4/dns_server/dnsserver_common.c (-4 / +5 lines)
 Lines 303-308   WERROR dns_common_replace(struct ldb_context *samdb, Link Here 
303
			  TALLOC_CTX *mem_ctx,
303
			  TALLOC_CTX *mem_ctx,
304
			  struct ldb_dn *dn,
304
			  struct ldb_dn *dn,
305
			  bool needs_add,
305
			  bool needs_add,
306
			  bool tombstoned,
306
			  uint32_t serial,
307
			  uint32_t serial,
307
			  struct dnsp_DnssrvRpcRecord *records,
308
			  struct dnsp_DnssrvRpcRecord *records,
308
			  uint16_t rec_count)
309
			  uint16_t rec_count)
 Lines 312-318   WERROR dns_common_replace(struct ldb_context *samdb, Link Here 
312
	int ret;
313
	int ret;
313
	WERROR werr;
314
	WERROR werr;
314
	struct ldb_message *msg = NULL;
315
	struct ldb_message *msg = NULL;
315
	bool was_tombstoned = false;
316
	bool tombstoned_marker = false;
316
	bool become_tombstoned = false;
317
	bool become_tombstoned = false;
317
318
318
	msg = ldb_msg_new(mem_ctx);
319
	msg = ldb_msg_new(mem_ctx);
 Lines 352-358   WERROR dns_common_replace(struct ldb_context *samdb, Link Here 
352
353
353
		if (records[i].wType == DNS_TYPE_TOMBSTONE) {
354
		if (records[i].wType == DNS_TYPE_TOMBSTONE) {
354
			if (records[i].data.timestamp != 0) {
355
			if (records[i].data.timestamp != 0) {
355
				was_tombstoned = true;
356
				tombstoned_marker = true;
356
			}
357
			}
357
			continue;
358
			continue;
358
		}
359
		}
 Lines 391-397   WERROR dns_common_replace(struct ldb_context *samdb, Link Here 
391
		enum ndr_err_code ndr_err;
392
		enum ndr_err_code ndr_err;
392
		struct timeval tv;
393
		struct timeval tv;
393
394
394
		if (was_tombstoned) {
395
		if (tombstoned && tombstoned_marker) {
395
			/*
396
			/*
396
			 * This is already a tombstoned object.
397
			 * This is already a tombstoned object.
397
			 * Just leave it instead of updating the time stamp.
398
			 * Just leave it instead of updating the time stamp.
 Lines 417-423   WERROR dns_common_replace(struct ldb_context *samdb, Link Here 
417
		become_tombstoned = true;
418
		become_tombstoned = true;
418
	}
419
	}
419
420
420
	if (was_tombstoned || become_tombstoned) {
421
	if (tombstoned || tombstoned_marker || become_tombstoned) {
421
		ret = ldb_msg_add_empty(msg, "dNSTombstoned",
422
		ret = ldb_msg_add_empty(msg, "dNSTombstoned",
422
					LDB_FLAG_MOD_REPLACE, NULL);
423
					LDB_FLAG_MOD_REPLACE, NULL);
423
		if (ret != LDB_SUCCESS) {
424
		if (ret != LDB_SUCCESS) {
(-)a/source4/dns_server/dnsserver_common.h (+1 lines)
 Lines 53-58   WERROR dns_common_replace(struct ldb_context *samdb, Link Here 
53
			  TALLOC_CTX *mem_ctx,
53
			  TALLOC_CTX *mem_ctx,
54
			  struct ldb_dn *dn,
54
			  struct ldb_dn *dn,
55
			  bool needs_add,
55
			  bool needs_add,
56
			  bool tombstoned,
56
			  uint32_t serial,
57
			  uint32_t serial,
57
			  struct dnsp_DnssrvRpcRecord *records,
58
			  struct dnsp_DnssrvRpcRecord *records,
58
			  uint16_t rec_count);
59
			  uint16_t rec_count);
(-)a/source4/dns_server/pydns.c (-4 / +8 lines)
 Lines 195-200   static PyObject *py_dsdb_dns_replace(PyObject *self, PyObject *args) Link Here 
195
	struct ldb_dn *dn;
195
	struct ldb_dn *dn;
196
	struct dnsp_DnssrvRpcRecord *records;
196
	struct dnsp_DnssrvRpcRecord *records;
197
	uint16_t num_records;
197
	uint16_t num_records;
198
	bool tombstone = false;
198
199
199
	/*
200
	/*
200
	 * TODO: This is a shocking abuse, but matches what the
201
	 * TODO: This is a shocking abuse, but matches what the
 Lines 203-209   static PyObject *py_dsdb_dns_replace(PyObject *self, PyObject *args) Link Here 
203
	 */
204
	 */
204
	static const int serial = 110;
205
	static const int serial = 110;
205
206
206
	if (!PyArg_ParseTuple(args, "OsO", &py_ldb, &dns_name, &py_dns_records)) {
207
	if (!PyArg_ParseTuple(args, "OsO|b", &py_ldb, &dns_name,
208
			      &py_dns_records, &tombstone)) {
207
		return NULL;
209
		return NULL;
208
	}
210
	}
209
	PyErr_LDB_OR_RAISE(py_ldb, samdb);
211
	PyErr_LDB_OR_RAISE(py_ldb, samdb);
 Lines 233-238   static PyObject *py_dsdb_dns_replace(PyObject *self, PyObject *args) Link Here 
233
				  frame,
235
				  frame,
234
				  dn,
236
				  dn,
235
				  false, /* Not adding a record */
237
				  false, /* Not adding a record */
238
				  tombstone,
236
				  serial,
239
				  serial,
237
				  records,
240
				  records,
238
				  num_records);
241
				  num_records);
 Lines 254-259   static PyObject *py_dsdb_dns_replace_by_dn(PyObject *self, PyObject *args) Link Here 
254
	struct ldb_dn *dn;
257
	struct ldb_dn *dn;
255
	struct dnsp_DnssrvRpcRecord *records;
258
	struct dnsp_DnssrvRpcRecord *records;
256
	uint16_t num_records;
259
	uint16_t num_records;
260
	bool tombstone = false;
257
261
258
	/*
262
	/*
259
	 * TODO: This is a shocking abuse, but matches what the
263
	 * TODO: This is a shocking abuse, but matches what the
 Lines 262-268   static PyObject *py_dsdb_dns_replace_by_dn(PyObject *self, PyObject *args) Link Here 
262
	 */
266
	 */
263
	static const int serial = 110;
267
	static const int serial = 110;
264
268
265
	if (!PyArg_ParseTuple(args, "OOO", &py_ldb, &py_dn, &py_dns_records)) {
269
	if (!PyArg_ParseTuple(args, "OOO|b", &py_ldb, &py_dn, &py_dns_records,
270
			      &tombstone)) {
266
		return NULL;
271
		return NULL;
267
	}
272
	}
268
	PyErr_LDB_OR_RAISE(py_ldb, samdb);
273
	PyErr_LDB_OR_RAISE(py_ldb, samdb);
 Lines 282-287   static PyObject *py_dsdb_dns_replace_by_dn(PyObject *self, PyObject *args) Link Here 
282
				  frame,
287
				  frame,
283
				  dn,
288
				  dn,
284
				  false, /* Not adding a record */
289
				  false, /* Not adding a record */
290
				  tombstone,
285
				  serial,
291
				  serial,
286
				  records,
292
				  records,
287
				  num_records);
293
				  num_records);
288
- 
289
--
290
source4/dns_server/dlz_bind9.c  | 2 +-
294
source4/dns_server/dlz_bind9.c  | 2 +-
291
source4/dns_server/dns_update.c | 2 +-
295
source4/dns_server/dns_update.c | 2 +-
292
2 files changed, 2 insertions(+), 2 deletions(-)
296
2 files changed, 2 insertions(+), 2 deletions(-)
(-)a/source4/dns_server/dlz_bind9.c (-1 / +1 lines)
 Lines 1593-1599   _PUBLIC_ isc_result_t dlz_addrdataset(const char *name, const char *rdatastr, vo Link Here 
1593
		return ISC_R_FAILURE;
1593
		return ISC_R_FAILURE;
1594
	}
1594
	}
1595
1595
1596
	if (tombstoned) {
1596
	if (tombstoned && num_recs > 0 && recs[num_recs - 1].wType == DNS_TYPE_TOMBSTONE) {
1597
		/*
1597
		/*
1598
		 * we need to keep the existing tombstone record
1598
		 * we need to keep the existing tombstone record
1599
		 * and ignore it
1599
		 * and ignore it
(-)a/source4/dns_server/dns_update.c (-3 / +1 lines)
 Lines 419-425   static WERROR handle_one_update(struct dns_server *dns, Link Here 
419
	}
419
	}
420
	W_ERROR_NOT_OK_RETURN(werror);
420
	W_ERROR_NOT_OK_RETURN(werror);
421
421
422
	if (tombstoned) {
422
	if (tombstoned && rcount > 0 && recs[rcount - 1].wType == DNS_TYPE_TOMBSTONE) {
423
		/*
423
		/*
424
		 * we need to keep the existing tombstone record
424
		 * we need to keep the existing tombstone record
425
		 * and ignore it
425
		 * and ignore it
426
- 
427
--
428
python/samba/tests/dcerpc/dnsserver.py | 2 +-
426
python/samba/tests/dcerpc/dnsserver.py | 2 +-
429
1 file changed, 1 insertion(+), 1 deletion(-)
427
1 file changed, 1 insertion(+), 1 deletion(-)
(-)a/python/samba/tests/dcerpc/dnsserver.py (-2 / +1 lines)
 Lines 192-198   class DnsserverTests(RpcInterfaceTestCase): Link Here 
192
192
193
        dn, record = self.get_record_from_db(self.custom_zone, "testrecord")
193
        dn, record = self.get_record_from_db(self.custom_zone, "testrecord")
194
        record.wType = dnsp.DNS_TYPE_TOMBSTONE
194
        record.wType = dnsp.DNS_TYPE_TOMBSTONE
195
        res = self.samdb.dns_replace_by_dn(dn, [record])
195
        res = self.samdb.dns_replace_by_dn(dn, [record], True)
196
        if res is not None:
196
        if res is not None:
197
            self.fail("Unable to update dns record to be tombstoned.")
197
            self.fail("Unable to update dns record to be tombstoned.")
198
198
199
- 

Return to bug 41190