termux-packages/packages/cfengine/unix_iface.patch

52 lines
2.1 KiB
Diff
Raw Normal View History

diff --git a/libenv/unix_iface.c b/libenv/unix_iface.c
index 65e359921..905e13c84 100644
--- a/libenv/unix_iface.c
+++ b/libenv/unix_iface.c
@@ -147,7 +147,7 @@ static void GetMacAddress(EvalContext *ctx, ARG_UNUSED int fd, struct ifreq *ifr
return;
}
-# if defined(SIOCGIFHWADDR) && defined(HAVE_STRUCT_IFREQ_IFR_HWADDR)
+# if defined(SIOCGIFHWADDR) && defined(HAVE_STRUCT_IFREQ_IFR_HWADDR) && !defined(__TERMUX__)
char hw_mac[CF_MAXVARSIZE];
if ((ioctl(fd, SIOCGIFHWADDR, ifr) == -1))
@@ -173,9 +173,8 @@ static void GetMacAddress(EvalContext *ctx, ARG_UNUSED int fd, struct ifreq *ifr
# elif defined(HAVE_GETIFADDRS) && !defined(__sun)
char hw_mac[CF_MAXVARSIZE];
- char *m;
struct ifaddrs *ifaddr, *ifa;
- struct sockaddr_dl *sdl;
+ struct sockaddr_ll *sdl;
if (getifaddrs(&ifaddr) == -1)
{
@@ -190,18 +189,16 @@ static void GetMacAddress(EvalContext *ctx, ARG_UNUSED int fd, struct ifreq *ifr
{
if ( strcmp(ifa->ifa_name, ifp->ifr_name) == 0)
{
- if (ifa->ifa_addr->sa_family == AF_LINK)
+ if (ifa->ifa_addr->sa_family == AF_PACKET)
{
- sdl = (struct sockaddr_dl *)ifa->ifa_addr;
- m = (char *) LLADDR(sdl);
-
+ sdl = (struct sockaddr_ll*)ifa->ifa_addr;
snprintf(hw_mac, sizeof(hw_mac), "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x",
- (unsigned char) m[0],
- (unsigned char) m[1],
- (unsigned char) m[2],
- (unsigned char) m[3],
- (unsigned char) m[4],
- (unsigned char) m[5]);
+ sdl->sll_addr[0],
+ sdl->sll_addr[1],
+ sdl->sll_addr[2],
+ sdl->sll_addr[3],
+ sdl->sll_addr[4],
+ sdl->sll_addr[5]);
EvalContextVariablePutSpecial(ctx, SPECIAL_SCOPE_SYS, name, hw_mac, CF_DATA_TYPE_STRING, "source=agent");
RlistAppend(hardware, hw_mac, RVAL_TYPE_SCALAR);