From c86c275068d89c5e106a3b474eff750d2367017c Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Wed, 17 Jul 2019 13:22:39 -0700 Subject: ifconfig: fix for non-root on Android. The change from ioctl to xioctl in 844f0d1aae28c54bbb672f53ba2cda182c572129 broke ifconfig for non-root on Android. SIOCGIFHWADDR has been protected to prevent device tracking since Nougat. Bug: https://issuetracker.google.com/137671590 --- toys/net/ifconfig.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/toys/net/ifconfig.c b/toys/net/ifconfig.c index dbe66d39..f8f1277e 100644 --- a/toys/net/ifconfig.c +++ b/toys/net/ifconfig.c @@ -133,8 +133,9 @@ static void display_ifconfig(char *name, int always, unsigned long long val[]) printf("%*c", 29-len, ' '); } - // query hardware type and hardware address - xioctl(TT.sockfd, SIOCGIFHWADDR, &ifre); + // Query hardware type and hardware address. + // Not xioctl because you don't have permission for this on Android. + ioctl(TT.sockfd, SIOCGIFHWADDR, &ifre); if (toys.optflags&FLAG_S) for (i=0; i<6; i++) printf(":%02x"+!i, ifre.ifr_hwaddr.sa_data[i]); -- cgit v1.2.3