From owner-freebsd-ports-bugs@FreeBSD.ORG Sat Mar 8 08:30:01 2014 Return-Path: Delivered-To: freebsd-ports-bugs@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 6B572B47 for ; Sat, 8 Mar 2014 08:30:01 +0000 (UTC) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 47743A0C for ; Sat, 8 Mar 2014 08:30:01 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.8/8.14.8) with ESMTP id s288U1hE050286 for ; Sat, 8 Mar 2014 08:30:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.8/8.14.8/Submit) id s288U1bK050285; Sat, 8 Mar 2014 08:30:01 GMT (envelope-from gnats) Resent-Date: Sat, 8 Mar 2014 08:30:01 GMT Resent-Message-Id: <201403080830.s288U1bK050285@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, clutton Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 65DE5AEA for ; Sat, 8 Mar 2014 08:23:04 +0000 (UTC) Received: from cgiserv.freebsd.org (cgiserv.freebsd.org [IPv6:2001:1900:2254:206a::50:4]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 520A09E5 for ; Sat, 8 Mar 2014 08:23:04 +0000 (UTC) Received: from cgiserv.freebsd.org ([127.0.1.6]) by cgiserv.freebsd.org (8.14.8/8.14.8) with ESMTP id s288N37l024694 for ; Sat, 8 Mar 2014 08:23:03 GMT (envelope-from nobody@cgiserv.freebsd.org) Received: (from nobody@localhost) by cgiserv.freebsd.org (8.14.8/8.14.8/Submit) id s288N3gw024690; Sat, 8 Mar 2014 08:23:03 GMT (envelope-from nobody) Message-Id: <201403080823.s288N3gw024690@cgiserv.freebsd.org> Date: Sat, 8 Mar 2014 08:23:03 GMT From: clutton To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Subject: ports/187363: [new port][net/macchanger] GNU macchanger port for the FreeBSD system X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 08 Mar 2014 08:30:01 -0000 >Number: 187363 >Category: ports >Synopsis: [new port][net/macchanger] GNU macchanger port for the FreeBSD system >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sat Mar 08 08:30:00 UTC 2014 >Closed-Date: >Last-Modified: >Originator: clutton >Release: >Organization: >Environment: >Description: GNU macchanger is a good tool because of it's mac's addresses database. The pool request https://github.com/alobbs/macchanger/pull/9 I hope patches will be accepted in new versions, for now I'd like to start by providing a working version. One feature was commented, because I don't know how to implement it now... >How-To-Repeat: >Fix: Patch attached with submission follows: # This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # macchanger # macchanger/pkg-plist # macchanger/files # macchanger/files/patch-src_netinfo.h # macchanger/files/patch-src_netinfo.c # macchanger/files/patch-src_main.c # macchanger/Makefile # macchanger/distinfo # macchanger/pkg-descr # echo c - macchanger mkdir -p macchanger > /dev/null 2>&1 echo x - macchanger/pkg-plist sed 's/^X//' >macchanger/pkg-plist << 'd03b69c5dadd960b1ea1d2397b6ac821' Xbin/macchanger Xman/man1/macchanger.1.gz X%%DATADIR%%/OUI.list X%%DATADIR%%/wireless.list X@dirrmtry %%DATADIR%% d03b69c5dadd960b1ea1d2397b6ac821 echo c - macchanger/files mkdir -p macchanger/files > /dev/null 2>&1 echo x - macchanger/files/patch-src_netinfo.h sed 's/^X//' >macchanger/files/patch-src_netinfo.h << 'cb21b643c2b0f08fdb9e24dc4956a846' X--- src/netinfo.h 2013-03-17 00:54:41.000000000 +0200 X+++ src/netinfo.h 2014-03-08 07:14:58.334245891 +0200 X@@ -30,6 +30,17 @@ X #include X #include "mac.h" X X+#ifdef __linux__ X+#define sockaddr_dl sockaddr_ll X+#define sdl_family sll_family X+#define AF_LINK AF_PACKET X+#define LLADDR(s) s->sll_addr; X+#endif X+ X+#ifdef __FreeBSD__ X+#define SIOCSIFHWADDR SIOCSIFLLADDR X+#endif X+ X typedef struct { X int sock; X struct ifreq dev; cb21b643c2b0f08fdb9e24dc4956a846 echo x - macchanger/files/patch-src_netinfo.c sed 's/^X//' >macchanger/files/patch-src_netinfo.c << '6698a3f09c341f61778b29439b1b7d42' X--- src/netinfo.c 2013-03-17 00:56:37.000000000 +0200 X+++ src/netinfo.c 2014-03-08 07:03:30.388297174 +0200 X@@ -29,8 +29,17 @@ X #include X #include X X-#include X-#include X+#if defined(__linux__) X+# include X+# include X+#elif defined(__FreeBSD__) X+# include X+# include X+# include X+# include X+# include X+# include X+#endif X X #include "netinfo.h" X X@@ -47,8 +56,9 @@ X return NULL; X } X X- strcpy (new->dev.ifr_name, device); X- if (ioctl(new->sock, SIOCGIFHWADDR, &new->dev) < 0) { X+ strncpy (new->dev.ifr_name, device, sizeof(new->dev.ifr_name)); X+ new->dev.ifr_name[sizeof(new->dev.ifr_name)-1] = '\0'; X+ if (if_nametoindex(device) == 0) { X perror ("[ERROR] Set device name"); X free(new); X return NULL; X@@ -65,31 +75,56 @@ X free(net); X } X X- X mac_t * X mc_net_info_get_mac (const net_info_t *net) X { X- int i; X- mac_t *new = (mac_t *) malloc (sizeof(mac_t)); X+ int i; X+ mac_t *mac = (mac_t *) malloc (sizeof(mac_t)); X+ u_char *lladr; X X- for (i=0; i<6; i++) { X- new->byte[i] = net->dev.ifr_hwaddr.sa_data[i] & 0xFF; X- } X+ struct ifaddrs *ifap, *ifa; X+ struct sockaddr_dl *sdl; X X- return new; X-} X+ if (getifaddrs(&ifap) == 0) { X+ for (ifa = ifap; ifa; ifa = ifa->ifa_next) { X+ X+ sdl = (struct sockaddr_dl *) ifa->ifa_addr; X X+ if (strcmp(ifa->ifa_name, net->dev.ifr_name) != 0) X+ continue; X+ X+ if (!sdl && sdl->sdl_family != AF_LINK) X+ continue; X+ X+ lladr = (u_char *) LLADDR(sdl); X+ for (i=0; i<6; i++) X+ mac->byte[i] = lladr[i] & 0xFF; X+ break; X+ } X+ freeifaddrs(ifap); X+ } else X+ perror("getifaddrs"); X+ X+ return mac; X+} X X int X mc_net_info_set_mac (net_info_t *net, const mac_t *mac) X { X int i; X+#if defined(__FreeBSD__) X+ net->dev.ifr_addr.sa_family = AF_LINK; X+ net->dev.ifr_addr.sa_len = ETHER_ADDR_LEN; X+#endif X X- for (i=0; i<6; i++) { X+ for (i=0; i<6; i++) X+#if defined(__linux__) X net->dev.ifr_hwaddr.sa_data[i] = mac->byte[i]; X- } X+#elif defined(__FreeBSD__) X+ net->dev.ifr_addr.sa_data[i] = mac->byte[i]; X+#endif X X- if (ioctl(net->sock, SIOCSIFHWADDR, &net->dev) < 0) { X+ if (ioctl(net->sock, SIOCSIFHWADDR, &net->dev) == -1) { X perror ("[ERROR] Could not change MAC: interface up or insufficient permissions"); X return -1; X } X@@ -97,6 +132,7 @@ X return 0; X } X X+#if defined(__linux__) X mac_t * X mc_net_info_get_permanent_mac (const net_info_t *net) X { X@@ -125,3 +161,4 @@ X free(epa); X return newmac; X } X+#endif 6698a3f09c341f61778b29439b1b7d42 echo x - macchanger/files/patch-src_main.c sed 's/^X//' >macchanger/files/patch-src_main.c << '3805d61673e2a7a097c57875d5c38ba9' X--- src/main.c 2013-03-17 00:57:41.000000000 +0200 X+++ src/main.c 2014-03-08 06:42:36.021380219 +0200 X@@ -40,9 +40,6 @@ X #include "maclist.h" X #include "netinfo.h" X X-#define EXIT_OK 0 X-#define EXIT_ERROR 1 X- X static void X print_help (void) X { X@@ -51,10 +48,12 @@ X " -h, --help Print this help\n" X " -V, --version Print version and exit\n" X " -s, --show Print the MAC address and exit\n" X- " -e, --endding Don't change the vendor bytes\n" X+ " -e, --ending Don't change the vendor bytes\n" X " -a, --another Set random vendor MAC of the same kind\n" X " -A Set random vendor MAC of any kind\n" X+#ifdef __linux__ X " -p, --permanent Reset to original, permanent hardware MAC\n" X+#endif X " -r, --random Set fully random MAC\n" X " -l, --list[=keyword] Print known vendors\n" X " -b, --bia Pretend to be a burned-in-address\n" X@@ -94,8 +93,9 @@ X struct timeval tv; X unsigned int seed; X X- if ((fd = open("/dev/urandom", O_RDONLY)) >= 0 || X- (fd = open("/dev/random", O_RDONLY)) >= 0) X+ if ((fd = open("/dev/hwrng", O_RDONLY)) >= 0 || X+ (fd = open("/dev/random", O_RDONLY)) >= 0 || X+ (fd = open("/dev/urandom", O_RDONLY)) >= 0) X { X read (fd, &seed, sizeof(seed)); X close (fd); X@@ -112,10 +112,12 @@ X main (int argc, char *argv[]) X { X char random = 0; X- char endding = 0; X+ char ending = 0; X char another_any = 0; X char another_same = 0; X+#ifdef __linux__ X char permanent = 0; X+#endif X char print_list = 0; X char show = 0; X char set_bia = 0; X@@ -127,9 +129,12 @@ X {"help", no_argument, NULL, 'h'}, X {"version", no_argument, NULL, 'V'}, X {"random", no_argument, NULL, 'r'}, X- {"endding", no_argument, NULL, 'e'}, X+ {"ending", no_argument, NULL, 'e'}, X+ {"endding", no_argument, NULL, 'e'}, /* kept for backwards compatibility */ X {"another", no_argument, NULL, 'a'}, X+#ifdef __linux__ X {"permanent", no_argument, NULL, 'p'}, X+#endif X {"show", no_argument, NULL, 's'}, X {"another_any", no_argument, NULL, 'A'}, X {"bia", no_argument, NULL, 'b'}, X@@ -140,7 +145,9 @@ X X net_info_t *net; X mac_t *mac; X+#ifdef __linux__ X mac_t *mac_permanent; X+#endif X mac_t *mac_faked; X char *device_name; X int val; X@@ -156,7 +163,7 @@ X "This is free software; see the source for copying conditions. There is NO\n" X "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n", X VERSION); X- exit (EXIT_OK); X+ exit (EXIT_SUCCESS); X break; X case 'l': X print_list = 1; X@@ -166,7 +173,7 @@ X random = 1; X break; X case 'e': X- endding = 1; X+ ending = 1; X break; X case 'b': X set_bia = 1; X@@ -180,9 +187,11 @@ X case 'A': X another_any = 1; X break; X+#ifdef __linux__ X case 'p': X permanent = 1; X break; X+#endif X case 'm': X set_mac = optarg; X break; X@@ -190,67 +199,78 @@ X case '?': X default: X print_help(); X- exit (EXIT_OK); X+ exit (EXIT_SUCCESS); X break; X } X } X X /* Read the MAC lists */ X if (mc_maclist_init() < 0) { X- exit (EXIT_ERROR); X+ exit (EXIT_FAILURE); X } X X /* Print list? */ X if (print_list) { X mc_maclist_print(search_word); X- exit (EXIT_OK); X+ exit (EXIT_SUCCESS); X } X X /* Get device name argument */ X if (optind >= argc) { X print_usage(); X- exit (EXIT_OK); X+ exit (EXIT_SUCCESS); X } X device_name = argv[optind]; X X /* Seed a random number generator */ X random_seed(); X X- /* Read the MAC */ X+ /* Read the MAC */ X if ((net = mc_net_info_new(device_name)) == NULL) { X- exit (EXIT_ERROR); X+ exit (EXIT_FAILURE); X } X mac = mc_net_info_get_mac(net); X+#ifdef __linux__ X mac_permanent = mc_net_info_get_permanent_mac(net); X+#endif X+ X+ /* --bia can only be used with --random */ X+ if (set_bia && !random) { X+ fprintf (stderr, "[WARNING] Ignoring --bia option that can only be used with --random\n"); X+ } X X /* Print the current MAC info */ X print_mac ("Current MAC: ", mac); X+#ifdef __linux__ X print_mac ("Permanent MAC: ", mac_permanent); X+#endif X X /* Change the MAC */ X mac_faked = mc_mac_dup (mac); X X if (show) { X- exit (EXIT_OK); X+ exit (EXIT_SUCCESS); X } else if (set_mac) { X if (mc_mac_read_string (mac_faked, set_mac) < 0) { X- exit (EXIT_ERROR); X+ exit (EXIT_FAILURE); X } X } else if (random) { X mc_mac_random (mac_faked, 6, set_bia); X- } else if (endding) { X- mc_mac_random (mac_faked, 3, set_bia); X+ } else if (ending) { X+ mc_mac_random (mac_faked, 3, 1); X } else if (another_same) { X val = mc_maclist_is_wireless (mac); X mc_maclist_set_random_vendor (mac_faked, val); X- mc_mac_random (mac_faked, 3, set_bia); X+ mc_mac_random (mac_faked, 3, 1); X } else if (another_any) { X mc_maclist_set_random_vendor(mac_faked, mac_is_anykind); X- mc_mac_random (mac_faked, 3, set_bia); X+ mc_mac_random (mac_faked, 3, 1); X+#ifdef __linux__ X } else if (permanent) { X mac_faked = mc_mac_dup (mac_permanent); X+#endif X } else { X- mc_mac_next (mac_faked); X+ exit (EXIT_SUCCESS); /* default to show */ X } X X /* Set the new MAC */ X@@ -272,9 +292,11 @@ X /* Memory free */ X mc_mac_free (mac); X mc_mac_free (mac_faked); X+#ifdef __linux__ X mc_mac_free (mac_permanent); X+#endif X mc_net_info_free (net); X mc_maclist_free(); X X- return (ret == 0) ? EXIT_OK : EXIT_ERROR; X+ return (ret == 0) ? EXIT_SUCCESS : EXIT_FAILURE; X } 3805d61673e2a7a097c57875d5c38ba9 echo x - macchanger/Makefile sed 's/^X//' >macchanger/Makefile << '3a74b2cc6a0f2b8b8b8e28da5443e260' X# $FreeBSD$ X XPORTNAME= macchanger XPORTVERSION= 1.6.0 XCATEGORIES= net XMASTER_SITES= GNU X XMAINTAINER= clutton@zoho.com XCOMMENT= GNU MAC Changer X XLICENSE= GPLv3 X XGNU_CONFIGURE= yes X XINFO= macchanger X X.include 3a74b2cc6a0f2b8b8b8e28da5443e260 echo x - macchanger/distinfo sed 's/^X//' >macchanger/distinfo << '614a08e9cf0867f64ce5227faaa18894' XSHA256 (macchanger-1.6.0.tar.gz) = 31534f138f1d21fa247be74ba6bef3fbfa47bbcd5033e99bd10c432fe58e51f7 XSIZE (macchanger-1.6.0.tar.gz) = 352061 614a08e9cf0867f64ce5227faaa18894 echo x - macchanger/pkg-descr sed 's/^X//' >macchanger/pkg-descr << '23d5d0fdb10e0c2778a645d256385f23' XGNU MAC Changer is an utility that makes the maniputation of MAC addresses of Xnetwork interfaces easier. X XWWW: http://www.gnu.org/software/macchanger 23d5d0fdb10e0c2778a645d256385f23 exit >Release-Note: >Audit-Trail: >Unformatted: