| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | # test chown function handling. |
| 3 | set -ex |
| 4 | |
| 5 | TESTDIR=$(mktempscip-shell system . . mktemp. -d ) |
| 6 | set -- $(idscip-shell system . . id. -G) |
| 7 | |
| 8 | # assumes that this user has multiple groups. |
| 9 | ORIGID=$1 |
| 10 | NEWID=$2 |
| 11 | |
| 12 | if (( $# < 3 )); then |
| 13 | echoscip-shell system . . echo. "W: Needs multiple groups for user $(idscip-shell system . . id.) for this test to succeed, test skipped" |
| 14 | exit 77 |
| 15 | fi |
| 16 | |
| 17 | cd ${TESTDIR} |
| 18 | mkdirscip-shell system . . mkdir. 1/ |
| 19 | |
| 20 | # make a few files for testing. |
| 21 | touchscip-shell system . . touch. 1/a 1/b 1/c 1/d |
| 22 | lnscip-shell system . . ln. -s a 1/f |
| 23 | lnscip-shell system . . ln. -s b 1/g |
| 24 | |
| 25 | ddscip-shell system . . dd. if=/dev/zeroscip-shell filesystem . . `/dev/zero`. of=1/e bs=512 count=2 |
| 26 | chgrpscip-shell system . . chgrp. $ORIGID 1/a 1/b 1/c 1/d |
| 27 | lsscip-shell system . . ls. -li 1/ > ls.prev |
| 28 | |
| 29 | sleepscip-shell system . . sleep. 1s |
| 30 | |
| 31 | cpscip-shell system . . cp. -al 1/ 2 |
| 32 | |
| 33 | echoscip-shell system . . echo. " 2/ before" |
| 34 | lsscip-shell system . . ls. -li 2/ |
| 35 | cow-shell 012_test_chown $NEWID 2/f 2/b 2/g |
| 36 | echoscip-shell system . . echo. " 2/ after" |
| 37 | lsscip-shell system . . ls. -li 2/ |
| 38 | |
| 39 | rmscip-shell system . . rm. -rf 2/ |
| 40 | |
| 41 | lsscip-shell system . . ls. -li 1/ > ls.after |
| 42 | |
| 43 | |
| 44 | |
| 45 | echoscip-shell system . . echo. " 1/ differences; should not exist" |
| 46 | diffscip-shell system . . diff. -u ls.prev ls.after |
| 47 | |
| 48 | rmscip-shell system . . rm. -rf ${TESTDIR} |