Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion containers/agent/setup-iptables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ SQUID_PORT="${SQUID_PROXY_PORT:-3128}"
echo "[iptables] Squid proxy: ${SQUID_HOST}:${SQUID_PORT}"

# Resolve Squid hostname to IP
SQUID_IP=$(getent hosts "$SQUID_HOST" | awk '{ print $1 }' | head -n 1)
# Use awk's NR to get first line to avoid host binary dependency in chroot mode
SQUID_IP=$(getent hosts "$SQUID_HOST" | awk 'NR==1 { print $1 }')
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The awk command should include an exit statement after printing the first line to match the behavior of head -n 1 and avoid unnecessarily processing remaining input. Change awk 'NR==1 { print $1 }' to awk 'NR==1 { print $1; exit }'. While this is a minor efficiency issue since getent hosts typically returns few lines, it's a best practice and makes the intent clearer.

Suggested change
SQUID_IP=$(getent hosts "$SQUID_HOST" | awk 'NR==1 { print $1 }')
SQUID_IP=$(getent hosts "$SQUID_HOST" | awk 'NR==1 { print $1; exit }')

Copilot uses AI. Check for mistakes.
if [ -z "$SQUID_IP" ]; then
echo "[iptables] ERROR: Could not resolve Squid proxy hostname: $SQUID_HOST"
exit 1
Expand Down
Loading