diff --git a/src/fromager/run_network_isolation.sh b/src/fromager/run_network_isolation.sh index 42e082f4..c3e3d40b 100755 --- a/src/fromager/run_network_isolation.sh +++ b/src/fromager/run_network_isolation.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env -S unshare -rn /bin/bash +#!/usr/bin/env -S unshare --uts --net --map-root-user /bin/bash # # Run command with network isolation (CLONE_NEWNET) and set up loopback # interface in the new network namespace. This is somewhat similar to @@ -6,6 +6,9 @@ # unprivilged container. The user is root inside the new namespace and mapped # to the euid/egid if the parent namespace. # +# Unshare UTS namespace, so we can set the hostname to "localhost", so +# lookup of "localhost" does not fail. +# # Ubuntu 24.04: needs `sysctl kernel.apparmor_restrict_unprivileged_userns=0` # to address `unshare: write failed /proc/self/uid_map: Operation not permitted`. # @@ -21,5 +24,10 @@ fi # bring loopback up ip link set lo up +# set hostname to "localhost" +if command -v hostname 2>&1 >/dev/null; then + hostname localhost +fi + # replace with command exec "$@"