Add the ZFS test suite

It was originally written by Sun as part of the STF (Solaris test framework).
They open sourced it in OpenSolaris, then HighCloud partially ported it to
FreeBSD, and Spectra Logic finished the port.  We also added many testcases,
fixed many broken ones, and converted them all to the ATF framework.  We've had
help along the way from avg, araujo, smh, and brd.

By default most of the tests are disabled.  Set the disks Kyua variable to
enable them.

Submitted by:	asomers, will, justing, ken, brd, avg, araujo, smh
Sponsored by:	Spectra Logic Corp, HighCloud
This commit is contained in:
Alan Somers 2018-02-23 16:31:00 +00:00
parent 2d87718fda
commit 2fae26bd8b
1506 changed files with 139361 additions and 0 deletions

View File

@ -428,6 +428,252 @@
..
aio
..
cddl
zfs
bin
..
include
..
tests
acl
cifs
..
nontrivial
..
trivial
..
..
atime
..
bootfs
..
cache
..
cachefile
..
clean_mirror
..
cli_root
zfs_upgrade
..
zfs_promote
..
zfs_clone
..
zfs_property
..
zfs_destroy
..
zpool_create
..
zpool_history
..
zpool_expand
..
zpool_remove
..
zfs_mount
..
zfs_unshare
..
zdb
..
zpool_online
..
zpool_get
..
zpool_export
..
zfs_copies
..
zfs_get
..
zfs
..
zpool_clear
..
zpool_import
blockfiles
..
..
zpool
..
zpool_offline
..
zpool_replace
..
zfs_rollback
..
zpool_set
..
zfs_send
..
zfs_set
..
zpool_detach
..
zfs_diff
..
zpool_scrub
..
zfs_inherit
..
zfs_snapshot
..
zfs_share
..
zpool_destroy
..
zpool_status
..
zfs_unmount
..
zfs_receive
..
zfs_create
..
zpool_upgrade
blockfiles
..
..
zpool_add
..
zfs_rename
..
zpool_attach
..
zfs_reservation
..
..
cli_user
misc
..
zfs_list
..
zpool_iostat
..
zpool_list
..
..
compression
..
ctime
..
delegate
..
devices
..
exec
..
grow_pool
..
grow_replicas
..
history
..
hotplug
..
hotspare
..
inheritance
..
interop
..
inuse
..
iscsi
..
large_files
..
largest_pool
..
link_count
..
migration
..
mmap
..
mount
..
mv_files
..
nestedfs
..
no_space
..
online_offline
..
pool_names
..
poolversion
..
quota
..
redundancy
..
refquota
..
refreserv
..
rename_dirs
..
replacement
..
reservation
..
rootpool
..
rsend
..
scrub_mirror
..
slog
..
snapshot
..
snapused
..
sparse
..
threadsappend
..
truncate
..
txg_integrity
..
userquota
..
utils_test
..
write_dirs
..
xattr
..
zfsd
..
zil
..
zinject
..
zones
..
zvol
zvol_ENOSPC
..
zvol_cli
..
zvol_misc
..
zvol_swap
..
..
zvol_thrash
..
..
..
..
dtrace
..
fifo
..
file

View File

@ -21,6 +21,7 @@
ATF_TESTS_C?=
ATF_TESTS_CXX?=
ATF_TESTS_SH?=
ATF_TESTS_KSH93?=
.if !empty(ATF_TESTS_C)
PROGS+= ${ATF_TESTS_C}
@ -80,3 +81,28 @@ ${_T}: ${ATF_TESTS_SH_SRC_${_T}}
mv ${.TARGET}.tmp ${.TARGET}
.endfor
.endif
.if !empty(ATF_TESTS_KSH93)
SCRIPTS+= ${ATF_TESTS_KSH93}
_TESTS+= ${ATF_TESTS_KSH93}
.for _T in ${ATF_TESTS_KSH93}
SCRIPTSDIR_${_T}= ${TESTSDIR}
TEST_INTERFACE.${_T}= atf
CLEANFILES+= ${_T} ${_T}.tmp
# TODO(jmmv): It seems to me that this SED and SRC functionality should
# exist in bsd.prog.mk along the support for SCRIPTS. Move it there if
# this proves to be useful within the tests.
ATF_TESTS_KSH93_SED_${_T}?= # empty
ATF_TESTS_KSH93_SRC_${_T}?= ${_T}.sh
${_T}: ${ATF_TESTS_KSH93_SRC_${_T}}
echo '#! /usr/libexec/atf-sh -s/usr/local/bin/ksh93' > ${.TARGET}.tmp
.if empty(ATF_TESTS_KSH93_SED_${_T})
cat ${.ALLSRC:N*Makefile*} >>${.TARGET}.tmp
.else
cat ${.ALLSRC:N*Makefile*} \
| sed ${ATF_TESTS_KSH93_SED_${_T}} >>${.TARGET}.tmp
.endif
chmod +x ${.TARGET}.tmp
mv ${.TARGET}.tmp ${.TARGET}
.endfor
.endif

View File

@ -1,9 +1,12 @@
# $FreeBSD$
.include <src.opts.mk>
TESTSDIR= ${TESTSBASE}/sys
TESTS_SUBDIRS+= acl
TESTS_SUBDIRS+= aio
TESTS_SUBDIRS+= ${_cddl}
TESTS_SUBDIRS+= fifo
TESTS_SUBDIRS+= file
TESTS_SUBDIRS+= fs
@ -21,6 +24,10 @@ TESTS_SUBDIRS+= sys
TESTS_SUBDIRS+= vfs
TESTS_SUBDIRS+= vm
.if ${MK_CDDL} != "no"
_cddl= cddl
.endif
# Items not integrated into kyua runs by default
SUBDIR+= pjdfstest

13
tests/sys/cddl/Makefile Normal file
View File

@ -0,0 +1,13 @@
# $FreeBSD$
.include <src.opts.mk>
TESTSDIR= ${TESTSBASE}/sys/cddl
TESTS_SUBDIRS+= ${_zfs}
.if ${MK_ZFS} != "no"
_zfs= zfs
.endif
.include <bsd.test.mk>

View File

@ -0,0 +1,11 @@
# $FreeBSD$
.include <src.opts.mk>
TESTSDIR= ${TESTSBASE}/sys/cddl/zfs
TESTS_SUBDIRS+= tests include
SUBDIR+= bin
.include <bsd.test.mk>

View File

@ -0,0 +1,61 @@
# $FreeBSD$
.include <src.opts.mk>
PACKAGE= tests
MAN=
BINDIR= ${TESTSBASE}/sys/cddl/zfs/bin
SCRIPTSDIR= ${TESTSBASE}/sys/cddl/zfs/bin
SCRIPTS+= bsddisks.ksh
SCRIPTS+= dircmp.ksh
SCRIPTS+= dumpadm.ksh
SCRIPTS+= ff.ksh
SCRIPTS+= fmadm.ksh
SCRIPTS+= fmdump.ksh
SCRIPTS+= format.ksh
SCRIPTS+= groupadd.ksh
SCRIPTS+= groupdel.ksh
SCRIPTS+= groupmod.ksh
SCRIPTS+= groupshow.ksh
SCRIPTS+= svcs.ksh
SCRIPTS+= swap.ksh
SCRIPTS+= testenv.ksh
SCRIPTS+= useradd.ksh
SCRIPTS+= userdel.ksh
SCRIPTS+= usermod.ksh
SCRIPTS+= zfs.ksh
SCRIPTS+= zfs_crypto.ksh
SCRIPTS+= zfs_version.ksh
SCRIPTS+= zlogin.ksh
SCRIPTS+= zoneadm.ksh
SCRIPTS+= zonecfg.ksh
SCRIPTS+= zpool.ksh
SCRIPTS+= zpool_bsd.ksh
SCRIPTS+= zpool_smi.ksh
SCRIPTS+= zpool_version.ksh
PROGS+= chg_usr_exec
# Not ported to FreeBSD
# PROGRS+= devname2devid
PROGS+= dir_rd_update
PROGS+= file_check
PROGS+= file_trunc
PROGS+= file_write
PROGS+= largest_file
PROGS+= mkfile
PROGS+= mktree
PROGS+= mmapwrite
PROGS+= randfree_file
PROGS+= readmmap
PROGS+= rename_dir
PROGS+= rm_lnkcnt_zero_file
.for p in ${PROGS}
SRCS.$p= $p.c
.endfor
LIBADD.mmapwrite+= pthread
LIBADD.rm_lnkcnt_zero_file+= pthread
.include <bsd.progs.mk>

View File

@ -0,0 +1,6 @@
#!/usr/local/bin/ksh93
# $FreeBSD$
BSDDEVS="ad|da|mlxd|myld|aacd|ided|twed"
ls /dev|egrep "^($BSDDEVS)[0-9]+\$" |sed 's/^/\/dev\//'

View File

@ -0,0 +1,78 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
* $FreeBSD$
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "@(#)chg_usr_exec.c 1.3 07/05/25 SMI"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <pwd.h>
int
main(int argc, char *argv[])
{
char *plogin = NULL;
char cmds[BUFSIZ] = { 0 };
char sep[] = " ";
struct passwd *ppw = NULL;
int i, len;
if (argc < 3 || strlen(argv[1]) == 0) {
(void) printf("\tUsage: %s <login> <commands> ...\n", argv[0]);
return (1);
}
plogin = argv[1];
len = 0;
for (i = 2; i < argc; i++) {
(void) snprintf(cmds+len, sizeof (cmds)-len,
"%s%s", argv[i], sep);
len += strlen(argv[i]) + strlen(sep);
}
if ((ppw = getpwnam(plogin)) == NULL) {
perror("getpwnam");
return (errno);
}
if (setgid(ppw->pw_gid) != 0) {
perror("setgid");
return (errno);
}
if (setuid(ppw->pw_uid) != 0) {
perror("setuid");
return (errno);
}
if (execl("/bin/sh", "sh", "-c", cmds, (char *)0) != 0) {
perror("execl");
return (errno);
}
return (0);
}

View File

@ -0,0 +1,123 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
* $FreeBSD$
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "@(#)devname2devid.c 1.3 07/05/25 SMI"
#include <sys/types.h>
#include <sys/stat.h>
#include <devid.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
/*
* Usage: devname2devid <devicepath>
*
* Examples:
* # ./devname2devid /dev/dsk/c1t4d0s0
* devid id1,sd@SSEAGATE_ST318404LSUN18G_3BT2G0Z300002146G4CR/a
* # ./devname2devid /dev/dsk/c1t4d0
* devid id1,sd@SSEAGATE_ST318404LSUN18G_3BT2G0Z300002146G4CR/wd
* # ./devname2devid /dev/dsk/c1t4d0s1
* devid id1,sd@SSEAGATE_ST318404LSUN18G_3BT2G0Z300002146G4CR/b
* #
*
* This program accepts a disk or disk slice path and prints a
* device id.
*
* Exit values:
* 0 - means success
* 1 - means failure
*
*/
int
main(int argc, char *argv[])
{
int fd;
ddi_devid_t devid;
char *minor_name, *devidstr, *device;
#ifdef DEBUG
devid_nmlist_t *list = NULL;
char *search_path;
int i;
#endif
if (argc == 1) {
(void) printf("%s <devicepath> [search path]\n",
argv[0]);
exit(1);
}
device = argv[1];
if ((fd = open(device, O_RDONLY|O_NDELAY)) < 0) {
perror(device);
exit(1);
}
if (devid_get(fd, &devid) != 0) {
perror("devid_get");
exit(1);
}
if (devid_get_minor_name(fd, &minor_name) != 0) {
perror("devid_get_minor_name");
exit(1);
}
if ((devidstr = devid_str_encode(devid, minor_name)) == 0) {
perror("devid_str_encode");
exit(1);
}
(void) printf("devid %s\n", devidstr);
devid_str_free(devidstr);
#ifdef DEBUG
if (argc == 3) {
search_path = argv[2];
} else {
search_path = "/dev/rdsk";
}
if (devid_deviceid_to_nmlist(search_path, devid, DEVID_MINOR_NAME_ALL,
&list)) {
perror("devid_deviceid_to_nmlist");
exit(1);
}
/* loop through list and process device names and numbers */
for (i = 0; list[i].devname != NULL; i++) {
(void) printf("devname: %s %p\n", list[i].devname, list[i].dev);
}
devid_free_nmlist(list);
#endif /* DEBUG */
devid_str_free(minor_name);
devid_free(devid);
return (0);
}

View File

@ -0,0 +1,122 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
* $FreeBSD$
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "@(#)dir_rd_update.c 1.2 07/01/09 SMI"
/*
* Assertion:
*
* A read operation and directory update operation performed
* concurrently on the same directory can lead to deadlock
* on a UFS logging file system, but not on a ZFS file system.
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#define TMP_DIR /tmp
static char dirpath[256];
int
main(int argc, char **argv)
{
char *cp1 = "";
int i = 0;
int ret = 0;
int testdd = 0;
pid_t pid;
static const int op_num = 5;
if (argc == 1) {
(void) printf("Usage: %s <mount point>\n", argv[0]);
exit(-1);
}
for (i = 0; i < 256; i++) {
dirpath[i] = 0;
}
cp1 = argv[1];
(void) strcpy(&dirpath[0], (const char *)cp1);
(void) strcat(&dirpath[strlen(dirpath)], "TMP_DIR");
ret = mkdir(dirpath, 0777);
if (ret != 0) {
if (errno != EEXIST) {
(void) printf(
"%s: mkdir(<%s>, 0777) failed: errno (decimal)=%d\n",
argv[0], dirpath, errno);
exit(-1);
}
}
testdd = open(dirpath, O_RDONLY|O_SYNC);
if (testdd < 0) {
(void) printf(
"%s: open(<%s>, O_RDONLY|O_SYNC) failed: errno (decimal)=%d\n",
argv[0], dirpath, errno);
exit(-1);
} else {
(void) close(testdd);
}
pid = fork();
if (pid > 0) {
int fd = open(dirpath, O_RDONLY|O_SYNC);
char buf[16];
int rdret;
int j = 0;
while (j < op_num) {
(void) sleep(1);
rdret = read(fd, buf, 16);
if (rdret == -1) {
(void) printf("readdir failed");
}
j++;
}
} else if (pid == 0) {
int fd = open(dirpath, O_RDONLY);
int chownret;
int k = 0;
while (k < op_num) {
(void) sleep(1);
chownret = fchown(fd, 0, 0);
if (chownret == -1) {
(void) printf("chown failed");
}
k++;
}
}
return (0);
}

View File

@ -0,0 +1,5 @@
#!/usr/local/bin/ksh93
# $FreeBSD$
diff -qr $*

View File

@ -0,0 +1,10 @@
#! /usr/local/bin/ksh93 -p
# $FreeBSD$
if [ $# != 0 ]
then
echo "ERROR option not supported"
return 1
fi
grep dumpdev /etc/rc.conf

View File

@ -0,0 +1,6 @@
#!/usr/local/bin/ksh93
# $FreeBSD$
echo dummy
exit 0

View File

@ -0,0 +1,89 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
* $FreeBSD$
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "@(#)file_check.c 1.3 07/05/25 SMI"
#include "file_common.h"
static unsigned char bigbuffer[BIGBUFFERSIZE];
/*
* Given a filename, check that the file consists entirely
* of a particular pattern. If the pattern is not specified a
* default will be used. For default values see file_common.h
*/
int
main(int argc, char **argv)
{
int bigfd;
long i, n;
uint8_t fillchar = DATA;
int bigbuffersize = BIGBUFFERSIZE;
int64_t read_count = 0;
/*
* Validate arguments
*/
if (argc < 2) {
(void) printf("Usage: %s filename [pattern]\n",
argv[0]);
exit(1);
}
if (argv[2]) {
fillchar = atoi(argv[2]);
}
/*
* Read the file contents and check every character
* against the supplied pattern. Abort if the
* pattern check fails.
*/
if ((bigfd = open(argv[1], O_RDONLY)) == -1) {
(void) printf("open %s failed %d\n", argv[1], errno);
exit(1);
}
do {
if ((n = read(bigfd, &bigbuffer, bigbuffersize)) == -1) {
(void) printf("read failed (%ld), %d\n", n, errno);
exit(errno);
}
for (i = 0; i < n; i++) {
if (bigbuffer[i] != fillchar) {
(void) printf("error %s: 0x%x != 0x%x)\n",
argv[1], bigbuffer[i], fillchar);
exit(1);
}
}
read_count += n;
} while (n == bigbuffersize);
return (0);
}

View File

@ -0,0 +1,65 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
* $FreeBSD$
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef FILE_COMMON_H
#define FILE_COMMON_H
#pragma ident "@(#)file_common.h 1.3 07/05/25 SMI"
/*
* header file for file_* utilities. These utilities
* are used by the test cases to perform various file
* operations (append writes, for example).
*/
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#define BLOCKSZ 8192
#define DATA 0xa5
#define DATA_RANGE 120
#define BIGBUFFERSIZE 0x800000
#define BIGFILESIZE 20
extern char *optarg;
extern int optind, opterr, optopt;
#ifdef __cplusplus
}
#endif
#endif /* FILE_COMMON_H */

View File

@ -0,0 +1,240 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
* $FreeBSD$
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "@(#)file_trunc.c 1.2 07/05/25 SMI"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <limits.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/fcntl.h>
#include <sys/stat.h>
#include <sys/statvfs.h>
#include <sys/errno.h>
#include <sys/time.h>
#include <sys/ioctl.h>
#include <sys/wait.h>
#include <sys/param.h>
#include <string.h>
#define FSIZE 256*1024*1024
#define BSIZE 512
/* Initialize Globals */
static long fsize = FSIZE;
static size_t bsize = BSIZE;
static int count = 0;
static int rflag = 0;
static int seed = 0;
static int vflag = 0;
static int errflag = 0;
static off_t offset = 0;
static char *filename = NULL;
static void usage(char *execname);
static void parse_options(int argc, char *argv[]);
static void do_write(int fd);
static void do_trunc(int fd);
static void
usage(char *execname)
{
(void) fprintf(stderr,
"usage: %s [-b blocksize] [-c count] [-f filesize]"
" [-o offset] [-s seed] [-r] [-v] filename\n", execname);
(void) exit(1);
}
int
main(int argc, char *argv[])
{
int i = 0;
int fd = -1;
parse_options(argc, argv);
fd = open(filename, O_RDWR|O_CREAT|O_TRUNC, 0666);
if (fd < 0) {
perror("open");
exit(3);
}
while (i < count) {
(void) do_write(fd);
(void) do_trunc(fd);
i++;
}
(void) close(fd);
return (0);
}
static void
parse_options(int argc, char *argv[])
{
int c;
extern char *optarg;
extern int optind, optopt;
count = fsize / bsize;
seed = time(NULL);
while ((c = getopt(argc, argv, "b:c:f:o:rs:v")) != -1) {
switch (c) {
case 'b':
bsize = atoi(optarg);
break;
case 'c':
count = atoi(optarg);
break;
case 'f':
fsize = atoi(optarg);
break;
case 'o':
offset = atoi(optarg);
break;
case 'r':
rflag++;
break;
case 's':
seed = atoi(optarg);
break;
case 'v':
vflag++;
break;
case ':':
(void) fprintf(stderr,
"Option -%c requires an operand\n", optopt);
errflag++;
break;
case '?':
(void) fprintf(stderr,
"Unrecognized option: -%c\n", optopt);
errflag++;
break;
}
if (errflag) {
(void) usage(argv[0]);
}
}
if (argc <= optind) {
(void) fprintf(stderr,
"No filename specified\n");
usage(argv[0]);
}
filename = argv[optind];
if (vflag) {
(void) fprintf(stderr, "Seed = %d\n", seed);
}
srandom(seed);
}
static void
do_write(int fd)
{
off_t roffset = 0;
char *buf = NULL;
char *rbuf = NULL;
buf = (char *)calloc(1, bsize);
rbuf = (char *)calloc(1, bsize);
if (buf == NULL || rbuf == NULL) {
perror("malloc");
exit(4);
}
roffset = random() % fsize;
if (lseek(fd, (offset + roffset), SEEK_SET) < 0) {
perror("lseek");
exit(5);
}
strcpy(buf, "ZFS Test Suite Truncation Test");
if (write(fd, buf, bsize) < bsize) {
perror("write");
exit(6);
}
if (rflag) {
if (lseek(fd, (offset + roffset), SEEK_SET) < 0) {
perror("lseek");
exit(7);
}
if (read(fd, rbuf, bsize) < bsize) {
perror("read");
exit(8);
}
if (memcmp(buf, rbuf, bsize) != 0) {
perror("memcmp");
exit(9);
}
}
if (vflag) {
(void) fprintf(stderr,
"Wrote to offset %ld\n", (offset + roffset));
if (rflag) {
(void) fprintf(stderr,
"Read back from offset %ld\n", (offset + roffset));
}
}
(void) free(buf);
(void) free(rbuf);
}
static void
do_trunc(int fd)
{
off_t roffset = 0;
roffset = random() % fsize;
if (ftruncate(fd, (offset + roffset)) < 0) {
perror("truncate");
exit(7);
}
if (vflag) {
(void) fprintf(stderr,
"Truncated at offset %ld\n",
(offset + roffset));
}
}

View File

@ -0,0 +1,239 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
* $FreeBSD$
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "@(#)file_write.c 1.4 07/10/09 SMI"
#include "file_common.h"
#include <libgen.h>
static unsigned char bigbuffer[BIGBUFFERSIZE];
/*
* Writes (or appends) a given value to a file repeatedly.
* See header file for defaults.
*/
static void usage(void);
static char *execname;
int
main(int argc, char **argv)
{
int bigfd;
int c;
int oflag = 0;
int err = 0;
int k;
long i;
int64_t good_writes = 0;
uint8_t nxtfillchar;
/*
* Default Parameters
*/
int write_count = BIGFILESIZE;
uint8_t fillchar = DATA;
int block_size = BLOCKSZ;
char *filename = NULL;
char *operation = NULL;
off_t noffset, offset = 0;
int verbose = 0;
int rsync = 0;
int wsync = 0;
execname = argv[0];
/*
* Process Arguments
*/
while ((c = getopt(argc, argv, "b:c:d:s:f:o:vwr")) != -1) {
switch (c) {
case 'b':
block_size = atoi(optarg);
break;
case 'c':
write_count = atoi(optarg);
break;
case 'd':
fillchar = atoi(optarg);
break;
case 's':
offset = atoll(optarg);
break;
case 'f':
filename = optarg;
break;
case 'o':
operation = optarg;
break;
case 'v':
verbose = 1;
break;
case 'w':
wsync = 1;
break;
case 'r':
rsync = 1;
break;
case '?':
(void) printf("unknown arg %c\n", optopt);
usage();
break;
}
}
/*
* Validate Parameters
*/
if (!filename) {
(void) printf("Filename not specified (-f <file>)\n");
err++;
}
if (!operation) {
(void) printf("Operation not specified (-o <operation>).\n");
err++;
}
if (block_size > BIGBUFFERSIZE) {
(void) printf("block_size is too large max==%d.\n",
BIGBUFFERSIZE);
err++;
}
if (err) usage();
/*
* Prepare the buffer and determine the requested operation
*/
nxtfillchar = fillchar;
k = 0;
for (i = 0; i < block_size; i++) {
bigbuffer[i] = nxtfillchar;
if (fillchar == 0) {
if ((k % DATA_RANGE) == 0) {
k = 0;
}
nxtfillchar = k++;
}
}
/*
* using the strncmp of operation will make the operation match the
* first shortest match - as the operations are unique from the first
* character this means that we match single character operations
*/
if ((strncmp(operation, "create", strlen(operation) + 1)) == 0 ||
(strncmp(operation, "overwrite", strlen(operation) + 1)) == 0) {
oflag = (O_RDWR|O_CREAT);
} else if ((strncmp(operation, "append", strlen(operation) + 1)) == 0) {
oflag = (O_RDWR|O_APPEND);
} else {
(void) printf("valid operations are <create|append> not '%s'\n",
operation);
usage();
}
#ifdef UNSUPPORTED
if (rsync) {
oflag = oflag | O_RSYNC;
}
#endif
if (wsync) {
oflag = oflag | O_SYNC;
}
/*
* Given an operation (create/overwrite/append), open the file
* accordingly and perform a write of the appropriate type.
*/
if ((bigfd = open(filename, oflag, 0666)) == -1) {
(void) printf("open %s: failed [%s]%d. Aborting!\n", filename,
strerror(errno), errno);
exit(errno);
}
noffset = lseek(bigfd, offset, SEEK_SET);
if (noffset != offset) {
(void) printf("lseek %s (%lld/%lld) failed [%s]%d.Aborting!\n",
filename, offset, noffset, strerror(errno), errno);
exit(errno);
}
if (verbose) {
(void) printf("%s: block_size = %d, write_count = %d, "
"offset = %lld, data = %s%d\n", filename, block_size,
write_count, offset,
(fillchar == 0) ? "0->" : "",
(fillchar == 0) ? DATA_RANGE : fillchar);
}
for (i = 0; i < write_count; i++) {
ssize_t n;
if ((n = write(bigfd, &bigbuffer, block_size)) == -1) {
(void) printf("write failed (%ld), good_writes = %lld, "
"error: %s[%d]\n", (long)n, good_writes,
strerror(errno),
errno);
exit(errno);
}
good_writes++;
}
if (verbose) {
(void) printf("Success: good_writes = %lld (%lld)\n",
good_writes, (good_writes * block_size));
}
return (0);
}
static void
usage(void)
{
char *base = (char *)"file_write";
char *exec = (char *)execname;
if (exec != NULL)
exec = strdup(exec);
if (exec != NULL)
base = basename(exec);
(void) printf("Usage: %s [-v] -o {create,overwrite,append} -f file_name"
" [-b block_size]\n"
"\t[-s offset] [-c write_count] [-d data]\n"
"\twhere [data] equal to zero causes chars "
"0->%d to be repeated throughout\n", base, DATA_RANGE);
if (exec) {
free(exec);
}
exit(1);
}

View File

@ -0,0 +1,6 @@
#!/usr/local/bin/ksh93
# $FreeBSD$
echo dummy
exit 0

View File

@ -0,0 +1,6 @@
#!/usr/local/bin/ksh93
# $FreeBSD$
echo dummy
exit 0

View File

@ -0,0 +1,6 @@
#!/usr/local/bin/ksh93
# $FreeBSD$
echo dummy
exit 0

View File

@ -0,0 +1,13 @@
#! /usr/local/bin/ksh93 -p
# $FreeBSD$
a=
g=
for i in $*
do
a="$a $g"
g=$i
done
/usr/sbin/pw groupadd $g $a

View File

@ -0,0 +1,13 @@
#! /usr/local/bin/ksh93 -p
# $FreeBSD$
a=
g=
for i in $*
do
a="$a $g"
g=$i
done
/usr/sbin/pw groupdel $a $g

View File

@ -0,0 +1,13 @@
#! /usr/local/bin/ksh93 -p
# $FreeBSD$
a=
g=
for i in $*
do
a="$a $g"
g=$i
done
/usr/sbin/pw groupmod $g $a

View File

@ -0,0 +1,5 @@
#! /usr/local/bin/ksh93 -p
# $FreeBSD$
/usr/sbin/pw groupshow $*

View File

@ -0,0 +1,132 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
* $FreeBSD$
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "@(#)largest_file.c 1.3 07/05/25 SMI"
#include "file_common.h"
#include <sys/param.h>
#include <signal.h>
#include <stdio.h>
/*
* --------------------------------------------------------------
*
* Assertion:
* The last byte of the largest file size can be
* accessed without any errors. Also, the writing
* beyond the last byte of the largest file size
* will produce an errno of EFBIG.
*
* --------------------------------------------------------------
* If the write() system call below returns a "1",
* then the last byte can be accessed.
* --------------------------------------------------------------
*/
static void sigxfsz(int);
static void usage(char *);
int
main(int argc, char **argv)
{
int fd = 0;
off_t offset = (OFF_MAX - 1);
off_t lseek_ret = 0;
int write_ret = 0;
int err = 0;
char mybuf[5];
char *testfile;
if (argc != 2) {
usage(argv[0]);
}
(void) sigset(SIGXFSZ, sigxfsz);
testfile = strdup(argv[1]);
fd = open(testfile, O_CREAT | O_RDWR);
if (fd < 0) {
perror("Failed to create testfile");
err = errno;
goto out;
}
lseek_ret = lseek(fd, offset, SEEK_SET);
if (lseek_ret < 0) {
perror("Failed to seek to end of testfile");
err = errno;
goto out;
}
write_ret = write(fd, mybuf, 1);
if (write_ret < 0) {
perror("Failed to write to end of file");
err = errno;
goto out;
}
offset = 0;
lseek_ret = lseek(fd, offset, SEEK_CUR);
if (lseek_ret < 0) {
perror("Failed to seek to end of file");
err = errno;
goto out;
}
write_ret = write(fd, mybuf, 1);
if (write_ret < 0) {
if (errno == EFBIG) {
(void) printf("write errno=EFBIG: success\n");
err = 0;
} else {
perror("Did not receive EFBIG");
err = errno;
}
} else {
(void) printf("write completed successfully, test failed\n");
err = 1;
}
out:
(void) unlink(testfile);
free(testfile);
return (err);
}
static void
usage(char *name)
{
(void) printf("%s <testfile>\n", name);
exit(1);
}
/* ARGSUSED */
static void
sigxfsz(int signo)
{
(void) printf("\nlargest_file: sigxfsz() caught SIGXFSZ\n");
}

View File

@ -0,0 +1,214 @@
/*-
* Copyright (c) 2001-2013
* HATANO Tomomi. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifndef lint
static char rcsid[] = "$Id: mkfile.c,v 1.5 2013-10-26 10:11:34+09 hatanou Exp $";
#endif /* !lint */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <fcntl.h>
#include <limits.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <unistd.h>
#include <ctype.h>
#include <errno.h>
#define MKFILE_WBUF ((size_t)(1048576)) /* Is 1M a reasonable value? */
/* SunOS's mkfile(8) sets "sticky bit." */
#define MKFILE_FLAG (O_WRONLY | O_CREAT | O_TRUNC)
#define MKFILE_MODE (S_IRUSR | S_IWUSR | S_ISVTX)
static char buf[MKFILE_WBUF];
static int nofill = 0;
static int verbose = 0;
static void
usage()
{
fprintf(stderr,
"Usage: mkfile [-nv] <size>[e|p|t|g|m|k|b] <filename> ...\n");
}
static unsigned long long
getsize(char *s)
{
int sh;
unsigned long long length;
char *suffix;
/*
* NOTE: We don't handle 'Z' (zetta) or 'Y' (yotta) suffixes yet.
* These are too large to store in unsigned long long (64bits).
* In the future, we'll have to use larger type,
* something like uint128_t.
*/
length = strtoull(s, &suffix, 10);
sh = 0;
switch (tolower(*suffix)) {
case 'e': /* Exabytes. */
sh = 60;
break;
case 'p': /* Petabytes. */
sh = 50;
break;
case 't': /* Terabytes. */
sh = 40;
break;
case 'g': /* Gigabytes. */
sh = 30;
break;
case 'm': /* Megabytes. */
sh = 20;
break;
case 'k': /* Kilobytes. */
sh = 10;
break;
case 'b': /* Blocks. */
sh = 9;
break;
case '\0': /* Bytes. */
break;
default: /* Unknown... */
errno = EINVAL;
return 0;
}
if (sh) {
unsigned long long l;
l = length;
length <<= sh;
/* Check overflow. */
if ((length >> sh) != l) {
errno = ERANGE;
return 0;
}
}
return length;
}
static int
create_file(char *f, unsigned long long s)
{
int fd;
size_t w;
ssize_t ws;
if (verbose) {
fprintf(stdout, "%s %llu bytes\n", f, s);
fflush(stdout);
}
/* Open file to create. */
if ((fd = open(f, MKFILE_FLAG, MKFILE_MODE)) < 0) {
return -1;
}
/* Seek to the end and write 1 byte. */
if ((lseek(fd, (off_t)(s - 1LL), SEEK_SET) == (off_t)-1) ||
(write(fd, buf, (size_t)1) == (ssize_t)-1)) {
/*
* We don't close(fd) here to avoid overwriting errno.
* This is fd-leak, but is not harmful
* because returning error causes mkfile(8) to exit.
*/
return -1;
}
/* Fill. */
if (!nofill) {
if (lseek(fd, (off_t)0, SEEK_SET) == (off_t)-1) {
/* Same as above. */
return -1;
}
while (s) {
w = (s > MKFILE_WBUF) ? MKFILE_WBUF : s;
if ((ws = write(fd, buf, w)) == (ssize_t)-1) {
/* Same as above. */
return -1;
}
s -= ws;
}
}
close(fd);
return 0;
}
int
main(int argc, char *argv[])
{
unsigned long long fsize;
char ch;
/* We have at least 2 arguments. */
if (argc < 3) {
usage();
return EXIT_FAILURE;
}
/* Options. */
while ((ch = getopt(argc, argv, "nv")) != -1) {
switch (ch) {
case 'n':
nofill = 1;
break;
case 'v':
verbose = 1;
break;
default:
usage();
return EXIT_FAILURE;
}
}
argc -= optind;
argv += optind;
/* File size to create. */
if ((fsize = getsize(*argv)) == 0) {
perror(*argv);
return EXIT_FAILURE;
}
/* Filenames to create. */
bzero(buf, MKFILE_WBUF);
while (++argv, --argc) {
if (create_file(*argv, fsize) == -1) {
perror(*argv);
return EXIT_FAILURE;
}
}
return EXIT_SUCCESS;
}

View File

@ -0,0 +1,196 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
* $FreeBSD$
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "@(#)mktree.c 1.3 07/05/25 SMI"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/errno.h>
#include <sys/param.h>
#define TYPE_D 'D'
#define TYPE_F 'F'
extern int errno;
static char fdname[MAXPATHLEN] = {0};
static char *pbasedir = NULL;
static int nlevel = 2;
static int ndir = 2;
static int nfile = 2;
static void usage(char *this);
static void crtfile(char *pname);
static char *getfdname(char *pdir, char type, int level, int dir, int file);
static int mktree(char *pbasedir, int level);
int
main(int argc, char *argv[])
{
int c, ret;
while ((c = getopt(argc, argv, "b:l:d:f:")) != -1) {
switch (c) {
case 'b':
pbasedir = optarg;
break;
case 'l':
nlevel = atoi(optarg);
break;
case 'd':
ndir = atoi(optarg);
break;
case 'f':
nfile = atoi(optarg);
break;
case '?':
usage(argv[0]);
}
}
if (nlevel < 0 || ndir < 0 || nfile < 0 || pbasedir == NULL) {
usage(argv[0]);
}
ret = mktree(pbasedir, 1);
return (ret);
}
static void
usage(char *this)
{
(void) fprintf(stderr,
"\tUsage: %s -b <base_dir> -l [nlevel] -d [ndir] -f [nfile]\n",
this);
exit(1);
}
static int
mktree(char *pdir, int level)
{
int d, f;
char dname[MAXPATHLEN] = {0};
char fname[MAXPATHLEN] = {0};
if (level > nlevel) {
return (1);
}
for (d = 0; d < ndir; d++) {
(void) memset(dname, '\0', sizeof (dname));
(void) strcpy(dname, getfdname(pdir, TYPE_D, level, d, 0));
if (mkdir(dname, 0777) != 0) {
(void) fprintf(stderr, "mkdir(%s) failed."
"\n[%d]: %s.\n",
dname, errno, strerror(errno));
exit(errno);
}
/*
* No sub-directory need be created, only create files in it.
*/
if (mktree(dname, level+1) != 0) {
for (f = 0; f < nfile; f++) {
(void) memset(fname, '\0', sizeof (fname));
(void) strcpy(fname,
getfdname(dname, TYPE_F, level+1, d, f));
crtfile(fname);
}
}
}
for (f = 0; f < nfile; f++) {
(void) memset(fname, '\0', sizeof (fname));
(void) strcpy(fname, getfdname(pdir, TYPE_F, level, d, f));
crtfile(fname);
}
return (0);
}
static char *
getfdname(char *pdir, char type, int level, int dir, int file)
{
(void) snprintf(fdname, sizeof (fdname),
"%s/%c-l%dd%df%d", pdir, type, level, dir, file);
return (fdname);
}
static void
crtfile(char *pname)
{
int fd = -1;
int afd = -1;
int i, size;
char *context = "0123456789ABCDF";
char *pbuf;
if (pname == NULL) {
exit(1);
}
size = sizeof (char) * 1024;
pbuf = (char *)valloc(size);
for (i = 0; i < size / strlen(context); i++) {
int offset = i * strlen(context);
(void) snprintf(pbuf+offset, size-offset, "%s", context);
}
if ((fd = open(pname, O_CREAT|O_RDWR, 0777)) < 0) {
(void) fprintf(stderr, "open(%s, O_CREAT|O_RDWR, 0777) failed."
"\n[%d]: %s.\n", pname, errno, strerror(errno));
exit(errno);
}
if (write(fd, pbuf, 1024) < 1024) {
(void) fprintf(stderr, "write(fd, pbuf, 1024) failed."
"\n[%d]: %s.\n", errno, strerror(errno));
exit(errno);
}
#if UNSUPPORTED
if ((afd = openat(fd, "xattr", O_CREAT | O_RDWR | O_XATTR, 0777)) < 0) {
(void) fprintf(stderr, "openat failed.\n[%d]: %s.\n",
errno, strerror(errno));
exit(errno);
}
if (write(afd, pbuf, 1024) < 1024) {
(void) fprintf(stderr, "write(afd, pbuf, 1024) failed."
"\n[%d]: %s.\n", errno, strerror(errno));
exit(errno);
}
(void) close(afd);
#endif
(void) close(fd);
free(pbuf);
}

View File

@ -0,0 +1,99 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
* $FreeBSD$
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "@(#)mmapwrite.c 1.4 07/05/25 SMI"
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <pthread.h>
/*
* --------------------------------------------------------------------
* Bug Id: 5032643
*
* Simply writing to a file and mmaping that file at the same time can
* result in deadlock. Nothing perverse like writing from the file's
* own mapping is required.
* --------------------------------------------------------------------
*/
static void *
mapper(void *fdp)
{
void *addr;
int fd = *(int *)fdp;
if ((addr =
mmap(0, 8192, PROT_READ, MAP_SHARED, fd, 0)) == MAP_FAILED) {
perror("mmap");
exit(1);
}
for (;;) {
if (mmap(addr, 8192, PROT_READ,
MAP_SHARED|MAP_FIXED, fd, 0) == MAP_FAILED) {
perror("mmap");
exit(1);
}
}
/* NOTREACHED */
return ((void *)1);
}
int
main(int argc, char **argv)
{
int fd;
char buf[BUFSIZ];
pthread_t pt;
if (argc != 2) {
(void) printf("usage: %s <file name>\n", argv[0]);
exit(1);
}
if ((fd = open(argv[1], O_RDWR|O_CREAT|O_TRUNC, 0666)) == -1) {
perror("open");
exit(1);
}
if (pthread_create(&pt, NULL, mapper, &fd) != 0) {
perror("pthread_create");
exit(1);
}
for (;;) {
if (write(fd, buf, sizeof (buf)) == -1) {
perror("write");
exit(1);
}
}
/* NOTREACHED */
return (0);
}

View File

@ -0,0 +1,104 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
* $FreeBSD$
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "@(#)randfree_file.c 1.3 07/05/25 SMI"
#include "file_common.h"
/*
* Create a file with assigned size and then free the specified
* section of the file
*/
static void usage(char *progname);
static void
usage(char *progname)
{
(void) fprintf(stderr,
"usage: %s [-l filesize] [-s start-offset]"
"[-n section-len] filename\n", progname);
exit(1);
}
int
main(int argc, char *argv[])
{
char *filename, *buf;
size_t filesize;
off_t start_off, off_len;
int fd, ch;
struct flock fl;
while ((ch = getopt(argc, argv, "l:s:n:")) != EOF) {
switch (ch) {
case 'l':
filesize = atoll(optarg);
break;
case 's':
start_off = atoll(optarg);
break;
case 'n':
off_len = atoll(optarg);
break;
default:
usage(argv[0]);
break;
}
}
if (optind == argc - 1)
filename = argv[optind];
else
usage(argv[0]);
buf = (char *)malloc(filesize);
if ((fd = open(filename, O_RDWR|O_CREAT|O_TRUNC)) < 0) {
perror("open");
return (1);
}
if (write(fd, buf, filesize) < filesize) {
perror("write");
return (1);
}
#if UNSUPPORTED
fl.l_whence = SEEK_SET;
fl.l_start = start_off;
fl.l_len = off_len;
if (fcntl(fd, F_FREESP, &fl) != 0) {
perror("fcntl");
return (1);
}
#else
fprintf(stderr, "fcntl: F_FREESP not supported\n");
return (1);
#endif
free(buf);
return (0);
}

View File

@ -0,0 +1,140 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
* $FreeBSD$
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "@(#)readmmap.c 1.4 07/05/25 SMI"
/*
* --------------------------------------------------------------
* BugId 5047993 : Getting bad read data.
*
* Usage: readmmap <filename>
*
* where:
* filename is an absolute path to the file name.
*
* Return values:
* 1 : error
* 0 : no errors
* --------------------------------------------------------------
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/mman.h>
int
main(int argc, char **argv)
{
char *filename = "badfile";
size_t size = 4395;
size_t idx = 0;
char *buf = NULL;
char *map = NULL;
int fd = -1, bytes, retval = 0;
unsigned seed;
if (argc < 2 || optind == argc) {
(void) fprintf(stderr,
"usage: %s <file name>\n", argv[0]);
exit(1);
}
if ((buf = calloc(1, size)) == NULL) {
perror("calloc");
exit(1);
}
filename = argv[optind];
(void) remove(filename);
fd = open(filename, O_RDWR|O_CREAT|O_TRUNC, 0666);
if (fd == -1) {
perror("open to create");
retval = 1;
goto end;
}
bytes = write(fd, buf, size);
if (bytes != size) {
(void) printf("short write: %d != %ud\n", bytes, size);
retval = 1;
goto end;
}
map = mmap(0, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
if (map == MAP_FAILED) {
perror("mmap");
retval = 1;
goto end;
}
seed = time(NULL);
srandom(seed);
idx = random() % size;
map[idx] = 1;
if (msync(map, size, MS_SYNC) != 0) {
perror("msync");
retval = 1;
goto end;
}
if (munmap(map, size) != 0) {
perror("munmap");
retval = 1;
goto end;
}
bytes = pread(fd, buf, size, 0);
if (bytes != size) {
(void) printf("short read: %d != %ud\n", bytes, size);
retval = 1;
goto end;
}
if (buf[idx] != 1) {
(void) printf(
"bad data from read! got buf[%ud]=%d, expected 1\n",
idx, buf[idx]);
retval = 1;
goto end;
}
(void) printf("good data from read: buf[%ud]=1\n", idx);
end:
if (fd != -1) {
(void) close(fd);
}
if (buf != NULL) {
free(buf);
}
return (retval);
}

View File

@ -0,0 +1,92 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
* $FreeBSD$
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "@(#)rename_dir.c 1.1 07/05/25 SMI"
/*
* Assertion:
* Create two directory trees in zfs filesystem, and rename
* directory across the directory structure. ZFS can handle
* the race situation.
*/
/*
* Need to create the following directory structures before
* running this program:
*
* mkdir -p 1/2/3/4/5 a/b/c/d/e
*/
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
int
main()
{
int i = 1;
char buf[256];
char *msg = "rename() fails to handle race situation\n";
switch (fork()) {
case -1:
perror("fork");
exit(1);
break;
case 0:
while (i > 0) {
int c_count = 0;
if (rename("a/b/c", "1/2/3/c") == 0)
c_count++;
if (rename("1/2/3/c", "a/b/c") == 0)
c_count++;
if (c_count) {
(void) strlcat(buf, "c_count: %d,", 256);
(void) strlcat(buf, msg, 256);
(void) fprintf(stderr, buf, c_count);
}
}
break;
default:
while (i > 0) {
int p_count = 0;
if (rename("1", "a/b/c/d/e/1") == 0)
p_count++;
if (rename("a/b/c/d/e/1", "1") == 0)
p_count++;
if (p_count) {
(void) strlcat(buf, "p_count: %d,", 256);
(void) strlcat(buf, msg, 256);
(void) fprintf(stderr, buf, p_count);
}
}
break;
}
return (0);
}

View File

@ -0,0 +1,148 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
* $FreeBSD$
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "@(#)rm_lnkcnt_zero_file.c 1.3 07/05/25 SMI"
/*
* --------------------------------------------------------------------
* The purpose of this test is to see if the bug reported (#4723351) for
* UFS exists when using a ZFS file system.
* --------------------------------------------------------------------
*
*/
#define _REENTRANT 1
#include <stdio.h>
#include <fcntl.h>
#include <pthread.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <unistd.h>
static const int TRUE = 1;
static char *filebase;
static int
pickidx()
{
return (random() % 1000);
}
/* ARGSUSED */
static void *
mover(void *a)
{
char buf[256];
int idx, ret;
while (TRUE) {
idx = pickidx();
(void) sprintf(buf, "%s.%03d", filebase, idx);
ret = rename(filebase, buf);
if (ret < 0 && errno != ENOENT)
(void) perror("renaming file");
}
return (NULL);
}
/* ARGSUSED */
static void *
cleaner(void *a)
{
char buf[256];
int idx, ret;
while (TRUE) {
idx = pickidx();
(void) sprintf(buf, "%s.%03d", filebase, idx);
ret = remove(buf);
if (ret < 0 && errno != ENOENT)
(void) perror("removing file");
}
return (NULL);
}
static void *
writer(void *a)
{
int *fd = (int *)a;
while (TRUE) {
(void) close (*fd);
*fd = open(filebase, O_APPEND | O_RDWR | O_CREAT, 0644);
if (*fd < 0)
perror("refreshing file");
(void) write(*fd, "test\n", 5);
}
return (NULL);
}
int
main(int argc, char **argv)
{
int fd;
pthread_t tid;
if (argc == 1) {
(void) printf("Usage: %s <filebase>\n", argv[0]);
exit(-1);
}
filebase = argv[1];
fd = open(filebase, O_APPEND | O_RDWR | O_CREAT, 0644);
if (fd < 0) {
perror("creating test file");
exit(-1);
}
if (pthread_setconcurrency(4)) { /* 3 threads + main */
fprintf(stderr, "failed to set concurrency\n");
exit(-1);
}
(void) pthread_create(&tid, NULL, mover, NULL);
(void) pthread_create(&tid, NULL, cleaner, NULL);
(void) pthread_create(&tid, NULL, writer, (void *) &fd);
while (TRUE) {
int ret;
struct stat st;
ret = stat(filebase, &st);
if (ret == 0 && (st.st_nlink > 2 || st.st_nlink < 1)) {
(void) printf("st.st_nlink = %d, exiting\n", \
(int)st.st_nlink);
exit(0);
}
(void) sleep(1);
}
return (0);
}

View File

@ -0,0 +1,6 @@
#!/usr/local/bin/ksh93
# $FreeBSD$
echo dummy
exit 0

View File

@ -0,0 +1,5 @@
#! /usr/local/bin/ksh93 -p
# $FreeBSD$
swapinfo

View File

@ -0,0 +1,8 @@
#!/usr/bin/env ksh93
script=$(realpath $0)
export STF_BIN=$(dirname ${script})
export STF_SUITE=$(dirname ${STF_BIN})
# $FreeBSD$
env ENV=${STF_SUITE}/include/testenv.kshlib ksh93 -E -l

View File

@ -0,0 +1,13 @@
#! /usr/local/bin/ksh93 -p
# $FreeBSD$
a=
g=
for i in $*
do
a="$a $g"
g=$i
done
/usr/sbin/pw useradd $g $a

View File

@ -0,0 +1,13 @@
#! /usr/local/bin/ksh93 -p
# $FreeBSD$
a=
g=
for i in $*
do
a="$a $g"
g=$i
done
/usr/sbin/pw userdel $g $a

View File

@ -0,0 +1,13 @@
#! /usr/local/bin/ksh93 -p
# $FreeBSD$
a=
g=
for i in $*
do
a="$a $g"
g=$i
done
/usr/sbin/pw usermod $g $a

View File

@ -0,0 +1,44 @@
#! /usr/local/bin/ksh93 -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# $FreeBSD$
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "@(#)zfs.ksh 1.2 09/01/13 SMI"
#
ZFS=/sbin/zfs
set -A saved_options -- "$@"
for wrapper in ${ZFS_WRAPPER} ; do
if [[ -x ${STF_SUITE}/bin/zfs_$wrapper ]]; then
options=$(${STF_SUITE}/bin/zfs_$wrapper "${saved_options[@]}")
set -A saved_options -- $options
fi
done
$ZFS "${saved_options[@]}"
return $?

View File

@ -0,0 +1,59 @@
#! /usr/local/bin/ksh93 -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# $FreeBSD$
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "@(#)zfs_crypto.ksh 1.2 09/05/19 SMI"
#
cmd=$1
shift
options="$@"
case $cmd in
create)
# Get zfs name
# eval zfsname=\${$#}
if [[ $KEYSOURCE_DATASET == "passphrase" ]]; then
options="-o encryption=$ENCRYPTION \
-o keysource=passphrase,file://$PASSPHRASE_FILE $options"
elif [[ $KEYSOURCE_DATASET == "raw" ]]; then
options="-o encryption=$ENCRYPTION \
-o keysource=raw,file://$RAW_KEY_FILE $options"
elif [[ $KEYSOURCE_DATASET == "hex" ]]; then
options="-o encryption=$ENCRYPTION \
-o keysource=hex,file://$HEX_KEY_FILE $options"
elif [[ -n $KEYSOURCE_DATASET ]]; then
log_note "Warning: invalid KEYSOURCE_DATASET \c"
log_note "value: $KEYSOURCE_DATASET, ignore it"
fi
;;
*)
;;
esac
print $cmd $options

View File

@ -0,0 +1,68 @@
#! /usr/local/bin/ksh93 -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# $FreeBSD$
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "@(#)zfs_version.ksh 1.1 09/01/13 SMI"
#
cmd=$1
shift
options="$@"
o_version_option="no"
V_option="no"
while getopts :o:V: c
do
case $c in
o)
if [[ "$OPTARG" == "version="* ]]; then
o_version_option="yes"
fi
;;
V)
V_option="yes"
;;
*)
;;
esac
done
shift $(($OPTIND - 1))
case $cmd in
create)
if [[ "$ZFS_TEST_VERSION" != "0" ]] &&
[[ "$o_version_option" == "no" ]] &&
[[ "$V_option" == "no" ]]; then
options="-o version=$ZFS_TEST_VERSION $options"
fi
;;
*)
;;
esac
print "$cmd $options"

View File

@ -0,0 +1,6 @@
#!/usr/local/bin/ksh93
# $FreeBSD$
echo dummy
exit 0

View File

@ -0,0 +1,6 @@
#!/usr/local/bin/ksh93
# $FreeBSD$
echo global
exit 0

View File

@ -0,0 +1,6 @@
#!/usr/local/bin/ksh93
# $FreeBSD$
echo dummy
exit 0

View File

@ -0,0 +1,46 @@
#! /usr/local/bin/ksh93 -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# $FreeBSD$
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "@(#)zpool.ksh 1.2 09/01/13 SMI"
#
. ${STF_SUITE}/include/libtest.kshlib
ZPOOL=/sbin/zpool
set -A saved_options -- "$@"
for wrapper in ${ZPOOL_WRAPPER} ; do
if [[ -x ${STF_SUITE}/bin/zpool_$wrapper ]]; then
options=$(${STF_SUITE}/bin/zpool_$wrapper "${saved_options[@]}")
set -A saved_options -- $options
fi
done
$ZPOOL "${saved_options[@]}"
return $?

View File

@ -0,0 +1,42 @@
#!/usr/local/bin/ksh93 -p
#
# $FreeBSD$
cmd=$1
if [[ -z $cmd ]]; then
return 0
fi
shift
typeset option
case $cmd in
create|add|attach|detach|replace|remove|online|offline|clear)
for arg in $@; do
if [[ $arg == "/dev/dsk/"* ]]; then
arg=${arg#/dev/dsk/}
arg="/dev/"$arg
fi
if [[ $arg == "/dev/"* ]]; then
echo $arg | egrep "*s[0-9]$" > /dev/null 2>&1
if [ $? -eq 0 ]
then
n=`echo $arg| wc -c`
set -A map a b c d e f g h i j
s=`echo $arg | cut -c $((n-1))`
arg=${arg%s[0-9]}${map[$s]}
fi
fi
option="${option} $arg"
done
;;
*)
option="$@"
;;
esac
echo $cmd $option

View File

@ -0,0 +1,138 @@
#!/usr/local/bin/ksh93 -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# $FreeBSD$
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "@(#)zpool_smi.ksh 1.2 09/01/13 SMI"
#
function labelvtoc
{
typeset disk=$1
if [[ -z $disk ]]; then
print "no disk is given."
return 1
fi
/usr/sbin/format $disk << _EOF >/dev/null 2>&1
label
yes
_EOF
labeltype=$(/usr/sbin/prtvtoc -fh /dev/rdsk/${disk}s2 | \
awk '{print $1}' | awk -F= '{print $2}' )
if [[ -z $labeltype ]]; then
print "${disk} not exist."
return 1
fi
if [[ $labeltype == "34" ]]; then
typeset label_file=$TMPDIR/labelvtoc.${TESTCASE_ID:-$$}
typeset arch=$(uname -p)
if [[ $arch == "i386" ]]; then
print "label" > $label_file
print "0" >> $label_file
print "" >> $label_file
print "q" >> $label_file
print "q" >> $label_file
fdisk -B /dev/rdsk/${disk}p0 >/dev/null 2>&1
# wait a while for fdisk finishes
/usr/sbin/devfsadm > /dev/null 2>&1
elif [[ $arch == "sparc" ]]; then
print "label" > $label_file
print "0" >> $label_file
print "" >> $label_file
print "" >> $label_file
print "" >> $label_file
print "q" >> $label_file
else
print "unknow arch type : $arch"
return 1
fi
format -e -s -d $disk -f $label_file
typeset -i ret_val=$?
rm -f $label_file
#
# wait the format to finish
#
/usr/sbin/devfsadm > /dev/null 2>&1
if (( ret_val != 0 )); then
print "unable to label $disk as VTOC."
return 1
fi
fi
return 0
}
cmd=$1
if [[ -z $cmd ]]; then
return 0
fi
shift
typeset option
case $cmd in
create|add|attach|detach|replace|remove|online|offline|clear)
for arg in $@; do
if [[ $arg == "/dev/dsk/"* ]]; then
arg=${arg#/dev/dsk/}
fi
print $arg | egrep "^c[0-F]+([td][0-F]+)+$" > /dev/null 2>&1
if [[ $? -eq 0 ]] ; then
labelvtoc $arg
if [[ $? -eq 0 ]] ; then
arg=${arg}s2
fi
fi
option="${option} $arg"
done
;;
*)
option="$@"
;;
esac
case $cmd in
create|add|attach|replace)
if [[ $option != *"-f"* ]]; then
cmd="${cmd} -f"
fi
;;
*)
;;
esac
print $cmd $option

View File

@ -0,0 +1,73 @@
#! /usr/local/bin/ksh93 -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# $FreeBSD$
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "@(#)zpool_version.ksh 1.1 09/01/13 SMI"
#
cmd=$1
shift
options="$@"
o_version_option="no"
O_version_option="no"
while getopts :o:O: c
do
case $c in
o)
if [[ "$OPTARG" == "version="* ]]; then
o_version_option="yes"
fi
;;
O)
if [[ "$OPTARG" == "version="* ]]; then
O_version_option="yes"
fi
;;
*)
;;
esac
done
shift $(($OPTIND - 1))
case $cmd in
create)
if [[ "$ZFS_TEST_VERSION" != "0" ]] &&
[[ "$O_version_option" == "no" ]]; then
options="-O version=$ZFS_TEST_VERSION $options"
fi
if [[ "$ZPOOL_TEST_VERSION" != "0" ]] &&
[[ "$o_version_option" == "no" ]]; then
options="-o version=$ZPOOL_TEST_VERSION $options"
fi
;;
*)
;;
esac
print "$cmd $options"

View File

@ -0,0 +1,32 @@
# $FreeBSD$
.include <src.opts.mk>
PACKAGE= tests
TESTSDIR=${TESTSBASE}/sys/cddl/zfs/include
STFSUITEDIR=${TESTSBASE}/sys/cddl/zfs
MAN=
FILESDIR= ${TESTSBASE}/sys/cddl/zfs/include
${PACKAGE}FILES+= constants.cfg
${PACKAGE}FILES+= libremote.kshlib
${PACKAGE}FILES+= libgnop.kshlib
${PACKAGE}FILES+= logapi.kshlib
${PACKAGE}FILES+= libtest.kshlib
${PACKAGE}FILES+= stf.shlib
${PACKAGE}FILES+= testenv.kshlib
${PACKAGE}FILES+= commands.cfg
CLEANFILES+= commands.cfg
commands.cfg: translatecommands.awk commands.txt
awk -v stfsuitedir=${STFSUITEDIR} -f ${.ALLSRC} > ${.TARGET}
${PACKAGE}FILES+= default.cfg
CLEANFILES+= default.cfg
default.cfg: default.cfg.in
sed "s:%%STFSUITEDIR%%:${STFSUITEDIR}:" ${.ALLSRC} > ${.TARGET}
ATF_TESTS_KSH93+= libtest_test
.include <bsd.test.mk>

View File

@ -0,0 +1,194 @@
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# $FreeBSD$
#!/usr/local/bin/ksh93 -p
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#ident "@(#)commands.txt 1.8 09/01/13 SMI"
#
# All the commands in this file are converted into environment variables
# with the same name as the command e.g.
#
# /bin/df becomes export DF="/bin/df"
# finally an export CMDS="aggregation of all the environment variables"
# is created for checking in the execution environment.
#
# comments are ignored in this file, as are whitespace lines
# General Solaris Commands
/usr/bin/awk
/usr/sbin/arp
/usr/bin/basename
/usr/bin/bzcat
/bin/cat
/usr/bin/cd
/usr/bin/chgrp
/bin/chmod
/usr/sbin/chown
/usr/bin/cksum
/sbin/clri
/usr/bin/cmp
/usr/bin/compress
/usr/bin/uncompress
#/usr/bin/coreadm
/bin/cp
/usr/bin/cpio
/usr/bin/cut
/bin/date
/bin/dd
#/usr/sbin/devfsadm
%%STFSUITEDIR%%/bin/df
/usr/bin/diff
%%STFSUITEDIR%%/bin/dircmp
/usr/bin/dirname
/usr/bin/du
#%%STFSUITEDIR%%/bin/dumpadm
/bin/echo
/usr/bin/egrep
/usr/bin/env
#%%STFSUITEDIR%%/bin/ff
/usr/bin/fgrep
/usr/bin/file
/usr/bin/find
#%%STFSUITEDIR%%/bin/fmadm
#%%STFSUITEDIR%%/bin/fmdump
#%%STFSUITEDIR%%/bin/format
/sbin/fsck
/sbin/fsdb
/sbin/fsirand
/usr/bin/fsync
/usr/sbin/fstyp
/usr/bin/id
#/usr/bin/isainfo
#/usr/sbin/iscsiadm
#/usr/sbin/iscsitadm
/usr/bin/getent
/bin/getfacl
/usr/bin/getconf
/sbin/sha1
/sbin/gpart
/usr/bin/grep
/usr/bin/groups
%%STFSUITEDIR%%/bin/groupadd
%%STFSUITEDIR%%/bin/groupdel
%%STFSUITEDIR%%/bin/groupmod
%%STFSUITEDIR%%/bin/groupshow
/usr/bin/head
/bin/hostname
/bin/kill
/usr/local/bin/ksh93
#/usr/sbin/labelit
#/usr/sbin/lockfs
#/usr/sbin/lofiadm
/bin/ls
/usr/bin/logname
#/usr/bin/mdb
/sbin/mdconfig
#/usr/sbin/metaclear
#/usr/sbin/metadb
#/usr/sbin/metainit
#/usr/sbin/metastat
/bin/mkdir
/sbin/mknod
#/usr/sbin/modinfo
#/usr/sbin/modunload
/sbin/mount
/bin/mv
#/usr/sbin/ncheck
/sbin/newfs
/usr/bin/nawk
#/usr/bin/pack
/usr/bin/pagesize
/bin/pax
/sbin/ping
/usr/bin/printf
#/usr/sbin/prtvtoc
#/usr/bin/pfexec
/bin/pgrep
#/usr/bin/pkginfo
/bin/pkill
/bin/ps
#/usr/sbin/psrinfo
/bin/pwd
/usr/sbin/quotaon
/bin/rcp
/sbin/reboot
/bin/rm
/bin/rmdir
/usr/bin/rsh
#/usr/bin/runat
/usr/bin/sed
#/usr/sbin/share
/bin/sleep
/usr/bin/su
/usr/bin/sum
#%%STFSUITEDIR%%/bin/svcs
#/usr/sbin/svcadm
#%%STFSUITEDIR%%/bin/swap
#/sbin/swapadd
/usr/bin/sort
/usr/bin/stat
/usr/bin/strings
/bin/sync
/usr/bin/tar
/usr/bin/tail
/usr/bin/timeout
/usr/bin/touch
/usr/bin/tr
/usr/bin/true
/usr/bin/truncate
/sbin/tunefs
#/usr/sbin/ufsdump
#/usr/sbin/ufsrestore
/usr/bin/umask
/sbin/umount
/usr/bin/uname
/usr/bin/uniq
#/usr/sbin/unshare
#/usr/bin/unpack
%%STFSUITEDIR%%/bin/useradd
%%STFSUITEDIR%%/bin/userdel
%%STFSUITEDIR%%/bin/usermod
/usr/bin/wait
/usr/bin/wc
#%%STFSUITEDIR%%/bin/zoneadm
#%%STFSUITEDIR%%/bin/zonecfg
#%%STFSUITEDIR%%/bin/zlogin
#/usr/bin/zonename
/sbin/swapon
/sbin/swapoff
/sbin/swapctl
/usr/bin/xargs
/usr/sbin/zfsd
# ZFS Commands
/usr/sbin/zdb
/sbin/zfs
/sbin/zpool
/usr/bin/zinject
# Test framework commands
#/opt/SUNWstc-runwattr/bin/runwattr
%%STFSUITEDIR%%/bin/bsddisks

View File

@ -0,0 +1,113 @@
#!/usr/bin/env ksh93
# vim: filetype=sh
# $FreeBSD$
# Add test-specific binaries to PATH
export PATH=${STF_SUITE}/bin:${PATH}
export TMPDIR=${TMPDIR-/tmp}
# Set default value of TMPDIR
export TMPDIR=${TMPDIR-/tmp}
# Define run length constants
export RT_LONG="3"
export RT_MEDIUM="2"
export RT_SHORT="1"
# Define macro for zone test
export ZONE_POOL="zonepool"
export ZONE_CTR="zonectr"
# Test Suite Specific Commands
export DEVNAME2DEVID="devname2devid"
export FILE_WRITE="file_write"
export FILE_CHECK="file_check"
export LARGEST_FILE="largest_file"
export MMAPWRITE="mmapwrite"
export MKFILE="mkfile"
export READMMAP="readmmap"
export FILE_TRUNC="file_trunc"
export CHG_USR_EXEC="chg_usr_exec"
export MKTREE="mktree"
export RANDFREE_FILE="randfree_file"
export DIR_RD_UPDATE="dir_rd_update"
export RM_LNKCNT_ZERO_FILE="rm_lnkcnt_zero_file"
export RENAME_DIR="rename_dir"
# ensure we're running in the C locale, since
# localised messages may result in test failures
export LC_ALL="C"
export LANG="C"
#
# pattern to ignore from 'zpool list'.
#
export NO_POOLS="no pools available"
# pattern to ignore from 'zfs list'.
export NO_DATASETS="no datasets available"
export TEST_BASE_DIR="/"
# Default to compression ON
export COMPRESSION_PROP=on
# Default to using the checksum
export CHECKSUM_PROP=on
# some common variables used by test scripts :
export TESTCASE_ID=${TESTCASE_ID:-$$}
# some test pool names
export TESTPOOL=testpool.${TESTCASE_ID}
export TESTPOOL1=testpool1.${TESTCASE_ID}
export TESTPOOL2=testpool2.${TESTCASE_ID}
export TESTPOOL3=testpool3.${TESTCASE_ID}
# some test file system names
export TESTCTR=testctr${TESTCASE_ID}
export TESTFS=testfs.${TESTCASE_ID}
export TESTFS1=testfs1.${TESTCASE_ID}
export TESTFS2=testfs2.${TESTCASE_ID}
export TESTFS3=testfs3.${TESTCASE_ID}
# some test directory names
export TESTDIR=${TEST_BASE_DIR%%/}/testdir${TESTCASE_ID}
export TESTDIR0=${TEST_BASE_DIR%%/}/testdir0${TESTCASE_ID}
export TESTDIR1=${TEST_BASE_DIR%%/}/testdir1${TESTCASE_ID}
export TESTDIR2=${TEST_BASE_DIR%%/}/testdir2${TESTCASE_ID}
# Default to limit disks to be checked
export MAX_FINDDISKSNUM=100
# For iscsi target support
export ISCSITGTFILE=$TMPDIR/iscsitgt_file
export ISCSITGT_FMRI=svc:/system/iscsitgt:default
if [ -n "$SVCS" ]; then
export AUTO_SNAP=$($SVCS -a | $GREP auto-snapshot | $GREP online | $AWK '{print $3}')
fi
# zfs upgrade should output the first line as:
# This system is currently running ZFS filesystem version 2.
# .
ZFS_VERSION=
$ZFS upgrade -v > /dev/null 2>&1
if [ $? -eq 0 ]; then
export ZFS_VERSION=$($ZFS upgrade | $HEAD -1 | $AWK '{print $NF}' \
| $SED -e 's/\.//g')
fi
if [ -n "$ZFS_VERSION" ]; then
i=1
ZFS_ALL_VERSIONS=""
while [ "$i" -le "$ZFS_VERSION" ]; do
eval 'export ZFS_VERSION_$i="v${i}-fs"'
ZFS_ALL_VERSIONS="$ZFS_ALL_VERSIONS $i"
i=$(( i + 1 ))
done
export ZFS_ALL_VERSIONS
fi
$TRUE

View File

@ -0,0 +1,52 @@
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# $FreeBSD$
#
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "@(#)default.cfg 1.8 08/11/03 SMI"
#
# Read the user config file, if it exists
#
export STF_SUITE=%%STFSUITEDIR%%
. $STF_SUITE/include/libtest.kshlib
# source the autogenerated commands.cfg file (built from the commands.txt file
. $STF_SUITE/include/commands.cfg
# Turn ATF variables into environment variables
export DISKS=`atf_config_get disks ""`
export KEEP=`atf_config_get keep_pools "" | ${SED} -E 's/ +/|/g'`
export TESTCASE_ID=$(echo $(atf_get ident) | cksum -o 2 | cut -f 1 -d " ")
. $STF_SUITE/include/constants.cfg
# finally, if we're running in a local zone
# we take some additional actions
if ! is_global_zone; then
reexport_pool
fi

View File

@ -0,0 +1,98 @@
# vim: filetype=sh
#
# Copyright (c) 2017 Spectra Logic Corporation
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions, and the following disclaimer,
# without modification.
# 2. Redistributions in binary form must reproduce at minimum a disclaimer
# substantially similar to the "NO WARRANTY" disclaimer below
# ("Disclaimer") and any redistribution must be conditioned upon
# including a substantially similar Disclaimer requirement for further
# binary redistribution.
#
# NO WARRANTY
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGES.
#
# $FreeBSD$
#
#
# Routines that use gnop(8) to simulate devices that can disappear at any time
#
# Create a gnop device on top of a real device. Don't use the full extent; use
# a portion in the middle so that any ZFS label present on the real device
# won't be present on the gnop device and vice versa.
function create_gnop
{
# Name of disk to use, with or without /dev/
typeset disk=$1
# Optional physical path to use
typeset physpath=$2
# size of disk in bytes
typeset -li disk_size
# disk size, rounded down to multiple of 16384
typeset -li disk_size_rounded
# size of the nop device in bytes
typeset -li nop_size
# offset of the beginning of the nop device in bytes
typeset -li nop_offset
typeset args
disk_size=`diskinfo $disk | cut -f 3`
# Round it down so the nop device will be 4k-aligned
disk_size_rounded=$(( ${disk_size} / 16384 * 16384 ))
nop_size=$(( ${disk_size_rounded} / 4 ))
nop_offset=${nop_size}
args="-s ${nop_size} -o ${nop_offset}"
if [ -n "$physpath" ]; then
args="$args -z $physpath"
fi
gnop create ${args} ${disk}
}
# Create multiple gnop devices
function create_gnops
{
typeset disk
for disk in $@; do
create_gnop "$disk" || return 1
done
return 0
}
# Destroy a gnop device.
function destroy_gnop
{
# Name of the underlying (non-gnop) device
typeset disk=$1
# Use "-f" so we can destroy a gnop with a consumer (like ZFS)
gnop destroy -f ${disk}.nop
}
# Destroy multiple gnop devices. Attempt to destroy them all, ignoring errors
function destroy_gnops
{
typeset disk
for disk in $@; do
destroy_gnop "$disk"
done
return 0
}

View File

@ -0,0 +1,47 @@
# vim: filetype=sh
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# $FreeBSD$
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "@(#)libremote.kshlib 1.1 07/05/25 SMI"
#
# Check if a package is installed
# $1 package name
# Return 0 if it is installed; 1 if not installed
function pkg_isinstalled
{
/usr/bin/pkginfo -q $1
return $?
}
# Get the installation base for a package
# $1 package name
# Return
function pkg_getinstbase
{
/bin/echo $(/usr/bin/pkginfo -r $1 2>/dev/null)
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,44 @@
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# $FreeBSD$
#
# Copyright 2016 Spectra Logic. All rights reserved.
# Use is subject to license terms.
#
atf_test_case raidz_dva_to_block_addr
raidz_dva_to_block_addr_head()
{
atf_set "descr" "Unit tests for raidz_dva_to_block_addr"
}
raidz_dva_to_block_addr_body()
{
. $(atf_get_srcdir)/default.cfg
# These test cases were determined by hand on an actual filesystem
atf_check_equal 3211 `raidz_dva_to_block_addr 0:3f40000:4000 3 13`
}
atf_init_test_cases()
{
atf_add_test_case raidz_dva_to_block_addr
}

View File

@ -0,0 +1,419 @@
# vim: filetype=sh
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# $FreeBSD$
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "@(#)logapi.kshlib 1.2 07/03/14 SMI"
#
#
# This is a ksh function library. It is intended to be sourced into
# other ksh scripts and not executed directly.
#
. ${STF_SUITE}/include/stf.shlib
#
# Send a debug message to stderr, if $STF_DEBUG set.
#
function log_debug
{
[ -z "$STF_DEBUG" ] && return
echo "$*" >&2
}
# Output an assertion
#
# $@ - assertion text
function log_assert
{
_printline ASSERTION: "$@"
}
# Output a comment
#
# $@ - comment text
function log_note
{
_printline NOTE: "$@"
}
# Execute a positive test and exit $STF_FAIL is test fails
#
# $@ - command to execute
function log_must
{
log_pos "$@"
(( $? != 0 )) && log_fail
}
# Execute a command that must exit $1
#
# $@ - command to execute
function log_mustbe
{
typeset exitcode_wanted=$1
shift
log_cmd "$@"
(( $? != $exitcode_wanted )) && log_fail
}
# Execute a negative test and exit $STF_FAIL if test passes
#
# $@ - command to execute
function log_mustnot
{
log_neg "$@"
(( $? != 0 )) && log_fail
}
# Execute a command that should only be logged if it fails.
#
# $@ - command to execute
function log_onfail
{
eval $@
typeset status=$?
[ $status -eq 0 ] && return
_printerror "$@" "unexpectedly exited $status"
}
# Execute and print command with status where success equals non-zero result
# or output includes expected keyword
#
# $2-$@ - command to execute
#
# Summary: execute $@. Return 1 if any of the following hold:
# 1) The command exited 0, 127, 138, or 139
# 2) The command's stderr included "internal error" or
# "assertion failed"
#
# return 0 if command fails, or the output contains the keyword expected,
# return 1 otherwise
function log_neg
{
typeset out=""
typeset logfile="$TMPDIR/log.$$"
typeset ret=1
while [[ -e $logfile ]]; do
logfile="$logfile.$$"
done
"$@" 2>$logfile
typeset status=$?
out="/bin/cat $logfile"
# unexpected status
if (( $status == 0 )); then
print -u2 $($out)
_printerror "$@" "unexpectedly exited $status"
# missing binary
elif (( $status == 127 )); then
print -u2 $($out)
_printerror "$@" "unexpectedly exited $status (File not found)"
# bus error - core dump
elif (( $status == 138 )); then
print -u2 $($out)
_printerror "$@" "unexpectedly exited $status (Bus Error)"
# segmentation violation - core dump
elif (( $status == 139 )); then
print -u2 $($out)
_printerror "$@" "unexpectedly exited $status (SEGV)"
else
$out | /usr/bin/egrep -i "internal error|assertion failed" \
> /dev/null 2>&1
# internal error or assertion failed
if (( $? == 0 )); then
print -u2 $($out)
_printerror "$@" "internal error or assertion failure" \
" exited $status"
else
ret=0
fi
if (( $ret == 0 )); then
[[ -n $LOGAPI_DEBUG ]] && print $($out)
_printsuccess "$@" "exited $status"
fi
fi
_recursive_output $logfile "false"
return $ret
}
# Execute and print command; unconditionally return its exit code.
# Useful for code that needs to do more specialized exit status filtering.
function log_cmd
{
typeset logfile="$TMPDIR/log.$$"
while [[ -e $logfile ]]; do
logfile="$logfile.$$"
done
"$@" 2>$logfile
typeset status=$?
_printline "EXECUTED (exited $status): $@"
_recursive_output $logfile "false"
return $status
}
# Execute and print command with status where success equals zero result
#
# $@ command to execute
#
# Summary: run $@. return 1 if its exit status was nonzero or if it printed
# "internal error" or "assertion failed" to stderr.
# print stderr on failure or if LOGAPI_DEBUG is set.
#
# return command exit status
function log_pos
{
typeset out=""
typeset logfile="$TMPDIR/log.$$"
while [[ -e $logfile ]]; do
logfile="$logfile.$$"
done
"$@" 2>$logfile
typeset status=$?
out="/bin/cat $logfile"
if (( $status != 0 )) ; then
print -u2 $($out)
_printerror "$@" "exited $status"
else
$out | /usr/bin/egrep -i "internal error|assertion failed" \
> /dev/null 2>&1
# internal error or assertion failed
if [[ $? -eq 0 ]]; then
print -u2 $($out)
_printerror "$@" "internal error or assertion failure" \
" exited $status"
status=1
else
[[ -n $LOGAPI_DEBUG ]] && print $($out)
_printsuccess "$@"
fi
fi
_recursive_output $logfile "false"
return $status
}
# Set an exit handler
#
# $@ - function(s) to perform on exit
function log_onexit
{
_CLEANUP="$@"
}
#
# Exit functions
#
# Perform cleanup and exit $STF_PASS
#
# $@ - message text
function log_pass
{
_endlog $STF_PASS "$@"
}
# Perform cleanup and exit $STF_FAIL
#
# $@ - message text
function log_fail
{
_endlog $STF_FAIL "$@"
}
# Perform cleanup and exit $STF_UNRESOLVED
#
# $@ - message text
function log_unresolved
{
_endlog $STF_UNRESOLVED "$@"
}
# Perform cleanup and exit $STF_NOTINUSE
#
# $@ - message text
function log_notinuse
{
_endlog $STF_NOTINUSE "$@"
}
# Perform cleanup and exit $STF_UNSUPPORTED
#
# $@ - message text
function log_unsupported
{
_endlog $STF_UNSUPPORTED "$@"
}
# Perform cleanup and exit $STF_UNTESTED
#
# $@ - message text
function log_untested
{
_endlog $STF_UNTESTED "$@"
}
# Perform cleanup and exit $STF_UNINITIATED
#
# $@ - message text
function log_uninitiated
{
_endlog $STF_UNINITIATED "$@"
}
# Perform cleanup and exit $STF_NORESULT
#
# $@ - message text
function log_noresult
{
_endlog $STF_NORESULT "$@"
}
# Perform cleanup and exit $STF_WARNING
#
# $@ - message text
function log_warning
{
_endlog $STF_WARNING "$@"
}
# Perform cleanup and exit $STF_TIMED_OUT
#
# $@ - message text
function log_timed_out
{
_endlog $STF_TIMED_OUT "$@"
}
# Perform cleanup and exit $STF_OTHER
#
# $@ - message text
function log_other
{
_endlog $STF_OTHER "$@"
}
#
# Internal functions
#
# Perform cleanup and exit
#
# Summary: Runs any cleanup routine registered with log_onexit. Prints a
# message and exits $1. Note: the _recursive_output does
# nothing, because the rest of this api guarantees that the
# logfile will not exist.
# $1 - stf exit code
# $2-$n - message text
function _endlog
{
typeset logfile="$TMPDIR/log.$$"
_recursive_output $logfile
export STF_EXITCODE=$1
shift
(( ${#@} > 0 )) && _printline "$@"
if [[ -n $_CLEANUP ]] ; then
typeset cleanup=$_CLEANUP
log_onexit ""
log_note "Performing local cleanup via log_onexit ($cleanup)"
$cleanup
fi
exit $STF_EXITCODE
}
# Output a formatted line
#
# $@ - message text
function _printline
{
print `/bin/date +%H:%M:%S` "$@"
}
# Output an error message
#
# $@ - message text
function _printerror
{
_printline ERROR: "$@"
}
# Output a success message
#
# $@ - message text
function _printsuccess
{
_printline SUCCESS: "$@"
}
# Output logfiles recursively
#
# $1 - start file
# $2 - indicate whether output the start file itself, default as yes.
function _recursive_output #logfile
{
typeset logfile=$1
while [[ -e $logfile ]]; do
if [[ -z $2 || $logfile != $1 ]]; then
/bin/cat $logfile
fi
/bin/rm -f $logfile
logfile="$logfile.$$"
done
}

View File

@ -0,0 +1,55 @@
# vim: filetype=sh
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# $FreeBSD$
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "@(#)stf.shlib 1.2 07/04/12 SMI"
#
STF_PASS=0
STF_FAIL=1
STF_UNRESOLVED=2
STF_NOTINUSE=3
STF_UNSUPPORTED=4
STF_UNTESTED=5
STF_UNINITIATED=6
STF_NORESULT=7
STF_WARNING=8
STF_TIMED_OUT=9
STF_OTHER=10
# do this to use the names: eval echo \$STF_RESULT_NAME_${result}
STF_RESULT_NAME_0="PASS"
STF_RESULT_NAME_1="FAIL"
STF_RESULT_NAME_2="UNRESOLVED"
STF_RESULT_NAME_3="NOTINUSE"
STF_RESULT_NAME_4="UNSUPPORTED"
STF_RESULT_NAME_5="UNTESTED"
STF_RESULT_NAME_6="UNINITIATED"
STF_RESULT_NAME_7="NORESULT"
STF_RESULT_NAME_8="WARNING"
STF_RESULT_NAME_9="TIMED_OUT"
STF_RESULT_NAME_10="OTHER"

View File

@ -0,0 +1,21 @@
. ${STF_SUITE}/include/libtest.kshlib
. ${STF_SUITE}/include/commands.cfg
# $FreeBSD$
# Environment-dependent constants.
for d in `geom disk list | awk '/Name:/ {print $3}'`; do
# Clear the GPT label first to avoid spurious create failures.
gpart destroy -F $d >/dev/null 2>&1
if gpart create -s gpt $d >/dev/null 2>&1 ; then
gpart destroy $d >/dev/null 2>&1 || continue
DISKS=("${DISKS[@]}" "/dev/$d") #"$DISKS $d"
fi
# Don't bother testing any more if we have enough already.
# Currently we use at most 5 disks plus 1 for temporary disks.
[ ${#DISKS[@]} -eq 6 ] && break
done
export KEEP="$(zpool list -H -o name)"
# Pull in constants.
. ${STF_SUITE}/include/constants.cfg

View File

@ -0,0 +1,22 @@
# vim: filetype=sh
# $FreeBSD$
. ${STF_SUITE}/include/libtest.kshlib
. ${STF_SUITE}/include/commands.cfg
# Environment-dependent constants.
for d in `geom disk list | awk '/Name:/ {print $3}'`; do
# Clear the GPT label first to avoid spurious create failures.
gpart destroy -F $d >/dev/null 2>&1
if gpart create -s gpt $d >/dev/null 2>&1 ; then
gpart destroy $d >/dev/null 2>&1 || continue
DISKS=("${DISKS[@]}" "/dev/$d") #"$DISKS $d"
fi
# Don't bother testing any more if we have enough already.
# Currently we use at most 5 disks plus 1 for temporary disks.
[ ${#DISKS[@]} -eq 6 ] && break
done
export KEEP="$(zpool list -H -o name)"
# Pull in constants.
. ${STF_SUITE}/include/constants.cfg

View File

@ -0,0 +1,40 @@
#! /usr/bin/awk -f
# $FreeBSD$
BEGIN {
print "# This file is autogenerated from commands.txt. Do not edit"
cmdstring = "export CMDS=\""
cmdch = 1
cmd_idx=0
}
# Strip comments
{
gsub(/#.*/, "", $0)
}
# Strip blank lines
/^[ ]*$/ {
next
}
# Process remaining lines
{
gsub(/%%STFSUITEDIR%%/, stfsuitedir, $1)
fullcmd = $1
cmdname = $1
gsub(/.*\//, "", cmdname)
CMDNAME = toupper(cmdname)
allcmds[cmd_idx] = CMDNAME
cmd_idx += 1
printf "export %s=\"%s\"\n", CMDNAME, fullcmd
}
# Print CMDS
END {
print ""
printf "export CMDS=\""
for (idx in allcmds)
printf "$%s ", allcmds[idx]
print "\""
}

View File

@ -0,0 +1,89 @@
# $FreeBSD$
.include <src.opts.mk>
PACKAGE= tests
TESTSDIR= ${TESTSBASE}/sys/cddl/zfs/tests
TESTS_SUBDIRS+= acl
TESTS_SUBDIRS+= atime
TESTS_SUBDIRS+= bootfs
TESTS_SUBDIRS+= cache
TESTS_SUBDIRS+= cachefile
TESTS_SUBDIRS+= clean_mirror
TESTS_SUBDIRS+= cli_root
TESTS_SUBDIRS+= cli_user
TESTS_SUBDIRS+= compression
TESTS_SUBDIRS+= ctime
TESTS_SUBDIRS+= delegate
TESTS_SUBDIRS+= devices
TESTS_SUBDIRS+= exec
TESTS_SUBDIRS+= grow_pool
TESTS_SUBDIRS+= grow_replicas
TESTS_SUBDIRS+= history
TESTS_SUBDIRS+= hotplug
TESTS_SUBDIRS+= hotspare
TESTS_SUBDIRS+= inheritance
# Not yet ported to FreeBSD
# TESTS_SUBDIRS+= interop
TESTS_SUBDIRS+= inuse
# Not yet ported to FreeBSD
# TESTS_SUBDIRS+= iscsi
TESTS_SUBDIRS+= large_files
# Not yet ported to FreeBSD
# TESTS_SUBDIRS+= largest_pool
# link_count is not yet ported to FreeBSD. I'm not sure what its purpose is.
# The assertion message contradicts with the log_fail message.
# TESTS_SUBDIRS+= link_count
TESTS_SUBDIRS+= migration
TESTS_SUBDIRS+= mmap
TESTS_SUBDIRS+= mount
TESTS_SUBDIRS+= mv_files
TESTS_SUBDIRS+= nestedfs
TESTS_SUBDIRS+= no_space
TESTS_SUBDIRS+= online_offline
TESTS_SUBDIRS+= pool_names
TESTS_SUBDIRS+= poolversion
TESTS_SUBDIRS+= quota
TESTS_SUBDIRS+= redundancy
TESTS_SUBDIRS+= refquota
TESTS_SUBDIRS+= refreserv
# Broken on every OS
# TESTS_SUBDIRS+= rename_dirs
TESTS_SUBDIRS+= replacement
TESTS_SUBDIRS+= reservation
TESTS_SUBDIRS+= rootpool
# Not yet ported to FreeBSD
# TESTS_SUBDIRS+= rsend
TESTS_SUBDIRS+= scrub_mirror
TESTS_SUBDIRS+= slog
TESTS_SUBDIRS+= snapshot
TESTS_SUBDIRS+= snapused
TESTS_SUBDIRS+= sparse
TESTS_SUBDIRS+= threadsappend
TESTS_SUBDIRS+= truncate
TESTS_SUBDIRS+= txg_integrity
TESTS_SUBDIRS+= userquota
TESTS_SUBDIRS+= utils_test
TESTS_SUBDIRS+= write_dirs
# Not yet ported to FreeBSD
# TESTS_SUBDIRS+= xattr
TESTS_SUBDIRS+= zfsd
TESTS_SUBDIRS+= zil
# Not yet ported to FreeBSD
# TESTS_SUBDIRS+= zinject
# Not yet ported to FreeBSD
# TESTS_SUBDIRS+= zones
TESTS_SUBDIRS+= zvol
TESTS_SUBDIRS+= zvol_thrash
# This is primarily useful for identifying which test a testid corresponds to.
# Sometimes all you might have is a pool name like 'testpool.1316'.
testids:
for i in `find ${.CURDIR} -name '*.sh' | xargs grep '^atf_test_case '|awk '{print $$2}'`; do \
echo "$${i}: $$(echo $$i | cksum -o 2 | cut -d" " -f1)"; \
done
.PHONY: testids
.include <bsd.test.mk>

View File

@ -0,0 +1,18 @@
# $FreeBSD$
.include <src.opts.mk>
PACKAGE=tests
TESTSDIR=${TESTSBASE}/sys/cddl/zfs/tests/acl
FILESDIR=${TESTSDIR}
${PACKAGE}FILES+= acl.cfg
${PACKAGE}FILES+= acl_common.kshlib
${PACKAGE}FILES+= cleanup.ksh
${PACKAGE}FILES+= setup.ksh
TESTS_SUBDIRS+= cifs
TESTS_SUBDIRS+= trivial
TESTS_SUBDIRS+= nontrivial
.include <bsd.test.mk>

View File

@ -0,0 +1,72 @@
# vim: filetype=sh
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# $FreeBSD$
#
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "@(#)acl.cfg 1.3 08/08/15 SMI"
#
. $STF_SUITE/include/libtest.kshlib
export NISSTAFILE=$TMPDIR/nis_state
export TESTFILE=testfile${TESTCASE_ID}
export TESTFILE0=testfile0.${TESTCASE_ID}
export TESTFILE2=testfile2.${TESTCASE_ID}
# Define super user 'admin'
export ZFS_ACL_ADMIN=admin
export ZFS_ACL_STAFF_GROUP=zfsgrp
export ZFS_ACL_STAFF1=staff1
export ZFS_ACL_STAFF2=staff2
export ZFS_ACL_OTHER_GROUP=othergrp
export ZFS_ACL_OTHER1=other1
export ZFS_ACL_OTHER2=other2
# Define the current user who run 'usr_exec'
export ZFS_ACL_CUR_USER=""
# Define global error string
export ZFS_ACL_ERR_STR=""
# Define test file and test directory which will be operated by chmod
export testfile=$TESTDIR/testfile
export testdir=$TESTDIR/testdir
# Define several directories for trivial ACLs function test.
export RES_DIR=$TESTDIR/RES
export INI_DIR=$TESTDIR/INIT
export TST_DIR=$TESTDIR/TEST
export TMP_DIR=$TESTDIR/TMP
# Define test files and their attributes files number for trivial
# ACLs function test
export NUM_FILE=5
export NUM_ATTR=10
# Enlarge STF_TIMEOUT
export STF_TIMEOUT=1800

View File

@ -0,0 +1,638 @@
# vim: filetype=sh
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# $FreeBSD$
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "@(#)acl_common.kshlib 1.4 09/05/19 SMI"
#
. $STF_SUITE/include/libtest.kshlib
# FreeBSD doesn't support ZFS extended attributes. It also doesn't support the
# same ACL mechanisms Solaris does for testing.
if [[ $os_name != "FreeBSD" ]]; then
export ZFS_XATTR="true"
export ZFS_ACL="true"
else
log_note "On FreeBSD most xattr and ACL tests are disabled"
fi
#
# Get the given file/directory access mode
#
# $1 object -- file or directroy
#
function get_mode #<obj>
{
typeset obj=$1
if (( ${#obj} == 0 )); then
return 1
fi
$LS -ld $obj | $AWK '{print $1}'
}
#
# Get the given file/directory ACL
#
# $1 object -- file or directroy
#
function get_acl #<obj>
{
typeset obj=$1
if (( ${#obj} == 0 )); then
return 1
fi
$LS -vd $obj | $NAWK '(NR != 1) {print $0}'
}
#
# Get the given file/directory ACL
#
# $1 object -- file or directroy
#
function get_compact_acl #<obj>
{
typeset obj=$1
if (( ${#obj} == 0 )); then
return 1
fi
$LS -Vd $obj | $NAWK '(NR != 1) {print $0}'
}
#
# Check the given two files/directories have the same ACLs
#
# Return 0, if source object acl is equal to target object acl.
#
# $1 source object
# $2 target object
#
function compare_acls #<src> <tgt>
{
typeset src=$1
typeset tgt=$2
(( ${#src} == 0 || ${#tgt} == 0 )) && return 1
[[ $src == $tgt ]] && return 0
typeset tmpsrc=$TMPDIR/compare_acls.src.${TESTCASE_ID}
typeset tmptgt=$TMPDIR/compare_acls.tgt.${TESTCASE_ID}
get_acl $src > $tmpsrc
get_acl $tgt > $tmptgt
typeset -i ret=0
$DIFF $tmpsrc $tmptgt > /dev/null 2>&1
ret=$?
$RM -f $tmpsrc $tmptgt
if (( ret != 0 )); then
return $ret
fi
get_compact_acl $src > $tmpsrc
get_compact_acl $tgt > $tmptgt
$DIFF $tmpsrc $tmptgt > /dev/null 2>&1
ret=$?
$RM -f $tmpsrc $tmptgt
return $ret
}
#
# Check that the given two objects have the same modes.
# Return 0, if their modes are equal with each other. Otherwise, return 1.
#
# $1 source object
# $2 target object
#
function compare_modes #<src> <tgt>
{
typeset src=$1
typeset tgt=$2
typeset -i i=0
set -A mode
(( ${#src} == 0 || ${#tgt} == 0 )) && return 1
[[ $src == $tgt ]] && return 0
typeset obj
for obj in $src $tgt
do
mode[i]=$(get_mode $obj)
(( i = i + 1 ))
done
[[ ${mode[0]} != ${mode[1]} ]] && return 1
return 0
}
#
# Check that the given two objects have the same xattrs.
# Return 0, if their xattrs are equal with each other. Otherwise, return 1.
#
# $1 source object
# $2 target object
#
function compare_xattrs #<src> <tgt>
{
typeset src=$1
typeset tgt=$2
(( ${#src} == 0 || ${#tgt} == 0 )) && return 1
[[ $src == $tgt ]] && return 0
typeset tmpsrc=$TMPDIR/compare_xattrs.src.${TESTCASE_ID}
typeset tmptgt=$TMPDIR/compare_xattrs.tgt.${TESTCASE_ID}
get_xattr $src > $tmpsrc
get_xattr $tgt > $tmptgt
typeset -i ret=0
$DIFF $tmpsrc $tmptgt > /dev/null 2>&1
ret=$?
$RM -f $tmpsrc $tmptgt
return $ret
}
#
# Check '+' is set for a given file/directory with 'ls [-l]' command
#
# $1 object -- file or directory.
#
function plus_sign_check_l #<obj>
{
typeset obj=$1
if (( ${#obj} == 0 )); then
return 1
fi
$LS -ld $obj | $AWK '{print $1}' | $GREP "+\>" > /dev/null
return $?
}
#
# Check '+' is set for a given file/directory with 'ls [-v]' command
#
# $1 object -- file or directory.
#
function plus_sign_check_v #<obj>
{
typeset obj=$1
if (( ${#obj} == 0 )); then
return 1
fi
$LS -vd $obj | $NAWK '(NR == 1) {print $1}' | $GREP "+\>" > /dev/null
return $?
}
#
# A wrapper function of c program
#
# $1 legal login name
# $2-n commands and options
#
function chgusr_exec #<login_name> <commands> [...]
{
$CHG_USR_EXEC $@
return $?
}
#
# Export the current user for the following usr_exec operating.
#
# $1 legal login name
#
function set_cur_usr #<login_name>
{
export ZFS_ACL_CUR_USER=$1
}
#
# Run commands by $ZFS_ACL_CUR_USER
#
# $1-n commands and options
#
function usr_exec #<commands> [...]
{
$CHG_USR_EXEC "$ZFS_ACL_CUR_USER" $@
return $?
}
#
# Count how many ACEs for the specified file or directory.
#
# $1 file or directroy name
#
function count_ACE #<file or dir name>
{
if [[ ! -e $1 ]]; then
log_note "Need input file or directroy name."
return 1
fi
$LS -vd $1 | $NAWK 'BEGIN {count=0}
(NR != 1)&&(/[0-9]:/) {count++}
END {print count}'
return 0
}
#
# Get specified number ACE content of specified file or directory.
#
# $1 file or directory name
# $2 specified number
#
function get_ACE #<file or dir name> <specified number> <verbose|compact>
{
if [[ ! -e $1 || $2 -ge $(count_ACE $1) ]]; then
return 1
fi
typeset file=$1
typeset -i num=$2
typeset format=${3:-verbose}
typeset -i next_num=-1
typeset tmpfile=$TMPDIR/tmp_get_ACE.${TESTCASE_ID}
typeset line=""
typeset args
case $format in
verbose) args="-vd"
;;
compact) args="-Vd"
;;
*) log_fail "Invalid parameter as ($format), " \
"only verbose|compact is supported."
;;
esac
$LS $args $file > $tmpfile
(( $? != 0 )) && log_fail "FAIL: $LS $args $file > $tmpfile"
while read line; do
[[ -z $line ]] && continue
if [[ $args == -vd ]]; then
if [[ $line == "$num":* ]]; then
(( next_num = num + 1 ))
fi
if [[ $line == "$next_num":* ]]; then
break
fi
if (( next_num != -1 )); then
print -n $line
fi
else
if (( next_num == num )); then
print -n $line
fi
(( next_num += 1 ))
fi
done < $tmpfile
$RM -f $tmpfile
(( $? != 0 )) && log_fail "FAIL: $RM -f $tmpfile"
}
#
# Cleanup exist user/group.
#
function cleanup_user_group
{
del_user $ZFS_ACL_ADMIN
del_user $ZFS_ACL_STAFF1
del_user $ZFS_ACL_STAFF2
del_group $ZFS_ACL_STAFF_GROUP
del_user $ZFS_ACL_OTHER1
del_user $ZFS_ACL_OTHER2
del_group $ZFS_ACL_OTHER_GROUP
return 0
}
#
# Clean up testfile and test directory
#
function cleanup
{
if [[ -d $TESTDIR ]]; then
cd $TESTDIR
$RM -rf $TESTDIR/*
fi
}
#
# According to specified access or acl_spec, do relevant operating by using the
# specified user.
#
# $1 specified user
# $2 node
# $3 acl_spec or access
#
function rwx_node #user node acl_spec|access
{
typeset user=$1
typeset node=$2
typeset acl_spec=$3
if [[ $user == "" || $node == "" || $acl_spec == "" ]]; then
log_note "node or acl_spec are not defined."
return 1
fi
if [[ -d $node ]]; then
case $acl_spec in
*:read_data:*|read_data)
chgusr_exec $user $LS -l $node > /dev/null 2>&1
return $? ;;
*:write_data:*|write_data)
if [[ -f ${node}/tmpfile ]]; then
log_must $RM -f ${node}/tmpfile
fi
chgusr_exec $user $TOUCH ${node}/tmpfile > \
/dev/null 2>&1
return $? ;;
*"execute:"*|execute)
chgusr_exec $user $FIND $node > /dev/null 2>&1
return $? ;;
esac
else
case $acl_spec in
*:read_data:*|read_data)
chgusr_exec $user $CAT $node > /dev/null 2>&1
return $? ;;
*:write_data:*|write_data)
chgusr_exec $user $DD if=/bin/ls of=$node > \
/dev/null 2>&1
return $? ;;
*"execute:"*|execute)
ZFS_ACL_ERR_STR=$(chgusr_exec $user $node 2>&1)
return $? ;;
esac
fi
}
#
# Get the given file/directory xattr
#
# $1 object -- file or directroy
#
function get_xattr #<obj>
{
typeset obj=$1
typeset xattr
if (( ${#obj} == 0 )); then
return 1
fi
for xattr in `$RUNAT $obj $LS | \
/usr/bin/egrep -v -e SUNWattr_ro -e SUNWattr_rw` ; do
$RUNAT $obj $SUM $xattr
done
}
#
# Get the owner of a file/directory
#
function get_owner #node
{
typeset node=$1
typeset value
if [[ -z $node ]]; then
log_fail "node are not defined."
fi
if [[ -d $node ]]; then
value=$($LS -dl $node | $AWK '{print $3}')
elif [[ -e $node ]]; then
value=$($LS -l $node | $AWK '{print $3}')
fi
$ECHO $value
}
#
# Get the group of a file/directory
#
function get_group #node
{
typeset node=$1
typeset value
if [[ -z $node ]]; then
log_fail "node are not defined."
fi
if [[ -d $node ]]; then
value=$($LS -dl $node | $AWK '{print $4}')
elif [[ -e $node ]]; then
value=$($LS -l $node | $AWK '{print $4}')
fi
$ECHO $value
}
#
# Get the group name that a UID belongs to
#
function get_user_group #uid
{
typeset uid=$1
typeset value
if [[ -z $uid ]]; then
log_fail "UID not defined."
fi
value=$(id $uid)
if [[ $? -eq 0 ]]; then
value=${value##*\(}
value=${value%%\)*}
$ECHO $value
else
log_fail "Invalid UID (uid)."
fi
}
#
# Get the specified item of the specified string
#
# $1: Item number, count from 0.
# $2-n: strings
#
function getitem
{
typeset -i n=$1
shift
(( n += 1 ))
eval print \${$n}
}
#
# This function calculate the specified directory files checksum and write
# to the specified array.
#
# $1 directory in which the files will be cksum.
# $2 file array name which was used to store file cksum information.
# $3 attribute array name which was used to store attribute information.
#
function cksum_files #<dir> <file_array_name> <attribute_array_name>
{
typeset dir=$1
typeset farr_name=$2
typeset aarr_name=$3
[[ ! -d $dir ]] && return
typeset oldpwd=$PWD
cd $dir
typeset files=$($LS file*)
typeset -i i=0
typeset -i n=0
while (( i < NUM_FILE )); do
typeset f=$(getitem $i $files)
eval $farr_name[$i]=\$\(\$CKSUM $f\)
typeset -i j=0
while (( j < NUM_ATTR )); do
eval $aarr_name[$n]=\$\(\$RUNAT \$f \$CKSUM \
attribute.$j\)
(( j += 1 ))
(( n += 1 ))
done
(( i += 1 ))
done
cd $oldpwd
}
#
# This function compare two cksum results array.
#
# $1 The array name which stored the cksum before operation.
# $2 The array name which stored the cksum after operation.
#
function compare_cksum #<array1> <array2>
{
typeset before=$1
typeset after=$2
eval typeset -i count=\${#$before[@]}
typeset -i i=0
while (( i < count )); do
eval typeset var1=\${$before[$i]}
eval typeset var2=\${$after[$i]}
if [[ $var1 != $var2 ]]; then
return 1
fi
(( i += 1 ))
done
return 0
}
#
# This function calculate all the files cksum information in current directory
# and output them to the specified file.
#
# $1 directory from which the files will be cksum.
# $2 cksum output file
#
function record_cksum #<outfile>
{
typeset dir=$1
typeset outfile=$2
[[ ! -d ${outfile%/*} ]] && usr_exec $MKDIR -p ${outfile%/*}
usr_exec cd $dir ; $FIND . -depth -type f -exec cksum {} \\\; | $SORT > $outfile
usr_exec cd $dir ; $FIND . -depth -type f -xattr -exec runat {} \
cksum attribute* \\\; | $SORT >> $outfile
}
#
# The function create_files creates the directories and files that the script
# will operate on to test extended attribute functionality.
#
# $1 The base directory in which to create directories and files.
#
function create_files #<directory>
{
typeset basedir=$1
[[ ! -d $basedir ]] && usr_exec $MKDIR -m 777 $basedir
[[ ! -d $RES_DIR ]] && usr_exec $MKDIR -m 777 $RES_DIR
[[ ! -d $INI_DIR ]] && usr_exec $MKDIR -m 777 $INI_DIR
[[ ! -d $TST_DIR ]] && usr_exec $MKDIR -m 777 $TST_DIR
[[ ! -d $TMP_DIR ]] && usr_exec $MKDIR -m 777 $TMP_DIR
#
# Create the original file and its attribute files.
#
[[ ! -a $RES_DIR/file ]] && \
usr_exec $FILE_WRITE -o create -f $RES_DIR/file \
-b 1024 -d 0 -c 1
[[ ! -a $RES_DIR/attribute ]] && \
usr_exec $CP $RES_DIR/file $RES_DIR/attribute
typeset oldpwd=$PWD
cd $INI_DIR
typeset -i i=0
while (( i < NUM_FILE )); do
typeset dstfile=$INI_DIR/file.${TESTCASE_ID}.$i
usr_exec $CP $RES_DIR/file $dstfile
typeset -i j=0
while (( j < NUM_ATTR )); do
usr_exec $RUNAT $dstfile \
$CP $RES_DIR/attribute ./attribute.$j
(( j += 1 ))
done
(( i += 1 ))
done
cd $oldpwd
}

View File

@ -0,0 +1,18 @@
# $FreeBSD$
.include <src.opts.mk>
PACKAGE=tests
TESTSDIR=${TESTSBASE}/sys/cddl/zfs/tests/acl/cifs
FILESDIR=${TESTSDIR}
${PACKAGE}FILES+= cifs.kshlib
${PACKAGE}FILES+= cifs_attr_001_pos.ksh
${PACKAGE}FILES+= cifs_attr_002_pos.ksh
${PACKAGE}FILES+= cifs_attr_003_pos.ksh
ATF_TESTS_KSH93+= cifs_test
TEST_METADATA+= required_user="root"
TEST_METADATA+= is_exclusive=true
.include <bsd.test.mk>

View File

@ -0,0 +1,91 @@
# vim: filetype=sh
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# $FreeBSD$
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "@(#)cifs.kshlib 1.4 09/05/19 SMI"
#
. $STF_SUITE/include/libtest.kshlib
function cifs_supported
{
if check_version "5.11" ; then
fs_prop_exist "sharesmb"
return $?
fi
return 1
}
#
# Create a file or direcotry
#
# $1: The type specified, "file" or "dir"
# $2: The given node name
# $3: Owner of the node
#
function create_object
{
typeset type=$1
typeset object=$2
typeset owner=$3
destroy_object $object
case $type in
dir)
$MKDIR -p $object
;;
file)
$ECHO "ZFS test suites" > $object
;;
esac
if [[ -n $owner ]]; then
$CHOWN $owner $object
fi
return 0
}
#
# Destroy the given node(s)
#
# $@: The node(s) need to be destroyed
#
function destroy_object
{
for object in $@ ; do
if [[ -e $object ]]; then
# clear_attribute is a common function name,
# but each case should have their own implement.
log_must clear_attribute $object
log_must $RM -rf $object
fi
done
return 0
}

View File

@ -0,0 +1,262 @@
#!/usr/local/bin/ksh93 -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# $FreeBSD$
#
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "@(#)cifs_attr_001_pos.ksh 1.1 08/02/27 SMI"
#
. $STF_SUITE/tests/acl/acl_common.kshlib
. $STF_SUITE/tests/acl/cifs/cifs.kshlib
#################################################################################
#
# __stc_assertion_start
#
# ID: cifs_attr_001_pos
#
# DESCRIPTION:
# Verify the user with write_attributes permission or
# PRIV_FILE_OWNER privilege could set/clear DOS attributes.
# (Readonly, Hidden, Archive, System)
#
# STRATEGY:
# 1. Loop super user and non-super user to run the test case.
# 2. Create basedir and a set of subdirectores and files within it.
# 3. Grant user has write_attributes permission or
# PRIV_FILE_OWNER privilege
# 4. Verify set/clear DOS attributes should succeed.
#
# TESTABILITY: explicit
#
# TEST_AUTOMATION_LEVEL: automated
#
# CODING_STATUS: COMPLETED (2007-11-05)
#
# __stc_assertion_end
#
################################################################################
verify_runnable "both"
if ! cifs_supported ; then
log_unsupported "CIFS not supported on current system."
fi
test_requires ZFS_ACL ZFS_XATTR
function cleanup
{
for fs in $TESTPOOL/$TESTFS $TESTPOOL ; do
mtpt=$(get_prop mountpoint $fs)
log_must $RM -rf $mtpt/file.* $mtpt/dir.*
done
}
#
# Set the special attribute to the given node
#
# $1: The given node (file/dir)
# $2: The special attribute to be set
# $3: Execute username
#
function set_attribute
{
typeset object=$1
typeset attr=${2:-AHRS}
typeset user=$3
typeset ret=0
if [[ -z $object ]]; then
log_fail "Object not defined."
fi
if [[ -n $user ]]; then
$RUNWATTR -u $user "$CHMOD S+c${attr} $object"
ret=$?
else
$CHMOD S+c${attr} $object
ret=$?
fi
return $ret
}
#
# Clear the special attribute to the given node
#
# $1: The given node (file/dir)
# $2: The special attribute to be cleared
# $3: Execute username
#
function clear_attribute
{
typeset object=$1
typeset attr=${2:-AHRS}
typeset user=$3
typeset ret=0
if [[ -z $object ]]; then
log_fail "Object not defined."
fi
if [[ -n $user ]]; then
$RUNWATTR -u $user "$CHMOD S-c${attr} $object"
ret=$?
else
$CHMOD S-c${attr} $object
ret=$?
fi
return $ret
}
#
# Grant the ace of write_attributes to the given user
#
# $1: The given user
# $2: The given node (file/dir)
#
function grant_attr
{
typeset user=$1
typeset object=$2
if [[ -z $user || -z $object ]]; then
log_fail "User($user), Object($object) not defined."
fi
# To increase the coverage, here we set 'deny' against
# superuser and owner.
# Only grant the user explicitly while it's not root neither owner.
if [[ $user == "root" ]]; then
log_must chmod A+user:root:write_attributes:deny $object
elif [[ $user == $(get_owner $object) ]]; then
if (( ( RANDOM % 2 ) == 0 )); then
log_must chmod A+owner@:write_attributes:deny $object
else
log_must chmod A+user:$user:write_attributes:deny \
$object
fi
else
log_must chmod A+user:$user:write_attributes:allow $object
fi
attr_mod="write_attributes"
}
#
# Revoke the ace of write_attributes from the given user
#
# $1: The given user
# $2: The given node (file/dir)
#
function revoke_attr
{
typeset user=$1
typeset object=$2
if [[ -z $user || -z $object ]]; then
log_fail "User($user), Object($object) not defined."
fi
log_must chmod A0- $object
attr_mod=
}
#
# Invoke the function and verify whether its return code as expected
#
# $1: Function be invoked
# $2: The given node (file/dir)
# $3: Execute user
# $4: Option
#
function verify_attr
{
typeset func=$1
typeset object=$2
typeset opt=$3
typeset user=$4
typeset expect="log_mustnot"
if [[ -z $func || -z $object ]]; then
log_fail "Func($func), Object($object), User($user), \
Opt($opt) not defined."
fi
# If user is superuser or has write_attributes permission or
# PRIV_FILE_OWNER privilege, it should log_must,
# otherwise log_mustnot.
if [[ -z $user || $user == "root" || \
$user == $(get_owner $object) || \
$attr_mod == *"write_attributes"* ]] ; then
expect="log_must"
fi
$expect $func $object $opt $user
}
log_assert "Verify set/clear DOS attributes will succeed while user has " \
"write_attributes permission or PRIV_FILE_OWNER privilege"
log_onexit cleanup
file="file.0"
dir="dir.0"
XATTROPTIONS="H S R A"
for fs in $TESTPOOL $TESTPOOL/$TESTFS ; do
mtpt=$(get_prop mountpoint $fs)
for owner in root $ZFS_ACL_STAFF1 ; do
create_object "file" $mtpt/$file $owner
create_object "dir" $mtpt/$dir $owner
for object in $mtpt/$file $mtpt/$dir ; do
for user in root $ZFS_ACL_STAFF2 ; do
for opt in $XATTROPTIONS ; do
verify_attr set_attribute \
$object $opt $user
verify_attr clear_attribute \
$object $opt $user
done
log_must grant_attr $user $object
for opt in $XATTROPTIONS ; do
verify_attr set_attribute \
$object $opt $user
verify_attr clear_attribute \
$object $opt $user
done
log_must revoke_attr $user $object
done
done
destroy_object $mtpt/$file $mtpt/$dir
done
done
log_pass "Set/Clear DOS attributes succeed while user has " \
"write_attributes permission or PRIV_FILE_OWNER privilege"

View File

@ -0,0 +1,280 @@
#!/usr/local/bin/ksh93 -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# $FreeBSD$
#
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "@(#)cifs_attr_002_pos.ksh 1.1 08/02/27 SMI"
#
. $STF_SUITE/tests/acl/acl_common.kshlib
. $STF_SUITE/tests/acl/cifs/cifs.kshlib
#################################################################################
#
# __stc_assertion_start
#
# ID: cifs_attr_002_pos
#
# DESCRIPTION:
# Verify the user with PRIV_FILE_FLAG_SET/PRIV_FILE_FLAG_CLEAR
# could set/clear BSD'ish attributes.
# (Immutable, nounlink, and appendonly)
#
# STRATEGY:
# 1. Loop super user and non-super user to run the test case.
# 2. Create basedir and a set of subdirectores and files within it.
# 3. Grant user has PRIV_FILE_FLAG_SET/PRIV_FILE_FLAG_CLEAR separately.
# 4. Verify set/clear BSD'ish attributes should succeed.
#
# TESTABILITY: explicit
#
# TEST_AUTOMATION_LEVEL: automated
#
# CODING_STATUS: COMPLETED (2007-11-05)
#
# __stc_assertion_end
#
################################################################################
verify_runnable "global"
if ! cifs_supported ; then
log_unsupported "CIFS not supported on current system."
fi
test_requires ZFS_ACL ZFS_XATTR
function cleanup
{
if [[ -n $gobject ]]; then
destroy_object $gobject
fi
for fs in $TESTPOOL/$TESTFS $TESTPOOL ; do
mtpt=$(get_prop mountpoint $fs)
log_must $RM -rf $mtpt/file.* $mtpt/dir.*
done
}
#
# Set the special attribute to the given node
#
# $1: The given node (file/dir)
# $2: The special attribute to be set
# $3: Execute username
#
function set_attribute
{
typeset object=$1
typeset attr=$2
typeset user=$3
typeset ret=0
if [[ -z $object ]]; then
log_fail "Object not defined."
fi
if [[ -z $attr ]]; then
attr="uiadm"
if [[ -f $object ]]; then
attr="${attr}q"
fi
fi
if [[ -n $user ]]; then
$RUNWATTR -u $user -p =basic${priv_mod} \
"$CHMOD S+c${attr} $object"
ret=$?
else
$CHMOD S+c${attr} $object
ret=$?
fi
return $ret
}
#
# Clear the special attribute to the given node
#
# $1: The given node (file/dir)
# $2: The special attribute to be cleared
# $3: Execute username
#
function clear_attribute
{
typeset object=$1
typeset attr=$2
typeset user=$3
typeset ret=0
if [[ -z $object ]]; then
log_fail "Object($object) not defined."
fi
if [[ -z $attr ]]; then
attr="uiadm"
if [[ -f $object ]]; then
attr="${attr}q"
fi
fi
if [[ -n $user ]]; then
$RUNWATTR -u $user -p =basic${priv_mod} \
"$CHMOD S-c${attr} $object"
ret=$?
else
$CHMOD S-c${attr} $object
ret=$?
fi
return $ret
}
#
# Grant the privset to the given user
#
# $1: The given user
# $2: The given privset
#
function grant_priv
{
typeset user=$1
typeset priv=$2
if [[ -z $user || -z $priv ]]; then
log_fail "User($user), Priv($priv) not defined."
fi
priv_mod=",$priv"
return $?
}
#
# Revoke the all additional privset from the given user
#
# $1: The given user
#
function revoke_priv
{
typeset user=$1
if [[ -z $user ]]; then
log_fail "User not defined."
fi
priv_mod=
return $?
}
#
# Invoke the function and verify whether its return code as expected
#
# $1: Function be invoked
# $2: The given node (file/dir)
# $3: Execute user
# $4: Option
#
function verify_op
{
typeset func=$1
typeset object=$2
typeset opt=$3
typeset user=$4
typeset expect="log_mustnot"
if [[ -z $func || -z $object ]]; then
log_fail "Func($func), Object($object) not defined."
fi
# If user has PRIV_FILE_FLAG_SET, it could permit to set_attribute,
# And If has PRIV_FILE_FLAG_CLEAR, it could permit to clear_attribute,
# otherwise log_mustnot.
if [[ -z $user || $user == "root" ]] || \
[[ $priv_mod == *"file_flag_set"* ]] || \
[[ $priv_mod == *"all"* ]] ; then
expect="log_must"
fi
if [[ -d $object ]] && \
[[ $opt == *"q"* ]] ; then
expect="log_mustnot"
fi
if [[ $func == clear_attribute ]]; then
if [[ $expect == "log_mustnot" ]]; then
expect="log_must"
elif [[ -z $user || $user == "root" ]] || \
[[ $priv_mod == *"all"* ]] ; then
expect="log_must"
else
expect="log_mustnot"
fi
fi
$expect $func $object $opt $user
}
log_assert "Verify set/clear BSD'ish attributes will succeed while user has " \
"PRIV_FILE_FLAG_SET/PRIV_FILE_FLAG_CLEAR privilege"
log_onexit cleanup
file="file.0"
dir="dir.0"
FLAGOPTIONS="u i a d q m"
typeset gobject
for fs in $TESTPOOL $TESTPOOL/$TESTFS ; do
mtpt=$(get_prop mountpoint $fs)
for owner in root $ZFS_ACL_STAFF1 ; do
create_object "file" $mtpt/$file $owner
create_object "dir" $mtpt/$dir $owner
for object in $mtpt/$file $mtpt/$dir ; do
gobject=$object
for user in root $ZFS_ACL_STAFF2 ; do
log_must grant_priv $user file_flag_set
for opt in $FLAGOPTIONS ; do
verify_op set_attribute \
$object $opt $user
verify_op clear_attribute \
$object $opt $user
done
log_must revoke_priv $user
log_must grant_priv $user all
for opt in $FLAGOPTIONS ; do
verify_op set_attribute \
$object $opt $user
verify_op clear_attribute \
$object $opt $user
done
log_must revoke_priv $user
done
done
destroy_object $mtpt/$file $mtpt/$dir
done
done
log_pass "Set/Clear BSD'ish attributes succeed while user has " \
"PRIV_FILE_FLAG_SET/PRIV_FILE_FLAG_CLEAR privilege"

View File

@ -0,0 +1,622 @@
#!/usr/local/bin/ksh93 -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# $FreeBSD$
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "@(#)cifs_attr_003_pos.ksh 1.4 09/05/19 SMI"
#
. $STF_SUITE/tests/acl/acl_common.kshlib
. $STF_SUITE/tests/acl/cifs/cifs.kshlib
#################################################################################
#
# __stc_assertion_start
#
# ID: cifs_attr_003_pos
#
# DESCRIPTION:
# Verify the DOS attributes (Readonly, Hidden, Archive, System)
# and BSD'ish attributes (Immutable, nounlink, and appendonly)
# will provide the proper access limitation as expected.
#
# Readonly means that the content of a file can't be modified, but
# timestamps, mode and so on can.
#
# Archive - Indicates if a file should be included in the next backup
# of the file system. ZFS will set this bit whenever a file is
# modified.
#
# Hidden and System (ZFS does nothing special with these, other than
# letting a user/application set them.
#
# Immutable (The data can't, change nor can mode, ACL, size and so on)
# The only attribute that can be updated is the access time.
#
# Nonunlink - Sort of like immutable except that a file/dir can't be
# removed.
# This will also effect a rename operation, since that involes a
# remove.
#
# Appendonly - File can only be appended to.
#
# nodump, settable, opaque (These are for the MacOS port) we will
# allow them to be set, but have no semantics tied to them.
#
# STRATEGY:
# 1. Loop super user and non-super user to run the test case.
# 2. Create basedir and a set of subdirectores and files within it.
# 3. Set the file/dir with each kind of special attribute.
# 4. Verify the access limitation works as expected.
#
# TESTABILITY: explicit
#
# TEST_AUTOMATION_LEVEL: automated
#
# CODING_STATUS: COMPLETED (2007-11-05)
#
# __stc_assertion_end
#
################################################################################
verify_runnable "both"
if ! cifs_supported ; then
log_unsupported "CIFS not supported on current system."
fi
test_requires ZFS_ACL ZFS_XATTR
function cleanup
{
if [[ -n $gobject ]]; then
destroy_object $gobject
fi
for fs in $TESTPOOL/$TESTFS $TESTPOOL ; do
mtpt=$(get_prop mountpoint $fs)
log_must $RM -rf $mtpt/file.* $mtpt/dir.*
done
}
#
# Set the special attribute to the given node
#
# $1: The given node (file/dir)
# $2: The special attribute to be set
#
function set_attribute
{
typeset object=$1
typeset attr=$2
if [[ -z $attr ]]; then
attr="AHRSadimu"
if [[ -f $object ]]; then
attr="${attr}q"
fi
fi
$CHMOD S+c${attr} $object
return $?
}
#
# Clear the special attribute to the given node
#
# $1: The given node (file/dir)
# $2: The special attribute to be cleared
#
function clear_attribute
{
typeset object=$1
typeset attr=$2
if [[ -z $attr ]]; then
if is_global_zone ; then
attr="AHRSadimu"
if [[ -f $object ]]; then
attr="${attr}q"
fi
else
attr="AHRS"
fi
fi
$CHMOD S-c${attr} $object
return $?
}
#
# A wrapper function to call test function according to the given attr
#
# $1: The given node (file/dir)
# $2: The special attribute to be test
#
function test_wrapper
{
typeset object=$1
typeset attr=$2
if [[ -z $object || -z $attr ]]; then
log_fail "Object($object), Attr($attr) not defined."
fi
case $attr in
R) func=test_readonly
;;
i) func=test_immutable
;;
u) func=test_nounlink
;;
a) func=test_appendonly
;;
esac
if [[ -n $func ]]; then
$func $object
fi
}
#
# Invoke the function and verify whether its return code as expected
#
# $1: Expect value
# $2-$n: Function and args need to be invoked
#
function verify_expect
{
typeset -i expect=$1
typeset status
shift
"$@" > /dev/null 2>&1
status=$?
if [[ $status -eq 0 ]]; then
if (( expect != 0 )); then
log_fail "$@ unexpect return 0"
fi
else
if (( expect == 0 )); then
log_fail "$@ unexpect return $status"
fi
fi
}
#
# Unit testing function against overwrite file
#
# $1: The given file node
# $2: Execute user
# $3: Expect value, default to be zero
#
function unit_writefile
{
typeset object=$1
typeset user=$2
typeset expect=${3:-0}
if [[ -f $object ]]; then
verify_expect $expect $CHG_USR_EXEC $user \
$CP $TESTFILE $object
verify_expect $expect $CHG_USR_EXEC $user \
$EVAL "$ECHO '$TESTSTR' > $object"
fi
}
#
# Unit testing function against write new stuffs into a directory
#
# $1: The given directory node
# $2: Execute user
# $3: Expect value, default to be zero
#
function unit_writedir
{
typeset object=$1
typeset user=$2
typeset expect=${3:-0}
if [[ -d $object ]]; then
verify_expect $expect $CHG_USR_EXEC $user \
$CP $TESTFILE $object
verify_expect $expect $CHG_USR_EXEC $user \
$MKDIR -p $object/$TESTDIR
fi
}
function unit_appenddata
{
typeset object=$1
typeset user=$2
typeset expect=${3:-0}
if [[ ! -d $object ]]; then
verify_expect $expect $CHG_USR_EXEC $user \
$EVAL "$ECHO '$TESTSTR' >> $object"
fi
}
#
# Unit testing function against delete content from a directory
#
# $1: The given node, dir
# $2: Execute user
# $3: Expect value, default to be zero
#
function unit_deletecontent
{
typeset object=$1
typeset user=$2
typeset expect=${3:-0}
if [[ -d $object ]]; then
for target in $object/${TESTFILE##*/} $object/$TESTDIR ; do
if [[ -e $target ]]; then
verify_expect $expect $CHG_USR_EXEC $user \
$EVAL "$MV $target $target.new"
verify_expect $expect $CHG_USR_EXEC $user \
$EVAL "$ECHO y | $RM -r $target.new"
fi
done
fi
}
#
# Unit testing function against delete a node
#
# $1: The given node, file/dir
# $2: Execute user
# $3: Expect value, default to be zero
#
function unit_deletedata
{
typeset object=$1
typeset user=$2
typeset expect=${3:-0}
verify_expect $expect $CHG_USR_EXEC $user \
$EVAL "$ECHO y | $RM -r $object"
}
#
# Unit testing function against write xattr to a node
#
# $1: The given node, file/dir
# $2: Execute user
# $3: Expect value, default to be zero
#
function unit_writexattr
{
typeset object=$1
typeset user=$2
typeset expect=${3:-0}
verify_expect $expect $CHG_USR_EXEC $user \
$RUNAT $object "$CP $TESTFILE $TESTATTR"
verify_expect $expect $CHG_USR_EXEC $user \
$EVAL "$RUNAT $object \"$ECHO '$TESTSTR' > $TESTATTR\""
verify_expect $expect $CHG_USR_EXEC $user \
$EVAL "$RUNAT $object \"$ECHO '$TESTSTR' >> $TESTATTR\""
if [[ $expect -eq 0 ]]; then
verify_expect $expect $CHG_USR_EXEC $user \
$RUNAT $object "$RM -f $TESTATTR"
fi
}
#
# Unit testing function against modify accesstime of a node
#
# $1: The given node, file/dir
# $2: Execute user
# $3: Expect value, default to be zero
#
function unit_accesstime
{
typeset object=$1
typeset user=$2
typeset expect=${3:-0}
if [[ -d $object ]]; then
verify_expect $expect $CHG_USR_EXEC $user $LS $object
else
verify_expect $expect $CHG_USR_EXEC $user $CAT $object
fi
}
#
# Unit testing function against modify updatetime of a node
#
# $1: The given node, file/dir
# $2: Execute user
# $3: Expect value, default to be zero
#
function unit_updatetime
{
typeset object=$1
typeset user=$2
typeset expect=${3:-0}
verify_expect $expect $CHG_USR_EXEC $user $TOUCH $object
verify_expect $expect $CHG_USR_EXEC $user $TOUCH -a $object
verify_expect $expect $CHG_USR_EXEC $user $TOUCH -m $object
}
#
# Unit testing function against write acl of a node
#
# $1: The given node, file/dir
# $2: Execute user
# $3: Expect value, default to be zero
#
function unit_writeacl
{
typeset object=$1
typeset user=$2
typeset expect=${3:-0}
verify_expect $expect $CHG_USR_EXEC $user chmod A+$TESTACL $object
verify_expect $expect $CHG_USR_EXEC $user chmod A+$TESTACL $object
verify_expect $expect $CHG_USR_EXEC $user chmod A0- $object
verify_expect $expect $CHG_USR_EXEC $user chmod A0- $object
oldmode=$(get_mode $object)
verify_expect $expect $CHG_USR_EXEC $user chmod $TESTMODE $object
}
#
# Testing function to verify the given node is readonly
#
# $1: The given node, file/dir
#
function test_readonly
{
typeset object=$1
if [[ -z $object ]]; then
log_fail "Object($object) not defined."
fi
log_note "Testing readonly of $object"
for user in $ZFS_ACL_CUR_USER root $ZFS_ACL_STAFF2; do
if [[ -d $object ]]; then
log_must usr_exec chmod \
A+user:$user:${ace_dir}:allow $object
else
log_must usr_exec chmod \
A+user:$user:${ace_file}:allow $object
fi
log_must set_attribute $object "R"
unit_writefile $object $user 1
unit_writedir $object $user
unit_appenddata $object $user 1
if [[ -d $object ]]; then
unit_writexattr $object $user
else
unit_writexattr $object $user 1
fi
unit_accesstime $object $user
unit_updatetime $object $user
unit_writeacl $object $user
unit_deletecontent $object $user
unit_deletedata $object $user
if [[ -d $object ]] ;then
create_object "dir" $object $ZFS_ACL_CUR_USER
else
create_object "file" $object $ZFS_ACL_CUR_USER
fi
done
}
#
# Testing function to verify the given node is immutable
#
# $1: The given node, file/dir
#
function test_immutable
{
typeset object=$1
if [[ -z $object ]]; then
log_fail "Object($object) not defined."
fi
log_note "Testing immutable of $object"
for user in $ZFS_ACL_CUR_USER root $ZFS_ACL_STAFF2; do
if [[ -d $object ]]; then
log_must usr_exec chmod \
A+user:$user:${ace_dir}:allow $object
else
log_must usr_exec chmod \
A+user:$user:${ace_file}:allow $object
fi
log_must set_attribute $object "i"
unit_writefile $object $user 1
unit_writedir $object $user 1
unit_appenddata $object $user 1
unit_writexattr $object $user 1
unit_accesstime $object $user
unit_updatetime $object $user 1
unit_writeacl $object $user 1
unit_deletecontent $object $user 1
unit_deletedata $object $user 1
if [[ -d $object ]] ;then
create_object "dir" $object $ZFS_ACL_CUR_USER
else
create_object "file" $object $ZFS_ACL_CUR_USER
fi
done
}
#
# Testing function to verify the given node is nounlink
#
# $1: The given node, file/dir
#
function test_nounlink
{
typeset object=$1
if [[ -z $object ]]; then
log_fail "Object($object) not defined."
fi
$ECHO "Testing nounlink of $object"
for user in $ZFS_ACL_CUR_USER root $ZFS_ACL_STAFF2; do
if [[ -d $object ]]; then
log_must usr_exec chmod \
A+user:$user:${ace_dir}:allow $object
else
log_must usr_exec chmod \
A+user:$user:${ace_file}:allow $object
fi
log_must set_attribute $object "u"
unit_writefile $object $user
unit_writedir $object $user
unit_appenddata $object $user
unit_writexattr $object $user
unit_accesstime $object $user
unit_updatetime $object $user
unit_writeacl $object $user
unit_deletecontent $object $user 1
unit_deletedata $object $user 1
if [[ -d $object ]] ;then
create_object "dir" $object $ZFS_ACL_CUR_USER
else
create_object "file" $object $ZFS_ACL_CUR_USER
fi
done
}
#
# Testing function to verify the given node is appendonly
#
# $1: The given node, file/dir
#
function test_appendonly
{
typeset object=$1
if [[ -z $object ]]; then
log_fail "Object($object) not defined."
fi
log_note "Testing appendonly of $object"
for user in $ZFS_ACL_CUR_USER root $ZFS_ACL_STAFF2; do
if [[ -d $object ]]; then
log_must usr_exec chmod \
A+user:$user:${ace_dir}:allow $object
else
log_must usr_exec chmod \
A+user:$user:${ace_file}:allow $object
fi
log_must set_attribute $object "a"
unit_writefile $object $user 1
unit_writedir $object $user
unit_appenddata $object $user
unit_writexattr $object $user
unit_accesstime $object $user
unit_updatetime $object $user
unit_writeacl $object $user
unit_deletecontent $object $user
unit_deletedata $object $user
if [[ -d $object ]] ;then
create_object "dir" $object $ZFS_ACL_CUR_USER
else
create_object "file" $object $ZFS_ACL_CUR_USER
fi
done
}
FILES="file.0 file.1"
DIRS="dir.0 dir.1"
XATTRS="attr.0 attr.1"
FS="$TESTPOOL $TESTPOOL/$TESTFS"
if is_global_zone ; then
ATTRS="R i u a"
else
ATTRS="R"
fi
TESTFILE=$TMPDIR/tfile
TESTDIR=tdir
TESTATTR=tattr
TESTACL=user:$ZFS_ACL_OTHER1:write_data:allow
TESTMODE=777
TESTSTR="ZFS test suites"
ace_file="write_data/append_data/write_xattr/write_acl/write_attributes"
ace_dir="add_file/add_subdirectory/${ace_file}"
log_assert "Verify DOS & BSD'ish attributes will provide the " \
"access limitation as expected."
log_onexit cleanup
$ECHO "$TESTSTR" > $TESTFILE
typeset gobject
typeset gattr
for gattr in $ATTRS ; do
for fs in $FS ; do
mtpt=$(get_prop mountpoint $fs)
$CHMOD 777 $mtpt
for user in root $ZFS_ACL_STAFF1; do
log_must set_cur_usr $user
for file in $FILES ; do
gobject=$mtpt/$file
create_object "file" $gobject $ZFS_ACL_CUR_USER
test_wrapper $gobject $gattr
destroy_object $gobject
done
for dir in $DIRS ; do
gobject=$mtpt/$dir
create_object "dir" $gobject $ZFS_ACL_CUR_USER
test_wrapper $gobject $gattr
destroy_object $gobject
done
done
done
done
log_pass "DOS & BSD'ish attributes provide the access limitation as expected."

View File

@ -0,0 +1,116 @@
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# $FreeBSD$
#
# Copyright 2012 Spectra Logic. All rights reserved.
# Use is subject to license terms.
#
atf_test_case cifs_attr_001_pos cleanup
cifs_attr_001_pos_head()
{
atf_set "descr" "Verify set/clear DOS attributes will succeed while user haswrite_attributes permission or PRIV_FILE_OWNER privilege"
atf_set "require.config" zfs_acl zfs_xattr
atf_set "require.progs" runwattr
}
cifs_attr_001_pos_body()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/cifs.kshlib
. $(atf_get_srcdir)/../acl.cfg
verify_disk_count "$DISKS" 1
ksh93 $(atf_get_srcdir)/../setup.ksh || atf_fail "Setup failed"
ksh93 $(atf_get_srcdir)/cifs_attr_001_pos.ksh || atf_fail "Testcase failed"
}
cifs_attr_001_pos_cleanup()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/cifs.kshlib
. $(atf_get_srcdir)/../acl.cfg
ksh93 $(atf_get_srcdir)/../cleanup.ksh || atf_fail "Cleanup failed"
}
atf_test_case cifs_attr_002_pos cleanup
cifs_attr_002_pos_head()
{
atf_set "descr" "Verify set/clear BSD'ish attributes will succeed while user hasPRIV_FILE_FLAG_SET/PRIV_FILE_FLAG_CLEAR privilege"
atf_set "require.config" zfs_acl zfs_xattr
atf_set "require.progs" runwattr
}
cifs_attr_002_pos_body()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/cifs.kshlib
. $(atf_get_srcdir)/../acl.cfg
verify_disk_count "$DISKS" 1
ksh93 $(atf_get_srcdir)/../setup.ksh || atf_fail "Setup failed"
ksh93 $(atf_get_srcdir)/cifs_attr_002_pos.ksh || atf_fail "Testcase failed"
}
cifs_attr_002_pos_cleanup()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/cifs.kshlib
. $(atf_get_srcdir)/../acl.cfg
ksh93 $(atf_get_srcdir)/../cleanup.ksh || atf_fail "Cleanup failed"
}
atf_test_case cifs_attr_003_pos cleanup
cifs_attr_003_pos_head()
{
atf_set "descr" "Verify DOS & BSD'ish attributes will provide theaccess limitation as expected."
atf_set "require.config" zfs_acl zfs_xattr
atf_set "require.progs" runat
}
cifs_attr_003_pos_body()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/cifs.kshlib
. $(atf_get_srcdir)/../acl.cfg
verify_disk_count "$DISKS" 1
ksh93 $(atf_get_srcdir)/../setup.ksh || atf_fail "Setup failed"
ksh93 $(atf_get_srcdir)/cifs_attr_003_pos.ksh || atf_fail "Testcase failed"
}
cifs_attr_003_pos_cleanup()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/cifs.kshlib
. $(atf_get_srcdir)/../acl.cfg
ksh93 $(atf_get_srcdir)/../cleanup.ksh || atf_fail "Cleanup failed"
}
atf_init_test_cases()
{
atf_add_test_case cifs_attr_001_pos
atf_add_test_case cifs_attr_002_pos
atf_add_test_case cifs_attr_003_pos
}

View File

@ -0,0 +1,44 @@
#!/usr/local/bin/ksh93 -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# $FreeBSD$
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "@(#)cleanup.ksh 1.2 07/01/09 SMI"
#
. $STF_SUITE/include/libtest.kshlib
. $STF_SUITE/tests/acl/acl_common.kshlib
cleanup_user_group
# restore the state of svc:/network/nis/client:default
if [[ -e $NISSTAFILE ]]; then
log_must $SVCADM enable svc:/network/nis/client:default
log_must $RM -f $NISSTAFILE
fi
default_cleanup

View File

@ -0,0 +1,40 @@
# $FreeBSD$
.include <src.opts.mk>
PACKAGE=tests
TESTSDIR=${TESTSBASE}/sys/cddl/zfs/tests/acl/nontrivial
FILESDIR=${TESTSDIR}
${PACKAGE}FILES+= zfs_acl_chmod_001_neg.ksh
${PACKAGE}FILES+= zfs_acl_chmod_002_pos.ksh
${PACKAGE}FILES+= zfs_acl_chmod_aclmode_001_pos.ksh
${PACKAGE}FILES+= zfs_acl_chmod_compact_001_pos.ksh
${PACKAGE}FILES+= zfs_acl_chmod_delete_001_pos.ksh
${PACKAGE}FILES+= zfs_acl_chmod_inherit_001_pos.ksh
${PACKAGE}FILES+= zfs_acl_chmod_inherit_002_pos.ksh
${PACKAGE}FILES+= zfs_acl_chmod_inherit_003_pos.ksh
${PACKAGE}FILES+= zfs_acl_chmod_inherit_004_pos.ksh
${PACKAGE}FILES+= zfs_acl_chmod_owner_001_pos.ksh
${PACKAGE}FILES+= zfs_acl_chmod_rwacl_001_pos.ksh
${PACKAGE}FILES+= zfs_acl_chmod_rwx_001_pos.ksh
${PACKAGE}FILES+= zfs_acl_chmod_rwx_002_pos.ksh
${PACKAGE}FILES+= zfs_acl_chmod_rwx_003_pos.ksh
${PACKAGE}FILES+= zfs_acl_chmod_rwx_004_pos.ksh
${PACKAGE}FILES+= zfs_acl_chmod_xattr_001_pos.ksh
${PACKAGE}FILES+= zfs_acl_chmod_xattr_002_pos.ksh
${PACKAGE}FILES+= zfs_acl_cp_001_pos.ksh
${PACKAGE}FILES+= zfs_acl_cp_002_pos.ksh
${PACKAGE}FILES+= zfs_acl_cpio_001_pos.ksh
${PACKAGE}FILES+= zfs_acl_cpio_002_pos.ksh
${PACKAGE}FILES+= zfs_acl_find_001_pos.ksh
${PACKAGE}FILES+= zfs_acl_ls_001_pos.ksh
${PACKAGE}FILES+= zfs_acl_mv_001_pos.ksh
${PACKAGE}FILES+= zfs_acl_tar_001_pos.ksh
${PACKAGE}FILES+= zfs_acl_tar_002_pos.ksh
ATF_TESTS_KSH93+= nontrivial_test
TEST_METADATA+= required_user="root"
TEST_METADATA+= is_exclusive=true
.include <bsd.test.mk>

View File

@ -0,0 +1,695 @@
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# $FreeBSD$
#
# Copyright 2012 Spectra Logic. All rights reserved.
# Use is subject to license terms.
#
atf_test_case zfs_acl_chmod_001_neg cleanup
zfs_acl_chmod_001_neg_head()
{
atf_set "descr" "Verify illegal operating to ACL, it will fail."
atf_set "require.config" zfs_acl
}
zfs_acl_chmod_001_neg_body()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
verify_disk_count "$DISKS" 1
ksh93 $(atf_get_srcdir)/../setup.ksh || atf_fail "Setup failed"
ksh93 $(atf_get_srcdir)/zfs_acl_chmod_001_neg.ksh || atf_fail "Testcase failed"
}
zfs_acl_chmod_001_neg_cleanup()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
ksh93 $(atf_get_srcdir)/../cleanup.ksh || atf_fail "Cleanup failed"
}
atf_test_case zfs_acl_chmod_002_pos cleanup
zfs_acl_chmod_002_pos_head()
{
atf_set "descr" "Verify acl after upgrading."
atf_set "require.config" zfs_acl
atf_set "require.progs" zfs
}
zfs_acl_chmod_002_pos_body()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
verify_disk_count "$DISKS" 1
ksh93 $(atf_get_srcdir)/../setup.ksh || atf_fail "Setup failed"
ksh93 $(atf_get_srcdir)/zfs_acl_chmod_002_pos.ksh || atf_fail "Testcase failed"
}
zfs_acl_chmod_002_pos_cleanup()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
ksh93 $(atf_get_srcdir)/../cleanup.ksh || atf_fail "Cleanup failed"
}
atf_test_case zfs_acl_chmod_aclmode_001_pos cleanup
zfs_acl_chmod_aclmode_001_pos_head()
{
atf_set "descr" "Verify chmod have correct behaviour to directory and file whenfilesystem has the different aclmode setting."
atf_set "require.config" zfs_acl
atf_set "require.progs" zfs
}
zfs_acl_chmod_aclmode_001_pos_body()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
verify_disk_count "$DISKS" 1
ksh93 $(atf_get_srcdir)/../setup.ksh || atf_fail "Setup failed"
ksh93 $(atf_get_srcdir)/zfs_acl_chmod_aclmode_001_pos.ksh || atf_fail "Testcase failed"
}
zfs_acl_chmod_aclmode_001_pos_cleanup()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
ksh93 $(atf_get_srcdir)/../cleanup.ksh || atf_fail "Cleanup failed"
}
atf_test_case zfs_acl_chmod_compact_001_pos cleanup
zfs_acl_chmod_compact_001_pos_head()
{
atf_set "descr" "chmod A{+|=} should set compact ACL correctly."
atf_set "require.config" zfs_acl
}
zfs_acl_chmod_compact_001_pos_body()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
verify_disk_count "$DISKS" 1
ksh93 $(atf_get_srcdir)/../setup.ksh || atf_fail "Setup failed"
ksh93 $(atf_get_srcdir)/zfs_acl_chmod_compact_001_pos.ksh || atf_fail "Testcase failed"
}
zfs_acl_chmod_compact_001_pos_cleanup()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
ksh93 $(atf_get_srcdir)/../cleanup.ksh || atf_fail "Cleanup failed"
}
atf_test_case zfs_acl_chmod_delete_001_pos cleanup
zfs_acl_chmod_delete_001_pos_head()
{
atf_set "descr" "Verify that the combined delete_child/delete permission forowner/group/everyone are correct."
atf_set "require.config" zfs_acl
}
zfs_acl_chmod_delete_001_pos_body()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
verify_disk_count "$DISKS" 1
ksh93 $(atf_get_srcdir)/../setup.ksh || atf_fail "Setup failed"
ksh93 $(atf_get_srcdir)/zfs_acl_chmod_delete_001_pos.ksh || atf_fail "Testcase failed"
}
zfs_acl_chmod_delete_001_pos_cleanup()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
ksh93 $(atf_get_srcdir)/../cleanup.ksh || atf_fail "Cleanup failed"
}
atf_test_case zfs_acl_chmod_inherit_001_pos cleanup
zfs_acl_chmod_inherit_001_pos_head()
{
atf_set "descr" "Verify chmod have correct behaviour to directory and file whensetting different inherit strategies to them."
atf_set "require.config" zfs_acl
}
zfs_acl_chmod_inherit_001_pos_body()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
verify_disk_count "$DISKS" 1
ksh93 $(atf_get_srcdir)/../setup.ksh || atf_fail "Setup failed"
ksh93 $(atf_get_srcdir)/zfs_acl_chmod_inherit_001_pos.ksh || atf_fail "Testcase failed"
}
zfs_acl_chmod_inherit_001_pos_cleanup()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
ksh93 $(atf_get_srcdir)/../cleanup.ksh || atf_fail "Cleanup failed"
}
atf_test_case zfs_acl_chmod_inherit_002_pos cleanup
zfs_acl_chmod_inherit_002_pos_head()
{
atf_set "descr" "Verify chmod have correct behaviour to directory and file whenfilesystem has the different aclinherit setting."
atf_set "require.config" zfs_acl
atf_set "require.progs" zfs
}
zfs_acl_chmod_inherit_002_pos_body()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
verify_disk_count "$DISKS" 1
ksh93 $(atf_get_srcdir)/../setup.ksh || atf_fail "Setup failed"
ksh93 $(atf_get_srcdir)/zfs_acl_chmod_inherit_002_pos.ksh || atf_fail "Testcase failed"
}
zfs_acl_chmod_inherit_002_pos_cleanup()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
ksh93 $(atf_get_srcdir)/../cleanup.ksh || atf_fail "Cleanup failed"
}
atf_test_case zfs_acl_chmod_inherit_003_pos cleanup
zfs_acl_chmod_inherit_003_pos_head()
{
atf_set "descr" "Verify chmod have correct behaviour to directory and file whenfilesystem has the different aclinherit setting."
atf_set "require.config" zfs_acl
atf_set "require.progs" zfs
}
zfs_acl_chmod_inherit_003_pos_body()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
verify_disk_count "$DISKS" 1
ksh93 $(atf_get_srcdir)/../setup.ksh || atf_fail "Setup failed"
ksh93 $(atf_get_srcdir)/zfs_acl_chmod_inherit_003_pos.ksh || atf_fail "Testcase failed"
}
zfs_acl_chmod_inherit_003_pos_cleanup()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
ksh93 $(atf_get_srcdir)/../cleanup.ksh || atf_fail "Cleanup failed"
}
atf_test_case zfs_acl_chmod_inherit_004_pos cleanup
zfs_acl_chmod_inherit_004_pos_head()
{
atf_set "descr" "Verify aclinherit=passthrough-x will inherit the 'x' bits while mode request."
atf_set "require.config" zfs_acl
atf_set "require.progs" zfs zpool
}
zfs_acl_chmod_inherit_004_pos_body()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
verify_disk_count "$DISKS" 1
ksh93 $(atf_get_srcdir)/../setup.ksh || atf_fail "Setup failed"
ksh93 $(atf_get_srcdir)/zfs_acl_chmod_inherit_004_pos.ksh || atf_fail "Testcase failed"
}
zfs_acl_chmod_inherit_004_pos_cleanup()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
ksh93 $(atf_get_srcdir)/../cleanup.ksh || atf_fail "Cleanup failed"
}
atf_test_case zfs_acl_chmod_owner_001_pos cleanup
zfs_acl_chmod_owner_001_pos_head()
{
atf_set "descr" "Verify that the chown/chgrp could take owner/groupwhile permission is granted."
atf_set "require.config" zfs_acl
}
zfs_acl_chmod_owner_001_pos_body()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
verify_disk_count "$DISKS" 1
ksh93 $(atf_get_srcdir)/../setup.ksh || atf_fail "Setup failed"
ksh93 $(atf_get_srcdir)/zfs_acl_chmod_owner_001_pos.ksh || atf_fail "Testcase failed"
}
zfs_acl_chmod_owner_001_pos_cleanup()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
ksh93 $(atf_get_srcdir)/../cleanup.ksh || atf_fail "Cleanup failed"
}
atf_test_case zfs_acl_chmod_rwacl_001_pos cleanup
zfs_acl_chmod_rwacl_001_pos_head()
{
atf_set "descr" "Verify chmod A[number]{+|-|=} read_acl/write_acl have correctbehaviour to access permission."
atf_set "require.config" zfs_acl
}
zfs_acl_chmod_rwacl_001_pos_body()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
verify_disk_count "$DISKS" 1
ksh93 $(atf_get_srcdir)/../setup.ksh || atf_fail "Setup failed"
ksh93 $(atf_get_srcdir)/zfs_acl_chmod_rwacl_001_pos.ksh || atf_fail "Testcase failed"
}
zfs_acl_chmod_rwacl_001_pos_cleanup()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
ksh93 $(atf_get_srcdir)/../cleanup.ksh || atf_fail "Cleanup failed"
}
atf_test_case zfs_acl_chmod_rwx_001_pos cleanup
zfs_acl_chmod_rwx_001_pos_head()
{
atf_set "descr" "chmod A{+|-|=} have the correct behaviour to the ACL list."
atf_set "require.config" zfs_acl
}
zfs_acl_chmod_rwx_001_pos_body()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
verify_disk_count "$DISKS" 1
ksh93 $(atf_get_srcdir)/../setup.ksh || atf_fail "Setup failed"
ksh93 $(atf_get_srcdir)/zfs_acl_chmod_rwx_001_pos.ksh || atf_fail "Testcase failed"
}
zfs_acl_chmod_rwx_001_pos_cleanup()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
ksh93 $(atf_get_srcdir)/../cleanup.ksh || atf_fail "Cleanup failed"
}
atf_test_case zfs_acl_chmod_rwx_002_pos cleanup
zfs_acl_chmod_rwx_002_pos_head()
{
atf_set "descr" "chmod A{+|-|=} read_data|write_data|execute for owner@, group@or everyone@ correctly alters mode bits."
atf_set "require.config" zfs_acl
}
zfs_acl_chmod_rwx_002_pos_body()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
verify_disk_count "$DISKS" 1
ksh93 $(atf_get_srcdir)/../setup.ksh || atf_fail "Setup failed"
ksh93 $(atf_get_srcdir)/zfs_acl_chmod_rwx_002_pos.ksh || atf_fail "Testcase failed"
}
zfs_acl_chmod_rwx_002_pos_cleanup()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
ksh93 $(atf_get_srcdir)/../cleanup.ksh || atf_fail "Cleanup failed"
}
atf_test_case zfs_acl_chmod_rwx_003_pos cleanup
zfs_acl_chmod_rwx_003_pos_head()
{
atf_set "descr" "Verify that the read_data/write_data/execute permission forowner/group/everyone are correct."
atf_set "require.config" zfs_acl
}
zfs_acl_chmod_rwx_003_pos_body()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
verify_disk_count "$DISKS" 1
ksh93 $(atf_get_srcdir)/../setup.ksh || atf_fail "Setup failed"
ksh93 $(atf_get_srcdir)/zfs_acl_chmod_rwx_003_pos.ksh || atf_fail "Testcase failed"
}
zfs_acl_chmod_rwx_003_pos_cleanup()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
ksh93 $(atf_get_srcdir)/../cleanup.ksh || atf_fail "Cleanup failed"
}
atf_test_case zfs_acl_chmod_rwx_004_pos cleanup
zfs_acl_chmod_rwx_004_pos_head()
{
atf_set "descr" "Verify that explicit ACL setting to specified user or group willoverride existed access rule."
atf_set "require.config" zfs_acl
}
zfs_acl_chmod_rwx_004_pos_body()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
verify_disk_count "$DISKS" 1
ksh93 $(atf_get_srcdir)/../setup.ksh || atf_fail "Setup failed"
ksh93 $(atf_get_srcdir)/zfs_acl_chmod_rwx_004_pos.ksh || atf_fail "Testcase failed"
}
zfs_acl_chmod_rwx_004_pos_cleanup()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
ksh93 $(atf_get_srcdir)/../cleanup.ksh || atf_fail "Cleanup failed"
}
atf_test_case zfs_acl_chmod_xattr_001_pos cleanup
zfs_acl_chmod_xattr_001_pos_head()
{
atf_set "descr" "Verify that the permission of read_xattr/write_xattr forowner/group/everyone are correct."
atf_set "require.config" zfs_acl zfs_xattr
atf_set "require.progs" runat
}
zfs_acl_chmod_xattr_001_pos_body()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
verify_disk_count "$DISKS" 1
ksh93 $(atf_get_srcdir)/../setup.ksh || atf_fail "Setup failed"
ksh93 $(atf_get_srcdir)/zfs_acl_chmod_xattr_001_pos.ksh || atf_fail "Testcase failed"
}
zfs_acl_chmod_xattr_001_pos_cleanup()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
ksh93 $(atf_get_srcdir)/../cleanup.ksh || atf_fail "Cleanup failed"
}
atf_test_case zfs_acl_chmod_xattr_002_pos cleanup
zfs_acl_chmod_xattr_002_pos_head()
{
atf_set "descr" "Verify that the permission of write_xattr forowner/group/everyone while remove extended attributes are correct."
atf_set "require.config" zfs_xattr
atf_set "require.progs" runat
}
zfs_acl_chmod_xattr_002_pos_body()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
verify_disk_count "$DISKS" 1
ksh93 $(atf_get_srcdir)/../setup.ksh || atf_fail "Setup failed"
ksh93 $(atf_get_srcdir)/zfs_acl_chmod_xattr_002_pos.ksh || atf_fail "Testcase failed"
}
zfs_acl_chmod_xattr_002_pos_cleanup()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
ksh93 $(atf_get_srcdir)/../cleanup.ksh || atf_fail "Cleanup failed"
}
atf_test_case zfs_acl_cp_001_pos cleanup
zfs_acl_cp_001_pos_head()
{
atf_set "descr" "Verify that '$CP [-p]' supports ZFS ACLs."
atf_set "require.config" zfs_acl
atf_set "require.progs" zfs
}
zfs_acl_cp_001_pos_body()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
verify_disk_count "$DISKS" 1
ksh93 $(atf_get_srcdir)/../setup.ksh || atf_fail "Setup failed"
ksh93 $(atf_get_srcdir)/zfs_acl_cp_001_pos.ksh || atf_fail "Testcase failed"
}
zfs_acl_cp_001_pos_cleanup()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
ksh93 $(atf_get_srcdir)/../cleanup.ksh || atf_fail "Cleanup failed"
}
atf_test_case zfs_acl_cp_002_pos cleanup
zfs_acl_cp_002_pos_head()
{
atf_set "descr" "Verify that '$CP [-p]' supports ZFS ACLs."
atf_set "require.config" zfs_acl zfs_xattr
atf_set "require.progs" zfs runat
}
zfs_acl_cp_002_pos_body()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
verify_disk_count "$DISKS" 1
ksh93 $(atf_get_srcdir)/../setup.ksh || atf_fail "Setup failed"
ksh93 $(atf_get_srcdir)/zfs_acl_cp_002_pos.ksh || atf_fail "Testcase failed"
}
zfs_acl_cp_002_pos_cleanup()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
ksh93 $(atf_get_srcdir)/../cleanup.ksh || atf_fail "Cleanup failed"
}
atf_test_case zfs_acl_cpio_001_pos cleanup
zfs_acl_cpio_001_pos_head()
{
atf_set "descr" "Verify that '$CPIO' command supports to archive ZFS ACLs."
atf_set "require.config" zfs_acl
atf_set "require.progs" zfs
}
zfs_acl_cpio_001_pos_body()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
verify_disk_count "$DISKS" 1
ksh93 $(atf_get_srcdir)/../setup.ksh || atf_fail "Setup failed"
ksh93 $(atf_get_srcdir)/zfs_acl_cpio_001_pos.ksh || atf_fail "Testcase failed"
}
zfs_acl_cpio_001_pos_cleanup()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
ksh93 $(atf_get_srcdir)/../cleanup.ksh || atf_fail "Cleanup failed"
}
atf_test_case zfs_acl_cpio_002_pos cleanup
zfs_acl_cpio_002_pos_head()
{
atf_set "descr" "Verify that '$CPIO' command supports to archive ZFS ACLs & xattrs."
atf_set "require.config" zfs_acl zfs_xattr
atf_set "require.progs" zfs runat
}
zfs_acl_cpio_002_pos_body()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
verify_disk_count "$DISKS" 1
ksh93 $(atf_get_srcdir)/../setup.ksh || atf_fail "Setup failed"
ksh93 $(atf_get_srcdir)/zfs_acl_cpio_002_pos.ksh || atf_fail "Testcase failed"
}
zfs_acl_cpio_002_pos_cleanup()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
ksh93 $(atf_get_srcdir)/../cleanup.ksh || atf_fail "Cleanup failed"
}
atf_test_case zfs_acl_find_001_pos cleanup
zfs_acl_find_001_pos_head()
{
atf_set "descr" "Verify that '$FIND' command supports ZFS ACLs."
atf_set "require.config" zfs_acl
}
zfs_acl_find_001_pos_body()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
verify_disk_count "$DISKS" 1
ksh93 $(atf_get_srcdir)/../setup.ksh || atf_fail "Setup failed"
ksh93 $(atf_get_srcdir)/zfs_acl_find_001_pos.ksh || atf_fail "Testcase failed"
}
zfs_acl_find_001_pos_cleanup()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
ksh93 $(atf_get_srcdir)/../cleanup.ksh || atf_fail "Cleanup failed"
}
atf_test_case zfs_acl_ls_001_pos cleanup
zfs_acl_ls_001_pos_head()
{
atf_set "descr" "Verify that '$LS' command supports ZFS ACLs."
atf_set "require.config" zfs_acl
}
zfs_acl_ls_001_pos_body()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
verify_disk_count "$DISKS" 1
ksh93 $(atf_get_srcdir)/../setup.ksh || atf_fail "Setup failed"
ksh93 $(atf_get_srcdir)/zfs_acl_ls_001_pos.ksh || atf_fail "Testcase failed"
}
zfs_acl_ls_001_pos_cleanup()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
ksh93 $(atf_get_srcdir)/../cleanup.ksh || atf_fail "Cleanup failed"
}
atf_test_case zfs_acl_mv_001_pos cleanup
zfs_acl_mv_001_pos_head()
{
atf_set "descr" "Verify that '$MV' supports ZFS ACLs."
atf_set "require.config" zfs_acl
}
zfs_acl_mv_001_pos_body()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
verify_disk_count "$DISKS" 1
ksh93 $(atf_get_srcdir)/../setup.ksh || atf_fail "Setup failed"
ksh93 $(atf_get_srcdir)/zfs_acl_mv_001_pos.ksh || atf_fail "Testcase failed"
}
zfs_acl_mv_001_pos_cleanup()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
ksh93 $(atf_get_srcdir)/../cleanup.ksh || atf_fail "Cleanup failed"
}
atf_test_case zfs_acl_tar_001_pos cleanup
zfs_acl_tar_001_pos_head()
{
atf_set "descr" "Verify that '$TAR' command supports to archive ZFS ACLs."
atf_set "require.config" zfs_acl
atf_set "require.progs" zfs
}
zfs_acl_tar_001_pos_body()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
verify_disk_count "$DISKS" 1
ksh93 $(atf_get_srcdir)/../setup.ksh || atf_fail "Setup failed"
ksh93 $(atf_get_srcdir)/zfs_acl_tar_001_pos.ksh || atf_fail "Testcase failed"
}
zfs_acl_tar_001_pos_cleanup()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
ksh93 $(atf_get_srcdir)/../cleanup.ksh || atf_fail "Cleanup failed"
}
atf_test_case zfs_acl_tar_002_pos cleanup
zfs_acl_tar_002_pos_head()
{
atf_set "descr" "Verify that '$TAR' command supports to archive ZFS ACLs & xattrs."
atf_set "require.config" zfs_acl zfs_xattr
atf_set "require.progs" zfs runat
}
zfs_acl_tar_002_pos_body()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
verify_disk_count "$DISKS" 1
ksh93 $(atf_get_srcdir)/../setup.ksh || atf_fail "Setup failed"
ksh93 $(atf_get_srcdir)/zfs_acl_tar_002_pos.ksh || atf_fail "Testcase failed"
}
zfs_acl_tar_002_pos_cleanup()
{
. $(atf_get_srcdir)/../../../include/default.cfg
. $(atf_get_srcdir)/../acl.cfg
ksh93 $(atf_get_srcdir)/../cleanup.ksh || atf_fail "Cleanup failed"
}
atf_init_test_cases()
{
atf_add_test_case zfs_acl_chmod_001_neg
atf_add_test_case zfs_acl_chmod_002_pos
atf_add_test_case zfs_acl_chmod_aclmode_001_pos
atf_add_test_case zfs_acl_chmod_compact_001_pos
atf_add_test_case zfs_acl_chmod_delete_001_pos
atf_add_test_case zfs_acl_chmod_inherit_001_pos
atf_add_test_case zfs_acl_chmod_inherit_002_pos
atf_add_test_case zfs_acl_chmod_inherit_003_pos
atf_add_test_case zfs_acl_chmod_inherit_004_pos
atf_add_test_case zfs_acl_chmod_owner_001_pos
atf_add_test_case zfs_acl_chmod_rwacl_001_pos
atf_add_test_case zfs_acl_chmod_rwx_001_pos
atf_add_test_case zfs_acl_chmod_rwx_002_pos
atf_add_test_case zfs_acl_chmod_rwx_003_pos
atf_add_test_case zfs_acl_chmod_rwx_004_pos
atf_add_test_case zfs_acl_chmod_xattr_001_pos
atf_add_test_case zfs_acl_chmod_xattr_002_pos
atf_add_test_case zfs_acl_cp_001_pos
atf_add_test_case zfs_acl_cp_002_pos
atf_add_test_case zfs_acl_cpio_001_pos
atf_add_test_case zfs_acl_cpio_002_pos
atf_add_test_case zfs_acl_find_001_pos
atf_add_test_case zfs_acl_ls_001_pos
atf_add_test_case zfs_acl_mv_001_pos
atf_add_test_case zfs_acl_tar_001_pos
atf_add_test_case zfs_acl_tar_002_pos
}

View File

@ -0,0 +1,151 @@
#!/usr/local/bin/ksh93 -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# $FreeBSD$
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "@(#)zfs_acl_chmod_001_neg.ksh 1.4 09/01/13 SMI"
#
. $STF_SUITE/tests/acl/acl_common.kshlib
#################################################################################
#
# __stc_assertion_start
#
# ID: zfs_acl_chmod_001_neg
#
# DESCRIPTION:
# Verify 1) Illegal options to chmod should fail.
# 2) Delete all the ACE will lead to fail.
# 3) Add ACE exceed 1024 will cause to fail.
#
# STRATEGY:
# 1. Loop root and non-root users
# 2. Verify all kinds of illegal option will lead to chmod failed.
# 3. Verify 'chmod A0-' will fail when try to delete all the ACE.
# 4. Verify 'chmod A+' will succeed when the ACE number exceed 1024.
#
# TESTABILITY: explicit
#
# TEST_AUTOMATION_LEVEL: automated
#
# CODING_STATUS: COMPLETED (2005-10-14)
#
# __stc_assertion_end
#
################################################################################
verify_runnable "both"
log_assert "Verify illegal operating to ACL, it will fail."
log_onexit cleanup
test_requires ZFS_ACL
function err_opts #node
{
typeset A_opts="+A@ -A#- +A% =A^ =A# =A@ +A#\ asd \
A+@ A-#- A+% A=^ A=# A=@ A+#"
log_note "Illegal option to chmod should fail."
for A in ${A_opts[@]}; do
log_mustnot usr_exec $CHMOD ${A}owner@:read_data:allow $node
log_mustnot usr_exec $CHMOD A+ asd owner@:execute:deny $node
done
typeset type_opts="everyone groups owner user@ users"
for tp in ${type_opts[@]}; do
log_mustnot usr_exec $CHMOD A+$tp:read_data:deny $node
done
return 0
}
function del_all_ACE #node
{
typeset node=$1
typeset -i cnt
cnt=$(count_ACE $node)
while (( cnt > 0 )); do
if (( cnt == 1 )); then
log_mustnot $CHMOD A0- $node
else
log_must $CHMOD A0- $node
fi
(( cnt -= 1 ))
done
return 0
}
function exceed_max_ACE #node
{
typeset node=$1
typeset -i max=1024
typeset -i cnt
cnt=$(count_ACE $node)
# One more ACE exceed the max limitation.
(( max = max - cnt + 1 ))
while (( max > 0 )); do
if (( max == 1 )); then
log_mustnot $CHMOD A+owner@:read_data:allow $node
else
$CHMOD A+owner@:read_data:allow $node
if (($? != 0)); then
((cnt = 1024 - max))
log_fail "Add No.$cnt ACL item failed."
fi
fi
(( max -= 1 ))
done
return 0
}
typeset node
typeset func_name="err_opts del_all_ACE exceed_max_ACE"
for usr in "root" "$ZFS_ACL_STAFF1"; do
log_must set_cur_usr $usr
for node in $testfile $testdir; do
log_must usr_exec $TOUCH $testfile
log_must usr_exec $MKDIR $testdir
for func in $func_name; do
log_must eval "$func $node"
done
log_must usr_exec $RM -rf $testfile $testdir
done
done
log_pass "Verify illegal operating to ACL passed."

View File

@ -0,0 +1,82 @@
#!/usr/local/bin/ksh93 -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# $FreeBSD$
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "@(#)zfs_acl_chmod_002_pos.ksh 1.1 09/06/22 SMI"
#
. $STF_SUITE/include/libtest.kshlib
#################################################################################
#
# __stc_assertion_start
#
# ID: zfs_acl_chmod_002_pos
#
# DESCRIPTION:
# Verify acl after upgrading.
# STRATEGY:
# 1. Create a low version fs.
# 2. Create a directory and chmod it.
# 3. Upgrade the fs.
# 4. Create a file under the directory and list it.
#
# TESTABILITY: explicit
#
# TEST_AUTOMATION_LEVEL: automated
#
# CODING_STATUS: COMPLETED (2009-06-05)
#
# __stc_assertion_end
#
################################################################################
verify_runnable "both"
function acl_upgrade_cleannup
{
datasetexists $ACL_UPGRADE_FS && \
log_must $ZFS destroy -rR $ACL_UPGRADE_FS
}
log_assert "Verify acl after upgrading."
log_onexit acl_upgrade_cleannup
ACL_UPGRADE_FS=$TESTPOOL/acl_upgrade_fs.${TESTCASE_ID}
test_requires ZFS_ACL
log_must $ZFS create -o version=2 $ACL_UPGRADE_FS
mntpnt=$(get_prop mountpoint $ACL_UPGRADE_FS)
log_must $MKDIR $mntpnt/dir.${TESTCASE_ID}
log_must $CHMOD A+owner@:rwxp:f:allow,group@:rwxp:f:allow $mntpnt/dir.${TESTCASE_ID}
log_must $ZFS upgrade $ACL_UPGRADE_FS
log_must $TOUCH $mntpnt/dir.${TESTCASE_ID}/file.${TESTCASE_ID}
log_must eval "$LS -V $mntpnt/dir.${TESTCASE_ID}/file.${TESTCASE_ID} > /dev/null 2>&1"
log_pass "Verify acl after upgrading."

View File

@ -0,0 +1,490 @@
#!/usr/local/bin/ksh93 -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# $FreeBSD$
#
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "@(#)zfs_acl_chmod_aclmode_001_pos.ksh 1.3 08/08/15 SMI"
#
. $STF_SUITE/tests/acl/acl_common.kshlib
#################################################################################
#
# __stc_assertion_start
#
# ID: zfs_acl_chmod_aclmode_001_pos
#
# DESCRIPTION:
# Verify chmod have correct behaviour to directory and file when
# filesystem has the different aclmode setting
#
# STRATEGY:
# 1. Loop super user and non-super user to run the test case.
# 2. Create basedir and a set of subdirectores and files within it.
# 3. Separately chmod basedir with different aclmode options,
# combine with the variable setting of aclmode:
# "discard", "groupmask", or "passthrough".
# 4. Verify each directories and files have the correct access control
# capability.
#
# TESTABILITY: explicit
#
# TEST_AUTOMATION_LEVEL: automated
#
# CODING_STATUS: COMPLETED (2006-03-02)
#
# __stc_assertion_end
#
################################################################################
verify_runnable "both"
test_requires ZFS_ACL
function cleanup
{
# Cleanup tarfile & basedir.
(( ${#cwd} != 0 )) && cd $cwd
if [[ -f $TARFILE ]]; then
log_must $RM -f $TARFILE
fi
if [[ -d $basedir ]]; then
log_must $RM -rf $basedir
fi
}
log_assert "Verify chmod have correct behaviour to directory and file when " \
"filesystem has the different aclmode setting."
log_onexit cleanup
# Define aclmode flag
set -A aclmode_flag discard groupmask passthrough
set -A ace_prefix "user:$ZFS_ACL_OTHER1" \
"user:$ZFS_ACL_OTHER2" \
"group:$ZFS_ACL_STAFF_GROUP" \
"group:$ZFS_ACL_OTHER_GROUP"
set -A argv "000" "444" "644" "777" "755" "231" "562" "413"
set -A ace_file_preset "read_data" \
"write_data" \
"append_data" \
"execute" \
"read_data/write_data" \
"read_data/write_data/append_data" \
"write_data/append_data" \
"read_data/execute" \
"write_data/append_data/execute" \
"read_data/write_data/append_data/execute"
# Defile the based directory and file
basedir=$TESTDIR/basedir; ofile=$basedir/ofile; odir=$basedir/odir
nfile=$basedir/nfile; ndir=$basedir/ndir
TARFILE=$TESTDIR/tarfile
# Verify all the node have expected correct access control
allnodes="$nfile $ndir"
#
# According to the original bits, the input ACE access and ACE type, return the
# expect bits after 'chmod A0{+|=}'.
#
# $1 isdir indicate if the target is a directory
# $1 bits which was make up of three bit 'rwx'
# $2 bits_limit which was make up of three bit 'rwx'
# $3 ACE access which is read_data, write_data or execute
# $4 ACE type which is allow or deny
#
function cal_bits #isdir bits bits_limit acl_access ctrl
{
typeset -i isdir=$1
typeset -i bits=$2
typeset -i bits_limit=$3
typeset acl_access=$4
typeset -i ctrl=${5:-0}
typeset flagr=0; flagw=0; flagx=0
typeset tmpstr
if (( ctrl == 0 )); then
if (( (( bits & 4 )) == 0 )); then
flagr=1
fi
if (( (( bits & 2 )) == 0 )); then
flagw=1
fi
if (( (( bits & 1 )) == 0 )); then
flagx=1
fi
else
#
# Tricky here:
# (1) flagr is always set to be 1,
# (2) flagw & flagx is set to be 0 only while
# bits_limit has lower permissions than bits
#
flagr=1
flagw=1
flagx=1
if (( (( bits & 2 )) != 0 )) && \
(( (( bits_limit & 2 )) == 0 )) ; then
flagw=0
fi
if (( (( bits & 1 )) != 0 )) && \
(( (( bits_limit & 1 )) == 0 )) ; then
flagx=0
fi
fi
if (( flagr != 0 )); then
if [[ $acl_access == *"read_data"* ]]; then
if (( isdir == 0 )) ; then
tmpstr=${tmpstr}/read_data
else
tmpstr=${tmpstr}/list_directory/read_data
fi
fi
fi
if (( flagw != 0 )); then
if [[ $acl_access == *"write_data"* ]]; then
if (( isdir == 0 )); then
tmpstr=${tmpstr}/write_data
else
tmpstr=${tmpstr}/add_file/write_data
fi
fi
if [[ $acl_access == *"append_data"* ]]; then
if (( isdir == 0 )); then
tmpstr=${tmpstr}/append_data
else
tmpstr=${tmpstr}/add_subdirectory/append_data
fi
fi
fi
if (( flagx != 0 )); then
[[ $acl_access == *"execute"* ]] && \
tmpstr=${tmpstr}/execute
fi
tmpstr=${tmpstr#/}
$ECHO "$tmpstr"
}
#
# To translate an ace if the node is dir
#
# $1 isdir indicate if the target is a directory
# $2 acl to be translated
#
function translate_acl #isdir acl
{
typeset -i isdir=$1
typeset acl=$2
typeset who prefix acltemp action
if (( isdir != 0 )); then
who=${acl%%:*}
prefix=$who
acltemp=${acl#*:}
acltemp=${acltemp%%:*}
prefix=$prefix:$acltemp
action=${acl##*:}
acl=$prefix:$(cal_bits $isdir 7 7 $acl 1):$action
fi
$ECHO "$acl"
}
#
# According to inherited flag, verify subdirectories and files within it has
# correct inherited access control.
#
function verify_aclmode #<aclmode> <node> <newmode>
{
# Define the nodes which will be affected by inherit.
typeset aclmode=$1
typeset node=$2
typeset newmode=$3
# count: the ACE item to fetch
# pass: to mark if the current ACE should apply to the target
# passcnt: counter, if it achieves to maxnumber,
# then no additional ACE should apply.
# step: indicate if the ACE be split during aclmode.
typeset -i count=0 pass=0 passcnt=0 step=0
typeset -i bits=0 obits=0 bits_owner=0 isdir=0
if [[ -d $node ]]; then
(( isdir = 1 ))
fi
(( i = maxnumber - 1 ))
count=0
passcnt=0
while (( i >= 0 )); do
pass=0
step=0
expect1=${acls[$i]}
expect2=""
#
# aclmode=passthrough,
# no changes will be made to the ACL other than
# generating the necessary ACL entries to represent
# the new mode of the file or directory.
#
# aclmode=discard,
# delete all ACL entries that don't represent
# the mode of the file.
#
# aclmode=groupmask,
# reduce user or group permissions. The permissions are
# reduced, such that they are no greater than the group
# permission bits, unless it is a user entry that has the
# same UID as the owner of the file or directory.
# Then, the ACL permissions are reduced so that they are
# no greater than owner permission bits.
#
case $aclmode in
passthrough)
expect1=$(translate_acl $isdir $expect1)
;;
groupmask)
if [[ $expect1 == *":allow" ]]; then
expect2=$expect1
who=${expect1%%:*}
prefix=$who
acltemp=""
reduce=0
# To determine the mask bits
# according to the entry type.
case $who in
owner@)
pos=1
;;
group@)
pos=2
;;
everyone@)
pos=3
;;
user)
acltemp=${expect1#*:}
acltemp=${acltemp%%:*}
owner=$(get_owner $node)
group=$(get_group $node)
if [[ $acltemp == $owner ]]; then
pos=1
else
pos=2
fi
prefix=$prefix:$acltemp
;;
group)
acltemp=${expect1#*:}
acltemp=${acltemp%%:*}
pos=2
prefix=$prefix:$acltemp
reduce=1
;;
esac
obits=$(get_substr $newmode $pos 1)
(( bits = obits ))
#
# permission should no greater than the group permission bits
#
if (( reduce != 0 )); then
(( bits &= $(get_substr $newmode 2 1) ))
# The ACL permissions are reduced so that they are
# no greater than owner permission bits.
(( bits_owner = $(get_substr $newmode 1 1) ))
(( bits &= bits_owner ))
fi
if (( bits < obits )) && [[ -n $acltemp ]]; then
expect2=$prefix:$(cal_bits $isdir $obits $bits_owner $expect2 1):allow
else
expect2=$prefix:$(cal_bits $isdir $obits $obits $expect2 1):allow
fi
priv=$(cal_bits $isdir $obits $bits_owner $expect2 0)
expect1=$prefix:$priv:deny
step=1
else
expect1=$(translate_acl $isdir $expect1)
fi
;;
discard)
passcnt=maxnumber
break
;;
esac
if (( pass == 0 )) ; then
# Get the first ACE to do comparison
aclcur=$(get_ACE $node $count)
aclcur=${aclcur#$count:}
if [[ -n $expect1 && $expect1 != $aclcur ]]; then
$LS -vd $node
log_fail "$i #$count " \
"ACE: $aclcur, expect to be " \
"$expect1"
fi
# Get the second ACE (if should have) to do comparison
if (( step > 0 )); then
(( count = count + step ))
aclcur=$(get_ACE $node $count)
aclcur=${aclcur#$count:}
if [[ -n $expect2 && \
$expect2 != $aclcur ]]; then
$LS -vd $node
log_fail "$i #$count " \
"ACE: $aclcur, expect to be " \
"$expect2"
fi
fi
(( count = count + 1 ))
fi
(( i = i - 1 ))
done
#
# If there's no any ACE be checked, it should be identify as
# an normal file/dir, verify it.
#
if (( passcnt == maxnumber )); then
if [[ -d $node ]]; then
compare_acls $node $odir
elif [[ -f $node ]]; then
compare_acls $node $ofile
fi
if [[ $? -ne 0 ]]; then
$LS -vd $node
log_fail "Unexpect acl: $node, $aclmode ($newmode)"
fi
fi
}
typeset -i maxnumber=0
typeset acl
typeset target
cwd=$PWD
cd $TESTDIR
for mode in "${aclmode_flag[@]}"; do
#
# Set different value of aclmode
#
log_must $ZFS set aclmode=$mode $TESTPOOL/$TESTFS
for user in root $ZFS_ACL_STAFF1; do
log_must set_cur_usr $user
log_must usr_exec $MKDIR $basedir
log_must usr_exec $MKDIR $odir
log_must usr_exec $TOUCH $ofile
log_must usr_exec $MKDIR $ndir
log_must usr_exec $TOUCH $nfile
for obj in $allnodes ; do
maxnumber=0
for preset in "${ace_file_preset[@]}"; do
for prefix in "${ace_prefix[@]}"; do
acl=$prefix:$preset
case $(( maxnumber % 2 )) in
0)
acl=$acl:deny
;;
1)
acl=$acl:allow
;;
esac
#
# Place on the target should succeed.
#
log_must usr_exec $CHMOD A+$acl $obj
acls[$maxnumber]=$acl
(( maxnumber = maxnumber + 1 ))
done
done
# Archive the file and directory
log_must $TAR cpf@ $TARFILE basedir
if [[ -d $obj ]]; then
target=$odir
elif [[ -f $obj ]]; then
target=$ofile
fi
for newmode in "${argv[@]}" ; do
log_must usr_exec $CHMOD $newmode $obj
log_must usr_exec $CHMOD $newmode $target
verify_aclmode $mode $obj $newmode
# Restore the tar archive
log_must $TAR xpf@ $TARFILE
done
done
log_must usr_exec $RM -rf $basedir $TARFILE
done
done
log_pass "Verify chmod behaviour co-op with aclmode setting passed."

View File

@ -0,0 +1,274 @@
#!/usr/local/bin/ksh93 -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# $FreeBSD$
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "@(#)zfs_acl_chmod_compact_001_pos.ksh 1.5 09/01/13 SMI"
#
. $STF_SUITE/tests/acl/acl_common.kshlib
. $STF_SUITE/tests/acl/cifs/cifs.kshlib
#################################################################################
#
# __stc_assertion_start
#
# ID: zfs_acl_chmod_compact_001_pos
#
# DESCRIPTION:
# chmod A{+|-|=} could set compact ACL correctly.
#
# STRATEGY:
# 1. Loop root and non-root user.
# 2. Get the random compact ACL string.
# 4. Separately chmod +|-|=
# 5. Check compact ACL display as expected
#
# TESTABILITY: explicit
#
# TEST_AUTOMATION_LEVEL: automated
#
# CODING_STATUS: COMPLETED (2006-08-11)
#
# __stc_assertion_end
#
################################################################################
verify_runnable "both"
test_requires ZFS_ACL
log_assert "chmod A{+|=} should set compact ACL correctly."
log_onexit cleanup
set -A a_flag owner group everyone
set -A a_access r w x p d D a A R W c C o s
set -A a_inherit_object f d
set -A a_inherit_strategy i n
set -A a_type allow deny
typeset cifs=""
if cifs_supported ; then
cifs="true"
fi
#
# Get a random item from an array.
#
# $1 the base set
#
function random_select #array_name
{
typeset arr_name=$1
typeset -i ind
eval typeset -i cnt=\${#${arr_name}[@]}
(( ind = $RANDOM % cnt ))
eval print \${${arr_name}[$ind]}
}
#
# Create a random string according to array name, the item number and
# separated tag.
#
# $1 array name where the function get the elements
# $2 the items number which you want to form the random string
# $3 the separated tag
#
function form_random_str #<array_name> <count> <sep>
{
typeset arr_name=$1
typeset -i count=${2:-1}
typeset sep=${3:-""}
typeset str=""
while (( count > 0 )); do
str="${str}$(random_select $arr_name)${sep}"
(( count -= 1 ))
done
print $str
}
#
# According to the input ACE access,ACE type, and inherit flags, return the
# expect compact ACE that could be used by chmod A0{+|=}'.
#
# $1 ACE flag which is owner, group, or everyone
# $2 ACE access generated by the element of a_access
# $3 ACE inherit_object generated by the element of a_inherit_object
# $4 ACE inherit_strategy generated by the element of a_inherit_strategy
# $5 ACE type which is allow or deny
#
function cal_ace # acl_flag acl_access \
# acl_inherit_object acl_inherit_strategy acl_type
{
typeset acl_flag=$1
typeset acl_access=$2
typeset acl_inherit_object=$3
typeset acl_inherit_strategy=$4
typeset acl_type=$5
tmp_ace=${acl_flag}@:
for element in ${a_access[@]} ; do
if [[ $acl_access == *"$element"* ]]; then
tmp_ace="${tmp_ace}${element}"
else
tmp_ace="${tmp_ace}-"
fi
done
tmp_ace=${tmp_ace}:
for element in ${a_inherit_object[@]} ; do
if [[ $acl_inherit_object == *"$element"* ]]; then
tmp_ace="${tmp_ace}${element}"
else
tmp_ace="${tmp_ace}-"
fi
done
for element in ${a_inherit_strategy[@]} ; do
if [[ $acl_inherit_strategy == *"$element"* ]]; then
tmp_ace="${tmp_ace}${element}"
else
tmp_ace="${tmp_ace}-"
fi
done
if [[ -n $cifs ]]; then
tmp_ace=${tmp_ace}---:${acl_type}
else
tmp_ace=${tmp_ace}--:${acl_type}
fi
print "${tmp_ace}"
}
#
# Check if chmod set the compact ACE correctly.
#
function check_test_result # node acl_flag acl_access \
# acl_inherit_object acl_inherit_strategy acl_type
{
typeset node=$1
typeset acl_flag=$2
typeset acl_access=$3
typeset acl_inherit_object=$4
typeset acl_inherit_strategy=$5
typeset acl_type=$6
typeset expect_ace=$(cal_ace "$acl_flag" "$acl_access" \
"$acl_inherit_object" "$acl_inherit_strategy" "$acl_type")
typeset cur_ace=$(get_ACE $node 0 "compact")
if [[ $cur_ace != $expect_ace ]]; then
log_fail "FAIL: Current map($cur_ace) != \
expected ace($expect_ace)"
fi
}
function test_chmod_map #<node>
{
typeset node=$1
typeset acl_flag acl_access acl_inherit_object acl_inherit_strategy acl_type
typeset -i cnt
if (( ${#node} == 0 )); then
log_fail "FAIL: file name or directroy name is not defined."
fi
# Get ACL flag, access & type
acl_flag=$(form_random_str a_flag)
(( cnt = ($RANDOM % ${#a_access[@]}) + 1 ))
acl_access=$(form_random_str a_access $cnt)
acl_access=${acl_access%/}
acl_type=$(form_random_str a_type 1)
acl_spec=${acl_flag}@:${acl_access}
if [[ -d $node ]]; then
# Get ACL inherit_object & inherit_strategy
(( cnt = ($RANDOM % ${#a_inherit_object[@]}) + 1 ))
acl_inherit_object=$(form_random_str a_inherit_object $cnt)
(( cnt = ($RANDOM % ${#a_inherit_strategy[@]}) + 1 ))
acl_inherit_strategy=$(form_random_str a_inherit_strategy $cnt)
acl_spec=${acl_spec}:${acl_inherit_object}${acl_inherit_strategy}
fi
acl_spec=${acl_spec}:${acl_type}
# Set the initial map and back the initial ACEs
typeset orig_ace=$TMPDIR/orig_ace.${TESTCASE_ID}
typeset cur_ace=$TMPDIR/cur_ace.${TESTCASE_ID}
for operator in "A0+" "A0="; do
log_must usr_exec eval "$LS -Vd $node > $orig_ace"
# To "A=", firstly add one ACE which can't modify map
if [[ $operator == "A0=" ]]; then
log_must $CHMOD A0+user:$ZFS_ACL_OTHER1:execute:deny \
$node
fi
log_must usr_exec $CHMOD ${operator}${acl_spec} $node
check_test_result \
"$node" "$acl_flag" "$acl_access" \
"$acl_inherit_object" "$acl_inherit_strategy" \
"$acl_type"
# Check "chmod A-"
log_must usr_exec $CHMOD A0- $node
log_must usr_exec eval "$LS -Vd $node > $cur_ace"
$DIFF $orig_ace $cur_ace
[[ $? -ne 0 ]] && \
log_fail "FAIL: 'chmod A-' failed."
done
[[ -f $orig_ace ]] && log_must usr_exec $RM -f $orig_ace
[[ -f $cur_ace ]] && log_must usr_exec $RM -f $cur_ace
}
for user in root $ZFS_ACL_STAFF1; do
set_cur_usr $user
typeset -i loop_cnt=2
while (( loop_cnt > 0 )); do
log_must usr_exec $TOUCH $testfile
test_chmod_map $testfile
log_must $RM -f $testfile
log_must usr_exec $MKDIR $testdir
test_chmod_map $testdir
log_must $RM -rf $testdir
(( loop_cnt -= 1 ))
done
done
log_pass "chmod A{+|=} set compact ACL correctly."

View File

@ -0,0 +1,321 @@
#!/usr/local/bin/ksh93 -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# $FreeBSD$
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "@(#)zfs_acl_chmod_delete_001_pos.ksh 1.6 09/01/13 SMI"
#
. $STF_SUITE/tests/acl/acl_common.kshlib
#################################################################################
#
# __stc_assertion_start
#
# ID: zfs_acl_chmod_delete_001_pos
#
# DESCRIPTION:
# Verify that the combined delete_child/delete permission for
# owner/group/everyone are correct.
#
# -------------------------------------------------------
# | Parent Dir | Target Object Permissions |
# | permissions | |
# -------------------------------------------------------
# | | ACL Allows | ACL Denies| Delete |
# | | Delete | Delete | unspecified|
# -------------------------------------------------------
# | ACL Allows | Permit | Permit | Permit |
# | DELETE_CHILD | |
# -------------------------------------------------------
# | ACL Denies | Permit | Deny | Deny |
# | DELETE_CHILD | | | |
# -------------------------------------------------------
# | ACL specifies | | | |
# | only allows | Permit | Permit | Permit |
# | write and | | | |
# | execute | | | |
# -------------------------------------------------------
# | ACL denies | | | |
# | write and | Permit | Deny | Deny |
# | execute | | | |
# -------------------------------------------------------
#
# STRATEGY:
# 1. Create file and directory in zfs filesystem
# 2. Set special ACE combination to the file and directory
# 3. Try to remove the file
# 4. Verify that combined permissions for owner/group/everyone are correct.
#
# TESTABILITY: explicit
#
# TEST_AUTOMATION_LEVEL: automated
#
# CODING_STATUS: COMPLETED (2005-10-24)
#
# __stc_assertion_end
#
################################################################################
verify_runnable "both"
function cleanup
{
[[ ! -e $TESTDIR/$ARCHIVEFILE ]] && return 0
if [[ ! -e $target ]]; then
log_must $TAR xpf $TESTDIR/$ARCHIVEFILE
fi
(( ${#cwd} != 0 )) && cd $cwd
cleanup_test_files $TESTDIR/basedir
log_must $RM -f $TESTDIR/$ARCHIVEFILE
return 0
}
#owner@ group group_users other_users
set -A users \
"root" "root" "$ZFS_ACL_ADMIN" "$ZFS_ACL_OTHER1" \
"$ZFS_ACL_STAFF1" "$ZFS_ACL_STAFF_GROUP" "$ZFS_ACL_STAFF2" "$ZFS_ACL_OTHER1"
set -A access_parent \
"delete_child:allow" \
"delete_child:deny" \
"write_data:allow" \
"write_data:deny" \
"delete_child:deny write_data:allow" \
"delete_child:allow write_data:deny"
set -A access_target \
"delete:allow" \
"delete:deny" \
""
set -A a_flag "owner@" "group@" "everyone@" "user:$ZFS_ACL_STAFF1"
log_assert "Verify that the combined delete_child/delete permission for" \
"owner/group/everyone are correct."
log_onexit cleanup
function operate_node #user node
{
typeset user=$1
typeset node=$2
typeset ret
if [[ $user == "" || $node == "" ]]; then
log_fail "user, node are not defined."
fi
if [[ -d $node ]]; then
chgusr_exec $user $RM -rf $node ; ret=$?
else
chgusr_exec $user $RM -f $node ; ret=$?
fi
if [[ -e $node ]]; then
if [[ $ret -eq 0 ]]; then
log_note "$node not removed, but return code is 0."
return 1
fi
else
log_must $TAR xpf $TESTDIR/$ARCHIVEFILE
if [[ $ret -ne 0 ]]; then
log_note "$node removed, but return code is $ret."
return 1
fi
fi
return $ret
}
function logname #acl_parent acl_target user
{
typeset acl_parent=$1
typeset acl_target=$2
typeset user=$3
# To super user, read and write deny permission was override.
if [[ $user == root || $acl_target == *:allow ]]; then
print "log_must"
elif [[ $acl_parent == *"delete_child"* ]]; then
if [[ $acl_parent == *"delete_child:allow"* ]]; then
print "log_must"
else
print "log_mustnot"
fi
elif [[ $acl_parent == *"write_data"* ]]; then
if [[ $acl_parent == *"write_data:allow"* ]]; then
print "log_must"
else
print "log_mustnot"
fi
else
print "log_mustnot"
fi
}
function check_chmod_results #node flag acl_parent acl_target g_usr o_usr
{
typeset node=$1
typeset flag=$2
typeset acl_parent=$3
typeset acl_target=$2:$4
typeset g_usr=$5
typeset o_usr=$6
typeset log acl_tmp
for acl in $acl_parent ; do
acl_tmp="$2:$acl $acl_tmp"
done
acl_parent=$acl_tmp
if [[ $flag == "owner@" || $flag == "everyone@" ]]; then
log=$(logname "$acl_parent" $acl_target $ZFS_ACL_CUR_USER)
$log operate_node $ZFS_ACL_CUR_USER $node
fi
if [[ $flag == "group@" || $flag == "everyone@" ]]; then
log=$(logname "$acl_parent" $acl_target $g_usr)
$log operate_node $g_usr $node
fi
if [[ $flag == "everyone@" ]]; then
log=$(logname "$acl_parent" $acl_target $o_usr)
$log operate_node $o_usr $node
fi
if [[ $flag == "user:"* ]]; then
typeset user=${flag#user:}
log=$(logname "$acl_parent" $acl_target $user)
$log operate_node $user $node
fi
}
function test_chmod_basic_access #node g_usr o_usr
{
typeset node=${1%/}
typeset g_usr=$2
typeset o_usr=$3
typeset flag acl_p acl_t parent
typeset -i i=0
parent=${node%/*}
for flag in ${a_flag[@]}; do
for acl_p in "${access_parent[@]}"; do
i=0
for acl in $acl_p ; do
log_must usr_exec $CHMOD A+$flag:$acl $parent
(( i = i + 1))
done
for acl_t in "${access_target[@]}"; do
[[ -n $acl_t ]] && \
log_must usr_exec $CHMOD A+$flag:$acl_t $node
log_must $TAR cpf $TESTDIR/$ARCHIVEFILE basedir
check_chmod_results "$node" "$flag" \
"$acl_p" "$acl_t" "$g_usr" "$o_usr"
[[ -n $acl_t ]] && \
log_must usr_exec $CHMOD A0- $node
done
while (( i > 0 )); do
log_must usr_exec $CHMOD A0- $parent
(( i = i - 1 ))
done
done
done
}
function setup_test_files #base_node user group
{
typeset base_node=$1
typeset user=$2
typeset group=$3
cleanup_test_files $base_node
log_must $MKDIR -p $base_node
log_must $CHOWN $user:$group $base_node
log_must set_cur_usr $user
# Prepare all files/sub-dirs for testing.
file0=$base_node/testfile_rm
dir0=$base_node/testdir_rm
log_must usr_exec $TOUCH $file0
log_must usr_exec $CHMOD 444 $file0
log_must usr_exec $MKDIR -p $dir0
log_must usr_exec $CHMOD 444 $dir0
log_must usr_exec $CHMOD 555 $base_node
return 0
}
function cleanup_test_files #base_node
{
typeset base_node=$1
if [[ -d $base_node ]]; then
log_must $RM -rf $base_node
elif [[ -e $base_node ]]; then
log_must $RM -f $base_node
fi
return 0
}
typeset cwd=$PWD
typeset ARCHIVEFILE=archive.tar
test_requires ZFS_ACL
typeset -i i=0
typeset -i j=0
typeset target
cd $TESTDIR
while (( i < ${#users[@]} )); do
setup_test_files $TESTDIR/basedir ${users[i]} ${users[((i+1))]}
j=0
while (( j < 1 )); do
eval target=\$file$j
test_chmod_basic_access $target \
"${users[((i+2))]}" "${users[((i+3))]}"
eval target=\$dir$j
test_chmod_basic_access $target \
"${users[((i+2))]}" "${users[((i+3))]}"
(( j = j + 1 ))
done
(( i += 4 ))
done
log_pass "Verify that the combined delete_child/delete permission for" \
"owner/group/everyone are correct."

View File

@ -0,0 +1,193 @@
#!/usr/local/bin/ksh93 -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# $FreeBSD$
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "@(#)zfs_acl_chmod_inherit_001_pos.ksh 1.5 09/05/19 SMI"
#
. $STF_SUITE/tests/acl/acl_common.kshlib
#################################################################################
#
# __stc_assertion_start
#
# ID: zfs_acl_chmod_inherit_001_pos
#
# DESCRIPTION:
# Verify chmod have correct behaviour to directory and file when setting
# different inherit strategy to them.
#
# STRATEGY:
# 1. Loop super user and non-super user to run the test case.
# 2. Create basedir and a set of subdirectores and files within it.
# 3. Separately chmod basedir with different inherite options.
# 4. Then create nested directories and files like the following.
#
# _ odir4
# |_ ofile4
# _ odir3 _|
# |_ ofile3
# _ odir1 _|
# |_ ofile2
# basefile |
# chmod --> basedir -|
# |_ nfile1
# |_ ndir1 _
# |_ nfile2
# |_ ndir2 _
# |_ nfile3
# |_ ndir3
#
# 5. Verify each directories and files have the correct access control
# capability.
#
# TESTABILITY: explicit
#
# TEST_AUTOMATION_LEVEL: automated
#
# CODING_STATUS: COMPLETED (2005-11-15)
#
# __stc_assertion_end
#
################################################################################
verify_runnable "both"
function cleanup
{
if [[ -f $basefile ]]; then
log_must $RM -f $basefile
fi
if [[ -d $basedir ]]; then
log_must $RM -rf $basedir
fi
}
log_assert "Verify chmod have correct behaviour to directory and file when " \
"setting different inherit strategies to them."
log_onexit cleanup
# Define inherit flag
set -A object_flag file_inherit dir_inherit file_inherit/dir_inherit
set -A strategy_flag "" inherit_only no_propagate inherit_only/no_propagate
# Defile the based directory and file
basedir=$TESTDIR/basedir; basefile=$TESTDIR/basefile
test_requires ZFS_ACL
# Define the existed files and directories before chmod
odir1=$basedir/odir1; odir2=$odir1/odir2; odir3=$odir2/odir3
ofile1=$basedir/ofile1; ofile2=$odir1/ofile2; ofile3=$odir2/ofile3
# Define the files and directories will be created after chmod
ndir1=$basedir/ndir1; ndir2=$ndir1/ndir2; ndir3=$ndir2/ndir3
nfile1=$basedir/nfile1; nfile2=$ndir1/nfile2; nfile3=$ndir2/nfile3
# Verify all the node have expected correct access control
allnodes="$basedir $ndir1 $ndir2 $ndir3 $nfile1 $nfile2 $nfile3"
allnodes="$allnodes $odir1 $odir2 $odir3 $ofile1 $ofile2 $ofile3"
#
# According to inherited flag, verify subdirectories and files within it has
# correct inherited access control.
#
function verify_inherit #<object> [strategy]
{
# Define the nodes which will be affected by inherit.
typeset inherit_nodes
typeset obj=$1
typeset str=$2
log_must usr_exec $MKDIR -p $ndir3
log_must usr_exec $TOUCH $nfile1 $nfile2 $nfile3
# Except for inherit_only, the basedir was affected always.
if [[ $str != *"inherit_only"* ]]; then
inherit_nodes="$inherit_nodes $basedir"
fi
# Get the files which inherited ACE.
if [[ $obj == *"file_inherit"* ]]; then
inherit_nodes="$inherit_nodes $nfile1"
if [[ $str != *"no_propagate"* ]]; then
inherit_nodes="$inherit_nodes $nfile2 $nfile3"
fi
fi
# Get the directores which inherited ACE.
if [[ $obj == *"dir_inherit"* ]]; then
inherit_nodes="$inherit_nodes $ndir1"
if [[ $str != *"no_propagate"* ]]; then
inherit_nodes="$inherit_nodes $ndir2 $ndir3"
fi
fi
for node in $allnodes; do
if [[ " $inherit_nodes " == *" $node "* ]]; then
log_mustnot chgusr_exec $ZFS_ACL_OTHER1 $LS -vd $node \
> /dev/null 2>&1
else
log_must chgusr_exec $ZFS_ACL_OTHER1 $LS -vd $node \
> /dev/null 2>&1
fi
done
}
for user in root $ZFS_ACL_STAFF1; do
log_must set_cur_usr $user
for obj in "${object_flag[@]}"; do
for str in "${strategy_flag[@]}"; do
typeset inh_opt=$obj
(( ${#str} != 0 )) && inh_opt=$inh_opt/$str
aclspec="A+user:$ZFS_ACL_OTHER1:read_acl:$inh_opt:deny"
log_must usr_exec $MKDIR $basedir
log_must usr_exec $TOUCH $basefile
log_must usr_exec $MKDIR -p $odir3
log_must usr_exec $TOUCH $ofile1 $ofile2 $ofile3
#
# Inherit flag can only be placed on a directory,
# otherwise it will fail.
#
log_must usr_exec $CHMOD $aclspec $basefile
#
# Place on a directory should succeed.
#
log_must usr_exec $CHMOD $aclspec $basedir
verify_inherit $obj $str
log_must usr_exec $RM -rf $basefile $basedir
done
done
done
log_pass "Verify chmod inherit behaviour passed."

View File

@ -0,0 +1,415 @@
#!/usr/local/bin/ksh93 -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# $FreeBSD$
#
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "@(#)zfs_acl_chmod_inherit_002_pos.ksh 1.3 08/02/27 SMI"
#
. $STF_SUITE/tests/acl/acl_common.kshlib
. $STF_SUITE/tests/acl/cifs/cifs.kshlib
#################################################################################
#
# __stc_assertion_start
#
# ID: zfs_acl_chmod_inherit_002_pos
#
# DESCRIPTION:
# Verify chmod have correct behaviour to directory and file when
# filesystem has the different aclinherit setting
#
# STRATEGY:
# 1. Loop super user and non-super user to run the test case.
# 2. Create basedir and a set of subdirectores and files within it.
# 3. Separately chmod basedir with different inherite options,
# combine with the variable setting of aclinherit:
# "discard", "noallow", "secure" or "passthrough".
# 4. Then create nested directories and files like the following.
#
# ofile
# odir
# chmod --> basedir -|
# |_ nfile1
# |_ ndir1 _
# |_ nfile2
# |_ ndir2 _
# |_ nfile3
# |_ ndir3
#
# 5. Verify each directories and files have the correct access control
# capability.
#
# TESTABILITY: explicit
#
# TEST_AUTOMATION_LEVEL: automated
#
# CODING_STATUS: COMPLETED (2006-03-02)
#
# __stc_assertion_end
#
################################################################################
verify_runnable "both"
function cleanup
{
typeset dir
# Cleanup basedir, compared file and dir.
if [[ -f $ofile ]]; then
log_must $RM -f $ofile
fi
for dir in $odir $basedir ; do
if [[ -d $dir ]]; then
log_must $RM -rf $dir
fi
done
}
log_assert "Verify chmod have correct behaviour to directory and file when " \
"filesystem has the different aclinherit setting."
log_onexit cleanup
# Define inherit flag
set -A aclinherit_flag discard noallow secure passthrough
set -A object_flag file_inherit dir_inherit file_inherit/dir_inherit
set -A strategy_flag "" inherit_only no_propagate inherit_only/no_propagate
typeset ace_prefix1="user:$ZFS_ACL_OTHER1"
typeset ace_prefix2="user:$ZFS_ACL_OTHER2"
typeset ace_discard ace_noallow ace_secure ace_passthrough
typeset ace_secure_new
# Defile the based directory and file
basedir=$TESTDIR/basedir; ofile=$TESTDIR/ofile; odir=$TESTDIR/odir
test_requires ZFS_ACL
# Define the files and directories will be created after chmod
ndir1=$basedir/ndir1; ndir2=$ndir1/ndir2; ndir3=$ndir2/ndir3
nfile1=$basedir/nfile1; nfile2=$ndir1/nfile2; nfile3=$ndir2/nfile3
# Verify all the node have expected correct access control
allnodes="$ndir1 $ndir2 $ndir3 $nfile1 $nfile2 $nfile3"
typeset cifs=""
if cifs_supported ; then
cifs="true"
fi
#
# According to inherited flag, verify subdirectories and files within it has
# correct inherited access control.
#
function verify_inherit #<aclinherit> <object> [strategy]
{
# Define the nodes which will be affected by inherit.
typeset inherit_nodes
typeset inherit=$1
typeset obj=$2
typeset str=$3
# count: the ACE item to fetch
# pass: to mark if the current ACE should apply to the target
# maxnumber: predefine as 4
# passcnt: counter, if it achieves to maxnumber,
# then no additional ACE should apply.
# isinherit: indicate if the current target is in the inherit list.
# step: indicate if the ACE be split during inherit.
typeset -i count=0 pass=0 passcnt=0 isinherit=0 maxnumber=4 step=0
log_must usr_exec $MKDIR -p $ndir3
log_must usr_exec $TOUCH $nfile1 $nfile2 $nfile3
# Get the files which inherited ACE.
if [[ $obj == *"file_inherit"* ]]; then
inherit_nodes="$inherit_nodes $nfile1"
if [[ $str != *"no_propagate"* ]]; then
inherit_nodes="$inherit_nodes $nfile2 $nfile3"
fi
fi
# Get the directores which inherited ACE.
if [[ $obj == *"dir_inherit"* ]]; then
inherit_nodes="$inherit_nodes $ndir1"
if [[ $str != *"no_propagate"* ]]; then
inherit_nodes="$inherit_nodes $ndir2 $ndir3"
fi
fi
for node in $allnodes; do
step=0
if [[ " $inherit_nodes " == *" $node "* ]]; then
isinherit=1
if [[ -d $node ]] ; then
step=1
fi
else
isinherit=0
fi
i=0
count=0
passcnt=0
while (( i < maxnumber )); do
pass=0
eval expect1=\$acl$i
expect2=$expect1
#
# aclinherit=passthrough,
# inherit all inheritable ACL entries without any
# modifications made to the ACL entries when they
# are inherited.
#
# aclinherit=secure,
# any inheritable ACL entries will remove
# write_acl and write_owner permissions when the ACL entry is
# inherited.
#
# aclinherit=noallow,
# only inherit inheritable ACE that specify "deny" permissions
#
# aclinherit=discard
# will not inherit any ACL entries
#
case $inherit in
passthrough)
;;
secure)
if [[ $expect1 == *":allow" ]] ; then
eval expect2=\$acls$i
fi
;;
noallow)
if [[ $expect1 == *":allow" ]] ; then
pass=1
(( passcnt = passcnt + 1 ))
fi
;;
discard)
passcnt=maxnumber
break
;;
esac
if (( pass == 0 )) ; then
acltemp=${expect2%:*}
acltemp=${acltemp%:*}
aclaction=${expect2##*:}
if [[ -n $cifs ]]; then
expect2=${acltemp}:inherited:${aclaction}
else
expect2=${acltemp}:${aclaction}
fi
acltemp=${expect1%:*}
if [[ -d $node ]]; then
if [[ $expect1 == *"no_propagate"* ]] ; then
#
# if no_propagate is set,
# then clear all inherit flags,
# only one ACE should left.
#
step=0
expect1=""
elif [[ $expect1 != *"inherit_only"* ]]; then
#
# directory should append
# "inherit_only" if not have
#
if [[ -n $cifs ]]; then
expect1=${acltemp}/inherit_only/inherited:${aclaction}
else
expect1=${acltemp}/inherit_only:${aclaction}
fi
elif [[ -n $cifs ]]; then
expect1=${acltemp}/inherited:${aclaction}
fi
#
# cleanup the first ACE if the directory
# not in inherit list
#
if (( isinherit == 0 )); then
expect1=""
fi
elif [[ -f $node ]] ; then
expect1=""
fi
# Get the first ACE to do comparison
aclcur=$(get_ACE $node $count)
aclcur=${aclcur#$count:}
if [[ -n $expect1 && $expect1 != $aclcur ]]; then
$LS -vd $basedir
$LS -vd $node
log_fail "$inherit $i #$count " \
"ACE: $aclcur, expect to be " \
"$expect1"
fi
# Get the second ACE (if should have) to do comparison
if (( step > 0 )); then
(( count = count + step ))
aclcur=$(get_ACE $node $count)
aclcur=${aclcur#$count:}
if [[ -n $expect2 && \
$expect2 != $aclcur ]]; then
$LS -vd $basedir
$LS -vd $node
log_fail "$inherit $i #$count " \
"ACE: $aclcur, expect to be " \
"$expect2"
fi
fi
(( count = count + 1 ))
fi
(( i = i + 1 ))
done
#
# If there's no any ACE be checked, it should be identify as
# an normal file/dir, verify it.
#
if (( passcnt == maxnumber )); then
if [[ -d $node ]]; then
compare_acls $node $odir
elif [[ -f $node ]]; then
compare_acls $node $ofile
fi
if [[ $? -ne 0 ]]; then
$LS -vd $basedir
$LS -vd $node
log_fail "Unexpect acl: $node, $inherit ($str)"
fi
fi
done
}
typeset -i i=0
typeset acl0 acl1 acl2 acl3
typeset acls0 acls1 acls2 acls3
#
# Set aclmode=passthrough to make sure
# the acl will not change during chmod.
# A general testing should verify the combination of
# aclmode/aclinherit works well,
# here we just simple test them separately.
#
log_must $ZFS set aclmode=passthrough $TESTPOOL/$TESTFS
for inherit in "${aclinherit_flag[@]}"; do
#
# Set different value of aclinherit
#
log_must $ZFS set aclinherit=$inherit $TESTPOOL/$TESTFS
for user in root $ZFS_ACL_STAFF1; do
log_must set_cur_usr $user
for obj in "${object_flag[@]}"; do
for str in "${strategy_flag[@]}"; do
typeset inh_opt=$obj
(( ${#str} != 0 )) && inh_opt=$inh_opt/$str
#
# Prepare 4 ACES, which should include :
# deny -> to verify "noallow"
# write_acl/write_owner -> to verify "secure"
#
acl0="$ace_prefix1:read_xattr/write_acl/write_owner:$inh_opt:deny"
acl1="$ace_prefix2:read_xattr/write_acl/write_owner:$inh_opt:allow"
acl2="$ace_prefix1:read_xattr:$inh_opt:deny"
acl3="$ace_prefix2:read_xattr:$inh_opt:allow"
#
# The ACE filtered by write_acl/write_owner
#
acls0="$ace_prefix1:read_xattr:$inh_opt:deny"
acls1="$ace_prefix2:read_xattr:$inh_opt:allow"
acls2=$acl2
acls3=$acl3
#
# Create basedir and tmp dir/file
# for comparison.
#
log_note "$user: $CHMOD $acl $basedir"
log_must usr_exec $MKDIR $basedir
log_must usr_exec $MKDIR $odir
log_must usr_exec $TOUCH $ofile
i=3
while (( i >= 0 )); do
eval acl=\$acl$i
#
# Place on a directory should succeed.
#
log_must usr_exec $CHMOD A+$acl $basedir
(( i = i - 1 ))
done
verify_inherit $inherit $obj $str
log_must usr_exec $RM -rf $ofile $odir $basedir
done
done
done
done
log_pass "Verify chmod inherit behaviour co-op with aclinherit setting passed."

View File

@ -0,0 +1,449 @@
#!/usr/local/bin/ksh93 -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# $FreeBSD$
#
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "@(#)zfs_acl_chmod_inherit_003_pos.ksh 1.1 08/08/15 SMI"
#
. $STF_SUITE/tests/acl/acl_common.kshlib
. $STF_SUITE/tests/acl/cifs/cifs.kshlib
#################################################################################
#
# __stc_assertion_start
#
# ID: zfs_acl_chmod_inherit_003_pos
#
# DESCRIPTION:
# Verify chmod have correct behaviour to directory and file when
# filesystem has the different aclinherit setting
#
# STRATEGY:
# 1. Loop super user and non-super user to run the test case.
# 2. Create basedir and a set of subdirectores and files within it.
# 3. Separately chmod basedir with different inherite options,
# combine with the variable setting of aclinherit:
# "discard", "noallow", "secure" or "passthrough".
# 4. Then create nested directories and files like the following.
#
# ofile
# odir
# chmod --> basedir -|
# |_ nfile1
# |_ ndir1 _
# |_ nfile2
# |_ ndir2 _
# |_ nfile3
# |_ ndir3
#
# 5. Verify each directories and files have the correct access control
# capability.
#
# TESTABILITY: explicit
#
# TEST_AUTOMATION_LEVEL: automated
#
# CODING_STATUS: COMPLETED (2008-07-04)
#
# __stc_assertion_end
#
################################################################################
verify_runnable "both"
function cleanup
{
typeset dir
# Cleanup basedir, compared file and dir.
if [[ -f $ofile ]]; then
log_must $RM -f $ofile
fi
for dir in $odir $basedir ; do
if [[ -d $dir ]]; then
log_must $RM -rf $dir
fi
done
}
log_assert "Verify chmod have correct behaviour to directory and file when " \
"filesystem has the different aclinherit setting."
log_onexit cleanup
# Define inherit flag
set -A aclinherit_flag discard noallow secure passthrough
set -A object_flag "f-" "-d" "fd"
set -A strategy_flag "--" "i-" "-n" "in"
typeset ace_prefix1="owner@"
typeset ace_prefix2="group@"
typeset ace_prefix3="everyone@"
typeset ace_discard ace_noallow ace_secure ace_passthrough
typeset ace_secure_new
# Defile the based directory and file
basedir=$TESTDIR/basedir; ofile=$TESTDIR/ofile; odir=$TESTDIR/odir
test_requires ZFS_ACL
# Define the files and directories will be created after chmod
ndir1=$basedir/ndir1; ndir2=$ndir1/ndir2; ndir3=$ndir2/ndir3
nfile1=$basedir/nfile1; nfile2=$ndir1/nfile2; nfile3=$ndir2/nfile3
# Verify all the node have expected correct access control
allnodes="$ndir1 $ndir2 $ndir3 $nfile1 $nfile2 $nfile3"
typeset cifs=""
if cifs_supported ; then
cifs="true"
fi
#
# According to inherited flag, verify subdirectories and files within it has
# correct inherited access control.
#
function verify_inherit #<aclinherit> <object> [strategy]
{
# Define the nodes which will be affected by inherit.
typeset inherit_nodes
typeset inherit=$1
typeset obj=$2
typeset str=$3
# count: the ACE item to fetch
# pass: to mark if the current ACE should apply to the target
# maxnumber: predefine as 4
# passcnt: counter, if it achieves to maxnumber,
# then no additional ACE should apply.
# isinherit: indicate if the current target is in the inherit list.
# step: indicate if the ACE be split during inherit.
typeset -i count=0 pass=0 passcnt=0 isinherit=0 maxnumber=4 step=0
log_must usr_exec $MKDIR -p $ndir3
log_must usr_exec $TOUCH $nfile1 $nfile2 $nfile3
# Get the files which inherited ACE.
if [[ $(get_substr $obj 1 1) == f ]]; then
inherit_nodes="$inherit_nodes $nfile1"
if [[ $(get_substr $str 2 1) != n ]]; then
inherit_nodes="$inherit_nodes $nfile2 $nfile3"
fi
fi
# Get the directores which inherited ACE.
if [[ $(get_substr $obj 2 1) == d ]]; then
inherit_nodes="$inherit_nodes $ndir1"
if [[ $(get_substr $str 2 1) != n ]]; then
inherit_nodes="$inherit_nodes $ndir2 $ndir3"
fi
fi
for node in $allnodes; do
step=0
if [[ " $inherit_nodes " == *" $node "* ]]; then
isinherit=1
if [[ -d $node ]] ; then
step=1
fi
else
isinherit=0
fi
i=0
count=0
passcnt=0
while (( i < maxnumber )); do
pass=0
eval expect1=\$acl$i
expect2=$expect1
#
# aclinherit=passthrough,
# inherit all inheritable ACL entries without any
# modifications made to the ACL entries when they
# are inherited.
#
# aclinherit=secure,
# any inheritable ACL entries will remove
# write_acl and write_owner permissions when the ACL entry is
# inherited.
#
# aclinherit=noallow,
# only inherit inheritable ACE that specify "deny" permissions
#
# aclinherit=discard
# will not inherit any ACL entries
#
case $inherit in
passthrough)
if [[ -z $cifs ]]; then
break
fi
action=${expect1##*:}
expect1=${expect1%:$action}
expect1=${expect1%-}
expect1=${expect1%I}
expect1=${expect1}I:$action
;;
secure)
eval expect2=\$acls$i
;;
noallow)
if [[ $expect1 == *":allow" ]] ; then
pass=1
(( passcnt = passcnt + 1 ))
else
eval expect2=\$acls$i
fi
;;
discard)
passcnt=maxnumber
break
;;
esac
if (( pass == 0 )) ; then
acltemp=${expect2%:*}
acltemp=${acltemp%:*}
aclaction=${expect2##*:}
if [[ -n $cifs ]]; then
expect2=${acltemp}:------I:${aclaction}
else
expect2=${acltemp}:------:${aclaction}
fi
acltemp=${expect1%:*}
inh=${acltemp##*:}
if [[ -d $node ]]; then
if [[ $(get_substr $inh 4 1) == n ]]; then
#
# if no_propagate is set,
# then clear all inherit flags,
# only one ACE should left.
#
step=0
expect1=""
elif [[ $(get_substr $inh 3 1) != i ]]; then
#
# directory should append
# "inherit_only" if not have
#
acltemp=${acltemp%i*}
if [[ -n $cifs ]]; then
expect1=${acltemp}i---I:${aclaction}
else
expect1=${acltemp}i---:${aclaction}
fi
elif [[ -n $cifs ]]; then
acltemp=${acltemp%-}
acltemp=${acltemp%I}
expect1=${acltemp}I:${aclaction}
fi
#
# cleanup the first ACE if the directory
# not in inherit list
#
if (( isinherit == 0 )); then
expect1=""
fi
elif [[ -f $node ]] ; then
expect1=""
fi
# Get the first ACE to do comparison
aclcur=$(get_ACE $node $count compact)
aclcur=${aclcur#$count:}
if [[ -n $expect1 && $expect1 != $aclcur ]]; then
$LS -Vd $basedir
$LS -Vd $node
log_fail "$inherit $i #$count " \
"ACE: $aclcur, expect to be " \
"$expect1"
fi
# Get the second ACE (if should have) to do comparison
if (( step > 0 )); then
(( count = count + step ))
aclcur=$(get_ACE $node $count compact)
aclcur=${aclcur#$count:}
if [[ -n $expect2 && \
$expect2 != $aclcur ]]; then
$LS -Vd $basedir
$LS -Vd $node
log_fail "$inherit $i #$count " \
"ACE: $aclcur, expect to be " \
"$expect2"
fi
fi
(( count = count + 1 ))
fi
(( i = i + 1 ))
done
#
# If there's no any ACE be checked, it should be identify as
# an normal file/dir, verify it.
#
if (( passcnt == maxnumber )); then
if [[ -d $node ]]; then
compare_acls $node $odir
elif [[ -f $node ]]; then
compare_acls $node $ofile
fi
if [[ $? -ne 0 ]]; then
$LS -Vd $basedir
$LS -Vd $node
log_fail "Unexpect acl: $node, $inherit ($str)"
fi
fi
done
}
typeset -i i=0
typeset acl0 acl1 acl2 acl3
typeset acls0 acls1 acls2 acls3
#
# Set aclmode=passthrough to make sure
# the acl will not change during chmod.
# A general testing should verify the combination of
# aclmode/aclinherit works well,
# here we just simple test them separately.
#
log_must $ZFS set aclmode=passthrough $TESTPOOL/$TESTFS
for inherit in "${aclinherit_flag[@]}"; do
#
# Set different value of aclinherit
#
log_must $ZFS set aclinherit=$inherit $TESTPOOL/$TESTFS
for user in root $ZFS_ACL_STAFF1; do
log_must set_cur_usr $user
for obj in "${object_flag[@]}"; do
for str in "${strategy_flag[@]}"; do
typeset inh_opt=$obj
(( ${#str} != 0 )) && inh_opt=${inh_opt}${str}--
if [[ -n $cifs ]]; then
inh_a=${inh_opt}-
inh_b=${inh_opt}I
else
inh_a=${inh_opt}
inh_b=${inh_opt}
fi
#
# Prepare 4 ACES, which should include :
# deny -> to verify "noallow"
# write_acl/write_owner -> to verify "secure"
#
acl0="$ace_prefix1:rwxp---A-W-Co-:${inh_a}:allow"
acl1="$ace_prefix2:rwxp---A-W-Co-:${inh_a}:deny"
acl2="$ace_prefix3:rwxp---A-W-Co-:${inh_a}:allow"
acl3="$ace_prefix1:-------A-W----:${inh_a}:deny"
acl4="$ace_prefix2:-------A-W----:${inh_a}:allow"
acl5="$ace_prefix3:-------A-W----:${inh_a}:deny"
#
# The ACE filtered by write_acl/write_owner
#
if [[ $inheri == "passthrough" ]]; then
acls0="$ace_prefix1:rwxp---A-W----:${inh_b}:allow"
acls1="$ace_prefix2:rwxp---A-W----:${inh_b}:deny"
acls2="$ace_prefix3:rwxp---A-W----:${inh_b}:allow"
acls3="$ace_prefix1:rwxp---A-W----:${inh_b}:deny"
acls4="$ace_prefix2:rwxp---A-W----:${inh_b}:allow"
acls5="$ace_prefix3:rwxp---A-W----:${inh_b}:deny"
else
acls0="$ace_prefix1:-------A-W----:${inh_b}:allow"
acls1="$ace_prefix2:-------A-W-Co-:${inh_b}:deny"
acls2="$ace_prefix3:-------A-W----:${inh_b}:allow"
acls3="$ace_prefix1:-------A-W----:${inh_b}:deny"
acls4="$ace_prefix2:-------A-W----:${inh_b}:allow"
acls5="$ace_prefix3:-------A-W----:${inh_b}:deny"
fi
#
# Create basedir and tmp dir/file
# for comparison.
#
log_note "$user: $CHMOD $acl $basedir"
log_must usr_exec $MKDIR $basedir
log_must usr_exec $MKDIR $odir
log_must usr_exec $TOUCH $ofile
i=5
while (( i >= 0 )); do
eval acl=\$acl$i
#
# Place on a directory should succeed.
#
log_must usr_exec $CHMOD A+$acl $basedir
(( i = i - 1 ))
done
verify_inherit $inherit $obj $str
log_must usr_exec $RM -rf $ofile $odir $basedir
done
done
done
done
log_pass "Verify chmod inherit behaviour co-op with aclinherit setting passed."

View File

@ -0,0 +1,162 @@
#!/usr/local/bin/ksh93 -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# $FreeBSD$
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "@(#)zfs_acl_chmod_inherit_004_pos.ksh 1.1 09/05/19 SMI"
#
. $STF_SUITE/tests/acl/acl_common.kshlib
#################################################################################
#
# __stc_assertion_start
#
# ID: zfs_acl_chmod_inherit_004_pos
#
# DESCRIPTION:
# Verify aclinherit=passthrough-x will inherit the 'x' bits while mode request.
#
# STRATEGY:
# 1. Loop super user and non-super user to run the test case.
# 2. Create basedir and a set of subdirectores and files within it.
# 3. Set aclinherit=passthrough-x
# 4. Verify only passthrough-x will inherit the 'x' bits while mode request.
#
# TESTABILITY: explicit
#
# TEST_AUTOMATION_LEVEL: automated
#
# CODING_STATUS: COMPLETED (2009-04-29)
#
# __stc_assertion_end
#
################################################################################
verify_runnable "both"
function cleanup
{
if [[ -d $basedir ]]; then
log_must $RM -rf $basedir
fi
}
$ZPOOL upgrade -v | $GREP "passthrough\-x aclinherit support" > /dev/null 2>&1
if (( $? != 0 )) ; then
log_unsupported "passthrough-x aclinherit not supported."
fi
log_assert "Verify aclinherit=passthrough-x will inherit the 'x' bits while mode request."
log_onexit cleanup
set -A aces "owner@:read_data/write_data/add_subdirectory/append_data/execute:dir_inherit/inherit_only:allow" \
"owner@:read_data/write_data/add_subdirectory/append_data/execute::allow" \
"group@:add_subdirectory/append_data/execute:dir_inherit/inherit_only:allow" \
"group@:add_subdirectory/append_data/execute::allow" \
"everyone@:add_subdirectory/append_data/execute:dir_inherit/inherit_only:allow" \
"everyone@:add_subdirectory/append_data/execute::allow" \
"owner@:read_data/write_data/add_subdirectory/append_data/execute:file_inherit/inherit_only:allow" \
"group@:read_data/add_subdirectory/append_data/execute:file_inherit/inherit_only:allow" \
"everyone@:read_data/add_subdirectory/append_data/execute:file_inherit/inherit_only:allow"
# Defile the based directory and file
basedir=$TESTDIR/basedir
test_requires ZFS_ACL
#
# According to inherited flag, verify subdirectories and files within it has
# correct inherited access control.
#
function verify_inherit # <object>
{
typeset obj=$1
# Define the files and directories will be created after chmod
ndir1=$obj/ndir1; ndir2=$ndir1/ndir2
nfile1=$ndir1/nfile1.c; nfile2=$ndir1/nfile2
log_must usr_exec $MKDIR -p $ndir1
typeset -i i=0
while (( i < ${#aces[*]} )) ; do
if (( i < 6 )) ; then
log_must usr_exec $CHMOD A$i=${aces[i]} $ndir1
else
log_must usr_exec $CHMOD A$i+${aces[i]} $ndir1
fi
(( i = i + 1 ))
done
log_must usr_exec $MKDIR -p $ndir2
log_must usr_exec $TOUCH $nfile1
$CAT > $nfile1 <<EOF
#include <stdlib.h>
#include <stdio.h>
int main()
{ return 0; }
EOF
mode=$(get_mode $ndir2)
if [[ $mode != "drwx--x--x"* ]] ; then
log_fail "Unexpect mode of $ndir2, expect: drwx--x--x, current: $mode"
fi
mode=$(get_mode $nfile1)
if [[ $mode != "-rw-r--r--"* ]] ; then
log_fail "Unexpect mode of $nfile1, expect: -rw-r--r--, current: $mode"
fi
if [[ -x /usr/sfw/bin/gcc ]] ; then
log_must /usr/sfw/bin/gcc -o $nfile2 $nfile1
mode=$(get_mode $nfile2)
if [[ $mode != "-rwxr-xr-x"* ]] ; then
log_fail "Unexpect mode of $nfile2, expect: -rwxr-xr-x, current: $mode"
fi
fi
}
#
# Set aclmode=passthrough to make sure
# the acl will not change during chmod.
# A general testing should verify the combination of
# aclmode/aclinherit works well,
# here we just simple test them separately.
#
log_must $ZFS set aclmode=passthrough $TESTPOOL/$TESTFS
log_must $ZFS set aclinherit=passthrough-x $TESTPOOL/$TESTFS
for user in root $ZFS_ACL_STAFF1; do
log_must set_cur_usr $user
verify_inherit $basedir
cleanup
done
log_pass "Verify aclinherit=passthrough-x will inherit the 'x' bits while mode request."

View File

@ -0,0 +1,402 @@
#!/usr/local/bin/ksh93 -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# $FreeBSD$
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "@(#)zfs_acl_chmod_owner_001_pos.ksh 1.4 09/01/13 SMI"
#
. $STF_SUITE/tests/acl/acl_common.kshlib
#################################################################################
#
# __stc_assertion_start
#
# ID: zfs_acl_chmod_owner_001_pos
#
# DESCRIPTION:
# Verify that the write_owner for
# owner/group/everyone are correct.
#
# STRATEGY:
# 1. Create file and directory in zfs filesystem
# 2. Set special write_owner ACE to the file and directory
# 3. Try to chown/chgrp of the file and directory to take owner/group
# 4. Verify that the owner/group are correct. Follow these rules:
# (1) If uid is granted the write_owner permission,
# then it can only do chown to its own uid,
# or a group that they are a member of.
# (2) Owner will ignore permission of (1) even write_owner not granted.
# (3) Superuser will always permit whatever they do.
#
# TESTABILITY: explicit
#
# TEST_AUTOMATION_LEVEL: automated
#
# CODING_STATUS: COMPLETED (2005-10-26)
#
# __stc_assertion_end
#
################################################################################
verify_runnable "both"
function cleanup
{
[[ ! -e $TESTDIR/$ARCHIVEFILE ]] && return 0
if [[ ! -e $target ]]; then
log_must $TAR xpf $TESTDIR/$ARCHIVEFILE
fi
(( ${#cwd} != 0 )) && cd $cwd
cleanup_test_files $TESTDIR/basedir
log_must $RM -f $TESTDIR/$ARCHIVEFILE
return 0
}
#owner@ group group_users other_users
set -A users \
"root" "root" "$ZFS_ACL_ADMIN" "$ZFS_ACL_OTHER1" \
"$ZFS_ACL_STAFF1" "$ZFS_ACL_STAFF_GROUP" "$ZFS_ACL_STAFF2" "$ZFS_ACL_OTHER1"
set -A a_access \
"write_owner:allow" \
"write_owner:deny"
set -A a_flag "owner@" "group@" "everyone@"
log_assert "Verify that the chown/chgrp could take owner/group " \
"while permission is granted."
log_onexit cleanup
#
# Get the owner of a file/directory
#
function get_owner #node
{
typeset node=$1
typeset value
if [[ -z $node ]]; then
log_fail "node are not defined."
fi
if [[ -d $node ]]; then
value=$($LS -dl $node | $AWK '{print $3}')
elif [[ -e $node ]]; then
value=$($LS -l $node | $AWK '{print $3}')
fi
$ECHO $value
}
#
# Get the group of a file/directory
#
function get_group #node
{
typeset node=$1
typeset value
if [[ -z $node ]]; then
log_fail "node are not defined."
fi
if [[ -d $node ]]; then
value=$($LS -dl $node | $AWK '{print $4}')
elif [[ -e $node ]]; then
value=$($LS -l $node | $AWK '{print $4}')
fi
$ECHO $value
}
#
# Get the group name that a UID belongs to
#
function get_user_group #uid
{
typeset uid=$1
typeset value
if [[ -z $uid ]]; then
log_fail "UID not defined."
fi
value=$(id $uid)
if [[ $? -eq 0 ]]; then
value=${value##*\(}
value=${value%%\)*}
$ECHO $value
else
log_fail "Invalid UID (uid)."
fi
}
function operate_node_owner #user node old_owner expect_owner
{
typeset user=$1
typeset node=$2
typeset old_owner=$3
typeset expect_owner=$4
typeset ret new_owner
if [[ $user == "" || $node == "" ]]; then
log_fail "user, node are not defined."
fi
chgusr_exec $user $CHOWN $expect_owner $node ; ret=$?
new_owner=$(get_owner $node)
if [[ $new_owner != $old_owner ]]; then
$TAR xpf $TESTDIR/$ARCHIVEFILE
fi
if [[ $ret -eq 0 ]]; then
if [[ $new_owner != $expect_owner ]]; then
log_note "Owner not changed as expected " \
"($old_owner|$new_owner|$expect_owner), " \
"but return code is $ret."
return 1
fi
elif [[ $ret -ne 0 && $new_owner != $old_owner ]]; then
log_note "Owner changed ($old_owner|$new_owner), " \
"but return code is $ret."
return 2
fi
return $ret
}
function operate_node_group #user node old_group expect_group
{
typeset user=$1
typeset node=$2
typeset old_group=$3
typeset expect_group=$4
typeset ret new_group
if [[ $user == "" || $node == "" ]]; then
log_fail "user, node are not defined."
fi
chgusr_exec $user $CHGRP $expect_group $node ; ret=$?
new_group=$(get_group $node)
if [[ $new_group != $old_group ]]; then
$TAR xpf $TESTDIR/$ARCHIVEFILE
fi
if [[ $ret -eq 0 ]]; then
if [[ $new_group != $expect_group ]]; then
log_note "Group not changed as expected " \
"($old_group|$new_group|$expect_group), " \
"but return code is $ret."
return 1
fi
elif [[ $ret -ne 0 && $new_group != $old_group ]]; then
log_note "Group changed ($old_group|$new_group), " \
"but return code is $ret."
return 2
fi
return $ret
}
function logname #acl_target user old new
{
typeset acl_target=$1
typeset user=$2
typeset old=$3
typeset new=$4
typeset ret="log_mustnot"
# To super user, read and write deny permission was override.
if [[ $user == root ]]; then
ret="log_must"
elif [[ $user == $new ]] ; then
if [[ $user == $old || $acl_target == *:allow ]]; then
ret="log_must"
fi
fi
print $ret
}
function check_chmod_results #node flag acl_target g_usr o_usr
{
typeset node=$1
typeset flag=$2
typeset acl_target=$2:$3
typeset g_usr=$4
typeset o_usr=$5
typeset log old_owner old_group new_owner new_group
old_owner=$(get_owner $node)
old_group=$(get_group $node)
if [[ $flag == "owner@" || $flag == "everyone@" ]]; then
for new_owner in $ZFS_ACL_CUR_USER "nobody"; do
new_group=$(get_user_group $new_owner)
log=$(logname $acl_target $ZFS_ACL_CUR_USER \
$old_owner $new_owner)
$log operate_node_owner $ZFS_ACL_CUR_USER $node \
$old_owner $new_owner
$log operate_node_group $ZFS_ACL_CUR_USER $node \
$old_group $new_group
done
fi
if [[ $flag == "group@" || $flag == "everyone@" ]]; then
for new_owner in $g_usr "nobody"; do
new_group=$(get_user_group $new_owner)
log=$(logname $acl_target $g_usr $old_owner \
$new_owner)
$log operate_node_owner $g_usr $node \
$old_owner $new_owner
$log operate_node_group $g_usr \
$node $old_group $new_group
done
fi
if [[ $flag == "everyone@" ]]; then
for new_owner in $g_usr "nobody"; do
new_group=$(get_user_group $new_owner)
log=$(logname $acl_target $o_usr $old_owner \
$new_owner)
$log operate_node_owner $o_usr $node \
$old_owner $new_owner
$log operate_node_group $o_usr $node \
$old_group $new_group
done
fi
}
function test_chmod_basic_access #node g_usr o_usr
{
typeset node=${1%/}
typeset g_usr=$2
typeset o_usr=$3
typeset flag acl_p acl_t parent
parent=${node%/*}
for flag in ${a_flag[@]}; do
for acl_t in "${a_access[@]}"; do
log_must usr_exec $CHMOD A+$flag:$acl_t $node
$TAR cpf $TESTDIR/$ARCHIVEFILE basedir
check_chmod_results "$node" "$flag" \
"$acl_t" "$g_usr" "$o_usr"
log_must usr_exec $CHMOD A0- $node
done
done
}
function setup_test_files #base_node user group
{
typeset base_node=$1
typeset user=$2
typeset group=$3
cleanup_test_files $base_node
log_must $MKDIR -p $base_node
log_must $CHOWN $user:$group $base_node
log_must set_cur_usr $user
# Prepare all files/sub-dirs for testing.
file0=$base_node/testfile_rm
dir0=$base_node/testdir_rm
log_must usr_exec $TOUCH $file0
log_must usr_exec $CHMOD 444 $file0
log_must usr_exec $MKDIR -p $dir0
log_must usr_exec $CHMOD 444 $dir0
log_must usr_exec $CHMOD 555 $base_node
return 0
}
function cleanup_test_files #base_node
{
typeset base_node=$1
if [[ -d $base_node ]]; then
log_must $RM -rf $base_node
elif [[ -e $base_node ]]; then
log_must $RM -f $base_node
fi
return 0
}
typeset cwd=$PWD
typeset ARCHIVEFILE=archive.tar
test_requires ZFS_ACL
typeset -i i=0
typeset -i j=0
typeset target
cd $TESTDIR
while (( i < ${#users[@]} )); do
setup_test_files $TESTDIR/basedir ${users[i]} ${users[((i+1))]}
j=0
while (( j < 1 )); do
eval target=\$file$j
test_chmod_basic_access $target \
"${users[((i+2))]}" "${users[((i+3))]}"
eval target=\$dir$j
test_chmod_basic_access $target \
"${users[((i+2))]}" "${users[((i+3))]}"
(( j = j + 1 ))
done
(( i += 4 ))
done
log_pass "Verify that the chown/chgrp could take owner/group " \
"while permission is granted."

View File

@ -0,0 +1,262 @@
#!/usr/local/bin/ksh93 -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# $FreeBSD$
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "@(#)zfs_acl_chmod_rwacl_001_pos.ksh 1.5 09/05/19 SMI"
#
. $STF_SUITE/tests/acl/acl_common.kshlib
#################################################################################
#
# __stc_assertion_start
#
# ID: zfs_acl_chmod_rwacl_001_pos
#
# DESCRIPTION:
# Verify assigned read_acl/write_acl to owner@/group@/everyone@,
# specificied user and group. File have the correct access permission.
#
# STRATEGY:
# 1. Separatedly verify file and directory was assigned read_acl/write_acl
# by root and non-root user.
# 2. Verify owner always can read and write acl, even deny.
# 3. Verify group access permission, when group was assigned
# read_acl/write_acl.
# 4. Verify access permission, after everyone was assigned read_acl/write.
# 5. Verify everyone@ was deny except specificied user, this user can read
# and write acl.
# 6. Verify the group was deny except specified user, this user can read
# and write acl
#
# TESTABILITY: explicit
#
# TEST_AUTOMATION_LEVEL: automated
#
# CODING_STATUS: COMPLETED (2005-10-19)
#
# __stc_assertion_end
#
################################################################################
verify_runnable "both"
log_assert "Verify chmod A[number]{+|-|=} read_acl/write_acl have correct " \
"behaviour to access permission."
log_onexit cleanup
function read_ACL #<node> <user1> <user2> ...
{
typeset node=$1
typeset user
typeset -i ret
shift
for user in $@; do
chgusr_exec $user $LS -vd $node > /dev/null 2>&1
ret=$?
(( ret != 0 )) && return $ret
shift
done
return 0
}
function write_ACL #<node> <user1> <user2> ...
{
typeset node=$1
typeset user
typeset -i ret before_cnt after_cnt
shift
for user in "$@"; do
before_cnt=$(count_ACE $node)
ret=$?;
(( ret != 0 )) && return $ret
chgusr_exec $user $CHMOD A0+owner@:read_data:allow $node
ret=$?
(( ret != 0 )) && return $ret
after_cnt=$(count_ACE $node)
ret=$?
(( ret != 0 )) && return $ret
chgusr_exec $user $CHMOD A0- $node
ret=$?
(( ret != 0 )) && return $ret
if (( after_cnt - before_cnt != 1 )); then
return 1
fi
shift
done
return 0
}
function check_owner #<node>
{
typeset node=$1
for acc in allow deny; do
log_must usr_exec \
$CHMOD A0+owner@:read_acl/write_acl:$acc $node
log_must read_ACL $node $ZFS_ACL_CUR_USER
log_must write_ACL $node $ZFS_ACL_CUR_USER
log_must usr_exec $CHMOD A0- $node
done
}
function check_group #<node>
{
typeset node=$1
typeset grp_usr=""
if [[ $ZFS_ACL_CUR_USER == root ]]; then
grp_usr=$ZFS_ACL_ADMIN
elif [[ $ZFS_ACL_CUR_USER == $ZFS_ACL_STAFF1 ]]; then
grp_usr=$ZFS_ACL_STAFF2
fi
log_must usr_exec $CHMOD A0+group@:read_acl/write_acl:allow $node
log_must read_ACL $node $grp_usr
log_must write_ACL $node $grp_usr
log_must usr_exec $CHMOD A0- $node
log_must usr_exec $CHMOD A0+group@:read_acl/write_acl:deny $node
log_mustnot read_ACL $node $grp_usr
log_mustnot write_ACL $node $grp_usr
log_must usr_exec $CHMOD A0- $node
}
function check_everyone #<node>
{
typeset node=$1
typeset flag
for flag in allow deny; do
if [[ $flag == allow ]]; then
log=log_must
else
log=log_mustnot
fi
log_must usr_exec \
$CHMOD A0+everyone@:read_acl/write_acl:$flag $node
$log read_ACL $node $ZFS_ACL_OTHER1 $ZFS_ACL_OTHER2
$log write_ACL $node $ZFS_ACL_OTHER1 $ZFS_ACL_OTHER2
log_must usr_exec $CHMOD A0- $node
done
}
function check_spec_user #<node>
{
typeset node=$1
log_must usr_exec $CHMOD A0+everyone@:read_acl/write_acl:deny $node
log_must usr_exec \
$CHMOD A0+user:$ZFS_ACL_OTHER1:read_acl/write_acl:allow $node
# The specified user can read and write acl
log_must read_ACL $node $ZFS_ACL_OTHER1
log_must write_ACL $node $ZFS_ACL_OTHER1
# All the other user can't read and write acl
log_mustnot \
read_ACL $node $ZFS_ACL_ADMIN $ZFS_ACL_STAFF2 $ZFS_ACL_OTHER2
log_mustnot \
write_ACL $node $ZFS_ACL_ADMIN $ZFS_ACL_STAFF2 $ZFS_ACL_OTHER2
log_must usr_exec $CHMOD A0- $node
log_must usr_exec $CHMOD A0- $node
}
function check_spec_group #<node>
{
typeset node=$1
log_must usr_exec $CHMOD A0+everyone@:read_acl/write_acl:deny $node
log_must usr_exec $CHMOD \
A0+group:$ZFS_ACL_OTHER_GROUP:read_acl/write_acl:allow $node
# The specified group can read and write acl
log_must read_ACL $node $ZFS_ACL_OTHER1 $ZFS_ACL_OTHER2
log_must write_ACL $node $ZFS_ACL_OTHER1 $ZFS_ACL_OTHER2
# All the other user can't read and write acl
log_mustnot read_ACL $node $ZFS_ACL_ADMIN $ZFS_ACL_STAFF2
log_mustnot write_ACL $node $ZFS_ACL_ADMIN $ZFS_ACL_STAFF2
}
function check_user_in_group #<node>
{
typeset node=$1
log_must usr_exec $CHMOD \
A0+group:$ZFS_ACL_OTHER_GROUP:read_acl/write_acl:deny $node
log_must usr_exec $CHMOD \
A0+user:$ZFS_ACL_OTHER1:read_acl/write_acl:allow $node
log_must read_ACL $node $ZFS_ACL_OTHER1
log_must write_ACL $node $ZFS_ACL_OTHER1
log_mustnot read_ACL $node $ZFS_ACL_OTHER2
log_mustnot write_ACL $node $ZFS_ACL_OTHER2
log_must usr_exec $CHMOD A0- $node
log_must usr_exec $CHMOD A0- $node
}
set -A func_name check_owner \
check_group \
check_everyone \
check_spec_user \
check_spec_group \
check_user_in_group
test_requires ZFS_ACL
for user in root $ZFS_ACL_STAFF1; do
log_must set_cur_usr $user
log_must usr_exec $TOUCH $testfile
log_must usr_exec $MKDIR $testdir
typeset func node
for func in ${func_name[@]}; do
for node in $testfile $testdir; do
eval $func \$node
done
done
log_must usr_exec $RM -rf $testfile $testdir
done
log_pass "Verify chmod A[number]{+|-|=} read_acl/write_acl passed."

View File

@ -0,0 +1,141 @@
#!/usr/local/bin/ksh93 -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# $FreeBSD$
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "@(#)zfs_acl_chmod_rwx_001_pos.ksh 1.3 09/01/13 SMI"
#
. $STF_SUITE/tests/acl/acl_common.kshlib
#################################################################################
#
# __stc_assertion_start
#
# ID: zfs_acl_chmod_rwx_001_pos
#
# DESCRIPTION:
# chmod A{+|-|=} have the correct behaviour to the ACL list.
#
# STRATEGY:
# 1. loop check root and non-root users
# 2. chmod file or dir with specified options
# 3. get ACE after behaviours of chmod
# 4. compare specified ACE and excpect ACE
#
# TESTABILITY: explicit
#
# TEST_AUTOMATION_LEVEL: automated
#
# CODING_STATUS: COMPLETED (2005-09-30)
#
# __stc_assertion_end
#
################################################################################
verify_runnable "both"
log_assert "chmod A{+|-|=} have the correct behaviour to the ACL list."
log_onexit cleanup
typeset -i trival_count=6 head=0 mid end
((mid = RANDOM % $trival_count))
((end = trival_count - 1))
opts="+ - ="
nums="$head $mid $end"
set -A file_ACEs \
"user:$ZFS_ACL_STAFF1:read_data:allow" \
"user:$ZFS_ACL_STAFF2:write_data:allow" \
"user:$ZFS_ACL_OTHER1:execute:allow"
set -A dir_ACEs \
"user:$ZFS_ACL_STAFF1:list_directory/read_data:allow" \
"user:$ZFS_ACL_STAFF2:add_file/write_data:allow" \
"user:$ZFS_ACL_OTHER1:execute:allow"
function test_chmod_ACE_list #$opt $num $ace-spec $node
{
typeset opt=A$2$1
typeset -i num=$2
typeset ace=$3
typeset node=$4
typeset -i expect_count=0
# Get expect ACE count
case $opt in
A[0-9]*+) (( expect_count = trival_count + 1 )) ;;
A[0-9]*-) (( expect_count = trival_count - 1 )) ;;
A[0-9]*=) (( expect_count = trival_count )) ;;
*) log_fail "Error option: '$opt'" ;;
esac
# Invoke chmod A[number]{+|-|=}<acl-specification> file|dir
if [[ $opt == A[0-9]*+ || $opt == A[0-9]*= ]]; then
log_must usr_exec $CHMOD "$opt$ace" "$node"
else
log_must usr_exec $CHMOD "$opt" "$node"
fi
# Get the current ACE count and specified ACE
typeset cur_ace cur_count
cur_ace=$(get_ACE $node $num)
cur_count=$(count_ACE $node)
# Compare with expected results
if [[ $opt == A[0-9]*+ || $opt == A[0-9]*= ]]; then
if [[ "$num:$ace" != "$cur_ace" ]]; then
log_fail "FAIL: $CHMOD $opt$ace $node"
fi
fi
if [[ "$expect_count" != "$cur_count" ]]; then
log_fail "FAIL: '$expect_count' != '$cur_count'"
fi
}
test_requires ZFS_ACL
for user in root $ZFS_ACL_STAFF1 $ZFS_ACL_OTHER1; do
log_must set_cur_usr $user
for opt in $opts; do
for num in $nums; do
for ace in $file_ACEs; do
ls -l $TESTDIR
log_must usr_exec $TOUCH $testfile
test_chmod_ACE_list $opt $num $ace $testfile
log_must $RM -f $testfile
done
for ace in $dir_ACEs; do
ls -l $TESTDIR
log_must usr_exec $MKDIR -p $testdir
test_chmod_ACE_list $opt $num $ace $testdir
log_must $RM -rf $testdir
done
done
done
done
log_pass "chmod A{+|-|=} behave to the ACL list passed."

View File

@ -0,0 +1,261 @@
#!/usr/local/bin/ksh93 -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# $FreeBSD$
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "@(#)zfs_acl_chmod_rwx_002_pos.ksh 1.5 09/01/13 SMI"
#
. $STF_SUITE/tests/acl/acl_common.kshlib
#################################################################################
#
# __stc_assertion_start
#
# ID: zfs_acl_chmod_rwx_002_pos
#
# DESCRIPTION:
# chmod A{+|-|=} read_data|write_data|execute for owner@ group@ or everyone@
# correctly alters mode bits .
#
# STRATEGY:
# 1. Loop root and non-root user.
# 2. Get the random initial map.
# 3. Get the random ACL string.
# 4. Separately chmod +|-|= read_data|write_data|execute
# 5. Check map bits
#
# TESTABILITY: explicit
#
# TEST_AUTOMATION_LEVEL: automated
#
# CODING_STATUS: COMPLETED (2005-10-05)
#
# __stc_assertion_end
#
################################################################################
verify_runnable "both"
log_assert "chmod A{+|-|=} read_data|write_data|execute for owner@, group@ " \
"or everyone@ correctly alters mode bits."
log_onexit cleanup
set -A bits 0 1 2 3 4 5 6 7
set -A a_flag owner group everyone
set -A a_access read_data write_data execute
set -A a_type allow deny
#
# Get a random item from an array.
#
# $1 the base set
#
function random_select #array_name
{
typeset arr_name=$1
typeset -i ind
eval typeset -i cnt=\${#${arr_name}[@]}
(( ind = $RANDOM % cnt ))
eval print \${${arr_name}[$ind]}
}
#
# Create a random string according to array name, the item number and
# separated tag.
#
# $1 array name where the function get the elements
# $2 the items number which you want to form the random string
# $3 the separated tag
#
function form_random_str #<array_name> <count> <sep>
{
typeset arr_name=$1
typeset -i count=${2:-1}
typeset sep=${3:-""}
typeset str=""
while (( count > 0 )); do
str="${str}$(random_select $arr_name)${sep}"
(( count -= 1 ))
done
print $str
}
#
# According to the original bits, the input ACE access and ACE type, return the
# expect bits after 'chmod A0{+|=}'.
#
# $1 bits which was make up of three bit 'rwx'
# $2 ACE access which is read_data, write_data or execute
# $3 ACE type which is allow or deny
#
function cal_bits #bits acl_access acl_type
{
typeset bits=$1
typeset acl_access=$2
typeset acl_type=$3
set -A bit r w x
typeset tmpbits=""
typeset -i i=0 j
while (( i < 3 )); do
if [[ $acl_access == *"${a_access[i]}"* ]]; then
if [[ $acl_type == "allow" ]]; then
tmpbits="$tmpbits${bit[i]}"
elif [[ $acl_type == "deny" ]]; then
tmpbits="${tmpbits}-"
fi
else
(( j = i + 1 ))
tmpbits="$tmpbits$(get_substr $bits $j 1)"
fi
(( i += 1 ))
done
print "$tmpbits"
}
#
# Based on the initial node map before chmod and the ace-spec, check if chmod
# has the correct behaven to map bits.
#
function check_test_result #init_mode node acl_flag acl_access a_type
{
typeset init_mode=$1
typeset node=$2
typeset acl_flag=$3
typeset acl_access=$4
typeset acl_type=$5
typeset -3L u_bits=$init_mode
typeset g_bits=$(get_substr $init_mode 4 3)
typeset -3R o_bits=$init_mode
if [[ $acl_flag == "owner" || $acl_flag == "everyone" ]]; then
u_bits=$(cal_bits $u_bits $acl_access $acl_type)
fi
if [[ $acl_flag == "group" || $acl_flag == "everyone" ]]; then
g_bits=$(cal_bits $g_bits $acl_access $acl_type)
fi
if [[ $acl_flag == "everyone" ]]; then
o_bits=$(cal_bits $o_bits $acl_access $acl_type)
fi
typeset cur_mode=$(get_mode $node)
cur_mode=$(get_substr $cur_mode 2 9)
if [[ $cur_mode == $u_bits$g_bits$o_bits ]]; then
log_note "SUCCESS: Current map($cur_mode) ==" \
"expected map($u_bits$g_bits$o_bits)"
else
log_fail "FAIL: Current map($cur_mode) != " \
"expected map($u_bits$g_bits$o_bits)"
fi
}
function test_chmod_map #<node>
{
typeset node=$1
typeset init_mask acl_flag acl_access acl_type
typeset -i cnt
if (( ${#node} == 0 )); then
log_fail "FAIL: file name or directroy name is not defined."
fi
# Get the initial map
init_mask=$(form_random_str bits 3)
# Get ACL flag, access & type
acl_flag=$(form_random_str a_flag)
(( cnt = ($RANDOM % ${#a_access[@]}) + 1 ))
acl_access=$(form_random_str a_access $cnt '/')
acl_access=${acl_access%/}
acl_type=$(form_random_str a_type)
typeset acl_spec=${acl_flag}@:${acl_access}:${acl_type}
# Set the initial map and back the initial ACEs
typeset orig_ace=$TMPDIR/orig_ace.${TESTCASE_ID}
typeset cur_ace=$TMPDIR/cur_ace.${TESTCASE_ID}
for operator in "A0+" "A0="; do
log_must usr_exec $CHMOD $init_mask $node
init_mode=$(get_mode $node)
init_mode=$(get_substr $init_mode 2 9)
log_must usr_exec eval "$LS -vd $node > $orig_ace"
# To "A=", firstly add one ACE which can't modify map
if [[ $operator == "A0=" ]]; then
log_must $CHMOD A0+user:$ZFS_ACL_OTHER1:execute:deny \
$node
fi
log_must usr_exec $CHMOD $operator$acl_spec $node
check_test_result \
$init_mode $node $acl_flag $acl_access $acl_type
# Check "chmod A-"
log_must usr_exec $CHMOD A0- $node
log_must usr_exec eval "$LS -vd $node > $cur_ace"
if $DIFF $orig_ace $cur_ace; then
log_note "SUCCESS: original ACEs equivalence the " \
"current ACEs. 'chmod A-' succeeded."
else
log_fail "FAIL: 'chmod A-' failed."
fi
done
[[ -f $orig_ace ]] && log_must usr_exec $RM -f $orig_ace
[[ -f $cur_ace ]] && log_must usr_exec $RM -f $cur_ace
}
test_requires ZFS_ACL
for user in root $ZFS_ACL_STAFF1; do
set_cur_usr $user
typeset -i loop_cnt=20
while (( loop_cnt > 0 )); do
log_must usr_exec $TOUCH $testfile
test_chmod_map $testfile
log_must $RM -f $testfile
log_must usr_exec $MKDIR $testdir
test_chmod_map $testdir
log_must $RM -rf $testdir
(( loop_cnt -= 1 ))
done
done
log_pass "chmod A{+|-|=} read_data|write_data|execute for owner@, group@ " \
"oreveryone@ correctly alters mode bits passed."

View File

@ -0,0 +1,152 @@
#!/usr/local/bin/ksh93 -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# $FreeBSD$
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "@(#)zfs_acl_chmod_rwx_003_pos.ksh 1.3 07/07/31 SMI"
#
. $STF_SUITE/tests/acl/acl_common.kshlib
#################################################################################
#
# __stc_assertion_start
#
# ID: zfs_acl_chmod_rwx_003_pos
#
# DESCRIPTION:
# Verify that the read_data/write_data/execute permission for
# owner/group/everyone are correct.
#
# STRATEGY:
# 1. Loop root and non-root user.
# 2. Separated verify type@:access:allow|deny to file and directory
# 3. To super user, read and write deny was override.
# 4. According to ACE list and override rule, expect that
# read/write/execute file or directory succeed or fail.
#
# TESTABILITY: explicit
#
# TEST_AUTOMATION_LEVEL: automated
#
# CODING_STATUS: COMPLETED (2005-10-09)
#
# __stc_assertion_end
#
################################################################################
verify_runnable "both"
# owner@ group_users other_users
set -A users \
"root" "$ZFS_ACL_ADMIN" "$ZFS_ACL_OTHER1" \
"$ZFS_ACL_STAFF1" "$ZFS_ACL_STAFF2" "$ZFS_ACL_OTHER1"
# In order to test execute permission, read_data was need firstly.
set -A a_access "read_data" "write_data" "read_data/execute"
set -A a_flag "owner@" "group@" "everyone@"
log_assert "Verify that the read_data/write_data/execute permission for" \
"owner/group/everyone are correct."
log_onexit cleanup
function logname #node acl_spec user
{
typeset node=$1
typeset acl_spec=$2
typeset user=$3
# To super user, read and write deny permission was override.
if [[ $acl_spec == *:allow ]] || \
[[ $user == root && -d $node ]] || \
[[ $user == root && $acl_spec != *"execute"* ]]
then
print "log_must"
elif [[ $acl_spec == *:deny ]]; then
print "log_mustnot"
fi
}
function check_chmod_results #node acl_spec g_usr o_usr
{
typeset node=$1
typeset acl_spec=$2
typeset g_usr=$3
typeset o_usr=$4
typeset log
if [[ $acl_spec == "owner@:"* || $acl_spec == "everyone@:"* ]]; then
log=$(logname $node $acl_spec $ZFS_ACL_CUR_USER)
$log rwx_node $ZFS_ACL_CUR_USER $node $acl_spec
fi
if [[ $acl_spec == "group@:"* || $acl_spec == "everyone@:"* ]]; then
log=$(logname $node $acl_spec $g_usr)
$log rwx_node $g_usr $node $acl_spec
fi
if [[ $acl_spec == "everyone@"* ]]; then
log=$(logname $node $acl_spec $o_usr)
$log rwx_node $o_usr $node $acl_spec
fi
}
function test_chmod_basic_access #node group_user other_user
{
typeset node=$1
typeset g_usr=$2
typeset o_usr=$3
typeset flag access acl_spec
for flag in ${a_flag[@]}; do
for access in ${a_access[@]}; do
for tp in allow deny; do
acl_spec="$flag:$access:$tp"
log_must usr_exec $CHMOD A+$acl_spec $node
check_chmod_results \
$node $acl_spec $g_usr $o_usr
log_must usr_exec $CHMOD A0- $node
done
done
done
}
test_requires ZFS_ACL
typeset -i i=0
while (( i < ${#users[@]} )); do
log_must set_cur_usr ${users[i]}
log_must usr_exec $TOUCH $testfile
test_chmod_basic_access $testfile ${users[((i+1))]} ${users[((i+2))]}
log_must usr_exec $MKDIR $testdir
test_chmod_basic_access $testdir ${users[((i+1))]} ${users[((i+2))]}
log_must usr_exec $RM -rf $testfile $testdir
(( i += 3 ))
done
log_pass "Verify that the read_data/write_data/execute permission for" \
"owner/group/everyone passed."

View File

@ -0,0 +1,155 @@
#!/usr/local/bin/ksh93 -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# $FreeBSD$
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "@(#)zfs_acl_chmod_rwx_004_pos.ksh 1.3 07/07/31 SMI"
#
. $STF_SUITE/tests/acl/acl_common.kshlib
#################################################################################
#
# __stc_assertion_start
#
# ID: zfs_acl_chmod_rwx_004_pos
#
# DESCRIPTION:
# Verify that explicit ACL setting to specified user or group will
# override existed access rule.
#
# STRATEGY:
# 1. Loop root and non-root user.
# 2. Loop the specified access one by one.
# 3. Loop verify explicit ACL set to specified user and group.
#
# TESTABILITY: explicit
#
# TEST_AUTOMATION_LEVEL: automated
#
# CODING_STATUS: COMPLETED (2005-10-14)
#
# __stc_assertion_end
#
################################################################################
verify_runnable "both"
function check_access #log user node access rflag
{
typeset log=$1
typeset user=$2
typeset node=$3
typeset access=$4
typeset rflag=$5
if [[ $rflag == "allow" && $access == execute ]]; then
rwx_node $user $node $access
#
# When everyone@ were deny, this file can't execute.
# So,'cannot execute' means user has the permission to
# execute, just the file can't be execute.
#
if [[ $ZFS_ACL_ERR_STR == *"cannot execute" ]]; then
log_note "SUCCESS: rwx_node $user $node $access"
else
log_fail "FAIL: rwx_node $user $node $access"
fi
else
$log rwx_node $user $node $access
fi
}
function verify_explicit_ACL_rule #node access flag
{
set -A a_access "read_data" "write_data" "execute"
typeset node=$1
typeset access=$2
typeset flag=$3
typeset log rlog rflag
# Get the expect log check
if [[ $flag == allow ]]; then
log=log_mustnot
rlog=log_must
rflag=deny
else
log=log_must
rlog=log_mustnot
rflag=allow
fi
log_must usr_exec $CHMOD A+everyone@:$access:$flag $node
log_must usr_exec $CHMOD A+user:$ZFS_ACL_OTHER1:$access:$rflag $node
check_access $log $ZFS_ACL_OTHER1 $node $access $rflag
log_must usr_exec $CHMOD A0- $node
log_must usr_exec \
$CHMOD A+group:$ZFS_ACL_OTHER_GROUP:$access:$rflag $node
check_access $log $ZFS_ACL_OTHER1 $node $access $rflag
check_access $log $ZFS_ACL_OTHER2 $node $access $rflag
log_must usr_exec $CHMOD A0- $node
log_must usr_exec $CHMOD A0- $node
log_must usr_exec \
$CHMOD A+group:$ZFS_ACL_OTHER_GROUP:$access:$flag $node
log_must usr_exec $CHMOD A+user:$ZFS_ACL_OTHER1:$access:$rflag $node
$log rwx_node $ZFS_ACL_OTHER1 $node $access
$rlog rwx_node $ZFS_ACL_OTHER2 $node $access
log_must usr_exec $CHMOD A0- $node
log_must usr_exec $CHMOD A0- $node
}
log_assert "Verify that explicit ACL setting to specified user or group will" \
"override existed access rule."
log_onexit cleanup
set -A a_access "read_data" "write_data" "execute"
set -A a_flag "allow" "deny"
typeset node
test_requires ZFS_ACL
for user in root $ZFS_ACL_STAFF1; do
log_must set_cur_usr $user
log_must usr_exec $TOUCH $testfile
log_must usr_exec $MKDIR $testdir
log_must usr_exec $CHMOD 755 $testfile $testdir
for node in $testfile $testdir; do
for access in ${a_access[@]}; do
for flag in ${a_flag[@]}; do
verify_explicit_ACL_rule $node $access $flag
done
done
done
log_must usr_exec $RM -rf $testfile $testdir
done
log_pass "Explicit ACL setting to specified user or group will override " \
"existed access rule passed."

View File

@ -0,0 +1,257 @@
#!/usr/local/bin/ksh93 -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# $FreeBSD$
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "@(#)zfs_acl_chmod_xattr_001_pos.ksh 1.4 09/01/13 SMI"
#
. $STF_SUITE/tests/acl/acl_common.kshlib
#################################################################################
#
# __stc_assertion_start
#
# ID: zfs_acl_chmod_xattr_001_pos
#
# DESCRIPTION:
# Verify that the read_xattr/write_xattr for
# owner/group/everyone are correct.
#
# STRATEGY:
# 1. Create file and directory in zfs filesystem
# 2. Set special read_xattr ACE to the file and directory
# 3. Try to list the extended attributes of the file and directory
# 4. Set special write_xattr ACE to the file and directory
# 5. Try to add new extended attributes to the file and directory
# 6. Verify above operation is successful.
#
# TESTABILITY: explicit
#
# TEST_AUTOMATION_LEVEL: automated
#
# CODING_STATUS: COMPLETED (2005-11-29)
#
# __stc_assertion_end
#
################################################################################
verify_runnable "both"
function cleanup
{
cd $cwd
cleanup_test_files $TESTDIR/basedir
if [[ -e $TESTDIR/$ARCHIVEFILE ]]; then
log_must $RM -f $TESTDIR/$ARCHIVEFILE
fi
return 0
}
# owner@ group group_users other_users
set -A users \
"root" "root" "$ZFS_ACL_ADMIN" "$ZFS_ACL_OTHER1" \
"$ZFS_ACL_STAFF1" "$ZFS_ACL_STAFF_GROUP" "$ZFS_ACL_STAFF2" "$ZFS_ACL_OTHER1"
set -A a_access \
"read_xattr:allow" \
"read_xattr:deny" \
"write_xattr:allow" \
"write_xattr:deny"
set -A a_flag "owner@" "group@" "everyone@"
MYTESTFILE=$STF_SUITE/include/default.cfg
log_assert "Verify that the permission of read_xattr/write_xattr for " \
"owner/group/everyone are correct."
log_onexit cleanup
function operate_node #user node acl
{
typeset user=$1
typeset node=$2
typeset acl_t=$3
typeset ret
if [[ $user == "" || $node == "" ]]; then
log_fail "user, node are not defined."
fi
if [[ $acl_t == *read_xattr* ]]; then
chgusr_exec $user $RUNAT $node $LS > /dev/null 2>&1; ret=$?
elif [[ $acl_t == *write_xattr* ]]; then
chgusr_exec $user $RUNAT $node $CP $MYTESTFILE attr.1 ; ret=$?
if [[ $ret -eq 0 ]]; then
log_must cleanup_test_files $TESTDIR/basedir
log_must $TAR xpf@ $TESTDIR/$ARCHIVEFILE
fi
fi
return $ret
}
function logname #acl_target user
{
typeset acl_target=$1
typeset user=$2
typeset ret="log_mustnot"
# To super user, read and write deny permission was override.
if [[ $user == root || $acl_target == *:allow ]] then
ret="log_must"
fi
print $ret
}
function check_chmod_results #node flag acl_target g_usr o_usr
{
typeset node=$1
typeset flag=$2
typeset acl_target=$2:$3
typeset g_usr=$4
typeset o_usr=$5
typeset log
if [[ $flag == "owner@" || $flag == "everyone@" ]]; then
log=$(logname $acl_target $ZFS_ACL_CUR_USER)
$log operate_node $ZFS_ACL_CUR_USER $node $acl_target
fi
if [[ $flag == "group@" || $flag == "everyone@" ]]; then
log=$(logname $acl_target $g_usr)
$log operate_node $g_usr $node $acl_target
fi
if [[ $flag == "everyone@" ]]; then
log=$(logname $acl_target $o_usr)
$log operate_node $o_usr $node $acl_target
fi
}
function test_chmod_basic_access #node g_usr o_usr
{
typeset node=${1%/}
typeset g_usr=$2
typeset o_usr=$3
typeset flag acl_p acl_t parent
parent=${node%/*}
for flag in ${a_flag[@]}; do
for acl_t in "${a_access[@]}"; do
log_must usr_exec $CHMOD A+$flag:$acl_t $node
log_must $TAR cpf@ $TESTDIR/$ARCHIVEFILE basedir
check_chmod_results "$node" "$flag" \
"$acl_t" "$g_usr" "$o_usr"
log_must usr_exec $CHMOD A0- $node
done
done
}
function setup_test_files #base_node user group
{
typeset base_node=$1
typeset user=$2
typeset group=$3
cleanup_test_files $base_node
log_must $MKDIR -p $base_node
log_must $CHOWN $user:$group $base_node
log_must set_cur_usr $user
# Prepare all files/sub-dirs for testing.
file0=$base_node/testfile_rm
dir0=$base_node/testdir_rm
log_must usr_exec $TOUCH $file0
log_must usr_exec $CHMOD 444 $file0
log_must usr_exec $RUNAT $file0 $CP $MYTESTFILE attr.0
log_must usr_exec $MKDIR -p $dir0
log_must usr_exec $CHMOD 555 $dir0
log_must usr_exec $RUNAT $dir0 $CP $MYTESTFILE attr.0
log_must usr_exec $CHMOD 777 $base_node
return 0
}
function cleanup_test_files #base_node
{
typeset base_node=$1
if [[ -d $base_node ]]; then
log_must $RM -rf $base_node
elif [[ -e $base_node ]]; then
log_must $RM -f $base_node
fi
return 0
}
typeset cwd=$PWD
typeset ARCHIVEFILE=archive.tar
test_requires RUNAT ZFS_ACL ZFS_XATTR
typeset -i i=0
typeset -i j=0
typeset target
while (( i < ${#users[@]} )); do
setup_test_files $TESTDIR/basedir ${users[i]} ${users[((i+1))]}
cd $TESTDIR
j=0
while (( j < 1 )); do
eval target=\$file$j
test_chmod_basic_access $target \
"${users[((i+2))]}" "${users[((i+3))]}"
eval target=\$dir$j
test_chmod_basic_access $target \
"${users[((i+2))]}" "${users[((i+3))]}"
(( j = j + 1 ))
done
(( i += 4 ))
done
log_pass "Verify that the permission of read_xattr/write_xattr for " \
"owner/group/everyone are correct."

View File

@ -0,0 +1,252 @@
#!/usr/local/bin/ksh93 -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# $FreeBSD$
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "@(#)zfs_acl_chmod_xattr_002_pos.ksh 1.4 09/01/13 SMI"
#
. $STF_SUITE/tests/acl/acl_common.kshlib
#################################################################################
#
# __stc_assertion_start
#
# ID: zfs_acl_chmod_xattr_002_pos
#
# DESCRIPTION:
# Verify that the write_xattr for remove the extended attributes of
# owner/group/everyone are correct.
#
# STRATEGY:
# 1. Create file and directory in zfs filesystem
# 2. Set special write_xattr ACE to the file and directory
# 3. Try to remove the extended attributes of the file and directory
# 4. Verify above operation is successful.
#
# TESTABILITY: explicit
#
# TEST_AUTOMATION_LEVEL: automated
#
# CODING_STATUS: COMPLETED (2005-11-29)
#
# __stc_assertion_end
#
################################################################################
verify_runnable "both"
function cleanup
{
cd $cwd
cleanup_test_files $TESTDIR/basedir
if [[ -e $TESTDIR/$ARCHIVEFILE ]]; then
log_must $RM -f $TESTDIR/$ARCHIVEFILE
fi
return 0
}
# owner@ group group_users other_users
set -A users \
"root" "root" "$ZFS_ACL_ADMIN" "$ZFS_ACL_OTHER1" \
"$ZFS_ACL_STAFF1" "$ZFS_ACL_STAFF_GROUP" "$ZFS_ACL_STAFF2" "$ZFS_ACL_OTHER1"
set -A a_access \
"write_xattr:allow" \
"write_xattr:deny"
set -A a_flag "owner@" "group@" "everyone@"
MYTESTFILE=$STF_SUITE/include/default.cfg
log_assert "Verify that the permission of write_xattr for " \
"owner/group/everyone while remove extended attributes are correct."
log_onexit cleanup
function operate_node #user node acl
{
typeset user=$1
typeset node=$2
typeset acl_t=$3
typeset ret
if [[ $user == "" || $node == "" ]]; then
log_fail "user, node are not defined."
fi
chgusr_exec $user $RUNAT $node $RM -f attr.0 ; ret=$?
if [[ $ret -eq 0 ]]; then
log_must cleanup_test_files $TESTDIR/basedir
log_must $TAR xpf@ $TESTDIR/$ARCHIVEFILE
fi
return $ret
}
function logname #acl_target owner user
{
typeset acl_target=$1
typeset owner=$2
typeset user=$3
typeset ret="log_mustnot"
# To super user, read and write deny permission was override.
if [[ $user == root || $owner == $user ]] then
ret="log_must"
fi
print $ret
}
function check_chmod_results #node flag acl_target owner g_usr o_usr
{
typeset node=$1
typeset flag=$2
typeset acl_target=$2:$3
typeset owner=$4
typeset g_usr=$5
typeset o_usr=$6
typeset log
if [[ $flag == "owner@" || $flag == "everyone@" ]]; then
log=$(logname $acl_target $owner $ZFS_ACL_CUR_USER)
$log operate_node $ZFS_ACL_CUR_USER $node $acl_target
fi
if [[ $flag == "group@" || $flag == "everyone@" ]]; then
log=$(logname $acl_target $owner $g_usr)
$log operate_node $g_usr $node $acl_target
fi
if [[ $flag == "everyone@" ]]; then
log=$(logname $acl_target $owner $o_usr)
$log operate_node $o_usr $node $acl_target
fi
}
function test_chmod_basic_access #node owner g_usr o_usr
{
typeset node=${1%/}
typeset owner=$2
typeset g_usr=$3
typeset o_usr=$4
typeset flag acl_p acl_t parent
parent=${node%/*}
for flag in ${a_flag[@]}; do
for acl_t in "${a_access[@]}"; do
log_must usr_exec $CHMOD A+$flag:$acl_t $node
log_must $TAR cpf@ $TESTDIR/$ARCHIVEFILE basedir
check_chmod_results "$node" "$flag" \
"$acl_t" "$owner" "$g_usr" "$o_usr"
log_must usr_exec $CHMOD A0- $node
done
done
}
function setup_test_files #base_node user group
{
typeset base_node=$1
typeset user=$2
typeset group=$3
cleanup_test_files $base_node
log_must $MKDIR -p $base_node
log_must $CHOWN $user:$group $base_node
log_must set_cur_usr $user
# Prepare all files/sub-dirs for testing.
file0=$base_node/testfile_rm
dir0=$base_node/testdir_rm
log_must usr_exec $TOUCH $file0
log_must usr_exec $CHMOD 444 $file0
log_must usr_exec $RUNAT $file0 $CP $MYTESTFILE attr.0
log_must usr_exec $MKDIR -p $dir0
log_must usr_exec $CHMOD 555 $dir0
log_must usr_exec $RUNAT $dir0 $CP $MYTESTFILE attr.0
log_must usr_exec $CHMOD 555 $base_node
return 0
}
function cleanup_test_files #base_node
{
typeset base_node=$1
if [[ -d $base_node ]]; then
log_must $RM -rf $base_node
elif [[ -e $base_node ]]; then
log_must $RM -f $base_node
fi
return 0
}
typeset cwd=$PWD
typeset ARCHIVEFILE=archive.tar
test_requires RUNAT ZFS_XATTR
typeset -i i=0
typeset -i j=0
typeset target
while (( i < ${#users[@]} )); do
setup_test_files $TESTDIR/basedir ${users[i]} ${users[((i+1))]}
cd $TESTDIR
j=0
while (( j < 1 )); do
eval target=\$file$j
test_chmod_basic_access $target ${users[i]} \
"${users[((i+2))]}" "${users[((i+3))]}"
eval target=\$dir$j
test_chmod_basic_access $target ${users[i]} \
"${users[((i+2))]}" "${users[((i+3))]}"
(( j = j + 1 ))
done
(( i += 4 ))
done
log_pass "Verify that the permission of write_xattr for " \
"owner/group/everyone while remove extended attributes are correct."

View File

@ -0,0 +1,115 @@
#!/usr/local/bin/ksh93 -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# $FreeBSD$
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "@(#)zfs_acl_cp_001_pos.ksh 1.2 07/01/09 SMI"
#
. $STF_SUITE/tests/acl/acl_common.kshlib
################################################################################
#
# __stc_assertion_start
#
# ID: zfs_acl_cp_001_pos
#
# DESCRIPTION:
# Verify that '/bin/cp [-p]' supports ZFS ACL
#
# STRATEGY:
# 1. Create file and directory in zfs filesystem
# 2. Set special ACE to the file and directory
# 3. Copy the file/directory within and across zfs file system
# 4. Verify that the ACL of file/directroy is not changed, when you are
# inserting an ACL with a user: or group: entry on the top.
# (abstractions entry are treated special, since they represent the
# traditional permission bit mapping.)
#
# TESTABILITY: explicit
#
# TEST_AUTOMATION_LEVEL: automated
#
# CODING_STATUS: COMPLETED (2005-10-11)
#
# __stc_assertion_end
#
################################################################################
verify_runnable "both"
function cleanup
{
if datasetexists $TESTPOOL/$TESTFS1; then
log_must $ZFS destroy -f $TESTPOOL/$TESTFS1
fi
[[ -d $TESTDIR1 ]] && log_must $RM -rf $TESTDIR1
[[ -d $TESTDIR ]] && log_must $RM -rf $TESTDIR/*
}
log_assert "Verify that '$CP [-p]' supports ZFS ACLs."
log_onexit cleanup
test_requires ZFS_ACL
log_note "Create the second zfs file system: $TESTPOOL/$TESTFS1."
log_must $ZFS create $TESTPOOL/$TESTFS1
log_must $ZFS set mountpoint=$TESTDIR1 $TESTPOOL/$TESTFS1
log_must $ZFS set aclmode=passthrough $TESTPOOL/$TESTFS1
log_must $CHMOD 777 $TESTDIR1
# Define target directory.
dstdir=$TESTDIR1/dstdir.${TESTCASE_ID}
for user in root $ZFS_ACL_STAFF1; do
# Set the current user
log_must set_cur_usr $user
for obj in $testfile $testdir; do
# Create source object and target directroy
log_must usr_exec $TOUCH $testfile
log_must usr_exec $MKDIR $testdir $dstdir
# Add the new ACE on the head.
log_must usr_exec $CHMOD \
A0+user:$ZFS_ACL_OTHER1:read_acl:deny $obj
cmd_str="$CP -p"
[[ -d $obj ]] && cmd_str="$CP -rp"
log_must usr_exec $cmd_str $obj $dstdir
log_must usr_exec $cmd_str $obj $TESTDIR1
for dir in $dstdir $TESTDIR1; do
log_must compare_modes $obj $dir/${obj##*/}
log_must compare_acls $obj $dir/${obj##*/}
done
# Delete all the test file and directory
log_must usr_exec $RM -rf $TESTDIR/* $TESTDIR1/*
done
done
log_pass "'$CP [-p]' succeeds to support ZFS ACLs."

View File

@ -0,0 +1,121 @@
#!/usr/local/bin/ksh93 -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# $FreeBSD$
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "@(#)zfs_acl_cp_002_pos.ksh 1.2 07/01/09 SMI"
#
. $STF_SUITE/tests/acl/acl_common.kshlib
################################################################################
#
# __stc_assertion_start
#
# ID: zfs_acl_cp_002_pos
#
# DESCRIPTION:
# Verify that '/bin/cp [-p@]' supports ZFS ACL & xattrs
#
# STRATEGY:
# 1. Create file and directory in zfs filesystem
# 2. Set special ACE to the file and directory
# 3. Create xattr of the file and directory
# 4. Copy the file/directory within and across zfs file system
# 5. Verify that the ACL & xattrs of the file/directroy is not changed,
# when you are inserting an ACL with user: or group: entry on the top.
# (abstractions entry are treated special, since they represent the
# traditional permission bit mapping.)
#
# TESTABILITY: explicit
#
# TEST_AUTOMATION_LEVEL: automated
#
# CODING_STATUS: COMPLETED (2005-10-11)
#
# __stc_assertion_end
#
################################################################################
verify_runnable "both"
function cleanup
{
if datasetexists $TESTPOOL/$TESTFS1; then
log_must $ZFS destroy -f $TESTPOOL/$TESTFS1
fi
[[ -d $TESTDIR1 ]] && log_must $RM -rf $TESTDIR1
[[ -d $TESTDIR ]] && log_must $RM -rf $TESTDIR/*
}
log_assert "Verify that '$CP [-p]' supports ZFS ACLs."
log_onexit cleanup
test_requires RUNAT ZFS_ACL ZFS_XATTR
log_note "Create the second zfs file system: $TESTPOOL/$TESTFS1."
log_must $ZFS create $TESTPOOL/$TESTFS1
log_must $ZFS set mountpoint=$TESTDIR1 $TESTPOOL/$TESTFS1
log_must $ZFS set aclmode=passthrough $TESTPOOL/$TESTFS1
log_must $CHMOD 777 $TESTDIR1
# Define target directory.
dstdir=$TESTDIR1/dstdir.${TESTCASE_ID}
MYTESTFILE=$STF_SUITE/include/default.cfg
for user in root $ZFS_ACL_STAFF1; do
# Set the current user
log_must set_cur_usr $user
for obj in $testfile $testdir; do
# Create source object and target directroy
log_must usr_exec $TOUCH $testfile
log_must usr_exec $MKDIR $testdir $dstdir
log_must usr_exec $RUNAT $testfile $CP $MYTESTFILE attr.0
log_must usr_exec $RUNAT $testdir $CP $MYTESTFILE attr.0
# Add the new ACE on the head.
log_must usr_exec $CHMOD \
A0+user:$ZFS_ACL_OTHER1:read_acl:deny $obj
cmd_str="$CP -p@"
[[ -d $obj ]] && cmd_str="$CP -rp@"
log_must usr_exec $cmd_str $obj $dstdir
log_must usr_exec $cmd_str $obj $TESTDIR1
for dir in $dstdir $TESTDIR1; do
log_must compare_modes $obj $dir/${obj##*/}
log_must compare_acls $obj $dir/${obj##*/}
log_must compare_xattrs $obj $dir/${obj##*/}
done
# Delete all the test file and directory
log_must usr_exec $RM -rf $TESTDIR/* $TESTDIR1/*
done
done
log_pass "'$CP [-p@]' succeeds to support ZFS ACLs."

View File

@ -0,0 +1,140 @@
#!/usr/local/bin/ksh93 -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# $FreeBSD$
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "@(#)zfs_acl_cpio_001_pos.ksh 1.2 07/01/09 SMI"
#
. $STF_SUITE/tests/acl/acl_common.kshlib
################################################################################
#
# __stc_assertion_start
#
# ID: zfs_acl_cpio_001_pos
#
# DESCRIPTION:
# Verify that '$CPIO' command with -P option supports to archive ZFS ACLs
#
# STRATEGY:
# 1. Create file and directory in zfs filesystem
# 2. Add new ACE in ACL or change mode of file and directory
# 3. Use $CPIO to archive file and directory
# 4. Extract the archive file
# 5. Verify that the restored ACLs of file and directory identify
# with the origional ones.
#
# TESTABILITY: explicit
#
# TEST_AUTOMATION_LEVEL: automated
#
# CODING_STATUS: COMPLETED (2005-09-26)
#
# __stc_assertion_end
#
################################################################################
verify_runnable "both"
function cleanup
{
if datasetexists $TESTPOOL/$TESTFS1; then
log_must $ZFS destroy -f $TESTPOOL/$TESTFS1
fi
if (( ${#orig_dir} != 0 )); then
cd $orig_dir
fi
[[ -d $TESTDIR1 ]] && log_must $RM -rf $TESTDIR1
[[ -d $TESTDIR ]] && log_must $RM -rf $TESTDIR/*
}
log_assert "Verify that '$CPIO' command supports to archive ZFS ACLs."
log_onexit cleanup
test_requires ZFS_ACL
set -A ops "A+everyone@:execute:allow" \
"A3+user:$ZFS_ACL_OTHER1:write_data:deny" \
"A5+group:$ZFS_ACL_OTHER_GROUP:read_data:deny" \
"A0+user:$ZFS_ACL_OTHER1:write_data:deny" \
"A1=user:$ZFS_ACL_STAFF1:write_data:deny" \
"A5=group:$ZFS_ACL_STAFF_GROUP:write_data:deny"
log_note "Create second zfs file system to restore the cpio archive."
log_must $ZFS create $TESTPOOL/$TESTFS1
log_must $ZFS set mountpoint=$TESTDIR1 $TESTPOOL/$TESTFS1
log_must $CHMOD 777 $TESTDIR1
# Define test fine and record the original directory.
CPIOFILE=cpiofile.${TESTCASE_ID}
file=$TESTFILE0
dir=dir.${TESTCASE_ID}
orig_dir=$PWD
typeset user
for user in root $ZFS_ACL_STAFF1; do
# Set the current user
log_must set_cur_usr $user
typeset -i i=0
while (( i < ${#ops[*]} )); do
log_note "Create file $file and directory $dir " \
"in zfs filesystem. "
cd $TESTDIR
log_must usr_exec $TOUCH $file
log_must usr_exec $MKDIR $dir
log_note "Change the ACLs of file and directory with " \
"'$CHMOD ${ops[i]}'."
for obj in $file $dir; do
log_must usr_exec $CHMOD ${ops[i]} $obj
done
log_note "Archive the file and directory."
cd $TESTDIR
log_must eval "usr_exec $LS | " \
"usr_exec $CPIO -ocP -O $CPIOFILE > /dev/null 2>&1"
log_note "Restore the cpio archive."
log_must usr_exec $MV $CPIOFILE $TESTDIR1
cd $TESTDIR1
log_must eval "usr_exec $CAT $CPIOFILE | " \
"usr_exec $CPIO -icP > /dev/null 2>&1"
log_note "Verify that the ACLs of restored file/directory " \
"have no changes."
for obj in $file $dir; do
log_must compare_modes $TESTDIR/$obj $TESTDIR1/$obj
log_must compare_acls $TESTDIR/$obj $TESTDIR1/$obj
done
log_must usr_exec $RM -rf $TESTDIR/* $TESTDIR1/*
(( i = i + 1 ))
done
done
log_pass "'$CPIO' command succeeds to support ZFS ACLs."

View File

@ -0,0 +1,144 @@
#!/usr/local/bin/ksh93 -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# $FreeBSD$
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "@(#)zfs_acl_cpio_002_pos.ksh 1.2 07/01/09 SMI"
#
. $STF_SUITE/tests/acl/acl_common.kshlib
################################################################################
#
# __stc_assertion_start
#
# ID: zfs_acl_cpio_002_pos
#
# DESCRIPTION:
# Verify that '$CPIO' command with -P@ option supports to archive ZFS ACLs
#
# STRATEGY:
# 1. Create file and directory in zfs filesystem
# 2. Add new ACE in ACL or change mode of file and directory
# 3. Create xattr of the file and directory
# 4. Use $CPIO to archive file and directory
# 5. Extract the archive file
# 6. Verify that the restored ACLs of file and directory identify
# with the origional ones.
#
# TESTABILITY: explicit
#
# TEST_AUTOMATION_LEVEL: automated
#
# CODING_STATUS: COMPLETED (2005-09-26)
#
# __stc_assertion_end
#
################################################################################
verify_runnable "both"
function cleanup
{
if datasetexists $TESTPOOL/$TESTFS1; then
log_must $ZFS destroy -f $TESTPOOL/$TESTFS1
fi
if (( ${#orig_dir} != 0 )); then
cd $orig_dir
fi
[[ -d $TESTDIR1 ]] && log_must $RM -rf $TESTDIR1
[[ -d $TESTDIR ]] && log_must $RM -rf $TESTDIR/*
}
log_assert "Verify that '$CPIO' command supports to archive ZFS ACLs & xattrs."
log_onexit cleanup
test_requires RUNAT ZFS_ACL ZFS_XATTR
set -A ops "A+everyone@:execute:allow" \
"A3+user:$ZFS_ACL_OTHER1:write_data:deny" \
"A5+group:$ZFS_ACL_OTHER_GROUP:read_data:deny" \
"A0+user:$ZFS_ACL_OTHER1:write_data:deny"
log_note "Create second zfs file system to restore the cpio archive."
log_must $ZFS create $TESTPOOL/$TESTFS1
log_must $ZFS set mountpoint=$TESTDIR1 $TESTPOOL/$TESTFS1
log_must $CHMOD 777 $TESTDIR1
# Define test fine and record the original directory.
CPIOFILE=cpiofile.${TESTCASE_ID}
file=$TESTFILE0
dir=dir.${TESTCASE_ID}
orig_dir=$PWD
MYTESTFILE=$STF_SUITE/include/default.cfg
typeset user
for user in root $ZFS_ACL_STAFF1; do
# Set the current user
log_must set_cur_usr $user
typeset -i i=0
while (( i < ${#ops[*]} )); do
log_note "Create file $file and directory $dir " \
"in zfs filesystem. "
cd $TESTDIR
log_must usr_exec $TOUCH $file
log_must usr_exec $MKDIR $dir
log_must usr_exec $RUNAT $file $CP $MYTESTFILE attr.0
log_must usr_exec $RUNAT $dir $CP $MYTESTFILE attr.0
log_note "Change the ACLs of file and directory with " \
"'$CHMOD ${ops[i]}'."
for obj in $file $dir; do
log_must usr_exec $CHMOD ${ops[i]} $obj
done
log_note "Archive the file and directory."
cd $TESTDIR
log_must eval "usr_exec $LS | " \
"usr_exec $CPIO -ocP@ -O $CPIOFILE > /dev/null 2>&1"
log_note "Restore the cpio archive."
log_must usr_exec $MV $CPIOFILE $TESTDIR1
cd $TESTDIR1
log_must eval "usr_exec $CAT $CPIOFILE | " \
"usr_exec $CPIO -icP@ > /dev/null 2>&1"
log_note "Verify that the ACLs of restored file/directory " \
"have no changes."
for obj in $file $dir; do
log_must compare_modes $TESTDIR/$obj $TESTDIR1/$obj
log_must compare_acls $TESTDIR/$obj $TESTDIR1/$obj
log_must compare_xattrs $TESTDIR/$obj $TESTDIR1/$obj
done
log_must usr_exec $RM -rf $TESTDIR/* $TESTDIR1/*
(( i = i + 1 ))
done
done
log_pass "'$CPIO' command succeeds to support ZFS ACLs & xattrs."

View File

@ -0,0 +1,144 @@
#!/usr/local/bin/ksh93 -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# $FreeBSD$
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "@(#)zfs_acl_find_001_pos.ksh 1.2 07/01/09 SMI"
#
. $STF_SUITE/tests/acl/acl_common.kshlib
################################################################################
#
# __stc_assertion_start
#
# ID: zfs_acl_find_001_pos
#
# DESCRIPTION:
# Verify that '$FIND' command with '-ls' and '-acl' options supports ZFS ACL
#
# STRATEGY:
# 1. Create 5 files and 5 directories in zfs filesystem
# 2. Select a file or directory and add a few ACEs to it
# 3. Use $FIND -ls to check the "+" existen only with the selected file or
# directory
# 4. Use $FIND -acl to check only the selected file/directory in the list
#
# TESTABILITY: explicit
#
# TEST_AUTOMATION_LEVEL: automated
#
# CODING_STATUS: COMPLETED (2005-09-26)
#
# __stc_assertion_end
#
################################################################################
verify_runnable "both"
function cleanup
{
[[ -d $TESTDIR ]] && $RM -rf $TESTDIR/*
(( ${#cwd} != 0 )) && cd $cwd
(( ${#mask} != 0 )) && $UMASK $mask
}
function find_ls_acl #<opt> <obj>
{
typeset opt=$1 # -ls or -acl
typeset obj=$2
typeset rst_str=""
if [[ $opt == "ls" ]]; then
rst_str=`$FIND . -ls | $GREP "+" | $AWK '{print $11}'`
else
rst_str=`$FIND . -acl`
fi
if [[ $rst_str == "./$obj" ]]; then
return 0
else
return 1
fi
}
log_assert "Verify that '$FIND' command supports ZFS ACLs."
log_onexit cleanup
test_requires ZFS_ACL
set -A ops " A+everyone@:read_data:allow" \
" A+owner@:write_data:allow"
f_base=testfile.${TESTCASE_ID} # Base file name for tested files
d_base=testdir.${TESTCASE_ID} # Base directory name for tested directory
cwd=$PWD
mask=`$UMASK`
log_note "Create five files and directories in the zfs filesystem. "
cd $TESTDIR
$UMASK 0777
typeset -i i=0
while (( i < 5 ))
do
log_must $TOUCH ${f_base}.$i
log_must $MKDIR ${d_base}.$i
(( i = i + 1 ))
done
for obj in ${f_base}.3 ${d_base}.3
do
i=0
while (( i < ${#ops[*]} ))
do
log_must $CHMOD ${ops[i]} $obj
(( i = i + 1 ))
done
for opt in "ls" "acl"
do
log_must find_ls_acl $opt $obj
done
log_note "Check the file access permission according to the added ACEs"
if [[ ! -r $obj || ! -w $obj ]]; then
log_fail "The added ACEs for $obj cannot be represented in " \
"mode."
fi
log_note "Remove the added ACEs from ACL."
i=0
while (( i < ${#ops[*]} ))
do
log_must $CHMOD A0- $obj
(( i = i + 1 ))
done
done
log_pass "'$FIND' command succeeds to support ZFS ACLs."

View File

@ -0,0 +1,124 @@
#!/usr/local/bin/ksh93 -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# $FreeBSD$
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "@(#)zfs_acl_ls_001_pos.ksh 1.3 07/07/31 SMI"
#
. $STF_SUITE/tests/acl/acl_common.kshlib
################################################################################
#
# __stc_assertion_start
#
# ID: zfs_acl_ls_001_pos
#
# DESCRIPTION:
# Verify that '/bin/ls' command option supports ZFS ACL
#
# STRATEGY:
# 1. Create file and directory in zfs filesystem
# 2. Verify that 'ls [-dv]' can list the ACEs of ACL of
# file/directroy
# 3. Change the file/directory's acl
# 4. Verify that 'ls -l' can use the '+' to indicate the non-trivial
# acl.
#
# TESTABILITY: explicit
#
# TEST_AUTOMATION_LEVEL: automated
#
# CODING_STATUS: COMPLETED (2005-10-11)
#
# __stc_assertion_end
#
################################################################################
verify_runnable "both"
function cleanup
{
(( ${#cwd} != 0 )) && cd $cwd
[[ -d $TESTDIR ]] && log_must $RM -rf $TESTDIR/*
(( ${#mask} != 0 )) && log_must $UMASK $mask
}
log_assert "Verify that '$LS' command supports ZFS ACLs."
log_onexit cleanup
test_requires ZFS_ACL
file=$TESTFILE0
dir=dir.${TESTCASE_ID}
cwd=$PWD
mask=`$UMASK`
spec_ace="everyone@:write_acl:allow"
$UMASK 0022
log_note "Create file and directory in the zfs filesystem. "
cd $TESTDIR
log_must $TOUCH $file
log_must $MKDIR $dir
log_note "Verify that '$LS [-dv]' can list file/directory ACEs of its acl."
typeset -i ace_num=0
for obj in $file $dir
do
typeset ls_str=""
if [[ -f $obj ]]; then
ls_str="$LS -v"
else
ls_str="$LS -dv"
fi
for ace_type in "owner@" "group@" "everyone@"
do
$ls_str $obj | $GREP $ace_type > /dev/null 2>&1
(( $? == 0 )) && (( ace_num += 1 ))
done
(( ace_num < 1 )) && \
log_fail "'$LS [-dv] fails to list file/directroy acls."
done
log_note "Verify that '$LS [-dl] [-dv]' can output '+' to indicate " \
"the acl existent."
for obj in $file $dir
do
$CHMOD A0+$spec_ace $obj
log_must eval "$LS -ld -vd $obj | $GREP "+" > /dev/null"
log_must plus_sign_check_v $obj
log_must eval "$LS -ld -vd $obj | $GREP $spec_ace > /dev/null"
log_must plus_sign_check_l $obj
done
log_pass "'$LS' command succeeds to support ZFS ACLs."

View File

@ -0,0 +1,190 @@
#!/usr/local/bin/ksh93 -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# $FreeBSD$
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "@(#)zfs_acl_mv_001_pos.ksh 1.2 07/01/09 SMI"
#
. $STF_SUITE/tests/acl/acl_common.kshlib
################################################################################
#
# __stc_assertion_start
#
# ID: zfs_acl_mv_001_pos
#
# DESCRIPTION:
# Verify that '/bin/mv' supports ZFS ACL
#
# STRATEGY:
# 1. Create file and directory in zfs filesystem
# 2. Set special ACE to the file and directory
# 3. Copy the file/directory within and across zfs file system
# 4. Verify that the ACL of file/directroy is not changed
#
# TESTABILITY: explicit
#
# TEST_AUTOMATION_LEVEL: automated
#
# CODING_STATUS: COMPLETED (2005-10-11)
#
# __stc_assertion_end
#
################################################################################
verify_runnable "both"
function cleanup
{
(( ${#cwd} != 0 )) && cd $cwd
[[ -d $TESTDIR ]] && log_must $RM -rf $TESTDIR/*
[[ -d $TESTDIR1 ]] && log_must $RM -rf $TESTDIR1
(( ${#mask} != 0 )) && log_must $UMASK $mask
}
function testing_mv #<flag for file|dir> <file1|dir1> <file2|dir2>
{
typeset flag=$1
set -A obj $2 $3
typeset -i i=0
typeset orig_acl=""
typeset orig_mode=""
typeset dst_acl=""
typeset dst_mode=""
if [[ $flag == "f" ]]; then
while (( i < ${#obj[*]} ))
do
orig_acl="$(get_acl ${obj[i]})"
orig_mode="$(get_mode ${obj[i]})"
if (( i < 1 )); then
log_must $MV ${obj[i]} $dst_file
dst_acl=$(get_acl $dst_file)
dst_mode=$(get_mode $dst_file)
else
log_must $MV ${obj[i]} $TESTDIR1
dst_acl=$(get_acl $TESTDIR1/${obj[i]})
dst_mode=$(get_mode $TESTDIR1/${obj[i]})
fi
if [[ "$dst_mode" != "$orig_mode" ]] || \
[[ "$dst_acl" != "$orig_acl" ]]; then
log_fail "$MV fails to keep the acl for file."
fi
(( i = i + 1 ))
done
else
while (( i < ${#obj[*]} ))
do
typeset orig_nested_acl=""
typeset orig_nested_mode=""
typeset dst_nested_acl=""
typeset dst_nested_mode=""
orig_acl=$(get_acl ${obj[i]})
orig_mode=$(get_mode ${obj[i]})
orig_nested_acl=$(get_acl ${obj[i]}/$nestedfile)
orig_nested_mode=$(get_mode ${obj[i]}/$nestedfile)
if (( i < 1 )); then
log_must $MV ${obj[i]} $dst_dir
dst_acl=$(get_acl $dst_dir)
dst_mode=$(get_mode $dst_dir)
dst_nested_acl=$(get_acl $dst_dir/$nestedfile)
dst_nested_mode=$(get_mode $dst_dir/$nestedfile)
else
log_must $MV ${obj[i]} $TESTDIR1
dst_acl=$(get_acl $TESTDIR1/${obj[i]})
dst_mode=$(get_mode $TESTDIR1/${obj[i]})
dst_nested_acl=$(get_acl \
$TESTDIR1/${obj[i]}/$nestedfile)
dst_nested_mode=$(get_mode \
$TESTDIR1/${obj[i]}/$nestedfile)
fi
if [[ "$orig_mode" != "$dst_mode" ]] || \
[[ "$orig_acl" != "$dst_acl" ]] || \
[[ "$dst_nested_mode" != "$orig_nested_mode" ]] || \
[[ "$dst_nested_acl" != "$orig_nested_acl" ]]; then
log_fail "$MV fails to recursively keep the acl for " \
"directory."
fi
(( i = i + 1 ))
done
fi
}
log_assert "Verify that '$MV' supports ZFS ACLs."
log_onexit cleanup
test_requires ZFS_ACL
spec_ace="everyone@:execute:allow"
set -A orig_file "origfile1.${TESTCASE_ID}" "origfile2.${TESTCASE_ID}"
set -A orig_dir "origdir1.${TESTCASE_ID}" "origdir2.${TESTCASE_ID}"
nestedfile="nestedfile.${TESTCASE_ID}"
dst_file=dstfile.${TESTCASE_ID}
dst_dir=dstdir.${TESTCASE_ID}
cwd=$PWD
mask=`$UMASK`
$UMASK 0022
#
# This assertion should only test 'mv' within the same filesystem
#
TESTDIR1=$TESTDIR/testdir1${TESTCASE_ID}
[[ ! -d $TESTDIR1 ]] && \
log_must $MKDIR -p $TESTDIR1
log_note "Create files and directories and set special ace on them for testing. "
cd $TESTDIR
typeset -i i=0
while (( i < ${#orig_file[*]} ))
do
log_must $TOUCH ${orig_file[i]}
log_must $CHMOD A0+$spec_ace ${orig_file[i]}
(( i = i + 1 ))
done
i=0
while (( i < ${#orig_dir[*]} ))
do
log_must $MKDIR ${orig_dir[i]}
log_must $TOUCH ${orig_dir[i]}/$nestedfile
for obj in ${orig_dir[i]} ${orig_dir[i]}/$nestedfile; do
log_must $CHMOD A0+$spec_ace $obj
done
(( i = i + 1 ))
done
testing_mv "f" ${orig_file[0]} ${orig_file[1]}
testing_mv "d" ${orig_dir[0]} ${orig_dir[1]}
log_pass "'$MV' succeeds to support ZFS ACLs."

View File

@ -0,0 +1,124 @@
#!/usr/local/bin/ksh93 -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# $FreeBSD$
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "@(#)zfs_acl_tar_001_pos.ksh 1.2 07/01/09 SMI"
#
. $STF_SUITE/tests/acl/acl_common.kshlib
################################################################################
#
# __stc_assertion_start
#
# ID: zfs_acl_tar_001_pos
#
# DESCRIPTION:
# Verify that '$TAR' command with -p option supports to archive ZFS ACLs
#
# STRATEGY:
# 1. Create file and directory in zfs filesystem
# 2. Add new ACE in ACL of file and directory
# 3. Use $TAR to archive file and directory
# 4. Extract the archive file
# 5. Verify that the restored ACLs of file and directory identify
# with the origional ones.
#
# TESTABILITY: explicit
#
# TEST_AUTOMATION_LEVEL: automated
#
# CODING_STATUS: COMPLETED (2005-09-26)
#
# __stc_assertion_end
#
################################################################################
verify_runnable "both"
function cleanup
{
if datasetexists $TESTPOOL/$TESTFS1; then
log_must $ZFS destroy -f $TESTPOOL/$TESTFS1
fi
(( ${#cwd} != 0 )) && cd $cwd
[[ -d $TESTDIR1 ]] && log_must $RM -rf $TESTDIR1
[[ -d $TESTDIR/ ]] && log_must $RM -rf $TESTDIR/*
}
log_assert "Verify that '$TAR' command supports to archive ZFS ACLs."
log_onexit cleanup
test_requires ZFS_ACL
set -A ops " A+everyone@:execute:allow" "a-x" "777"
TARFILE=tarfile.${TESTCASE_ID}.tar
file=$TESTFILE0
dir=dir.${TESTCASE_ID}
cwd=$PWD
log_note "Create second zfs file system to restore the tar archive."
log_must $ZFS create $TESTPOOL/$TESTFS1
[[ ! -d $TESTDIR1 ]] && \
log_must $MKDIR -p $TESTDIR1
log_must $ZFS set mountpoint=$TESTDIR1 $TESTPOOL/$TESTFS1
log_note "Create a file: $file, and directory: $dir, in zfs filesystem. "
cd $TESTDIR
log_must $TOUCH $file
log_must $MKDIR $dir
typeset -i i=0
while (( i < ${#ops[*]} ))
do
log_note "Change the ACLs of file and directory with " \
"'$CHMOD ${ops[i]}'."
cd $TESTDIR
for obj in $file $dir; do
log_must $CHMOD ${ops[i]} $obj
done
log_note "Archive the file and directory."
log_must $TAR cpf $TARFILE $file $dir
log_note "Restore the tar archive."
log_must $MV $TARFILE $TESTDIR1
cd $TESTDIR1
log_must $TAR xpf $TARFILE
log_note "Verify the ACLs of restored file/directory have no changes."
for obj in $file $dir; do
log_must compare_modes $TESTDIR/$obj $TESTDIR1/$obj
log_must compare_acls $TESTDIR/$obj $TESTDIR1/$obj
done
log_must $RM -rf $TESTDIR1/*
(( i = i + 1 ))
done
log_pass "'$TAR' command succeeds to support ZFS ACLs."

View File

@ -0,0 +1,131 @@
#!/usr/local/bin/ksh93 -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# $FreeBSD$
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "@(#)zfs_acl_tar_002_pos.ksh 1.2 07/01/09 SMI"
#
. $STF_SUITE/tests/acl/acl_common.kshlib
################################################################################
#
# __stc_assertion_start
#
# ID: zfs_acl_tar_002_pos
#
# DESCRIPTION:
# Verify that '$TAR' command with -p@ option supports to archive ZFS ACLs
# & xattrs
#
# STRATEGY:
# 1. Create file and directory in zfs filesystem
# 2. Add new ACE in ACL of file and directory
# 3. Create xattr of the file and directory
# 4. Use $TAR cf@ to archive file and directory
# 5. Use $TAR xf@ to extract the archive file
# 6. Verify that the restored ACLs & xttrs of file and directory identify
# with the origional ones.
#
# TESTABILITY: explicit
#
# TEST_AUTOMATION_LEVEL: automated
#
# CODING_STATUS: COMPLETED (2005-12-16)
#
# __stc_assertion_end
#
################################################################################
verify_runnable "both"
function cleanup
{
if datasetexists $TESTPOOL/$TESTFS1; then
log_must $ZFS destroy -f $TESTPOOL/$TESTFS1
fi
(( ${#cwd} != 0 )) && cd $cwd
[[ -d $TESTDIR1 ]] && log_must $RM -rf $TESTDIR1
[[ -d $TESTDIR/ ]] && log_must $RM -rf $TESTDIR/*
}
log_assert "Verify that '$TAR' command supports to archive ZFS ACLs & xattrs."
log_onexit cleanup
test_requires RUNAT ZFS_ACL ZFS_XATTR
set -A ops " A+everyone@:execute:allow" "a-x" "777"
MYTESTFILE=$STF_SUITE/include/default.cfg
TARFILE=tarfile.${TESTCASE_ID}.tar
cwd=$PWD
log_note "Create second zfs file system to restore the tar archive."
log_must $ZFS create $TESTPOOL/$TESTFS1
[[ ! -d $TESTDIR1 ]] && \
log_must $MKDIR -p $TESTDIR1
log_must $ZFS set mountpoint=$TESTDIR1 $TESTPOOL/$TESTFS1
log_note "Create a file: $testfile, and directory: $testdir, in zfs filesystem. " \
"And prepare for there xattr files."
for user in root $ZFS_ACL_STAFF1; do
# Set the current user
log_must set_cur_usr $user
# Create source object and target directroy
cd $TESTDIR
log_must usr_exec $TOUCH $testfile
log_must usr_exec $MKDIR $testdir
log_must usr_exec $RUNAT $testfile $CP $MYTESTFILE attr.0
log_must usr_exec $RUNAT $testdir $CP $MYTESTFILE attr.0
# Add the new ACE on the head.
log_note "Change the ACLs of file and directory with " \
"'$CHMOD ${ops[0]}'."
log_must usr_exec $CHMOD ${ops[0]} $testfile
log_must usr_exec $CHMOD ${ops[0]} $testdir
log_note "Archive the file and directory."
log_must $TAR cpf@ $TARFILE ${testfile#$TESTDIR/} ${testdir#$TESTDIR/}
log_note "Restore the tar archive."
cd $TESTDIR1
log_must $TAR xpf@ $TESTDIR/$TARFILE
log_note "Verify the ACLs of restored file/directory have no changes."
for obj in $testfile $testdir; do
log_must compare_modes $obj $TESTDIR1/${obj##*/}
log_must compare_acls $obj $TESTDIR1/${obj##*/}
log_must compare_xattrs $obj $TESTDIR1/${obj##*/}
done
log_must $RM -rf $TESTDIR/* $TESTDIR1/*
done
log_pass "'$TAR' command succeeds to support ZFS ACLs."

Some files were not shown because too many files have changed in this diff Show More