forked from python-wheel-build/fromager
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request python-wheel-build#477 from tiran/run-network-isol…
…ation Fix: enable loopback device in network isolation
- Loading branch information
Showing
4 changed files
with
54 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env -S unshare -rn /bin/bash | ||
# | ||
# Run command with network isolation (CLONE_NEWNET) and set up loopback | ||
# interface in the new network namespace. This is somewhat similar to | ||
# Bubblewrap `bwrap --unshare-net --dev-bind / /`, but works in an | ||
# unprivilged container. The user is root inside the new namespace and mapped | ||
# to the euid/egid if the parent namespace. | ||
# | ||
# Ubuntu 24.04: needs `sysctl kernel.apparmor_restrict_unprivileged_userns=0` | ||
# to address `unshare: write failed /proc/self/uid_map: Operation not permitted`. | ||
# | ||
|
||
set -e | ||
set -o pipefail | ||
|
||
if [ "$#" -eq 0 ]; then | ||
echo "$0 command" >&2 | ||
exit 2 | ||
fi | ||
|
||
# bring loopback up | ||
ip link set lo up | ||
|
||
# replace with command | ||
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters