aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorChris Evich <cevich@redhat.com>2019-03-18 15:17:46 -0400
committerChris Evich <cevich@redhat.com>2019-03-19 13:00:18 -0400
commit37eb694bd073b8dff265be137ae75eac81e9d769 (patch)
tree99e158529ea8f6b20ed1ab266c0168c9f78f68a0 /contrib
parent537c382f5bd098bc89a457554db9bd0b08eab3c2 (diff)
downloadpodman-37eb694bd073b8dff265be137ae75eac81e9d769.tar.gz
podman-37eb694bd073b8dff265be137ae75eac81e9d769.tar.bz2
podman-37eb694bd073b8dff265be137ae75eac81e9d769.zip
Cirrus: Various fixes for rootless testing
* Randomize the user's UID and GID * Simplify `setup_environment.sh` * Support new "-r" option for `hack/get_ci_vm.sh` setting up rootless * Connect as $ROOTLESS_USER when using "-r" with `hack/get_ci_vm.sh` Signed-off-by: Chris Evich <cevich@redhat.com>
Diffstat (limited to 'contrib')
-rw-r--r--contrib/cirrus/lib.sh26
-rwxr-xr-xcontrib/cirrus/setup_environment.sh9
2 files changed, 18 insertions, 17 deletions
diff --git a/contrib/cirrus/lib.sh b/contrib/cirrus/lib.sh
index fe5fe7238..e941610e2 100644
--- a/contrib/cirrus/lib.sh
+++ b/contrib/cirrus/lib.sh
@@ -54,8 +54,6 @@ show_env_vars() {
BUILDTAGS $BUILDTAGS
BUILT_IMAGE_SUFFIX $BUILT_IMAGE_SUFFIX
ROOTLESS_USER $ROOTLESS_USER
-ROOTLESS_UID $ROOTLESS_UID
-ROOTLESS_GID $ROOTLESS_GID
CI $CI
CIRRUS_CI $CIRRUS_CI
CI_NODE_INDEX $CI_NODE_INDEX
@@ -130,7 +128,7 @@ bad_os_id_ver() {
}
run_rootless() {
- if [[ -z "$ROOTLESS_USER" ]] && [[ -z "$ROOTLESS_UID" ]] && [[ -z "$ROOTLESS_GID" ]]
+ if [[ -z "$ROOTLESS_USER" ]]
then
return 1
else
@@ -170,15 +168,23 @@ record_timestamp() {
setup_rootless() {
req_env_var "
ROOTLESS_USER $ROOTLESS_USER
- #ROOTLESS_UID $ROOTLESS_UID
- #ROOTLESS_GID $ROOTLESS_GID
GOSRC $GOSRC
ENVLIB $ENVLIB
"
+
+ if passwd --status $ROOTLESS_USER
+ then
+ echo "Updating $ROOTLESS_USER user permissions on possibly changed libpod code"
+ chown -R $ROOTLESS_USER:$ROOTLESS_USER "$GOSRC"
+ return 0
+ fi
+
+ # Guarantee independence from specific values
+ ROOTLESS_UID=$[RANDOM+1000]
+ ROOTLESS_GID=$[RANDOM+1000]
echo "creating $ROOTLESS_UID:$ROOTLESS_GID $ROOTLESS_USER user"
- #groupadd -g $ROOTLESS_GID $ROOTLESS_USER
- #useradd -g $ROOTLESS_GID -u $ROOTLESS_UID --no-user-group --create-home $ROOTLESS_USER
- useradd --create-home $ROOTLESS_USER
+ groupadd -g $ROOTLESS_GID $ROOTLESS_USER
+ useradd -g $ROOTLESS_GID -u $ROOTLESS_UID --no-user-group --create-home $ROOTLESS_USER
chown -R $ROOTLESS_USER:$ROOTLESS_USER "$GOSRC"
echo "creating ssh keypair for $USER"
@@ -193,7 +199,9 @@ setup_rootless() {
cat /root/.ssh/authorized_keys >> "/home/$ROOTLESS_USER/.ssh/authorized_keys"
echo "Configuring subuid and subgid"
- echo "${ROOTLESS_USER}:$[ROOTLESS_UID * 100]:65536" | tee -a /etc/subuid >> /etc/subgid
+ grep -q "${ROOTLESS_USER}" /etc/subuid || \
+ echo "${ROOTLESS_USER}:$[ROOTLESS_UID * 100]:65536" | \
+ tee -a /etc/subuid >> /etc/subgid
echo "Setting permissions on automation files"
chmod 666 "$TIMESTAMPS_FILEPATH"
diff --git a/contrib/cirrus/setup_environment.sh b/contrib/cirrus/setup_environment.sh
index 7ba6965ba..96d0e1b55 100755
--- a/contrib/cirrus/setup_environment.sh
+++ b/contrib/cirrus/setup_environment.sh
@@ -44,8 +44,6 @@ then
"export OS_RELEASE_VER=\"$(os_release_ver)\"" \
"export OS_REL_VER=\"$(os_release_id)-$(os_release_ver)\"" \
"export ROOTLESS_USER=$ROOTLESS_USER" \
- "export ROOTLESS_UID=$ROOTLESS_UID" \
- "export ROOTLESS_GID=$ROOTLESS_GID" \
"export BUILT_IMAGE_SUFFIX=\"-$CIRRUS_REPO_NAME-${CIRRUS_CHANGE_IN_REPO:0:8}\"" \
"export GOPATH=\"/var/tmp/go\"" \
'export PATH="$HOME/bin:$GOPATH/bin:/usr/local/bin:$PATH"' \
@@ -74,6 +72,7 @@ then
esac
cd "${GOSRC}/"
+ # Reload to incorporate any changes from above
source "$SCRIPT_BASE/lib.sh"
if run_rootless
@@ -83,12 +82,6 @@ then
go get github.com/onsi/ginkgo/ginkgo
go get github.com/onsi/gomega/...
dnf -y update runc
- else
- # Includes some $HOME relative details
- go env | while read envline
- do
- X=$(echo "export $envline" | tee -a "$HOME/$ENVLIB") && eval "$X" && echo "$X"
- done
fi
fi