s4-dfs_server: check for netbios aliases in ad_get_referrals
authorBjörn Baumbach <bb@sernet.de>
Wed, 5 Jun 2013 13:01:14 +0000 (15:01 +0200)
committerMichael Adam <obnox@samba.org>
Mon, 10 Jun 2013 23:12:07 +0000 (01:12 +0200)
Without this patch ad_get_referrals checks for netbios, dns names
and ip, but not for netbios aliases set by netbios aliases option,
whether the requested name is our dns name.

Pair-programmed-with: Stefan Metzmacher <metze@samba.org>

Signed-off-by: Björn Baumbach <bb@sernet.de>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
Autobuild-User(master): Michael Adam <obnox@samba.org>
Autobuild-Date(master): Tue Jun 11 01:12:08 CEST 2013 on sn-devel-104

dfs_server/dfs_server_ad.c

index 4d3891a..249a1d1 100644 (file)
@@ -751,6 +751,7 @@ NTSTATUS dfs_server_ad_get_referrals(struct loadparm_context *lp_ctx,
        const char *dns_domain;
        const char *netbios_name;
        const char *dns_name;
+       const char **netbios_aliases;
 
        if (!lpcfg_host_msdfs(lp_ctx)) {
                return NT_STATUS_FS_DRIVER_REQUIRED;
@@ -827,6 +828,40 @@ NTSTATUS dfs_server_ad_get_referrals(struct loadparm_context *lp_ctx,
                return NT_STATUS_NOT_FOUND;
        }
 
+       netbios_aliases = lpcfg_netbios_aliases(lp_ctx);
+       while (netbios_aliases && *netbios_aliases) {
+               const char *netbios_alias = *netbios_aliases;
+               char *dns_alias;
+               int cmp;
+
+               cmp = strcasecmp_m(server_name, netbios_alias);
+               if (cmp == 0) {
+                       /*
+                        * If it is not domain related do not
+                        * handle it here.
+                        */
+                       return NT_STATUS_NOT_FOUND;
+               }
+
+               dns_alias = talloc_asprintf(r, "%s.%s",
+                                           netbios_alias,
+                                           dns_domain);
+               if (dns_alias == NULL) {
+                       return NT_STATUS_NO_MEMORY;
+               }
+
+               cmp = strcasecmp_m(server_name, dns_alias);
+               talloc_free(dns_alias);
+               if (cmp == 0) {
+                       /*
+                        * If it is not domain related do not
+                        * handle it here.
+                        */
+                       return NT_STATUS_NOT_FOUND;
+               }
+               netbios_aliases++;
+       }
+
        if ((strcasecmp_m(server_name, netbios_domain) != 0) &&
            (strcasecmp_m(server_name, dns_domain) != 0)) {
                /*