ifconfig: fix for non-root on Android.

The change from ioctl to xioctl in
844f0d1aae broke ifconfig for non-root on
Android. SIOCGIFHWADDR has been protected to prevent device tracking
since Nougat.

Bug: https://issuetracker.google.com/137671590
This commit is contained in:
Elliott Hughes 2019-07-17 13:22:39 -07:00 committed by Rob Landley
parent 25bfbb69be
commit c86c275068

View File

@ -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]);