^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) #!/bin/bash
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) TCID="safesetid-test.sh"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) errcode=0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) # Kselftest framework requirement - SKIP code is 4.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) ksft_skip=4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) check_root()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) uid=$(id -u)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) if [ $uid -ne 0 ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) echo $TCID: must be run as root >&2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) exit $ksft_skip
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) main_function()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) check_root
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) ./safesetid-test
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) main_function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) echo "$TCID: done"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) exit $errcode