Skip to content

Instantly share code, notes, and snippets.

@jfarcand
Last active May 29, 2018 18:07
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jfarcand/8302675 to your computer and use it in GitHub Desktop.
Save jfarcand/8302675 to your computer and use it in GitHub Desktop.
Fixing broken ngrep with OS X Mavericks

Migrating to OS X Mavericks breaks the ngrep utility. Doing:

sudo ngrep -d lo0 -q -W byline port 8080

stopped working where the process exits immediately. I didn't dig into the ngrep code, but was able to find a simple workaround by doing

sudo ngrep -q -W byline -d lo0 '' 'port 8080'

You can call that a lazy hack, but it work!

@dch
Copy link

dch commented May 28, 2014

nice idea, this works for me without needing to remember quirky syntax. I have no idea how you discovered this workaround!

commit 628d35c4be805bc89de30b14128c5a88e41d76eb
Author: Dave Cottlehuber <dch@skunkwerks.at>
Date:   Wed May 21 15:27:25 2014 +0200

    ngrep: workaround for upstream bug

diff --git a/Library/Formula/ngrep.rb b/Library/Formula/ngrep.rb
index c82939c..9809799 100644
--- a/Library/Formula/ngrep.rb
+++ b/Library/Formula/ngrep.rb
@@ -18,7 +18,10 @@ class Ngrep < Formula
                           "--enable-ipv6",
                           "--prefix=#{prefix}",
                           # this line required to make configure succeed
-                          "--with-pcap-includes=/usr/include"
+                          "--with-pcap-includes=/usr/include",
+                          # this line required to avoid segfault
+                          # https://github.com/Homebrew/homebrew/issues/27171
+                          "--disable-pcap-restart"
     system "make install"
   end
 end

@jpr5
Copy link

jpr5 commented Jun 12, 2014

This was submitted as an issue, and I just followed up with an explanation.

If you have any other problems in the future, please don't hesitate to CC me in.

cheers,
--jordan

@jpr5
Copy link

jpr5 commented Jun 12, 2014

I think I've got this fixed on https://github.com/jpr5/ngrep/tree/true-up

I'd appreciate it if you could give it a whirl and let me know either way. Thanks!

@falcn
Copy link

falcn commented Jun 16, 2014

jpr5 - yes, it is working now, thank you (OS X 10.9.3)

@geraldstanje
Copy link

geraldstanje commented May 29, 2018

any idea why that is not working?

$ sudo ngrep -t "/getResponseRate" -d lo0 port 8081 -q -W byline
interface: en0 (172.11.83.0/255.255.252.0)
pcap compile: syntax error

$ ifconfig lo0
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
	options=3<RXCSUM,TXCSUM>
	inet6 ::1 prefixlen 128 
	inet 127.0.0.1 netmask 0xff000000 
	inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 
	nd6 options=1<PERFORMNUD>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment