From cae9eb3c79e4fdf2a17a3a4a2d3d28030839dedb Mon Sep 17 00:00:00 2001 From: psycep Date: Wed, 22 Apr 2026 12:28:37 -0500 Subject: [PATCH] install.sh: prefix cross-compile outputs with gopacket- The native install already renamed each tool to gopacket- before copying to /usr/local/bin, but the portable and windows cross- compile targets dropped raw binaries like ping.exe, net.exe, reg.exe, attrib.exe, services.exe into ./dist/. When a user copies one of those to a Windows host and runs it from the same directory, cmd.exe's PATH resolution picks up the local binary before the Windows built-in of the same name, shadowing tools users rely on. The portable target on Linux has the same risk for binaries named ping, net, etc. Applies the same normalization (lowercase, underscores to hyphens) and gopacket- prefix the native install already uses, but at build time for the cross-compile targets. Native behavior is unchanged: ./bin/ still gets raw names so install_native can prefix on copy. --- install.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 61113a6..eaa0baf 100755 --- a/install.sh +++ b/install.sh @@ -272,7 +272,20 @@ build_target() { continue fi echo -n " ${tool}... " - local out_path="${outdir}/${tool}${exe_suffix}" + # Cross-compile outputs get the same gopacket- prefix as the native + # install, so users copying a .exe to a Windows host don't end up with + # ping.exe / net.exe / reg.exe shadowing built-ins of the same name. + # Native stays as the raw name here; install_native prefixes when it + # copies to INSTALL_DIR. + local out_name + if [ "$t" = "native" ]; then + out_name="$tool" + else + local normalized + normalized=$(echo "$tool" | tr '[:upper:]' '[:lower:]' | tr '_' '-') + out_name="gopacket-${normalized}" + fi + local out_path="${outdir}/${out_name}${exe_suffix}" local build_cmd=(go build -o "$out_path") if [ "$t" = "native" ]; then # Static-link libgcc so binaries run on minimally-versioned hosts.