Print this page
7290 ZFS test suite needs to control what utilities it can run
Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/test/zfs-tests/tests/functional/xattr/xattr_007_neg.ksh
          +++ new/usr/src/test/zfs-tests/tests/functional/xattr/xattr_007_neg.ksh
↓ open down ↓ 16 lines elided ↑ open up ↑
  17   17  # fields enclosed by brackets "[]" replaced with your own identifying
  18   18  # information: Portions Copyright [yyyy] [name of copyright owner]
  19   19  #
  20   20  # CDDL HEADER END
  21   21  #
  22   22  # Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  23   23  # Use is subject to license terms.
  24   24  #
  25   25  
  26   26  #
  27      -# Copyright (c) 2013 by Delphix. All rights reserved.
       27 +# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
  28   28  #
  29   29  
  30   30  . $STF_SUITE/include/libtest.shlib
  31   31  . $STF_SUITE/tests/functional/xattr/xattr_common.kshlib
  32   32  
  33   33  #
  34   34  # DESCRIPTION:
  35   35  # Creating and writing xattrs on files in snapshot directories fails. Also,
  36   36  # we shouldn't be able to list the xattrs of files in snapshots who didn't have
  37   37  # xattrs when the snapshot was created (the xattr namespace wouldn't have been
↓ open down ↓ 1 lines elided ↑ open up ↑
  39   39  #
  40   40  # STRATEGY:
  41   41  #       1. Create a file and add an xattr to it.
  42   42  #       2. Create another file, but don't add an xattr to it.
  43   43  #       3. Snapshot the filesystem
  44   44  #       4. Verify we're unable to alter the xattr on the first file
  45   45  #       5. Verify we're unable to list the xattrs on the second file
  46   46  #
  47   47  
  48   48  function cleanup {
  49      -        log_must $ZFS destroy $TESTPOOL/$TESTFS@snap
  50      -        log_must $RM $TESTDIR/myfile2.$$
  51      -        log_must $RM $TESTDIR/myfile.$$
  52      -        log_must $RM /tmp/output.$$
  53      -        [[ -e /tmp/expected_output.$$ ]]  && log_must $RM  \
       49 +        log_must zfs destroy $TESTPOOL/$TESTFS@snap
       50 +        log_must rm $TESTDIR/myfile2.$$
       51 +        log_must rm $TESTDIR/myfile.$$
       52 +        log_must rm /tmp/output.$$
       53 +        [[ -e /tmp/expected_output.$$ ]]  && log_must rm  \
  54   54          /tmp/expected_output.$$
  55   55  
  56   56  }
  57   57  
  58   58  log_assert "create/write xattr on a snapshot fails"
  59   59  log_onexit cleanup
  60   60  
  61   61  # create a file, and an xattr on it
  62      -log_must $TOUCH $TESTDIR/myfile.$$
       62 +log_must touch $TESTDIR/myfile.$$
  63   63  create_xattr $TESTDIR/myfile.$$ passwd /etc/passwd
  64   64  
  65   65  # create another file that doesn't have an xattr
  66      -log_must $TOUCH $TESTDIR/myfile2.$$
       66 +log_must touch $TESTDIR/myfile2.$$
  67   67  
  68   68  # snapshot the filesystem
  69      -log_must $ZFS snapshot $TESTPOOL/$TESTFS@snap
       69 +log_must zfs snapshot $TESTPOOL/$TESTFS@snap
  70   70  
  71   71  # we shouldn't be able to alter the first file's xattr
  72      -log_mustnot eval " $RUNAT $TESTDIR/.zfs/snapshot/snap/myfile.$$ \
  73      -    $CP /etc/passwd .  >/tmp/output.$$  2>&1"
  74      -log_must $GREP  -i  Read-only  /tmp/output.$$
       72 +log_mustnot eval " runat $TESTDIR/.zfs/snapshot/snap/myfile.$$ \
       73 +    cp /etc/passwd .  >/tmp/output.$$  2>&1"
       74 +log_must grep  -i  Read-only  /tmp/output.$$
  75   75  
  76      -log_must eval "$RUNAT $TESTDIR/.zfs/snapshot/snap/myfile2.$$  \
  77      -    $LS >/tmp/output.$$  2>&1"
       76 +log_must eval "runat $TESTDIR/.zfs/snapshot/snap/myfile2.$$  \
       77 +    ls >/tmp/output.$$  2>&1"
  78   78  create_expected_output  /tmp/expected_output.$$ SUNWattr_ro SUNWattr_rw
  79      -log_must $DIFF /tmp/output.$$ /tmp/expected_output.$$
       79 +log_must diff /tmp/output.$$ /tmp/expected_output.$$
  80   80  
  81   81  log_pass "create/write xattr on a snapshot fails"
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX