|
43 | 43 | # 4. Check that we're unable to write an xattr as a non-root user
|
44 | 44 | #
|
45 | 45 |
|
46 |
| -function cleanup { |
47 |
| - |
48 |
| - log_must rm $TESTDIR/myfile.$$ |
49 |
| - |
| 46 | +function cleanup |
| 47 | +{ |
| 48 | + rm -f $testfile $tempfile |
50 | 49 | }
|
51 | 50 |
|
52 | 51 | log_assert "read/write xattr on a file with no permissions fails"
|
53 | 52 | log_onexit cleanup
|
54 | 53 |
|
55 |
| -log_must touch $TESTDIR/myfile.$$ |
56 |
| -create_xattr $TESTDIR/myfile.$$ passwd /etc/passwd |
| 54 | +typeset testfile=$TESTDIR/testfile.$$ |
| 55 | +typeset tempfile=/tmp/tempfile.$$ |
| 56 | + |
| 57 | +log_must touch $testfile |
| 58 | +create_xattr $testfile passwd /etc/passwd |
57 | 59 |
|
58 |
| -log_must chmod 000 $TESTDIR/myfile.$$ |
| 60 | +log_must chmod 000 $testfile |
59 | 61 | if is_illumos; then
|
60 |
| - log_mustnot su $ZFS_USER -c "runat $TESTDIR/myfile.$$ cat passwd" |
61 |
| - log_mustnot su $ZFS_USER -c "runat $TESTDIR/myfile.$$ cp /etc/passwd ." |
| 62 | + log_mustnot su $ZFS_USER -c "runat $testfile cat passwd" |
| 63 | + log_mustnot su $ZFS_USER -c "runat $testfile cp /etc/passwd ." |
62 | 64 | else
|
63 |
| - user_run $ZFS_USER eval \ |
64 |
| - "get_xattr passwd $TESTDIR/myfile.$$ >/tmp/passwd.$$" |
65 |
| - log_mustnot diff /etc/passwd /tmp/passwd.$$ |
66 |
| - log_must rm /tmp/passwd.$$ |
| 65 | + log_mustnot user_run $ZFS_USER " |
| 66 | +. $STF_SUITE/include/libtest.shlib |
| 67 | +get_xattr passwd $testfile >$tempfile |
| 68 | +" |
| 69 | + log_mustnot diff -q /etc/passwd $tempfile |
| 70 | + log_must rm $tempfile |
67 | 71 |
|
68 |
| - user_run $ZFS_USER eval \ |
69 |
| - "set_xattr_stdin passwd $TESTDIR/myfile.$$ </etc/group" |
70 |
| - log_must chmod 644 $TESTDIR/myfile.$$ |
71 |
| - get_xattr passwd $TESTDIR/myfile.$$ >/tmp/passwd.$$ |
72 |
| - log_must diff /etc/passwd /tmp/passwd.$$ |
73 |
| - log_must rm /tmp/passwd.$$ |
| 72 | + log_mustnot user_run $ZFS_USER " |
| 73 | +. $STF_SUITE/include/libtest.shlib |
| 74 | +set_xattr_stdin passwd $testfile </etc/group |
| 75 | +" |
| 76 | + log_must chmod 644 $testfile |
| 77 | + get_xattr passwd $testfile >$tempfile |
| 78 | + log_must diff -q /etc/passwd $tempfile |
| 79 | + log_must rm $tempfile |
74 | 80 | fi
|
75 | 81 |
|
76 | 82 | log_pass "read/write xattr on a file with no permissions fails"
|
0 commit comments