summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2008-02-29 00:06:55 +0100
committerMichael Adam <obnox@samba.org>2008-02-29 09:31:19 +0100
commit39cae1d5b7dc987fd1457b5e4e4e9c15baf17086 (patch)
treedc120a025e0e8b529554c59713fb1a5f84f3643a
parentca237a3ad31a8bba18297042df670e3a710ca10e (diff)
downloadsamba-39cae1d5b7dc987fd1457b5e4e4e9c15baf17086.tar.gz
samba-39cae1d5b7dc987fd1457b5e4e4e9c15baf17086.tar.bz2
samba-39cae1d5b7dc987fd1457b5e4e4e9c15baf17086.zip
libreplace: try and fix rep_getifaddrs() for Tru64.
Don't fail when there is no address assigned to the interface. Put NULL into the ifaddrs structure instead. Michael (cherry picked from commit ee170c85e0e76411bd752de5fe51db6940dab929) (This used to be commit 650cc1da4b4404880389c583dbb07ce86df48576)
-rw-r--r--source3/lib/replace/getifaddrs.c37
1 files changed, 16 insertions, 21 deletions
diff --git a/source3/lib/replace/getifaddrs.c b/source3/lib/replace/getifaddrs.c
index 551ff863df..f66bf800eb 100644
--- a/source3/lib/replace/getifaddrs.c
+++ b/source3/lib/replace/getifaddrs.c
@@ -109,38 +109,33 @@ int rep_getifaddrs(struct ifaddrs **ifap)
/* Loop through interfaces, looking for given IP address */
for (i=n-1; i>=0; i--) {
- if (ioctl(fd, SIOCGIFADDR, &ifr[i]) != 0) {
+ if (ioctl(fd, SIOCGIFFLAGS, &ifr[i]) == -1) {
freeifaddrs(*ifap);
+ return -1;
}
curif = calloc(1, sizeof(struct ifaddrs));
- if (lastif == NULL) {
- *ifap = curif;
- } else {
- lastif->ifa_next = curif;
- }
-
curif->ifa_name = strdup(ifr[i].ifr_name);
- curif->ifa_addr = sockaddr_dup(&ifr[i].ifr_addr);
+ curif->ifa_flags = ifr[i].ifr_flags;
curif->ifa_dstaddr = NULL;
curif->ifa_data = NULL;
curif->ifa_next = NULL;
- curif->ifa_netmask = NULL;
-
- if (ioctl(fd, SIOCGIFFLAGS, &ifr[i]) != 0) {
- freeifaddrs(*ifap);
- return -1;
- }
- curif->ifa_flags = ifr[i].ifr_flags;
-
- if (ioctl(fd, SIOCGIFNETMASK, &ifr[i]) != 0) {
- freeifaddrs(*ifap);
- return -1;
- }
+ curif->ifa_addr = NULL
+ if (ioctl(fd, SIOCGIFADDR, &ifr[i]) != -1) {
+ curif->ifa_addr = sockaddr_dup(&ifr[i].ifr_addr);
+ }
- curif->ifa_netmask = sockaddr_dup(&ifr[i].ifr_addr);
+ curif->ifa_netmask = NULL;
+ if (ioctl(fd, SIOCGIFNETMASK, &ifr[i]) != -1) {
+ curif->ifa_netmask = sockaddr_dup(&ifr[i].ifr_addr);
+ }
+ if (lastif == NULL) {
+ *ifap = curif;
+ } else {
+ lastif->ifa_next = curif;
+ }
lastif = curif;
}