summaryrefslogtreecommitdiff
path: root/source4/lib/replace
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 00:06:55 +0100
commit53654f5caf701a32b615bed784d78765f351cb73 (patch)
treedf37d6db428e3e2da8bc2f65a54c0ebb8e81cb6c /source4/lib/replace
parentc9fb4f05f42209ed383e4e84954b549687fe6d6d (diff)
downloadsamba-53654f5caf701a32b615bed784d78765f351cb73.tar.gz
samba-53654f5caf701a32b615bed784d78765f351cb73.tar.bz2
samba-53654f5caf701a32b615bed784d78765f351cb73.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 (This used to be commit ee170c85e0e76411bd752de5fe51db6940dab929)
Diffstat (limited to 'source4/lib/replace')
-rw-r--r--source4/lib/replace/getifaddrs.c37
1 files changed, 16 insertions, 21 deletions
diff --git a/source4/lib/replace/getifaddrs.c b/source4/lib/replace/getifaddrs.c
index 551ff863df..f66bf800eb 100644
--- a/source4/lib/replace/getifaddrs.c
+++ b/source4/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;
}