github.com/tri-adam/singularity@v3.1.1+incompatible/docs/2.x-tests/45-targetmode.sh (about) 1 #!/bin/bash 2 # 3 # Copyright (c) 2017, Michael W. Bauer. All rights reserved. 4 # Copyright (c) 2017, Gregory M. Kurtzer. All rights reserved. 5 # 6 # "Singularity" Copyright (c) 2016, The Regents of the University of California, 7 # through Lawrence Berkeley National Laboratory (subject to receipt of any 8 # required approvals from the U.S. Dept. of Energy). All rights reserved. 9 # 10 # This software is licensed under a customized 3-clause BSD license. Please 11 # consult LICENSE file distributed with the sources of this project regarding 12 # your rights to use or distribute this software. 13 # 14 # NOTICE. This Software was developed under funding from the U.S. Department of 15 # Energy and the U.S. Government consequently retains certain rights. As such, 16 # the U.S. Government has been granted for itself and others acting on its 17 # behalf a paid-up, nonexclusive, irrevocable, worldwide license in the Software 18 # to reproduce, distribute copies to the public, prepare derivative works, and 19 # perform publicly and display publicly, and to permit other to do so. 20 # 21 # 22 23 24 . ./functions 25 26 if [ `id -g` -lt 1000 ]; then 27 echo -e "\nGID less than 1000 ... skipping 45-targetmode\n" 28 exit 0 29 fi 30 31 test_init "Checking target UID/GID mode" 32 33 34 35 CONTAINER="$SINGULARITY_TESTDIR/container.img" 36 37 stest 0 sudo singularity build "$CONTAINER" "../examples/busybox/Singularity" 38 stest 0 singularity exec "$CONTAINER" true 39 stest 1 singularity exec "$CONTAINER" false 40 41 stest 0 sh -c "sudo SINGULARITY_TARGET_GID=`id -g` SINGULARITY_TARGET_UID=`id -u` singularity exec $CONTAINER whoami | grep `id -un`" 42 stest 1 sh -c "SINGULARITY_TARGET_GID=99 SINGULARITY_TARGET_UID=99 singularity exec $CONTAINER whoami | grep 99" 43 stest 1 sh -c "SINGULARITY_TARGET_GID=99 SINGULARITY_TARGET_UID=99 singularity exec $CONTAINER true" 44 45 46 test_cleanup 47