fix system breakage window during make install due to permissions
[musl] / src / network / getifaddrs.c
index a4c3178..5a94cc7 100644 (file)
@@ -11,6 +11,7 @@
 #include <arpa/inet.h> /* inet_pton */
 #include <unistd.h>
 #include <sys/ioctl.h>
+#include <sys/socket.h>
 
 typedef union {
        struct sockaddr_in6 v6;
@@ -66,7 +67,7 @@ static void ipv6netmask(unsigned prefix_length, struct sockaddr_in6 *sa)
 
 static void dealwithipv6(stor **list, stor** head)
 {
-       FILE* f = fopen("/proc/net/if_inet6", "r");
+       FILE* f = fopen("/proc/net/if_inet6", "rbe");
        /* 00000000000000000000000000000001 01 80 10 80 lo
           A                                B  C  D  E  F
           all numbers in hex
@@ -127,7 +128,7 @@ int getifaddrs(struct ifaddrs **ifap)
        }
        if_freenameindex(ii);
 
-       int sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP);
+       int sock = socket(PF_INET, SOCK_DGRAM|SOCK_CLOEXEC, IPPROTO_IP);
        if(sock == -1) goto err2;
        struct ifreq reqs[32]; /* arbitrary chosen boundary */
        struct ifconf conf = {.ifc_len = sizeof reqs, .ifc_req = reqs};