diff options
author | Chris Evich <cevich@redhat.com> | 2019-03-18 15:17:46 -0400 |
---|---|---|
committer | Chris Evich <cevich@redhat.com> | 2019-03-19 13:00:18 -0400 |
commit | 37eb694bd073b8dff265be137ae75eac81e9d769 (patch) | |
tree | 99e158529ea8f6b20ed1ab266c0168c9f78f68a0 /contrib/cirrus/lib.sh | |
parent | 537c382f5bd098bc89a457554db9bd0b08eab3c2 (diff) | |
download | podman-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/cirrus/lib.sh')
-rw-r--r-- | contrib/cirrus/lib.sh | 26 |
1 files changed, 17 insertions, 9 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" |