[PATCH] obey "interfaces" smb.conf option on AD DNS update
David Disseldorp
ddiss at sgi.com
Fri May 23 07:58:39 GMT 2008
When performing an AD DNS update, Samba currently re-probes all interfaces
and adds non-loopback IPs to the DNS.
As load_interfaces() is called by net:main() (which take "interfaces"
smb.conf into account) there is no need to do the re-probe.
---
source/utils/net_dns.c | 27 ++++++++++++++++-----------
1 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/source/utils/net_dns.c b/source/utils/net_dns.c
index 14d45e2..2a7baf9 100644
--- a/source/utils/net_dns.c
+++ b/source/utils/net_dns.c
@@ -145,16 +145,15 @@ error:
int get_my_ip_address( struct sockaddr_storage **pp_ss )
{
- struct iface_struct nics[MAX_INTERFACES];
int i, n;
struct sockaddr_storage *list = NULL;
+ struct sockaddr_storage *this_saddr;
int count = 0;
- /* find the first non-loopback address from our list of interfaces */
+ /* load_interfaces() must have been called before we do this */
+ n = iface_count();
- n = get_interfaces(nics, MAX_INTERFACES);
-
- if (n <= 0) {
+ if ((n <= 0) || (n >= MAX_INTERFACES)) {
return -1;
}
@@ -163,22 +162,28 @@ int get_my_ip_address( struct sockaddr_storage **pp_ss )
}
for ( i=0; i<n; i++ ) {
- if (is_loopback_addr(&nics[i].ip)) {
+ this_saddr = iface_n_sockaddr_storage(i);
+ if ((this_saddr == NULL) || is_loopback_addr(this_saddr)) {
continue;
}
#if defined(HAVE_IPV6)
- if ((nics[i].ip.ss_family == AF_INET6)) {
- memcpy(&list[count++], &nics[i].ip,
+ if ((this_saddr->ss_family == AF_INET6)) {
+ memcpy(&list[count++], this_saddr,
sizeof(struct sockaddr_storage));
} else
#endif
- if (nics[i].ip.ss_family == AF_INET) {
- memcpy(&list[count++], &nics[i].ip,
+ if (this_saddr->ss_family == AF_INET) {
+ memcpy(&list[count++], this_saddr,
sizeof(struct sockaddr_storage));
}
}
- *pp_ss = list;
+ if (count <= 0) {
+ /* nothing on the list */
+ SAFE_FREE(list);
+ list = NULL;
+ }
+ *pp_ss = list;
return count;
}
--
1.5.4.rc0
More information about the samba-technical
mailing list