nightmaremail

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit b8fb15d71f70bddff87ea5aa2b56b0da0f91bea7
parent 390afb7cf05fbafef68788c6388037bf87d1f862
Author: Rolf Eike Beer <eike@sf-mail.de>
Date:   Thu, 29 Aug 2019 20:37:03 +0200

ipme: fix detection of multiple IP addresses on the same link

The problem was that the code did another ioctl() to check if the link is
actually up, and when doing this overwrites the information it is currently
looking at. The code when sa_len is available copies the current IP address out
before checking if the link is up. Reorder the code so both branches share more
code and both work.

Diffstat:
MCHANGES | 2++
Mipme.c | 14+++-----------
2 files changed, 5 insertions(+), 11 deletions(-)

diff --git a/CHANGES b/CHANGES @@ -1,3 +1,5 @@ +20190919 fix ipme with multiple addresses on the same interface on platforms + without sa_len 20190904 code: use stdint.h to get the definition for uint32 20190903 code: do not parse header recipients for "qmail-inject -a" 20190826 code: if $QMAILREMOTE is set, it's invoked instead of qmail-remote. diff --git a/ipme.c b/ipme.c @@ -89,6 +89,9 @@ int ipme_init() len = sizeof(ifr->ifr_name) + ifr->ifr_addr.sa_len; if (len < sizeof(*ifr)) len = sizeof(*ifr); +#else + len = sizeof(*ifr); +#endif if (ifr->ifr_addr.sa_family == AF_INET) { sin = (struct sockaddr_in *) &ifr->ifr_addr; byte_copy(&ix.ip,4,&sin->sin_addr); @@ -96,17 +99,6 @@ int ipme_init() if (ifr->ifr_flags & IFF_UP) if (!ipalloc_append(&ipme,&ix)) { close(s); return 0; } } -#else - len = sizeof(*ifr); - if (ioctl(s,SIOCGIFFLAGS,x) == 0) - if (ifr->ifr_flags & IFF_UP) - if (ioctl(s,SIOCGIFADDR,x) == 0) - if (ifr->ifr_addr.sa_family == AF_INET) { - sin = (struct sockaddr_in *) &ifr->ifr_addr; - byte_copy(&ix.ip,4,&sin->sin_addr); - if (!ipalloc_append(&ipme,&ix)) { close(s); return 0; } - } -#endif x += len; } close(s);