mirror of
https://github.com/samba-team/samba.git
synced 2025-01-06 13:18:07 +03:00
fcecdfa8e5
This function already exists in bind9 but takes different arguments, so when the DLZ is loaded and this function is called bind crashes: named[1523]: samba_dlz: allowing update of signer=DESKTOP-8BUKMBK\$\@AFOREST.AD name=118.101.168.192.in-addr.arpa tcpaddr=192.168.101.118 type=PTR key=1264-ms-7.1-2ac9.9ef238e1-9747-11ed-9f95-525400dc6981/159/0 named[1523]: samba_dlz: allowing update of signer=DESKTOP-8BUKMBK\$\@AFOREST.AD name=118.101.168.192.in-addr.arpa tcpaddr=192.168.101.118 type=PTR key=1264-ms-7.1-2ac9.9ef238e1-9747-11ed-9f95-525400dc6981/159/0 named[1523]: client @0x7f26caa90f68 192.168.101.118#58223/key DESKTOP-8BUKMBK\$\@AFOREST.AD: updating zone '101.168.192.in-addr.arpa/NONE': deleting rrset at '118.101.168.192.in-addr.ar named[1523]: name.c:664: REQUIRE(((name1) != ((void *)0) && ((const isc__magic_t *)(name1))->magic == ((('D') << 24 | ('N') << 16 | ('S') << 8 | ('n'))))) failed, back trace Backtrace: #0 0x00007f2716c957ec in __pthread_kill_implementation () from /lib64/libc.so.6 #1 0x00007f2716c42816 in raise () from /lib64/libc.so.6 #2 0x00007f2716c2b81c in abort () from /lib64/libc.so.6 #3 0x000055d4de847995 in assertion_failed (file=<optimized out>, line=<optimized out>, type=<optimized out>, cond=<optimized out>) at /usr/src/debug/bind-9.18.10/bin/named/main.c:237 #4 0x00007f27176388fc in isc_assertion_failed (file=file@entry=0x7f27173b0df6 "name.c", line=line@entry=664, type=type@entry=isc_assertiontype_require, cond=cond@entry=0x7f27173b0268 "((name1) != ((void *)0) && ((const isc__magic_t *)(name1))->magic == ((('D') << 24 | ('N') << 16 | ('S') << 8 | ('n'))))") at /usr/src/debug/bind-9.18.10/lib/isc/assertions.c:48 #5 0x00007f27172946f9 in dns_name_equal (name1=<optimized out>, name2=<optimized out>) at /usr/src/debug/bind-9.18.10/lib/dns/name.c:664 **** Here bind's dns_name_equal() is called instead of samba's dns_name_equal() **** #6 0x00007f27077ad6f2 in dns_record_match (rec1=0x7f26f8042d70, rec2=0x7f26f8044d10) at ../../source4/dns_server/dnsserver_common.c:1346 #7 0x00007f271404732c in b9_record_match (rec1=0x7f26f8042d70, rec2=0x7f26f8044d10) at ../../source4/dns_server/dlz_bind9.c:1830 #8 0x00007f2714047daa in dlz_subrdataset (name=0x7f2706ff82f0 "118.101.168.192.in-addr.arpa", rdatastr=0x7f26c9c10000 "118.101.168.192.in-addr.arpa.\t1200\tIN\tPTR\tDESKTOP-8BUKMBK.aforest.ad.", dbdata=0x7f271003d300, version=0x7f26f8044b20) at ../../source4/dns_server/dlz_bind9.c:2077 #9 0x000055d4de84afb4 in dlopen_dlz_subrdataset (name=0x7f2706ff82f0 "118.101.168.192.in-addr.arpa", rdatastr=<optimized out>, driverarg=<optimized out>, dbdata=0x7f270430f680, version=<optimized out>) at /usr/src/debug/bind-9.18.10/bin/named/dlz_dlopen_driver.c:483 #10 0x00007f271738e734 in modrdataset.constprop.0 (db=0x7f2704291740, node=0x7f26c9c006e0, version=0x7f26f8044b20, rdataset=0x7f2706ff8830, mod_function=0x55d4de84af80 <dlopen_dlz_subrdataset>, options=<optimized out>) at /usr/src/debug/bind-9.18.10/lib/dns/sdlz.c:1107 #11 0x00007f2717251855 in diff_apply (diff=diff@entry=0x7f2706ff8df0, db=db@entry=0x7f2704291740, ver=ver@entry=0x7f26f8044b20, warn=warn@entry=true) at /usr/src/debug/bind-9.18.10/lib/dns/diff.c:370 #12 0x00007f2717251c8a in dns_diff_apply (diff=diff@entry=0x7f2706ff8df0, db=db@entry=0x7f2704291740, ver=ver@entry=0x7f26f8044b20) at /usr/src/debug/bind-9.18.10/lib/dns/diff.c:465 #13 0x00007f2717d105aa in do_one_tuple (tuple=tuple@entry=0x7f2706ff8e50, db=db@entry=0x7f2704291740, ver=ver@entry=0x7f26f8044b20, diff=diff@entry=0x7f2706ff9400) at /usr/src/debug/bind-9.18.10/lib/ns/update.c:454 #14 0x00007f2717d10fff in update_one_rr (rdata=0x7f2706ff8ee8, ttl=<optimized out>, name=<optimized out>, op=DNS_DIFFOP_DEL, diff=0x7f2706ff9400, ver=0x7f26f8044b20, db=0x7f2704291740) at /usr/src/debug/bind-9.18.10/lib/ns/update.c:505 #15 delete_if_action (data=<optimized out>, rr=0x7f2706ff8ee0) at /usr/src/debug/bind-9.18.10/lib/ns/update.c:1427 #16 0x00007f2717d10ccd in foreach_rr (db=0x7f2704291740, ver=<optimized out>, name=0x7f26caa61d00, type=<optimized out>, covers=<optimized out>, rr_action=rr_action@entry=0x7f2717d10f60 <delete_if_action>, rr_action_data=0x7f2706ff9280) at /usr/src/debug/bind-9.18.10/lib/ns/update.c:736 #17 0x00007f2717d10e76 in delete_if (predicate=predicate@entry=0x7f2717d0fb10 <true_p>, db=<optimized out>, ver=<optimized out>, name=<optimized out>, type=<optimized out>, covers=<optimized out>, update_rr=0x7f2706ff94b0, diff=0x7f2706ff9400) at /usr/src/debug/bind-9.18.10/lib/ns/update.c:1454 #18 0x00007f2717d1bccd in update_action (task=<optimized out>, event=<optimized out>) at /usr/src/debug/bind-9.18.10/lib/ns/update.c:3299 #19 0x00007f271765eb4c in task_run (task=0x7f27155ccf00) at /usr/src/debug/bind-9.18.10/lib/isc/task.c:823 #20 isc_task_run (task=0x7f27155ccf00) at /usr/src/debug/bind-9.18.10/lib/isc/task.c:904 #21 0x00007f271762cb12 in isc__nm_async_task (worker=0x7f2716236560, ev0=0x7f26caa07000) at netmgr/netmgr.c:840 #22 process_netievent (worker=worker@entry=0x7f2716236560, ievent=0x7f26caa07000) at netmgr/netmgr.c:918 #23 0x00007f271762d197 in process_queue (worker=worker@entry=0x7f2716236560, type=type@entry=NETIEVENT_TASK) at netmgr/netmgr.c:1011 #24 0x00007f271762d3b3 in process_all_queues (worker=0x7f2716236560) at netmgr/netmgr.c:765 #25 async_cb (handle=0x7f27162368c0) at netmgr/netmgr.c:794 #26 0x00007f2717c4cb0d in uv__async_io (loop=0x7f2716236570, w=<optimized out>, events=<optimized out>) at src/unix/async.c:163 #27 0x00007f2717c6825d in uv__io_poll (loop=0x7f2716236570, timeout=<optimized out>) at src/unix/epoll.c:374 #28 0x00007f2717c5247a in uv__io_poll (timeout=<optimized out>, loop=0x7f2716236570) at src/unix/udp.c:122 #29 uv_run (loop=loop@entry=0x7f2716236570, mode=mode@entry=UV_RUN_DEFAULT) at src/unix/core.c:406 #30 0x00007f271762d834 in nm_thread (worker0=0x7f2716236560) at netmgr/netmgr.c:696 #31 0x00007f27176627f5 in isc__trampoline_run (arg=0x55d4dfe3ad70) at /usr/src/debug/bind-9.18.10/lib/isc/trampoline.c:189 #32 0x00007f2716c9398d in start_thread () from /lib64/libc.so.6 #33 0x00007f2716d19344 in clone () from /lib64/libc.so.6 BUG: https://bugzilla.samba.org/show_bug.cgi?id=14030 Signed-off-by: Samuel Cabrero <scabrero@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Autobuild-User(master): Samuel Cabrero <scabrero@samba.org> Autobuild-Date(master): Thu Jan 19 10:20:27 UTC 2023 on atb-devel-224
415 lines
12 KiB
C
415 lines
12 KiB
C
/*
|
|
Unix SMB/CIFS implementation.
|
|
|
|
DNS Server
|
|
|
|
Copyright (C) Amitay Isaacs 2011
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include "includes.h"
|
|
#include "dnsserver.h"
|
|
#include "rpc_server/common/common.h"
|
|
#include "dns_server/dnsserver_common.h"
|
|
#include "dsdb/samdb/samdb.h"
|
|
#include "lib/socket/netif.h"
|
|
#include "lib/util/util_net.h"
|
|
#include "dnsserver_common.h"
|
|
|
|
#undef strcasecmp
|
|
|
|
static struct DNS_ADDR_ARRAY *fill_dns_addr_array(TALLOC_CTX *mem_ctx,
|
|
struct loadparm_context *lp_ctx,
|
|
bool listen_only)
|
|
{
|
|
struct interface *ifaces;
|
|
int num_interfaces, i;
|
|
struct DNS_ADDR_ARRAY *dns_addr_array;
|
|
const char *ipstr;
|
|
bool have_ipv4, have_ipv6;
|
|
uint16_t family;
|
|
|
|
have_ipv4 = have_ipv6 = false;
|
|
|
|
if (!listen_only) {
|
|
/*
|
|
Return all interfaces from kernel
|
|
Not implemented!
|
|
*/
|
|
return NULL;
|
|
}
|
|
|
|
/* Only the used interfaces */
|
|
load_interface_list(mem_ctx, lp_ctx, &ifaces);
|
|
num_interfaces = iface_list_count(ifaces);
|
|
|
|
dns_addr_array = talloc_zero(mem_ctx, struct DNS_ADDR_ARRAY);
|
|
if (dns_addr_array == NULL) {
|
|
goto nomem;
|
|
}
|
|
dns_addr_array->MaxCount = num_interfaces;
|
|
dns_addr_array->AddrCount = num_interfaces;
|
|
if (num_interfaces == 0) {
|
|
goto nomem;
|
|
}
|
|
|
|
dns_addr_array->AddrArray = talloc_zero_array(mem_ctx, struct DNS_ADDR,
|
|
num_interfaces);
|
|
if (!dns_addr_array->AddrArray) {
|
|
TALLOC_FREE(dns_addr_array);
|
|
goto nomem;
|
|
}
|
|
|
|
for (i = 0; i < num_interfaces; i++) {
|
|
int ret;
|
|
ipstr = iface_list_n_ip(ifaces, i);
|
|
if (is_ipaddress_v4(ipstr)) {
|
|
have_ipv4 = true;
|
|
dns_addr_array->AddrArray[i].MaxSa[0] = 0x02;
|
|
ret = inet_pton(AF_INET, ipstr,
|
|
&dns_addr_array->AddrArray[i].MaxSa[4]);
|
|
} else {
|
|
have_ipv6 = true;
|
|
dns_addr_array->AddrArray[i].MaxSa[0] = 0x17;
|
|
ret = inet_pton(AF_INET6, ipstr,
|
|
&dns_addr_array->AddrArray[i].MaxSa[8]);
|
|
}
|
|
if (ret != 1) { /*yep, 1 means success for inet_pton */
|
|
DBG_ERR("Interface %d address (%s) is invalid\n",
|
|
i, ipstr);
|
|
goto nomem;
|
|
}
|
|
}
|
|
|
|
if (have_ipv4 && have_ipv6) {
|
|
family = 0; /* mixed: MS-DNSP */
|
|
} else if (have_ipv4 && !have_ipv6) {
|
|
family = AF_INET;
|
|
} else {
|
|
family = AF_INET6;
|
|
}
|
|
dns_addr_array->Family = family;
|
|
|
|
nomem:
|
|
talloc_free(ifaces);
|
|
return dns_addr_array;
|
|
}
|
|
|
|
struct dnsserver_serverinfo *dnsserver_init_serverinfo(TALLOC_CTX *mem_ctx,
|
|
struct loadparm_context *lp_ctx,
|
|
struct ldb_context *samdb)
|
|
{
|
|
struct dnsserver_serverinfo *serverinfo;
|
|
struct dcerpc_server_info *dinfo;
|
|
struct ldb_dn *domain_dn, *forest_dn;
|
|
|
|
serverinfo = talloc_zero(mem_ctx, struct dnsserver_serverinfo);
|
|
if (serverinfo == NULL) {
|
|
return NULL;
|
|
}
|
|
|
|
dinfo = lpcfg_dcerpc_server_info(mem_ctx, lp_ctx);
|
|
if (dinfo) {
|
|
serverinfo->dwVersion = (dinfo->version_build & 0x0000FFFF) << 16 |
|
|
(dinfo->version_minor & 0x000000FF) << 8 |
|
|
(dinfo->version_major & 0x000000FF);
|
|
talloc_free(dinfo);
|
|
} else {
|
|
serverinfo->dwVersion = 0x0ECE0205; /* build, os_minor, os_major */;
|
|
}
|
|
|
|
serverinfo->fBootMethod = DNS_BOOT_METHOD_DIRECTORY;
|
|
serverinfo->fAdminConfigured = 0;
|
|
serverinfo->fAllowUpdate = 1;
|
|
serverinfo->fDsAvailable = 1;
|
|
|
|
serverinfo->pszServerName = talloc_asprintf(mem_ctx, "%s.%s",
|
|
lpcfg_netbios_name(lp_ctx),
|
|
lpcfg_dnsdomain(lp_ctx));
|
|
|
|
domain_dn = ldb_get_default_basedn(samdb);
|
|
forest_dn = ldb_get_root_basedn(samdb);
|
|
|
|
serverinfo->pszDsContainer = talloc_asprintf(mem_ctx,
|
|
"CN=MicrosoftDNS,DC=DomainDnsZones,%s",
|
|
ldb_dn_get_linearized(domain_dn));
|
|
|
|
serverinfo->dwDsForestVersion = dsdb_forest_functional_level(samdb);
|
|
serverinfo->dwDsDomainVersion = dsdb_functional_level(samdb);
|
|
serverinfo->dwDsDsaVersion = dsdb_dc_functional_level(samdb);
|
|
|
|
serverinfo->pszDomainName = samdb_dn_to_dns_domain(mem_ctx, domain_dn);
|
|
serverinfo->pszForestName = samdb_dn_to_dns_domain(mem_ctx, forest_dn);
|
|
|
|
serverinfo->pszDomainDirectoryPartition = talloc_asprintf(mem_ctx,
|
|
"DC=DomainDnsZones,%s",
|
|
ldb_dn_get_linearized(domain_dn));
|
|
serverinfo->pszForestDirectoryPartition = talloc_asprintf(mem_ctx,
|
|
"DC=ForestDnsZones,%s",
|
|
ldb_dn_get_linearized(forest_dn));
|
|
/* IP addresses on which the DNS server listens for DNS requests */
|
|
serverinfo->aipListenAddrs = fill_dns_addr_array(mem_ctx, lp_ctx, true);
|
|
|
|
/* All IP addresses available on the server
|
|
* Not implemented!
|
|
* Use same as listen addresses
|
|
*/
|
|
serverinfo->aipServerAddrs = serverinfo->aipListenAddrs;
|
|
|
|
serverinfo->aipForwarders = NULL;
|
|
|
|
serverinfo->aipLogFilter = NULL;
|
|
serverinfo->pwszLogFilePath = NULL;
|
|
|
|
serverinfo->dwLogLevel = 0;
|
|
serverinfo->dwDebugLevel = 0;
|
|
serverinfo->dwEventLogLevel = DNS_EVENT_LOG_INFORMATION_TYPE;
|
|
serverinfo->dwLogFileMaxSize = 0;
|
|
|
|
serverinfo->dwForwardTimeout = 3; /* seconds (default) */
|
|
serverinfo->dwRpcProtocol = 5;
|
|
serverinfo->dwNameCheckFlag = DNS_ALLOW_MULTIBYTE_NAMES;
|
|
serverinfo->cAddressAnswerLimit = 0;
|
|
serverinfo->dwRecursionRetry = 3; /* seconds (default) */
|
|
serverinfo->dwRecursionTimeout = 8; /* seconds (default) */
|
|
serverinfo->dwMaxCacheTtl = 0x00015180; /* 1 day (default) */
|
|
serverinfo->dwDsPollingInterval = 0xB4; /* 3 minutes (default) */
|
|
serverinfo->dwLocalNetPriorityNetMask = 0x000000FF;
|
|
|
|
serverinfo->dwScavengingInterval = lpcfg_parm_int(
|
|
lp_ctx, NULL, "dnsserver", "ScavengingInterval", 24 * 7);
|
|
serverinfo->dwDefaultRefreshInterval = lpcfg_parm_int(
|
|
lp_ctx, NULL, "dnsserver", "DefaultRefreshInterval", 24 * 3);
|
|
serverinfo->dwDefaultNoRefreshInterval = lpcfg_parm_int(
|
|
lp_ctx, NULL, "dnsserver", "DefaultNoRefreshInterval", 24 * 3);
|
|
|
|
serverinfo->dwLastScavengeTime = 0;
|
|
|
|
serverinfo->fAutoReverseZones = 0;
|
|
serverinfo->fAutoCacheUpdate = 0;
|
|
|
|
serverinfo->fRecurseAfterForwarding = 0;
|
|
serverinfo->fForwardDelegations = 1;
|
|
serverinfo->fNoRecursion = 0;
|
|
serverinfo->fSecureResponses = 0;
|
|
|
|
serverinfo->fRoundRobin = 1;
|
|
serverinfo->fLocalNetPriority = 0;
|
|
|
|
serverinfo->fBindSecondaries = 0;
|
|
serverinfo->fWriteAuthorityNs = 0;
|
|
|
|
serverinfo->fStrictFileParsing = 0;
|
|
serverinfo->fLooseWildcarding = 0 ;
|
|
serverinfo->fDefaultAgingState = 0;
|
|
|
|
return serverinfo;
|
|
}
|
|
|
|
struct dnsserver_zoneinfo *dnsserver_init_zoneinfo(struct dnsserver_zone *zone,
|
|
struct dnsserver_serverinfo *serverinfo)
|
|
{
|
|
struct dnsserver_zoneinfo *zoneinfo;
|
|
uint32_t fReverse;
|
|
const char *revzone = "in-addr.arpa";
|
|
const char *revzone6 = "ip6.arpa";
|
|
int len1, len2;
|
|
unsigned int i = 0;
|
|
|
|
zoneinfo = talloc_zero(zone, struct dnsserver_zoneinfo);
|
|
if (zoneinfo == NULL) {
|
|
return NULL;
|
|
}
|
|
|
|
/* If the zone name ends with in-addr.arpa, it's reverse zone */
|
|
/* If the zone name ends with ip6.arpa, it's reverse zone (IPv6) */
|
|
fReverse = 0;
|
|
len1 = strlen(zone->name);
|
|
len2 = strlen(revzone);
|
|
if (len1 > len2 && strcasecmp(&zone->name[len1-len2], revzone) == 0) {
|
|
fReverse = 1;
|
|
} else {
|
|
len2 = strlen(revzone6);
|
|
if (len1 > len2 && strcasecmp(&zone->name[len1-len2], revzone6) == 0) {
|
|
fReverse = 1;
|
|
}
|
|
}
|
|
|
|
zoneinfo->Version = 0x32;
|
|
zoneinfo->Flags = DNS_RPC_ZONE_DSINTEGRATED;
|
|
|
|
if (strcmp(zone->name, ".") == 0) {
|
|
zoneinfo->dwZoneType = DNS_ZONE_TYPE_CACHE;
|
|
zoneinfo->fAllowUpdate = DNS_ZONE_UPDATE_OFF;
|
|
zoneinfo->fSecureSecondaries = DNS_ZONE_SECSECURE_NO_SECURITY;
|
|
zoneinfo->fNotifyLevel = DNS_ZONE_NOTIFY_OFF;
|
|
zoneinfo->dwNoRefreshInterval = 0;
|
|
zoneinfo->dwRefreshInterval = 0;
|
|
} else {
|
|
zoneinfo->Flags |= DNS_RPC_ZONE_UPDATE_SECURE;
|
|
zoneinfo->dwZoneType = DNS_ZONE_TYPE_PRIMARY;
|
|
zoneinfo->fAllowUpdate = DNS_ZONE_UPDATE_SECURE;
|
|
zoneinfo->fSecureSecondaries = DNS_ZONE_SECSECURE_NO_XFER;
|
|
zoneinfo->fNotifyLevel = DNS_ZONE_NOTIFY_LIST_ONLY;
|
|
zoneinfo->dwNoRefreshInterval = serverinfo->dwDefaultNoRefreshInterval;
|
|
zoneinfo->dwRefreshInterval = serverinfo->dwDefaultRefreshInterval;
|
|
}
|
|
|
|
zoneinfo->fReverse = fReverse;
|
|
zoneinfo->fPaused = 0;
|
|
zoneinfo->fShutdown = 0;
|
|
zoneinfo->fAutoCreated = 0;
|
|
zoneinfo->fUseDatabase = 1;
|
|
zoneinfo->pszDataFile = NULL;
|
|
zoneinfo->aipMasters = NULL;
|
|
zoneinfo->aipSecondaries = NULL;
|
|
zoneinfo->aipNotify = NULL;
|
|
zoneinfo->fUseWins = 0;
|
|
zoneinfo->fUseNbstat = 0;
|
|
zoneinfo->fAging = 0;
|
|
zoneinfo->dwAvailForScavengeTime = 0;
|
|
zoneinfo->aipScavengeServers = NULL;
|
|
zoneinfo->dwForwarderTimeout = 0;
|
|
zoneinfo->fForwarderSlave = 0;
|
|
zoneinfo->aipLocalMasters = NULL;
|
|
zoneinfo->pwszZoneDn = discard_const_p(char, ldb_dn_get_linearized(zone->zone_dn));
|
|
zoneinfo->dwLastSuccessfulSoaCheck = 0;
|
|
zoneinfo->dwLastSuccessfulXfr = 0;
|
|
zoneinfo->fQueuedForBackgroundLoad = 0;
|
|
zoneinfo->fBackgroundLoadInProgress = 0;
|
|
zoneinfo->fReadOnlyZone = 0;
|
|
zoneinfo->dwLastXfrAttempt = 0;
|
|
zoneinfo->dwLastXfrResult = 0;
|
|
|
|
for(i=0; i<zone->num_props; i++){
|
|
bool valid_property;
|
|
valid_property = dns_zoneinfo_load_zone_property(
|
|
zoneinfo, &zone->tmp_props[i]);
|
|
if (!valid_property) {
|
|
TALLOC_FREE(zoneinfo);
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
return zoneinfo;
|
|
}
|
|
|
|
struct dnsserver_zone *dnsserver_find_zone(struct dnsserver_zone *zones, const char *zone_name)
|
|
{
|
|
struct dnsserver_zone *z = NULL;
|
|
|
|
for (z = zones; z; z = z->next) {
|
|
if (samba_dns_name_equal(zone_name, z->name)) {
|
|
break;
|
|
}
|
|
}
|
|
|
|
return z;
|
|
}
|
|
|
|
struct ldb_dn *dnsserver_name_to_dn(TALLOC_CTX *mem_ctx, struct dnsserver_zone *z, const char *name)
|
|
{
|
|
struct ldb_dn *dn;
|
|
bool ret;
|
|
struct ldb_val name_val =
|
|
data_blob_string_const(name);
|
|
|
|
dn = ldb_dn_copy(mem_ctx, z->zone_dn);
|
|
if (dn == NULL) {
|
|
return NULL;
|
|
}
|
|
if (strcasecmp(name, z->name) == 0) {
|
|
ret = ldb_dn_add_child_fmt(dn, "DC=@");
|
|
if (!ret) {
|
|
talloc_free(dn);
|
|
return NULL;
|
|
}
|
|
return dn;
|
|
}
|
|
|
|
ret = ldb_dn_add_child_val(dn,
|
|
"DC",
|
|
name_val);
|
|
|
|
if (!ret) {
|
|
talloc_free(dn);
|
|
return NULL;
|
|
}
|
|
|
|
return dn;
|
|
}
|
|
|
|
uint32_t dnsserver_zone_to_request_filter(const char *zone_name)
|
|
{
|
|
uint32_t request_filter = 0;
|
|
|
|
if (strcmp(zone_name, "..AllZones") == 0) {
|
|
request_filter = DNS_ZONE_REQUEST_PRIMARY
|
|
| DNS_ZONE_REQUEST_SECONDARY
|
|
| DNS_ZONE_REQUEST_AUTO
|
|
| DNS_ZONE_REQUEST_FORWARD
|
|
| DNS_ZONE_REQUEST_REVERSE
|
|
| DNS_ZONE_REQUEST_FORWARDER
|
|
| DNS_ZONE_REQUEST_STUB
|
|
| DNS_ZONE_REQUEST_DS
|
|
| DNS_ZONE_REQUEST_NON_DS
|
|
| DNS_ZONE_REQUEST_DOMAIN_DP
|
|
| DNS_ZONE_REQUEST_FOREST_DP
|
|
| DNS_ZONE_REQUEST_CUSTOM_DP
|
|
| DNS_ZONE_REQUEST_LEGACY_DP;
|
|
} else if (strcmp(zone_name, "..AllZonesAndCache") == 0) {
|
|
request_filter = DNS_ZONE_REQUEST_PRIMARY
|
|
| DNS_ZONE_REQUEST_SECONDARY
|
|
| DNS_ZONE_REQUEST_CACHE
|
|
| DNS_ZONE_REQUEST_AUTO
|
|
| DNS_ZONE_REQUEST_FORWARD
|
|
| DNS_ZONE_REQUEST_REVERSE
|
|
| DNS_ZONE_REQUEST_FORWARDER
|
|
| DNS_ZONE_REQUEST_STUB
|
|
| DNS_ZONE_REQUEST_DS
|
|
| DNS_ZONE_REQUEST_NON_DS
|
|
| DNS_ZONE_REQUEST_DOMAIN_DP
|
|
| DNS_ZONE_REQUEST_FOREST_DP
|
|
| DNS_ZONE_REQUEST_CUSTOM_DP
|
|
| DNS_ZONE_REQUEST_LEGACY_DP;
|
|
} else if (strcmp(zone_name, "..AllPrimaryZones") == 0) {
|
|
request_filter = DNS_ZONE_REQUEST_PRIMARY;
|
|
} else if (strcmp(zone_name, "..AllSecondaryZones") == 0) {
|
|
request_filter = DNS_ZONE_REQUEST_SECONDARY;
|
|
} else if (strcmp(zone_name, "..AllForwardZones") == 0) {
|
|
request_filter = DNS_ZONE_REQUEST_FORWARD;
|
|
} else if (strcmp(zone_name, "..AllReverseZones") == 0) {
|
|
request_filter = DNS_ZONE_REQUEST_REVERSE;
|
|
} else if (strcmp(zone_name, "..AllDsZones") == 0) {
|
|
request_filter = DNS_ZONE_REQUEST_DS;
|
|
} else if (strcmp(zone_name, "..AllNonDsZones") == 0) {
|
|
request_filter = DNS_ZONE_REQUEST_NON_DS;
|
|
} else if (strcmp(zone_name, "..AllPrimaryReverseZones") == 0) {
|
|
request_filter = DNS_ZONE_REQUEST_PRIMARY
|
|
| DNS_ZONE_REQUEST_REVERSE;
|
|
} else if (strcmp(zone_name, "..AllPrimaryForwardZones") == 0) {
|
|
request_filter = DNS_ZONE_REQUEST_PRIMARY
|
|
| DNS_ZONE_REQUEST_FORWARD;
|
|
} else if (strcmp(zone_name, "..AllSecondaryReverseZones") == 0) {
|
|
request_filter = DNS_ZONE_REQUEST_SECONDARY
|
|
| DNS_ZONE_REQUEST_REVERSE;
|
|
} else if (strcmp(zone_name, "..AllSecondaryForwardZones") == 0) {
|
|
request_filter = DNS_ZONE_REQUEST_SECONDARY
|
|
| DNS_ZONE_REQUEST_REVERSE;
|
|
}
|
|
|
|
return request_filter;
|
|
}
|