net: Don't register link local addresses with DNS
[mat/samba.git] / source3 / utils / net_dns.c
index f4ad6f7b4761188b5f908f4ae25989041cec6c95..f146f29bcd41b7b1fc4fe9bfab362493fbae9e0f 100644 (file)
@@ -1,4 +1,3 @@
-
 /* 
    Samba Unix/Linux Dynamic DNS Update
    net ads commands
    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 "utils/net.h"
-#include "dns.h"
+#include "../lib/addns/dns.h"
 
 #if defined(WITH_DNS_UPDATES)
-
 /*
  * Silly prototype to get rid of a warning
  */
@@ -55,7 +53,7 @@ DNS_ERROR DoDNSUpdate(char *pszServerName,
        if (!(mem_ctx = talloc_init("DoDNSUpdate"))) {
                return ERROR_DNS_NO_MEMORY;
        }
-               
+
        err = dns_open_connection( pszServerName, DNS_TCP, mem_ctx, &conn );
        if (!ERR_DNS_IS_OK(err)) {
                goto error;
@@ -114,10 +112,9 @@ DNS_ERROR DoDNSUpdate(char *pszServerName,
                                                     keyname, &gss_context, 
                                                     DNS_SRV_WIN2000 );
                }
-               
+
                if (!ERR_DNS_IS_OK(err))
                        goto error;
-               
 
                err = dns_sign_update(req, gss_context, keyname,
                                      "gss.microsoft.com", time(NULL), 3600);
@@ -173,6 +170,11 @@ int get_my_ip_address( struct sockaddr_storage **pp_ss )
                        continue;
                }
 
+               /* Don't register link-local addresses */
+               if (is_linklocal_addr(nic_sa_storage)) {
+                       continue;
+               }
+
                memcpy(&list[count++], nic_sa_storage, sizeof(struct sockaddr_storage));
        }
        *pp_ss = list;