From 40394d7a25564e6d688292e1d978c78ef7fd5cc3 Mon Sep 17 00:00:00 2001
From: Tim Wojtulewicz <tim@corelight.com>
Date: Thu, 12 Dec 2024 13:33:19 -0700
Subject: [PATCH] Revert modification of sys.path when importing zeekclient

This was removed in f93b8e193773a667eaaba5bb5f99cf05f1c478dd but causes
problems on air-gapped systems.
---
 zeek-client | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/zeek-client b/zeek-client
index 349c4a8..fb9e3fe 100755
--- a/zeek-client
+++ b/zeek-client
@@ -13,9 +13,19 @@ the idioms and primitives also used by the zkg package manager.
 # https://pypi.org/project/argcomplete/#global-completion
 # PYTHON_ARGCOMPLETE_OK
 
+import os.path
 import sys
 
-import zeekclient
+# For Zeek-bundled installation, prepend the Python path of the Zeek
+# installation to the search path. This ensures we find the matching module
+# first (or at all), avoiding potential conflicts with installations elsewhere
+# on the system.
+ZEEK_PYTHON_DIR = "@PY_MOD_INSTALL_DIR@"
+if os.path.isdir(ZEEK_PYTHON_DIR):
+    sys.path.insert(0, os.path.abspath(ZEEK_PYTHON_DIR))
+else:
+    ZEEK_PYTHON_DIR = None
+import zeekclient  # pylint: disable=wrong-import-position
 
 
 def main():