From 9f76e076fa2593fdc67c3b82fb262670154bad09 Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Wed, 14 Dec 2011 16:17:31 +1100 Subject: s4:rpc-dnsserver: If a zone is reverse zone, set the fReverse flag And use fReverse flag in the enumeration of zones. --- source4/rpc_server/dnsserver/dcerpc_dnsserver.c | 4 ++-- source4/rpc_server/dnsserver/dnsutils.c | 13 ++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/source4/rpc_server/dnsserver/dcerpc_dnsserver.c b/source4/rpc_server/dnsserver/dcerpc_dnsserver.c index e1966fa6fc..98e935ca99 100644 --- a/source4/rpc_server/dnsserver/dcerpc_dnsserver.c +++ b/source4/rpc_server/dnsserver/dcerpc_dnsserver.c @@ -1165,12 +1165,12 @@ static WERROR dnsserver_complex_operate_server(struct dnsserver_state *dsstate, found2 = false; if (rin->Dword & 0x000000f0) { if (rin->Dword & DNS_ZONE_REQUEST_FORWARD) { - if (!(z->zoneinfo->Flags & DNS_RPC_ZONE_REVERSE)) { + if (!(z->zoneinfo->fReverse)) { found2 = true; } } if (rin->Dword & DNS_ZONE_REQUEST_REVERSE) { - if (z->zoneinfo->Flags & DNS_RPC_ZONE_REVERSE) { + if (z->zoneinfo->fReverse) { found2 = true; } } diff --git a/source4/rpc_server/dnsserver/dnsutils.c b/source4/rpc_server/dnsserver/dnsutils.c index 1f5edae2da..3ae47a8c5f 100644 --- a/source4/rpc_server/dnsserver/dnsutils.c +++ b/source4/rpc_server/dnsserver/dnsutils.c @@ -159,6 +159,9 @@ struct dnsserver_zoneinfo *dnsserver_init_zoneinfo(struct dnsserver_zone *zone, { struct dnsserver_zoneinfo *zoneinfo; uint32_t dp_flags; + uint32_t fReverse; + const char *revzone = "in-addr.arpa"; + int len1, len2; zoneinfo = talloc_zero(zone, struct dnsserver_zoneinfo); if (zoneinfo == NULL) { @@ -172,10 +175,18 @@ struct dnsserver_zoneinfo *dnsserver_init_zoneinfo(struct dnsserver_zone *zone, dp_flags |= DNS_DP_DOMAIN_DEFAULT; } + /* If the zone name ends with in-addr.arpa, it's reverse zone */ + fReverse = 0; + len1 = strlen(zone->name); + len2 = strlen(revzone); + if (len1 > len2 && strcmp(&zone->name[len1-len2], revzone) == 0) { + fReverse = 1; + } + zoneinfo->Version = 0x32; zoneinfo->Flags = DNS_RPC_ZONE_DSINTEGRATED | DNS_RPC_ZONE_UPDATE_SECURE; zoneinfo->dwZoneType = DNS_ZONE_TYPE_PRIMARY; - zoneinfo->fReverse = 0; /* We only support forward zones for now */ + zoneinfo->fReverse = fReverse; zoneinfo->fAllowUpdate = DNS_ZONE_UPDATE_SECURE; zoneinfo->fPaused = 0; zoneinfo->fShutdown = 0; -- cgit