summaryrefslogtreecommitdiff
path: root/source4/dns_server/pydns.c
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2017-06-09 16:05:31 +1200
committerAndrew Bartlett <abartlet@samba.org>2017-06-10 21:48:20 +0200
commit970fdfae6a18bf11d423a72973c0f7b589e6f92a (patch)
treeb61e542a464306866c7228e3af44864c4c886f63 /source4/dns_server/pydns.c
parentf5e945c810b5e453b699d4e796cfb6790c442a17 (diff)
downloadsamba-970fdfae6a18bf11d423a72973c0f7b589e6f92a.tar.gz
pydsdb_dns: Allow the partition DN to be specified into py_dsdb_dns_lookup
This allows lookups to be confined to one partition, which in turn avoids issues when running this against MS Windows, which does not match Samba behaviour for dns_common_zones() Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Diffstat (limited to 'source4/dns_server/pydns.c')
-rw-r--r--source4/dns_server/pydns.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/source4/dns_server/pydns.c b/source4/dns_server/pydns.c
index 7fc8f0c8811..cb41faa1441 100644
--- a/source4/dns_server/pydns.c
+++ b/source4/dns_server/pydns.c
@@ -93,27 +93,40 @@ static int py_dnsp_DnssrvRpcRecord_get_array(PyObject *value,
return 0;
}
-static PyObject *py_dsdb_dns_lookup(PyObject *self, PyObject *args)
+static PyObject *py_dsdb_dns_lookup(PyObject *self,
+ PyObject *args, PyObject *kwargs)
{
struct ldb_context *samdb;
PyObject *py_ldb, *ret, *pydn;
+ PyObject *py_dns_partition = NULL;
char *dns_name;
TALLOC_CTX *frame;
NTSTATUS status;
WERROR werr;
struct dns_server_zone *zones_list;
- struct ldb_dn *dn;
+ struct ldb_dn *dn, *dns_partition = NULL;
struct dnsp_DnssrvRpcRecord *records;
uint16_t num_records;
+ const char * const kwnames[] = { "ldb", "dns_name",
+ "dns_partition", NULL };
- if (!PyArg_ParseTuple(args, "Os", &py_ldb, &dns_name)) {
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Os|O",
+ discard_const_p(char *, kwnames),
+ &py_ldb, &dns_name,
+ &py_dns_partition)) {
return NULL;
}
PyErr_LDB_OR_RAISE(py_ldb, samdb);
+ if (py_dns_partition) {
+ PyErr_LDB_DN_OR_RAISE(py_dns_partition,
+ dns_partition);
+ }
+
frame = talloc_stackframe();
- status = dns_common_zones(samdb, frame, &zones_list);
+ status = dns_common_zones(samdb, frame, dns_partition,
+ &zones_list);
if (!NT_STATUS_IS_OK(status)) {
talloc_free(frame);
PyErr_SetNTSTATUS(status);
@@ -210,7 +223,7 @@ static PyObject *py_dsdb_dns_replace(PyObject *self, PyObject *args)
frame = talloc_stackframe();
- status = dns_common_zones(samdb, frame, &zones_list);
+ status = dns_common_zones(samdb, frame, NULL, &zones_list);
if (!NT_STATUS_IS_OK(status)) {
PyErr_SetNTSTATUS(status);
talloc_free(frame);
@@ -305,7 +318,8 @@ static PyObject *py_dsdb_dns_replace_by_dn(PyObject *self, PyObject *args)
static PyMethodDef py_dsdb_dns_methods[] = {
{ "lookup", (PyCFunction)py_dsdb_dns_lookup,
- METH_VARARGS, "Get the DNS database entries for a DNS name"},
+ METH_VARARGS|METH_KEYWORDS,
+ "Get the DNS database entries for a DNS name"},
{ "replace", (PyCFunction)py_dsdb_dns_replace,
METH_VARARGS, "Replace the DNS database entries for a DNS name"},
{ "replace_by_dn", (PyCFunction)py_dsdb_dns_replace_by_dn,