This repository has been archived by the owner on Jun 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 667
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[proxy] rewrite /etc/hosts from outside the container
Avoids problems when container user is non-root. Added a test for this and the --no-rewrite-hosts flag.
- Loading branch information
1 parent
3180c67
commit 4da9bea
Showing
6 changed files
with
166 additions
and
117 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
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,26 @@ | ||
#! /bin/bash | ||
|
||
. ./config.sh | ||
|
||
start_suite "Proxy rewrites hosts file" | ||
|
||
# Default rewrites the host file | ||
weave_on $HOST1 launch-proxy | ||
assert "proxy docker_on $HOST1 run -e 'WEAVE_CIDR=10.2.1.1/24' $SMALL_IMAGE hostname -i | cut -d' ' -f1" "10.2.1.1" | ||
|
||
# When container user is non-root | ||
docker_on $HOST1 build -t non-root >/dev/null - <<- EOF | ||
FROM $SMALL_IMAGE | ||
RUN adduser -D -s /bin/sh user | ||
ENV HOME /home/user | ||
USER user | ||
CMD true | ||
EOF | ||
assert "proxy docker_on $HOST1 run -e 'WEAVE_CIDR=10.2.1.1/24' non-root hostname -i | cut -d' ' -f1" "10.2.1.1" | ||
|
||
# When rewrite hosts is disabled | ||
weave_on $HOST1 stop-proxy | ||
weave_on $HOST1 launch-proxy --no-rewrite-hosts | ||
assert_raises "proxy docker_on $HOST1 run -e 'WEAVE_CIDR=10.2.1.1/24' $SMALL_IMAGE hostname -i | cut -d' ' -f1 | grep -v 10.2.1.1" | ||
|
||
end_suite |
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