3 [ -f testing.sh ] && . testing.sh
5 if [ "$(id -u)" -ne 0 ]
7 echo "SKIPPED: chown (not root)"
12 # We chown between user "root" and the last user in /etc/passwd,
13 # and group "root" and the last group in /etc/group.
15 USR="$(sed -n '$s/:.*//p' /etc/passwd)"
16 GRP="$(sed -n '$s/:.*//p' /etc/group)"
18 # Set up a little testing hierarchy
25 # Wrapper to reset groups and return results
27 OUT="&& echo \$(ls -l testdir/file | awk '{print \$3,\$4}')"
29 #testing "name" "command" "result" "infile" "stdin"
32 testing "chown initial" "chown root:root $F $OUT" "root root\n" "" ""
33 testing "chown usr:grp" "chown $USR:$GRP $F $OUT" "$USR $GRP\n" "" ""
34 testing "chown root" "chown root $F $OUT" "root $GRP\n" "" ""
35 # TODO: can we test "owner:"?
36 testing "chown :grp" "chown root:root $F && chown :$GRP $F $OUT" \
38 testing "chown :" "chown $USR:$GRP $F && chown : $F $OUT" \