From d26b96dcc513b7e393d7ba908ad86862de0104ce Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Tue, 20 Nov 2018 07:49:53 +0100 Subject: [PATCH] pap.py: Try to locate puppy in /usr/lib/go/ if GOPATH is not set --- pappyproxy/pap.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/pappyproxy/pap.py b/pappyproxy/pap.py index 4e9bf1d..55ac49a 100644 --- a/pappyproxy/pap.py +++ b/pappyproxy/pap.py @@ -74,16 +74,21 @@ def main(): msg_addr = args.dbgattach[0] else: msg_addr = None - try: - # Try to get the binary from GOPATH - gopath = os.environ["GOPATH"] - binloc = os.path.join(gopath, "bin", "puppy") - except: - # Try to get the binary from ~/.pappy/puppy - binloc = os.path.join(data_dir, "puppy") - if not os.path.exists(binloc): - print("Could not find puppy binary in GOPATH or ~/.pappy. Please ensure that it has been compiled, or pass in the binary location from the command line") - exit(1) + + binpaths = [ + # Try to get the binary from GOPATH + os.path.join(os.getenv('GOPATH', '/usr/lib/go'), 'bin'), + # Try to get the binary from ~/.pappy/puppy + data_dir, + ] + + for binpath in binpaths: + binloc = os.path.join(binpath, 'puppy') + if os.path.exists(binloc): + break + else: + print('Could not find puppy binary in GOPATH or ~/.pappy. Please ensure that it has been compiled, or pass in the binary location from the command line') + exit(1) config = ProxyConfig() if not args.lite: config.load("./config.json")